Commit ecef61da authored by Lukas Riedel's avatar Lukas Riedel

Fixed bug in test-mass-conservation

Throwing an exception now correctly results in a failing test
parent d83971ed
......@@ -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