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

#include <Dsolve.h>

+ Inheritance diagram for Dsolve:
+ Collaboration diagram for Dsolve:

Public Member Functions

void build (double dt)
 
void buildMeshJunctions (const Eref &e, Id other)
 
void buildNeuroMeshJunctions (const Eref &e, Id spineD, Id psdD)
 
void calcJnChan (const DiffJunction &jn, Dsolve *other, double dt)
 
void calcJnDiff (const DiffJunction &jn, Dsolve *other, double dt)
 
void calcJnXfer (const DiffJunction &jn, const vector< unsigned int > &srcXfer, const vector< unsigned int > &destXfer, Dsolve *srcDsolve, Dsolve *destDsolve)
 
void calcJunction (const DiffJunction &jn, double dt)
 
void calcOtherJnChan (const DiffJunction &jn, Dsolve *other, double dt)
 
unsigned int convertIdToPoolIndex (Id id) const
 
unsigned int convertIdToPoolIndex (const Eref &e) const
 
 Dsolve ()
 
void fillConcChans (const vector< ObjId > &chans)
 
void filterCrossRateTerms (const vector< pair< Id, Id > > &xrt)
 
void getBlock (vector< double > &values) const
 
double getDiffConst (const Eref &e) const
 Diffusion constant: Only one per pool, voxel number is ignored. More...
 
double getDiffScale (unsigned int voxel) const
 
double getDiffVol1 (unsigned int voxel) const
 LookupFied for examining cross-solver diffusion terms. More...
 
double getDiffVol2 (unsigned int voxel) const
 
double getN (const Eref &e) const
 Get # of molecules in given pool and voxel. Varies with time. More...
 
double getNinit (const Eref &e) const
 get initial # of molecules in given pool and voxel. Bdry cond. More...
 
unsigned int getNumLocalVoxels () const
 Number of voxels here. pools_.size() == getNumLocalVoxels. More...
 
unsigned int getNumPools () const
 gets number of pools (species) handled by system. More...
 
unsigned int getNumVarPools () const
 
unsigned int getNumVoxels () const
 
vector< double > getNvec (unsigned int pool) const
 
string getPath (const Eref &e) const
 
unsigned int getPoolIndex (const Eref &e) const
 Return pool index, using Stoich ptr to do lookup. More...
 
Id getStoich () const
 
void makePoolMapFromElist (const vector< ObjId > &elist, vector< Id > &temp)
 
VoxelPoolsBasepools (unsigned int i)
 Return a pointer to the specified VoxelPool. More...
 
void print () const
 
void process (const Eref &e, ProcPtr p)
 
void rebuildPools ()
 
void reinit (const Eref &e, ProcPtr p)
 
void setBlock (const vector< double > &values)
 
void setCompartment (Id id)
 Assigns compartment. More...
 
void setDiffConst (const Eref &e, double value)
 Diffusion constant: Only one per pool, voxel number is ignored. More...
 
void setDiffScale (unsigned int voxel, double scale)
 
void setDiffVol1 (unsigned int voxel, double vol)
 
void setDiffVol2 (unsigned int voxel, double vol)
 
void setDsolve (Id id)
 Inherited, defining dummy function here. More...
 
void setMotorConst (const Eref &e, double value)
 
void setN (const Eref &e, double value)
 Set # of molecules in given pool and voxel. Varies with time. More...
 
void setNinit (const Eref &e, double value)
 Set initial # of molecules in given pool and voxel. Bdry cond. More...
 
void setNumAllVoxels (unsigned int numVoxels)
 Inherited virtual. More...
 
void setNumPools (unsigned int num)
 Specifies number of pools (species) handled by system. More...
 
void setNvec (unsigned int pool, vector< double > vec)
 
void setPath (const Eref &e, string path)
 Dummy, inherited but not used. More...
 
void setPrev ()
 Used to tell Dsolver to assign 'prev' values. More...
 
void setStoich (Id id)
 
void setupCrossSolverReacs (const map< Id, vector< Id > > &xr, Id otherStoich)
 
void setupCrossSolverReacVols (const vector< vector< Id > > &subCompts, const vector< vector< Id > > &prdCompts)
 
void updateJunctions (double dt)
 Used for telling Dsolver to handle all ops across Junctions. More...
 
void updateRateTerms (unsigned int index)
 
double volume (unsigned int i) const
 Return volume of voxel i. More...
 
 ~Dsolve ()
 
- Public Member Functions inherited from ZombiePoolInterface
Id getCompartment () const
 
 ZombiePoolInterface ()
 

Static Public Member Functions

static const CinfoinitCinfo ()
 
static void innerBuildMeshJunctions (Id self, Id other, bool isMembraneBound)
 
static void mapChansBetweenDsolves (DiffJunction &jn, Id self, Id other)
 
static void mapDiffPoolsBetweenDsolves (DiffJunction &jn, Id self, Id other)
 Sets up map of matching pools for diffusion. More...
 
static void mapXfersBetweenDsolves (vector< unsigned int > &srcPools, vector< unsigned int > &destPools, Id src, Id dest)
 

Private Attributes

vector< ConcChanInfochannels_
 Internal vector, one for each ConcChan managed by Dsolve. More...
 
double dt_
 Timestep used by diffusion calculations. More...
 
vector< DiffJunctionjunctions_
 
unsigned int numLocalPools_
 
unsigned int numTotPools_
 
unsigned int numVoxels_
 
string path_
 Path of pools managed by Dsolve, may include other classes too. More...
 
vector< unsigned int > poolMap_
 Looks up pool# from pool Id, using poolMapStart_ as offset. More...
 
unsigned int poolMapStart_
 smallest Id value for poolMap_ More...
 
vector< DiffPoolVecpools_
 Internal vector, one for each pool species managed by Dsolve. More...
 
unsigned int poolStartIndex_
 

Additional Inherited Members

- Protected Attributes inherited from ZombiePoolInterface
Id compartment_
 Id of Chem compartment used to figure out volumes of voxels. More...
 
bool isBuilt_
 Flag: True when solver setup has been completed. More...
 
Id stoich_
 

Detailed Description

The Dsolve manages a large number of pools, each inhabiting a large number of voxels that are shared for all the pools. Each pool is represented by an array of concs, one for each voxel. Each such array is kept on a single node for efficient solution. The different pool arrays are assigned to different nodes for balance. All pool arrays We have the parent Dsolve as a global. It constructs the diffusion matrix from the NeuroMesh and generates the opvecs. We have the child DiffPoolVec as a local. Each one contains a vector of pool 'n' in each voxel, plus the opvec for that pool. There is an array of DiffPoolVecs, one for each species, and we let the system put each DiffPoolVec on a suitable node for balancing. Some DiffPoolVecs are for molecules that don't diffuse. These simply have an empty opvec.

Definition at line 29 of file Dsolve.h.

Constructor & Destructor Documentation

Dsolve::Dsolve ( )

Definition at line 188 of file Dsolve.cpp.

Referenced by initCinfo().

189  :
190  dt_( -1.0 ),
191  numTotPools_( 0 ),
192  numLocalPools_( 0 ),
193  poolStartIndex_( 0 ),
194  numVoxels_( 0 )
195 {;}
unsigned int numVoxels_
Definition: Dsolve.h:204
unsigned int numTotPools_
Definition: Dsolve.h:201
double dt_
Timestep used by diffusion calculations.
Definition: Dsolve.h:199
unsigned int numLocalPools_
Definition: Dsolve.h:202
unsigned int poolStartIndex_
Definition: Dsolve.h:203

+ Here is the caller graph for this function:

Dsolve::~Dsolve ( )

Definition at line 197 of file Dsolve.cpp.

198 {;}

Member Function Documentation

void Dsolve::build ( double  dt)

This key function does the work of setting up the Dsolve. Should be called after the compartment has been attached to the Dsolve, and the stoich is assigned. Called during the setStoich function.

build: This function is called either by setStoich or setPath. By this point the diffusion consts etc will be assigned to the poolVecs. This requires

  • Stoich should be assigned, OR
  • A 'path' should be assigned which has been traversed to find pools.
  • compartment should be assigned so we know how many voxels.
  • If Stoich, its 'path' should be set so we know numPools. It needs to know the numVoxels from the compartment. At the time of path setting the zombification is done, which takes the Id of the solver.
  • After this build can be done. Just reinit doesn't make sense since the build does a lot of things which should not be repeated for each reinit.

Definition at line 723 of file Dsolve.cpp.

References FastMatrixElim::buildBackwardSub(), FastMatrixElim::buildForDiffusion(), FastMatrixElim::buildForwardElim(), FastMatrixElim::checkSymmetricShape(), ZombiePoolInterface::compartment_, Eref::data(), doubleEq(), dt_, Id::eref(), ChemCompt::getNumEntries(), MeshCompt::getParentVoxel(), MeshCompt::getVoxelArea(), MeshCompt::getVoxelLength(), ChemCompt::getVoxelVolume(), FastMatrixElim::hinesReorder(), numLocalPools_, numVoxels_, FastMatrixElim::opsReorder(), pools_, and SparseMatrix< T >::print().

Referenced by reinit().

724 {
725  if ( doubleEq( dt, dt_ ) )
726  return;
727  if ( compartment_ == Id() ) {
728  cout << "Dsolve::build: Warning: No compartment defined. \n"
729  "Did you forget to assign 'stoich.dsolve = this' ?\n";
730  return;
731  }
732  dt_ = dt;
733  const MeshCompt* m = reinterpret_cast< const MeshCompt* >(
734  compartment_.eref().data() );
735  unsigned int numVoxels = m->getNumEntries();
736 
737  for ( unsigned int i = 0; i < numLocalPools_; ++i ) {
738  bool debugFlag = false;
739  vector< unsigned int > diagIndex;
740  vector< double > diagVal;
741  vector< Triplet< double > > fops;
742  FastMatrixElim elim( numVoxels, numVoxels );
743  if ( elim.buildForDiffusion(
744  m->getParentVoxel(), m->getVoxelVolume(),
745  m->getVoxelArea(), m->getVoxelLength(),
746  pools_[i].getDiffConst(), pools_[i].getMotorConst(), dt ) )
747  {
748  vector< unsigned int > parentVoxel = m->getParentVoxel();
749  assert( elim.checkSymmetricShape() );
750  vector< unsigned int > lookupOldRowsFromNew;
751  elim.hinesReorder( parentVoxel, lookupOldRowsFromNew );
752  assert( elim.checkSymmetricShape() );
753  pools_[i].setNumVoxels( numVoxels_ );
754  elim.buildForwardElim( diagIndex, fops );
755  elim.buildBackwardSub( diagIndex, fops, diagVal );
756  elim.opsReorder( lookupOldRowsFromNew, fops, diagVal );
757  if (debugFlag )
758  elim.print();
759  }
760  pools_[i].setOps( fops, diagVal );
761  }
762 }
char * data() const
Definition: Eref.cpp:41
unsigned int numVoxels_
Definition: Dsolve.h:204
vector< double > getVoxelVolume() const
Returns vector of all voxel volumes in compartment.
Definition: ChemCompt.cpp:313
Eref eref() const
Definition: Id.cpp:125
double dt_
Timestep used by diffusion calculations.
Definition: Dsolve.h:199
virtual vector< unsigned int > getParentVoxel() const =0
unsigned int getNumEntries() const
Definition: ChemCompt.cpp:390
bool doubleEq(double x, double y)
Definition: doubleEq.cpp:16
unsigned int numLocalPools_
Definition: Dsolve.h:202
vector< DiffPoolVec > pools_
Internal vector, one for each pool species managed by Dsolve.
Definition: Dsolve.h:207
virtual const vector< double > & getVoxelArea() const =0
virtual const vector< double > & getVoxelLength() const =0
Id compartment_
Id of Chem compartment used to figure out volumes of voxels.
Definition: Id.h:17

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Dsolve::buildMeshJunctions ( const Eref e,
Id  other 
)

