MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
FuncTerm Class Reference

#include <FuncTerm.h>

+ Collaboration diagram for FuncTerm:

Public Member Functions

void evalPool (double *s, double t) const
 
 FuncTerm ()
 
const string & getExpr () const
 
const vector< unsigned int > & getReactantIndex () const
 
const unsigned int getTarget () const
 
double getVolScale () const
 
double operator() (const double *S, double t) const
 
const FuncTermoperator= (const FuncTerm &other)
 
void setExpr (const string &e)
 
void setReactantIndex (const vector< unsigned int > &mol)
 
void setTarget (unsigned int tgt)
 
void setVolScale (double vs)
 
 ~FuncTerm ()
 

Private Attributes

double * args_
 
string expr_
 
mu::Parser parser_
 
vector< unsigned int > reactantIndex_
 
unsigned int target_
 
double volScale_
 

Detailed Description

Definition at line 15 of file FuncTerm.h.

Constructor & Destructor Documentation

FuncTerm::FuncTerm ( )

Definition at line 30 of file FuncTerm.cpp.

References args_, M_E, M_PI, and parser_.

31  : reactantIndex_( 1, 0 ),
32  volScale_( 1.0 ),
33  target_( ~0U)
34 {
35  args_ = 0;
36  parser_.DefineConst(_T("pi"), (mu::value_type)M_PI);
37  parser_.DefineConst(_T("e"), (mu::value_type)M_E);
38 }
unsigned int target_
Definition: FuncTerm.h:54
double * args_
Definition: FuncTerm.h:43
double value_type
double volScale_
Definition: FuncTerm.h:53
mu::Parser parser_
Definition: FuncTerm.h:46
#define M_PI
Definition: numutil.h:34
#define M_E
Definition: numutil.h:38
vector< unsigned int > reactantIndex_
Definition: FuncTerm.h:45
FuncTerm::~FuncTerm ( )

Definition at line 40 of file FuncTerm.cpp.

References args_.

41 {
42  if (args_) {
43  delete[] args_;
44  }
45 }
double * args_
Definition: FuncTerm.h:43

Member Function Documentation

void FuncTerm::evalPool ( double *  s,
double  t 
) const

Definition at line 156 of file FuncTerm.cpp.

References args_, parser_, reactantIndex_, showError(), target_, and volScale_.

157 {
158  if ( !args_ || target_ == ~0U )
159  return;
160  unsigned int i;
161  for ( i = 0; i < reactantIndex_.size(); ++i )
162  args_[i] = S[reactantIndex_[i]];
163  args_[i] = t;
164  try
165  {
166  S[ target_] = parser_.Eval() * volScale_;
167  }
168  catch ( mu::Parser::exception_type & e )
169  {
170  showError( e );
171  //throw e;
172  }
173 }
unsigned int target_
Definition: FuncTerm.h:54
double * args_
Definition: FuncTerm.h:43
double volScale_
Definition: FuncTerm.h:53
mu::Parser parser_
Definition: FuncTerm.h:46
void showError(mu::Parser::exception_type &e)
Definition: FuncTerm.cpp:73
vector< unsigned int > reactantIndex_
Definition: FuncTerm.h:45

+ Here is the call graph for this function:

const string & FuncTerm::getExpr ( ) const

Definition at line 95 of file FuncTerm.cpp.

References expr_.

Referenced by FuncRate::getExpr().

96 {
97  return expr_;
98 }
string expr_
Definition: FuncTerm.h:47

+ Here is the caller graph for this function:

const vector< unsigned int > & FuncTerm::getReactantIndex ( ) const

Definition at line 67 of file FuncTerm.cpp.

References reactantIndex_.

Referenced by Gsolve::fillPoolFuncDep(), and FuncRate::getFuncArgIndex().

68 {
69  return reactantIndex_;
70 }
vector< unsigned int > reactantIndex_
Definition: FuncTerm.h:45

+ Here is the caller graph for this function:

const unsigned int FuncTerm::getTarget ( ) const

Definition at line 105 of file FuncTerm.cpp.

References target_.

Referenced by FuncRate::copyWithVolScaling(), Gsolve::fillPoolFuncDep(), and FuncRate::getReactants().

106 {
107  return target_;
108 }
unsigned int target_
Definition: FuncTerm.h:54

+ Here is the caller graph for this function:

double FuncTerm::getVolScale ( ) const

Definition at line 115 of file FuncTerm.cpp.

References volScale_.

116 {
117  return volScale_;
118 }
double volScale_
Definition: FuncTerm.h:53
double FuncTerm::operator() ( const double *  S,
double  t 
) const

This computes the value. The time t is an argument needed by some functions.

Definition at line 135 of file FuncTerm.cpp.

References args_, parser_, reactantIndex_, and volScale_.

136 {
137  if ( !args_ )
138  return 0.0;
139  unsigned int i;
140  for ( i = 0; i < reactantIndex_.size(); ++i )
141  args_[i] = S[reactantIndex_[i]];
142  args_[i] = t;
143  try
144  {
145  double result = parser_.Eval() * volScale_;
146  return result;
147  }
148  catch (mu::Parser::exception_type &e )
149  {
150  cerr << "Error: " << e.GetMsg() << endl;
151  throw e;
152  }
153 
154 }
double * args_
Definition: FuncTerm.h:43
double volScale_
Definition: FuncTerm.h:53
mu::Parser parser_
Definition: FuncTerm.h:46
vector< unsigned int > reactantIndex_
Definition: FuncTerm.h:45
const FuncTerm & FuncTerm::operator= ( const FuncTerm other)

