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

#include <CylMesh.h>

+ Inheritance diagram for CylMesh:
+ Collaboration diagram for CylMesh:

Public Member Functions

void buildStencil ()
 
 CylMesh ()
 
double extendedMeshEntryVolume (unsigned int fid) const
 Volume of mesh Entry including abutting diff-coupled voxels. More...
 
vector< double > getCoordinates (unsigned int fid) const
 Virtual function to return coords of mesh Entry. More...
 
vector< double > getCoords (const Eref &e) const
 
double getDiffLength (const Eref &e) const
 
vector< double > getDiffusionArea (unsigned int fid) const
 Virtual function to return diffusion X-section area. More...
 
vector< double > getDiffusionScaling (unsigned int fid) const
 Virtual function to return scale factor for diffusion. 1 here. More...
 
unsigned int getMeshDimensions (unsigned int fid) const
 Virtual function to return dimensions of specified entry. More...
 
double getMeshEntryVolume (unsigned int fid) const
 Virtual function to return volume of mesh Entry. More...
 
unsigned int getMeshType (unsigned int fid) const
 Virtual function to return MeshType of specified entry. More...
 
vector< unsigned int > getParentVoxel () const
 Inherited virtual, do nothing for now. More...
 
double getR0 (const Eref &e) const
 
double getR1 (const Eref &e) const
 
double getTotLength () const
 
const vector< double > & getVoxelArea () const
 
const vector< double > & getVoxelLength () const
 
double getX0 (const Eref &e) const
 
double getX1 (const Eref &e) const
 
double getY0 (const Eref &e) const
 
double getY1 (const Eref &e) const
 
double getZ0 (const Eref &e) const
 
double getZ1 (const Eref &e) const
 
void indexToSpace (unsigned int index, double &x, double &y, double &z) const
 
void innerBuildDefaultMesh (const Eref &e, double volume, unsigned int numEntries)
 Virtual func to make a mesh with specified Volume and numEntries. More...
 
unsigned int innerGetDimensions () const
 
unsigned int innerGetNumEntries () const
 
void innerHandleNodeInfo (const Eref &e, unsigned int numNodes, unsigned int numThreads)
 
void innerHandleRequestMeshStats (const Eref &e, const SrcFinfo2< unsigned int, vector< double > > *meshStatsFinfo)
 More inherited virtual funcs: request comes in for mesh stats. More...
 
void innerSetCoords (const Eref &e, const vector< double > &v)
 
void innerSetNumEntries (unsigned int n)
 Inherited virtual func. More...
 
void matchCubeMeshEntries (const CubeMesh *other, vector< VoxelJunction > &ret) const
 
void matchCylMeshEntries (const CylMesh *other, vector< VoxelJunction > &ret) const
 
void matchMeshEntries (const ChemCompt *other, vector< VoxelJunction > &ret) const
 
void matchNeuroMeshEntries (const NeuroMesh *other, vector< VoxelJunction > &ret) const
 
double nearest (double x, double y, double z, unsigned int &index) const
 
double nearest (double x, double y, double z, double &linePos, double &r) const
 
double selectGridVolume (double h) const
 
void setCoords (const Eref &e, vector< double > v)
 
void setDiffLength (const Eref &e, double v)
 
void setR0 (const Eref &e, double v)
 
void setR1 (const Eref &e, double v)
 
void setX0 (const Eref &e, double v)
 
void setX1 (const Eref &e, double v)
 
void setY0 (const Eref &e, double v)
 
void setY1 (const Eref &e, double v)
 
void setZ0 (const Eref &e, double v)
 
void setZ1 (const Eref &e, double v)
 
void transmitChange (const Eref &e)
 
void updateCoords (const Eref &e, const vector< double > &childConcs)
 
double vGetEntireVolume () const
 Inherited virtual. Returns entire volume of compartment. More...
 
const vector< double > & vGetVoxelMidpoint () const
 Virtual func so that derived classes can return voxel midpoint. More...
 
const vector< double > & vGetVoxelVolume () const
 Virtual func so that derived classes can pass voxel volume back. More...
 
bool vSetVolumeNotRates (double volume)
 Inherited virtual. Resizes len and dia of each voxel. More...
 
 ~CylMesh ()
 
- Public Member Functions inherited from MeshCompt
void addRow (unsigned int index, const vector< double > &entry, const vector< unsigned int > &colIndex)
 
void clearExtendedMeshEntryVolume ()
 Inherited virtual function to clear the vector of MeshEntryVolume. More...
 
double extendedMeshEntryVolume (unsigned int fid) const
 Virtual function to return volume of mesh Entry, including. More...
 
void extendStencil (const ChemCompt *other, const vector< VoxelJunction > &vj)
 Add boundary voxels to stencil for cross-solver junctions. More...
 
vector< unsigned int > getNeighbors (unsigned int fid) const
 Looks up stencil to return vector of indices of coupled voxels. More...
 
const SparseMatrix< double > & getStencil () const
 Returns entire sparse matrix of mesh. Used by diffusion solver. More...
 
unsigned int getStencilRow (unsigned int meshIndex, const double **entry, const unsigned int **colIndex) const
 
vector< double > innerGetStencilRate (unsigned int row) const
 
void innerResetStencil ()
 virtual func implemented here. More...
 
 MeshCompt ()
 
void setStencilSize (unsigned int numRows, unsigned int numCols)
 
 ~MeshCompt ()
 
- Public Member Functions inherited from ChemCompt
void buildDefaultMesh (const Eref &e, double volume, unsigned int numEntries)
 
void buildJunction (ChemCompt *other, vector< VoxelJunction > &ret)
 
 ChemCompt ()
 
void flipRet (vector< VoxelJunction > &ret) const
 Utility function for swapping first and second in VoxelJunctions. More...
 
void getChildConcs (const Eref &e, vector< double > &childConcs) const
 
unsigned int getDimensions () const
 
double getEntireVolume (const Eref &e) const
 
bool getIsMembraneBound () const
 
string getMethod () const
 
unsigned int getNumEntries () const
 
double getOneVoxelVolume (const Eref &e, unsigned int voxel) const
 
vector< unsigned int > getStencilIndex (unsigned int row) const
 
vector< double > getStencilRate (unsigned int row) const
 
vector< double > getVoxelMidpoint () const
 Returns vector of all voxel midpoints in compartment. More...
 
vector< double > getVoxelVolume () const
 Returns vector of all voxel volumes in compartment. More...
 
void handleNodeInfo (const Eref &e, unsigned int numNodes, unsigned int numThreads)
 
MeshEntrylookupEntry (unsigned int index)
 
void resetStencil ()
 
unsigned int setChildConcs (const Eref &e, const vector< double > &childConcs, unsigned int start) const
 
void setEntireVolume (const Eref &e, double volume)
 
void setIsMembraneBound (bool v)
 
virtual void setMeshEntryVolume (unsigned int fid, double volume)
 
void setMethod (string method)
 
void setNumEntries (unsigned int num)
 
void setOneVoxelVolume (const Eref &e, unsigned int voxel, double volume)
 
void setVolumeNotRates (double volume)
 
virtual ~ChemCompt ()
 

Static Public Member Functions

static const CinfoinitCinfo ()
 
- Static Public Member Functions inherited from ChemCompt
static double distance (double x, double y, double z)
 
static const CinfoinitCinfo ()
 
static SrcFinfo1< vector
< double > > * 
voxelVolOut ()
 

Private Attributes

double diffLength_
 Radius at other end. More...
 
bool isToroid_
 
double lenSlope_
 Utility value: dr/dx. More...
 
unsigned int numEntries_
 
double r0_
 coords More...
 
double r1_
 Radius at one end. More...
 
double rSlope_
 Utility value: Total length of cylinder. More...
 
double surfaceGranularity_
 Length constant for diffusion. Equal to dx. More...
 
double totLen_
 
bool useCaps_
 
double x0_
 
double x1_
 coords More...
 
double y0_
 coords More...
 
double y1_
 coords More...
 
double z0_
 coords More...
 
double z1_
 coords More...
 

Detailed Description

The CylMesh represents a chemically identified compartment shaped like an extended cylinder. This is psuedo-1 dimension: Only the axial dimension is considered for diffusion and subdivisions. Typically used in modelling small segments of dendrite

Definition at line 19 of file CylMesh.h.

Constructor & Destructor Documentation

CylMesh::CylMesh ( )

Definition at line 169 of file CylMesh.cpp.

170  :
171  numEntries_( 100 ),
172  useCaps_( 0 ),
173  isToroid_( false ),
174  x0_( 0.0 ),
175  y0_( 0.0 ),
176  z0_( 0.0 ),
177  x1_( 100.0e-6 ),
178  y1_( 0.0 ),
179  z1_( 0.0 ),
180  r0_( 1.0e-6 ),
181  r1_( 1.0e-6 ),
182  diffLength_( 1.0e-6 ),
183  surfaceGranularity_( 0.1 ),
184  totLen_( 100.0e-6 ),
185  rSlope_( 0.0 ),
186  lenSlope_( 0.0 )
187 {
188  ;
189 }
double surfaceGranularity_
Length constant for diffusion. Equal to dx.
Definition: CylMesh.h:185
unsigned int numEntries_
Definition: CylMesh.h:163
double x0_
Definition: CylMesh.h:167
double r1_
Radius at one end.
Definition: CylMesh.h:176
double y1_
coords
Definition: CylMesh.h:172
double z0_
coords
Definition: CylMesh.h:169
bool isToroid_
Definition: CylMesh.h:165
double lenSlope_
Utility value: dr/dx.
Definition: CylMesh.h:189
bool useCaps_
Definition: CylMesh.h:164
double r0_
coords
Definition: CylMesh.h:175
double rSlope_
Utility value: Total length of cylinder.
Definition: CylMesh.h:188
double totLen_
Definition: CylMesh.h:187
double x1_
coords
Definition: CylMesh.h:171
double z1_
coords
Definition: CylMesh.h:173
double diffLength_
Radius at other end.
Definition: CylMesh.h:178
double y0_
coords
Definition: CylMesh.h:168
CylMesh::~CylMesh ( )

