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

#include <ZombieFunction.h>

+ Inheritance diagram for ZombieFunction:
+ Collaboration diagram for ZombieFunction:

Public Member Functions

void innerSetExpr (const Eref &e, string val)
 
void process (const Eref &e, ProcPtr p)
 
void reinit (const Eref &e, ProcPtr p)
 
void setSolver (Id solver, Id orig)
 
 ZombieFunction ()
 
 ~ZombieFunction ()
 
- Public Member Functions inherited from Function
unsigned int addVar ()
 
 Function ()
 
 Function (const Function &rhs)
 
double getConst (string name) const
 
double getDerivative () const
 
bool getDoEvalAtReinit () const
 
string getExpr (const Eref &e) const
 
string getIndependent () const
 
unsigned int getMode () const
 
unsigned int getNumVar () const
 
double getRate () const
 
bool getUseTrigger () const
 
double getValue () const
 
VariablegetVar (unsigned int ii)
 
vector< string > getVars () const
 
vector< double > getY () const
 
Functionoperator= (const Function rhs)
 
void process (const Eref &e, ProcPtr p)
 
void reinit (const Eref &e, ProcPtr p)
 
void setConst (string name, double value)
 
void setDoEvalAtReinit (bool doEvalAtReinit)
 
void setExpr (const Eref &e, string expr)
 
void setIndependent (string index)
 
void setMode (unsigned int mode)
 
void setNumVar (unsigned int num)
 
void setUseTrigger (bool useTrigger)
 
void setVar (unsigned int index, double value)
 
void setVarValues (vector< string > vars, vector< double > vals)
 
 ~Function ()
 

Static Public Member Functions

static const CinfoinitCinfo ()
 
static void zombify (Element *orig, const Cinfo *zClass, Id ksolve, Id dsolve)
 
- Static Public Member Functions inherited from Function
static const CinfoinitCinfo ()
 

Additional Inherited Members

- Static Public Attributes inherited from Function
static const int VARMAX
 
- Protected Member Functions inherited from Function
void _clearBuffer ()
 
void _showError (mu::Parser::exception_type &e) const
 
- Protected Attributes inherited from Function
map< string, double * > _constbuf
 
bool _doEvalAtReinit
 
string _independent
 
double _lastValue
 
unsigned int _mode
 
unsigned int _numVar
 
mu::Parser _parser
 
vector< double * > _pullbuf
 
double _rate
 
char * _stoich
 
double _t
 
bool _useTrigger
 
bool _valid
 
double _value
 
vector< Variable * > _varbuf
 

Detailed Description

Definition at line 13 of file ZombieFunction.h.

Constructor & Destructor Documentation

ZombieFunction::ZombieFunction ( )

Definition at line 107 of file ZombieFunction.cpp.

108 {;}
ZombieFunction::~ZombieFunction ( )

Definition at line 110 of file ZombieFunction.cpp.

111 {;}

Member Function Documentation

const Cinfo * ZombieFunction::initCinfo ( )
static

Definition at line 29 of file ZombieFunction.cpp.

References Function::initCinfo(), process(), reinit(), and zombieFunctionCinfo.

Referenced by zombify().

