From 4b841fa9ece0f77a69b701182110451b1498e474 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Tue, 3 Sep 2013 14:41:38 +0200 Subject: [PATCH] Add exception handlers to all tutorials and examples --- examples/aniso_implicitcap_test.cpp | 6 ++++++ examples/aniso_simulator_test.cpp | 6 +++++- examples/co2_blackoil_pvt.cpp | 5 +++++ examples/implicitcap_test.cpp | 6 ++++++ examples/known_answer_test.cpp | 6 ++++++ examples/mimetic_aniso_solver_test.cpp | 13 ++++++++++++- examples/mimetic_periodic_test.cpp | 5 +++++ examples/mimetic_solver_test.cpp | 5 +++++ examples/sim_blackoil_impes.cpp | 6 ++++++ examples/sim_co2_impes.cpp | 6 ++++++ examples/sim_steadystate_explicit.cpp | 6 +++++- examples/sim_steadystate_implicit.cpp | 6 ++++++ tests/common/boundaryconditions_test.cpp | 3 +++ 13 files changed, 76 insertions(+), 3 deletions(-) diff --git a/examples/aniso_implicitcap_test.cpp b/examples/aniso_implicitcap_test.cpp index e603a61..7e1c030 100644 --- a/examples/aniso_implicitcap_test.cpp +++ b/examples/aniso_implicitcap_test.cpp @@ -54,6 +54,7 @@ typedef SimulatorTraits SimTraits; typedef SimulatorTesterFlexibleBC Simulator; int main(int argc, char** argv) +try { Opm::parameter::ParameterGroup param(argc, argv); Dune::MPIHelper::instance(argc,argv); @@ -65,4 +66,9 @@ int main(int argc, char** argv) sim.init(param); sim.run(); } +catch (const std::exception &e) { + std::cerr << "Program threw an exception: " << e.what() << "\n"; + throw; +} + diff --git a/examples/aniso_simulator_test.cpp b/examples/aniso_simulator_test.cpp index 766d48f..6a6ac5a 100644 --- a/examples/aniso_simulator_test.cpp +++ b/examples/aniso_simulator_test.cpp @@ -54,6 +54,7 @@ typedef SimulatorTraits SimTraits; typedef SimulatorTesterFlexibleBC Simulator; int main(int argc, char** argv) +try { Opm::parameter::ParameterGroup param(argc, argv); Dune::MPIHelper::instance(argc,argv); @@ -65,4 +66,7 @@ int main(int argc, char** argv) sim.init(param); sim.run(); } - +catch (const std::exception &e) { + std::cerr << "Program threw an exception: " << e.what() << "\n"; + throw; +} diff --git a/examples/co2_blackoil_pvt.cpp b/examples/co2_blackoil_pvt.cpp index a2fffcd..f330e6d 100644 --- a/examples/co2_blackoil_pvt.cpp +++ b/examples/co2_blackoil_pvt.cpp @@ -25,6 +25,7 @@ #include int main(int argc, char** argv) +try { double temperature = 300.; if (argc == 2) temperature = std::atof(argv[1]); @@ -39,4 +40,8 @@ int main(int argc, char** argv) clock.stop(); std::cout << "\n\nInitialisation and table generation - clock time (secs): " << clock.secsSinceStart() << std::endl; } +catch (const std::exception &e) { + std::cerr << "Program threw an exception: " << e.what() << "\n"; + throw; +} diff --git a/examples/implicitcap_test.cpp b/examples/implicitcap_test.cpp index b276999..7953f23 100644 --- a/examples/implicitcap_test.cpp +++ b/examples/implicitcap_test.cpp @@ -54,6 +54,7 @@ typedef SimulatorTraits SimTraits; typedef SimulatorTesterFlexibleBC Simulator; int main(int argc, char** argv) +try { Opm::parameter::ParameterGroup param(argc, argv); Dune::MPIHelper::instance(argc,argv); @@ -65,4 +66,9 @@ int main(int argc, char** argv) sim.init(param); sim.run(); } +catch (const std::exception &e) { + std::cerr << "Program threw an exception: " << e.what() << "\n"; + throw; +} + diff --git a/examples/known_answer_test.cpp b/examples/known_answer_test.cpp index 2df2f56..29470d5 100644 --- a/examples/known_answer_test.cpp +++ b/examples/known_answer_test.cpp @@ -291,6 +291,7 @@ void test_flowsolver(const GI& g, const RI& r, double tol, int kind) int main(int argc, char** argv) +try { Opm::parameter::ParameterGroup param(argc, argv); Dune::MPIHelper::instance(argc,argv); @@ -330,3 +331,8 @@ int main(int argc, char** argv) param.getDefault("tolerance", 1e-8), param.getDefault("linear_solver_type", 1)); } +catch (const std::exception &e) { + std::cerr << "Program threw an exception: " << e.what() << "\n"; + throw; +} + diff --git a/examples/mimetic_aniso_solver_test.cpp b/examples/mimetic_aniso_solver_test.cpp index 1e331db..3dbffd9 100644 --- a/examples/mimetic_aniso_solver_test.cpp +++ b/examples/mimetic_aniso_solver_test.cpp @@ -213,6 +213,7 @@ void test_flowsolver(const GI& g, const RI& r) using namespace Opm; int main(int argc, char** argv) +try { Opm::parameter::ParameterGroup param(argc, argv); Dune::MPIHelper::instance(argc,argv); @@ -272,10 +273,15 @@ int main(int argc, char** argv) transport_solver.transportSolve(sat, time, gravity, flow_solution); #endif } +catch (const std::exception &e) { + std::cerr << "Program threw an exception: " << e.what() << "\n"; + throw; +} + #if 0 -int main (int argc , char **argv) { +int main (int argc , char **argv) try { try { #if HAVE_MPI // initialize MPI @@ -304,4 +310,9 @@ int main (int argc , char **argv) { return 0; } +catch (const std::exception &e) { + std::cerr << "Program threw an exception: " << e.what() << "\n"; + throw; +} + #endif diff --git a/examples/mimetic_periodic_test.cpp b/examples/mimetic_periodic_test.cpp index 5d71aa2..b1da3d8 100644 --- a/examples/mimetic_periodic_test.cpp +++ b/examples/mimetic_periodic_test.cpp @@ -55,6 +55,7 @@ using namespace Opm; int main(int argc, char** argv) +try { typedef Opm::GridInterfaceEuler GI; typedef GI ::CellIterator CI; @@ -116,4 +117,8 @@ int main(int argc, char** argv) return 0; } +catch (const std::exception &e) { + std::cerr << "Program threw an exception: " << e.what() << "\n"; + throw; +} diff --git a/examples/mimetic_solver_test.cpp b/examples/mimetic_solver_test.cpp index fc473ea..bde251d 100644 --- a/examples/mimetic_solver_test.cpp +++ b/examples/mimetic_solver_test.cpp @@ -162,6 +162,7 @@ void test_flowsolver(const GI& g, const RI& r) using namespace Opm; int main(int argc, char** argv) +try { Opm::parameter::ParameterGroup param(argc, argv); Dune::MPIHelper::instance(argc,argv); @@ -186,3 +187,7 @@ int main(int argc, char** argv) test_flowsolver<3>(g, res_prop); } +catch (const std::exception &e) { + std::cerr << "Program threw an exception: " << e.what() << "\n"; + throw; +} diff --git a/examples/sim_blackoil_impes.cpp b/examples/sim_blackoil_impes.cpp index ab90875..6669266 100644 --- a/examples/sim_blackoil_impes.cpp +++ b/examples/sim_blackoil_impes.cpp @@ -49,6 +49,7 @@ typedef Opm::BlackoilSimulator SimTraits; typedef SimulatorTesterFlexibleBC Simulator; int main(int argc, char** argv) +try { Opm::parameter::ParameterGroup param(argc, argv); Dune::MPIHelper::instance(argc,argv); @@ -50,4 +51,7 @@ int main(int argc, char** argv) sim.init(param); sim.run(); } - +catch (const std::exception &e) { + std::cerr << "Program threw an exception: " << e.what() << "\n"; + throw; +} diff --git a/examples/sim_steadystate_implicit.cpp b/examples/sim_steadystate_implicit.cpp index 5aae776..d22e5e7 100644 --- a/examples/sim_steadystate_implicit.cpp +++ b/examples/sim_steadystate_implicit.cpp @@ -54,6 +54,7 @@ typedef SimulatorTraits SimTraits; typedef SimulatorTesterFlexibleBC Simulator; int main(int argc, char** argv) +try { Opm::parameter::ParameterGroup param(argc, argv); Dune::MPIHelper::instance(argc,argv); @@ -61,4 +62,9 @@ int main(int argc, char** argv) sim.init(param); sim.run(); } +catch (const std::exception &e) { + std::cerr << "Program threw an exception: " << e.what() << "\n"; + throw; +} + diff --git a/tests/common/boundaryconditions_test.cpp b/tests/common/boundaryconditions_test.cpp index e5a7573..f56316c 100644 --- a/tests/common/boundaryconditions_test.cpp +++ b/tests/common/boundaryconditions_test.cpp @@ -101,6 +101,7 @@ BOOST_AUTO_TEST_CASE(saturationboundarycondition) BOOST_CHECK(bc2.saturation() == 0.3); } + BOOST_AUTO_TEST_CASE(saturationboundaryconditions) { BasicBoundaryConditions bc1; @@ -115,6 +116,7 @@ BOOST_AUTO_TEST_CASE(saturationboundaryconditions) BOOST_CHECK(bc2.satCond(1).saturation() == 0.8); } + BOOST_AUTO_TEST_CASE(surfvolboundaryconditions) { enum { Nc = 3 }; @@ -134,3 +136,4 @@ BOOST_AUTO_TEST_CASE(surfvolboundaryconditions) BOOST_CHECK(bc2.surfvolCond(1).isDirichlet()); BOOST_CHECK(bc2.surfvolCond(1).surfvol() == z); } +