Definition at line 120 of file FuncTerm.cpp.

References args_, expr_, parser_, reactantIndex_, setReactantIndex(), target_, and volScale_.

121 {
122  args_ = 0; // Don't delete it, the original one is still using it.
123  parser_ = other.parser_;
124  expr_ = other.expr_;
125  volScale_ = other.volScale_;
126  target_ = other.target_;
128  return *this;
129 }
unsigned int target_
Definition: FuncTerm.h:54
double * args_
Definition: FuncTerm.h:43
string expr_
Definition: FuncTerm.h:47
void setReactantIndex(const vector< unsigned int > &mol)
Definition: FuncTerm.cpp:47
double volScale_
Definition: FuncTerm.h:53
mu::Parser parser_
Definition: FuncTerm.h:46
vector< unsigned int > reactantIndex_
Definition: FuncTerm.h:45

+ Here is the call graph for this function:

void FuncTerm::setExpr ( const string &  e)

Definition at line 83 of file FuncTerm.cpp.

References expr_, parser_, and showError().

Referenced by Stoich::installAndUnschedFunc(), FuncRate::setExpr(), Stoich::setFunctionExpr(), and testFuncTerm().

84 {
85  try {
86  parser_.SetExpr( expr );
87  expr_ = expr;
88  } catch(mu::Parser::exception_type &e) {
89  showError(e);
90  //return;
91  throw(e);
92  }
93 }
string expr_
Definition: FuncTerm.h:47
mu::Parser parser_
Definition: FuncTerm.h:46
void showError(mu::Parser::exception_type &e)
Definition: FuncTerm.cpp:73

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void FuncTerm::setReactantIndex ( const vector< unsigned int > &  mol)

This function finds the reactant indices in the vector S. It returns the number of indices found, which are the entries in molIndex.

Definition at line 47 of file FuncTerm.cpp.

References args_, parser_, and reactantIndex_.

Referenced by Stoich::installAndUnschedFunc(), operator=(), FuncRate::setFuncArgIndex(), and testFuncTerm().

48 {
49  reactantIndex_ = mol;
50  if ( args_ ) {
51  delete[] args_;
52  args_ = 0;
53  }
54  args_ = new double[ mol.size() + 1 ];
55  // args_.resize( mol.size() + 1, 0.0 );
56  for ( unsigned int i = 0; i < mol.size(); ++i ) {
57  stringstream ss;
58  args_[i] = 0.0;
59  ss << "x" << i;
60  parser_.DefineVar( ss.str(), &args_[i] );
61  }
62  // Define a 't' variable even if we don't always use it.
63  args_[mol.size()] = 0.0;
64  parser_.DefineVar( "t", &args_[mol.size()] );
65 }
double * args_
Definition: FuncTerm.h:43
mu::Parser parser_
Definition: FuncTerm.h:46
vector< unsigned int > reactantIndex_
Definition: FuncTerm.h:45

+ Here is the caller graph for this function:

void FuncTerm::setTarget ( unsigned int  tgt)

Definition at line 100 of file FuncTerm.cpp.

References target_.

Referenced by FuncRate::FuncRate(), Stoich::installAndUnschedFunc(), and FuncRate::setReactants().

101 {
102  target_ = t;
103 }
unsigned int target_
Definition: FuncTerm.h:54

+ Here is the caller graph for this function:

void FuncTerm::setVolScale ( double  vs)

Definition at line 110 of file FuncTerm.cpp.

References volScale_.

Referenced by Stoich::installAndUnschedFunc().

111 {
112  volScale_ = vs;
113 }
double volScale_
Definition: FuncTerm.h:53

+ Here is the caller graph for this function:

Member Data Documentation

double* FuncTerm::args_
private

Definition at line 43 of file FuncTerm.h.

Referenced by evalPool(), FuncTerm(), operator()(), operator=(), setReactantIndex(), and ~FuncTerm().

string FuncTerm::expr_
private

Definition at line 47 of file FuncTerm.h.

Referenced by getExpr(), operator=(), and setExpr().

mu::Parser FuncTerm::parser_
private

Definition at line 46 of file FuncTerm.h.

Referenced by evalPool(), FuncTerm(), operator()(), operator=(), setExpr(), and setReactantIndex().

vector< unsigned int > FuncTerm::reactantIndex_
private

Definition at line 45 of file FuncTerm.h.

Referenced by evalPool(), getReactantIndex(), operator()(), operator=(), and setReactantIndex().

unsigned int FuncTerm::target_
private

Definition at line 54 of file FuncTerm.h.

Referenced by evalPool(), getTarget(), operator=(), and setTarget().

double FuncTerm::volScale_
private

Scale factor to account for pool volume if we are assigning conc rather than N. Note that this conc will not be further updated so this is an undesirable option.

Definition at line 53 of file FuncTerm.h.

Referenced by evalPool(), getVolScale(), operator()(), operator=(), and setVolScale().


The documentation for this class was generated from the following files: