From 66f0b71fc1f3db90f1cae04f0050940007be193e Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Mon, 19 Sep 2016 19:44:41 +0200 Subject: [PATCH] Log the message of exceptions in the catch clause of adaptive time stepper. --- .../AdaptiveTimeStepping_impl.hpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/opm/simulators/timestepping/AdaptiveTimeStepping_impl.hpp b/opm/simulators/timestepping/AdaptiveTimeStepping_impl.hpp index a79cd2937..23ef1dd50 100644 --- a/opm/simulators/timestepping/AdaptiveTimeStepping_impl.hpp +++ b/opm/simulators/timestepping/AdaptiveTimeStepping_impl.hpp @@ -57,6 +57,17 @@ namespace Opm { return solver_.model().relativeChange( previous_, current_ ); } }; + + template + void logException(const E& exception, bool verbose) + { + if( verbose ) + { + std::ostringstream message; + message << "Caught Exception: " << exception.what(); + OpmLog::debug(message.str()); + } + } } // AdaptiveTimeStepping @@ -207,19 +218,19 @@ namespace Opm { } } catch (const Opm::NumericalProblem& e) { - std::cerr << e.what() << std::endl; + detail::logException(e, solver_verbose_); // since linearIterations is < 0 this will restart the solver } catch (const std::runtime_error& e) { - std::cerr << e.what() << std::endl; + detail::logException(e, solver_verbose_); // also catch linear solver not converged } catch (const Dune::ISTLError& e) { - std::cerr << e.what() << std::endl; + detail::logException(e, solver_verbose_); // also catch errors in ISTL AMG that occur when time step is too large } catch (const Dune::MatrixBlockError& e) { - std::cerr << e.what() << std::endl; + detail::logException(e, solver_verbose_); // this can be thrown by ISTL's ILU0 in block mode, yet is not an ISTLError }