Skip to content

Commit 36a7c00

Browse files
committed
Enable DUNE grid tests
For this to work it is additionally needed that * Entities return the correct number of faces (to count intersections in the tests) * The refinement does not throw. Instead, it returns false when it cannot make a refinement. * DUNE is at least version 2.10 due to https://gitlab.dune-project.org/core/dune-grid/-/merge_requests/734
1 parent 152ae9d commit 36a7c00

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

opm/grid/cpgrid/CpGridData.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,8 +1577,8 @@ void CpGridData::distributeGlobalGrid(CpGrid& grid,
15771577

15781578
// Compute partition type for points
15791579
computePointPartitionType();
1580-
1581-
computeCommunicationInterfaces(noExistingPoints);
1580+
1581+
computeCommunicationInterfaces(noExistingPoints);
15821582
#else // #if HAVE_MPI
15831583
static_cast<void>(grid);
15841584
static_cast<void>(view_data);
@@ -2065,9 +2065,9 @@ int CpGridData::sharedFaceTag(const std::vector<std::array<int,3>>& startIJK_2Pa
20652065
assert(endIJK_2Patches.size() == 2);
20662066

20672067
int faceTag = -1; // 0 represents I_FACE, 1 J_FACE, and 2 K_FACE. Use -1 for no sharing face case.
2068-
2068+
20692069
if (patchesShareFace(startIJK_2Patches, endIJK_2Patches)) {
2070-
2070+
20712071
const auto& detectSharing = [](const std::vector<int>& faceIdxs, const std::vector<int>& otherFaceIdxs){
20722072
bool faceIsShared = false;
20732073
for (const auto& face : faceIdxs) {
@@ -2080,7 +2080,7 @@ int CpGridData::sharedFaceTag(const std::vector<std::array<int,3>>& startIJK_2Pa
20802080
}
20812081
return faceIsShared; // should be false here
20822082
};
2083-
2083+
20842084
const auto& [iFalse, iTrue, jFalse, jTrue, kFalse, kTrue] = this->getBoundaryPatchFaces(startIJK_2Patches[0], endIJK_2Patches[0]);
20852085
const auto& [iFalseOther, iTrueOther, jFalseOther, jTrueOther, kFalseOther, kTrueOther] =
20862086
this->getBoundaryPatchFaces(startIJK_2Patches[1], endIJK_2Patches[1]);
@@ -2668,11 +2668,11 @@ CpGridData::refinePatch(const std::array<int,3>& cells_per_dim, const std::array
26682668
bool CpGridData::mark(int refCount, const cpgrid::Entity<0>& element)
26692669
{
26702670
if (refCount == -1) {
2671-
OPM_THROW(std::logic_error, "Coarsening is not supported yet.");
2671+
return false; // Coarsening is not supported yet.
26722672
}
26732673
// Prevent refinement if the cell has a non-neighbor connection (NNC).
26742674
if (hasNNCs({element.index()}) && (refCount == 1)) {
2675-
OPM_THROW(std::logic_error, "Refinement of cells with face representing an NNC is not supported yet.");
2675+
return false; // Refinement of cells with face representing an NNC is not supported yet
26762676
}
26772677
assert((refCount == 0) || (refCount == 1)); // Do nothing (0), Refine (1), Coarsen (-1) not supported yet.
26782678
if (mark_.empty()) {
@@ -2699,7 +2699,7 @@ bool CpGridData::preAdapt()
26992699
if (local_empty)
27002700
mark_.resize(size(0));
27012701
}
2702-
2702+
27032703
// Detect the maximum mark across processes, and rewrite
27042704
// the local entry in mark_, i.e.,
27052705
// mark_[ element.index() ] = max{ local marks in processes where this element belongs to}.

opm/grid/cpgrid/Entity.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,12 @@ unsigned int Entity<codim>::subEntities ( const unsigned int cc ) const
382382
if ( cc == 3 ) { // Get number of corners of the element.
383383
return 8;
384384
}
385+
if ( cc == 2 ) { // Get number of lines of the element.
386+
return 12;
387+
}
388+
if ( cc == 1 ) { // Get number of faces of the element.
389+
return 6;
390+
}
385391
}
386392
return 0;
387393
}

tests/test_cpgrid.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ using Dune::referenceElement; //grid check assume usage of Dune::Geometry
2424
#include <opm/input/eclipse/EclipseState/Grid/EclipseGrid.hpp>
2525
#include <opm/input/eclipse/Parser/Parser.hpp>
2626

27+
#include <dune/common/version.hh>
28+
2729
#include <iostream>
2830

2931
template <class GridView>
@@ -91,16 +93,17 @@ template <class Grid>
9193
void testGrid(Grid& grid, const std::string& name, const size_t nElem, const size_t nVertices)
9294
{
9395
typedef typename Grid::LeafGridView GridView;
94-
/*
9596

97+
#if DUNE_VERSION_GTE(DUNE_GRID, 2, 10)
9698
try {
9799
gridcheck( grid );
98100
}
99101
catch ( const Dune::Exception& e)
100102
{
101103
std::cerr << "Warning: " << e.what() << std::endl;
102104
}
103-
*/
105+
#endif
106+
104107
std::cout << name << std::endl;
105108

106109
testGridIteration( grid.leafGridView(), nElem );
@@ -166,7 +169,7 @@ int main(int argc, char** argv )
166169

167170
grid.processEclipseFormat(&ecl_grid, nullptr, false, false, false);
168171
testGrid( grid, "CpGrid_ecl", 8, 27 );
169-
172+
170173
const auto& grid_leafView = grid.leafGridView();
171174
Dune::CartesianIndexMapper<Grid> grid_cartMapper = Dune::CartesianIndexMapper<Grid>(grid);
172175
for (const auto& element: Dune::elements(grid_leafView)){
@@ -183,8 +186,8 @@ int main(int argc, char** argv )
183186
}
184187
std::cout << " " << '\n';
185188
}
186-
187-
189+
190+
188191
#endif
189192

190193
std::stringstream dgfFile;

0 commit comments

Comments
 (0)