-
-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Reactor] Suppress recoverable errors in RHS function by default
Accumulate errors and show them if the integrator actually fails. In "verbose" mode, the errors are shown as they occur.
- Loading branch information
Showing
6 changed files
with
113 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include "cantera/numerics/FuncEval.h" | ||
#include <sstream> | ||
|
||
namespace Cantera | ||
{ | ||
|
||
FuncEval::FuncEval() | ||
: m_suppress_errors(false) | ||
{ | ||
} | ||
|
||
int FuncEval::eval_nothrow(double t, double* y, double* ydot) | ||
{ | ||
try { | ||
eval(t, y, ydot, m_sens_params.data()); | ||
} catch (CanteraError& err) { | ||
if (suppressErrors()) { | ||
m_errors.push_back(err.getMessage()); | ||
} else { | ||
writelog(err.what()); | ||
} | ||
return 1; // possibly recoverable error | ||
} catch (std::exception& err) { | ||
if (suppressErrors()) { | ||
m_errors.push_back(err.what()); | ||
} else { | ||
writelog("FuncEval::eval_nothrow: unhandled exception:\n"); | ||
writelog(err.what()); | ||
writelogendl(); | ||
} | ||
return -1; // unrecoverable error | ||
} catch (...) { | ||
std::string msg = "FuncEval::eval_nothrow: unhandled exception" | ||
" of unknown type\n"; | ||
if (suppressErrors()) { | ||
m_errors.push_back(msg); | ||
} else { | ||
writelog(msg); | ||
} | ||
return -1; // unrecoverable error | ||
} | ||
return 0; // successful evaluation | ||
} | ||
|
||
std::string FuncEval::getErrors() const { | ||
std::stringstream errs; | ||
for (const auto& err : m_errors) { | ||
errs << err; | ||
errs << "\n"; | ||
} | ||
return errs.str(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters