Newer
Older
/**********************************************************************
** This program is part of 'MOOSE', the
** Messaging Object Oriented Simulation Environment.
** Copyright (C) 2003-2010 Upinder S. Bhalla. and NCBS
** It is made available under the terms of the
** GNU Lesser General Public License version 2.1
** See the file COPYING.LIB for the full notice.
**********************************************************************/
#include "header.h"
#include "ElementValueFinfo.h"
#include "lookupVolumeFromMesh.h"
#include "PoolBase.h"
#include "Pool.h"
#define EPSILON 1e-15
const Cinfo* Pool::initCinfo()
{
//////////////////////////////////////////////////////////////
// Field Definitions: All inherited from PoolBase.
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
// MsgDest Definitions: All inherited
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
// SrcFinfo Definitions: All inherited.
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
// SharedMsg Definitions: All inherited.
//////////////////////////////////////////////////////////////
static Dinfo< Pool > dinfo;
static Cinfo poolCinfo (
"Pool",
PoolBase::initCinfo(),
&dinfo
);
return &poolCinfo;
}
//////////////////////////////////////////////////////////////
// Class definitions
//////////////////////////////////////////////////////////////
static const Cinfo* poolCinfo = Pool::initCinfo();
const SrcFinfo1< double >& nOut =
*dynamic_cast< const SrcFinfo1< double >* >(
poolCinfo->findFinfo( "nOut" ) );
Pool::Pool()
: n_( 0.0 ), nInit_( 0.0 ), diffConst_( 0.0 ), motorConst_( 0.0 ),
A_( 0.0 ), B_( 0.0 ), species_( 0 )
{;}
Pool::~Pool()
{;}
//////////////////////////////////////////////////////////////
// Field Definitions
/**
* setIsBuffered is a really nasty operation, made possible only because
* BufPool is derived from Pool and has no other fields.
* It uses a low-level replaceCinfo call to just change the
* identity of the Cinfo used, leaving everything else as is.
*/
void Pool::vSetIsBuffered( const Eref& e, bool v )
{
static const Cinfo* bufPoolCinfo = Cinfo::find( "BufPool" );
if (vGetIsBuffered( e ) == v)
return;
if (v) {
e.element()->replaceCinfo( bufPoolCinfo );
} else {
e.element()->replaceCinfo( poolCinfo );
}
}
bool Pool::vGetIsBuffered( const Eref& e ) const
/// We need this explicit check because when the moose class is
/// flipped, the internal C++ class isn't.
/// Inherited by BufPool.
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
return e.element()->cinfo()->name() == "BufPool";
}
//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
// MsgDest Definitions
//////////////////////////////////////////////////////////////
void Pool::vProcess( const Eref& e, ProcPtr p )
{
// double A = e.sumBuf( aSlot );
// double B = e.sumBuf( bSlot );
if ( n_ > EPSILON && B_ > EPSILON ) {
double C = exp( -B_ * p->dt / n_ );
n_ *= C + (A_ / B_ ) * ( 1.0 - C );
} else {
n_ += ( A_ - B_ ) * p->dt;
if ( n_ < 0.0 )
n_ = 0.0;
}
A_ = B_ = 0.0;
nOut.send( e, n_ );
}
void Pool::vReinit( const Eref& e, ProcPtr p )
{
A_ = B_ = 0.0;
n_ = getNinit( e );
nOut.send( e, n_ );
}
void Pool::vReac( double A, double B )
{
A_ += A;
B_ += B;
}
void Pool::vIncrement( double val )
{
if ( val > 0 )
A_ += val;
else
B_ -= val;
}
void Pool::vDecrement( double val )
{
if ( val < 0 )
A_ -= val;
else
B_ += val;
}
void Pool::vnIn( double val)
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
{
n_ = val;
B_ = 0;
A_ = 0;
}
void Pool::vHandleMolWt( const Eref& e, double v )
{
; // Here I should update DiffConst too.
}
//////////////////////////////////////////////////////////////
// Field Definitions
//////////////////////////////////////////////////////////////
void Pool::vSetN( const Eref& e, double v )
{
n_ = v;
}
double Pool::vGetN( const Eref& e ) const
{
return n_;
}
void Pool::vSetNinit( const Eref& e, double v )
{
nInit_ = v;
}
double Pool::vGetNinit( const Eref& e ) const
{
return nInit_;
}
// Conc is given in millimolar. Volume is in m^3
void Pool::vSetConc( const Eref& e, double c )
{
n_ = NA * c * lookupVolumeFromMesh( e );
}
// Returns conc in millimolar.
double Pool::vGetConc( const Eref& e ) const
{
return (n_ / NA) / lookupVolumeFromMesh( e );
}
void Pool::vSetConcInit( const Eref& e, double c )
{
nInit_ = NA * c * lookupVolumeFromMesh( e );
}
void Pool::vSetDiffConst( const Eref& e, double v )
{
diffConst_ = v;
}
double Pool::vGetDiffConst( const Eref& e ) const
{
return diffConst_;
}
void Pool::vSetMotorConst( const Eref& e, double v )
{
motorConst_ = v;
}
double Pool::vGetMotorConst( const Eref& e ) const
{
return motorConst_;
}
void Pool::vSetVolume( const Eref& e, double v )
{
cout << "Warning: Pool::vSetVolume: Operation not permitted. Ignored\n";
}
double Pool::vGetVolume( const Eref& e ) const
{
return lookupVolumeFromMesh( e );
}
void Pool::vSetSpecies( const Eref& e, SpeciesId v )
{
species_ = v;
}
SpeciesId Pool::vGetSpecies( const Eref& e ) const
{
return species_;
}