Definition at line 191 of file CylMesh.cpp.

192 {
193  ;
194 }

Member Function Documentation

void CylMesh::buildStencil ( )

Definition at line 785 of file CylMesh.cpp.

References MeshCompt::addRow(), diffLength_, MeshCompt::innerResetStencil(), isToroid_, numEntries_, PI, r0_, r1_, rSlope_, and MeshCompt::setStencilSize().

Referenced by innerSetNumEntries(), and updateCoords().

786 {
788  for ( unsigned int i = 0; i < numEntries_; ++i ) {
789  double rLow = r0_ + i * rSlope_;
790  double rHigh = r0_ + (i + 1.0) * rSlope_;
791  double aLow = rLow * rLow * PI;
792  double aHigh = rHigh * rHigh * PI;
793  vector< double > entry;
794  vector< unsigned int > colIndex;
795  if ( i == 0 ) {
796  colIndex.push_back( 1 );
797  entry.push_back( aHigh / diffLength_ );
798  if ( isToroid_ ) {
799  colIndex.push_back( numEntries_ - 1 );
800  entry.push_back( aLow / diffLength_ );
801  }
802  } else if ( i == numEntries_ - 1 ) {
803  if ( isToroid_ ) {
804  colIndex.push_back( 0 );
805  if ( r0_ < r1_ )
806  entry.push_back( r0_ * r0_ * PI / diffLength_ );
807  else
808  entry.push_back( r1_ * r1_ * PI / diffLength_ );
809  }
810  colIndex.push_back( numEntries_ - 2 );
811  entry.push_back( aLow / diffLength_ );
812  } else { // Mostly it is in the middle.
813  colIndex.push_back( i - 1 );
814  entry.push_back( aLow / diffLength_ );
815  colIndex.push_back( i + 1 );
816  entry.push_back( aHigh / diffLength_ );
817  }
818  addRow( i, entry, colIndex );
819  }
821 }
void innerResetStencil()
virtual func implemented here.
Definition: MeshCompt.cpp:49
unsigned int numEntries_
Definition: CylMesh.h:163
void addRow(unsigned int index, const vector< double > &entry, const vector< unsigned int > &colIndex)
Definition: MeshCompt.cpp:98
double r1_
Radius at one end.
Definition: CylMesh.h:176
bool isToroid_
Definition: CylMesh.h:165
double r0_
coords
Definition: CylMesh.h:175
double rSlope_
Utility value: Total length of cylinder.
Definition: CylMesh.h:188
double diffLength_
Radius at other end.
Definition: CylMesh.h:178
const double PI
Definition: consts.cpp:12
void setStencilSize(unsigned int numRows, unsigned int numCols)
Definition: MeshCompt.cpp:106

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double CylMesh::extendedMeshEntryVolume ( unsigned int  fid) const
virtual

Volume of mesh Entry including abutting diff-coupled voxels.

Virtual function to return volume of mesh Entry, including for diffusively coupled voxels from other solvers.

Implements ChemCompt.

Definition at line 569 of file CylMesh.cpp.

References MeshCompt::extendedMeshEntryVolume(), getMeshEntryVolume(), and numEntries_.

570 {
571  if ( fid < numEntries_ ) {
572  return getMeshEntryVolume( fid );
573  } else {
575  }
576 }
unsigned int numEntries_
Definition: CylMesh.h:163
double extendedMeshEntryVolume(unsigned int fid) const
Virtual function to return volume of mesh Entry, including.
Definition: MeshCompt.cpp:36
double getMeshEntryVolume(unsigned int fid) const
Virtual function to return volume of mesh Entry.
Definition: CylMesh.cpp:477

+ Here is the call graph for this function:

vector< double > CylMesh::getCoordinates ( unsigned int  fid) const
virtual

Virtual function to return coords of mesh Entry.

Virtual function to return coords of mesh Entry. For Cylindrical mesh, coords are x1y1z1 x2y2z2 r0 r1 phi0 phi1

Implements ChemCompt.

Definition at line 489 of file CylMesh.cpp.

References diffLength_, lenSlope_, r0_, r1_, rSlope_, totLen_, x0_, x1_, y0_, y1_, z0_, and z1_.

490 {
491  vector< double > ret(10, 0.0);
492  double len0 = diffLength_ * 2 * r0_ / ( r0_ + r1_ );
493  // double len0 = diffLength_ * 2 * ( r0_ + rSlope_ / 0.5) / ( r0_ + r1_ );
494  double lenStart = len0 + lenSlope_ * 0.5;
495 
496  double axialStart = fid * lenStart + ( ( fid * (fid - 1 ) )/2 ) * lenSlope_;
497  // fid * totLen_/numEntries_ + (fid - frac ) * lenSlope_;
498  double axialEnd =
499  (fid + 1) * lenStart + ( ( fid * (fid + 1 ) )/2 ) * lenSlope_;
500  // (fid + 1) * totLen_/numEntries_ + (fid - frac + 1.0) * lenSlope_;
501 
502  ret[0] = x0_ + (x1_ - x0_ ) * axialStart/totLen_;
503  ret[1] = y0_ + (y1_ - y0_ ) * axialStart/totLen_;
504  ret[2] = z0_ + (z1_ - z0_ ) * axialStart/totLen_;
505 
506  ret[3] = x0_ + (x1_ - x0_ ) * axialEnd/totLen_;
507  ret[4] = y0_ + (y1_ - y0_ ) * axialEnd/totLen_;
508  ret[5] = z0_ + (z1_ - z0_ ) * axialEnd/totLen_;
509 
510  ret[6] = r0_ + fid * rSlope_;
511  ret[7] = r0_ + (fid + 1.0) * rSlope_;
512 
513  ret[8] = 0;
514  ret[9] = 0;
515 
516  return ret;
517 }
double x0_
Definition: CylMesh.h:167
double r1_
Radius at one end.
Definition: CylMesh.h:176
double y1_
coords
Definition: CylMesh.h:172
double z0_
coords
Definition: CylMesh.h:169
double lenSlope_
Utility value: dr/dx.
Definition: CylMesh.h:189
double r0_
coords
Definition: CylMesh.h:175
double rSlope_
Utility value: Total length of cylinder.
Definition: CylMesh.h:188
double totLen_
Definition: CylMesh.h:187
double x1_
coords
Definition: CylMesh.h:171
double z1_
coords
Definition: CylMesh.h:173
double diffLength_
Radius at other end.
Definition: CylMesh.h:178
double y0_
coords
Definition: CylMesh.h:168
vector< double > CylMesh::getCoords ( const Eref e) const

Definition at line 372 of file CylMesh.cpp.

References diffLength_, r0_, r1_, x0_, x1_, y0_, y1_, z0_, and z1_.

Referenced by initCinfo().

373 {
374  vector< double > ret( 9 );
375 
376  ret[0] = x0_;
377  ret[1] = y0_;
378  ret[2] = z0_;
379 
380  ret[3] = x1_;
381  ret[4] = y1_;
382  ret[5] = z1_;
383 
384  ret[6] = r0_;
385  ret[7] = r1_;
386 
387  ret[8] = diffLength_;
388  return ret;
389 }
double x0_
Definition: CylMesh.h:167
double r1_
Radius at one end.
Definition: CylMesh.h:176
double y1_
coords
Definition: CylMesh.h:172
double z0_
coords
Definition: CylMesh.h:169
double r0_
coords
Definition: CylMesh.h:175
double x1_
coords
Definition: CylMesh.h:171
double z1_
coords
Definition: CylMesh.h:173
double diffLength_
Radius at other end.
Definition: CylMesh.h:178
double y0_
coords
Definition: CylMesh.h:168

+ Here is the caller graph for this function:

double CylMesh::getDiffLength ( const Eref e) const

Definition at line 400 of file CylMesh.cpp.

References diffLength_.

Referenced by initCinfo().

401 {
402  return diffLength_;
403 }
double diffLength_
Radius at other end.
Definition: CylMesh.h:178

+ Here is the caller graph for this function:

vector< double > CylMesh::getDiffusionArea ( unsigned int  fid) const
virtual

Virtual function to return diffusion X-section area.

Virtual function to return diffusion X-section area for each neighbor.

Implements ChemCompt.

Definition at line 520 of file CylMesh.cpp.

References isToroid_, numEntries_, PI, r0_, and rSlope_.

