Commit 14a7d5c9 authored by Lukas Riedel's avatar Lukas Riedel 📝

Add a test for the new grid implementation

[ci skip]
parent 0507c49d
......@@ -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})
......
add_executable(grid-test grid-test.cc)
dune_target_link_libraries(grid-test ${DUNE_LIBS})
\ No newline at end of file
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string>
#include <iostream>
#include <cstdio>
#include <thread>
#include <dune/common/exceptions.hh>
#include <dune/common/parametertree.hh>
#include <dune/common/parametertreeparser.hh>
#include <dune/common/parallel/mpihelper.hh>
#include <dune/grid/yaspgrid.hh>
#include <dune/grid/uggrid.hh>
#include <dune/grid/io/file/vtk/vtkwriter.hh>
#include <dune/dorie/solver/util_grid_creator.hh>
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<bool>("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<GridType> 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<std::string>("output.fileName"),
inifile.get<std::string>("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
Markdown is supported
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