Builds junctions between current Dsolve and another. For this to work the respective meshes must be compatible. These junctions handle diffusion between different meshes.

Definition at line 792 of file Dsolve.cpp.

References Element::cinfo(), ZombiePoolInterface::compartment_, Id::element(), Field< A >::get(), Eref::id(), innerBuildMeshJunctions(), Cinfo::isA(), and Id::path().

Referenced by initCinfo().

793 {
794  Id otherMesh;
795  if ( other.element()->cinfo()->isA( "Dsolve" ) ) {
796  otherMesh = Field< Id >::get( other, "compartment" );
797  if ( compartment_.element()->cinfo()->isA( "ChemCompt" ) &&
798  otherMesh.element()->cinfo()->isA( "ChemCompt" ) ) {
799  bool isMembraneBound =
800  Field< bool >::get( compartment_, "isMembraneBound" );
801  innerBuildMeshJunctions( e.id(), other, isMembraneBound );
802  return;
803  }
804  }
805  cout << "Warning: Dsolve::buildMeshJunctions: one of '" <<
806  compartment_.path() << ", " << otherMesh.path() <<
807  "' is not a Mesh\n";
808 }
Id id() const
Definition: Eref.cpp:62
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
static void innerBuildMeshJunctions(Id self, Id other, bool isMembraneBound)
Definition: Dsolve.cpp:941
std::string path(const std::string &separator="/") const
Definition: Id.cpp:76
bool isA(const string &ancestor) const
Definition: Cinfo.cpp:280
const Cinfo * cinfo() const
Definition: Element.cpp:66
Id compartment_
Id of Chem compartment used to figure out volumes of voxels.
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 Dsolve::buildNeuroMeshJunctions ( const Eref e,
Id  spineD,
Id  psdD 
)

Builds junctions between Dsolves handling NeuroMesh, SpineMesh, and PsdMesh. Must only be called from the one handling the NeuroMesh. These junctions handle diffusion between different meshes. Note that a single NeuroMesh may contact many spines which are all in a single SpineMesh. Likewise each spine has a single PSD, but there are many spines in the SpineMesh and matching psds in the PsdMesh. Finally, note that there may be many molecules which diffuse across each diffusion junction.

Should be called only from the Dsolve handling the NeuroMesh.

Definition at line 768 of file Dsolve.cpp.

References Element::cinfo(), ZombiePoolInterface::compartment_, Id::element(), Field< A >::get(), Eref::id(), innerBuildMeshJunctions(), Cinfo::isA(), and Id::path().

Referenced by initCinfo().

769 {
770  if ( !compartment_.element()->cinfo()->isA( "NeuroMesh" ) ) {
771  cout << "Warning: Dsolve::buildNeuroMeshJunction: Compartment '" <<
772  compartment_.path() << "' is not a NeuroMesh\n";
773  return;
774  }
775  Id spineMesh = Field< Id >::get( spineD, "compartment" );
776  if ( !spineMesh.element()->cinfo()->isA( "SpineMesh" ) ) {
777  cout << "Warning: Dsolve::buildNeuroMeshJunction: Compartment '" <<
778  spineMesh.path() << "' is not a SpineMesh\n";
779  return;
780  }
781  Id psdMesh = Field< Id >::get( psdD, "compartment" );
782  if ( !psdMesh.element()->cinfo()->isA( "PsdMesh" ) ) {
783  cout << "Warning: Dsolve::buildNeuroMeshJunction: Compartment '" <<
784  psdMesh.path() << "' is not a PsdMesh\n";
785  return;
786  }
787 
788  innerBuildMeshJunctions( spineD, e.id(), false );
789  innerBuildMeshJunctions( psdD, spineD, false );
790 }
Id id() const
Definition: Eref.cpp:62
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
static void innerBuildMeshJunctions(Id self, Id other, bool isMembraneBound)
Definition: Dsolve.cpp:941
std::string path(const std::string &separator="/") const
Definition: Id.cpp:76
bool isA(const string &ancestor) const
Definition: Cinfo.cpp:280
const Cinfo * cinfo() const
Definition: Element.cpp:66
Id compartment_
Id of Chem compartment used to figure out volumes of voxels.
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 Dsolve::calcJnChan ( const DiffJunction jn,
Dsolve other,
double  dt 
)

Definition at line 373 of file Dsolve.cpp.

References channels_, ConcChanInfo::chanPool, DiffPoolVec::getN(), integ(), DiffJunction::myChannels, ConcChanInfo::myPool, NA, ConcChanInfo::otherPool, ConcChanInfo::permeability, pools_, DiffPoolVec::setN(), and DiffJunction::vj.

Referenced by calcJunction().

374 {
375  // Each jn has some channels
376  // Each channel has a chanPool, an intPool and an extPool.
377  // chanPool and intPool must be on self, extPool is on other. In
378  // cases where the intPool is on other, it attempts to swap the
379  // int and ext pools, but this too could fail
380  // because the chanPool could be a third compartment, such as the memb
381  //
382  // Don't have a solution for this case as yet.
383  // Other alternative is to have a message to update the N of the chan,
384  // so it isn't in the domain of the solver at all except for here.
385  // In which case we will want to point to the Moose object for it.
386  //
387 
388  for ( unsigned int i = 0; i < jn.myChannels.size(); ++i ) {
389  ConcChanInfo& myChan = channels_[ jn.myChannels[i] ];
390  DiffPoolVec& myDv = pools_[ myChan.myPool ];
391  DiffPoolVec& otherDv = other->pools_[ myChan.otherPool ];
392  DiffPoolVec& chanDv = pools_[ myChan.chanPool ];
393  for ( vector< VoxelJunction >::const_iterator
394  j = jn.vj.begin(); j != jn.vj.end(); ++j ) {
395 
396  double myN = myDv.getN( j->first );
397  double lastN = myN;
398  double otherN = otherDv.getN( j->second );
399  double chanN = chanDv.getN( j->first );
400  double perm = myChan.permeability * chanN / NA;
401  myN = integ( myN, perm * myN/j->firstVol,
402  perm * otherN/j->secondVol, dt );
403  otherN += lastN - myN; // Mass consv
404  if ( otherN < 0.0 ) { // Avoid negatives
405  myN += otherN;
406  otherN = 0.0;
407  }
408  myDv.setN( j->first, myN );
409  otherDv.setN( j->second, otherN );
410  }
411  }
412 }
void setN(unsigned int vox, double value)
Definition: DiffPoolVec.cpp:50
const double NA
Definition: consts.cpp:15
unsigned int chanPool
Definition: ConcChanInfo.h:28
unsigned int otherPool
Definition: ConcChanInfo.h:27
static double integ(double myN, double rf, double rb, double dt)
Definition: Dsolve.cpp:295
vector< ConcChanInfo > channels_
Internal vector, one for each ConcChan managed by Dsolve.
Definition: Dsolve.h:209
vector< unsigned int > myChannels
Definition: DiffJunction.h:46
double permeability
Definition: ConcChanInfo.h:32
unsigned int myPool
Definition: ConcChanInfo.h:26
vector< DiffPoolVec > pools_
Internal vector, one for each pool species managed by Dsolve.
Definition: Dsolve.h:207
vector< VoxelJunction > vj
Definition: DiffJunction.h:49
double getN(unsigned int vox) const
Definition: DiffPoolVec.cpp:44

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Dsolve::calcJnDiff ( const DiffJunction jn,
Dsolve other,
double  dt 
)

Definition at line 309 of file Dsolve.cpp.

References EPSILON, DiffPoolVec::getDiffConst(), DiffPoolVec::getN(), integ(), DiffJunction::myPools, DiffJunction::otherPools, pools_, DiffPoolVec::setN(), and DiffJunction::vj.

Referenced by calcJunction().

310 {
311  const double EPSILON = 1e-16;
312  assert( jn.otherPools.size() == jn.myPools.size() );
313  for ( unsigned int i = 0; i < jn.myPools.size(); ++i ) {
314  DiffPoolVec& myDv = pools_[ jn.myPools[i] ];
315  if ( myDv.getDiffConst() < EPSILON )
316  continue;
317  DiffPoolVec& otherDv = other->pools_[ jn.otherPools[i] ];
318  if ( otherDv.getDiffConst() < EPSILON )
319  continue;
320  // This geom mean is used in case we have the odd situation of
321  // different diffusion constants.
322  double effectiveDiffConst =
323  sqrt( myDv.getDiffConst() * otherDv.getDiffConst() );
324  for ( vector< VoxelJunction >::const_iterator
325  j = jn.vj.begin(); j != jn.vj.end(); ++j ) {
326  double myN = myDv.getN( j->first );
327  double otherN = otherDv.getN( j->second );
328  // Here we do an exp Euler calculation
329  // rf is rate from self to other.
330  // double k = myDv.getDiffConst() * j->diffScale;
331  double k = effectiveDiffConst * j->diffScale;
332  double lastN = myN;
333  myN = integ( myN,
334  k * myN / j->firstVol,
335  k * otherN / j->secondVol,
336  dt
337  );
338  otherN += lastN - myN; // Simple mass conservation
339  if ( otherN < 0.0 ) { // Avoid negatives
340  myN += otherN;
341  otherN = 0.0;
342  }
343  myDv.setN( j->first, myN );
344  otherDv.setN( j->second, otherN );
345  }
346  }
347 }
void setN(unsigned int vox, double value)
Definition: DiffPoolVec.cpp:50
vector< unsigned int > otherPools
Definition: DiffJunction.h:38
double getDiffConst() const
Definition: DiffPoolVec.cpp:87
static double integ(double myN, double rf, double rb, double dt)
Definition: Dsolve.cpp:295
vector< unsigned int > myPools
Definition: DiffJunction.h:37
vector< DiffPoolVec > pools_
Internal vector, one for each pool species managed by Dsolve.
Definition: Dsolve.h:207
vector< VoxelJunction > vj
Definition: DiffJunction.h:49
#define EPSILON
Definition: MatrixOps.h:28
double getN(unsigned int vox) const
Definition: DiffPoolVec.cpp:44

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Dsolve::calcJnXfer ( const DiffJunction jn,
const vector< unsigned int > &  srcXfer,
const vector< unsigned int > &  destXfer,
Dsolve srcDsolve,
Dsolve destDsolve 
)

