Cantera
2.4.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.
what
());
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:153
Cantera::CanteraError::what
const char * what() const
Get a description of the error.
Definition:
ctexceptions.cpp:24
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.
FuncEval.h
Cantera::FuncEval::m_errors
std::vector< std::string > m_errors
Errors occuring during function evaluations.
Definition:
FuncEval.h:96
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:81
Cantera::FuncEval::suppressErrors
bool suppressErrors() const
Get current state of error suppression.
Definition:
FuncEval.h:71
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:
AnyMap.cpp:8
Generated by
1.8.14