521 {
522  if ( numEntries_ <= 1 )
523  return vector< double >( 0 );
524 
525  double rlow = r0_ + fid * rSlope_;
526  double rhigh = r0_ + (fid + 1.0) * rSlope_;
527 
528  if ( fid == 0 ) {
529  if ( isToroid_ ) {
530  vector < double > ret( 2 );
531  ret[0] = rlow * rlow * PI;
532  ret[1] = rhigh * rhigh * PI;
533  return ret;
534  } else {
535  return vector < double >( 1, rhigh * rhigh * PI );
536  }
537  }
538 
539  if ( fid == (numEntries_ - 1 ) ) {
540  if ( isToroid_ ) {
541  vector < double > ret( 2 );
542  ret[0] = rlow * rlow * PI;
543  ret[1] = r0_ * r0_ * PI; // Wrapping around
544  return ret;
545  } else {
546  return vector < double >( 1, rlow * rlow * PI );
547  }
548  }
549  vector< double > ret( 2 );
550  ret[0] = rlow * rlow * PI;
551  ret[1] = rhigh * rhigh * PI;
552  return ret;
553 }
unsigned int numEntries_
Definition: CylMesh.h:163
bool isToroid_
Definition: CylMesh.h:165
double r0_
coords
Definition: CylMesh.h:175
double rSlope_
Utility value: Total length of cylinder.
Definition: CylMesh.h:188
const double PI
Definition: consts.cpp:12
vector< double > CylMesh::getDiffusionScaling ( unsigned int  fid) const
virtual

Virtual function to return scale factor for diffusion. 1 here.

Implements ChemCompt.

Definition at line 556 of file CylMesh.cpp.

References isToroid_, and numEntries_.

557 {
558  if ( numEntries_ <= 1 )
559  return vector< double >( 0 );
560 
561  if ( !isToroid_ && ( fid == 0 || fid == (numEntries_ - 1) ) )
562  return vector< double >( 1, 1.0 );
563 
564  return vector< double >( 2, 1.0 );
565 }
unsigned int numEntries_
Definition: CylMesh.h:163
bool isToroid_
Definition: CylMesh.h:165
unsigned int CylMesh::getMeshDimensions ( unsigned int  fid) const
virtual

Virtual function to return dimensions of specified entry.

Implements ChemCompt.

Definition at line 430 of file CylMesh.cpp.

431 {
432  return 3;
433 }
double CylMesh::getMeshEntryVolume ( unsigned int  fid) const
virtual

Virtual function to return volume of mesh Entry.

diffLength = length constant for diffusive spread len = length of each mesh entry totLen = total length of cylinder diffLength = k * r^2 Each entry has the same number of diffLengths, L = len/diffLength. Thinner entries have shorter diffLength. This gives a moderately nasty quadratic. However, as len(i) is prop to diffLength(i), and diffLength(i) is prop to r(i)^2 and the cyl-mesh is assumed a gently sloping cone we get len(i) is prop to (r0 + slope.x)^2 and ignoring the 2nd-order term we have len(i) is approx proportional to x position.

dr/dx = (r1-r0)/len ri = r0 + i * dr/dx r(i+1)-ri = (r1-r0)/numEntries len = k * r^2 we get k from integ_r0,r1( len.dr ) = totLen So k.r^3/3 | r0, r1 = totLen => k/3 * ( r1^3 - r0^3) = totLen => k = 3 * totLen / (r1^3 - r0^3); This is bad if r1 == r0, and is generally unpleasant.

Simple definition of rSlope: rSlope is measured per meshEntry, not per length: rSlope = ( r1 - r0 ) / numEntries; Let's just compute len0 from r0 and diffLength. len0/diffLength = 2 * r0 / (r0 + r1) so len0 = diffLength * 2 * r0 / (r0 + r1) and dlen/dx = lenSlope = diffLength * rSlope * 2/(r0 + r1)

Drop the following calculations: // dlen/dx = dr/dx * dlen/dr = ( (r1-r0)/len ) * 2k.r // To linearize, let 2r = r0 + r1. // so dlen/dx = ( (r1-r0)/len ) * k * ( r0 + r1 ) // len(i) = len0 + i * dlen/dx // len0 = totLen/numEntries - ( numEntries/2 ) * dlen/dx

Implements ChemCompt.

Definition at line 477 of file CylMesh.cpp.

Referenced by extendedMeshEntryVolume(), matchCylMeshEntries(), vGetEntireVolume(), and vGetVoxelVolume().

478 {
479  double len0 = diffLength_ * 2 * r0_ / ( r0_ + r1_ );
480 
481  double ri = r0_ + (fid + 0.5) * rSlope_;
482  double leni = len0 + ( fid + 0.5 ) * lenSlope_;
483 
484  return leni * ri * ri * PI;
485 }
double r1_
Radius at one end.
Definition: CylMesh.h:176
double lenSlope_
Utility value: dr/dx.
Definition: CylMesh.h:189
double r0_
coords
Definition: CylMesh.h:175
double rSlope_
Utility value: Total length of cylinder.
Definition: CylMesh.h:188
double diffLength_
Radius at other end.
Definition: CylMesh.h:178
const double PI
Definition: consts.cpp:12

+ Here is the caller graph for this function:

unsigned int CylMesh::getMeshType ( unsigned int  fid) const
virtual

Virtual function to return MeshType of specified entry.

Implements ChemCompt.

Definition at line 421 of file CylMesh.cpp.

References CYL, isToroid_, numEntries_, SPHERE_SHELL_SEG, and useCaps_.

422 {
423  if ( !isToroid_ && useCaps_ && ( fid == 0 || fid == numEntries_ - 1 ) )
424  return SPHERE_SHELL_SEG;
425 
426  return CYL;
427 }
unsigned int numEntries_
Definition: CylMesh.h:163
bool isToroid_
Definition: CylMesh.h:165
Definition: MeshEntry.h:20
bool useCaps_
Definition: CylMesh.h:164
vector< unsigned int > CylMesh::getParentVoxel ( ) const
virtual

Inherited virtual, do nothing for now.

Implements MeshCompt.

Definition at line 656 of file CylMesh.cpp.

References numEntries_.

657 {
658  vector< unsigned int > ret( numEntries_ );
659  if ( numEntries_ > 0 )
660  ret[0] = static_cast< unsigned int >( -1 );
661  for (unsigned int i = 1; i < numEntries_; ++i )
662  ret[i] = i-1;
663 
664  return ret;
665 }
unsigned int numEntries_
Definition: CylMesh.h:163
double CylMesh::getR0 ( const Eref e) const

Definition at line 285 of file CylMesh.cpp.

References r0_.

Referenced by initCinfo().

286 {
287  return r0_;
288 }
double r0_
coords
Definition: CylMesh.h:175

+ Here is the caller graph for this function:

double CylMesh::getR1 ( const Eref e) const

Definition at line 338 of file CylMesh.cpp.

References r1_.

Referenced by initCinfo().

339 {
340  return r1_;
341 }
double r1_
Radius at one end.
Definition: CylMesh.h:176

+ Here is the caller graph for this function:

double CylMesh::getTotLength ( ) const

Definition at line 406 of file CylMesh.cpp.

References totLen_.

Referenced by initCinfo().

407 {
408  return totLen_;
409 }
double totLen_
Definition: CylMesh.h:187

+ Here is the caller graph for this function:

const vector< double > & CylMesh::getVoxelArea ( ) const
virtual

Implements MeshCompt.

Definition at line 694 of file CylMesh.cpp.

References numEntries_, PI, r0_, and r1_.

695 {
696  static vector< double > area;
697  area.resize( numEntries_ );
698  for ( unsigned int i = 0; i < numEntries_; ++i ) {
699  double frac = ( 0.5 + static_cast< double >( i ) ) /
700  static_cast< double >( numEntries_ );
701  double r = r0_ * ( 1.0 - frac ) + r1_ * frac;
702  area[i] = r * r * PI;
703  }
704  return area;
705 }
unsigned int numEntries_
Definition: CylMesh.h:163
double r1_
Radius at one end.
Definition: CylMesh.h:176
double r0_
coords
Definition: CylMesh.h:175
const double PI
Definition: consts.cpp:12
const vector< double > & CylMesh::getVoxelLength ( ) const
virtual

Implements MeshCompt.

Definition at line 707 of file CylMesh.cpp.

References numEntries_, and totLen_.

708 {
709  static vector< double > length;
710  length.assign( numEntries_, totLen_ / numEntries_ );
711  return length;
712 }
unsigned int numEntries_
Definition: CylMesh.h:163
double totLen_
Definition: CylMesh.h:187
double CylMesh::getX0 ( const Eref e) const

Definition at line 246 of file CylMesh.cpp.

References x0_.

Referenced by initCinfo().

247 {
248  return x0_;
249 }
double x0_
Definition: CylMesh.h:167

+ Here is the caller graph for this function:

double CylMesh::getX1 ( const Eref e) const

Definition at line 299 of file CylMesh.cpp.

References x1_.

Referenced by initCinfo().

300 {
301  return x1_;
302 }
double x1_
coords
Definition: CylMesh.h:171

+ Here is the caller graph for this function:

double CylMesh::getY0 ( const Eref e) const

Definition at line 259 of file CylMesh.cpp.

References y0_.

Referenced by initCinfo().

260 {
261  return y0_;
262 }
double y0_
coords
Definition: CylMesh.h:168

+ Here is the caller graph for this function:

double CylMesh::getY1 ( const Eref e) const

Definition at line 312 of file CylMesh.cpp.