Definition at line 349 of file Dsolve.cpp.

References DiffPoolVec::getN(), DiffPoolVec::getPrev(), pools_, DiffPoolVec::setN(), and DiffJunction::vj.

Referenced by calcJunction().

353 {
354  assert( destXfer.size() == srcXfer.size() );
355  for ( unsigned int i = 0; i < srcXfer.size(); ++i ) {
356  DiffPoolVec& srcDv = srcDsolve->pools_[ srcXfer[i] ];
357  DiffPoolVec& destDv = destDsolve->pools_[ destXfer[i] ];
358  for ( vector< VoxelJunction >::const_iterator
359  j = jn.vj.begin(); j != jn.vj.end(); ++j ) {
360  double prevSrc = srcDv.getPrev( j->first );
361  double prevDest = destDv.getPrev( j->second );
362  double srcN = srcDv.getN( j->first );
363  double destN = destDv.getN( j->second );
364  // Consider delta as sum of local dN, and reference as prevDest
365  // newN = (srcN - prevSrc + destN - prevDest) + prevDest
366  double newN = srcN + destN - prevSrc;
367  srcDv.setN( j->first, newN );
368  destDv.setN( j->second, newN );
369  }
370  }
371 }
void setN(unsigned int vox, double value)
Definition: DiffPoolVec.cpp:50
vector< DiffPoolVec > pools_
Internal vector, one for each pool species managed by Dsolve.
Definition: Dsolve.h:207
vector< VoxelJunction > vj
Definition: DiffJunction.h:49
double getN(unsigned int vox) const
Definition: DiffPoolVec.cpp:44
double getPrev(unsigned int vox) const
Definition: DiffPoolVec.cpp:56

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Dsolve::calcJunction ( const DiffJunction jn,
double  dt 
)

Computes flux through a junction between diffusion solvers. Most used at junctions on spines and PSDs, but can also be used when a given diff solver is decomposed. At present the lookups on the other diffusion solver assume that the data is on the local node. Once this works well I can figure out how to do across nodes.

Computes flux through a junction between diffusion solvers. Most used at junctions on spines and PSDs, but can also be used when a given diff solver is decomposed. At present the lookups on the other diffusion solver assume that the data is on the local node. Once this works well I can figure out how to do across nodes. Note that we split the diffusion and channel calculations before and after then calcJnXfer calculations. This improves accuracy by 5x.

Definition at line 457 of file Dsolve.cpp.

References calcJnChan(), calcJnDiff(), calcJnXfer(), calcOtherJnChan(), Element::cinfo(), Eref::data(), Id::element(), Id::eref(), Cinfo::isA(), DiffJunction::myXferDest, DiffJunction::myXferSrc, DiffJunction::otherDsolve, DiffJunction::otherXferDest, and DiffJunction::otherXferSrc.

Referenced by updateJunctions().

458 {
459  Id oid( jn.otherDsolve );
460  assert ( oid != Id() );
461  assert ( oid.element()->cinfo()->isA( "Dsolve" ) );
462 
463  Dsolve* other = reinterpret_cast< Dsolve* >( oid.eref().data() );
464  calcJnDiff( jn, other, dt/2.0 );
465 
466  calcJnChan( jn, other, dt/2.0 );
467  calcOtherJnChan( jn, other, dt/2.0 );
468 
469  calcJnXfer( jn, jn.myXferSrc, jn.otherXferDest, this, other );
470  calcJnXfer( jn, jn.otherXferSrc, jn.myXferDest, other, this );
471 
472  calcJnDiff( jn, other, dt/2.0 );
473 
474  calcJnChan( jn, other, dt/2.0 );
475  calcOtherJnChan( jn, other, dt/2.0 );
476 }
Definition: Dsolve.h:29
void calcJnDiff(const DiffJunction &jn, Dsolve *other, double dt)
Definition: Dsolve.cpp:309
vector< unsigned int > otherXferSrc
Definition: DiffJunction.h:44
unsigned int otherDsolve
Definition: DiffJunction.h:36
void calcJnChan(const DiffJunction &jn, Dsolve *other, double dt)
Definition: Dsolve.cpp:373
vector< unsigned int > myXferSrc
Definition: DiffJunction.h:40
vector< unsigned int > otherXferDest
Definition: DiffJunction.h:41
void calcJnXfer(const DiffJunction &jn, const vector< unsigned int > &srcXfer, const vector< unsigned int > &destXfer, Dsolve *srcDsolve, Dsolve *destDsolve)
Definition: Dsolve.cpp:349
vector< unsigned int > myXferDest
Definition: DiffJunction.h:43
void calcOtherJnChan(const DiffJunction &jn, Dsolve *other, double dt)
Definition: Dsolve.cpp:415
Definition: Id.h:17

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Dsolve::calcOtherJnChan ( const DiffJunction jn,
Dsolve other,
double  dt 
)

Definition at line 415 of file Dsolve.cpp.

References channels_, ConcChanInfo::chanPool, DiffPoolVec::getN(), integ(), ConcChanInfo::myPool, NA, DiffJunction::otherChannels, ConcChanInfo::otherPool, ConcChanInfo::permeability, pools_, DiffPoolVec::setN(), and DiffJunction::vj.

Referenced by calcJunction().

416 {
417  for ( unsigned int i = 0; i < jn.otherChannels.size(); ++i ) {
418  ConcChanInfo& otherChan = other->channels_[ jn.otherChannels[i] ];
419  // This is the DiffPoolVec for the pools on the other Dsolve,
420  // the one with the channel.
421  // DiffPoolVec& otherDv = other->pools_[ jn.otherPools[otherChan.myPool] ];
422  DiffPoolVec& otherDv = other->pools_[ otherChan.myPool ];
423  // Local diffPoolVec.
424  // DiffPoolVec& myDv = pools_[ jn.myPools[otherChan.otherPool] ];
425  DiffPoolVec& myDv = pools_[ otherChan.otherPool ];
426  DiffPoolVec& chanDv = other->pools_[ otherChan.chanPool ];
427  for ( vector< VoxelJunction >::const_iterator
428  j = jn.vj.begin(); j != jn.vj.end(); ++j ) {
429 
430  double myN = myDv.getN( j->first );
431  double lastN = myN;
432  double otherN = otherDv.getN( j->second );
433  double chanN = chanDv.getN( j->second );
434  double perm = otherChan.permeability * chanN / NA;
435  myN = integ( myN, perm * myN/j->firstVol,
436  perm * otherN/j->secondVol, dt );
437  otherN += lastN - myN; // Mass consv
438  if ( otherN < 0.0 ) { // Avoid negatives
439  myN += otherN;
440  otherN = 0.0;
441  }
442  myDv.setN( j->first, myN );
443  otherDv.setN( j->second, otherN );
444  }
445  }
446 }
void setN(unsigned int vox, double value)
Definition: DiffPoolVec.cpp:50
const double NA
Definition: consts.cpp:15
unsigned int chanPool
Definition: ConcChanInfo.h:28
unsigned int otherPool
Definition: ConcChanInfo.h:27
static double integ(double myN, double rf, double rb, double dt)
Definition: Dsolve.cpp:295
vector< ConcChanInfo > channels_
Internal vector, one for each ConcChan managed by Dsolve.
Definition: Dsolve.h:209
double permeability
Definition: ConcChanInfo.h:32
unsigned int myPool
Definition: ConcChanInfo.h:26
vector< DiffPoolVec > pools_
Internal vector, one for each pool species managed by Dsolve.
Definition: Dsolve.h:207
vector< VoxelJunction > vj
Definition: DiffJunction.h:49
vector< unsigned int > otherChannels
Definition: DiffJunction.h:47
double getN(unsigned int vox) const
Definition: DiffPoolVec.cpp:44

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

unsigned int Dsolve::convertIdToPoolIndex ( Id  id) const

Definition at line 982 of file Dsolve.cpp.

References poolMap_, and poolMapStart_.

Referenced by convertIdToPoolIndex(), fillConcChans(), getDiffConst(), getN(), getNinit(), getPoolIndex(), mapChansBetweenDsolves(), setDiffConst(), setMotorConst(), setN(), and setNinit().

983 {
984  unsigned int i = id.value() - poolMapStart_;
985  if ( i < poolMap_.size() ) {
986  return poolMap_[i];
987  }
988  cout << "Warning: Dsolve::convertIdToPoollndex: Id out of range, (" <<
989  poolMapStart_ << ", " << id << ", " << id.path() << ", " <<
990  poolMap_.size() + poolMapStart_ << "\n";
991  return 0;
992 }
unsigned int poolMapStart_
smallest Id value for poolMap_
Definition: Dsolve.h:212
vector< unsigned int > poolMap_
Looks up pool# from pool Id, using poolMapStart_ as offset.
Definition: Dsolve.h:215

+ Here is the caller graph for this function:

unsigned int Dsolve::convertIdToPoolIndex ( const Eref e) const

Definition at line 994 of file Dsolve.cpp.

References convertIdToPoolIndex(), and Eref::id().

995 {
996  return convertIdToPoolIndex( e.id() );
997 }
Id id() const
Definition: Eref.cpp:62
unsigned int convertIdToPoolIndex(Id id) const
Definition: Dsolve.cpp:982

+ Here is the call graph for this function:

void Dsolve::fillConcChans ( const vector< ObjId > &  chans)

Definition at line 547 of file Dsolve.cpp.

References ObjId::bad(), channels_, convertIdToPoolIndex(), Cinfo::find(), Cinfo::findFinfo(), ObjId::id, and Id::value().

Referenced by setStoich().

