Commit a29e0b8f authored by Lukas Riedel's avatar Lukas Riedel

Merge branch '54-raise-mass-conservation-limits' into 'master'

Resolve "Raise mass conservation limits"

Closes #54

See merge request !35
parents d83971ed d71e1ffe
...@@ -2,12 +2,12 @@ include ${CMAKE_BINARY_DIR}/doc/default_files/config.ini ...@@ -2,12 +2,12 @@ include ${CMAKE_BINARY_DIR}/doc/default_files/config.ini
__name = mc __name = mc
_asset_path = "${CMAKE_CURRENT_LIST_DIR}" _asset_path = "${CMAKE_CURRENT_LIST_DIR}"
_limit_cube_static = 2E-9 _limit_cube_static = 4e-7
_limit_cube_adapt = 2E-4 _limit_cube_adapt = 3E-7
_limit_simplex_static = 5E-10 _limit_simplex_static = 4E-7
_limit_simplex_adapt = 3E-6 _limit_simplex_adapt = 2E-6
_prefix = _simplex _prefix = _simplex, _cube | expand grid
_suffix = _static, _adapt | expand adaptive _suffix = _static, _adapt | expand adaptive
limit = {_limit{_prefix}{_suffix}} limit = {_limit{_prefix}{_suffix}}
...@@ -32,7 +32,7 @@ adaptivity.coarseningFraction = 5E-10 ...@@ -32,7 +32,7 @@ adaptivity.coarseningFraction = 5E-10
adaptivity.threshold = 0.0 adaptivity.threshold = 0.0
grid.FEorder = 1 grid.FEorder = 1
grid.gridType = simplex grid.gridType = simplex, rectangular | expand grid
grid.initialLevel = 2 grid.initialLevel = 2
grid.cells = 20 20 grid.cells = 20 20
grid.gridFile = {_asset_path}/meshes/square.msh grid.gridFile = {_asset_path}/meshes/square.msh
\ No newline at end of file
...@@ -32,57 +32,64 @@ using CubeAdaptive = Dune::Dorie::BaseTraits<Dune::UGGrid, ...@@ -32,57 +32,64 @@ using CubeAdaptive = Dune::Dorie::BaseTraits<Dune::UGGrid,
int main (int argc, char** argv) int main (int argc, char** argv)
{ {
// initialize MPI if needed try{
auto& helper = Dune::MPIHelper::instance(argc, argv); // initialize MPI if needed
auto& helper = Dune::MPIHelper::instance(argc, argv);
// Read ini file // Read ini file
if (argc!=2) if (argc!=2)
DUNE_THROW(Dune::IOError, DUNE_THROW(Dune::IOError,
"Call this program with arguments <config>"); "Call this program with arguments <config>");
const std::string inifilename = argv[1]; const std::string inifilename = argv[1];
Dune::ParameterTree inifile; Dune::ParameterTree inifile;
Dune::ParameterTreeParser ptreeparser; Dune::ParameterTreeParser ptreeparser;
ptreeparser.readINITree(inifilename,inifile); ptreeparser.readINITree(inifilename,inifile);
const double limit = inifile.get<double>("limit"); const double limit = inifile.get<double>("limit");
// run test // run test
double result {0.0}; double result {0.0};
const auto adaptive = inifile.get<bool>("adaptivity.useAdaptivity"); const auto adaptive = inifile.get<bool>("adaptivity.useAdaptivity");
const auto grid_type = inifile.get<std::string>("grid.gridType"); const auto grid_type = inifile.get<std::string>("grid.gridType");
if (adaptive) { if (adaptive) {
if (grid_type == "rectangular") { if (grid_type == "rectangular") {
using TestSim = Dune::Dorie::TestSimulation<CubeAdaptive<2, 1>>; using TestSim = Dune::Dorie::TestSimulation<CubeAdaptive<2, 1>>;
auto grid = Dune::Dorie::build_grid_cube<Dune::UGGrid<2>>(inifile, helper); auto grid = Dune::Dorie::build_grid_cube<Dune::UGGrid<2>>(inifile, helper);
TestSim sim(helper, grid, inifile); TestSim sim(helper, grid, inifile);
result = sim.run_test(); result = sim.run_test();
}
else if (grid_type == "simplex") {
using TestSim = Dune::Dorie::TestSimulation<SimplexAdaptive<2, 1>>;
auto grid = Dune::Dorie::build_grid_gmsh<Dune::UGGrid<2>>(inifile, helper);
TestSim sim(helper, grid, inifile);
result = sim.run_test();
}
} }
else if (grid_type == "simplex") { else {
using TestSim = Dune::Dorie::TestSimulation<SimplexAdaptive<2, 1>>; if (grid_type == "rectangular") {
auto grid = Dune::Dorie::build_grid_gmsh<Dune::UGGrid<2>>(inifile, helper); using TestSim = Dune::Dorie::TestSimulation<Cube<2, 1>>;
TestSim sim(helper, grid, inifile); auto grid = Dune::Dorie::build_grid_cube<Dune::YaspGrid<2>>(inifile, helper);
result = sim.run_test(); TestSim sim(helper, grid, inifile);
result = sim.run_test();
}
else if (grid_type == "simplex") {
using TestSim = Dune::Dorie::TestSimulation<Simplex<2, 1>>;
auto grid = Dune::Dorie::build_grid_gmsh<Dune::UGGrid<2>>(inifile, helper);
TestSim sim(helper, grid, inifile);
result = sim.run_test();
}
} }
}
else { if (std::abs(result) > limit) {
if (grid_type == "rectangular") { std::cerr << "Mass conservation test exceeded limit!" << std::endl;
using TestSim = Dune::Dorie::TestSimulation<Cube<2, 1>>; std::cerr << "Limit: " << limit << std::endl;
auto grid = Dune::Dorie::build_grid_cube<Dune::YaspGrid<2>>(inifile, helper); std::cerr << "Result: " << result << std::endl;
TestSim sim(helper, grid, inifile); return 2;
result = sim.run_test();
}
else if (grid_type == "simplex") {
using TestSim = Dune::Dorie::TestSimulation<Simplex<2, 1>>;
auto grid = Dune::Dorie::build_grid_gmsh<Dune::UGGrid<2>>(inifile, helper);
TestSim sim(helper, grid, inifile);
result = sim.run_test();
} }
} }
if (std::abs(result) > limit) { catch(...) {
std::cerr << "Mass conservation test exceeded limit!" << std::endl; std::cerr << "Exception occurred!" << std::endl;
std::cerr << "Limit: " << limit << std::endl;
std::cerr << "Result: " << result << std::endl;
return 1; return 1;
} }
......
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