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