References y1_.

Referenced by initCinfo().

313 {
314  return y1_;
315 }
double y1_
coords
Definition: CylMesh.h:172

+ Here is the caller graph for this function:

double CylMesh::getZ0 ( const Eref e) const

Definition at line 272 of file CylMesh.cpp.

References z0_.

Referenced by initCinfo().

273 {
274  return z0_;
275 }
double z0_
coords
Definition: CylMesh.h:169

+ Here is the caller graph for this function:

double CylMesh::getZ1 ( const Eref e) const

Definition at line 325 of file CylMesh.cpp.

References z1_.

Referenced by initCinfo().

326 {
327  return z1_;
328 }
double z1_
coords
Definition: CylMesh.h:173

+ Here is the caller graph for this function:

void CylMesh::indexToSpace ( unsigned int  index,
double &  x,
double &  y,
double &  z 
) const
virtual

Converts specified index to xyz coords of middle of voxel Values out of range return original xyz

Implements ChemCompt.

Definition at line 1026 of file CylMesh.cpp.

References numEntries_, x0_, x1_, y0_, y1_, z0_, and z1_.

1028 {
1029  if ( index < numEntries_ ) {
1030  double k = ( index + 0.5 ) / static_cast< double >( numEntries_ );
1031  x = ( x1_ - x0_ ) * k + x0_;
1032  y = ( y1_ - y0_ ) * k + y0_;
1033  z = ( z1_ - z0_ ) * k + z0_;
1034  }
1035 }
unsigned int numEntries_
Definition: CylMesh.h:163
double x0_
Definition: CylMesh.h:167
double y1_
coords
Definition: CylMesh.h:172
double z0_
coords
Definition: CylMesh.h:169
double x1_
coords
Definition: CylMesh.h:171
double z1_
coords
Definition: CylMesh.h:173
double y0_
coords
Definition: CylMesh.h:168
const Cinfo * CylMesh::initCinfo ( )
static

Definition at line 27 of file CylMesh.cpp.

References cylMeshCinfo, getCoords(), getDiffLength(), getR0(), getR1(), getTotLength(), getX0(), getX1(), getY0(), getY1(), getZ0(), getZ1(), ChemCompt::initCinfo(), innerGetNumEntries(), setCoords(), setDiffLength(), setR0(), setR1(), setX0(), setX1(), setY0(), setY1(), setZ0(), and setZ1().

28 {
30  // Field Definitions
33  "x0",
34  "x coord of one end",
37  );
39  "y0",
40  "y coord of one end",
43  );
45  "z0",
46  "z coord of one end",
49  );
51  "r0",
52  "Radius of one end",
55  );
57  "x1",
58  "x coord of other end",
61  );
63  "y1",
64  "y coord of other end",
67  );
69  "z1",
70  "z coord of other end",
73  );
75  "r1",
76  "Radius of other end",
79  );
81  "coords",
82  "All the coords as a single vector: x0 y0 z0 x1 y1 z1 r0 r1 diffLength",
85  );
86 
87  static ElementValueFinfo< CylMesh, double > diffLength(
88  "diffLength",
89  "Length constant to use for subdivisions"
90  "The system will attempt to subdivide using compartments of"
91  "length diffLength on average. If the cylinder has different end"
92  "diameters r0 and r1, it will scale to smaller lengths"
93  "for the smaller diameter end and vice versa."
94  "Once the value is set it will recompute diffLength as "
95  "totLength/numEntries",
98  );
99 
100  static ReadOnlyValueFinfo< CylMesh, unsigned int > numDiffCompts(
101  "numDiffCompts",
102  "Number of diffusive compartments in model",
104  );
105 
106  static ReadOnlyValueFinfo< CylMesh, double > totLength(
107  "totLength",
108  "Total length of cylinder",
110  );
111 
113  // MsgDest Definitions
115 
117  // Field Elements
119 
120  static Finfo* cylMeshFinfos[] = {
121  &x0, // Value
122  &y0, // Value
123  &z0, // Value
124  &r0, // Value
125  &x1, // Value
126  &y1, // Value
127  &z1, // Value
128  &r1, // Value
129  &diffLength, // Value
130  &coords, // Value
131  &numDiffCompts, // ReadOnlyValue
132  &totLength, // ReadOnlyValue
133  };
134 
135  static string doc[] =
136  {
137  "Name", "CylMesh",
138  "Author", "Upi Bhalla",
139  "Description", "Chemical compartment with cylindrical geometry. "
140  "Defaults to a uniform cylinder of radius 1 micron, "
141  "length 100 microns, and voxel length 1 micron so there "
142  "are 100 voxels in the cylinder. "
143  "The cylinder can be given a linear taper, by assigning "
144  "different radii r0 and r1 to the two ends. ",
145  };
146  static Dinfo< CylMesh > dinfo;
147  static Cinfo cylMeshCinfo (
148  "CylMesh",
150  cylMeshFinfos,
151  sizeof( cylMeshFinfos ) / sizeof ( Finfo* ),
152  &dinfo,
153  doc,
154  sizeof(doc)/sizeof(string)
155  );
156 
157  return &cylMeshCinfo;
158 }
static const Cinfo * initCinfo()
Definition: ChemCompt.cpp:25
double getY0(const Eref &e) const
Definition: CylMesh.cpp:259
Definition: Dinfo.h:60
void setDiffLength(const Eref &e, double v)
Definition: CylMesh.cpp:392
static const Cinfo * cylMeshCinfo
Definition: CylMesh.cpp:164
void setY1(const Eref &e, double v)
Definition: CylMesh.cpp:304
vector< double > getCoords(const Eref &e) const
Definition: CylMesh.cpp:372
double getTotLength() const
Definition: CylMesh.cpp:406
unsigned int innerGetNumEntries() const
Definition: CylMesh.cpp:615
double getX1(const Eref &e) const
Definition: CylMesh.cpp:299
void setZ0(const Eref &e, double v)
Definition: CylMesh.cpp:264
void setX0(const Eref &e, double v)
Definition: CylMesh.cpp:238
void setX1(const Eref &e, double v)
Definition: CylMesh.cpp:291
double getR1(const Eref &e) const
Definition: CylMesh.cpp:338
void setR0(const Eref &e, double v)
Definition: CylMesh.cpp:277
double getR0(const Eref &e) const
Definition: CylMesh.cpp:285
double getZ0(const Eref &e) const
Definition: CylMesh.cpp:272
double getY1(const Eref &e) const
Definition: CylMesh.cpp:312
void setR1(const Eref &e, double v)
Definition: CylMesh.cpp:330
double getX0(const Eref &e) const
Definition: CylMesh.cpp:246
void setY0(const Eref &e, double v)
Definition: CylMesh.cpp:251
void setZ1(const Eref &e, double v)
Definition: CylMesh.cpp:317
double getDiffLength(const Eref &e) const
Definition: CylMesh.cpp:400
void setCoords(const Eref &e, vector< double > v)
Definition: CylMesh.cpp:363
Definition: Cinfo.h:18
double getZ1(const Eref &e) const
Definition: CylMesh.cpp:325
Definition: Finfo.h:12

+ Here is the call graph for this function:

void CylMesh::innerBuildDefaultMesh ( const Eref e,
double  volume,
unsigned int  numEntries 
)
virtual

Virtual func to make a mesh with specified Volume and numEntries.

Single voxel cylinder with diameter = length. vol = volume = pi.r^2.len. So len = 2r, volume = pi*r^2*2r = 2pi*r^3 so r = (volume/2pi)^(1/3)

Implements ChemCompt.

Definition at line 641 of file CylMesh.cpp.

References numEntries, PI, and setCoords().

643 {
647  double r = pow( ( volume / ( PI * 2 ) ), 1.0 / 3 );
648  vector< double > coords( 9, 0 );
649  coords[3] = 2 * r;
650  coords[6] = r;
651  coords[7] = r;
652  coords[8] = 2 * r / numEntries;
653  setCoords( e, coords );
654 }
const int numEntries
Definition: proc.cpp:60
const double PI
Definition: consts.cpp:12
void setCoords(const Eref &e, vector< double > v)
Definition: CylMesh.cpp:363

+ Here is the call graph for this function:

unsigned int CylMesh::innerGetDimensions ( ) const
virtual

Implements ChemCompt.

Definition at line 411 of file CylMesh.cpp.

412 {
413  return 3;
414 }
unsigned int CylMesh::innerGetNumEntries ( ) const
virtual

Inherited virtual func. Returns number of MeshEntry in array

Implements ChemCompt.

Definition at line 615 of file CylMesh.cpp.

References numEntries_.

Referenced by initCinfo().

616 {
617  return numEntries_;
618 }
unsigned int numEntries_
Definition: CylMesh.h:163

+ Here is the caller graph for this function:

void CylMesh::innerHandleNodeInfo ( const Eref e,
unsigned int  numNodes,
unsigned int  numThreads 
)
virtual

Implements ChemCompt.

Definition at line 591 of file CylMesh.cpp.