548 {
549  static const Cinfo* ccc = Cinfo::find( "ConcChan" );
550  static const Finfo* inPoolFinfo = ccc->findFinfo( "inPool" );
551  static const Finfo* outPoolFinfo = ccc->findFinfo( "outPool" );
552  static const Finfo* chanPoolFinfo = ccc->findFinfo( "setNumChan" );
553  FuncId fin = static_cast< const DestFinfo* >( inPoolFinfo )->getFid();
554  FuncId fout = static_cast< const DestFinfo* >(outPoolFinfo )->getFid();
555  FuncId fchan =
556  static_cast< const DestFinfo* >(chanPoolFinfo )->getFid();
557 
558  // Find the in pools and the chan pools on the current compt.
559  // Save the Id of the outPool as an integer.
560  // Use these and the permeability to create the ConcChanInfo.
561  for ( auto i = chans.begin(); i != chans.end(); ++i ) {
562  vector< Id > ret;
563  if (i->element()->getNeighbors( ret, inPoolFinfo ) == 0 ) return;
564  ObjId inPool( ret[0] );
565  ret.clear();
566  if (i->element()->getNeighbors( ret, outPoolFinfo ) == 0 ) return;
567  ObjId outPool( ret[0] );
568  ret.clear();
569  if (i->element()->getNeighbors( ret, chanPoolFinfo ) == 0 ) return;
570  ObjId chanPool( ret[0] );
571  ret.clear();
572  unsigned int outPoolValue = outPool.id.value();
573  bool swapped = false;
574  if ( !( inPool.bad() or chanPool.bad() ) ) {
575  unsigned int inPoolIndex = convertIdToPoolIndex( inPool.id );
576  unsigned int chanPoolIndex = convertIdToPoolIndex(chanPool.id);
577  if ( inPoolIndex == ~0U ) { // Swap in and out as chan is symm
578  inPoolIndex = convertIdToPoolIndex( outPool.id );
579  outPoolValue = inPool.id.value();
580  swapped = true;
581  }
582  if ( ( inPoolIndex != ~0U) && (chanPoolIndex != ~0U ) ) {
583  ConcChanInfo cci(
584  inPoolIndex, outPoolValue, chanPoolIndex,
585  Field< double >::get( *i, "permeability" ),
587  swapped
588  );
589  channels_.push_back( cci );
590  }
591  }
592  }
593 }
Definition: SetGet.h:236
static const Cinfo * find(const std::string &name)
Definition: Cinfo.cpp:200
Definition: ObjId.h:20
vector< ConcChanInfo > channels_
Internal vector, one for each ConcChan managed by Dsolve.
Definition: Dsolve.h:209
unsigned int FuncId
Definition: header.h:42
Definition: Cinfo.h:18
unsigned int convertIdToPoolIndex(Id id) const
Definition: Dsolve.cpp:982
const Finfo * findFinfo(const string &name) const
Definition: Cinfo.cpp:224
Definition: Finfo.h:12

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Dsolve::filterCrossRateTerms ( const vector< pair< Id, Id > > &  xrt)
void Dsolve::getBlock ( vector< double > &  values) const
virtual

Gets block of data. The first 4 entries are passed in on the 'values' vector: the start voxel, numVoxels, start pool#, numPools. These are followed by numVoxels * numPools of data values which are filled in by the function. We assert that the entire requested block is present in this ZombiePoolInterface. The block is organized as an array of arrays of voxels; values[pool#][voxel#]

Note that numVoxels and numPools are the number in the current block, not the upper limit of the block. So values.size() == 4 + numPools * numVoxels.

Implements ZombiePoolInterface.

Definition at line 1099 of file Dsolve.cpp.

References numLocalPools_, numVoxels_, pools_, and poolStartIndex_.

1100 {
1101  unsigned int startVoxel = values[0];
1102  unsigned int numVoxels = values[1];
1103  unsigned int startPool = values[2];
1104  unsigned int numPools = values[3];
1105 
1106  assert( startVoxel + numVoxels <= numVoxels_ );
1107  assert( startPool >= poolStartIndex_ );
1108  assert( numPools + startPool <= numLocalPools_ );
1109  values.resize( 4 );
1110 
1111  for ( unsigned int i = 0; i < numPools; ++i ) {
1112  unsigned int j = i + startPool;
1113  if ( j >= poolStartIndex_ && j < poolStartIndex_ + numLocalPools_ ){
1114  vector< double >::const_iterator q =
1115  pools_[ j - poolStartIndex_ ].getNvec().begin();
1116 
1117  values.insert( values.end(),
1118  q + startVoxel, q + startVoxel + numVoxels );
1119  }
1120  }
1121 }
unsigned int numVoxels_
Definition: Dsolve.h:204
unsigned int numLocalPools_
Definition: Dsolve.h:202
vector< DiffPoolVec > pools_
Internal vector, one for each pool species managed by Dsolve.
Definition: Dsolve.h:207
unsigned int poolStartIndex_
Definition: Dsolve.h:203
double Dsolve::getDiffConst ( const Eref e) const
virtual

Diffusion constant: Only one per pool, voxel number is ignored.

Implements ZombiePoolInterface.

Definition at line 1062 of file Dsolve.cpp.

References convertIdToPoolIndex(), and pools_.

1063 {
1064  unsigned int pid = convertIdToPoolIndex( e );
1065  if ( pid >= pools_.size() ) // Ignore silently, out of range.
1066  return 0.0;
1067  return pools_[ convertIdToPoolIndex( e ) ].getDiffConst();
1068 }
vector< DiffPoolVec > pools_
Internal vector, one for each pool species managed by Dsolve.
Definition: Dsolve.h:207
unsigned int convertIdToPoolIndex(Id id) const
Definition: Dsolve.cpp:982

+ Here is the call graph for this function:

double Dsolve::getDiffScale ( unsigned int  voxel) const

Definition at line 282 of file Dsolve.cpp.

References checkJn(), VoxelJunction::diffScale, and junctions_.

Referenced by initCinfo().

283 {
284  if ( checkJn( junctions_, voxel, "getDiffScale" ) ) {
285  const VoxelJunction& vj = junctions_[0].vj[ voxel ];
286  return vj.diffScale;
287  }
288  return 0.0;
289 }
double diffScale
Definition: VoxelJunction.h:44
vector< DiffJunction > junctions_
Definition: Dsolve.h:222
static bool checkJn(const vector< DiffJunction > &jn, unsigned int voxel, const string &info)
Definition: Dsolve.cpp:225

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double Dsolve::getDiffVol1 ( unsigned int  voxel) const

LookupFied for examining cross-solver diffusion terms.

Definition at line 248 of file Dsolve.cpp.

References checkJn(), VoxelJunction::firstVol, and junctions_.

Referenced by initCinfo().

249 {
250  if ( checkJn( junctions_, voxel, "getDiffVol1" ) ) {
251  const VoxelJunction& vj = junctions_[0].vj[ voxel ];
252  return vj.firstVol;
253  }
254  return 0.0;
255 }
vector< DiffJunction > junctions_
Definition: Dsolve.h:222
double firstVol
MeshIndex for second compartment.
Definition: VoxelJunction.h:42
static bool checkJn(const vector< DiffJunction > &jn, unsigned int voxel, const string &info)
Definition: Dsolve.cpp:225

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double Dsolve::getDiffVol2 ( unsigned int  voxel) const

Definition at line 265 of file Dsolve.cpp.

References checkJn(), junctions_, and VoxelJunction::secondVol.

Referenced by initCinfo().

266 {
267  if ( checkJn( junctions_, voxel, "getDiffVol2" ) ) {
268  const VoxelJunction& vj = junctions_[0].vj[ voxel ];
269  return vj.secondVol;
270  }
271  return 0.0;
272 }
vector< DiffJunction > junctions_
Definition: Dsolve.h:222
double secondVol
Definition: VoxelJunction.h:43
static bool checkJn(const vector< DiffJunction > &jn, unsigned int voxel, const string &info)
Definition: Dsolve.cpp:225

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double Dsolve::getN ( const Eref e) const
virtual

Get # of molecules in given pool and voxel. Varies with time.

Implements ZombiePoolInterface.

Definition at line 1014 of file Dsolve.cpp.

References convertIdToPoolIndex(), Eref::dataIndex(), numVoxels_, and pools_.

1015 {
1016  unsigned int pid = convertIdToPoolIndex( e );
1017  if ( pid >= pools_.size() ) return 0.0; // ignore silently
1018  unsigned int vox = e.dataIndex();
1019  if ( vox < numVoxels_ ) {
1020  return pools_[ pid ].getN( vox );
1021  }
1022  cout << "Warning: Dsolve::setN: Eref " << e << " out of range " <<
1023  pools_.size() << ", " << numVoxels_ << "\n";
1024  return 0.0;
1025 }
unsigned int numVoxels_
Definition: Dsolve.h:204
unsigned int dataIndex() const
Definition: Eref.h:50
vector< DiffPoolVec > pools_
Internal vector, one for each pool species managed by Dsolve.
Definition: Dsolve.h:207
unsigned int convertIdToPoolIndex(Id id) const
Definition: Dsolve.cpp:982

+ Here is the call graph for this function:

double Dsolve::getNinit ( const Eref e) const
virtual

get initial # of molecules in given pool and voxel. Bdry cond.

Implements ZombiePoolInterface.

Definition at line 1041 of file Dsolve.cpp.

References convertIdToPoolIndex(), Eref::dataIndex(), numVoxels_, and pools_.

1042 {
1043  unsigned int pid = convertIdToPoolIndex( e );
1044  if ( pid >= pools_.size() ) return 0.0; // ignore silently
1045  unsigned int vox = e.dataIndex();
1046  if ( vox < numVoxels_ ) {
1047  return pools_[ pid ].getNinit( vox );
1048  }
1049  cout << "Warning: Dsolve::setNinit: Eref " << e << " out of range " <<
1050  pools_.size() << ", " << numVoxels_ << "\n";
1051  return 0.0;
1052 }
unsigned int numVoxels_
Definition: Dsolve.h:204
unsigned int dataIndex() const
Definition: Eref.h:50
vector< DiffPoolVec > pools_
Internal vector, one for each pool species managed by Dsolve.
Definition: Dsolve.h:207
unsigned int convertIdToPoolIndex(Id id) const
Definition: Dsolve.cpp:982

+ Here is the call graph for this function:

unsigned int Dsolve::getNumLocalVoxels ( ) const
virtual

Number of voxels here. pools_.size() == getNumLocalVoxels.

Implements ZombiePoolInterface.

Definition at line 1167 of file Dsolve.cpp.

References numVoxels_.

1168 {
1169  return numVoxels_;
1170 }
unsigned int numVoxels_
Definition: Dsolve.h:204
unsigned int Dsolve::getNumPools ( ) const
virtual

gets number of pools (species) handled by system.

Implements ZombiePoolInterface.

Definition at line 1093 of file Dsolve.cpp.

References numTotPools_.

Referenced by initCinfo().

1094 {
1095  return numTotPools_;
1096 }
unsigned int numTotPools_
Definition: Dsolve.h:201

+ Here is the caller graph for this function:

unsigned int Dsolve::getNumVarPools ( ) const

Definition at line 965 of file Dsolve.cpp.

966 {
967  return 0;
968 }
unsigned int Dsolve::getNumVoxels ( ) const

Definition at line 970 of file Dsolve.cpp.

References numVoxels_.

Referenced by initCinfo().

971 {
972  return numVoxels_;
973 }
unsigned int numVoxels_
Definition: Dsolve.h:204

+ Here is the caller graph for this function:

vector< double > Dsolve::getNvec ( unsigned int  pool) const

Definition at line 215 of file Dsolve.cpp.

References pools_.

Referenced by initCinfo().

216 {
217  static vector< double > ret;
218  if ( pool < pools_.size() )
219  return pools_[pool].getNvec();
220 
221  cout << "Warning: Dsolve::setNvec: pool index out of range\n";
222  return ret;
223 }
vector< double > getNvec(unsigned int pool) const
Definition: Dsolve.cpp:215
vector< DiffPoolVec > pools_
Internal vector, one for each pool species managed by Dsolve.
Definition: Dsolve.h:207

+ Here is the caller graph for this function:

string Dsolve::getPath ( const Eref e) const

Definition at line 697 of file Dsolve.cpp.

References path_.

Referenced by initCinfo().

