diff --git a/testing/test-mass-conservation.cc b/testing/test-mass-conservation.cc index eefd64f482d406bf07ce12e823150a47ad2fcfda..0929361e03dbc5d47d628f9079d01f1376c2ddad 100644 --- a/testing/test-mass-conservation.cc +++ b/testing/test-mass-conservation.cc @@ -32,57 +32,64 @@ using CubeAdaptive = Dune::Dorie::BaseTraits"); - 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 "); + const std::string inifilename = argv[1]; + Dune::ParameterTree inifile; + Dune::ParameterTreeParser ptreeparser; + ptreeparser.readINITree(inifilename,inifile); - const double limit = inifile.get("limit"); + const double limit = inifile.get("limit"); - // run test - double result {0.0}; - const auto adaptive = inifile.get("adaptivity.useAdaptivity"); - const auto grid_type = inifile.get("grid.gridType"); - if (adaptive) { - if (grid_type == "rectangular") { - using TestSim = Dune::Dorie::TestSimulation>; - auto grid = Dune::Dorie::build_grid_cube>(inifile, helper); - TestSim sim(helper, grid, inifile); - result = sim.run_test(); + // run test + double result {0.0}; + const auto adaptive = inifile.get("adaptivity.useAdaptivity"); + const auto grid_type = inifile.get("grid.gridType"); + if (adaptive) { + if (grid_type == "rectangular") { + using TestSim = Dune::Dorie::TestSimulation>; + auto grid = Dune::Dorie::build_grid_cube>(inifile, helper); + TestSim sim(helper, grid, inifile); + result = sim.run_test(); + } + else if (grid_type == "simplex") { + using TestSim = Dune::Dorie::TestSimulation>; + auto grid = Dune::Dorie::build_grid_gmsh>(inifile, helper); + TestSim sim(helper, grid, inifile); + result = sim.run_test(); + } } - else if (grid_type == "simplex") { - using TestSim = Dune::Dorie::TestSimulation>; - auto grid = Dune::Dorie::build_grid_gmsh>(inifile, helper); - TestSim sim(helper, grid, inifile); - result = sim.run_test(); + else { + if (grid_type == "rectangular") { + using TestSim = Dune::Dorie::TestSimulation>; + auto grid = Dune::Dorie::build_grid_cube>(inifile, helper); + TestSim sim(helper, grid, inifile); + result = sim.run_test(); + } + else if (grid_type == "simplex") { + using TestSim = Dune::Dorie::TestSimulation>; + auto grid = Dune::Dorie::build_grid_gmsh>(inifile, helper); + TestSim sim(helper, grid, inifile); + result = sim.run_test(); + } } - } - else { - if (grid_type == "rectangular") { - using TestSim = Dune::Dorie::TestSimulation>; - auto grid = Dune::Dorie::build_grid_cube>(inifile, helper); - TestSim sim(helper, grid, inifile); - result = sim.run_test(); - } - else if (grid_type == "simplex") { - using TestSim = Dune::Dorie::TestSimulation>; - auto grid = Dune::Dorie::build_grid_gmsh>(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; }