#include <Function.h>
Public Member Functions | |
Function () | |
Function (const Function &rhs) | |
~Function () | |
void | setExpr (const Eref &e, string expr) |
string | getExpr (const Eref &e) const |
vector< string > | getVars () const |
void | setVarValues (vector< string > vars, vector< double > vals) |
void | setVar (unsigned int index, double value) |
Variable * | getVar (unsigned int ii) |
double | getValue () const |
double | getRate () const |
void | setMode (unsigned int mode) |
unsigned int | getMode () const |
void | setNumVar (unsigned int num) |
unsigned int | getNumVar () const |
void | setConst (string name, double value) |
double | getConst (string name) const |
void | setIndependent (string index) |
string | getIndependent () const |
vector< double > | getY () const |
double | getDerivative () const |
Function & | operator= (const Function rhs) |
unsigned int | addVar () |
void | process (const Eref &e, ProcPtr p) |
void | reinit (const Eref &e, ProcPtr p) |
Static Public Member Functions | |
static const Cinfo * | initCinfo () |
Static Public Attributes | |
static const int | VARMAX |
Protected Member Functions | |
void | _clearBuffer () |
void | _showError (mu::Parser::exception_type &e) const |
Protected Attributes | |
bool | _valid |
unsigned int | _numVar |
double | _lastValue |
double | _value |
double | _rate |
unsigned int | _mode |
vector< Variable * > | _varbuf |
vector< double * > | _pullbuf |
map< string, double * > | _constbuf |
string | _independent |
mu::Parser | _parser |
char * | _stoich |
Friends | |
double * | _functionAddVar (const char *name, void *data) |
Function::Function | ( | ) |
References _clearBuffer(), _functionAddVar, _independent, _parser, _showError(), _valid, M_E, and M_PI.
Function::Function | ( | const Function & | rhs | ) |
References _functionAddVar, _independent, _parser, _pullbuf, _varbuf, getExpr(), M_E, M_PI, and setExpr().
Function::~Function | ( | ) |
void Function::_clearBuffer | ( | ) | [protected] |
References _numVar, _parser, _pullbuf, and _varbuf.
Referenced by Function(), operator=(), setNumVar(), and ~Function().
void Function::_showError | ( | mu::Parser::exception_type & | e | ) | const [protected] |
Referenced by Function(), getDerivative(), and getValue().
unsigned int Function::addVar | ( | ) |
This function is for automatically adding variables when setVar messages are connected.
There are two ways new variables can be created :
(1) When the user sets the expression, muParser calls _functionAddVar to get the address of the storage for each variable name in the expression.
(2) When the user connects a setVar message to a Variable. ??
This is called by Variable::addMsgCallback - which is unused.
double Function::getConst | ( | string | name | ) | const |
Referenced by initCinfo().
double Function::getDerivative | ( | ) | const |
References _independent, _parser, _showError(), and _valid.
Referenced by initCinfo(), and process().
string Function::getExpr | ( | const Eref & | e | ) | const |
References _parser, _valid, Eref::objId(), and ObjId::path().
Referenced by Function(), ZombieFunction::initCinfo(), initCinfo(), and operator=().
string Function::getIndependent | ( | ) | const |
References _independent.
Referenced by initCinfo().
unsigned int Function::getMode | ( | ) | const |
References _mode.
Referenced by initCinfo().
unsigned int Function::getNumVar | ( | ) | const |
References _numVar.
Referenced by initCinfo().
double Function::getRate | ( | ) | const |
Referenced by initCinfo().
double Function::getValue | ( | ) | const |
References _parser, _showError(), and _valid.
Referenced by initCinfo(), and process().
Variable * Function::getVar | ( | unsigned int | ii | ) |
References _varbuf, and dummy().
Referenced by initCinfo().
vector<string> Function::getVars | ( | ) | const |
vector< double > Function::getY | ( | ) | const |
References _pullbuf.
Referenced by initCinfo().
const Cinfo * Function::initCinfo | ( | ) | [static] |
Reimplemented in ZombieFunction.
References getConst(), getDerivative(), getExpr(), getIndependent(), getMode(), getNumVar(), getRate(), getValue(), getVar(), getY(), Neutral::initCinfo(), Variable::initCinfo(), process(), reinit(), setConst(), setExpr(), setIndependent(), setMode(), setNumVar(), and y.
Referenced by ZombieFunction::initCinfo(), and ZombieFunction::zombify().
References _clearBuffer(), _independent, _lastValue, _mode, _parser, _pullbuf, _rate, _value, _varbuf, getExpr(), M_E, M_PI, and setExpr().
Reimplemented in ZombieFunction.
References _lastValue, _mode, _pullbuf, _rate, _valid, _value, ProcInfo::dt, getDerivative(), and getValue().
Referenced by initCinfo().
Reimplemented in ZombieFunction.
References _lastValue, _mode, _parser, _rate, _valid, _value, setExpr(), and trim().
Referenced by initCinfo().
void Function::setConst | ( | string | name, | |
double | value | |||
) |
Referenced by initCinfo().
void Function::setExpr | ( | const Eref & | e, | |
string | expr | |||
) |
Reimplemented in ZombieFunction.
Referenced by Function(), initCinfo(), operator=(), and reinit().
void Function::setIndependent | ( | string | index | ) |
Referenced by initCinfo().
void Function::setMode | ( | unsigned int | mode | ) |
References _mode.
Referenced by initCinfo().
void Function::setNumVar | ( | unsigned int | num | ) |
References _clearBuffer(), and _functionAddVar.
Referenced by initCinfo().
void Function::setVar | ( | unsigned int | index, | |
double | value | |||
) |
References _varbuf.
void Function::setVarValues | ( | vector< string > | vars, | |
vector< double > | vals | |||
) |
double* _functionAddVar | ( | const char * | name, | |
void * | data | |||
) | [friend] |
Call-back to add variables to parser automatically.
We use different storage for constants and variables. Variables are stored in a vector of Variable object pointers. They must have the name x{index} where index is any non-negative integer. Note that the vector is resized to whatever the maximum index is. It is up to the user to make sure that indices are sequential without any gap. In case there is a gap in indices, those entries will remain unused.
If the name starts with anything other than `x` or `y`, then it is taken to be a named constant, which must be set before any expression or variables and error is thrown.
NOTE: this is called not on setting expression but on first attempt at evaluation of the same, i.e. when you access `value` of the Function object.
Simple function parser and evaluator for MOOSE. This can take a mathematical expression in standard C form and a list of variables values and evaluate the results.
Referenced by Function(), and setNumVar().
map< string, double *> Function::_constbuf [protected] |
string Function::_independent [protected] |
Referenced by Function(), getDerivative(), getIndependent(), and operator=().
double Function::_lastValue [protected] |
Referenced by operator=(), process(), and reinit().
unsigned int Function::_mode [protected] |
Referenced by getMode(), operator=(), process(), reinit(), and setMode().
unsigned int Function::_numVar [protected] |
Referenced by _clearBuffer(), _functionAddVar(), and getNumVar().
mu::Parser Function::_parser [protected] |
Referenced by _clearBuffer(), Function(), getDerivative(), getExpr(), getValue(), operator=(), and reinit().
vector< double * > Function::_pullbuf [protected] |
Referenced by _clearBuffer(), _functionAddVar(), Function(), getY(), operator=(), and process().
double Function::_rate [protected] |
Referenced by getRate(), operator=(), process(), and reinit().
char* Function::_stoich [protected] |
Referenced by ZombieFunction::setSolver().
bool Function::_valid [mutable, protected] |
Referenced by Function(), getDerivative(), getExpr(), getRate(), getValue(), process(), and reinit().
double Function::_value [protected] |
Referenced by operator=(), process(), and reinit().
vector<Variable *> Function::_varbuf [protected] |
Referenced by _clearBuffer(), _functionAddVar(), Function(), getVar(), operator=(), and setVar().
const int Function::VARMAX [static] |