594 {
595  /*
596  unsigned int numEntries = numEntries_;
597  vector< double > vols( numEntries, volume_ / numEntries );
598  vector< unsigned int > localEntries( numEntries );
599  vector< vector< unsigned int > > outgoingEntries;
600  vector< vector< unsigned int > > incomingEntries;
601  */
602  /*
603  double oldvol = getMeshEntryVolume( 0 );
604  meshSplit()->send( e,
605  oldvol,
606  vols, localEntries,
607  outgoingEntries, incomingEntries );
608  */
609 }
void CylMesh::innerHandleRequestMeshStats ( const Eref e,
const SrcFinfo2< unsigned int, vector< double > > *  meshStatsFinfo 
)

More inherited virtual funcs: request comes in for mesh stats.

Definition at line 583 of file CylMesh.cpp.

References numEntries_, and vGetEntireVolume().

586 {
587  vector< double > ret( vGetEntireVolume() / numEntries_ ,1 );
588  meshStatsFinfo->send( e, 1, ret );
589 }
unsigned int numEntries_
Definition: CylMesh.h:163
void send(const Eref &e, const T1 &arg1, const T2 &arg2) const
Definition: SrcFinfo.h:228
double vGetEntireVolume() const
Inherited virtual. Returns entire volume of compartment.
Definition: CylMesh.cpp:714

+ Here is the call graph for this function:

void CylMesh::innerSetCoords ( const Eref e,
const vector< double > &  v 
)

Definition at line 343 of file CylMesh.cpp.

References diffLength_, ChemCompt::getChildConcs(), r0_, r1_, updateCoords(), x0_, x1_, y0_, y1_, z0_, and z1_.

Referenced by setCoords().

344 {
345  vector< double > childConcs;
346  getChildConcs( e, childConcs );
347  x0_ = v[0];
348  y0_ = v[1];
349  z0_ = v[2];
350 
351  x1_ = v[3];
352  y1_ = v[4];
353  z1_ = v[5];
354 
355  r0_ = v[6];
356  r1_ = v[7];
357 
358  diffLength_ = v[8];
359 
360  updateCoords( e, childConcs );
361 }
void updateCoords(const Eref &e, const vector< double > &childConcs)
Definition: CylMesh.cpp:205
double x0_
Definition: CylMesh.h:167
double r1_
Radius at one end.
Definition: CylMesh.h:176
double y1_
coords
Definition: CylMesh.h:172
double z0_
coords
Definition: CylMesh.h:169
void getChildConcs(const Eref &e, vector< double > &childConcs) const
Definition: ChemCompt.cpp:264
double r0_
coords
Definition: CylMesh.h:175
double x1_
coords
Definition: CylMesh.h:171
double z1_
coords
Definition: CylMesh.h:173
double diffLength_
Radius at other end.
Definition: CylMesh.h:178
double y0_
coords
Definition: CylMesh.h:168

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CylMesh::innerSetNumEntries ( unsigned int  n)
virtual

Inherited virtual func.

Inherited virtual func. Assigns number of MeshEntries.

Implements ChemCompt.

Definition at line 623 of file CylMesh.cpp.

References buildStencil(), diffLength_, lenSlope_, numEntries_, r0_, r1_, rSlope_, and totLen_.

624 {
625  static const unsigned int WayTooLarge = 1000000;
626  if ( n == 0 || n > WayTooLarge ) {
627  cout << "Warning: CylMesh::innerSetNumEntries( " << n <<
628  " ): out of range\n";
629  return;
630  }
631  assert( n > 0 );
632  numEntries_ = n;
633  diffLength_ = totLen_ / n;
634  rSlope_ = ( r1_ - r0_ ) / numEntries_;
635  lenSlope_ = diffLength_ * rSlope_ * 2 / ( r0_ + r1_ );
636 
637  buildStencil();
638 }
unsigned int numEntries_
Definition: CylMesh.h:163
double r1_
Radius at one end.
Definition: CylMesh.h:176
double lenSlope_
Utility value: dr/dx.
Definition: CylMesh.h:189
double r0_
coords
Definition: CylMesh.h:175
void buildStencil()
Definition: CylMesh.cpp:785
double rSlope_
Utility value: Total length of cylinder.
Definition: CylMesh.h:188
double totLen_
Definition: CylMesh.h:187
double diffLength_
Radius at other end.
Definition: CylMesh.h:178

+ Here is the call graph for this function:

void CylMesh::matchCubeMeshEntries ( const CubeMesh other,
vector< VoxelJunction > &  ret 
) const

Definition at line 983 of file CylMesh.cpp.

References Vec::a0(), Vec::a1(), Vec::a2(), diffLength_, EPSILON, fillPointsOnCircle(), CubeMesh::getDx(), ChemCompt::getNumEntries(), numEntries_, Vec::orthogonalAxes(), r0_, rSlope_, selectGridVolume(), totLen_, x0_, x1_, y0_, y1_, z0_, and z1_.

Referenced by matchMeshEntries().

985 {
986  const double EPSILON = 1e-18;
987  Vec a( x1_ - x0_, y1_ - y0_, z1_ - z0_ );
988  Vec u;
989  Vec v;
990  a.orthogonalAxes( u, v );
991 
992  double h = selectGridVolume( other->getDx() );
993 
994  unsigned int num = floor( 0.1 + diffLength_ / h );
995  // March along axis of cylinder.
996  // q is the location of the point along axis.
997  for ( unsigned int i = 0; i < numEntries_; ++i ) {
998  vector< double >area( other->getNumEntries(), 0.0 );
999  for ( unsigned int j = 0; j < num; ++j ) {
1000  unsigned int m = i * num + j;
1001  double frac = ( m * h + h/2.0 ) / totLen_;
1002  double q0 = x0_ + a.a0() * frac;
1003  double q1 = y0_ + a.a1() * frac;
1004  double q2 = z0_ + a.a2() * frac;
1005  // get radius of cylinder at this point.
1006  double r = r0_ + ( m * h + h / 2.0 ) * rSlope_;
1007  fillPointsOnCircle( u, v, Vec( q0, q1, q2 ),
1008  h, r, area, other );
1009  }
1010  // Go through all cubeMesh entries and compute diffusion
1011  // cross-section. Assume this is through a membrane, so the
1012  // only factor relevant is area. Not the distance.
1013  for ( unsigned int k = 0; k < area.size(); ++k ) {
1014  if ( area[k] > EPSILON ) {
1015  ret.push_back( VoxelJunction( i, k, area[k] ) );
1016  }
1017  }
1018  }
1019 }
unsigned int numEntries_
Definition: CylMesh.h:163
double x0_
Definition: CylMesh.h:167
double getDx() const
Definition: CubeMesh.cpp:507
double y1_
coords
Definition: CylMesh.h:172
double z0_
coords
Definition: CylMesh.h:169
unsigned int getNumEntries() const
Definition: ChemCompt.cpp:390
Definition: Vec.h:13
double r0_
coords
Definition: CylMesh.h:175
double rSlope_
Utility value: Total length of cylinder.
Definition: CylMesh.h:188
double totLen_
Definition: CylMesh.h:187
double x1_
coords
Definition: CylMesh.h:171
double z1_
coords
Definition: CylMesh.h:173
void fillPointsOnCircle(const Vec &u, const Vec &v, const Vec &q, double h, double r, vector< double > &area, const CubeMesh *other)
Definition: CylMesh.cpp:955
double diffLength_
Radius at other end.
Definition: CylMesh.h:178
void orthogonalAxes(Vec &u, Vec &v) const
Generates vectors u and v to form a mutually orthogonal system.
Definition: Vec.cpp:41
double y0_
coords
Definition: CylMesh.h:168
#define EPSILON
Definition: MatrixOps.h:28
double selectGridVolume(double h) const
Definition: CylMesh.cpp:940

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CylMesh::matchCylMeshEntries ( const CylMesh other,
vector< VoxelJunction > &  ret 
) const

Definition at line 861 of file CylMesh.cpp.

References diffLength_, ChemCompt::distance(), EPSILON, getMeshEntryVolume(), numEntries_, PI, r0_, r1_, totLen_, x0_, x1_, y0_, y1_, z0_, and z1_.

Referenced by matchMeshEntries().

863 {
864  const double EPSILON = 1e-3;
865  ret.clear();
866  // Should really estimate the distance from the centre of the smaller
867  // cylinder cap disk to the plane of the larger disk, provided it is
868  // within the radius of the disk. The subsequent calculations are the
869  // same though.
870  double dr1 = // startOfSelf-to-startOfOther
871  distance(x0_ - other->x0_, y0_ - other->y0_, z0_ - other->z0_ );
872  double dr2 = // endOfSelf-to-endOfOther
873  distance(x1_ - other->x1_, y1_ - other->y1_, z1_ - other->z1_ );
874  double dr3 = // endOfSelf-to-startOfOther
875  distance(x1_ - other->x0_, y1_ - other->y0_, z1_ - other->z0_ );
876  double dr4 = // startOfSelf-to-endOfOther
877  distance(x0_ - other->x1_, y0_ - other->y1_, z0_ - other->z1_ );
878 
879  if ( dr1 <= dr2 && dr1 <= dr3 && dr1 <= dr4 ) {
880  if ( ( dr1/totLen_ < EPSILON && dr1/other->totLen_ < EPSILON ) ) {
881  double xda;
882  if ( r0_ < other->r0_ )
883  xda = 2 * r0_ * r0_ * PI / ( diffLength_ + other->diffLength_ );
884  else
885  xda = 2 * other->r0_ * other->r0_ * PI /
886  ( diffLength_ + other->diffLength_ );
887  ret.push_back( VoxelJunction( 0, 0, xda ) );
888  ret.back().first = 0;
889  ret.back().second = 0;
890  ret.back().firstVol = getMeshEntryVolume( 0 );
891  ret.back().secondVol = other->getMeshEntryVolume( 0 );
892  }
893  } else if ( dr2 <= dr3 && dr2 <= dr4 ) {
894  if ( ( dr2/totLen_ < EPSILON && dr2/other->totLen_ < EPSILON ) ) {
895  double xda;
896  if ( r1_ < other->r1_ )
897  xda = 2 * r1_ * r1_ * PI / ( diffLength_ + other->diffLength_ );
898  else
899  xda = 2 * other->r1_ * other->r1_ * PI /
900  ( diffLength_ + other->diffLength_ );
901  ret.push_back( VoxelJunction( numEntries_ - 1,
902  other->numEntries_ - 1, xda ) );
903  ret.back().first = numEntries_;
904  ret.back().second = other->numEntries_ - 1;
905  ret.back().firstVol = getMeshEntryVolume( numEntries_ - 1 );
906  ret.back().secondVol = other->getMeshEntryVolume( other->numEntries_ - 1 );
907  }
908  } else if ( dr3 <= dr4 ) {
909  if ( ( dr3/totLen_ < EPSILON && dr3/other->totLen_ < EPSILON ) ) {
910  double xda;
911  if ( r1_ < other->r0_ )
912  xda = 2 * r1_ * r1_ * PI / ( diffLength_ + other->diffLength_ );
913  else
914  xda = 2 * other->r0_ * other->r0_ * PI /
915  ( diffLength_ + other->diffLength_ );
916  ret.push_back( VoxelJunction( numEntries_ - 1, 0, xda ) );
917  ret.back().first = numEntries_ - 1;
918  ret.back().second = 0;
919  ret.back().firstVol = getMeshEntryVolume( numEntries_ - 1 );
920  ret.back().secondVol = other->getMeshEntryVolume( 0 );
921  }
922  } else {
923  if ( ( dr4/totLen_ < EPSILON && dr4/other->totLen_ < EPSILON ) ) {
924  double xda;
925  if ( r0_ < other->r1_ )
926  xda = 2 * r0_ * r0_ * PI / ( diffLength_ + other->diffLength_ );
927  else
928  xda = 2 * other->r1_ * other->r1_ * PI /
929  ( diffLength_ + other->diffLength_ );
930  ret.push_back( VoxelJunction( 0, other->numEntries_ - 1, xda ));
931  ret.back().first = 0;
932  ret.back().second = other->numEntries_ - 1;
933  ret.back().firstVol = getMeshEntryVolume( 0 );
934  ret.back().secondVol = other->getMeshEntryVolume( other->numEntries_ - 1 );
935  }
936  }
937 }
unsigned int numEntries_
Definition: CylMesh.h:163
double x0_
Definition: CylMesh.h:167
double r1_
Radius at one end.
Definition: CylMesh.h:176
double y1_
coords
Definition: CylMesh.h:172
double z0_
coords
Definition: CylMesh.h:169
double getMeshEntryVolume(unsigned int fid) const
Virtual function to return volume of mesh Entry.
Definition: CylMesh.cpp:477
static double distance(double x, double y, double z)
Definition: ChemCompt.cpp:422
double r0_
coords
Definition: CylMesh.h:175
double totLen_
Definition: CylMesh.h:187
double x1_
coords
Definition: CylMesh.h:171
double z1_
coords
Definition: CylMesh.h:173
double diffLength_
Radius at other end.
Definition: CylMesh.h:178
const double PI
Definition: consts.cpp:12
double y0_
coords
Definition: CylMesh.h:168
#define EPSILON
Definition: MatrixOps.h:28

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CylMesh::matchMeshEntries ( const ChemCompt other,
vector< VoxelJunction > &  ret 
) const
virtual

Returns the meshIndices (NOT spatial indices) of all adjacent mesh entry pairs on ether side of the (self, other) junction. meshIndices are the indices that look up entries in the vector of pools. spatialIndices are (iz * ny + iy) * nx + ix, that is, a linear conversion of cartesian spatial indices. So, for two touching cubes, the return vector is the paired meshIndices on either side of the plane of contact. If one mesh has a finer mesh than the other, or if there are more than one contact points from self to other (for example, at a corner), then we just have multiple pairs using the same meshIndex of the repeated voxel.

Implements ChemCompt.

Definition at line 827 of file CylMesh.cpp.

References ChemCompt::flipRet(), matchCubeMeshEntries(), matchCylMeshEntries(), EndoMesh::matchMeshEntries(), and matchNeuroMeshEntries().

829 {
830  // This is seriously ugly, and what virtual funcs were meant to handle.
831  // Dirty hack for now.
832  const CylMesh* cyl = dynamic_cast< const CylMesh* >( other );
833  if ( cyl ) {
834  matchCylMeshEntries( cyl, ret );
835  return;
836  }
837  const EndoMesh* em = dynamic_cast< const EndoMesh* >( other );
838  if ( em )
839  {
840  em->matchMeshEntries( this, ret );
841  flipRet( ret );
842  return;
843  }
844  const CubeMesh* cube = dynamic_cast< const CubeMesh* >( other );
845  if ( cube ) {
846  matchCubeMeshEntries( cube, ret );
847  return;
848  }
849  const NeuroMesh* nm = dynamic_cast< const NeuroMesh* >( other );
850  if ( nm ) {
851  matchNeuroMeshEntries( nm, ret );
852  return;
853  }
854  cout << "Warning:CylMesh::matchMeshEntries: " <<
855  " unknown mesh type\n";
856 }
void matchNeuroMeshEntries(const NeuroMesh *other, vector< VoxelJunction > &ret) const
Definition: CylMesh.cpp:1021
void matchCubeMeshEntries(const CubeMesh *other, vector< VoxelJunction > &ret) const
Definition: CylMesh.cpp:983
void matchCylMeshEntries(const CylMesh *other, vector< VoxelJunction > &ret) const
Definition: CylMesh.cpp:861
void flipRet(vector< VoxelJunction > &ret) const
Utility function for swapping first and second in VoxelJunctions.
Definition: ChemCompt.cpp:406
void matchMeshEntries(const ChemCompt *other, vector< VoxelJunction > &ret) const
Definition: EndoMesh.cpp:420

+ Here is the call graph for this function:

void CylMesh::matchNeuroMeshEntries ( const NeuroMesh other,
vector< VoxelJunction > &  ret 
) const

Definition at line 1021 of file CylMesh.cpp.

Referenced by matchMeshEntries().

1023 {
1024 }

+ Here is the caller graph for this function:

double CylMesh::nearest ( double  x,
double  y,
double  z,
unsigned int &  index 
) const
virtual

Returns distance and index of nearest mesh entry. Computes each mesh entry position as its geometric centre. If the current location is not inside a valid mesh entry, distance returned is negative.

Implements ChemCompt.

Definition at line 1075 of file CylMesh.cpp.

References numEntries_, r0_, and rSlope_.

1077 {
1078  double k = 0.0;
1079  double r;
1080  double ret = nearest( x, y, z, k, r );
1081  if ( k < 0.0 ) {
1082  ret = -ret;
1083  index = 0;
1084  } else if ( k > 1.0 ) {
1085  ret = -ret;
1086  index = numEntries_ - 1;
1087  } else { // Inside length of cylinder, now is it inside radius?
1088  index = k * numEntries_;
1089  double ri = r0_ + (index + 0.5) * rSlope_;
1090  if ( ret > ri )
1091  ret = -ret;
1092  }
1093  return ret;
1094 }
double nearest(double x, double y, double z, unsigned int &index) const
Definition: CylMesh.cpp:1075
unsigned int numEntries_
Definition: CylMesh.h:163
double r0_
coords
Definition: CylMesh.h:175
double rSlope_
Utility value: Total length of cylinder.
Definition: CylMesh.h:188
double CylMesh::nearest ( double  x,
double  y,
double  z,
double &  linePos,
double &  r 
) const

Definition at line 1045 of file CylMesh.cpp.

References ChemCompt::distance(), dotprd(), numEntries_, r0_, rSlope_, x0_, x1_, y0_, y1_, z0_, and z1_.

1047 {
1048  // Consider r0 = x0,y0,z0 and r1 = x1, y1, z1, and r = x,y,z.
1049  // Fraction along cylinder = k
1050  //
1051  // Then, point p along line from r0 to r1 is
1052  // p = k( r0-r1) + r1.
1053  //
1054  // Solving,
1055  // k = (r0 - r1).(r - r1) / (|r0-r1|^2)
1056  //
1057 
1058  double dist = distance( x1_ - x0_, y1_ - y0_, z1_ - z0_ );
1059  double k = dotprd(
1060  x1_ - x0_, y1_ - y0_, z1_ - z0_,
1061  x - x0_, y - y0_, z - z0_ ) / ( dist * dist );
1062 
1063  // x2, y2, z2 are the coords of the nearest point.
1064  double x2 = k * (x1_ - x0_) + x0_;
1065  double y2 = k * (y1_ - y0_) + y0_;
1066  double z2 = k * (z1_ - z0_) + z0_;
1067 
1068  double ret = distance( x - x2, y - y2, z - z2 );
1069  linePos = k;
1070  r = r0_ + k * numEntries_ * rSlope_;
1071  return ret;
1072 }
unsigned int numEntries_
Definition: CylMesh.h:163
double x0_
Definition: CylMesh.h:167
double y1_
coords
Definition: CylMesh.h:172
double z0_
coords
Definition: CylMesh.h:169
static double dotprd(double x0, double y0, double z0, double x1, double y1, double z1)
Definition: CylMesh.cpp:1037
static double distance(double x, double y, double z)
Definition: ChemCompt.cpp:422
double r0_
coords
Definition: CylMesh.h:175
double rSlope_
Utility value: Total length of cylinder.
Definition: CylMesh.h:188
double x1_
coords
Definition: CylMesh.h:171
double z1_
coords
Definition: CylMesh.h:173
double y0_
coords
Definition: CylMesh.h:168

