Commit 1db890f8 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

problems with alugrid in dune 2.7

parent e6a25e28
...@@ -70,7 +70,6 @@ public: ...@@ -70,7 +70,6 @@ public:
std::vector<std::uint64_t> data; std::vector<std::uint64_t> data;
data.reserve(numPoints_); data.reserve(numPoints_);
GlobalIndexSet<GridView> globalIndexSet(gridView_, dim); GlobalIndexSet<GridView> globalIndexSet(gridView_, dim);
auto const& indexSet = gridView_.indexSet();
for (auto const& vertex : vertices(gridView_, partition)) { for (auto const& vertex : vertices(gridView_, partition)) {
data.emplace_back(globalIndexSet.index(vertex)); data.emplace_back(globalIndexSet.index(vertex));
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <dune/common/parallel/mpihelper.hh> // An initializer of MPI #include <dune/common/parallel/mpihelper.hh> // An initializer of MPI
#include <dune/common/filledarray.hh> #include <dune/common/filledarray.hh>
#include <dune/common/std/type_traits.hh>
#include <dune/common/test/testsuite.hh> #include <dune/common/test/testsuite.hh>
#include <dune/grid/uggrid.hh> #include <dune/grid/uggrid.hh>
...@@ -67,11 +68,11 @@ bool compare_files (std::string const& fn1, std::string const& fn2) ...@@ -67,11 +68,11 @@ bool compare_files (std::string const& fn1, std::string const& fn2)
} }
template <class G> struct HasParallelGridFactory : std::false_type {}; template <class GF>
#if DUNE_VERSION_GT(DUNE_GRID,2,6) && HAVE_DUNE_ALUGRID using HasParallelGridFactoryImpl = decltype(std::declval<GF>().createGrid(true,true,std::string(""),true));
template<int dim, int dimworld, Dune::ALUGridElementType elType, Dune::ALUGridRefinementType refineType, class Comm>
struct HasParallelGridFactory<Dune::ALUGrid<dim,dimworld,elType,refineType,Comm>> : std::true_type {}; template <class G>
#endif using HasParallelGridFactory = Std::is_detected<HasParallelGridFactoryImpl, GridFactory<G>>;
template <class Test> template <class Test>
...@@ -107,7 +108,6 @@ void reader_writer_test(MPIHelper& mpi, TestSuite& test, std::string const& test ...@@ -107,7 +108,6 @@ void reader_writer_test(MPIHelper& mpi, TestSuite& test, std::string const& test
auto numElements = filledArray<dim,unsigned int>(4); auto numElements = filledArray<dim,unsigned int>(4);
auto gridPtr = StructuredGridFactory<Grid>::createSimplexGrid(lowerLeft, upperRight, numElements); auto gridPtr = StructuredGridFactory<Grid>::createSimplexGrid(lowerLeft, upperRight, numElements);
gridPtr->loadBalance(); gridPtr->loadBalance();
// std::cout << "write1\n";
writer_test(gridPtr->leafGridView(), base_name); writer_test(gridPtr->leafGridView(), base_name);
} }
...@@ -115,7 +115,6 @@ void reader_writer_test(MPIHelper& mpi, TestSuite& test, std::string const& test ...@@ -115,7 +115,6 @@ void reader_writer_test(MPIHelper& mpi, TestSuite& test, std::string const& test
// Step 2: read the grid from file1 and write it back to file2 // Step 2: read the grid from file1 and write it back to file2
{ GridFactory<Grid> factory; { GridFactory<Grid> factory;
// std::cout << "read1\n";
VtkReader<Grid, Creator> reader{factory}; VtkReader<Grid, Creator> reader{factory};
reader.readFromFile(base_name + ext); reader.readFromFile(base_name + ext);
...@@ -185,13 +184,15 @@ int main (int argc, char** argv) ...@@ -185,13 +184,15 @@ int main (int argc, char** argv)
#endif #endif
#if HAVE_DUNE_ALUGRID #if HAVE_DUNE_ALUGRID
// Test VtkWriter for ALUGrid.
reader_writer_test<ALUGridType<2>, SerialGridCreator<ALUGridType<2>>>(mpi, test, "ALUGridType<2>"); reader_writer_test<ALUGridType<2>, SerialGridCreator<ALUGridType<2>>>(mpi, test, "ALUGridType<2>");
reader_writer_test<ALUGridType<3>, SerialGridCreator<ALUGridType<3>>>(mpi, test, "ALUGridType<3>"); reader_writer_test<ALUGridType<2>, ParallelGridCreator<ALUGridType<2>>>(mpi, test, "ALUGridType<2, Parallel>", false);
if (HasParallelGridFactory<ALUGridType<2>>{}) reader_writer_test<ALUGridType<3>, SerialGridCreator<ALUGridType<3>>>(mpi, test, "ALUGridType<3>");
reader_writer_test<ALUGridType<2>, ParallelGridCreator<ALUGridType<2>>>(mpi, test, "ALUGridType<2, Parallel>", false); #if DUNE_VERSION_LT(DUNE_GRID,2,7)
if (HasParallelGridFactory<ALUGridType<3>>{}) // Currently the 2.7 branch is not working, due to a new bisection compatibility check in 3d
reader_writer_test<ALUGridType<3>, ParallelGridCreator<ALUGridType<3>>>(mpi, test, "ALUGridType<3, Parallel>", false); reader_writer_test<ALUGridType<3>, ParallelGridCreator<ALUGridType<3>>>(mpi, test, "ALUGridType<3, Parallel>", false);
#endif
#endif #endif
return test.exit(); return test.exit();
......
...@@ -91,19 +91,10 @@ void writer_test (GridView const& gridView) ...@@ -91,19 +91,10 @@ void writer_test (GridView const& gridView)
} }
} }
template <class G> struct IsALUGrid : std::false_type {};
#if DUNE_VERSION_GT(DUNE_GRID,2,6) && HAVE_DUNE_ALUGRID
template<int dim, int dimworld, Dune::ALUGridElementType elType, Dune::ALUGridRefinementType refineType, class Comm>
struct IsALUGrid<Dune::ALUGrid<dim,dimworld,elType,refineType,Comm>> : std::true_type {};
#endif
template <class Grid, class Test> template <class Grid, class Test>
void reader_test (MPIHelper& mpi, Test& test) void reader_test (MPIHelper& mpi, Test& test)
{ {
std::string ext = ".vtu"; std::string ext = ".vtu";
if (mpi.size() > 1)
ext = ".pvtu";
for (auto const& test_case : test_cases) { for (auto const& test_case : test_cases) {
std::vector<std::string> pieces1, pieces2; std::vector<std::string> pieces1, pieces2;
...@@ -112,11 +103,8 @@ void reader_test (MPIHelper& mpi, Test& test) ...@@ -112,11 +103,8 @@ void reader_test (MPIHelper& mpi, Test& test)
VtkReader<Grid> reader{factory}; VtkReader<Grid> reader{factory};
reader.readFromFile("reader_writer_test_" + std::get<0>(test_case) + ext); reader.readFromFile("reader_writer_test_" + std::get<0>(test_case) + ext);
std::unique_ptr<Grid> grid{ Hybrid::ifElse(IsALUGrid<Grid>{}, std::unique_ptr<Grid> grid{factory.createGrid()};
[&](auto id) { return id(factory).createGrid(std::true_type{}); }, pieces1 = reader.pieces();
[&](auto id) { return id(factory).createGrid(); }) };
pieces1 = mpi.size() > 1 ? reader.pieces() :
std::vector<std::string>{"reader_writer_test_" + std::get<0>(test_case) + ".vtu"};
VtkUnstructuredGridWriter<typename Grid::LeafGridView> vtkWriter(grid->leafGridView(), VtkUnstructuredGridWriter<typename Grid::LeafGridView> vtkWriter(grid->leafGridView(),
std::get<1>(test_case), std::get<2>(test_case)); std::get<1>(test_case), std::get<2>(test_case));
...@@ -127,8 +115,7 @@ void reader_test (MPIHelper& mpi, Test& test) ...@@ -127,8 +115,7 @@ void reader_test (MPIHelper& mpi, Test& test)
GridFactory<Grid> factory2; GridFactory<Grid> factory2;
VtkReader<Grid> reader2{factory2}; VtkReader<Grid> reader2{factory2};
reader2.readFromFile("reader_writer_test_" + std::get<0>(test_case) + "_2" + ext, false); reader2.readFromFile("reader_writer_test_" + std::get<0>(test_case) + "_2" + ext, false);
pieces2 = mpi.size() > 1 ? reader2.pieces() : pieces2 = reader2.pieces();
std::vector<std::string>{"reader_writer_test_" + std::get<0>(test_case) + "_2.vtu"};
} }
test.check(pieces1.size() == pieces2.size(), "pieces1.size == pieces2.size"); test.check(pieces1.size() == pieces2.size(), "pieces1.size == pieces2.size");
...@@ -153,7 +140,6 @@ int main (int argc, char** argv) ...@@ -153,7 +140,6 @@ int main (int argc, char** argv)
#if HAVE_UG #if HAVE_UG
// Test VtkWriter for UGGrid // Test VtkWriter for UGGrid
if (mpi.size() == 1) {
Hybrid::forEach(std::make_tuple(int_<2>{}, int_<3>{}), [&test,&mpi](auto dim) Hybrid::forEach(std::make_tuple(int_<2>{}, int_<3>{}), [&test,&mpi](auto dim)
{ {
using GridType = UGGrid<dim.value>; using GridType = UGGrid<dim.value>;
...@@ -169,11 +155,9 @@ int main (int argc, char** argv) ...@@ -169,11 +155,9 @@ int main (int argc, char** argv)
reader_test<GridType>(mpi,test); reader_test<GridType>(mpi,test);
}); });
}
#endif #endif
// DUNE_VERSION_LT(DUNE_GRID,2,7) && #if DUNE_VERSION_LT(DUNE_GRID,2,7) && HAVE_DUNE_ALUGRID
#if HAVE_DUNE_ALUGRID
// Test VtkWriter for ALUGrid. Currently the 2.7 branch is not working. // Test VtkWriter for ALUGrid. Currently the 2.7 branch is not working.
Hybrid::forEach(std::make_tuple(int_<2>{}, int_<3>{}), [&test,&mpi](auto dim) Hybrid::forEach(std::make_tuple(int_<2>{}, int_<3>{}), [&test,&mpi](auto dim)
{ {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment