diff --git a/dune/dorie/CMakeLists.txt b/dune/dorie/CMakeLists.txt index a9c07d2d1978cb05c108d6dc7abb93ca72d604c0..010140db39f3d39f0a85a0d728d5b71efe279a60 100644 --- a/dune/dorie/CMakeLists.txt +++ b/dune/dorie/CMakeLists.txt @@ -2,6 +2,7 @@ add_subdirectory(interface) add_subdirectory(solver) add_subdirectory(impl) add_subdirectory(test) +add_subdirectory(grid-test) add_executable("dorie" dorie.cc) dune_target_link_libraries(dorie dorie-impl ${DUNE_LIBS}) diff --git a/dune/dorie/grid-test/CMakeLists.txt b/dune/dorie/grid-test/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..57af28daade0c91c182ac4e704e0cd52eed9185b --- /dev/null +++ b/dune/dorie/grid-test/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(grid-test grid-test.cc) +dune_target_link_libraries(grid-test ${DUNE_LIBS}) \ No newline at end of file diff --git a/dune/dorie/grid-test/grid-test.cc b/dune/dorie/grid-test/grid-test.cc new file mode 100644 index 0000000000000000000000000000000000000000..b2fa7468ee9b38ce317b572fd1707e75d2baf1b1 --- /dev/null +++ b/dune/dorie/grid-test/grid-test.cc @@ -0,0 +1,80 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include + +int main(int argc, char** argv) +{ + try{ + //Initialize Mpi + Dune::MPIHelper& helper = Dune::MPIHelper::instance(argc, argv); + + if (argc!=2) + DUNE_THROW(Dune::IOError,"No parameter file specified!"); + const std::string inifilename = argv[1]; + + // Read ini file + Dune::ParameterTree inifile; + Dune::ParameterTreeParser ptreeparser; + ptreeparser.readINITree(inifilename, inifile); + + // maybe attach debugger + if (helper.size() > 1 && inifile.get("misc.debugMode", false)) + { + int i = 0; + std::cout << "Attach now" << std::endl; + while (0 == i) + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + + + // build the grid creator + using GridType = Dune::UGGrid<2>; + Dune::Dorie::GridCreator gc(helper, inifile); + auto [grid, mapper] = gc.get_grid_and_mapper(); + + auto element_map = mapper.get_element_index_map(); + auto boundary_map = mapper.get_boundary_index_map(); + + std::cout << "Process " << helper.rank() << std::endl; + std::cout << "Element index map (" << element_map.size() << "): "; + for (auto&& value : element_map) { + std::cout << value << " "; + } + std::cout << std::endl; + + auto gv = grid->levelGridView(0); + Dune::VTKWriter writer(gv); + writer.addCellData(element_map, "mapping"); + writer.pwrite( + inifile.get("output.fileName"), + inifile.get("output.outputPath"), + "./"); + + return 0; + } + catch (Dune::Exception &e){ + std::cerr << "Dune reported error: " << e << std::endl; + return 1; + } + catch (...){ + std::cerr << "Unknown exception thrown!" << std::endl; + throw; + return 1; + } +} \ No newline at end of file