Cantera
2.3.0
src
numerics
FuncEval.cpp
1
#include "
cantera/numerics/FuncEval.h
"
2
#include <sstream>
3
4
namespace
Cantera
5
{
6
7
FuncEval::FuncEval()
8
: m_suppress_errors(false)
9
{
10
}
11
12
int
FuncEval::eval_nothrow
(
double
t,
double
* y,
double
* ydot)
13
{
14
try
{
15
eval
(t, y, ydot,
m_sens_params
.data());
16
}
catch
(
CanteraError
& err) {
17
if
(
suppressErrors
()) {
18
m_errors
.push_back(err.
getMessage
());
19
}
else
{
20
writelog
(err.
what
());
21
}
22
return
1;
// possibly recoverable error
23
}
catch
(std::exception& err) {
24
if
(
suppressErrors
()) {
25
m_errors
.push_back(err.what());
26
}
else
{
27
writelog
(
"FuncEval::eval_nothrow: unhandled exception:\n"
);
28
writelog
(err.what());
29
writelogendl
();
30
}
31
return
-1;
// unrecoverable error
32
}
catch
(...) {
33
std::string msg =
"FuncEval::eval_nothrow: unhandled exception"
34
" of unknown type\n"
;
35
if
(
suppressErrors
()) {
36
m_errors
.push_back(msg);
37
}
else
{
38
writelog
(msg);
39
}
40
return
-1;
// unrecoverable error
41
}
42
return
0;
// successful evaluation
43
}
44
45
std::string
FuncEval::getErrors
()
const
{
46
std::stringstream errs;
47
for
(
const
auto
& err :
m_errors
) {
48
errs << err;
49
errs <<
"\n"
;
50
}
51
return
errs.str();
52
}
53
54
}
Cantera::writelog
void writelog(const std::string &fmt, const Args &... args)
Write a formatted message to the screen.
Definition:
global.h:179
Cantera::CanteraError::what
const char * what() const
Get a description of the error.
Definition:
ctexceptions.cpp:34
Cantera::FuncEval::getErrors
std::string getErrors() const
Return a string containing the text of any suppressed errors.
Definition:
FuncEval.cpp:45
Cantera::FuncEval::eval
virtual void eval(double t, double *y, double *ydot, double *p)=0
Evaluate the right-hand-side function.
Cantera::CanteraError::getMessage
virtual std::string getMessage() const
Method overridden by derived classes to format the error message.
Definition:
ctexceptions.cpp:54
FuncEval.h
Cantera::FuncEval::m_errors
std::vector< std::string > m_errors
Errors occuring during function evaluations.
Definition:
FuncEval.h:107
Cantera::CanteraError
Base class for exceptions thrown by Cantera classes.
Definition:
ctexceptions.h:65
Cantera::FuncEval::m_sens_params
vector_fp m_sens_params
Values for the problem parameters for which sensitivities are computed This is the array which is per...
Definition:
FuncEval.h:92
Cantera::FuncEval::suppressErrors
bool suppressErrors() const
Get current state of error suppression.
Definition:
FuncEval.h:82
Cantera::FuncEval::eval_nothrow
int eval_nothrow(double t, double *y, double *ydot)
Evaluate the right-hand side using return code to indicate status.
Definition:
FuncEval.cpp:12
Cantera::writelogendl
void writelogendl()
Write an end of line character to the screen and flush output.
Definition:
global.cpp:38
Cantera
Namespace for the Cantera kernel.
Definition:
application.cpp:29
Generated by
1.8.14