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:
std::vector<std::uint64_t> data;
data.reserve(numPoints_);
GlobalIndexSet<GridView> globalIndexSet(gridView_, dim);
auto const& indexSet = gridView_.indexSet();
for (auto const& vertex : vertices(gridView_, partition)) {
data.emplace_back(globalIndexSet.index(vertex));
}
......
......@@ -11,6 +11,7 @@
#include <dune/common/parallel/mpihelper.hh> // An initializer of MPI
#include <dune/common/filledarray.hh>
#include <dune/common/std/type_traits.hh>
#include <dune/common/test/testsuite.hh>
#include <dune/grid/uggrid.hh>
......@@ -67,11 +68,11 @@ bool compare_files (std::string const& fn1, std::string const& fn2)
}
template <class G> struct HasParallelGridFactory : 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 HasParallelGridFactory<Dune::ALUGrid<dim,dimworld,elType,refineType,Comm>> : std::true_type {};
#endif
template <class GF>
using HasParallelGridFactoryImpl = decltype(std::declval<GF>().createGrid(true,true,std::string(""),true));
template <class G>
using HasParallelGridFactory = Std::is_detected<HasParallelGridFactoryImpl, GridFactory<G>>;
template <class 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 gridPtr = StructuredGridFactory<Grid>::createSimplexGrid(lowerLeft, upperRight, numElements);
gridPtr->loadBalance();
// std::cout << "write1\n";
writer_test(gridPtr->leafGridView(), base_name);
}
......@@ -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
{ GridFactory<Grid> factory;
// std::cout << "read1\n";
VtkReader<Grid, Creator> reader{factory};
reader.readFromFile(base_name + ext);
......@@ -185,13 +184,15 @@ int main (int argc, char** argv)
#endif
#if HAVE_DUNE_ALUGRID
// Test VtkWriter for ALUGrid.
reader_writer_test<ALUGridType<2>, SerialGridCreator<ALUGridType<2>>>(mpi, test, "ALUGridType<2>");
reader_writer_test<ALUGridType<3>, SerialGridCreator<ALUGridType<3>>>(mpi, test, "ALUGridType<3>");
if (HasParallelGridFactory<ALUGridType<2>>{})
reader_writer_test<ALUGridType<2>, ParallelGridCreator<ALUGridType<2>>>(mpi, test, "ALUGridType<2, Parallel>", false);
if (HasParallelGridFactory<ALUGridType<3>>{})
reader_writer_test<ALUGridType<3>, SerialGridCreator<ALUGridType<3>>>(mpi, test, "ALUGridType<3>");
#if DUNE_VERSION_LT(DUNE_GRID,2,7)
// 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);
#endif
#endif
return test.exit();
......
......@@ -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>
void reader_test (MPIHelper& mpi, Test& test)
{
std::string ext = ".vtu";
if (mpi.size() > 1)
ext = ".pvtu";
for (auto const& test_case : test_cases) {
std::vector<std::string> pieces1, pieces2;
......@@ -112,11 +103,8 @@ void reader_test (MPIHelper& mpi, Test& test)
VtkReader<Grid> reader{factory};
reader.readFromFile("reader_writer_test_" + std::get<0>(test_case) + ext);
std::unique_ptr<Grid> grid{ Hybrid::ifElse(IsALUGrid<Grid>{},
[&](auto id) { return id(factory).createGrid(std::true_type{}); },
[&](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"};
std::unique_ptr<Grid> grid{factory.createGrid()};
pieces1 = reader.pieces();
VtkUnstructuredGridWriter<typename Grid::LeafGridView> vtkWriter(grid->leafGridView(),
std::get<1>(test_case), std::get<2>(test_case));
......@@ -127,8 +115,7 @@ void reader_test (MPIHelper& mpi, Test& test)
GridFactory<Grid> factory2;
VtkReader<Grid> reader2{factory2};
reader2.readFromFile("reader_writer_test_" + std::get<0>(test_case) + "_2" + ext, false);
pieces2 = mpi.size() > 1 ? reader2.pieces() :
std::vector<std::string>{"reader_writer_test_" + std::get<0>(test_case) + "_2.vtu"};
pieces2 = reader2.pieces();
}
test.check(pieces1.size() == pieces2.size(), "pieces1.size == pieces2.size");
......@@ -153,7 +140,6 @@ int main (int argc, char** argv)
#if HAVE_UG
// Test VtkWriter for UGGrid
if (mpi.size() == 1) {
Hybrid::forEach(std::make_tuple(int_<2>{}, int_<3>{}), [&test,&mpi](auto dim)
{
using GridType = UGGrid<dim.value>;
......@@ -169,11 +155,9 @@ int main (int argc, char** argv)
reader_test<GridType>(mpi,test);
});
}
#endif
// DUNE_VERSION_LT(DUNE_GRID,2,7) &&
#if HAVE_DUNE_ALUGRID
#if DUNE_VERSION_LT(DUNE_GRID,2,7) && HAVE_DUNE_ALUGRID
// 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)
{
......
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