fix test with dune-alugrid 2.7

This commit is contained in:
Arne Morten Kvarving 2022-11-14 16:34:30 +01:00
parent 9b6c493da4
commit c906b55a64

View File

@ -34,6 +34,13 @@
#if HAVE_DUNE_ALUGRID #if HAVE_DUNE_ALUGRID
#include <dune/alugrid/grid.hh> #include <dune/alugrid/grid.hh>
#if HAVE_MPI
template<int dim, Dune::ALUGridElementType elType>
using AluGrid = Dune::ALUGrid<dim, dim, elType, Dune::nonconforming, Dune::ALUGridMPIComm>;
#else
template<int dim, Dune::ALUGridElementType elType>
using AluGrid = Dune::ALUGrid<dim, dim, elType, Dune::nonconforming, Dune::ALUGridNoComm>;
#endif //HAVE_MPI
#endif #endif
#include <dune/common/version.hh> #include <dune/common/version.hh>
@ -107,7 +114,7 @@ void writeTetrahedronSubControlVolumes([[maybe_unused]] const Grid& grid)
#if HAVE_DUNE_ALUGRID #if HAVE_DUNE_ALUGRID
using GridView = typename Grid::LeafGridView; using GridView = typename Grid::LeafGridView;
using Grid2 = Dune::ALUGrid<dim, dim, Dune::cube, Dune::nonconforming>; using Grid2 = AluGrid<dim, Dune::cube>;
using GridView2 = typename Grid2::LeafGridView; using GridView2 = typename Grid2::LeafGridView;
using GridFactory2 = Dune::GridFactory<Grid2>; using GridFactory2 = Dune::GridFactory<Grid2>;
@ -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<GridView2>; using VtkWriter = Dune::VTKWriter<GridView2>;
VtkWriter writer(grid2.leafView(), Dune::VTK::conforming); VtkWriter writer(grid2->leafView(), Dune::VTK::conforming);
writer.write("tetrahedron-scvs", Dune::VTK::ascii); writer.write("tetrahedron-scvs", Dune::VTK::ascii);
#endif // HAVE_DUNE_ALUGRID #endif // HAVE_DUNE_ALUGRID
} }
@ -166,7 +173,7 @@ void writeTetrahedronSubControlVolumes([[maybe_unused]] const Grid& grid)
void testTetrahedron() void testTetrahedron()
{ {
#if HAVE_DUNE_ALUGRID #if HAVE_DUNE_ALUGRID
using Grid = Dune::ALUGrid<dim, dim, Dune::simplex, Dune::nonconforming>; using Grid = AluGrid<dim, Dune::simplex>;
using GridFactory = Dune::GridFactory<Grid>; using GridFactory = Dune::GridFactory<Grid>;
GridFactory gf; GridFactory gf;
Scalar corners[][3] = { { 0, 0, 0 }, { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } }; Scalar corners[][3] = { { 0, 0, 0 }, { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } };
@ -180,10 +187,10 @@ void testTetrahedron()
std::vector<unsigned int> v = { 0, 1, 2, 3 }; std::vector<unsigned int> v = { 0, 1, 2, 3 };
// in Dune >= 2.6 topologyIds seem to be opaque integers. WTF!? // in Dune >= 2.6 topologyIds seem to be opaque integers. WTF!?
gf.insertElement(Dune::GeometryType(/*topologyId=*/0, dim), v); 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. // write the sub-control volumes to a VTK file.
writeTetrahedronSubControlVolumes(grid); writeTetrahedronSubControlVolumes(*grid);
#endif // HAVE_DUNE_ALUGRID #endif // HAVE_DUNE_ALUGRID
} }
@ -192,8 +199,7 @@ void writeCubeSubControlVolumes([[maybe_unused]] const Grid& grid)
{ {
#if HAVE_DUNE_ALUGRID #if HAVE_DUNE_ALUGRID
using GridView = typename Grid::LeafGridView; using GridView = typename Grid::LeafGridView;
using Grid2 = AluGrid<dim, Dune::cube>;
using Grid2 = Dune::ALUGrid<dim, dim, Dune::cube, Dune::nonconforming>;
using GridView2 = typename Grid2::LeafGridView; using GridView2 = typename Grid2::LeafGridView;
using GridFactory2 = Dune::GridFactory<Grid2>; using GridFactory2 = Dune::GridFactory<Grid2>;
using Stencil = Opm::VcfvStencil<Scalar, GridView>; using Stencil = Opm::VcfvStencil<Scalar, GridView>;
@ -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<GridView2>; using VtkWriter = Dune::VTKWriter<GridView2>;
VtkWriter writer(grid2.leafView(), Dune::VTK::conforming); VtkWriter writer(grid2->leafView(), Dune::VTK::conforming);
writer.write("cube-scvs", Dune::VTK::ascii); writer.write("cube-scvs", Dune::VTK::ascii);
#endif // HAVE_DUNE_ALUGRID #endif // HAVE_DUNE_ALUGRID
} }
@ -252,7 +258,7 @@ void writeCubeSubControlVolumes([[maybe_unused]] const Grid& grid)
void testCube() void testCube()
{ {
#if HAVE_DUNE_ALUGRID #if HAVE_DUNE_ALUGRID
using Grid = Dune::ALUGrid<dim, dim, Dune::cube, Dune::nonconforming>; using Grid = AluGrid<dim, Dune::cube>;
using GridFactory = Dune::GridFactory<Grid>; using GridFactory = Dune::GridFactory<Grid>;
GridFactory gf; GridFactory gf;
Scalar corners[][3] = { { 0, 0, 0 }, Scalar corners[][3] = { { 0, 0, 0 },
@ -273,10 +279,10 @@ void testCube()
std::vector<unsigned int> v = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<unsigned int> v = { 0, 1, 2, 3, 4, 5, 6, 7 };
// in Dune >= 2.6 topologyIds seem to be opaque integers. WTF!? // in Dune >= 2.6 topologyIds seem to be opaque integers. WTF!?
gf.insertElement(Dune::GeometryType((1 << dim) - 1, dim), v); 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. // write the sub-control volumes to a VTK file.
writeCubeSubControlVolumes(grid); writeCubeSubControlVolumes(*grid);
#endif // HAVE_DUNE_ALUGRID #endif // HAVE_DUNE_ALUGRID
} }