+ Here is the call graph for this function:

double CylMesh::selectGridVolume ( double  h) const

Definition at line 940 of file CylMesh.cpp.

References diffLength_, r0_, r1_, and surfaceGranularity_.

Referenced by matchCubeMeshEntries().

941 {
942  if ( h > diffLength_ )
943  h = diffLength_;
944  if ( h > r0_ )
945  h = r0_;
946  if ( h > r1_ )
947  h = r1_;
948  h *= surfaceGranularity_;
949  unsigned int num = ceil( diffLength_ / h );
950  h = diffLength_ / num;
951 
952  return h;
953 }
double surfaceGranularity_
Length constant for diffusion. Equal to dx.
Definition: CylMesh.h:185
double r1_
Radius at one end.
Definition: CylMesh.h:176
double r0_
coords
Definition: CylMesh.h:175
double diffLength_
Radius at other end.
Definition: CylMesh.h:178

+ Here is the caller graph for this function:

void CylMesh::setCoords ( const Eref e,
vector< double >  v 
)

Definition at line 363 of file CylMesh.cpp.

References innerSetCoords(), and transmitChange().

Referenced by initCinfo(), and innerBuildDefaultMesh().

364 {
365  if ( v.size() < 9 ) {
366  cout << "CylMesh::setCoords: Warning: size of argument vec should be >= 9, was " << v.size() << endl;
367  }
368  innerSetCoords( e, v );
369  transmitChange( e );
370 }
void transmitChange(const Eref &e)
Definition: CylMesh.cpp:741
void innerSetCoords(const Eref &e, const vector< double > &v)
Definition: CylMesh.cpp:343

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CylMesh::setDiffLength ( const Eref e,
double  v 
)

Definition at line 392 of file CylMesh.cpp.

References diffLength_, ChemCompt::getChildConcs(), and updateCoords().

Referenced by initCinfo().

393 {
394  vector< double > childConcs;
395  getChildConcs( e, childConcs );
396  diffLength_ = v;
397  updateCoords( e, childConcs );
398 }
void updateCoords(const Eref &e, const vector< double > &childConcs)
Definition: CylMesh.cpp:205
void getChildConcs(const Eref &e, vector< double > &childConcs) const
Definition: ChemCompt.cpp:264
double diffLength_
Radius at other end.
Definition: CylMesh.h:178

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CylMesh::setR0 ( const Eref e,
double  v 
)

Definition at line 277 of file CylMesh.cpp.

References ChemCompt::getChildConcs(), r0_, and updateCoords().

Referenced by initCinfo().

278 {
279  vector< double > childConcs;
280  getChildConcs( e, childConcs );
281  r0_ = v;
282  updateCoords( e, childConcs );
283 }
void updateCoords(const Eref &e, const vector< double > &childConcs)
Definition: CylMesh.cpp:205
void getChildConcs(const Eref &e, vector< double > &childConcs) const
Definition: ChemCompt.cpp:264
double r0_
coords
Definition: CylMesh.h:175

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CylMesh::setR1 ( const Eref e,
double  v 
)

Definition at line 330 of file CylMesh.cpp.

References ChemCompt::getChildConcs(), r1_, and updateCoords().

Referenced by initCinfo().

331 {
332  vector< double > childConcs;
333  getChildConcs( e, childConcs );
334  r1_ = v;
335  updateCoords( e, childConcs );
336 }
void updateCoords(const Eref &e, const vector< double > &childConcs)
Definition: CylMesh.cpp:205
double r1_
Radius at one end.
Definition: CylMesh.h:176
void getChildConcs(const Eref &e, vector< double > &childConcs) const
Definition: ChemCompt.cpp:264

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CylMesh::setX0 ( const Eref e,
double  v 
)

Definition at line 238 of file CylMesh.cpp.

References ChemCompt::getChildConcs(), updateCoords(), and x0_.

Referenced by initCinfo().

239 {
240  vector< double > childConcs;
241  getChildConcs( e, childConcs );
242  x0_ = v;
243  updateCoords( e, childConcs );
244 }
void updateCoords(const Eref &e, const vector< double > &childConcs)
Definition: CylMesh.cpp:205
double x0_
Definition: CylMesh.h:167
void getChildConcs(const Eref &e, vector< double > &childConcs) const
Definition: ChemCompt.cpp:264

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CylMesh::setX1 ( const Eref e,
double  v 
)

Definition at line 291 of file CylMesh.cpp.

References ChemCompt::getChildConcs(), updateCoords(), and x1_.

Referenced by initCinfo().

292 {
293  vector< double > childConcs;
294  getChildConcs( e, childConcs );
295  x1_ = v;
296  updateCoords( e, childConcs );
297 }
void updateCoords(const Eref &e, const vector< double > &childConcs)
Definition: CylMesh.cpp:205
void getChildConcs(const Eref &e, vector< double > &childConcs) const
Definition: ChemCompt.cpp:264
double x1_
coords
Definition: CylMesh.h:171

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CylMesh::setY0 ( const Eref e,
double  v 
)

Definition at line 251 of file CylMesh.cpp.

References ChemCompt::getChildConcs(), updateCoords(), and y0_.

Referenced by initCinfo().

252 {
253  vector< double > childConcs;
254  getChildConcs( e, childConcs );
255  y0_ = v;
256  updateCoords( e, childConcs );
257 }
void updateCoords(const Eref &e, const vector< double > &childConcs)
Definition: CylMesh.cpp:205
void getChildConcs(const Eref &e, vector< double > &childConcs) const
Definition: ChemCompt.cpp:264
double y0_
coords
Definition: CylMesh.h:168

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CylMesh::setY1 ( const Eref e,
double  v 
)

Definition at line 304 of file CylMesh.cpp.

References ChemCompt::getChildConcs(), updateCoords(), and y1_.

Referenced by initCinfo().

305 {
306  vector< double > childConcs;
307  getChildConcs( e, childConcs );
308  y1_ = v;
309  updateCoords( e, childConcs );
310 }
void updateCoords(const Eref &e, const vector< double > &childConcs)
Definition: CylMesh.cpp:205
double y1_
coords
Definition: CylMesh.h:172
void getChildConcs(const Eref &e, vector< double > &childConcs) const
Definition: ChemCompt.cpp:264

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CylMesh::setZ0 ( const Eref e,
double  v 
)

Definition at line 264 of file CylMesh.cpp.

References ChemCompt::getChildConcs(), updateCoords(), and z0_.

Referenced by initCinfo().

265 {
266  vector< double > childConcs;
267  getChildConcs( e, childConcs );
268  z0_ = v;
269  updateCoords( e, childConcs );
270 }
void updateCoords(const Eref &e, const vector< double > &childConcs)
Definition: CylMesh.cpp:205
double z0_
coords
Definition: CylMesh.h:169
void getChildConcs(const Eref &e, vector< double > &childConcs) const
Definition: ChemCompt.cpp:264

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CylMesh::setZ1 ( const Eref e,
double  v 
)

Definition at line 317 of file CylMesh.cpp.

References ChemCompt::getChildConcs(), updateCoords(), and z1_.

Referenced by initCinfo().

318 {
319  vector< double > childConcs;
320  getChildConcs( e, childConcs );
321  z1_ = v;
322  updateCoords( e, childConcs );
323 }
void updateCoords(const Eref &e, const vector< double > &childConcs)
Definition: CylMesh.cpp:205
void getChildConcs(const Eref &e, vector< double > &childConcs) const
Definition: ChemCompt.cpp:264
double z1_
coords
Definition: CylMesh.h:173

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CylMesh::transmitChange ( const Eref e)

Definition at line 741 of file CylMesh.cpp.

Referenced by setCoords().