30 {
32  // Field Definitions: mostly inherited from Function
34 
36  // MsgDest Definitions: All inherited from Function
39  // SrcFinfo Definitions: All inherited from Function
42  // SharedMsg Definitions: Override Function
44  static DestFinfo process( "process",
45  "Handles process call, updates internal time stamp.",
47  static DestFinfo reinit( "reinit",
48  "Handles reinit call.",
50  static Finfo* processShared[] =
51  {
52  &process, &reinit
53  };
54 
55  static SharedFinfo proc( "proc",
56  "This is a shared message to receive Process messages "
57  "from the scheduler objects."
58  "The first entry in the shared msg is a MsgDest "
59  "for the Process operation. It has a single argument, "
60  "ProcInfo, which holds lots of information about current "
61  "time, thread, dt and so on. The second entry is a MsgDest "
62  "for the Reinit operation. It also uses ProcInfo. ",
63  processShared, sizeof( processShared ) / sizeof( Finfo* )
64  );
65 
66  // Note that here the isOneZombie_ flag on the Dinfo constructor is
67  // true. This means that the duplicate and copy operations only make
68  // one copy, regardless of how big the array of zombie pools.
69  // The assumption is that each Id has a single pool, which can be
70  // present in many voxels.
71  static Finfo *functionFinfos[] =
72  {
73  &proc,
74  };
75 
76  static string doc[] =
77  {
78  "Name", "ZombieFunction",
79  "Author", "Upi Bhalla",
80  "Description",
81  "ZombieFunction: Takes over Function, which is a general "
82  "purpose function calculator using real numbers."
83  };
84 
85  static Dinfo< ZombieFunction > dinfo;
86  static Cinfo zombieFunctionCinfo (
87  "ZombieFunction",
89  functionFinfos,
90  sizeof(functionFinfos) / sizeof(Finfo*),
91  &dinfo,
92  doc,
93  sizeof(doc)/sizeof(string)
94  );
95 
96  return &zombieFunctionCinfo;
97 }
void process(const Eref &e, ProcPtr p)
Definition: Dinfo.h:60
static const Cinfo * initCinfo()
Definition: Function.cpp:91
void reinit(const Eref &e, ProcPtr p)
static const Cinfo * zombieFunctionCinfo
Definition: Cinfo.h:18
Definition: Finfo.h:12

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ZombieFunction::innerSetExpr ( const Eref e,
string  val 
)
virtual

Reimplemented from Function.

Definition at line 128 of file ZombieFunction.cpp.

References Function::_stoich, Function::innerSetExpr(), and Stoich::setFunctionExpr().

129 {
130  Function::innerSetExpr( e, v );
131  if ( _stoich ) {
132  Stoich* s = reinterpret_cast< Stoich* >( _stoich );
133  s->setFunctionExpr( e, v );
134  } else {
135  // I had this warning here but it is triggered needlessly when we
136  // do an assignment of the Zombie function. So removed.
137  // cout << "Warning: ZombieFunction::setExpr: Stoich not set.\n";
138  }
139 }
virtual void innerSetExpr(const Eref &e, string expr)
Definition: Function.cpp:562
char * _stoich
Definition: Function.h:160
void setFunctionExpr(const Eref &e, string expr)
Definition: Stoich.cpp:2028
Definition: Stoich.h:49

+ Here is the call graph for this function:

void ZombieFunction::process ( const Eref e,
ProcPtr  p 
)

Definition at line 116 of file ZombieFunction.cpp.

References Function::_t, and ProcInfo::currTime.

Referenced by initCinfo().

117 {
118  _t = p->currTime;
119 }
double currTime
Definition: ProcInfo.h:19
double _t
Definition: Function.h:142

+ Here is the caller graph for this function:

void ZombieFunction::reinit ( const Eref e,
ProcPtr  p 
)

Definition at line 121 of file ZombieFunction.cpp.

Referenced by initCinfo().

122 {;}

+ Here is the caller graph for this function:

void ZombieFunction::setSolver ( Id  solver,
Id  orig 
)

Definition at line 145 of file ZombieFunction.cpp.

References Function::_stoich, Element::cinfo(), ObjId::data(), Id::element(), Field< A >::get(), Cinfo::isA(), Cinfo::name(), and Id::path().

Referenced by zombify().

146 {
147  if ( ksolve.element()->cinfo()->isA( "Ksolve" ) ||
148  ksolve.element()->cinfo()->isA( "Gsolve" ) ) {
149  Id sid = Field< Id >::get( ksolve, "stoich" );
150  _stoich = ObjId( sid, 0 ).data();
151  if ( _stoich == 0 )
152  cout << "Warning:ZombieFunction::setSolver: Empty Stoich on Ksolve" << ksolve.path() << endl;
153  } else if ( ksolve == Id() ) {
154  _stoich = 0;
155  } else {
156  cout << "Warning:ZombieFunction::setSolver: solver class " <<
157  ksolve.element()->cinfo()->name() <<
158  " not known.\nShould be Ksolve or Gsolve\n";
159  _stoich = 0;
160  }
161 
162  /*
163  if ( dsolve.element()->cinfo()->isA( "Dsolve" ) ) {
164  dsolve_= ObjId( dsolve, 0 ).data();
165  } else if ( dsolve == Id() ) {
166  dsolve_ = 0;
167  } else {
168  cout << "Warning:ZombieFunction::vSetSolver: solver class " <<
169  dsolve.element()->cinfo()->name() <<
170  " not known.\nShould be Dsolve\n";
171  dsolve_ = 0;
172  }
173  */
174 }
char * data() const
Definition: ObjId.cpp:113
char * _stoich
Definition: Function.h:160
Definition: ObjId.h:20
Definition: Id.h:17
static A get(const ObjId &dest, const string &field)
Definition: SetGet.h:284

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ZombieFunction::zombify ( Element orig,
const Cinfo zClass,
Id  ksolve,
Id  dsolve 
)
static

Definition at line 176 of file ZombieFunction.cpp.

References Element::cinfo(), Eref::data(), initCinfo(), Element::numLocalData(), setSolver(), and Element::zombieSwap().

Referenced by Stoich::unZombifyModel(), Stoich::zombifyModel(), and Stoich::zombifyPoolFuncWithScaling().

178 {
179  //cout << "ZombieFunction::zombify: " << orig->id().path() << endl;
180  if ( orig->cinfo() == zClass )
181  return;
182  // unsigned int start = orig->localDataStart();
183  unsigned int num = orig->numLocalData();
184  if ( num == 0 )
185  return;
186  if ( num > 1 )
187  cout << "ZombieFunction::zombify: Warning: ZombieFunction doesn't\n"
188  "handle volumes yet. Proceeding without this.\n";
189 
190  Function* f = reinterpret_cast< Function *>( Eref( orig, 0 ).data() );
191  Function temp = *f;
192  orig->zombieSwap( zClass );
193  if ( zClass == ZombieFunction::initCinfo() ) { // call SetSolver
194  ZombieFunction* zf = reinterpret_cast< ZombieFunction *>(
195  Eref( orig, 0 ).data() );
196  *zf = *static_cast< ZombieFunction* >(&temp);
197  zf->setSolver( ksolve, dsolve );
198  } else {
199  Function* nf =
200  reinterpret_cast< Function *>(Eref( orig, 0 ).data());
201  *nf = temp;
202  }
203 
204  /*
205  // We can swap the class because the class data is identical, just
206  // the moose expr and process handlers are different.
207  if ( orig->cinfo() == ZombieFunction::initCinfo() ) { // unzombify
208  orig->replaceCinfo( Function::initCinfo() );
209  } else { // zombify
210  orig->replaceCinfo( ZombieFunction::initCinfo() );
211  ZombieFunction* zf = reinterpret_cast< ZombieFunction *>(
212  Eref( orig, 0 ).data() );
213  zf->setSolver( ksolve, dsolve );
214  }
215  */
216 }
char * data() const
Definition: Eref.cpp:41
void setSolver(Id solver, Id orig)
static const Cinfo * initCinfo()
virtual void zombieSwap(const Cinfo *zCinfo)
virtual func, this base version must be called by all derived classes
Definition: Element.cpp:159
Definition: Eref.h:26
const Cinfo * cinfo() const
Definition: Element.cpp:66
virtual unsigned int numLocalData() const =0
Returns number of local data entries on this node.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


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