698 {
699  return path_;
700 }
string path_
Path of pools managed by Dsolve, may include other classes too.
Definition: Dsolve.h:196

+ Here is the caller graph for this function:

unsigned int Dsolve::getPoolIndex ( const Eref er) const
virtual

Return pool index, using Stoich ptr to do lookup.

Implements ZombiePoolInterface.

Definition at line 1162 of file Dsolve.cpp.

References convertIdToPoolIndex().

1163 {
1164  return convertIdToPoolIndex( e );
1165 }
unsigned int convertIdToPoolIndex(Id id) const
Definition: Dsolve.cpp:982

+ Here is the call graph for this function:

Id Dsolve::getStoich ( ) const

Definition at line 595 of file Dsolve.cpp.

References ZombiePoolInterface::stoich_.

Referenced by initCinfo().

596 {
597  return stoich_;
598 }

+ Here is the caller graph for this function:

const Cinfo * Dsolve::initCinfo ( )
static

Definition at line 36 of file Dsolve.cpp.

References buildMeshJunctions(), buildNeuroMeshJunctions(), Dsolve(), dsolveCinfo, ZombiePoolInterface::getCompartment(), getDiffScale(), getDiffVol1(), getDiffVol2(), getNumPools(), getNumVoxels(), getNvec(), getPath(), getStoich(), Neutral::initCinfo(), path, process(), reinit(), setCompartment(), setDiffScale(), setDiffVol1(), setDiffVol2(), setNumPools(), setNvec(), setPath(), and setStoich().

