Commit 89084786 authored by Andreas Lauser's avatar Andreas Lauser
Browse files

box models: improve exception handling

all non-NumericalProblem exceptions are caught at the level of the
newton method and the constructor of the NumericalProblem class can
directly take a string as an argument for improved convenience,

git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@5040 2fb0f335-1f38-0410-981e-8018bf24f1b0
parent 3b05dad5
// $Id$ // $Id$
/***************************************************************************** /*****************************************************************************
* Copyright (C) 2009 by Andreas Lauser * * Copyright (C) 2009 by Andreas Lauser *
* Institute of Hydraulic Engineering * * Institute of Hydraulic Engineering *
...@@ -28,6 +27,8 @@ ...@@ -28,6 +27,8 @@
#include <dune/common/exceptions.hh> #include <dune/common/exceptions.hh>
#include <string>
namespace Dumux { namespace Dumux {
/*! /*!
* \brief Exception thrown if a fixable numerical problem occurs. * \brief Exception thrown if a fixable numerical problem occurs.
...@@ -35,7 +36,21 @@ namespace Dumux { ...@@ -35,7 +36,21 @@ namespace Dumux {
* (e.g. time step too big, etc.) * (e.g. time step too big, etc.)
*/ */
class NumericalProblem : public Dune::Exception class NumericalProblem : public Dune::Exception
{ }; {
public:
// copy constructor
NumericalProblem(const NumericalProblem &v)
: Dune::Exception(v)
{}
// default constructor
NumericalProblem()
{}
// constructor with error message
NumericalProblem(const std::string &s)
{ this->message(s); }
};
} }
#endif #endif
...@@ -467,7 +467,7 @@ public: ...@@ -467,7 +467,7 @@ public:
if (!converged) { if (!converged) {
DUNE_THROW(NumericalProblem, DUNE_THROW(NumericalProblem,
"A process threw MatrixBlockError"); "A process threw NumericalProblem");
} }
} }
catch (Dune::MatrixBlockError e) { catch (Dune::MatrixBlockError e) {
...@@ -482,6 +482,15 @@ public: ...@@ -482,6 +482,15 @@ public:
p.message(ms.str()); p.message(ms.str());
throw p; throw p;
} }
catch (const Dune::ISTLError &e) {
// make sure all processes converged
int converged = 0;
gridView_().comm().min(converged);
Dumux::NumericalProblem p;
p.message(e.what());
throw p;
}
} }
/*! /*!
......
...@@ -103,12 +103,6 @@ public: ...@@ -103,12 +103,6 @@ public:
try { try {
return execute_(ctl); return execute_(ctl);
} }
catch (const Dune::ISTLError &e) {
if (ctl.verbose())
std::cout << "Newton: Caught exception: \"" << e.what() << "\"\n";
ctl.newtonFail();
return false;
}
catch (const Dumux::NumericalProblem &e) { catch (const Dumux::NumericalProblem &e) {
if (ctl.verbose()) if (ctl.verbose())
std::cout << "Newton: Caught exception: \"" << e.what() << "\"\n"; std::cout << "Newton: Caught exception: \"" << e.what() << "\"\n";
......
Supports Markdown
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