MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ZombiePool.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 "PoolBase.h"
12 #include "VoxelPoolsBase.h"
13 #include "../mesh/VoxelJunction.h"
14 #include "XferInfo.h"
15 #include "ZombiePoolInterface.h"
16 #include "ZombiePool.h"
17 #include "lookupVolumeFromMesh.h"
18 
19 #define EPSILON 1e-15
20 
22 {
24  // Field Definitions: All inherited from PoolBase
27  // MsgDest Definitions: All inherited from PoolBase
30  // SrcFinfo Definitions: All inherited from PoolBase
33  // SharedMsg Definitions: All inherited from PoolBase
35 
36  // Note that here the isOneZombie_ flag on the Dinfo constructor is
37  // true. This means that the duplicate and copy operations only make
38  // one copy, regardless of how big the array of zombie pools.
39  // The assumption is that each Id has a single pool, which can be
40  // present in many voxels.
41  static Dinfo< ZombiePool > dinfo( true );
42  static Cinfo zombiePoolCinfo (
43  "ZombiePool",
45  0,
46  0,
47  &dinfo
48  );
49 
50  return &zombiePoolCinfo;
51 }
52 
53 
54 
55 
57 // Class definitions
60 
62  : dsolve_( 0 ), ksolve_( 0 ), diffConst_( 1e-12 ), motorConst_( 0.0 )
63 {;}
64 
66 {;}
67 
69 // MsgDest Definitions
71 
73 // Field Definitions
75 
76 void ZombiePool::vSetN( const Eref& e, double v )
77 {
78  if ( ksolve_ )
79  ksolve_->setN( e, v );
80  if ( dsolve_ )
81  dsolve_->setN( e, v );
82  // S_[ e.index().value() ][ convertIdToPoolIndex( e.id() ) ] = v;
83 }
84 
85 double ZombiePool::vGetN( const Eref& e ) const
86 {
87  if ( ksolve_ != 0 )
88  return ksolve_->getN( e );
89  else if ( dsolve_ != 0 )
90  return dsolve_->getN( e );
91  return 0.0;
92 }
93 
94 void ZombiePool::vSetNinit( const Eref& e, double v )
95 {
96  if ( ksolve_ )
97  ksolve_->setNinit( e, v );
98  if ( dsolve_ )
99  dsolve_->setNinit( e, v );
100 }
101 
102 double ZombiePool::vGetNinit( const Eref& e ) const
103 {
104  if ( ksolve_ != 0 )
105  return ksolve_->getNinit( e );
106  else if ( dsolve_ != 0 )
107  return dsolve_->getNinit( e );
108  return 0.0;
109 }
110 
111 void ZombiePool::vSetConc( const Eref& e, double conc )
112 {
113  // unsigned int pool = convertIdToPoolIndex( e.id() );
114  double n = NA * conc * lookupVolumeFromMesh( e );
115  vSetN( e, n );
116 }
117 
118 double ZombiePool::vGetConc( const Eref& e ) const
119 {
120  return vGetN( e ) / ( NA * lookupVolumeFromMesh( e ) );
121 }
122 
123 void ZombiePool::vSetConcInit( const Eref& e, double conc )
124 {
125  double n = NA * conc * lookupVolumeFromMesh( e );
126  vSetNinit( e, n );
127 }
128 
129 // Do not get concInit from ZombiePool, the PoolBase handles it.
130 // Reconsider this, since for arrays of ZombiePools we end up with problems
131 // in that there is just a single PoolBase so all the concInits are
132 // the same. Here is a reimplementation.
133 double ZombiePool::vGetConcInit( const Eref& e ) const
134 {
135  return vGetNinit( e ) / (NA * lookupVolumeFromMesh( e ) );
136 }
137 
138 void ZombiePool::vSetDiffConst( const Eref& e, double v )
139 {
140  diffConst_ = v;
141  if ( dsolve_ )
142  dsolve_->setDiffConst( e, v );
143 }
144 
145 double ZombiePool::vGetDiffConst( const Eref& e ) const
146 {
147  return diffConst_;
148 }
149 
150 double ZombiePool::vGetMotorConst( const Eref& e ) const
151 {
152  return motorConst_;
153 }
154 
155 void ZombiePool::vSetMotorConst( const Eref& e, double v )
156 {
157  motorConst_ = v;
158  if ( dsolve_ )
159  dsolve_->setMotorConst( e, v );
160 }
161 
162 void ZombiePool::vSetSpecies( const Eref& e, unsigned int v )
163 {
164  ;
165 }
166 
167 unsigned int ZombiePool::vGetSpecies( const Eref& e ) const
168 {
169  return 0;
170 }
171 
172 void ZombiePool::vSetVolume( const Eref& e, double v )
173 {
174  assert( 0 ); // Illegal op, but should handle more gracefully.
175 }
176 
177 double ZombiePool::vGetVolume( const Eref& e ) const
178 {
179  return lookupVolumeFromMesh( e );
180 }
181 
182 bool ZombiePool::vGetIsBuffered( const Eref& e ) const
183 {
184  return false;
185 }
186 
188 // Zombie conversion functions.
190 
191 void ZombiePool::vSetSolver( Id ksolve, Id dsolve )
192 {
193  // Nasty unsafe typecast. I would have preferred to pass in a
194  // safely typed pointer but that would have exposed a low-level
195  // class for the ZombiePoolInterface.
196  if ( ksolve.element()->cinfo()->isA( "Ksolve" ) ||
197  ksolve.element()->cinfo()->isA( "Gsolve" ) ) {
198  ksolve_= reinterpret_cast< ZombiePoolInterface *>(
199  ObjId( ksolve, 0 ).data() );
200  } else if ( ksolve == Id() ) {
201  ksolve_ = 0;
202  } else {
203  cout << "Warning:ZombiePool::vSetSolver: solver class " <<
204  ksolve.element()->cinfo()->name() <<
205  " not known.\nShould be Ksolve or Gsolve\n";
206  ksolve_ = 0;
207  }
208 
209  if ( dsolve.element()->cinfo()->isA( "Dsolve" ) ) {
210  dsolve_= reinterpret_cast< ZombiePoolInterface *>(
211  ObjId( dsolve, 0 ).data() );
212  } else if ( dsolve == Id() ) {
213  dsolve_ = 0;
214  } else {
215  cout << "Warning:ZombiePool::vSetSolver: solver class " <<
216  dsolve.element()->cinfo()->name() <<
217  " not known.\nShould be Dsolve\n";
218  dsolve_ = 0;
219  }
220 }
void vSetSolver(Id ksolve, Id dsolve)
Definition: ZombiePool.cpp:191
virtual void setNinit(const Eref &e, double val)=0
Set initial # of molecules in given pool and voxel. Bdry cond.
char * data() const
Definition: ObjId.cpp:113
const double NA
Definition: consts.cpp:15
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
void vSetConcInit(const Eref &e, double v)
Definition: ZombiePool.cpp:123
virtual double getN(const Eref &e) const =0
Get # of molecules in given pool and voxel. Varies with time.
static const Cinfo * initCinfo()
Definition: ZombiePool.cpp:21
Definition: Dinfo.h:60
static const Cinfo * initCinfo()
Definition: PoolBase.cpp:19
unsigned int vGetSpecies(const Eref &e) const
Definition: ZombiePool.cpp:167
Definition: ObjId.h:20
virtual void setN(const Eref &e, double val)=0
Set # of molecules in given pool and voxel. Varies with time.
void vSetConc(const Eref &e, double v)
Definition: ZombiePool.cpp:111
const std::string & name() const
Definition: Cinfo.cpp:260
double motorConst_
Definition: ZombiePool.h:73
void vSetDiffConst(const Eref &e, double v)
Definition: ZombiePool.cpp:138
void vSetNinit(const Eref &e, double v)
Definition: ZombiePool.cpp:94
double vGetN(const Eref &e) const
Definition: ZombiePool.cpp:85
ZombiePoolInterface * dsolve_
Definition: ZombiePool.h:70
double vGetNinit(const Eref &e) const
Definition: ZombiePool.cpp:102
void vSetSpecies(const Eref &e, unsigned int v)
Definition: ZombiePool.cpp:162
bool vGetIsBuffered(const Eref &e) const
Definition: ZombiePool.cpp:182
Definition: Eref.h:26
bool isA(const string &ancestor) const
Definition: Cinfo.cpp:280
const Cinfo * cinfo() const
Definition: Element.cpp:66
void vSetVolume(const Eref &e, double v)
Definition: ZombiePool.cpp:172
double vGetMotorConst(const Eref &e) const
Definition: ZombiePool.cpp:150
virtual double getNinit(const Eref &e) const =0
get initial # of molecules in given pool and voxel. Bdry cond.
virtual void setMotorConst(const Eref &e, double val)
ZombiePoolInterface * ksolve_
Definition: ZombiePool.h:71
double vGetConc(const Eref &e) const
Definition: ZombiePool.cpp:118
virtual void setDiffConst(const Eref &e, double val)=0
Diffusion constant: Only one per pool, voxel number is ignored.
double vGetVolume(const Eref &e) const
Definition: ZombiePool.cpp:177
void vSetN(const Eref &e, double v)
Definition: ZombiePool.cpp:76
Definition: Id.h:17
double diffConst_
Definition: ZombiePool.h:72
Definition: Cinfo.h:18
double vGetDiffConst(const Eref &e) const
Definition: ZombiePool.cpp:145
void vSetMotorConst(const Eref &e, double v)
Dummy MotorConst field for most Pool subclasses.
Definition: ZombiePool.cpp:155
double lookupVolumeFromMesh(const Eref &e)
double vGetConcInit(const Eref &e) const
Definition: ZombiePool.cpp:133
static const Cinfo * zombiePoolCinfo
Definition: ZombiePool.cpp:59