From c906b55a640904fa5739f923c59a2b1eef6529aa Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 14 Nov 2022 16:34:30 +0100 Subject: [PATCH 1/3] fix test with dune-alugrid 2.7 --- tests/models/test_quadrature.cpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/tests/models/test_quadrature.cpp b/tests/models/test_quadrature.cpp index 9e885752f..3795600a8 100644 --- a/tests/models/test_quadrature.cpp +++ b/tests/models/test_quadrature.cpp @@ -34,6 +34,13 @@ #if HAVE_DUNE_ALUGRID #include +#if HAVE_MPI +template +using AluGrid = Dune::ALUGrid; +#else +template +using AluGrid = Dune::ALUGrid; +#endif //HAVE_MPI #endif #include @@ -107,7 +114,7 @@ void writeTetrahedronSubControlVolumes([[maybe_unused]] const Grid& grid) #if HAVE_DUNE_ALUGRID using GridView = typename Grid::LeafGridView; - using Grid2 = Dune::ALUGrid; + using Grid2 = AluGrid; using GridView2 = typename Grid2::LeafGridView; using GridFactory2 = Dune::GridFactory; @@ -156,9 +163,9 @@ void writeTetrahedronSubControlVolumes([[maybe_unused]] const Grid& grid) } } - const auto &grid2 = *gf2.createGrid(); + const auto grid2 = gf2.createGrid(); using VtkWriter = Dune::VTKWriter; - VtkWriter writer(grid2.leafView(), Dune::VTK::conforming); + VtkWriter writer(grid2->leafView(), Dune::VTK::conforming); writer.write("tetrahedron-scvs", Dune::VTK::ascii); #endif // HAVE_DUNE_ALUGRID } @@ -166,7 +173,7 @@ void writeTetrahedronSubControlVolumes([[maybe_unused]] const Grid& grid) void testTetrahedron() { #if HAVE_DUNE_ALUGRID - using Grid = Dune::ALUGrid; + using Grid = AluGrid; using GridFactory = Dune::GridFactory; GridFactory gf; Scalar corners[][3] = { { 0, 0, 0 }, { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } }; @@ -180,10 +187,10 @@ void testTetrahedron() std::vector v = { 0, 1, 2, 3 }; // in Dune >= 2.6 topologyIds seem to be opaque integers. WTF!? gf.insertElement(Dune::GeometryType(/*topologyId=*/0, dim), v); - const auto& grid = *gf.createGrid(); + const auto grid = gf.createGrid(); // write the sub-control volumes to a VTK file. - writeTetrahedronSubControlVolumes(grid); + writeTetrahedronSubControlVolumes(*grid); #endif // HAVE_DUNE_ALUGRID } @@ -192,8 +199,7 @@ void writeCubeSubControlVolumes([[maybe_unused]] const Grid& grid) { #if HAVE_DUNE_ALUGRID using GridView = typename Grid::LeafGridView; - - using Grid2 = Dune::ALUGrid; + using Grid2 = AluGrid; using GridView2 = typename Grid2::LeafGridView; using GridFactory2 = Dune::GridFactory; using Stencil = Opm::VcfvStencil; @@ -242,9 +248,9 @@ void writeCubeSubControlVolumes([[maybe_unused]] const Grid& grid) } } - const auto &grid2 = *gf2.createGrid(); + const auto grid2 = gf2.createGrid(); using VtkWriter = Dune::VTKWriter; - VtkWriter writer(grid2.leafView(), Dune::VTK::conforming); + VtkWriter writer(grid2->leafView(), Dune::VTK::conforming); writer.write("cube-scvs", Dune::VTK::ascii); #endif // HAVE_DUNE_ALUGRID } @@ -252,7 +258,7 @@ void writeCubeSubControlVolumes([[maybe_unused]] const Grid& grid) void testCube() { #if HAVE_DUNE_ALUGRID - using Grid = Dune::ALUGrid; + using Grid = AluGrid; using GridFactory = Dune::GridFactory; GridFactory gf; Scalar corners[][3] = { { 0, 0, 0 }, @@ -273,10 +279,10 @@ void testCube() std::vector v = { 0, 1, 2, 3, 4, 5, 6, 7 }; // in Dune >= 2.6 topologyIds seem to be opaque integers. WTF!? gf.insertElement(Dune::GeometryType((1 << dim) - 1, dim), v); - const auto& grid = *gf.createGrid(); + const auto grid = gf.createGrid(); // write the sub-control volumes to a VTK file. - writeCubeSubControlVolumes(grid); + writeCubeSubControlVolumes(*grid); #endif // HAVE_DUNE_ALUGRID } From a7249bee65302411272cd144565aa3b8a89f3742 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 14 Nov 2022 16:35:42 +0100 Subject: [PATCH 2/3] test_quadrature: remove support for dune < 2.6 --- tests/models/test_quadrature.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/tests/models/test_quadrature.cpp b/tests/models/test_quadrature.cpp index 3795600a8..970cb443a 100644 --- a/tests/models/test_quadrature.cpp +++ b/tests/models/test_quadrature.cpp @@ -123,11 +123,7 @@ void writeTetrahedronSubControlVolumes([[maybe_unused]] const Grid& grid) using Stencil = Opm::VcfvStencil; using Mapper = typename Stencil :: Mapper; -#if DUNE_VERSION_NEWER(DUNE_GRID, 2,6) Mapper mapper(gridView, Dune::mcmgVertexLayout()); -#else - Mapper mapper(gridView); -#endif Stencil stencil(gridView, mapper); auto eIt = gridView.template begin<0>(); @@ -207,13 +203,8 @@ void writeCubeSubControlVolumes([[maybe_unused]] const Grid& grid) GridFactory2 gf2; const auto &gridView = grid.leafView(); -#if DUNE_VERSION_NEWER(DUNE_GRID, 2,6) using VertexMapper = Dune::MultipleCodimMultipleGeomTypeMapper; VertexMapper vertexMapper(gridView, Dune::mcmgVertexLayout()); -#else - using VertexMapper = Dune::MultipleCodimMultipleGeomTypeMapper; - VertexMapper vertexMapper(gridView); -#endif Stencil stencil(gridView, vertexMapper); auto eIt = gridView.template begin<0>(); const auto &eEndIt = gridView.template end<0>(); @@ -309,11 +300,7 @@ void testQuadrature() using Stencil = Opm::VcfvStencil; using Mapper = typename Stencil :: Mapper; -#if DUNE_VERSION_NEWER(DUNE_GRID, 2,6) Mapper mapper(gridView, Dune::mcmgVertexLayout()); -#else - Mapper mapper(gridView); -#endif Stencil stencil(gridView, mapper); for (; eIt != eEndIt; ++eIt) { const auto &elemGeom = eIt->geometry(); From e61a5a3e2172507e7918703b5c34f396b4115446 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Tue, 15 Nov 2022 12:12:45 +0100 Subject: [PATCH 3/3] remove pointless assert unsigned is always positive --- opm/models/discretization/vcfv/vcfvstencil.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/models/discretization/vcfv/vcfvstencil.hh b/opm/models/discretization/vcfv/vcfvstencil.hh index 83017e189..cadba839b 100644 --- a/opm/models/discretization/vcfv/vcfvstencil.hh +++ b/opm/models/discretization/vcfv/vcfvstencil.hh @@ -1102,7 +1102,7 @@ public: */ Entity entity(unsigned dofIdx) const { - assert(0 <= dofIdx && dofIdx < numDof()); + assert(dofIdx < numDof()); return element_.template subEntity(static_cast(dofIdx)); }