742 {
743  /*
744  Id meshEntry( e.id().value() + 1 );
745  assert(
746  meshEntry.eref().data() == reinterpret_cast< char* >( lookupEntry( 0 ) )
747  );
748  double oldvol = getMeshEntryVolume( 0 );
749  unsigned int totalNumEntries = numEntries_;
750  unsigned int localNumEntries = totalNumEntries;
751  unsigned int startEntry = 0;
752  vector< unsigned int > localIndices( localNumEntries ); // empty
753  for ( unsigned int i = 0; i < localNumEntries; ++i )
754  localIndices[i] = i;
755  vector< double > vols( localNumEntries, volume_ / numEntries_ );
756  vector< vector< unsigned int > > outgoingEntries; // [node#][Entry#]
757  vector< vector< unsigned int > > incomingEntries; // [node#][Entry#]
758 
759  // This function updates the size of the FieldDataHandler for the
760  // MeshEntries.
761  DataHandler* dh = meshEntry.element()->dataHandler();
762  FieldDataHandlerBase* fdh = dynamic_cast< FieldDataHandlerBase* >( dh );
763  assert( fdh );
764  if ( totalNumEntries > fdh->getMaxFieldEntries() ) {
765  fdh->setMaxFieldEntries( localNumEntries );
766  }
767 
768  // This message tells the Stoich about the new mesh, and also about
769  // how it communicates with other nodes.
770  meshSplit()->fastSend( e,
771  oldvol,
772  vols, localIndices,
773  outgoingEntries, incomingEntries );
774 
775  // This func goes down to the MeshEntry to tell all the pools and
776  // Reacs to deal with the new mesh. They then update the stoich.
777  lookupEntry( 0 )->triggerRemesh( meshEntry.eref(),
778  oldvol, startEntry, localIndices, vols );
779  */
780 }

+ Here is the caller graph for this function:

void CylMesh::updateCoords ( const Eref e,
const vector< double > &  concs 
)

Recomputes all local coordinate and meshing data following a change in any of the coord parameters

This assumes that diffLength is the quantity to preserve, over numEntries. So when the compartment changes volume, numEntries changes. diffLength will be fine-tuned to be a clean multiple.

Definition at line 205 of file CylMesh.cpp.

References buildStencil(), diffLength_, doubleEq(), lenSlope_, numEntries_, r0_, r1_, rSlope_, ChemCompt::setChildConcs(), totLen_, x0_, x1_, y0_, y1_, z0_, and z1_.

Referenced by innerSetCoords(), setDiffLength(), setR0(), setR1(), setX0(), setX1(), setY0(), setY1(), setZ0(), and setZ1().

206 {
207  double temp = sqrt(
208  ( x1_ - x0_ ) * ( x1_ - x0_ ) +
209  ( y1_ - y0_ ) * ( y1_ - y0_ ) +
210  ( z1_ - z0_ ) * ( z1_ - z0_ )
211  );
212 
213  if ( doubleEq( temp, 0.0 ) ) {
214  cout << "Error: CylMesh::updateCoords:\n"
215  "total length of compartment = 0 with these parameters\n";
216  return;
217  }
218  totLen_ = temp;
219 
220 
221  temp = totLen_ / diffLength_;
222  if ( temp < 1.0 ) {
224  numEntries_ = 1;
225  } else {
226  numEntries_ = static_cast< unsigned int >( round ( temp ) );
228  }
229  rSlope_ = ( r1_ - r0_ ) / numEntries_;
230  lenSlope_ = diffLength_ * rSlope_ * 2 / ( r0_ + r1_ );
231 
232  // dx2_[0] = diffLength_;
233  // dx2_[1] = diffLength_;
234  buildStencil();
235  setChildConcs( e, concs, 0 );
236 }
unsigned int numEntries_
Definition: CylMesh.h:163
double x0_
Definition: CylMesh.h:167
double r1_
Radius at one end.
Definition: CylMesh.h:176
double y1_
coords
Definition: CylMesh.h:172
double z0_
coords
Definition: CylMesh.h:169
bool doubleEq(double x, double y)
Definition: doubleEq.cpp:16
double lenSlope_
Utility value: dr/dx.
Definition: CylMesh.h:189
double r0_
coords
Definition: CylMesh.h:175
void buildStencil()
Definition: CylMesh.cpp:785
double rSlope_
Utility value: Total length of cylinder.
Definition: CylMesh.h:188
unsigned int setChildConcs(const Eref &e, const vector< double > &childConcs, unsigned int start) const
Definition: ChemCompt.cpp:288
double totLen_
Definition: CylMesh.h:187
double x1_
coords
Definition: CylMesh.h:171
double z1_
coords
Definition: CylMesh.h:173
double diffLength_
Radius at other end.
Definition: CylMesh.h:178
double y0_
coords
Definition: CylMesh.h:168

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double CylMesh::vGetEntireVolume ( ) const
virtual

Inherited virtual. Returns entire volume of compartment.

Implements ChemCompt.

Definition at line 714 of file CylMesh.cpp.

References getMeshEntryVolume(), and numEntries_.

Referenced by innerHandleRequestMeshStats(), and vSetVolumeNotRates().

715 {
716  double vol = 0.0;
717  for ( unsigned int i = 0; i < numEntries_; ++i )
718  vol += getMeshEntryVolume( i );
719  return vol;
720 }
unsigned int numEntries_
Definition: CylMesh.h:163
double getMeshEntryVolume(unsigned int fid) const
Virtual function to return volume of mesh Entry.
Definition: CylMesh.cpp:477

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const vector< double > & CylMesh::vGetVoxelMidpoint ( ) const
virtual

Virtual func so that derived classes can return voxel midpoint.

Implements ChemCompt.

Definition at line 676 of file CylMesh.cpp.

References numEntries_, x0_, x1_, y0_, y1_, z0_, and z1_.

677 {
678  static vector< double > midpoint( numEntries_ * 3, 0.0 );
679  midpoint.resize( numEntries_ * 3 );
680  double dx = ( x1_ - x0_ ) / numEntries_;
681  double dy = ( y1_ - y0_ ) / numEntries_;
682  double dz = ( z1_ - z0_ ) / numEntries_;
683  vector< double >::iterator j = midpoint.begin();
684  for ( unsigned int i = 0; i < numEntries_; ++i )
685  *j++ = x0_ + dx * i;
686  for ( unsigned int i = 0; i < numEntries_; ++i )
687  *j++ = y0_ + dy * i;
688  for ( unsigned int i = 0; i < numEntries_; ++i )
689  *j++ = z0_ + dz * i;
690 
691  return midpoint;
692 }
unsigned int numEntries_
Definition: CylMesh.h:163
double x0_
Definition: CylMesh.h:167
double y1_
coords
Definition: CylMesh.h:172
double z0_
coords
Definition: CylMesh.h:169
double x1_
coords
Definition: CylMesh.h:171
double z1_
coords
Definition: CylMesh.h:173
double y0_
coords
Definition: CylMesh.h:168
const vector< double > & CylMesh::vGetVoxelVolume ( ) const
virtual

Virtual func so that derived classes can pass voxel volume back.

Implements ChemCompt.

Definition at line 667 of file CylMesh.cpp.

References getMeshEntryVolume(), and numEntries_.

668 {
669  static vector< double > vol;
670  vol.resize( numEntries_ );
671  for ( unsigned int i = 0; i < numEntries_; ++i )
672  vol[i] = getMeshEntryVolume( i );
673  return vol;
674 }
unsigned int numEntries_
Definition: CylMesh.h:163
double getMeshEntryVolume(unsigned int fid) const
Virtual function to return volume of mesh Entry.
Definition: CylMesh.cpp:477

+ Here is the call graph for this function:

bool CylMesh::vSetVolumeNotRates ( double  volume)
virtual

Inherited virtual. Resizes len and dia of each voxel.

Implements ChemCompt.

Definition at line 722 of file CylMesh.cpp.

References diffLength_, numEntries_, r0_, r1_, totLen_, vGetEntireVolume(), x1_, y1_, and z1_.

723 {
724  double oldVol = vGetEntireVolume();
725  double linScale = pow( volume/oldVol, 1.0 / 3.0 );
726  x1_ *= linScale;
727  y1_ *= linScale;
728  z1_ *= linScale;
729  r0_ *= linScale;
730  r1_ *= linScale;
731  totLen_ *= linScale;
732  // Have to scale this so numEntries remains the same.
734  return true;
735 }
unsigned int numEntries_
Definition: CylMesh.h:163
double r1_
Radius at one end.
Definition: CylMesh.h:176
double y1_
coords
Definition: CylMesh.h:172
double r0_
coords
Definition: CylMesh.h:175
double totLen_
Definition: CylMesh.h:187
double x1_
coords
Definition: CylMesh.h:171
double z1_
coords
Definition: CylMesh.h:173
double diffLength_
Radius at other end.
Definition: CylMesh.h:178
double vGetEntireVolume() const
Inherited virtual. Returns entire volume of compartment.
Definition: CylMesh.cpp:714

+ Here is the call graph for this function:

Member Data Documentation

bool CylMesh::isToroid_
private

Definition at line 165 of file CylMesh.h.

Referenced by buildStencil(), getDiffusionArea(), getDiffusionScaling(), and getMeshType().

double CylMesh::lenSlope_
private

Utility value: dr/dx.

Definition at line 189 of file CylMesh.h.

Referenced by getCoordinates(), innerSetNumEntries(), and updateCoords().

double CylMesh::rSlope_
private

Utility value: Total length of cylinder.

Definition at line 188 of file CylMesh.h.

Referenced by buildStencil(), getCoordinates(), getDiffusionArea(), innerSetNumEntries(), matchCubeMeshEntries(), nearest(), and updateCoords().

double CylMesh::surfaceGranularity_
private

Length constant for diffusion. Equal to dx.

surfaceGranularity_ decides how finely to subdivide DiffLength or cubic mesh side, when computing surface area of intersections between them when diffusing. Defaults to 0.1

Definition at line 185 of file CylMesh.h.

Referenced by selectGridVolume().

bool CylMesh::useCaps_
private

Definition at line 164 of file CylMesh.h.

Referenced by getMeshType().


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