MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
PoolBase.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 ** This program is part of 'MOOSE', the
3 ** Messaging Object Oriented Simulation Environment.
4 ** Copyright (C) 2003-2010 Upinder S. Bhalla. and NCBS
5 ** It is made available under the terms of the
6 ** GNU Lesser General Public License version 2.1
7 ** See the file COPYING.LIB for the full notice.
8 **********************************************************************/
9 
10 #include "header.h"
11 #include "ElementValueFinfo.h"
12 #include "lookupVolumeFromMesh.h"
13 #include "PoolBase.h"
14 
15 #define EPSILON 1e-15
16 
18 
20 {
22  // Field Definitions
25  "n",
26  "Number of molecules in pool",
29  );
30 
32  "nInit",
33  "Initial value of number of molecules in pool",
36  );
37 
39  "diffConst",
40  "Diffusion constant of molecule",
43  );
44 
45  static ElementValueFinfo< PoolBase, double > motorConst(
46  "motorConst",
47  "Motor transport rate molecule. + is away from soma, - is "
48  "towards soma. Only relevant for ZombiePool subclasses.",
51  );
52 
54  "conc",
55  "Concentration of molecules in this pool",
58  );
59 
61  "concInit",
62  "Initial value of molecular concentration in pool",
65  );
66 
68  "volume",
69  "Volume of compartment. Units are SI. "
70  "Utility field, the actual volume info is "
71  "stored on a volume mesh entry in the parent compartment."
72  "This mapping is implicit: the parent compartment must be "
73  "somewhere up the element tree, and must have matching mesh "
74  "entries. If the compartment isn't"
75  "available the volume is just taken as 1",
78  );
79 
81  "speciesId",
82  "Species identifier for this mol pool. Eventually link to ontology.",
85  );
86 
87  static ElementValueFinfo< PoolBase, bool > isBuffered(
88  "isBuffered",
89  "Flag: True if Pool is buffered. "
90  "In the case of Pool and BufPool the field can be assigned, to "
91  "change the type of the Pool object to BufPool, or vice versa. "
92  "None of the messages are affected. "
93  "This object class flip can only be done in the non-zombified "
94  "form of the Pool/BufPool. In Zombies it is read-only.",
97  );
98 
100  // MsgDest Definitions
102  static DestFinfo process( "process",
103  "Handles process call",
105  static DestFinfo reinit( "reinit",
106  "Handles reinit call",
108 
109  static DestFinfo reacDest( "reacDest",
110  "Handles reaction input",
112  );
113 
114  static DestFinfo handleMolWt( "handleMolWt",
115  "Separate finfo to assign molWt, and consequently diffusion const."
116  "Should only be used in SharedMsg with species.",
118  );
120  // MsgDest Definitions: These three are used for non-reaction
121  // calculations involving algebraically defined rate terms.
123  static DestFinfo increment( "increment",
124  "Increments mol numbers by specified amount. Can be +ve or -ve",
126  );
127 
128  static DestFinfo decrement( "decrement",
129  "Decrements mol numbers by specified amount. Can be +ve or -ve",
131  );
132 
133  static DestFinfo nIn( "nIn",
134  "Assigns the number of molecules in Pool to specified value",
136  );
137 
139  // SrcFinfo Definitions
141 
142  static SrcFinfo1< double > nOut(
143  "nOut",
144  "Sends out # of molecules in pool on each timestep"
145  );
146 
147  static SrcFinfo0 requestMolWt(
148  "requestMolWt",
149  "Requests Species object for mol wt"
150  );
151 
153  // SharedMsg Definitions
155  static Finfo* reacShared[] =
156  {
157  &reacDest, &nOut
158  };
159  static SharedFinfo reac( "reac",
160  "Connects to reaction",
161  reacShared, sizeof( reacShared ) / sizeof( const Finfo* )
162  );
163  static Finfo* procShared[] =
164  {
165  &process, &reinit
166  };
167  static SharedFinfo proc( "proc",
168  "Shared message for process and reinit",
169  procShared, sizeof( procShared ) / sizeof( const Finfo* )
170  );
171 
172  static Finfo* speciesShared[] =
173  {
174  &requestMolWt, &handleMolWt
175  };
176 
177  static SharedFinfo species( "species",
178  "Shared message for connecting to species objects",
179  speciesShared, sizeof( speciesShared ) / sizeof ( const Finfo* )
180  );
181 
182  static Finfo* poolFinfos[] =
183  {
184  &n, // Value
185  &nInit, // Value
186  &diffConst, // Value
187  &motorConst, // Value
188  &conc, // Value
189  &concInit, // Value
190  &volume, // Readonly Value
191  &speciesId, // Value
192  &isBuffered, // Value
193  &increment, // DestFinfo
194  &decrement, // DestFinfo
195  &nIn, // DestFinfo
196  &reac, // SharedFinfo
197  &proc, // SharedFinfo
198  &species, // SharedFinfo
199  };
200 
201  static string doc[] =
202  {
203  "Name", "PoolBase",
204  "Author", "Upi Bhalla",
205  "Description", "Abstract base class for pools."
206  };
207  static ZeroSizeDinfo< int > dinfo;
208  static Cinfo poolCinfo (
209  "PoolBase",
211  poolFinfos,
212  sizeof( poolFinfos ) / sizeof ( Finfo* ),
213  &dinfo,
214  doc,
215  sizeof( doc )/sizeof( string ),
216  true // Ban creation as this is an abstract base class.
217  );
218 
219  return &poolCinfo;
220 }
221 
223 // Class definitions
226 
229  : concInit_( 0.0 )
230 {;}
231 
233 {;}
234 
236 // MsgDest Definitions
238 
239 void PoolBase::process( const Eref& e, ProcPtr p )
240 {
241  vProcess( e, p );
242 }
243 
244 void PoolBase::reinit( const Eref& e, ProcPtr p )
245 {
246  vReinit( e, p );
247 }
248 
249 void PoolBase::increment( double val )
250 {
251  vIncrement(val);
252 }
253 
254 void PoolBase::decrement( double val )
255 {
256  vDecrement( val );
257 }
258 
259 void PoolBase::nIn( double val)
260 {
261  vnIn(val);
262 }
263 
264 void PoolBase::reac( double A, double B )
265 {
266  vReac( A, B );
267 }
268 
269 void PoolBase::handleMolWt( const Eref& e, double v )
270 {
271  vHandleMolWt( e, v );
272 }
273 
275 // virtual MsgDest Definitions
277 
278 void PoolBase::vProcess( const Eref& e, ProcPtr p )
279 {;}
280 
281 void PoolBase::vReinit( const Eref& e, ProcPtr p )
282 {;}
283 
284 void PoolBase::vReac( double A, double B )
285 {;}
286 
287 void PoolBase::vHandleMolWt( const Eref& e, double v )
288 {;}
289 
290 void PoolBase::vIncrement( double val )
291 {;}
292 
293 void PoolBase::vDecrement( double val )
294 {;}
295 
296 void PoolBase::vnIn( double val)
297 {;}
298 
300 // Field Definitions
302 
303 void PoolBase::setN( const Eref& e, double v )
304 {
305  vSetN( e, v );
306 }
307 
308 double PoolBase::getN( const Eref& e ) const
309 {
310  return vGetN( e );
311 }
312 
313 void PoolBase::setNinit( const Eref& e, double v )
314 {
315  concInit_ = v / ( NA * lookupVolumeFromMesh( e ) );
316  vSetNinit( e, v );
317 }
318 
319 double PoolBase::getNinit( const Eref& e ) const
320 {
321  return vGetNinit( e );
322 }
323 
324 // Conc is given in millimolar. Volume is in m^3
325 void PoolBase::setConc( const Eref& e, double c )
326 {
327  vSetConc( e, c );
328 }
329 
330 // Returns conc in millimolar.
331 double PoolBase::getConc( const Eref& e ) const
332 {
333  return vGetConc( e );
334 }
335 
336 void PoolBase::setConcInit( const Eref& e, double c )
337 {
338  concInit_ = c;
339  vSetConcInit( e, c );
340 }
341 
342 double PoolBase::vGetConcInit( const Eref& e ) const
343 {
344  return concInit_;
345 }
346 
347 double PoolBase::getConcInit( const Eref& e ) const
348 {
349  // return concInit_;
350  return vGetConcInit( e );
351 }
352 
353 void PoolBase::setDiffConst( const Eref& e, double v )
354 {
355  vSetDiffConst( e, v );
356 }
357 
358 double PoolBase::getDiffConst(const Eref& e ) const
359 {
360  return vGetDiffConst( e );
361 }
362 
363 void PoolBase::setMotorConst( const Eref& e, double v )
364 {
365  vSetMotorConst( e, v );
366 }
367 
368 double PoolBase::getMotorConst(const Eref& e ) const
369 {
370  return vGetMotorConst( e );
371 }
372 
373 void PoolBase::setVolume( const Eref& e, double v )
374 {
375  vSetVolume( e, v );
376 }
377 
378 double PoolBase::getVolume( const Eref& e ) const
379 {
380  return vGetVolume( e );
381 }
382 
383 void PoolBase::setSpecies( const Eref& e, unsigned int v )
384 {
385  vSetSpecies( e, v );
386 }
387 
388 unsigned int PoolBase::getSpecies( const Eref& e ) const
389 {
390  return vGetSpecies( e );
391 }
392 
396 void PoolBase::setIsBuffered( const Eref& e, bool v )
397 {
398  vSetIsBuffered( e, v );
399 }
400 
401 bool PoolBase::getIsBuffered( const Eref& e ) const
402 {
403  return vGetIsBuffered( e );
404 }
405 
407 // Virtual Field Definitions
409 
411 void PoolBase::vSetMotorConst( const Eref& e, double v )
412 {;}
413 
414 double PoolBase::vGetMotorConst(const Eref& e ) const
415 {
416  return 0.0;
417 }
418 
420 void PoolBase::vSetIsBuffered( const Eref& e, bool v )
421 {;}
422 
424 // Zombie conversion routine: Converts Pool subclasses. There
425 // will typically be a target specific follow-up function, for example,
426 // to assign a pointer to the stoichiometry class.
427 // There should also be a subsequent call to resched for the entire tree.
429 // static func
430 void PoolBase::zombify( Element* orig, const Cinfo* zClass,
431  Id ksolve, Id dsolve )
432 {
433  if ( orig->cinfo() == zClass )
434  return;
435  unsigned int start = orig->localDataStart();
436  unsigned int num = orig->numLocalData();
437  if ( num == 0 )
438  return;
439  vector< unsigned int > species( num, 0 );
440  vector< double > concInit( num, 0.0 );
441  vector< double > diffConst( num, 0.0 );
442  vector< double > motorConst( num, 0.0 );
443  for ( unsigned int i = 0; i < num; ++i )
444  {
445  Eref er( orig, i + start );
446  const PoolBase* pb =
447  reinterpret_cast< const PoolBase* >( er.data() );
448  species[ i ] = pb->getSpecies( er );
449  concInit[ i ] = pb->getConcInit( er );
450  diffConst[ i ] = pb->getDiffConst( er );
451  motorConst[ i ] = pb->getMotorConst( er );
452  }
453  orig->zombieSwap( zClass );
454  for ( unsigned int i = 0; i < num; ++i )
455  {
456  Eref er( orig, i + start );
457  PoolBase* pb = reinterpret_cast< PoolBase* >( er.data() );
458  pb->vSetSolver( ksolve, dsolve );
459  pb->setSpecies( er, species[i] );
460  pb->setConcInit( er, concInit[i] );
461  pb->setDiffConst( er, diffConst[i] );
462  pb->setMotorConst( er, motorConst[i] );
463  }
464 }
465 
466 // Virtual func: default does nothing.
467 void PoolBase::vSetSolver( Id ksolve, Id dsolve )
468 {
469  ;
470 }
virtual SpeciesId vGetSpecies(const Eref &e) const =0
virtual void vSetVolume(const Eref &e, double v)=0
char * data() const
Definition: Eref.cpp:41
void setVolume(const Eref &e, double v)
Definition: PoolBase.cpp:373
SpeciesId getSpecies(const Eref &e) const
Definition: PoolBase.cpp:388
const double NA
Definition: consts.cpp:15
void handleMolWt(const Eref &e, double v)
Definition: PoolBase.cpp:269
void setConc(const Eref &e, double v)
Definition: PoolBase.cpp:325
virtual void vHandleMolWt(const Eref &e, double v)
Definition: PoolBase.cpp:287
static const Cinfo * initCinfo()
Definition: PoolBase.cpp:19
virtual void vDecrement(double val)
Definition: PoolBase.cpp:293
Definition: EpFunc.h:64
double concInit_
Definition: PoolBase.h:157
void setConcInit(const Eref &e, double v)
Definition: PoolBase.cpp:336
virtual void zombieSwap(const Cinfo *zCinfo)
virtual func, this base version must be called by all derived classes
Definition: Element.cpp:159
double getMotorConst(const Eref &e) const
Definition: PoolBase.cpp:368
virtual void vSetMotorConst(const Eref &e, double v)
Dummy MotorConst field for most Pool subclasses.
Definition: PoolBase.cpp:411
void setDiffConst(const Eref &e, double v)
Definition: PoolBase.cpp:353
const SpeciesId DefaultSpeciesId
Definition: PoolBase.cpp:17
virtual void vSetSpecies(const Eref &e, SpeciesId v)=0
virtual double vGetVolume(const Eref &e) const =0
static void zombify(Element *original, const Cinfo *zClass, Id ksolve, Id dsolve)
Definition: PoolBase.cpp:430
Definition: OpFunc.h:40
virtual double vGetDiffConst(const Eref &e) const =0
double getConc(const Eref &e) const
Definition: PoolBase.cpp:331
virtual void vSetConcInit(const Eref &e, double v)=0
virtual double vGetConcInit(const Eref &e) const
Definition: PoolBase.cpp:342
void nIn(double val)
Definition: PoolBase.cpp:259
virtual void vIncrement(double val)
Definition: PoolBase.cpp:290
void setNinit(const Eref &e, double v)
Definition: PoolBase.cpp:313
double getVolume(const Eref &e) const
Definition: PoolBase.cpp:378
virtual double vGetN(const Eref &e) const =0
virtual void vReac(double A, double B)
Definition: PoolBase.cpp:284
virtual void vSetConc(const Eref &e, double v)=0
virtual ~PoolBase()
Definition: PoolBase.cpp:232
virtual void vReinit(const Eref &e, ProcPtr p)
Definition: PoolBase.cpp:281
void reinit(const Eref &e, ProcPtr p)
Definition: PoolBase.cpp:244
virtual double vGetMotorConst(const Eref &e) const
Definition: PoolBase.cpp:414
Definition: OpFunc.h:27
Definition: Eref.h:26
const SrcFinfo1< double > & nOut
Definition: Pool.cpp:49
virtual void vSetDiffConst(const Eref &e, double v)=0
const Cinfo * cinfo() const
Definition: Element.cpp:66
virtual double vGetConc(const Eref &e) const =0
void decrement(double val)
Definition: PoolBase.cpp:254
unsigned int SpeciesId
Definition: PoolBase.h:18
virtual unsigned int localDataStart() const =0
Returns index of first data entry on this node.
virtual unsigned int numLocalData() const =0
Returns number of local data entries on this node.
void setIsBuffered(const Eref &e, bool v)
Definition: PoolBase.cpp:396
double getConcInit(const Eref &e) const
Definition: PoolBase.cpp:347
void increment(double val)
Definition: PoolBase.cpp:249
void setMotorConst(const Eref &e, double v)
Definition: PoolBase.cpp:363
void reac(double A, double B)
Definition: PoolBase.cpp:264
virtual double vGetNinit(const Eref &e) const =0
Definition: Id.h:17
static const Cinfo * poolCinfo
Definition: PoolBase.cpp:225
virtual void vSetNinit(const Eref &e, double v)=0
static const Cinfo * initCinfo()
Definition: Neutral.cpp:16
double getNinit(const Eref &e) const
Definition: PoolBase.cpp:319
virtual bool vGetIsBuffered(const Eref &e) const =0
bool getIsBuffered(const Eref &e) const
Definition: PoolBase.cpp:401
double getDiffConst(const Eref &e) const
Definition: PoolBase.cpp:358
virtual void vSetSolver(Id ksolve, Id dsolve)
Definition: PoolBase.cpp:467
virtual void vProcess(const Eref &e, ProcPtr p)
Definition: PoolBase.cpp:278
Definition: Cinfo.h:18
virtual void vSetN(const Eref &e, double v)=0
virtual void vSetIsBuffered(const Eref &e, bool v)
I put in a default empty function for vSetIsBuffered.
Definition: PoolBase.cpp:420
double getN(const Eref &e) const
Definition: PoolBase.cpp:308
void process(const Eref &e, ProcPtr p)
Definition: PoolBase.cpp:239
double lookupVolumeFromMesh(const Eref &e)
void setSpecies(const Eref &e, SpeciesId v)
Definition: PoolBase.cpp:383
virtual void vnIn(double val)
Definition: PoolBase.cpp:296
void setN(const Eref &e, double v)
Definition: PoolBase.cpp:303
Definition: Finfo.h:12