37 {
39  // Field definitions
41 
42  static ValueFinfo< Dsolve, Id > stoich (
43  "stoich",
44  "Stoichiometry object for handling this reaction system.",
47  );
48 
50  "path",
51  "Path of reaction system. Must include all the pools that "
52  "are to be handled by the Dsolve, can also include other "
53  "random objects, which will be ignored.",
56  );
57 
59  "numVoxels",
60  "Number of voxels in the core reac-diff system, on the "
61  "current diffusion solver. ",
63  );
65  "numAllVoxels",
66  "Number of voxels in the core reac-diff system, on the "
67  "current diffusion solver. ",
69  );
70  static LookupValueFinfo<
71  Dsolve, unsigned int, vector< double > > nVec(
72  "nVec",
73  "vector of # of molecules along diffusion length, "
74  "looked up by pool index",
77  );
78 
79  static ValueFinfo< Dsolve, unsigned int > numPools(
80  "numPools",
81  "Number of molecular pools in the entire reac-diff system, "
82  "including variable, function and buffered.",
85  );
86 
87  static ValueFinfo< Dsolve, Id > compartment (
88  "compartment",
89  "Reac-diff compartment in which this diffusion system is "
90  "embedded.",
93  );
94 
96  "diffVol1",
97  "Volume used to set diffusion scaling: firstVol[ voxel# ] "
98  "Particularly relevant for diffusion between PSD and head.",
101  );
102 
104  "diffVol2",
105  "Volume used to set diffusion scaling: secondVol[ voxel# ] "
106  "Particularly relevant for diffusion between spine and dend.",
109  );
110 
112  "diffScale",
113  "Geometry term to set diffusion scaling: diffScale[ voxel# ] "
114  "Here the scaling term is given by cross-section area/length "
115  "Relevant for diffusion between spine head and dend, or PSD.",
118  );
119 
120 
122  // DestFinfo definitions
124 
125  static DestFinfo process( "process",
126  "Handles process call",
128  static DestFinfo reinit( "reinit",
129  "Handles reinit call",
131 
132  static DestFinfo buildMeshJunctions( "buildMeshJunctions",
133  "Builds junctions between mesh on current Dsolve, and another"
134  " Dsolve. The meshes have to be compatible. ",
137 
138  static DestFinfo buildNeuroMeshJunctions( "buildNeuroMeshJunctions",
139  "Builds junctions between NeuroMesh, SpineMesh and PsdMesh",
142 
144  // Shared definitions
146  static Finfo* procShared[] = {
147  &process, &reinit
148  };
149  static SharedFinfo proc( "proc",
150  "Shared message for process and reinit",
151  procShared, sizeof( procShared ) / sizeof( const Finfo* )
152  );
153 
154  static Finfo* dsolveFinfos[] =
155  {
156  &stoich, // ElementValue
157  &path, // ElementValue
158  &compartment, // Value
159  &numVoxels, // ReadOnlyValue
160  &numAllVoxels, // ReadOnlyValue
161  &nVec, // LookupValue
162  &numPools, // Value
163  &diffVol1, // LookupValue
164  &diffVol2, // LookupValue
165  &diffScale, // LookupValue
166  &buildMeshJunctions, // DestFinfo
167  &buildNeuroMeshJunctions, // DestFinfo
168  &proc, // SharedFinfo
169  };
170 
171  static Dinfo< Dsolve > dinfo;
172  static Cinfo dsolveCinfo(
173  "Dsolve",
175  dsolveFinfos,
176  sizeof(dsolveFinfos)/sizeof(Finfo *),
177  &dinfo
178  );
179 
180  return &dsolveCinfo;
181 }
string getPath(const Eref &e) const
Definition: Dsolve.cpp:697
double getDiffScale(unsigned int voxel) const
Definition: Dsolve.cpp:282
void setDiffScale(unsigned int voxel, double scale)
Definition: Dsolve.cpp:274
unsigned int getNumVoxels() const
Definition: Dsolve.cpp:970
void setPath(const Eref &e, string path)
Dummy, inherited but not used.
Definition: Dsolve.cpp:660
void setNumPools(unsigned int num)
Specifies number of pools (species) handled by system.
Definition: Dsolve.cpp:1078
Definition: Dinfo.h:60
Definition: EpFunc.h:64
double getDiffVol2(unsigned int voxel) const
Definition: Dsolve.cpp:265
Id getStoich() const
Definition: Dsolve.cpp:595
void setStoich(Id id)
Definition: Dsolve.cpp:506
vector< double > getNvec(unsigned int pool) const
Definition: Dsolve.cpp:215
void setNvec(unsigned int pool, vector< double > vec)
Definition: Dsolve.cpp:204
static const Cinfo * dsolveCinfo
Definition: Dsolve.cpp:183
void buildMeshJunctions(const Eref &e, Id other)
Definition: Dsolve.cpp:792
void setDiffVol2(unsigned int voxel, double vol)
Definition: Dsolve.cpp:257
double getDiffVol1(unsigned int voxel) const
LookupFied for examining cross-solver diffusion terms.
Definition: Dsolve.cpp:248
void setCompartment(Id id)
Assigns compartment.
Definition: Dsolve.cpp:604
Dsolve()
Definition: Dsolve.cpp:188
unsigned int getNumPools() const
gets number of pools (species) handled by system.
Definition: Dsolve.cpp:1093
void reinit(const Eref &e, ProcPtr p)
Definition: Dsolve.cpp:486
static const Cinfo * initCinfo()
Definition: Neutral.cpp:16
void setDiffVol1(unsigned int voxel, double vol)
Definition: Dsolve.cpp:240
void process(const Eref &e, ProcPtr p)
Definition: Dsolve.cpp:478
void buildNeuroMeshJunctions(const Eref &e, Id spineD, Id psdD)
Definition: Dsolve.cpp:768
Definition: Cinfo.h:18
static char path[]
Definition: mfield.cpp:403
Definition: EpFunc.h:79
Definition: Finfo.h:12

+ Here is the call graph for this function:

void Dsolve::innerBuildMeshJunctions ( Id  self,
Id  other,
bool  isMembraneBound 
)
static

buildMeshJunctions is the inner utility function for building the junction between any specified pair of Dsolves. Note that it builds the junction on the 'self' Dsolve.

Definition at line 941 of file Dsolve.cpp.

References junctions_, mapChansBetweenDsolves(), mapDiffPoolsBetweenDsolves(), mapVoxelsBetweenMeshes(), mapXfersBetweenDsolves(), DiffJunction::myXferDest, DiffJunction::myXferSrc, DiffJunction::otherDsolve, DiffJunction::otherXferDest, DiffJunction::otherXferSrc, and Id::value().

Referenced by buildMeshJunctions(), and buildNeuroMeshJunctions().

942 {
943  DiffJunction jn; // This is based on the Spine Dsolver.
944  jn.otherDsolve = other.value();
945  Dsolve* dself = reinterpret_cast< Dsolve* >( self.eref().data() );
946  if ( selfIsMembraneBound ) {
947  mapChansBetweenDsolves( jn, self, other );
948  } else {
949  mapDiffPoolsBetweenDsolves( jn, self, other );
950  }
951  mapXfersBetweenDsolves( jn.myXferSrc, jn.otherXferDest, self, other );
952  mapXfersBetweenDsolves( jn.otherXferSrc, jn.myXferDest, other, self );
953 
954  mapVoxelsBetweenMeshes( jn, self, other );
955 
956 
957  // printJunction( self, other, jn );
958  dself->junctions_.push_back( jn );
959 }
unsigned int value() const
Definition: Id.cpp:197
Definition: Dsolve.h:29
vector< DiffJunction > junctions_
Definition: Dsolve.h:222
static void mapChansBetweenDsolves(DiffJunction &jn, Id self, Id other)
Definition: Dsolve.cpp:892
vector< unsigned int > otherXferSrc
Definition: DiffJunction.h:44
unsigned int otherDsolve
Definition: DiffJunction.h:36
static void mapVoxelsBetweenMeshes(DiffJunction &jn, Id self, Id other)
Definition: Dsolve.cpp:921
vector< unsigned int > myXferSrc
Definition: DiffJunction.h:40
vector< unsigned int > otherXferDest
Definition: DiffJunction.h:41
static void mapXfersBetweenDsolves(vector< unsigned int > &srcPools, vector< unsigned int > &destPools, Id src, Id dest)
Definition: Dsolve.cpp:858
vector< unsigned int > myXferDest
Definition: DiffJunction.h:43
static void mapDiffPoolsBetweenDsolves(DiffJunction &jn, Id self, Id other)
Sets up map of matching pools for diffusion.
Definition: Dsolve.cpp:824

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Dsolve::makePoolMapFromElist ( const vector< ObjId > &  elist,
vector< Id > &  temp 
)

Fills in poolMap_ using elist of objects found when the 'setPath' function is executed. temp is returned with the list of PoolBase objects that exist on the path.

Definition at line 622 of file Dsolve.cpp.

References path_, poolMap_, poolMapStart_, and ZombiePoolInterface::stoich_.

Referenced by setPath().

624 {
625  unsigned int minId = 0;
626  unsigned int maxId = 0;
627  temp.resize( 0 );
628  for ( vector< ObjId >::const_iterator
629  i = elist.begin(); i != elist.end(); ++i ) {
630  if ( i->element()->cinfo()->isA( "PoolBase" ) ) {
631  temp.push_back( i->id );
632  if ( minId == 0 )
633  maxId = minId = i->id.value();
634  else if ( i->id.value() < minId )
635  minId = i->id.value();
636  else if ( i->id.value() > maxId )
637  maxId = i->id.value();
638  }
639  }
640 
641  if ( temp.size() == 0 ) {
642  cout << "Dsolve::makePoolMapFromElist::( " << path_ <<
643  " ): Error: path is has no pools\n";
644  return;
645  }
646 
647  stoich_ = Id();
648  poolMapStart_ = minId;
649  poolMap_.resize( 1 + maxId - minId );
650  for ( auto i = poolMap_.begin(); i != poolMap_.end(); ++i )
651  *i = ~0U;
652  for ( unsigned int i = 0; i < temp.size(); ++i ) {
653  unsigned int idValue = temp[i].value();
654  assert( idValue >= minId );
655  assert( idValue - minId < poolMap_.size() );
656  poolMap_[ idValue - minId ] = i;
657  }
658 }
string path_
Path of pools managed by Dsolve, may include other classes too.
Definition: Dsolve.h:196
unsigned int poolMapStart_
smallest Id value for poolMap_
Definition: Dsolve.h:212
Definition: Id.h:17
vector< unsigned int > poolMap_
Looks up pool# from pool Id, using poolMapStart_ as offset.
Definition: Dsolve.h:215

+ Here is the caller graph for this function:

void Dsolve::mapChansBetweenDsolves ( DiffJunction jn,
Id  self,
Id  other 
)
static

Definition at line 892 of file Dsolve.cpp.

References channels_, convertIdToPoolIndex(), Eref::data(), Id::eref(), DiffJunction::myChannels, and DiffJunction::otherChannels.

Referenced by innerBuildMeshJunctions().

893 {
894  Dsolve* otherSolve = reinterpret_cast< Dsolve* >(
895  other.eref().data() );
896  Dsolve* selfSolve = reinterpret_cast< Dsolve* >( self.eref().data() );
897  vector< ConcChanInfo >& ch = selfSolve->channels_;
898  unsigned int outIndex;
899  for ( unsigned int i = 0; i < ch.size(); ++i ) {
900  unsigned int chanIndex = ch[i].chanPool;
901  outIndex = otherSolve->convertIdToPoolIndex( ch[i].otherPool );
902  if ( (outIndex != ~0U) && (chanIndex != ~0U ) ) {
903  jn.myChannels.push_back(i);
904  ch[i].otherPool = outIndex; // replace the Id with the index.
905  ch[i].chanPool = chanIndex; //chanIndex may be on either Dsolve
906  }
907  }
908  // Now set up the other Dsolve.
909  vector< ConcChanInfo >& ch2 = otherSolve->channels_;
910  for ( unsigned int i = 0; i < ch2.size(); ++i ) {
911  unsigned int chanIndex = ch2[i].chanPool;
912  outIndex = selfSolve->convertIdToPoolIndex( ch2[i].otherPool );
913  if ( (outIndex != ~0U) && (chanIndex != ~0U) ) {
914  jn.otherChannels.push_back(i);
915  ch2[i].otherPool = outIndex; // replace the Id with the index
916  ch2[i].chanPool = chanIndex; //chanIndex may be on either Dsolve
917  }
918  }
919 }
char * data() const
Definition: Eref.cpp:41
Definition: Dsolve.h:29
Eref eref() const
Definition: Id.cpp:125
vector< ConcChanInfo > channels_
Internal vector, one for each ConcChan managed by Dsolve.
Definition: Dsolve.h:209
vector< unsigned int > myChannels
Definition: DiffJunction.h:46
unsigned int convertIdToPoolIndex(Id id) const
Definition: Dsolve.cpp:982
vector< unsigned int > otherChannels
Definition: DiffJunction.h:47

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Dsolve::mapDiffPoolsBetweenDsolves ( DiffJunction jn,
Id  self,
Id  other 
)
static

Sets up map of matching pools for diffusion.

Definition at line 824 of file Dsolve.cpp.

References Eref::data(), Id::eref(), DiffJunction::myPools, DiffJunction::otherPools, and pools_.

Referenced by innerBuildMeshJunctions().

826 {
827  Dsolve* mySolve = reinterpret_cast< Dsolve* >( self.eref().data() );
828  unordered_map< string, unsigned int > myPools;
829  for ( unsigned int i = 0; i < mySolve->pools_.size(); ++i ) {
830  Id pool( mySolve->pools_[i].getId() );
831  assert( pool != Id() );
832  myPools[ pool.element()->getName() ] = i;
833  }
834 
835  const Dsolve* otherSolve = reinterpret_cast< const Dsolve* >(
836  other.eref().data() );
837  for ( unsigned int i = 0; i < otherSolve->pools_.size(); ++i ) {
838  Id otherPool( otherSolve->pools_[i].getId() );
839  unordered_map< string, unsigned int >::iterator p =
840  myPools.find( otherPool.element()->getName() );
841  if ( p != myPools.end() ) {
842  jn.otherPools.push_back( i );
843  jn.myPools.push_back( p->second );
844  }
845  }
846 }
char * data() const
Definition: Eref.cpp:41
vector< unsigned int > otherPools
Definition: DiffJunction.h:38
Definition: Dsolve.h:29
Eref eref() const
Definition: Id.cpp:125
vector< unsigned int > myPools
Definition: DiffJunction.h:37
vector< DiffPoolVec > pools_
Internal vector, one for each pool species managed by Dsolve.
Definition: Dsolve.h:207
Definition: Id.h:17

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Dsolve::mapXfersBetweenDsolves ( vector< unsigned int > &  srcPools,
vector< unsigned int > &  destPools,
Id  src,
Id  dest 
)
static

static void mapXfersBetweenDsolves(...) Build a list of all the molecules that should transfer instantaneously to another compartment, for cross-compartment reactions. Here we look for src names of the form <name>_xfer_<destComptName> For example, if we had an enzyme in compartment 'src', whose product should go to pool 'bar' in compartment 'dest', the name of the enzyme product in compartment src would be bar_xfer_dest

Definition at line 858 of file Dsolve.cpp.

References Eref::data(), Id::element(), Id::eref(), Field< A >::get(), Element::getName(), and pools_.

Referenced by innerBuildMeshJunctions().

861 {
862  Id destMesh = Field< Id >::get( dest, "compartment" );
863  string xferPost( string( "_xfer_" ) + destMesh.element()->getName() );
864  size_t xlen = xferPost.length();
865 
866  Dsolve* srcSolve = reinterpret_cast< Dsolve* >( src.eref().data() );
867  unordered_map< string, unsigned int > srcMap;
868  for ( unsigned int i = 0; i < srcSolve->pools_.size(); ++i ) {
869  Id pool( srcSolve->pools_[i].getId() );
870  assert( pool != Id() );
871  string poolName = pool.element()->getName();
872  if ( poolName.length() > xlen ) {
873  size_t prefixLen = poolName.length() - xlen;
874  if ( poolName.rfind( xferPost ) == prefixLen )
875  srcMap[ poolName.substr( 0, prefixLen) ] = i;
876  }
877  }
878 
879  const Dsolve* destSolve = reinterpret_cast< const Dsolve* >(
880  dest.eref().data() );
881  for ( unsigned int i = 0; i < destSolve->pools_.size(); ++i ) {
882  Id destPool( destSolve->pools_[i].getId() );
883  unordered_map< string, unsigned int >::iterator p =
884  srcMap.find( destPool.element()->getName() );
885  if ( p != srcMap.end() ) {
886  destPools.push_back( i );
887  srcPools.push_back( p->second );
888  }
889  }
890 }
char * data() const
Definition: Eref.cpp:41
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
Definition: Dsolve.h:29
Eref eref() const
Definition: Id.cpp:125
vector< DiffPoolVec > pools_
Internal vector, one for each pool species managed by Dsolve.
Definition: Dsolve.h:207
Definition: Id.h:17
static A get(const ObjId &dest, const string &field)
Definition: SetGet.h:284
const string & getName() const
Definition: Element.cpp:56

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VoxelPoolsBase * Dsolve::pools ( unsigned int  i)
virtual

Return a pointer to the specified VoxelPool.

Implements ZombiePoolInterface.

Definition at line 1172 of file Dsolve.cpp.

1173 {
1174  return 0;
1175 }
void Dsolve::print ( ) const

Utility func for debugging: Prints N_ matrix

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

Definition at line 478 of file Dsolve.cpp.

References ProcInfo::dt, and pools_.

Referenced by initCinfo().

479 {
480  for ( vector< DiffPoolVec >::iterator
481  i = pools_.begin(); i != pools_.end(); ++i ) {
482  i->advance( p->dt );
483  }
484 }
double dt
Definition: ProcInfo.h:18
vector< DiffPoolVec > pools_
Internal vector, one for each pool species managed by Dsolve.
Definition: Dsolve.h:207

+ Here is the caller graph for this function:

void Dsolve::rebuildPools ( )
void Dsolve::reinit ( const Eref e,
ProcPtr  p 
)

Definition at line 486 of file Dsolve.cpp.

References build(), ProcInfo::dt, and pools_.

Referenced by initCinfo().

487 {
488  build( p->dt );
489  for ( vector< DiffPoolVec >::iterator
490  i = pools_.begin(); i != pools_.end(); ++i ) {
491  i->reinit();
492  }
493 }
double dt
Definition: ProcInfo.h:18
vector< DiffPoolVec > pools_
Internal vector, one for each pool species managed by Dsolve.
Definition: Dsolve.h:207
void build(double dt)
Definition: Dsolve.cpp:723

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Dsolve::setBlock ( const vector< double > &  values)
virtual

Sets block of data. The first 4 entries on the 'values' vector are the start voxel, numVoxels, start pool#, numPools. These are followed by numVoxels * numPools of data values.

Implements ZombiePoolInterface.

Definition at line 1132 of file Dsolve.cpp.

References numLocalPools_, numVoxels_, pools_, and poolStartIndex_.

1133 {
1134  unsigned int startVoxel = values[0];
1135  unsigned int numVoxels = values[1];
1136  unsigned int startPool = values[2];
1137  unsigned int numPools = values[3];
1138 
1139  assert( startVoxel + numVoxels <= numVoxels_ );
1140  assert( startPool >= poolStartIndex_ );
1141  assert( numPools + startPool <= numLocalPools_ );
1142  assert( values.size() == 4 + numVoxels * numPools );
1143 
1144  for ( unsigned int i = 0; i < numPools; ++i ) {
1145  unsigned int j = i + startPool;
1146  if ( j >= poolStartIndex_ && j < poolStartIndex_ + numLocalPools_ ){
1147  vector< double >::const_iterator
1148  q = values.begin() + 4 + i * numVoxels;
1149  pools_[ j - poolStartIndex_ ].setNvec( startVoxel, numVoxels, q );
1150  }
1151  }
1152 }
unsigned int numVoxels_
Definition: Dsolve.h:204
unsigned int numLocalPools_
Definition: Dsolve.h:202
vector< DiffPoolVec > pools_
Internal vector, one for each pool species managed by Dsolve.
Definition: Dsolve.h:207
unsigned int poolStartIndex_
Definition: Dsolve.h:203
void Dsolve::setCompartment ( Id  compartment)
virtual

Assigns compartment.

Reimplemented from ZombiePoolInterface.

Definition at line 604 of file Dsolve.cpp.

References ZombiePoolInterface::compartment_, Field< A >::get(), id, Cinfo::isA(), Cinfo::name(), and numVoxels_.

Referenced by initCinfo().

605 {
606  const Cinfo* c = id.element()->cinfo();
607  compartment_ = id;
608  numVoxels_ = Field< unsigned int >::get( id, "numMesh" );
609  if ( c->isA( "CubeMesh" ) ) { // we do only linear diffusion for now
610  unsigned int nx = Field< unsigned int >::get( id, "nx" );
611  unsigned int ny = Field< unsigned int >::get( id, "nx" );
612  unsigned int nz = Field< unsigned int >::get( id, "nx" );
613  if ( !( nx*ny == 1 || nx*nz == 1 || ny*nz == 1 ) ) {
614  cout << "Warning: Dsolve::setCompartment:: Cube mesh: " <<
615  c->name() << " found with >1 dimension of voxels. " <<
616  "Only 1-D diffusion supported for now.\n";
617  return;
618  }
619  }
620 }
unsigned int numVoxels_
Definition: Dsolve.h:204
const std::string & name() const
Definition: Cinfo.cpp:260
bool isA(const string &ancestor) const
Definition: Cinfo.cpp:280
Id compartment_
Id of Chem compartment used to figure out volumes of voxels.
static A get(const ObjId &dest, const string &field)
Definition: SetGet.h:284
static char id[]
Definition: mfield.cpp:404
Definition: Cinfo.h:18

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Dsolve::setDiffConst ( const Eref e,
double  val 
)
virtual

Diffusion constant: Only one per pool, voxel number is ignored.

Implements ZombiePoolInterface.

Definition at line 1054 of file Dsolve.cpp.

References convertIdToPoolIndex(), and pools_.

1055 {
1056  unsigned int pid = convertIdToPoolIndex( e );
1057  if ( pid >= pools_.size() ) // Ignore silently, out of range.
1058  return;
1059  pools_[ convertIdToPoolIndex( e ) ].setDiffConst( v );
1060 }
vector< DiffPoolVec > pools_
Internal vector, one for each pool species managed by Dsolve.
Definition: Dsolve.h:207
unsigned int convertIdToPoolIndex(Id id) const
Definition: Dsolve.cpp:982

+ Here is the call graph for this function:

void Dsolve::setDiffScale ( unsigned int  voxel,
double  scale 
)

Definition at line 274 of file Dsolve.cpp.

References checkJn(), VoxelJunction::diffScale, and junctions_.

Referenced by initCinfo().

275 {
276  if ( checkJn( junctions_, voxel, "setDiffScale" ) ) {
277  VoxelJunction& vj = junctions_[0].vj[ voxel ];
278  vj.diffScale = adx;
279  }
280 }
double diffScale
Definition: VoxelJunction.h:44
vector< DiffJunction > junctions_
Definition: Dsolve.h:222
static bool checkJn(const vector< DiffJunction > &jn, unsigned int voxel, const string &info)
Definition: Dsolve.cpp:225

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Dsolve::setDiffVol1 ( unsigned int  voxel,
double  vol 
)

Definition at line 240 of file Dsolve.cpp.

References checkJn(), VoxelJunction::firstVol, and junctions_.

Referenced by initCinfo().

241 {
242  if ( checkJn( junctions_, voxel, "setDiffVol1" ) ) {
243  VoxelJunction& vj = junctions_[0].vj[ voxel ];
244  vj.firstVol = vol;
245  }
246 }
vector< DiffJunction > junctions_
Definition: Dsolve.h:222
double firstVol
MeshIndex for second compartment.
Definition: VoxelJunction.h:42
static bool checkJn(const vector< DiffJunction > &jn, unsigned int voxel, const string &info)
Definition: Dsolve.cpp:225

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Dsolve::setDiffVol2 ( unsigned int  voxel,
double  vol 
)

Definition at line 257 of file Dsolve.cpp.

References checkJn(), junctions_, and VoxelJunction::secondVol.

Referenced by initCinfo().

258 {
259  if ( checkJn( junctions_, voxel, "setDiffVol2" ) ) {
260  VoxelJunction& vj = junctions_[0].vj[ voxel ];
261  vj.secondVol = vol;
262  }
263 }
vector< DiffJunction > junctions_
Definition: Dsolve.h:222
double secondVol
Definition: VoxelJunction.h:43
static bool checkJn(const vector< DiffJunction > &jn, unsigned int voxel, const string &info)
Definition: Dsolve.cpp:225

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Dsolve::setDsolve ( Id  id)
virtual

Inherited, defining dummy function here.

Implements ZombiePoolInterface.

Definition at line 601 of file Dsolve.cpp.

602 {;}
void Dsolve::setMotorConst ( const Eref e,
double  val 
)
virtual

Motor constant: Only one per pool, voxel number is ignored. Used only in Dsolves, so here I put in a dummy.

Reimplemented from ZombiePoolInterface.

Definition at line 1070 of file Dsolve.cpp.

References convertIdToPoolIndex(), and pools_.

1071 {
1072  unsigned int pid = convertIdToPoolIndex( e );
1073  if ( pid >= pools_.size() ) // Ignore silently, out of range.
1074  return;
1075  pools_[ convertIdToPoolIndex( e ) ].setMotorConst( v );
1076 }
vector< DiffPoolVec > pools_
Internal vector, one for each pool species managed by Dsolve.
Definition: Dsolve.h:207
unsigned int convertIdToPoolIndex(Id id) const
Definition: Dsolve.cpp:982

+ Here is the call graph for this function:

void Dsolve::setN ( const Eref e,
double  val 
)
virtual

Set # of molecules in given pool and voxel. Varies with time.

Implements ZombiePoolInterface.

Definition at line 999 of file Dsolve.cpp.

References convertIdToPoolIndex(), Eref::dataIndex(), numVoxels_, and pools_.

1000 {
1001  unsigned int pid = convertIdToPoolIndex( e );
1002  // Ignore silently, as this may be a valid pid for the ksolve to use.
1003  if ( pid >= pools_.size() )
1004  return;
1005  unsigned int vox = e.dataIndex();
1006  if ( vox < numVoxels_ ) {
1007  pools_[ pid ].setN( vox, v );
1008  return;
1009  }
1010  cout << "Warning: Dsolve::setN: Eref " << e << " out of range " <<
1011  pools_.size() << ", " << numVoxels_ << "\n";
1012 }
unsigned int numVoxels_
Definition: Dsolve.h:204
unsigned int dataIndex() const
Definition: Eref.h:50
vector< DiffPoolVec > pools_
Internal vector, one for each pool species managed by Dsolve.
Definition: Dsolve.h:207
unsigned int convertIdToPoolIndex(Id id) const
Definition: Dsolve.cpp:982

+ Here is the call graph for this function:

void Dsolve::setNinit ( const Eref e,
double  val 
)
virtual

Set initial # of molecules in given pool and voxel. Bdry cond.

Implements ZombiePoolInterface.

Definition at line 1027 of file Dsolve.cpp.

References convertIdToPoolIndex(), Eref::dataIndex(), numVoxels_, and pools_.

1028 {
1029  unsigned int pid = convertIdToPoolIndex( e );
1030  if ( pid >= pools_.size() ) // Ignore silently
1031  return;
1032  unsigned int vox = e.dataIndex();
1033  if ( vox < numVoxels_ ) {
1034  pools_[ pid ].setNinit( vox, v );
1035  return;
1036  }
1037  cout << "Warning: Dsolve::setNinit: Eref " << e << " out of range " <<
1038  pools_.size() << ", " << numVoxels_ << "\n";
1039 }
unsigned int numVoxels_
Definition: Dsolve.h:204
unsigned int dataIndex() const
Definition: Eref.h:50
vector< DiffPoolVec > pools_
Internal vector, one for each pool species managed by Dsolve.
Definition: Dsolve.h:207
unsigned int convertIdToPoolIndex(Id id) const
Definition: Dsolve.cpp:982

+ Here is the call graph for this function:

void Dsolve::setNumAllVoxels ( unsigned int  numVoxels)
virtual

Inherited virtual.

Implements ZombiePoolInterface.

Definition at line 975 of file Dsolve.cpp.

References numLocalPools_, numVoxels_, and pools_.

976 {
977  numVoxels_ = num;
978  for ( unsigned int i = 0 ; i < numLocalPools_; ++i )
979  pools_[i].setNumVoxels( numVoxels_ );
980 }
unsigned int numVoxels_
Definition: Dsolve.h:204
unsigned int numLocalPools_
Definition: Dsolve.h:202
vector< DiffPoolVec > pools_
Internal vector, one for each pool species managed by Dsolve.
Definition: Dsolve.h:207
void Dsolve::setNumPools ( unsigned int  num)
virtual

Specifies number of pools (species) handled by system.

Implements ZombiePoolInterface.

Definition at line 1078 of file Dsolve.cpp.

References numLocalPools_, numTotPools_, numVoxels_, pools_, and poolStartIndex_.

Referenced by initCinfo(), and setPath().

1079 {
1080  // Decompose numPoolSpecies here, assigning some to each node.
1081  numTotPools_ = numPoolSpecies;
1082  numLocalPools_ = numPoolSpecies;
1083  poolStartIndex_ = 0;
1084 
1085  pools_.resize( numLocalPools_ );
1086  for ( unsigned int i = 0 ; i < numLocalPools_; ++i ) {
1087  pools_[i].setNumVoxels( numVoxels_ );
1088  // pools_[i].setId( reversePoolMap_[i] );
1089  // pools_[i].setParent( me );
1090  }
1091 }
unsigned int numVoxels_
Definition: Dsolve.h:204
unsigned int numTotPools_
Definition: Dsolve.h:201
unsigned int numLocalPools_
Definition: Dsolve.h:202
vector< DiffPoolVec > pools_
Internal vector, one for each pool species managed by Dsolve.
Definition: Dsolve.h:207
unsigned int poolStartIndex_
Definition: Dsolve.h:203

+ Here is the caller graph for this function:

void Dsolve::setNvec ( unsigned int  pool,
vector< double >  vec 
)

Definition at line 204 of file Dsolve.cpp.

References pools_.

Referenced by initCinfo().

205 {
206  if ( pool < pools_.size() ) {
207  if ( vec.size() != pools_[pool].getNumVoxels() ) {
208  cout << "Warning: Dsolve::setNvec: pool index out of range\n";
209  } else {
210  pools_[ pool ].setNvec( vec );
211  }
212  }
213 }
vector< DiffPoolVec > pools_
Internal vector, one for each pool species managed by Dsolve.
Definition: Dsolve.h:207

+ Here is the caller graph for this function:

void Dsolve::setPath ( const Eref e,
string  path 
)

Dummy, inherited but not used.

Definition at line 660 of file Dsolve.cpp.

References Field< A >::get(), Eref::id(), ZombieBufPool::initCinfo(), BufPool::initCinfo(), ZombiePool::initCinfo(), Pool::initCinfo(), makePoolMapFromElist(), Cinfo::name(), numVoxels_, poolMap_, poolMapStart_, pools_, setNumPools(), simpleWildcardFind(), value, and PoolBase::zombify().

Referenced by initCinfo().

661 {
662  vector< ObjId > elist;
663  simpleWildcardFind( path, elist );
664  if ( elist.size() == 0 ) {
665  cout << "Dsolve::setPath::( " << path << " ): Error: path is empty\n";
666  return;
667  }
668  vector< Id > temp;
669  makePoolMapFromElist( elist, temp );
670 
671  setNumPools( temp.size() );
672  for ( unsigned int i = 0; i < temp.size(); ++i ) {
673  Id id = temp[i];
674  double diffConst = Field< double >::get( id, "diffConst" );
675  double motorConst = Field< double >::get( id, "motorConst" );
676  const Cinfo* c = id.element()->cinfo();
677  if ( c == Pool::initCinfo() ) {
678  PoolBase::zombify( id.element(), ZombiePool::initCinfo(), Id(), e.id() );
679  } else if ( c == BufPool::initCinfo() ) {
680  PoolBase::zombify( id.element(), ZombieBufPool::initCinfo(), Id(), e.id() );
681  // Any Functions will have to continue to manage the BufPools.
682  // This needs them to be replicated, and for their messages
683  // to be copied over. Not really set up here.
684  } else {
685  cout << "Error: Dsolve::setPath( " << path << " ): unknown pool class:" << c->name() << endl;
686  }
687  id.element()->resize( numVoxels_ );
688 
689  unsigned int j = temp[i].value() - poolMapStart_;
690  assert( j < poolMap_.size() );
691  pools_[ poolMap_[i] ].setId( id.value() );
692  pools_[ poolMap_[j] ].setDiffConst( diffConst );
693  pools_[ poolMap_[j] ].setMotorConst( motorConst );
694  }
695 }
Id id() const
Definition: Eref.cpp:62
uint32_t value
Definition: moosemodule.h:42
unsigned int poolMapStart_
smallest Id value for poolMap_
Definition: Dsolve.h:212
unsigned int numVoxels_
Definition: Dsolve.h:204
static const Cinfo * initCinfo()
Definition: ZombiePool.cpp:21
void setNumPools(unsigned int num)
Specifies number of pools (species) handled by system.
Definition: Dsolve.cpp:1078
int simpleWildcardFind(const string &path, vector< ObjId > &ret)
Definition: Wildcard.cpp:137
static void zombify(Element *original, const Cinfo *zClass, Id ksolve, Id dsolve)
Definition: PoolBase.cpp:430
const std::string & name() const
Definition: Cinfo.cpp:260
static const Cinfo * initCinfo()
static const Cinfo * initCinfo()
Definition: BufPool.cpp:18
static const Cinfo * initCinfo()
Definition: Pool.cpp:18
void makePoolMapFromElist(const vector< ObjId > &elist, vector< Id > &temp)
Definition: Dsolve.cpp:622
vector< DiffPoolVec > pools_
Internal vector, one for each pool species managed by Dsolve.
Definition: Dsolve.h:207
Definition: Id.h:17
static A get(const ObjId &dest, const string &field)
Definition: SetGet.h:284
Definition: Cinfo.h:18
static char path[]
Definition: mfield.cpp:403
vector< unsigned int > poolMap_
Looks up pool# from pool Id, using poolMapStart_ as offset.
Definition: Dsolve.h:215

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Dsolve::setPrev ( )
virtual

Used to tell Dsolver to assign 'prev' values.

Reimplemented from ZombiePoolInterface.

Definition at line 1124 of file Dsolve.cpp.

References pools_.

1125 {
1126  for ( auto i = pools_.begin(); i != pools_.end(); ++i ) {
1127  // if (i->getDiffConst() > 0.0 )
1128  i->setPrevVec();
1129  }
1130 }
vector< DiffPoolVec > pools_
Internal vector, one for each pool species managed by Dsolve.
Definition: Dsolve.h:207
void Dsolve::setStoich ( Id  stoich)
virtual

Informs the ZPI about the stoich, used during subsequent computations. Called to wrap up the model building. The Stoich does this call after it has set up its own path.

Implements ZombiePoolInterface.

Definition at line 506 of file Dsolve.cpp.

References Element::cinfo(), Eref::data(), Id::element(), Id::eref(), fillConcChans(), Field< A >::get(), PoolBase::getDiffConst(), id, Cinfo::isA(), path_, poolMap_, poolMapStart_, pools_, ZombiePoolInterface::stoich_, Id::value(), and wildcardFind().

Referenced by initCinfo().

507 {
508  if ( !id.element()->cinfo()->isA( "Stoich" ) ) {
509  cout << "Dsolve::setStoich::( " << id << " ): Error: provided Id is not a Stoich\n";
510  return;
511  }
512 
513  stoich_ = id;
514  poolMap_ = Field< vector< unsigned int > >::get( stoich_, "poolIdMap" );
515  poolMapStart_ = poolMap_.back();
516  poolMap_.pop_back();
517 
518  path_ = Field< string >::get( stoich_, "path" );
519  // cout << "Pool Info for stoich " << id.path() << endl;
520 
521  for ( unsigned int i = 0; i < poolMap_.size(); ++i ) {
522  unsigned int poolIndex = poolMap_[i];
523  if ( poolIndex != ~0U && poolIndex < pools_.size() ) {
524  // assert( poolIndex < pools_.size() );
525  Id pid( i + poolMapStart_ );
526  assert( pid.element()->cinfo()->isA( "PoolBase" ) );
527  PoolBase* pb =
528  reinterpret_cast< PoolBase* >( pid.eref().data());
529  double diffConst = pb->getDiffConst( pid.eref() );
530  double motorConst = pb->getMotorConst( pid.eref() );
531  pools_[ poolIndex ].setId( pid.value() );
532  pools_[ poolIndex ].setDiffConst( diffConst );
533  pools_[ poolIndex ].setMotorConst( motorConst );
534  /*
535  cout << i << " poolIndex=" << poolIndex <<
536  ", id=" << pid.value() <<
537  ", name=" << pid.element()->getName() << endl;
538  */
539  }
540  }
541  string chanpath = path_ + "[ISA=ConcChan]";
542  vector< ObjId > chans;
543  wildcardFind( chanpath, chans );
544  fillConcChans( chans );
545 }
int wildcardFind(const string &path, vector< ObjId > &ret)
Definition: Wildcard.cpp:169
void fillConcChans(const vector< ObjId > &chans)
Definition: Dsolve.cpp:547
string path_
Path of pools managed by Dsolve, may include other classes too.
Definition: Dsolve.h:196
unsigned int poolMapStart_
smallest Id value for poolMap_
Definition: Dsolve.h:212
Definition: SetGet.h:236
vector< DiffPoolVec > pools_
Internal vector, one for each pool species managed by Dsolve.
Definition: Dsolve.h:207
Definition: Id.h:17
static A get(const ObjId &dest, const string &field)
Definition: SetGet.h:284
static char id[]
Definition: mfield.cpp:404
double getDiffConst(const Eref &e) const
Definition: PoolBase.cpp:358
vector< unsigned int > poolMap_
Looks up pool# from pool Id, using poolMapStart_ as offset.
Definition: Dsolve.h:215

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Dsolve::setupCrossSolverReacs ( const map< Id, vector< Id > > &  xr,
Id  otherStoich 
)
void Dsolve::setupCrossSolverReacVols ( const vector< vector< Id > > &  subCompts,
const vector< vector< Id > > &  prdCompts 
)
void Dsolve::updateJunctions ( double  dt)
virtual

Used for telling Dsolver to handle all ops across Junctions.

Reimplemented from ZombiePoolInterface.

Definition at line 495 of file Dsolve.cpp.

References calcJunction(), and junctions_.

496 {
497  for ( vector< DiffJunction >::const_iterator
498  i = junctions_.begin(); i != junctions_.end(); ++i ) {
499  calcJunction( *i, dt );
500  }
501 }
void calcJunction(const DiffJunction &jn, double dt)
Definition: Dsolve.cpp:457
vector< DiffJunction > junctions_
Definition: Dsolve.h:222

+ Here is the call graph for this function:

void Dsolve::updateRateTerms ( unsigned int  index)
virtual

Informs the solver that the rate terms or volumes have changed and that the parameters must be updated. The index specifies which rateTerm to change, and if it is ~0U it means update all of them.

Implements ZombiePoolInterface.

Definition at line 1157 of file Dsolve.cpp.

1158 {
1159  ;
1160 }
double Dsolve::volume ( unsigned int  i) const
virtual

Return volume of voxel i.

Implements ZombiePoolInterface.

Definition at line 1177 of file Dsolve.cpp.

1178 {
1179  return 1.0;
1180 }

Member Data Documentation

vector< ConcChanInfo > Dsolve::channels_
private

Internal vector, one for each ConcChan managed by Dsolve.

Definition at line 209 of file Dsolve.h.

Referenced by calcJnChan(), calcOtherJnChan(), fillConcChans(), and mapChansBetweenDsolves().

double Dsolve::dt_
private

Timestep used by diffusion calculations.

Definition at line 199 of file Dsolve.h.

Referenced by build().

vector< DiffJunction > Dsolve::junctions_
private

Lists all the diffusion junctions managed by this Dsolve. Each junction entry provides the info needed to do the numerical integration for flux between the Dsolves.

Definition at line 222 of file Dsolve.h.

Referenced by getDiffScale(), getDiffVol1(), getDiffVol2(), innerBuildMeshJunctions(), setDiffScale(), setDiffVol1(), setDiffVol2(), and updateJunctions().

unsigned int Dsolve::numLocalPools_
private

Definition at line 202 of file Dsolve.h.

Referenced by build(), getBlock(), setBlock(), setNumAllVoxels(), and setNumPools().

unsigned int Dsolve::numTotPools_
private

Definition at line 201 of file Dsolve.h.

Referenced by getNumPools(), and setNumPools().

unsigned int Dsolve::numVoxels_
private
string Dsolve::path_
private

Path of pools managed by Dsolve, may include other classes too.

Definition at line 196 of file Dsolve.h.

Referenced by getPath(), makePoolMapFromElist(), and setStoich().

vector< unsigned int > Dsolve::poolMap_
private

Looks up pool# from pool Id, using poolMapStart_ as offset.

Definition at line 215 of file Dsolve.h.

Referenced by convertIdToPoolIndex(), makePoolMapFromElist(), setPath(), and setStoich().

unsigned int Dsolve::poolMapStart_
private

smallest Id value for poolMap_

Definition at line 212 of file Dsolve.h.

Referenced by convertIdToPoolIndex(), makePoolMapFromElist(), setPath(), and setStoich().

unsigned int Dsolve::poolStartIndex_
private

Definition at line 203 of file Dsolve.h.

Referenced by getBlock(), setBlock(), and setNumPools().


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