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

#include <CubeMesh.h>

+ Inheritance diagram for CubeMesh:
+ Collaboration diagram for CubeMesh:

Public Member Functions

void addStoich (Id stoich)
 
void assignVoxels (vector< pair< unsigned int, unsigned int > > &intersect, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) const
 
void buildMesh (Id geom, double x, double y, double z)
 
void buildStencil ()
 
int compareMeshSpacing (const CubeMesh *other) const
 Return 0 if spacing same, -1 if self smaller, +1 if self bigger. More...
 
 CubeMesh ()
 
void defineIntersection (const CubeMesh *other, double &xmin, double &xmax, double &ymin, double &ymax, double &zmin, double &zmax) const
 Defines a cuboid volume of intersection between self and other. More...
 
void deriveM2sFromS2m ()
 
void deriveS2mFromM2s ()
 
double extendedMeshEntryVolume (unsigned int fid) const
 Virtual function to return volume of mesh Entry, including. More...
 
void fillSpaceToMeshLookup ()
 
void fillThreeDimSurface ()
 
void fillTwoDimSurface ()
 Fills surface_ vector with spatial meshIndices for a rectangle. More...
 
bool getAlwaysDiffuse () const
 
vector< double > getCoordinates (unsigned int fid) const
 Virtual function to return coords of mesh Entry. More...
 
vector< double > getCoords (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...
 
double getDx () const
 
double getDy () const
 
double getDz () const
 
bool getIsToroid () const
 
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...
 
vector< unsigned int > getMeshToSpace () const
 
unsigned int getMeshType (unsigned int fid) const
 Virtual function to return MeshType of specified entry. More...
 
unsigned int getNx () const
 
unsigned int getNy () const
 
unsigned int getNz () const
 
vector< unsigned int > getParentVoxel () const
 Inherited virtual, do nothing for now. More...
 
bool getPreserveNumEntries () const
 
vector< unsigned int > getSpaceToMesh () const
 
vector< unsigned int > getSurface () const
 
const vector< double > & getVoxelArea () const
 
const vector< double > & getVoxelLength () const
 
double getX0 () const
 
double getX1 () const
 
double getY0 () const
 
double getY1 () const
 
double getZ0 () const
 
double getZ1 () const
 
void indexToSpace (unsigned int index, double &x, double &y, double &z) const
 Converts the integer meshIndex to spatial coords. More...
 
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 vector< double > &v)
 
void innerSetNumEntries (unsigned int n)
 Inherited virtual func. More...
 
bool isInsideCuboid (double x, double y, double z) const
 
bool isInsideSpheroid (double x, double y, double z) const
 
void matchAllEntries (const CubeMesh *other, vector< VoxelJunction > &ret) const
 
void matchCubeMeshEntries (const CubeMesh *other, vector< VoxelJunction > &ret) const
 
void matchCylMeshEntries (const ChemCompt *other, vector< VoxelJunction > &ret) const
 
void matchMeshEntries (const ChemCompt *other, vector< VoxelJunction > &ret) const
 
double nearest (double x, double y, double z, unsigned int &index) const
 
unsigned int neighbor (unsigned int spaceIndex, int dx, int dy, int dz) const
 
unsigned int numDims () const
 Utility function for returning # of dimensions in mesh. More...
 
void setAlwaysDiffuse (bool v)
 
void setCoords (const Eref &e, vector< double > v)
 
void setDiffScale (const CubeMesh *other, vector< VoxelJunction > &ret) const
 Assigns diffusion scaling info for the voxel junctions. More...
 
void setDx (double v)
 
void setDy (double v)
 
void setDz (double v)
 
void setIsToroid (bool v)
 
void setJunctionVol (const CubeMesh *other, vector< VoxelJunction > &ret) const
 Assigns volume info for the voxel junctions. More...
 
void setMeshToSpace (vector< unsigned int > v)
 
void setNx (unsigned int v)
 
void setNy (unsigned int v)
 
void setNz (unsigned int v)
 
void setPreserveNumEntries (bool v)
 
void setSpaceToMesh (vector< unsigned int > v)
 
void setSurface (vector< unsigned int > v)
 
void setX0 (double v)
 
void setX1 (double v)
 
void setY0 (double v)
 
void setY1 (double v)
 
void setZ0 (double v)
 
void setZ1 (double v)
 
unsigned int spaceToIndex (double x, double y, double z) const
 Converts the 3-D coords to an index. EMPTY if out of range. More...
 
const vector< unsigned int > & surface () const
 Utility and test function to read surface. More...
 
void transmitChange (const Eref &e, double oldvol)
 
void updateCoords ()
 
void updateM2s ()
 
void updateS2m ()
 
double vGetEntireVolume () const
 Virtual func to get volume of entire 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)
 Virtual func, assigns volume, usually to single voxel. More...
 
 ~CubeMesh ()
 
- 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 ()
 

Static Public Attributes

static const unsigned int ABUTX = ~2
 
static const unsigned int ABUTY = ~3
 
static const unsigned int ABUTZ = ~4
 
static const unsigned int EMPTY = ~0
 
static const unsigned int MULTI = ~5
 
static const unsigned int SURFACE = ~1
 

Private Attributes

bool alwaysDiffuse_
 Flag: Should dx change or nx, with vol? More...
 
double dx_
 coords More...
 
double dy_
 Cuboid edge. More...
 
double dz_
 Cuboid edge. More...
 
bool isToroid_
 
vector< unsigned int > m2s_
 

of entries in z in surround volume

More...
 
unsigned int nx_
 Cuboid edge. More...
 
unsigned int ny_
 

of entries in x in surround volume

More...
 
unsigned int nz_
 

of entries in y in surround volume

More...
 
bool preserveNumEntries_
 Flag: Should the ends loop around mathemagically? More...
 
vector< unsigned int > s2m_
 
vector< unsigned int > surface_
 
double x0_
 Flag: should all voxels diffuse to any tgt? More...
 
double x1_
 coords More...
 
double y0_
 coords More...
 
double y1_
 coords More...
 
double z0_
 coords More...
 
double z1_
 coords More...
 

Detailed Description

The CubeMesh represents a chemically identified compartment shaped like a cuboid. This is not really an effective geometry for most neurons because it would have to be rather finely subdivided to fit a typical dendrite or soma volume, but it is general.

Definition at line 19 of file CubeMesh.h.

Constructor & Destructor Documentation

CubeMesh::CubeMesh ( )

Definition at line 261 of file CubeMesh.cpp.

References updateCoords().

262  :
263  isToroid_( 0 ),
264  preserveNumEntries_( 1 ),
265  alwaysDiffuse_( false ),
266  x0_( 0.0 ),
267  y0_( 0.0 ),
268  z0_( 0.0 ),
269  x1_( 10e-6 ),
270  y1_( 10e-6 ),
271  z1_( 10e-6 ),
272  dx_( 10e-6 ),
273  dy_( 10e-6 ),
274  dz_( 10e-6 ),
275  nx_( 1 ),
276  ny_( 1 ),
277  nz_( 1 ),
278  m2s_( 1, 0 ),
279  s2m_( 1, 0 )
280 {
281  updateCoords();
282 }
vector< unsigned int > m2s_
of entries in z in surround volume
Definition: CubeMesh.h:330
unsigned int nz_
of entries in y in surround volume
Definition: CubeMesh.h:313
void updateCoords()
Definition: CubeMesh.cpp:384
double x0_
Flag: should all voxels diffuse to any tgt?
Definition: CubeMesh.h:299
bool isToroid_
Definition: CubeMesh.h:295
double dx_
coords
Definition: CubeMesh.h:307
double y1_
coords
Definition: CubeMesh.h:304
bool alwaysDiffuse_
Flag: Should dx change or nx, with vol?
Definition: CubeMesh.h:297
double z1_
coords
Definition: CubeMesh.h:305
vector< unsigned int > s2m_
Definition: CubeMesh.h:339
unsigned int nx_
Cuboid edge.
Definition: CubeMesh.h:311
double dz_
Cuboid edge.
Definition: CubeMesh.h:309
bool preserveNumEntries_
Flag: Should the ends loop around mathemagically?
Definition: CubeMesh.h:296
unsigned int ny_
of entries in x in surround volume
Definition: CubeMesh.h:312
double x1_
coords
Definition: CubeMesh.h:303
double z0_
coords
Definition: CubeMesh.h:301
double dy_
Cuboid edge.
Definition: CubeMesh.h:308
double y0_
coords
Definition: CubeMesh.h:300

+ Here is the call graph for this function:

CubeMesh::~CubeMesh ( )

Definition at line 284 of file CubeMesh.cpp.

285 {
286  ;
287 }

Member Function Documentation

void CubeMesh::addStoich ( Id  stoich)
void CubeMesh::assignVoxels ( vector< pair< unsigned int, unsigned int > > &  intersect,
double  xmin,
double  xmax,
double  ymin,
double  ymax,
double  zmin,
double  zmax 
) const

Definition at line 1410 of file CubeMesh.cpp.

References dx_, dy_, dz_, indexToSpace(), nx_, ny_, nz_, s2m_, setIntersectVoxel(), surface_, x0_, y0_, and z0_.

Referenced by matchCubeMeshEntries().

1415 {
1416  unsigned int nx = 0.5 + ( xmax - xmin ) / dx_;
1417  unsigned int ny = 0.5 + ( ymax - ymin ) / dy_;
1418  unsigned int nz = 0.5 + ( zmax - zmin ) / dz_;
1419  // offset terms for nx, ny, nz from coord system for coarser grid.
1420  // Note that these can go negative if the intersect grid goes past
1421  // the coarse grid.
1422  int ox = round( ( xmin - x0_ ) / dx_ );
1423  int oy = round( ( ymin - y0_ ) / dy_ );
1424  int oz = round( ( zmin - z0_ ) / dz_ );
1425 
1426  // Scan through mesh surface using coarser grid, assign cuboid voxels
1427  for ( vector< unsigned int >::const_iterator i = surface_.begin();
1428  i != surface_.end(); ++i ) {
1429  unsigned int index = *i;
1430  double x, y, z;
1431  indexToSpace( index, x, y, z );
1432  if ( x >= xmin && x <= xmax && y >= ymin && y <= ymax &&
1433  z >= zmin && z <= zmax ) {
1434  int ix = index % nx_ - ox;
1435  assert( ix >= 0 );
1436  unsigned int uix = ix;
1437  index /= nx_;
1438  int iy = index % ny_ - oy;
1439  assert( iy >= 0 );
1440  unsigned int uiy = iy;
1441  index /= ny_;
1442  int iz = index % nz_ - oz;
1443  assert( iz >= 0 );
1444  unsigned int uiz = iz;
1445  unsigned int meshIndex = s2m_[ *i ];
1446 
1447  setIntersectVoxel( intersect, uix, uiy, uiz, nx, ny, nz,
1448  meshIndex );
1449  }
1450  }
1451 }
vector< unsigned int > surface_
Definition: CubeMesh.h:345
unsigned int nz_
of entries in y in surround volume
Definition: CubeMesh.h:313
void setIntersectVoxel(vector< PII > &intersect, unsigned int ix, unsigned int iy, unsigned int iz, unsigned int nx, unsigned int ny, unsigned int nz, unsigned int meshIndex)
Definition: CubeMesh.cpp:1304
double x0_
Flag: should all voxels diffuse to any tgt?
Definition: CubeMesh.h:299
double dx_
coords
Definition: CubeMesh.h:307
vector< unsigned int > s2m_
Definition: CubeMesh.h:339
unsigned int nx_
Cuboid edge.
Definition: CubeMesh.h:311
void indexToSpace(unsigned int index, double &x, double &y, double &z) const
Converts the integer meshIndex to spatial coords.
Definition: CubeMesh.cpp:1154
double dz_
Cuboid edge.
Definition: CubeMesh.h:309
unsigned int ny_
of entries in x in surround volume
Definition: CubeMesh.h:312
double z0_
coords
Definition: CubeMesh.h:301
double dy_
Cuboid edge.
Definition: CubeMesh.h:308
double y0_
coords
Definition: CubeMesh.h:300

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CubeMesh::buildMesh ( Id  geom,
double  x,
double  y,
double  z 
)

Definition at line 697 of file CubeMesh.cpp.

Referenced by initCinfo().

698 {
699  ;
700 }

+ Here is the caller graph for this function:

void CubeMesh::buildStencil ( )

Sets up the stencil that defines how to combine neighboring mesh elements to set up the diffusion du/dt term, using the method of lines. This is a very general function. It uses the information in the m2s_ and s2m_ vectors to work out the adjacency matrix. So we could use an arbitrary 3-D image to define the diffusive volume and boundaries using m2s_ and s2m_. We could also use geometric shapes through the fillSpaceToMeshLookup() function, which is currently a dummy and just does a cuboid.

Definition at line 1060 of file CubeMesh.cpp.

References MeshCompt::addRow(), dx_, dy_, dz_, EMPTY, MeshCompt::innerResetStencil(), m2s_, nx_, ny_, nz_, s2m_, and MeshCompt::setStencilSize().

Referenced by deriveM2sFromS2m(), deriveS2mFromM2s(), and updateCoords().

1061 {
1062  static const unsigned int flag = EMPTY;
1063 
1064 
1065  // fillSpaceToMeshLookup();
1066  unsigned int num = m2s_.size();
1067  setStencilSize( num, num );
1068  for ( unsigned int i = 0; i < num; ++i ) {
1069  unsigned int q = m2s_[i];
1070  unsigned int ix = q % nx_;
1071  unsigned int iy = ( q / nx_ ) % ny_;
1072  unsigned int iz = ( q / ( nx_ * ny_ ) ) % nz_;
1073  vector< double > entry;
1074  vector< unsigned int > colIndex;
1075  vector< Ecol > e;
1076 
1077  if ( ix > 0 && s2m_[q-1] != flag ) {
1078  e.push_back( Ecol( dy_ * dz_ / dx_, s2m_[q-1] ) );
1079  }
1080  if ( ( ix < nx_ - 1 ) && s2m_[q+1] != flag ) {
1081  e.push_back( Ecol( dy_ * dz_ / dx_, s2m_[q+1] ) );
1082  }
1083  if ( iy > 0 && s2m_[ q-nx_ ] != flag ) {
1084  assert( q >= nx_ );
1085  e.push_back( Ecol( dx_ * dz_ / dy_, s2m_[q-nx_] ) );
1086  }
1087  if ( iy < ny_ - 1 && s2m_[ q+nx_ ] != flag ) {
1088  assert( q+nx_ < s2m_.size() );
1089  e.push_back( Ecol( dx_ * dz_ / dy_, s2m_[q+nx_] ) );
1090  }
1091  if ( iz > 0 && s2m_[ q - nx_*ny_ ] != flag ) {
1092  assert( q >= nx_ * ny_ );
1093  e.push_back( Ecol( dx_ * dy_ / dz_, s2m_[q - nx_ * ny_] ) );
1094  }
1095  if ( iz < nz_ - 1 && s2m_[ q + nx_*ny_ ] ) {
1096  assert( q+nx_ < s2m_.size() );
1097  e.push_back( Ecol( dx_ * dy_ / dz_, s2m_[q + nx_ * ny_] ) );
1098  }
1099  sort( e.begin(), e.end() );
1100  for ( vector< Ecol >::iterator j = e.begin(); j != e.end(); ++j ) {
1101  entry.push_back( j->e_ );
1102  colIndex.push_back( j->col_ );
1103  }
1104  addRow( i, entry, colIndex );
1105  }
1107 }
vector< unsigned int > m2s_
of entries in z in surround volume
Definition: CubeMesh.h:330
void innerResetStencil()
virtual func implemented here.
Definition: MeshCompt.cpp:49
unsigned int nz_
of entries in y in surround volume
Definition: CubeMesh.h:313
void addRow(unsigned int index, const vector< double > &entry, const vector< unsigned int > &colIndex)
Definition: MeshCompt.cpp:98
double dx_
coords
Definition: CubeMesh.h:307
vector< unsigned int > s2m_
Definition: CubeMesh.h:339
unsigned int nx_
Cuboid edge.
Definition: CubeMesh.h:311
double dz_
Cuboid edge.
Definition: CubeMesh.h:309
unsigned int ny_
of entries in x in surround volume
Definition: CubeMesh.h:312
static const unsigned int EMPTY
Definition: CubeMesh.h:285
void setStencilSize(unsigned int numRows, unsigned int numCols)
Definition: MeshCompt.cpp:106
double dy_
Cuboid edge.
Definition: CubeMesh.h:308
Definition: MeshCompt.h:89

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int CubeMesh::compareMeshSpacing ( const CubeMesh other) const

Return 0 if spacing same, -1 if self smaller, +1 if self bigger.

Definition at line 1222 of file CubeMesh.cpp.

References doubleApprox(), dx_, dy_, and dz_.

Referenced by matchCubeMeshEntries().

1223 {
1224  if ( doubleApprox( dx_, other->dx_ ) &&
1225  doubleApprox( dy_, other->dy_ ) &&
1226  doubleApprox( dz_, other->dz_ ) )
1227  return 0; // equal
1228 
1229  if ( dx_ >= other->dx_ &&
1230  dy_ >= other->dy_ &&
1231  dz_ >= other->dz_ )
1232  return 1; // bigger
1233 
1234  if ( dx_ <= other->dx_ &&
1235  dy_ <= other->dy_ &&
1236  dz_ <= other->dz_ )
1237  return -1; // smaller than other.
1238 
1239 
1240  cout << "Warning: CubeMesh::compareMeshSpacing: inconsistent spacing\n";
1241  return 0;
1242 }
bool doubleApprox(double x, double y)
Definition: doubleEq.cpp:24
double dx_
coords
Definition: CubeMesh.h:307
double dz_
Cuboid edge.
Definition: CubeMesh.h:309
double dy_
Cuboid edge.
Definition: CubeMesh.h:308

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CubeMesh::defineIntersection ( const CubeMesh other,
double &  xmin,
double &  xmax,
double &  ymin,
double &  ymax,
double &  zmin,
double &  zmax 
) const

Defines a cuboid volume of intersection between self and other.

Definition at line 1244 of file CubeMesh.cpp.

References dx_, dy_, dz_, swapIfBackward(), x0_, x1_, y0_, y1_, z0_, and z1_.

Referenced by matchCubeMeshEntries().

1249 {
1250  const double meshSlop = 0.2;
1251  xmin = ( x0_ > other->x0_ ) ? x0_ : other->x0_;
1252  xmax = ( x1_ < other->x1_ ) ? x1_ : other->x1_;
1253  ymin = ( y0_ > other->y0_ ) ? y0_ : other->y0_;
1254  ymax = ( y1_ < other->y1_ ) ? y1_ : other->y1_;
1255  zmin = ( z0_ > other->z0_ ) ? z0_ : other->z0_;
1256  zmax = ( z1_ < other->z1_ ) ? z1_ : other->z1_;
1257  // Align to coarser mesh
1258  double temp = ( xmin - x0_) / dx_;
1259  if ( temp - floor( temp ) > meshSlop )
1260  xmin = floor( temp ) * dx_;
1261  temp = ( ymin - y0_) / dy_;
1262  if ( temp - floor( temp ) > meshSlop )
1263  ymin = floor( temp ) * dy_;
1264  temp = ( zmin - z0_) / dz_;
1265  if ( temp - floor( temp ) > meshSlop )
1266  zmin = floor( temp ) * dz_;
1267 
1268  // Provide 1 voxel padding all around.
1269  xmin -= dx_;
1270  xmax += dx_;
1271  ymin -= dy_;
1272  ymax += dy_;
1273  zmin -= dz_;
1274  zmax += dz_;
1275  swapIfBackward( xmin, xmax );
1276  swapIfBackward( ymin, ymax );
1277  swapIfBackward( zmin, zmax );
1278 }
double x0_
Flag: should all voxels diffuse to any tgt?
Definition: CubeMesh.h:299
double dx_
coords
Definition: CubeMesh.h:307
double y1_
coords
Definition: CubeMesh.h:304
double z1_
coords
Definition: CubeMesh.h:305
double dz_
Cuboid edge.
Definition: CubeMesh.h:309
double x1_
coords
Definition: CubeMesh.h:303
void swapIfBackward(double &x0, double &x1)
Definition: CubeMesh.cpp:294
double z0_
coords
Definition: CubeMesh.h:301
double dy_
Cuboid edge.
Definition: CubeMesh.h:308
double y0_
coords
Definition: CubeMesh.h:300

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CubeMesh::deriveM2sFromS2m ( )

Updates the m2s_ vector after s2m_ has been changed, and rebuilds the Stencil too. Any earlier junction information is lost.

Definition at line 1033 of file CubeMesh.cpp.

References buildStencil(), EMPTY, m2s_, nx_, ny_, nz_, and s2m_.

Referenced by setSpaceToMesh().

1034 {
1035  m2s_.clear();
1036  assert( s2m_.size() == nx_ * ny_ * nz_ );
1037  for ( unsigned int i = 0; i < s2m_.size(); ++i ) {
1038  if ( s2m_[i] != EMPTY ) {
1039  m2s_.push_back( i );
1040  assert( m2s_.size() == s2m_[i] + 1 );
1041  }
1042  }
1043  buildStencil();
1044 }
vector< unsigned int > m2s_
of entries in z in surround volume
Definition: CubeMesh.h:330
unsigned int nz_
of entries in y in surround volume
Definition: CubeMesh.h:313
void buildStencil()
Definition: CubeMesh.cpp:1060
vector< unsigned int > s2m_
Definition: CubeMesh.h:339
unsigned int nx_
Cuboid edge.
Definition: CubeMesh.h:311
unsigned int ny_
of entries in x in surround volume
Definition: CubeMesh.h:312
static const unsigned int EMPTY
Definition: CubeMesh.h:285

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CubeMesh::deriveS2mFromM2s ( )

Updates the s2m_ vector after m2s_ has been changed, and rebuilds the Stencil too. Any earlier junction information is lost.

Definition at line 1046 of file CubeMesh.cpp.

References buildStencil(), EMPTY, m2s_, nx_, ny_, nz_, and s2m_.

Referenced by setMeshToSpace().

1047 {
1048  s2m_.clear();
1049  s2m_.resize( nx_ * ny_ * nz_, EMPTY );
1050  for ( unsigned int i = 0; i < m2s_.size(); ++i ) {
1051  s2m_[ m2s_[i] ] = i;
1052  }
1053  buildStencil();
1054 }
vector< unsigned int > m2s_
of entries in z in surround volume
Definition: CubeMesh.h:330
unsigned int nz_
of entries in y in surround volume
Definition: CubeMesh.h:313
void buildStencil()
Definition: CubeMesh.cpp:1060
vector< unsigned int > s2m_
Definition: CubeMesh.h:339
unsigned int nx_
Cuboid edge.
Definition: CubeMesh.h:311
unsigned int ny_
of entries in x in surround volume
Definition: CubeMesh.h:312
static const unsigned int EMPTY
Definition: CubeMesh.h:285

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Virtual function to return volume of mesh Entry, including.

Utility function to return volume of any voxel including those diffusively coupled and aubtting the present volume.

Implements ChemCompt.

Definition at line 791 of file CubeMesh.cpp.

References dx_, dy_, dz_, MeshCompt::extendedMeshEntryVolume(), and m2s_.

792 {
793  if ( fid >= m2s_.size() ) {
794  return MeshCompt::extendedMeshEntryVolume( fid - m2s_.size() );
795  }
796  return dx_ * dy_ * dz_;
797 }
vector< unsigned int > m2s_
of entries in z in surround volume
Definition: CubeMesh.h:330
double extendedMeshEntryVolume(unsigned int fid) const
Virtual function to return volume of mesh Entry, including.
Definition: MeshCompt.cpp:36
double dx_
coords
Definition: CubeMesh.h:307
double dz_
Cuboid edge.
Definition: CubeMesh.h:309
double dy_
Cuboid edge.
Definition: CubeMesh.h:308

+ Here is the call graph for this function:

void CubeMesh::fillSpaceToMeshLookup ( )

Definition at line 1005 of file CubeMesh.cpp.

References dx_, dy_, dz_, EMPTY, isInsideCuboid(), m2s_, nx_, ny_, nz_, s2m_, x0_, y0_, and z0_.

1006 {
1007  static const unsigned int flag = EMPTY;
1008  unsigned int num = 0;
1009  unsigned int q = 0;
1010  m2s_.clear();
1011  s2m_.resize( nx_ * ny_ * nz_, flag );
1012  for( unsigned int k = 0; k < nz_; ++k ) {
1013  double z = k * dz_ + z0_;
1014  for( unsigned int j = 0; j < ny_; ++j ) {
1015  double y = j * dy_ + y0_;
1016  for( unsigned int i = 0; i < nx_; ++i ) {
1017  double x = i * dx_ + x0_;
1018  if ( isInsideCuboid( x, y, z ) ) {
1019  s2m_[q] = num;
1020  m2s_.push_back( q );
1021  ++num;
1022  } else {
1023  s2m_[q] = flag;
1024  }
1025  ++q;
1026  }
1027  }
1028  }
1029  assert( m2s_.size() == num );
1030 }
vector< unsigned int > m2s_
of entries in z in surround volume
Definition: CubeMesh.h:330
unsigned int nz_
of entries in y in surround volume
Definition: CubeMesh.h:313
double x0_
Flag: should all voxels diffuse to any tgt?
Definition: CubeMesh.h:299
bool isInsideCuboid(double x, double y, double z) const
Definition: CubeMesh.cpp:986
double dx_
coords
Definition: CubeMesh.h:307
vector< unsigned int > s2m_
Definition: CubeMesh.h:339
unsigned int nx_
Cuboid edge.
Definition: CubeMesh.h:311
double dz_
Cuboid edge.
Definition: CubeMesh.h:309
unsigned int ny_
of entries in x in surround volume
Definition: CubeMesh.h:312
static const unsigned int EMPTY
Definition: CubeMesh.h:285
double z0_
coords
Definition: CubeMesh.h:301
double dy_
Cuboid edge.
Definition: CubeMesh.h:308
double y0_
coords
Definition: CubeMesh.h:300

+ Here is the call graph for this function:

void CubeMesh::fillThreeDimSurface ( )

Fills surface_ vector with spatial meshIndices for a cuboid, that is, puts the surfaces of the cuboid in the vector.

Definition at line 340 of file CubeMesh.cpp.

References nx_, ny_, nz_, and surface_.

Referenced by updateCoords().

341 {
342  unsigned int size = nx_ * ny_ * nz_;
343  // z == 0 plane
344  for ( unsigned int j = 0; j < ny_; ++j )
345  for ( unsigned int k = 0; k < nx_; ++k )
346  surface_.push_back( j * nx_ + k );
347  // z == nz_-1 plane
348  unsigned int offset = size - nx_ * ny_;
349  for ( unsigned int j = 0; j < ny_; ++j )
350  for ( unsigned int k = 0; k < nx_; ++k )
351  surface_.push_back( offset + j * nx_ + k );
352 
353  // y == 0 plane
354  for ( unsigned int i = 0; i < nz_; ++i )
355  for ( unsigned int k = 0; k < nx_; ++k )
356  surface_.push_back( i * nx_ * ny_ + k );
357  // y == ny_-1 plane
358  offset = nx_ * ( ny_ - 1 );
359  for ( unsigned int i = 0; i < nz_; ++i )
360  for ( unsigned int k = 0; k < nx_; ++k )
361  surface_.push_back( offset + i * nx_ * ny_ + k );
362 
363  // x == 0 plane
364  for ( unsigned int i = 0; i < nz_; ++i )
365  for ( unsigned int j = 0; j < ny_; ++j )
366  surface_.push_back( ( i * ny_ + j ) * nx_ );
367  // x == nx_-1 plane
368  offset = nx_ - 1;
369  for ( unsigned int i = 0; i < nz_; ++i )
370  for ( unsigned int j = 0; j < ny_; ++j )
371  surface_.push_back( offset + ( i * ny_ + j ) * nx_ );
372 
373  sort( surface_.begin(), surface_.end() );
374  surface_.erase( unique( surface_.begin(), surface_.end() ),
375  surface_.end() );
376 }
vector< unsigned int > surface_
Definition: CubeMesh.h:345
unsigned int nz_
of entries in y in surround volume
Definition: CubeMesh.h:313
unsigned int nx_
Cuboid edge.
Definition: CubeMesh.h:311
unsigned int ny_
of entries in x in surround volume
Definition: CubeMesh.h:312

+ Here is the caller graph for this function:

void CubeMesh::fillTwoDimSurface ( )

Fills surface_ vector with spatial meshIndices for a rectangle.

Definition at line 303 of file CubeMesh.cpp.

References nx_, ny_, nz_, and surface_.

304 {
305  unsigned int size = nx_ * ny_ * nz_;
306  if ( nx_ == 1 ) {
307  for ( unsigned int j = 0; j < ny_; ++j )
308  surface_.push_back( j );
309  for ( unsigned int j = size - ny_; j < size; ++j )
310  surface_.push_back( j );
311  for ( unsigned int i = 1; i < nz_ - 1; ++i )
312  surface_.push_back( i * ny_ );
313  for ( unsigned int i = 1; i < nz_ - 1; ++i )
314  surface_.push_back( ny_ - 1 + i * ny_ );
315  } else if ( ny_ == 1 ) {
316  for ( unsigned int k = 0; k < nx_; ++k )
317  surface_.push_back( k );
318  for ( unsigned int k = size - nx_; k < size; ++k )
319  surface_.push_back( k );
320  for ( unsigned int i = 1; i < nz_ - 1; ++i )
321  surface_.push_back( i * nx_ );
322  for ( unsigned int i = 1; i < nz_ - 1; ++i )
323  surface_.push_back( nx_ - 1 + i * nx_ );
324  } else if ( nz_ == 1 ) {
325  for ( unsigned int k = 0; k < nx_; ++k )
326  surface_.push_back( k );
327  for ( unsigned int k = size - nx_; k < size; ++k )
328  surface_.push_back( k );
329  for ( unsigned int j = 1; j < ny_ - 1; ++j )
330  surface_.push_back( j * nx_ );
331  for ( unsigned int j = 1; j < ny_ - 1; ++j )
332  surface_.push_back( j * nx_ + nx_ - 1 );
333  }
334  // Ah, C++ STL. Look on my works, ye mighty, and despair.
335  sort( surface_.begin(), surface_.end() );
336  surface_.erase( unique( surface_.begin(), surface_.end() ),
337  surface_.end() );
338 }
vector< unsigned int > surface_
Definition: CubeMesh.h:345
unsigned int nz_
of entries in y in surround volume
Definition: CubeMesh.h:313
unsigned int nx_
Cuboid edge.
Definition: CubeMesh.h:311
unsigned int ny_
of entries in x in surround volume
Definition: CubeMesh.h:312
bool CubeMesh::getAlwaysDiffuse ( ) const

Definition at line 596 of file CubeMesh.cpp.

References alwaysDiffuse_.

Referenced by initCinfo().

597 {
598  // alwaysDiffuse is normally false.
599  return alwaysDiffuse_;
600 }
bool alwaysDiffuse_
Flag: Should dx change or nx, with vol?
Definition: CubeMesh.h:297

+ Here is the caller graph for this function:

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

Virtual function to return coords of mesh Entry.

Virtual function to return coords of mesh Entry. For Cuboid mesh, coords are x1y1z1 x2y2z2

Implements ChemCompt.

Definition at line 801 of file CubeMesh.cpp.

References dx_, dy_, dz_, m2s_, nx_, ny_, nz_, x0_, y0_, and z0_.

802 {
803  assert( fid < m2s_.size() );
804  unsigned int spaceIndex = m2s_[fid];
805 
806  unsigned int ix = spaceIndex % nx_;
807  unsigned int iy = (spaceIndex / nx_) % ny_;
808  unsigned int iz = (spaceIndex / ( nx_ * ny_ )) % nz_;
809 
810  vector< double > ret( 6 );
811  ret[0] = x0_ + ix * dx_;
812  ret[1] = y0_ + iy * dy_;
813  ret[2] = z0_ + iz * dz_;
814 
815  ret[3] = x0_ + ix * dx_ + dx_;
816  ret[4] = y0_ + iy * dy_ + dx_;
817  ret[5] = z0_ + iz * dz_ + dx_;
818 
819  return ret;
820 }
vector< unsigned int > m2s_
of entries in z in surround volume
Definition: CubeMesh.h:330
unsigned int nz_
of entries in y in surround volume
Definition: CubeMesh.h:313
double x0_
Flag: should all voxels diffuse to any tgt?
Definition: CubeMesh.h:299
double dx_
coords
Definition: CubeMesh.h:307
unsigned int nx_
Cuboid edge.
Definition: CubeMesh.h:311
double dz_
Cuboid edge.
Definition: CubeMesh.h:309
unsigned int ny_
of entries in x in surround volume
Definition: CubeMesh.h:312
double z0_
coords
Definition: CubeMesh.h:301
double dy_
Cuboid edge.
Definition: CubeMesh.h:308
double y0_
coords
Definition: CubeMesh.h:300
vector< double > CubeMesh::getCoords ( const Eref e) const

Definition at line 636 of file CubeMesh.cpp.

References dx_, dy_, dz_, x0_, x1_, y0_, y1_, z0_, and z1_.

Referenced by initCinfo(), and testCubeMesh().

637 {
638  vector< double > ret( 9 );
639 
640  ret[0] = x0_;
641  ret[1] = y0_;
642  ret[2] = z0_;
643 
644  ret[3] = x1_;
645  ret[4] = y1_;
646  ret[5] = z1_;
647 
648  ret[6] = dx_;
649  ret[7] = dy_;
650  ret[8] = dz_;
651 
652  return ret;
653 }
double x0_
Flag: should all voxels diffuse to any tgt?
Definition: CubeMesh.h:299
double dx_
coords
Definition: CubeMesh.h:307
double y1_
coords
Definition: CubeMesh.h:304
double z1_
coords
Definition: CubeMesh.h:305
double dz_
Cuboid edge.
Definition: CubeMesh.h:309
double x1_
coords
Definition: CubeMesh.h:303
double z0_
coords
Definition: CubeMesh.h:301
double dy_
Cuboid edge.
Definition: CubeMesh.h:308
double y0_
coords
Definition: CubeMesh.h:300

+ Here is the caller graph for this function:

vector< double > CubeMesh::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 846 of file CubeMesh.cpp.

References dx_, dy_, dz_, EMPTY, m2s_, and neighbor().

847 {
848  assert( fid < m2s_.size() );
849 
850  vector< double > ret;
851  unsigned int spaceIndex = m2s_[fid];
852 
853  unsigned int nIndex = neighbor( spaceIndex, 0, 0, 1 );
854  if ( nIndex != EMPTY )
855  ret.push_back( dx_ * dy_ );
856 
857  nIndex = neighbor( spaceIndex, 0, 0, -1 );
858  if ( nIndex != EMPTY )
859  ret.push_back( dx_ * dy_ );
860 
861  nIndex = neighbor( spaceIndex, 0, 1, 0 );
862  if ( nIndex != EMPTY )
863  ret.push_back( dz_ * dx_ );
864 
865  nIndex = neighbor( spaceIndex, 0, -1, 0 );
866  if ( nIndex != EMPTY )
867  ret.push_back( dz_ * dx_ );
868 
869  nIndex = neighbor( spaceIndex, 1, 0, 0 );
870  if ( nIndex != EMPTY )
871  ret.push_back( dy_ * dz_ );
872 
873  nIndex = neighbor( spaceIndex, -1, 0, 0 );
874  if ( nIndex != EMPTY )
875  ret.push_back( dy_ * dz_ );
876 
877  return ret;
878 }
vector< unsigned int > m2s_
of entries in z in surround volume
Definition: CubeMesh.h:330
unsigned int neighbor(unsigned int spaceIndex, int dx, int dy, int dz) const
Definition: CubeMesh.cpp:822
double dx_
coords
Definition: CubeMesh.h:307
double dz_
Cuboid edge.
Definition: CubeMesh.h:309
static const unsigned int EMPTY
Definition: CubeMesh.h:285
double dy_
Cuboid edge.
Definition: CubeMesh.h:308

+ Here is the call graph for this function:

vector< double > CubeMesh::getDiffusionScaling ( unsigned int  fid) const
virtual

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

Implements ChemCompt.

Definition at line 881 of file CubeMesh.cpp.

882 {
883  return vector< double >( 6, 1.0 );
884 }
double CubeMesh::getDx ( ) const

Definition at line 507 of file CubeMesh.cpp.

References dx_.

Referenced by initCinfo(), CylBase::matchCubeMeshEntries(), CylMesh::matchCubeMeshEntries(), and testCubeMesh().

508 {
509  return dx_;
510 }
double dx_
coords
Definition: CubeMesh.h:307

+ Here is the caller graph for this function:

double CubeMesh::getDy ( ) const

Definition at line 519 of file CubeMesh.cpp.

References dy_.

Referenced by initCinfo(), and testCubeMesh().

520 {
521  return dy_;
522 }
double dy_
Cuboid edge.
Definition: CubeMesh.h:308

+ Here is the caller graph for this function:

double CubeMesh::getDz ( ) const

Definition at line 531 of file CubeMesh.cpp.

References dz_.

Referenced by initCinfo(), and testCubeMesh().

532 {
533  return dz_;
534 }
double dz_
Cuboid edge.
Definition: CubeMesh.h:309

+ Here is the caller graph for this function:

bool CubeMesh::getIsToroid ( ) const

Definition at line 576 of file CubeMesh.cpp.

References isToroid_.

Referenced by initCinfo().

577 {
578  return isToroid_;
579 }
bool isToroid_
Definition: CubeMesh.h:295

+ Here is the caller graph for this function:

unsigned int CubeMesh::getMeshDimensions ( unsigned int  fid) const
virtual

Virtual function to return dimensions of specified entry.

Implements ChemCompt.

Definition at line 778 of file CubeMesh.cpp.

Referenced by testCubeMesh(), and testCubeMeshExtendStencil().

779 {
780  return 3;
781 }

+ Here is the caller graph for this function:

double CubeMesh::getMeshEntryVolume ( unsigned int  fid) const
virtual

Virtual function to return volume of mesh Entry.

Implements ChemCompt.

Definition at line 784 of file CubeMesh.cpp.

References dx_, dy_, and dz_.

785 {
786  return dx_ * dy_ * dz_;
787 }
double dx_
coords
Definition: CubeMesh.h:307
double dz_
Cuboid edge.
Definition: CubeMesh.h:309
double dy_
Cuboid edge.
Definition: CubeMesh.h:308
vector< unsigned int > CubeMesh::getMeshToSpace ( ) const

Definition at line 661 of file CubeMesh.cpp.

References m2s_.

Referenced by initCinfo(), and testCubeMeshJunctionTwoDimSurface().

662 {
663  return m2s_;
664 }
vector< unsigned int > m2s_
of entries in z in surround volume
Definition: CubeMesh.h:330

+ Here is the caller graph for this function:

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

Virtual function to return MeshType of specified entry.

Implements ChemCompt.

Definition at line 772 of file CubeMesh.cpp.

References CUBOID.

Referenced by testCubeMesh(), and testCubeMeshExtendStencil().

773 {
774  return CUBOID;
775 }

+ Here is the caller graph for this function:

unsigned int CubeMesh::getNx ( ) const

Definition at line 542 of file CubeMesh.cpp.

References nx_.

Referenced by initCinfo(), and testCubeMesh().

543 {
544  return nx_;
545 }
unsigned int nx_
Cuboid edge.
Definition: CubeMesh.h:311

+ Here is the caller graph for this function:

unsigned int CubeMesh::getNy ( ) const

Definition at line 554 of file CubeMesh.cpp.

References ny_.

Referenced by initCinfo(), and testCubeMesh().

555 {
556  return ny_;
557 }
unsigned int ny_
of entries in x in surround volume
Definition: CubeMesh.h:312

+ Here is the caller graph for this function:

unsigned int CubeMesh::getNz ( ) const

Definition at line 565 of file CubeMesh.cpp.

References nz_.

Referenced by initCinfo(), and testCubeMesh().

566 {
567  return nz_;
568 }
unsigned int nz_
of entries in y in surround volume
Definition: CubeMesh.h:313

+ Here is the caller graph for this function:

vector< unsigned int > CubeMesh::getParentVoxel ( ) const
virtual

Inherited virtual, do nothing for now.

Implements MeshCompt.

Definition at line 905 of file CubeMesh.cpp.

References innerGetNumEntries(), and numEntries.

906 {
907  unsigned int numEntries = innerGetNumEntries();
908  vector< unsigned int > ret( numEntries );
909  if ( numEntries > 0 )
910  ret[0] = static_cast< unsigned int >( -1 );
911  for (unsigned int i = 1; i < numEntries; ++i )
912  ret[i] = i-1;
913 
914  return ret;
915 }
const int numEntries
Definition: proc.cpp:60
unsigned int innerGetNumEntries() const
Definition: CubeMesh.cpp:891

+ Here is the call graph for this function:

bool CubeMesh::getPreserveNumEntries ( ) const

Definition at line 586 of file CubeMesh.cpp.

References preserveNumEntries_.

Referenced by initCinfo().

587 {
588  return preserveNumEntries_;
589 }
bool preserveNumEntries_
Flag: Should the ends loop around mathemagically?
Definition: CubeMesh.h:296

+ Here is the caller graph for this function:

vector< unsigned int > CubeMesh::getSpaceToMesh ( ) const

Definition at line 672 of file CubeMesh.cpp.

References s2m_.

Referenced by initCinfo(), and testCubeMeshJunctionTwoDimSurface().

673 {
674  return s2m_;
675 }
vector< unsigned int > s2m_
Definition: CubeMesh.h:339

+ Here is the caller graph for this function:

vector< unsigned int > CubeMesh::getSurface ( ) const

Definition at line 682 of file CubeMesh.cpp.

References surface_.

Referenced by initCinfo().

683 {
684  return surface_;
685 }
vector< unsigned int > surface_
Definition: CubeMesh.h:345

+ Here is the caller graph for this function:

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

Implements MeshCompt.

Definition at line 942 of file CubeMesh.cpp.

References dx_, dy_, dz_, nx_, ny_, and nz_.

943 {
944  static vector< double > area;
945  if ( nx_ * ny_ == 1 )
946  area.resize( nz_, dx_ * dy_ );
947  else if ( nx_ * nz_ == 1 )
948  area.resize( ny_, dx_ * dz_ );
949  else if ( ny_ * nz_ == 1 )
950  area.resize( nx_, dy_ * dz_ );
951  else
952  area.resize( nx_, dy_ * dz_ ); // Just put in a number.
953  assert( area.size() == nx_ * ny_ * nz_ );
954  return area;
955 }
unsigned int nz_
of entries in y in surround volume
Definition: CubeMesh.h:313
double dx_
coords
Definition: CubeMesh.h:307
unsigned int nx_
Cuboid edge.
Definition: CubeMesh.h:311
double dz_
Cuboid edge.
Definition: CubeMesh.h:309
unsigned int ny_
of entries in x in surround volume
Definition: CubeMesh.h:312
double dy_
Cuboid edge.
Definition: CubeMesh.h:308
const vector< double > & CubeMesh::getVoxelLength ( ) const
virtual

Implements MeshCompt.

Definition at line 957 of file CubeMesh.cpp.

References dx_, dy_, dz_, and innerGetNumEntries().

958 {
959  static vector< double > length;
960  if ( dx_ > dy_ && dx_ > dz_ )
961  length.assign( innerGetNumEntries(), dx_ );
962  else if ( dy_ > dz_ )
963  length.assign( innerGetNumEntries(), dy_ );
964  else
965  length.assign( innerGetNumEntries(), dz_ );
966  return length;
967 }
double dx_
coords
Definition: CubeMesh.h:307
double dz_
Cuboid edge.
Definition: CubeMesh.h:309
double dy_
Cuboid edge.
Definition: CubeMesh.h:308
unsigned int innerGetNumEntries() const
Definition: CubeMesh.cpp:891

+ Here is the call graph for this function:

double CubeMesh::getX0 ( ) const

Definition at line 441 of file CubeMesh.cpp.

References x0_.

Referenced by initCinfo(), and testCubeMesh().

442 {
443  return x0_;
444 }
double x0_
Flag: should all voxels diffuse to any tgt?
Definition: CubeMesh.h:299

+ Here is the caller graph for this function:

double CubeMesh::getX1 ( ) const

Definition at line 474 of file CubeMesh.cpp.

References x1_.

Referenced by initCinfo(), and testCubeMesh().

475 {
476  return x1_;
477 }
double x1_
coords
Definition: CubeMesh.h:303

+ Here is the caller graph for this function:

double CubeMesh::getY0 ( ) const

Definition at line 452 of file CubeMesh.cpp.

References y0_.

Referenced by initCinfo(), and testCubeMesh().

453 {
454  return y0_;
455 }
double y0_
coords
Definition: CubeMesh.h:300

+ Here is the caller graph for this function:

double CubeMesh::getY1 ( ) const

Definition at line 485 of file CubeMesh.cpp.

References y1_.

Referenced by initCinfo(), and testCubeMesh().

486 {
487  return y1_;
488 }
double y1_
coords
Definition: CubeMesh.h:304

+ Here is the caller graph for this function:

double CubeMesh::getZ0 ( ) const

Definition at line 463 of file CubeMesh.cpp.

References z0_.

Referenced by initCinfo(), and testCubeMesh().

464 {
465  return z0_;
466 }
double z0_
coords
Definition: CubeMesh.h:301

+ Here is the caller graph for this function:

double CubeMesh::getZ1 ( ) const

Definition at line 496 of file CubeMesh.cpp.

References z1_.

Referenced by initCinfo(), and testCubeMesh().

497 {
498  return z1_;
499 }
double z1_
coords
Definition: CubeMesh.h:305

+ Here is the caller graph for this function:

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

Converts the integer meshIndex to spatial coords.

Implements ChemCompt.

Definition at line 1154 of file CubeMesh.cpp.

References dx_, dy_, dz_, nx_, ny_, nz_, x0_, y0_, and z0_.

Referenced by assignVoxels(), matchCubeMeshEntries(), and nearest().

1156 {
1157  assert ( index < nx_ * ny_ * nz_ );
1158 
1159  // index = m2s_[index];
1160  unsigned int ix = index % nx_;
1161  index /= nx_;
1162  unsigned int iy = index % ny_;
1163  index /= ny_;
1164  unsigned int iz = index % nz_;
1165 
1166  x = x0_ + ix * dx_ + dx_ * 0.5;
1167  y = y0_ + iy * dy_ + dy_ * 0.5;
1168  z = z0_ + iz * dz_ + dz_ * 0.5;
1169 }
unsigned int nz_
of entries in y in surround volume
Definition: CubeMesh.h:313
double x0_
Flag: should all voxels diffuse to any tgt?
Definition: CubeMesh.h:299
double dx_
coords
Definition: CubeMesh.h:307
unsigned int nx_
Cuboid edge.
Definition: CubeMesh.h:311
double dz_
Cuboid edge.
Definition: CubeMesh.h:309
unsigned int ny_
of entries in x in surround volume
Definition: CubeMesh.h:312
double z0_
coords
Definition: CubeMesh.h:301
double dy_
Cuboid edge.
Definition: CubeMesh.h:308
double y0_
coords
Definition: CubeMesh.h:300

+ Here is the caller graph for this function:

const Cinfo * CubeMesh::initCinfo ( )
static

Definition at line 31 of file CubeMesh.cpp.

References buildMesh(), cubeMeshCinfo, getAlwaysDiffuse(), getCoords(), getDx(), getDy(), getDz(), getIsToroid(), getMeshToSpace(), getNx(), getNy(), getNz(), getPreserveNumEntries(), getSpaceToMesh(), getSurface(), getX0(), getX1(), getY0(), getY1(), getZ0(), getZ1(), ChemCompt::initCinfo(), setAlwaysDiffuse(), setCoords(), setDx(), setDy(), setDz(), setIsToroid(), setMeshToSpace(), setNx(), setNy(), setNz(), setPreserveNumEntries(), setSpaceToMesh(), setSurface(), setX0(), setX1(), setY0(), setY1(), setZ0(), setZ1(), and surface().

32 {
34  // Field Definitions
37  "x0",
38  "X coord of one end",
41  );
43  "y0",
44  "Y coord of one end",
47  );
49  "z0",
50  "Z coord of one end",
53  );
55  "x1",
56  "X coord of other end",
59  );
61  "y1",
62  "Y coord of other end",
65  );
67  "z1",
68  "Z coord of other end",
71  );
72 
74  "dx",
75  "X size for mesh",
78  );
80  "dy",
81  "Y size for mesh",
84  );
86  "dz",
87  "Z size for mesh",
90  );
91 
93  "nx",
94  "Number of subdivisions in mesh in X",
97  );
99  "ny",
100  "Number of subdivisions in mesh in Y",
103  );
105  "nz",
106  "Number of subdivisions in mesh in Z",
109  );
110 
111  static ValueFinfo< CubeMesh, bool > isToroid(
112  "isToroid",
113  "Flag. True when the mesh should be toroidal, that is,"
114  "when going beyond the right face brings us around to the"
115  "left-most mesh entry, and so on. If we have nx, ny, nz"
116  "entries, this rule means that the coordinate (x, ny, z)"
117  "will map onto (x, 0, z). Similarly,"
118  "(-1, y, z) -> (nx-1, y, z)"
119  "Default is false",
122  );
123 
124  static ValueFinfo< CubeMesh, bool > preserveNumEntries(
125  "preserveNumEntries",
126  "Flag. When it is true, the numbers nx, ny, nz remain"
127  "unchanged when x0, x1, y0, y1, z0, z1 are altered. Thus"
128  "dx, dy, dz would change instead. When it is false, then"
129  "dx, dy, dz remain the same and nx, ny, nz are altered."
130  "Default is true",
133  );
134 
135  static ValueFinfo< CubeMesh, bool > alwaysDiffuse(
136  "alwaysDiffuse",
137  "Flag. When it is true, the mesh matches up sequential "
138  "mesh entries for diffusion and chmestry. This is regardless "
139  "of spatial location, and is guaranteed to set up at least "
140  "the home reaction system"
141  "Default is false",
144  );
145 
147  "coords",
148  "Set all the coords of the cuboid at once. Order is:"
149  "x0 y0 z0 x1 y1 z1 dx dy dz"
150  "When this is done, it recalculates the numEntries since "
151  "dx, dy and dz are given explicitly."
152  "As a special hack, you can leave out dx, dy and dz and use "
153  "a vector of size 6. In this case the operation assumes that "
154  "nx, ny and nz are to be preserved and dx, dy and dz will "
155  "be recalculated. ",
158  );
159 
161  "meshToSpace",
162  "Array in which each mesh entry stores spatial (cubic) index",
165  );
166 
168  "spaceToMesh",
169  "Array in which each space index (obtained by linearizing "
170  "the xyz coords) specifies which meshIndex is present."
171  "In many cases the index will store the EMPTY flag if there is"
172  "no mesh entry at that spatial location",
175  );
176 
178  "surface",
179  "Array specifying surface of arbitrary volume within the "
180  "CubeMesh. All entries must fall within the cuboid. "
181  "Each entry of the array is a spatial index obtained by "
182  "linearizing the ix, iy, iz coordinates within the cuboid. "
183  "So, each entry == ( iz * ny + iy ) * nx + ix"
184  "Note that the voxels listed on the surface are WITHIN the "
185  "volume of the CubeMesh object",
188  );
189 
191  // MsgDest Definitions
193 
194  static DestFinfo buildMesh( "buildMesh",
195  "Build cubical mesh for geom surface specified by Id, using"
196  "specified x y z coords as an inside point in mesh",
199  );
200 
202  // Field Elements
204 
205  static Finfo* cubeMeshFinfos[] = {
206  &isToroid, // Value
207  &preserveNumEntries, // Value
208  &alwaysDiffuse, // Value
209  &x0, // Value
210  &y0, // Value
211  &z0, // Value
212  &x1, // Value
213  &y1, // Value
214  &z1, // Value
215  &dx, // Value
216  &dy, // Value
217  &dz, // Value
218  &nx, // Value
219  &ny, // Value
220  &nz, // Value
221  &coords, // Value
222  &meshToSpace, // Value
223  &spaceToMesh, // Value
224  &surface, // Value
225  };
226 
227  static string doc[] =
228  {
229  "Name", "CubeMesh",
230  "Author", "Upi Bhalla",
231  "Description", "Chemical compartment with cuboid grid. "
232  "Defaults to a cube of size 10 microns, with mesh size "
233  "also 10 microns, so that there is just 1 cubic voxel. "
234  "These defaults are similar to that of a typical cell. "
235  "Can be configured to have different x,y,z dimensions and "
236  "also different dx,dy,dz voxel sizes. ",
237  };
238  static Dinfo< CubeMesh > dinfo;
239  static Cinfo cubeMeshCinfo (
240  "CubeMesh",
242  cubeMeshFinfos,
243  sizeof( cubeMeshFinfos ) / sizeof ( Finfo* ),
244  &dinfo,
245  doc,
246  sizeof(doc)/sizeof(string)
247  );
248 
249  return &cubeMeshCinfo;
250 }
static const Cinfo * initCinfo()
Definition: ChemCompt.cpp:25
void setDz(double v)
Definition: CubeMesh.cpp:525
vector< unsigned int > getSurface() const
Definition: CubeMesh.cpp:682
unsigned int getNx() const
Definition: CubeMesh.cpp:542
unsigned int getNz() const
Definition: CubeMesh.cpp:565
double getDz() const
Definition: CubeMesh.cpp:531
static const Cinfo * cubeMeshCinfo
Definition: CubeMesh.cpp:256
Definition: Dinfo.h:60
double getX0() const
Definition: CubeMesh.cpp:441
void setX1(double v)
Definition: CubeMesh.cpp:468
void setCoords(const Eref &e, vector< double > v)
Definition: CubeMesh.cpp:629
vector< double > getCoords(const Eref &e) const
Definition: CubeMesh.cpp:636
double getX1() const
Definition: CubeMesh.cpp:474
double getDx() const
Definition: CubeMesh.cpp:507
void setY0(double v)
Definition: CubeMesh.cpp:446
void setZ0(double v)
Definition: CubeMesh.cpp:457
double getY1() const
Definition: CubeMesh.cpp:485
void setZ1(double v)
Definition: CubeMesh.cpp:490
unsigned int getNy() const
Definition: CubeMesh.cpp:554
double getZ0() const
Definition: CubeMesh.cpp:463
const vector< unsigned int > & surface() const
Utility and test function to read surface.
Definition: CubeMesh.cpp:1111
void setSpaceToMesh(vector< unsigned int > v)
Definition: CubeMesh.cpp:666
void setIsToroid(bool v)
Definition: CubeMesh.cpp:571
void setNx(unsigned int v)
Definition: CubeMesh.cpp:536
vector< unsigned int > getMeshToSpace() const
Definition: CubeMesh.cpp:661
double getY0() const
Definition: CubeMesh.cpp:452
void setAlwaysDiffuse(bool v)
Definition: CubeMesh.cpp:591
void setMeshToSpace(vector< unsigned int > v)
Definition: CubeMesh.cpp:655
vector< unsigned int > getSpaceToMesh() const
Definition: CubeMesh.cpp:672
bool getIsToroid() const
Definition: CubeMesh.cpp:576
void setNz(unsigned int v)
Definition: CubeMesh.cpp:559
void setY1(double v)
Definition: CubeMesh.cpp:479
double getZ1() const
Definition: CubeMesh.cpp:496
void setDy(double v)
Definition: CubeMesh.cpp:513
void setNy(unsigned int v)
Definition: CubeMesh.cpp:548
void setPreserveNumEntries(bool v)
Definition: CubeMesh.cpp:581
bool getAlwaysDiffuse() const
Definition: CubeMesh.cpp:596
void setSurface(vector< unsigned int > v)
Definition: CubeMesh.cpp:677
void buildMesh(Id geom, double x, double y, double z)
Definition: CubeMesh.cpp:697
double getDy() const
Definition: CubeMesh.cpp:519
Definition: Cinfo.h:18
void setX0(double v)
Definition: CubeMesh.cpp:435
void setDx(double v)
Definition: CubeMesh.cpp:501
bool getPreserveNumEntries() const
Definition: CubeMesh.cpp:586
Definition: OpFunc.h:70
Definition: Finfo.h:12

+ Here is the call graph for this function:

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

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

Builds something as close to a cube as can get. This needs a smarter boundary handling code than I have here. For now, goes for the nearest cube

Implements ChemCompt.

Definition at line 707 of file CubeMesh.cpp.

References numEntries, nx_, ny_, nz_, and setCoords().

709 {
710  double approxN = numEntries;
711  approxN = pow( approxN, 1.0 / 3.0 );
712  unsigned int smaller = floor( approxN );
713  unsigned int bigger = ceil( approxN );
714  unsigned int numSide;
715  if ( smaller != bigger ) {
716  numSide = smaller;
717  } else {
718  unsigned int smallerVol = smaller * smaller * smaller;
719  unsigned int biggerVol = bigger * bigger * bigger;
720  if ( numEntries - smallerVol < biggerVol - numEntries )
721  numSide = smaller;
722  else
723  numSide = bigger;
724  }
725  double side = pow( volume, 1.0 / 3.0 );
726  vector< double > coords( 9, side );
727  coords[0] = coords[1] = coords[2] = 0;
728  coords[6] = coords[7] = coords[8] = side / numSide;
729  nx_ = ny_ = nz_ = numSide;
730  setCoords( e, coords );
731 }
unsigned int nz_
of entries in y in surround volume
Definition: CubeMesh.h:313
void setCoords(const Eref &e, vector< double > v)
Definition: CubeMesh.cpp:629
const int numEntries
Definition: proc.cpp:60
unsigned int nx_
Cuboid edge.
Definition: CubeMesh.h:311
unsigned int ny_
of entries in x in surround volume
Definition: CubeMesh.h:312

+ Here is the call graph for this function:

unsigned int CubeMesh::innerGetDimensions ( ) const
virtual

Implements ChemCompt.

Definition at line 687 of file CubeMesh.cpp.

688 {
689  return 3;
690 }
unsigned int CubeMesh::innerGetNumEntries ( ) const
virtual

Inherited virtual func. Returns number of MeshEntry in array

Implements ChemCompt.

Definition at line 891 of file CubeMesh.cpp.

References m2s_.

Referenced by getParentVoxel(), getVoxelLength(), and testCubeMesh().

892 {
893  return m2s_.size();
894 }
vector< unsigned int > m2s_
of entries in z in surround volume
Definition: CubeMesh.h:330

+ Here is the caller graph for this function:

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

Generate node decomposition of mesh, send it out along meshSplitFinfo msg

Implements ChemCompt.

Definition at line 743 of file CubeMesh.cpp.

746 {
747  /*
748  unsigned int numEntries = nx_ * ny_ * nz_ ;
749  vector< double > vols( numEntries, dx_ * dy_ * dz_ );
750  vector< unsigned int > localEntries( numEntries );
751  vector< vector< unsigned int > > outgoingEntries;
752  vector< vector< unsigned int > > incomingEntries;
753  double oldvol = getMeshEntryVolume( 0 );
754  meshSplit()->send( e,
755  oldvol,
756  vols, localEntries,
757  outgoingEntries, incomingEntries );
758  */
759 }
void CubeMesh::innerHandleRequestMeshStats ( const Eref e,
const SrcFinfo2< unsigned int, vector< double > > *  meshStatsFinfo 
)

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

Definition at line 734 of file CubeMesh.cpp.

References dx_, dy_, dz_, nx_, ny_, and nz_.

736 {
737  vector< double > meshVolumes( 1, dx_ * dy_ * dz_ );
738  meshStatsFinfo->send( e, nx_ * ny_ * nz_, meshVolumes);
739 }
unsigned int nz_
of entries in y in surround volume
Definition: CubeMesh.h:313
double dx_
coords
Definition: CubeMesh.h:307
void send(const Eref &e, const T1 &arg1, const T2 &arg2) const
Definition: SrcFinfo.h:228
unsigned int nx_
Cuboid edge.
Definition: CubeMesh.h:311
double dz_
Cuboid edge.
Definition: CubeMesh.h:309
unsigned int ny_
of entries in x in surround volume
Definition: CubeMesh.h:312
double dy_
Cuboid edge.
Definition: CubeMesh.h:308
void CubeMesh::innerSetCoords ( const vector< double > &  v)

Definition at line 602 of file CubeMesh.cpp.

References dx_, dy_, dz_, preserveNumEntries_, updateCoords(), x0_, x1_, y0_, y1_, z0_, and z1_.

Referenced by setCoords(), testCubeMesh(), testCubeMeshExtendStencil(), testCubeMeshFillTwoDimSurface(), testCubeMeshJunctionDiffSizeMesh(), testCubeMeshJunctionTwoDimSurface(), and testCubeMeshMultiJunctionTwoD().

603 {
604  if ( v.size() < 6 )
605  return;
606 
607  x0_ = v[0];
608  y0_ = v[1];
609  z0_ = v[2];
610 
611  x1_ = v[3];
612  y1_ = v[4];
613  z1_ = v[5];
614 
615  bool temp = preserveNumEntries_;
616  if ( v.size() >= 9 ) {
617  dx_ = v[6];
618  dy_ = v[7];
619  dz_ = v[8];
621  } else {
623  }
624  updateCoords();
625  preserveNumEntries_ = temp;
626 
627 }
void updateCoords()
Definition: CubeMesh.cpp:384
double x0_
Flag: should all voxels diffuse to any tgt?
Definition: CubeMesh.h:299
double dx_
coords
Definition: CubeMesh.h:307
double y1_
coords
Definition: CubeMesh.h:304
double z1_
coords
Definition: CubeMesh.h:305
double dz_
Cuboid edge.
Definition: CubeMesh.h:309
bool preserveNumEntries_
Flag: Should the ends loop around mathemagically?
Definition: CubeMesh.h:296
double x1_
coords
Definition: CubeMesh.h:303
double z0_
coords
Definition: CubeMesh.h:301
double dy_
Cuboid edge.
Definition: CubeMesh.h:308
double y0_
coords
Definition: CubeMesh.h:300

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CubeMesh::innerSetNumEntries ( unsigned int  n)
virtual

Inherited virtual func.

Inherited virtual func. Assigns number of MeshEntries.

Implements ChemCompt.

Definition at line 899 of file CubeMesh.cpp.

900 {
901  cout << "Warning: CubeMesh::innerSetNumEntries is readonly.\n";
902 }
bool CubeMesh::isInsideCuboid ( double  x,
double  y,
double  z 
) const

Definition at line 986 of file CubeMesh.cpp.

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

Referenced by fillSpaceToMeshLookup().

987 {
988  return ( x >= x0_ && x < x1_ && y >= y0_ && y < y1_ &&
989  z >= z0_ && z < z1_ );
990 }
double x0_
Flag: should all voxels diffuse to any tgt?
Definition: CubeMesh.h:299
double y1_
coords
Definition: CubeMesh.h:304
double z1_
coords
Definition: CubeMesh.h:305
double z0_
coords
Definition: CubeMesh.h:301
double y0_
coords
Definition: CubeMesh.h:300

+ Here is the caller graph for this function:

bool CubeMesh::isInsideSpheroid ( double  x,
double  y,
double  z 
) const

Definition at line 992 of file CubeMesh.cpp.

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

993 {
994  double cx = ( x0_ + x1_ ) / 2.0;
995  double cy = ( y0_ + y1_ ) / 2.0;
996  double cz = ( z0_ + z1_ ) / 2.0;
997 
998  double rx = ( x - cx ) / fabs( x1_ - x0_ ) / 2.0;
999  double ry = ( y - cy ) / fabs( y1_ - y0_ ) / 2.0;
1000  double rz = ( z - cz ) / fabs( z1_ - z0_ ) / 2.0;
1001 
1002  return ( ( rx * rx + ry * ry + rz * rz ) < 1.0 );
1003 }
double x0_
Flag: should all voxels diffuse to any tgt?
Definition: CubeMesh.h:299
double y1_
coords
Definition: CubeMesh.h:304
double z1_
coords
Definition: CubeMesh.h:305
double x1_
coords
Definition: CubeMesh.h:303
double z0_
coords
Definition: CubeMesh.h:301
double y0_
coords
Definition: CubeMesh.h:300
void CubeMesh::matchAllEntries ( const CubeMesh other,
vector< VoxelJunction > &  ret 
) const

Dumbed-down version that does mesh matching based only on index. Useful for non-spatial matching and single-voxel systems.

Version that assumes all voxels are in contact and able to diffuse with matching voxels on other mesh

Definition at line 1503 of file CubeMesh.cpp.

References m2s_.

Referenced by matchMeshEntries().

1505 {
1506  ret.clear();
1507  unsigned int min = m2s_.size();
1508  if ( min > other->m2s_.size() )
1509  min = other->m2s_.size();
1510  ret.resize( min );
1511  for ( unsigned int i = 0; i < min; ++i ) {
1512  ret[i] = VoxelJunction( i, i );
1513  }
1514 }
vector< unsigned int > m2s_
of entries in z in surround volume
Definition: CubeMesh.h:330

+ Here is the caller graph for this function:

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

Specialization for cube-to-cube mesh matching. Return vector is of pairs of meshIndices (not spatialIndices).

Definition at line 1453 of file CubeMesh.cpp.

References assignVoxels(), checkAbut(), compareMeshSpacing(), defineIntersection(), dx_, dy_, dz_, EMPTY, ChemCompt::flipRet(), indexToSpace(), matchMeshEntries(), s2m_, setDiffScale(), setJunctionVol(), and surface_.

Referenced by matchMeshEntries(), testCubeMeshJunctionDiffSizeMesh(), and testCubeMeshJunctionTwoDimSurface().

1455 {
1456  // Flip meshes if the current grid is finer.
1457  // There are still problems here because a finer grid will end
1458  // up with 2 levels deep defined as being abutting.
1459  if ( compareMeshSpacing( other ) == -1 ) {
1460  other->matchMeshEntries( this, ret );
1461  flipRet( ret );
1462  return;
1463  }
1464  ret.resize( 0 );
1465  // Define intersecting cuboid
1466  double xmin, xmax, ymin, ymax, zmin, zmax;
1467  defineIntersection( other, xmin, xmax, ymin, ymax, zmin, zmax );
1468 
1469  // Allocate intersecting cuboid
1470  unsigned int nx = 0.5 + ( xmax - xmin ) / dx_;
1471  unsigned int ny = 0.5 + ( ymax - ymin ) / dy_;
1472  unsigned int nz = 0.5 + ( zmax - zmin ) / dz_;
1473  vector< PII > intersect( nx * ny * nz, PII( EMPTY, EMPTY ) );
1474  assignVoxels( intersect, xmin, xmax, ymin, ymax, zmin, zmax );
1475 
1476  // Scan through finer mesh surface, check for occupied voxels.
1477  for ( vector< unsigned int >::const_iterator i =
1478  other->surface_.begin();
1479  i != other->surface_.end(); ++i ) {
1480  double x, y, z;
1481  other->indexToSpace( *i, x, y, z );
1482  if ( x >= xmin && x <= xmax && y >= ymin && y <= ymax &&
1483  z >= zmin && z <= zmax ) {
1484  unsigned int ix = ( x - xmin ) / dx_;
1485  unsigned int iy = ( y - ymin ) / dy_;
1486  unsigned int iz = ( z - zmin ) / dz_;
1487  unsigned int meshIndex = other->s2m_[ *i ];
1488  checkAbut( intersect, ix, iy, iz, nx, ny, nz, meshIndex, ret );
1489  }
1490  }
1491 
1492  // Scan through the VoxelJunctions and populate their diffScale field
1493  setDiffScale( other, ret );
1494  // Scan through the VoxelJunctions and populate their volume field
1495  setJunctionVol( other, ret );
1496  sort( ret.begin(), ret.end() );
1497 }
vector< unsigned int > surface_
Definition: CubeMesh.h:345
void assignVoxels(vector< pair< unsigned int, unsigned int > > &intersect, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) const
Definition: CubeMesh.cpp:1410
int compareMeshSpacing(const CubeMesh *other) const
Return 0 if spacing same, -1 if self smaller, +1 if self bigger.
Definition: CubeMesh.cpp:1222
pair< unsigned int, unsigned int > PII
Definition: CubeMesh.cpp:29
double dx_
coords
Definition: CubeMesh.h:307
void matchMeshEntries(const ChemCompt *other, vector< VoxelJunction > &ret) const
Definition: CubeMesh.cpp:1118
void defineIntersection(const CubeMesh *other, double &xmin, double &xmax, double &ymin, double &ymax, double &zmin, double &zmax) const
Defines a cuboid volume of intersection between self and other.
Definition: CubeMesh.cpp:1244
vector< unsigned int > s2m_
Definition: CubeMesh.h:339
void setJunctionVol(const CubeMesh *other, vector< VoxelJunction > &ret) const
Assigns volume info for the voxel junctions.
Definition: CubeMesh.cpp:1557
void setDiffScale(const CubeMesh *other, vector< VoxelJunction > &ret) const
Assigns diffusion scaling info for the voxel junctions.
Definition: CubeMesh.cpp:1523
void indexToSpace(unsigned int index, double &x, double &y, double &z) const
Converts the integer meshIndex to spatial coords.
Definition: CubeMesh.cpp:1154
double dz_
Cuboid edge.
Definition: CubeMesh.h:309
void checkAbut(const vector< PII > &intersect, unsigned int ix, unsigned int iy, unsigned int iz, unsigned int nx, unsigned int ny, unsigned int nz, unsigned int meshIndex, vector< VoxelJunction > &ret)
Definition: CubeMesh.cpp:1348
static const unsigned int EMPTY
Definition: CubeMesh.h:285
void flipRet(vector< VoxelJunction > &ret) const
Utility function for swapping first and second in VoxelJunctions.
Definition: ChemCompt.cpp:406
double dy_
Cuboid edge.
Definition: CubeMesh.h:308

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1516 of file CubeMesh.cpp.

References ChemCompt::flipRet(), and ChemCompt::matchMeshEntries().

1518 {
1519  other->matchMeshEntries( this, ret );
1520  flipRet( ret );
1521 }
virtual void matchMeshEntries(const ChemCompt *other, vector< VoxelJunction > &ret) const =0
void flipRet(vector< VoxelJunction > &ret) const
Utility function for swapping first and second in VoxelJunctions.
Definition: ChemCompt.cpp:406

+ Here is the call graph for this function:

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

Key virtual function for generating a map between facing surfaces on a CubeMesh and another ChemCompt

Implements ChemCompt.

Definition at line 1118 of file CubeMesh.cpp.

References alwaysDiffuse_, ChemCompt::flipRet(), matchAllEntries(), matchCubeMeshEntries(), and EndoMesh::matchMeshEntries().

Referenced by matchCubeMeshEntries().

1120 {
1121  const CubeMesh* cm = dynamic_cast< const CubeMesh* >( other );
1122 
1123  if ( cm ) {
1124  if ( alwaysDiffuse_ )
1125  matchAllEntries( cm, ret );
1126  else
1127  matchCubeMeshEntries( cm, ret );
1128  /*
1129  if ( compareMeshSpacing( cm ) == 0 ) { // Equal spacing.
1130  matchSameSpacing( cm, ret );
1131  } else if ( compareMeshSpacing( cm ) == -1 ) { // self is finer
1132  cout << "Warning:CubeMesh::matchMeshEntries: cannot yet handle unequal meshes\n";
1133  } else { // other is finer.
1134  cout << "Warning:CubeMesh::matchMeshEntries: cannot yet handle unequal meshes\n";
1135  }
1136  */
1137  return;
1138  }
1139  const EndoMesh* em = dynamic_cast< const EndoMesh* >( other );
1140  if ( em ) {
1141  em->matchMeshEntries( this, ret );
1142  flipRet( ret );
1143  return;
1144  }
1145  cout << "Warning:CubeMesh::matchMeshEntries: cannot yet handle Neuro or Cyl meshes.\n";
1146 }
void matchCubeMeshEntries(const CubeMesh *other, vector< VoxelJunction > &ret) const
Definition: CubeMesh.cpp:1453
bool alwaysDiffuse_
Flag: Should dx change or nx, with vol?
Definition: CubeMesh.h:297
void matchAllEntries(const CubeMesh *other, vector< VoxelJunction > &ret) const
Definition: CubeMesh.cpp:1503
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:

+ Here is the caller graph for this function:

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

Virtual function to return the distance and index of nearest meshEntry. Places entry at centre of voxel.

Implements ChemCompt.

Definition at line 1185 of file CubeMesh.cpp.

References ChemCompt::distance(), dx_, dy_, dz_, EMPTY, indexToSpace(), nx_, ny_, s2m_, surface_, x0_, y0_, z0_, and z1_.

1187 {
1188  if ( x > x0_ && x < x1_ && y > y0_ && y < y1_ && z > z0_ && z < z1_ )
1189  {
1190  unsigned int ix = ( x - x0_ ) / dx_;
1191  unsigned int iy = ( y - y0_ ) / dy_;
1192  unsigned int iz = ( z - z0_ ) / dz_;
1193  index = ( iz * ny_ + iy ) * nx_ + ix;
1194  unsigned int innerIndex = s2m_[ index ];
1195  if ( innerIndex != EMPTY ) { // Inside filled volume
1196  index = innerIndex;
1197  double tx = x0_ + ix * dx_ + dx_ * 0.5;
1198  double ty = y0_ + iy * dy_ + dy_ * 0.5;
1199  double tz = z0_ + iz * dz_ + dz_ * 0.5;
1200  return distance( x - tx, y - ty, z - tz );
1201  } else { // Outside volume. Look over surface for nearest.
1202  double rmin = 1e99;
1203  for ( vector< unsigned int >::const_iterator
1204  i = surface_.begin(); i != surface_.end(); ++i )
1205  {
1206  double tx, ty, tz;
1207  indexToSpace( *i, tx, ty, tz );
1208  double r = distance( tx - x, ty - y, tz - z );
1209  if ( rmin > r ) {
1210  rmin = r;
1211  index = *i;
1212  }
1213  }
1214  return -rmin; // Negative distance indicates xyz is outside vol
1215  }
1216  }
1217  // Should really figure out nearest corner anyway.
1218  index = 0;
1219  return -1.0;
1220 }
vector< unsigned int > surface_
Definition: CubeMesh.h:345
double x0_
Flag: should all voxels diffuse to any tgt?
Definition: CubeMesh.h:299
double dx_
coords
Definition: CubeMesh.h:307
static double distance(double x, double y, double z)
Definition: ChemCompt.cpp:422
double z1_
coords
Definition: CubeMesh.h:305
vector< unsigned int > s2m_
Definition: CubeMesh.h:339
unsigned int nx_
Cuboid edge.
Definition: CubeMesh.h:311
void indexToSpace(unsigned int index, double &x, double &y, double &z) const
Converts the integer meshIndex to spatial coords.
Definition: CubeMesh.cpp:1154
double dz_
Cuboid edge.
Definition: CubeMesh.h:309
unsigned int ny_
of entries in x in surround volume
Definition: CubeMesh.h:312
static const unsigned int EMPTY
Definition: CubeMesh.h:285
double z0_
coords
Definition: CubeMesh.h:301
double dy_
Cuboid edge.
Definition: CubeMesh.h:308
double y0_
coords
Definition: CubeMesh.h:300

+ Here is the call graph for this function:

unsigned int CubeMesh::neighbor ( unsigned int  spaceIndex,
int  dx,
int  dy,
int  dz 
) const

Definition at line 822 of file CubeMesh.cpp.

References EMPTY, nx_, ny_, nz_, and s2m_.

Referenced by getDiffusionArea().

824 {
825  int ix = spaceIndex % nx_;
826  int iy = (spaceIndex / nx_) % ny_;
827  int iz = (spaceIndex / ( nx_ * ny_ )) % nz_;
828 
829  ix += dx;
830  iy += dy;
831  iz += dz;
832 
833  if ( ix < 0 || ix >= static_cast< int >( nx_ ) )
834  return EMPTY;
835  if ( iy < 0 || iy >= static_cast< int >( ny_ ) )
836  return EMPTY;
837  if ( iz < 0 || iz >= static_cast< int >( nz_ ) )
838  return EMPTY;
839 
840  unsigned int nIndex = ( ( iz * ny_ ) + iy ) * nx_ + ix;
841 
842  return s2m_[nIndex];
843 }
unsigned int nz_
of entries in y in surround volume
Definition: CubeMesh.h:313
vector< unsigned int > s2m_
Definition: CubeMesh.h:339
unsigned int nx_
Cuboid edge.
Definition: CubeMesh.h:311
unsigned int ny_
of entries in x in surround volume
Definition: CubeMesh.h:312
static const unsigned int EMPTY
Definition: CubeMesh.h:285

+ Here is the caller graph for this function:

unsigned int CubeMesh::numDims ( ) const

Utility function for returning # of dimensions in mesh.

Definition at line 1148 of file CubeMesh.cpp.

References nx_, ny_, and nz_.

Referenced by testCubeMeshFillTwoDimSurface().

1149 {
1150  return ( ( nx_ > 1 ) + ( ny_ > 1 ) + ( nz_ > 1 ) );
1151 }
unsigned int nz_
of entries in y in surround volume
Definition: CubeMesh.h:313
unsigned int nx_
Cuboid edge.
Definition: CubeMesh.h:311
unsigned int ny_
of entries in x in surround volume
Definition: CubeMesh.h:312

+ Here is the caller graph for this function:

void CubeMesh::setAlwaysDiffuse ( bool  v)

Definition at line 591 of file CubeMesh.cpp.

References alwaysDiffuse_.

Referenced by initCinfo().

592 {
593  alwaysDiffuse_ = v;
594 }
bool alwaysDiffuse_
Flag: Should dx change or nx, with vol?
Definition: CubeMesh.h:297

+ Here is the caller graph for this function:

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

Definition at line 629 of file CubeMesh.cpp.

References innerSetCoords(), vGetVoxelVolume(), and ChemCompt::voxelVolOut().

Referenced by initCinfo(), and innerBuildDefaultMesh().

630 {
631  // double oldVol = getMeshEntryVolume( 0 );
632  innerSetCoords( v );
633  ChemCompt::voxelVolOut()->send( e, vGetVoxelVolume() );
634 }
void innerSetCoords(const vector< double > &v)
Definition: CubeMesh.cpp:602
static SrcFinfo1< vector< double > > * voxelVolOut()
Definition: ChemCompt.cpp:17
const vector< double > & vGetVoxelVolume() const
Virtual func so that derived classes can pass voxel volume back.
Definition: CubeMesh.cpp:917

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Assigns diffusion scaling info for the voxel junctions.

Definition at line 1523 of file CubeMesh.cpp.

References doubleEq(), dx_, dy_, and dz_.

Referenced by matchCubeMeshEntries().

1525 {
1526 
1527  for ( vector< VoxelJunction >::iterator i = ret.begin();
1528  i != ret.end(); ++i )
1529  {
1530  if ( doubleEq( i->diffScale, 0 ) ) { // Junction across x plane
1531  double selfXA = dy_ * dz_;
1532  double otherXA = other->dy_ * other->dz_;
1533  if ( selfXA <= otherXA )
1534  i->diffScale = 2 * selfXA / ( dx_ + other->dx_ );
1535  else
1536  i->diffScale = 2 * otherXA / ( dx_ + other->dx_ );
1537  } else if ( doubleEq( i->diffScale, 1 ) ) { // across y plane
1538  double selfXA = dx_ * dz_;
1539  double otherXA = other->dx_ * other->dz_;
1540  if ( selfXA <= otherXA )
1541  i->diffScale = 2 * selfXA / ( dy_ + other->dy_ );
1542  else
1543  i->diffScale = 2 * otherXA / ( dy_ + other->dy_ );
1544  } else if ( doubleEq( i->diffScale, 2 ) ) { // across z plane
1545  double selfXA = dx_ * dy_;
1546  double otherXA = other->dx_ * other->dy_;
1547  if ( selfXA <= otherXA )
1548  i->diffScale = 2 * selfXA / ( dz_ + other->dz_ );
1549  else
1550  i->diffScale = 2 * otherXA / ( dz_ + other->dz_ );
1551  } else {
1552  assert( 0 );
1553  }
1554  }
1555 }
bool doubleEq(double x, double y)
Definition: doubleEq.cpp:16
double dx_
coords
Definition: CubeMesh.h:307
double dz_
Cuboid edge.
Definition: CubeMesh.h:309
double dy_
Cuboid edge.
Definition: CubeMesh.h:308

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CubeMesh::setDx ( double  v)

Definition at line 501 of file CubeMesh.cpp.

References dx_, and updateCoords().

Referenced by initCinfo().

502 {
503  dx_ = v;
504  updateCoords();
505 }
void updateCoords()
Definition: CubeMesh.cpp:384
double dx_
coords
Definition: CubeMesh.h:307

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CubeMesh::setDy ( double  v)

Definition at line 513 of file CubeMesh.cpp.

References dy_, and updateCoords().

Referenced by initCinfo().

514 {
515  dy_ = v;
516  updateCoords();
517 }
void updateCoords()
Definition: CubeMesh.cpp:384
double dy_
Cuboid edge.
Definition: CubeMesh.h:308

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CubeMesh::setDz ( double  v)

Definition at line 525 of file CubeMesh.cpp.

References dz_, and updateCoords().

Referenced by initCinfo().

526 {
527  dz_ = v;
528  updateCoords();
529 }
void updateCoords()
Definition: CubeMesh.cpp:384
double dz_
Cuboid edge.
Definition: CubeMesh.h:309

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CubeMesh::setIsToroid ( bool  v)

Definition at line 571 of file CubeMesh.cpp.

References isToroid_.

Referenced by initCinfo().

572 {
573  isToroid_ = v;
574 }
bool isToroid_
Definition: CubeMesh.h:295

+ Here is the caller graph for this function:

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

Assigns volume info for the voxel junctions.

Definition at line 1557 of file CubeMesh.cpp.

References dx_, dy_, and dz_.

Referenced by matchCubeMeshEntries().

1559 {
1560 
1561  double myVol = dx_ * dy_ * dz_;
1562  double otherVol = other->dx_ * other->dy_ * other->dz_;
1563  for ( vector< VoxelJunction >::iterator i = ret.begin();
1564  i != ret.end(); ++i )
1565  {
1566  i->firstVol = myVol;
1567  i->secondVol = otherVol;
1568  }
1569 }
double dx_
coords
Definition: CubeMesh.h:307
double dz_
Cuboid edge.
Definition: CubeMesh.h:309
double dy_
Cuboid edge.
Definition: CubeMesh.h:308

+ Here is the caller graph for this function:

void CubeMesh::setMeshToSpace ( vector< unsigned int >  v)

Definition at line 655 of file CubeMesh.cpp.

References deriveS2mFromM2s(), and m2s_.

Referenced by initCinfo(), and testCubeMeshJunctionTwoDimSurface().

656 {
657  m2s_ = v;
659 }
vector< unsigned int > m2s_
of entries in z in surround volume
Definition: CubeMesh.h:330
void deriveS2mFromM2s()
Definition: CubeMesh.cpp:1046

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CubeMesh::setNx ( unsigned int  v)

Definition at line 536 of file CubeMesh.cpp.

References nx_, and updateCoords().

Referenced by initCinfo().

537 {
538  nx_ = v;
539  updateCoords();
540 }
void updateCoords()
Definition: CubeMesh.cpp:384
unsigned int nx_
Cuboid edge.
Definition: CubeMesh.h:311

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CubeMesh::setNy ( unsigned int  v)

Definition at line 548 of file CubeMesh.cpp.

References ny_, and updateCoords().

Referenced by initCinfo().

549 {
550  ny_ = v;
551  updateCoords();
552 }
void updateCoords()
Definition: CubeMesh.cpp:384
unsigned int ny_
of entries in x in surround volume
Definition: CubeMesh.h:312

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CubeMesh::setNz ( unsigned int  v)

Definition at line 559 of file CubeMesh.cpp.

References nz_, and updateCoords().

Referenced by initCinfo().

560 {
561  nz_ = v;
562  updateCoords();
563 }
unsigned int nz_
of entries in y in surround volume
Definition: CubeMesh.h:313
void updateCoords()
Definition: CubeMesh.cpp:384

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CubeMesh::setPreserveNumEntries ( bool  v)

Definition at line 581 of file CubeMesh.cpp.

References preserveNumEntries_.

Referenced by initCinfo(), testCubeMesh(), testCubeMeshExtendStencil(), testCubeMeshFillTwoDimSurface(), testCubeMeshJunctionDiffSizeMesh(), testCubeMeshJunctionTwoDimSurface(), and testCubeMeshMultiJunctionTwoD().

582 {
584 }
bool preserveNumEntries_
Flag: Should the ends loop around mathemagically?
Definition: CubeMesh.h:296

+ Here is the caller graph for this function:

void CubeMesh::setSpaceToMesh ( vector< unsigned int >  v)

Definition at line 666 of file CubeMesh.cpp.

References deriveM2sFromS2m(), and s2m_.

Referenced by initCinfo(), and testCubeMeshJunctionTwoDimSurface().

667 {
668  s2m_ = v;
670 }
void deriveM2sFromS2m()
Definition: CubeMesh.cpp:1033
vector< unsigned int > s2m_
Definition: CubeMesh.h:339

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CubeMesh::setSurface ( vector< unsigned int >  v)

Definition at line 677 of file CubeMesh.cpp.

References surface_.

Referenced by initCinfo(), and testCubeMeshJunctionTwoDimSurface().

678 {
679  surface_ = v;
680 }
vector< unsigned int > surface_
Definition: CubeMesh.h:345

+ Here is the caller graph for this function:

void CubeMesh::setX0 ( double  v)

Definition at line 435 of file CubeMesh.cpp.

References updateCoords(), and x0_.

Referenced by initCinfo(), and testCubeMesh().

436 {
437  x0_ = v;
438  updateCoords();
439 }
void updateCoords()
Definition: CubeMesh.cpp:384
double x0_
Flag: should all voxels diffuse to any tgt?
Definition: CubeMesh.h:299

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CubeMesh::setX1 ( double  v)

Definition at line 468 of file CubeMesh.cpp.

References updateCoords(), and x1_.

Referenced by initCinfo(), and testCubeMesh().

469 {
470  x1_ = v;
471  updateCoords();
472 }
void updateCoords()
Definition: CubeMesh.cpp:384
double x1_
coords
Definition: CubeMesh.h:303

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CubeMesh::setY0 ( double  v)

Definition at line 446 of file CubeMesh.cpp.

References updateCoords(), and y0_.

Referenced by initCinfo(), and testCubeMesh().

447 {
448  y0_ = v;
449  updateCoords();
450 }
void updateCoords()
Definition: CubeMesh.cpp:384
double y0_
coords
Definition: CubeMesh.h:300

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CubeMesh::setY1 ( double  v)

Definition at line 479 of file CubeMesh.cpp.

References updateCoords(), and y1_.

Referenced by initCinfo(), and testCubeMesh().

480 {
481  y1_ = v;
482  updateCoords();
483 }
void updateCoords()
Definition: CubeMesh.cpp:384
double y1_
coords
Definition: CubeMesh.h:304

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CubeMesh::setZ0 ( double  v)

Definition at line 457 of file CubeMesh.cpp.

References updateCoords(), and z0_.

Referenced by initCinfo(), and testCubeMesh().

458 {
459  z0_ = v;
460  updateCoords();
461 }
void updateCoords()
Definition: CubeMesh.cpp:384
double z0_
coords
Definition: CubeMesh.h:301

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CubeMesh::setZ1 ( double  v)

Definition at line 490 of file CubeMesh.cpp.

References updateCoords(), and z1_.

Referenced by initCinfo(), and testCubeMesh().

491 {
492  z1_ = v;
493  updateCoords();
494 }
void updateCoords()
Definition: CubeMesh.cpp:384
double z1_
coords
Definition: CubeMesh.h:305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

unsigned int CubeMesh::spaceToIndex ( double  x,
double  y,
double  z 
) const

Converts the 3-D coords to an index. EMPTY if out of range.

Definition at line 1171 of file CubeMesh.cpp.

References dx_, dy_, dz_, EMPTY, nx_, ny_, s2m_, x0_, y0_, z0_, and z1_.

Referenced by fillPointsOnCircle(), and fillPointsOnDisc().

1172 {
1173  if ( x > x0_ && x < x1_ && y > y0_ && y < y1_ && z > z0_ && z < z1_ )
1174  {
1175  unsigned int ix = ( x - x0_ ) / dx_;
1176  unsigned int iy = ( y - y0_ ) / dy_;
1177  unsigned int iz = ( z - z0_ ) / dz_;
1178  unsigned int index = ( iz * ny_ + iy ) * nx_ + ix;
1179  unsigned int innerIndex = s2m_[ index ];
1180  return innerIndex;
1181  }
1182  return EMPTY;
1183 }
double x0_
Flag: should all voxels diffuse to any tgt?
Definition: CubeMesh.h:299
double dx_
coords
Definition: CubeMesh.h:307
double z1_
coords
Definition: CubeMesh.h:305
vector< unsigned int > s2m_
Definition: CubeMesh.h:339
unsigned int nx_
Cuboid edge.
Definition: CubeMesh.h:311
double dz_
Cuboid edge.
Definition: CubeMesh.h:309
unsigned int ny_
of entries in x in surround volume
Definition: CubeMesh.h:312
static const unsigned int EMPTY
Definition: CubeMesh.h:285
double z0_
coords
Definition: CubeMesh.h:301
double dy_
Cuboid edge.
Definition: CubeMesh.h:308
double y0_
coords
Definition: CubeMesh.h:300

+ Here is the caller graph for this function:

const vector< unsigned int > & CubeMesh::surface ( ) const

Utility and test function to read surface.

Definition at line 1111 of file CubeMesh.cpp.

References surface_.

Referenced by initCinfo(), testCubeMeshFillTwoDimSurface(), testCubeMeshJunctionDiffSizeMesh(), testCubeMeshJunctionTwoDimSurface(), and testCubeMeshMultiJunctionTwoD().

1112 {
1113  return surface_;
1114 }
vector< unsigned int > surface_
Definition: CubeMesh.h:345

+ Here is the caller graph for this function:

void CubeMesh::transmitChange ( const Eref e,
double  oldvol 
)
void CubeMesh::updateCoords ( )

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

This assumes that dx, dy, dz are the quantities to preserve, over numEntries. So when the compartment changes volume, so does numEntries. dx, dy, dz do not change, some of the sub-cuboids will partially be outside.

Temporarily fill out the whole cube for m2s and s2m. These

Definition at line 384 of file CubeMesh.cpp.

References buildStencil(), dx_, dy_, dz_, fillThreeDimSurface(), m2s_, nx_, ny_, nz_, preserveNumEntries_, s2m_, surface_, swapIfBackward(), x0_, x1_, y0_, y1_, z0_, and z1_.

Referenced by CubeMesh(), innerSetCoords(), setDx(), setDy(), setDz(), setNx(), setNy(), setNz(), setX0(), setX1(), setY0(), setY1(), setZ0(), and setZ1().

385 {
386  swapIfBackward( x0_, x1_ );
387  swapIfBackward( y0_, y1_ );
388  swapIfBackward( z0_, z1_ );
389  if ( preserveNumEntries_ ) {
390  dx_ = ( x1_ - x0_ ) / nx_;
391  dy_ = ( y1_ - y0_ ) / ny_;
392  dz_ = ( z1_ - z0_ ) / nz_;
393  } else {
394  nx_ = round( (x1_ - x0_) / dx_ );
395  ny_ = round( (y1_ - y0_) / dy_ );
396  nz_ = round( (z1_ - z0_) / dz_ );
397 
398  if ( nx_ == 0 ) nx_ = 1;
399  if ( ny_ == 0 ) ny_ = 1;
400  if ( nz_ == 0 ) nz_ = 1;
401  }
402 
404  // will change for none-cube geometries.
405  unsigned int size = nx_ * ny_ * nz_;
406  m2s_.resize( size );
407  s2m_.resize( size );
408  for ( unsigned int i = 0; i < size; ++i ) {
409  m2s_[i] = s2m_[i] = i;
410  }
411 
412  // Fill out surface vector
413  surface_.resize( 0 );
414  /*
415  if ( numDims() == 0 ) {
416  surface_.push_back( 0 );
417  } else if ( numDims() == 1 ) {
418  surface_.push_back( 0 );
419  if ( size > 1 )
420  surface_.push_back( size - 1 );
421  } else if ( numDims() == 2 ) {
422  fillTwoDimSurface();
423  } else if ( numDims() == 3 ) {
424  fillThreeDimSurface();
425  }
426  */
428 
429  // volume_ = ( x1_ - x0_ ) * ( y1_ - y0_ ) * ( z1_ - z0_ );
430  assert( size >= 0 );
431 
432  buildStencil();
433 }
vector< unsigned int > surface_
Definition: CubeMesh.h:345
vector< unsigned int > m2s_
of entries in z in surround volume
Definition: CubeMesh.h:330
unsigned int nz_
of entries in y in surround volume
Definition: CubeMesh.h:313
void fillThreeDimSurface()
Definition: CubeMesh.cpp:340
double x0_
Flag: should all voxels diffuse to any tgt?
Definition: CubeMesh.h:299
double dx_
coords
Definition: CubeMesh.h:307
double y1_
coords
Definition: CubeMesh.h:304
void buildStencil()
Definition: CubeMesh.cpp:1060
double z1_
coords
Definition: CubeMesh.h:305
vector< unsigned int > s2m_
Definition: CubeMesh.h:339
unsigned int nx_
Cuboid edge.
Definition: CubeMesh.h:311
double dz_
Cuboid edge.
Definition: CubeMesh.h:309
bool preserveNumEntries_
Flag: Should the ends loop around mathemagically?
Definition: CubeMesh.h:296
unsigned int ny_
of entries in x in surround volume
Definition: CubeMesh.h:312
double x1_
coords
Definition: CubeMesh.h:303
void swapIfBackward(double &x0, double &x1)
Definition: CubeMesh.cpp:294
double z0_
coords
Definition: CubeMesh.h:301
double dy_
Cuboid edge.
Definition: CubeMesh.h:308
double y0_
coords
Definition: CubeMesh.h:300

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CubeMesh::updateM2s ( )
void CubeMesh::updateS2m ( )
double CubeMesh::vGetEntireVolume ( ) const
virtual

Virtual func to get volume of entire compartment.

Implements ChemCompt.

Definition at line 761 of file CubeMesh.cpp.

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

Referenced by vSetVolumeNotRates().

762 {
763  return fabs( (x1_ - x0_) * (y1_ - y0_) * (z1_ - z0_) );
764 }
double x0_
Flag: should all voxels diffuse to any tgt?
Definition: CubeMesh.h:299
double y1_
coords
Definition: CubeMesh.h:304
double z1_
coords
Definition: CubeMesh.h:305
double x1_
coords
Definition: CubeMesh.h:303
double z0_
coords
Definition: CubeMesh.h:301
double y0_
coords
Definition: CubeMesh.h:300

+ Here is the caller graph for this function:

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

Virtual func so that derived classes can return voxel midpoint.

Implements ChemCompt.

Definition at line 925 of file CubeMesh.cpp.

References dx_, dy_, dz_, m2s_, nx_, ny_, x0_, y0_, and z0_.

926 {
927  static vector< double > midpoint;
928  midpoint.resize( m2s_.size() * 3 );
929  for ( unsigned int i = 0; i < m2s_.size(); ++i ) // x coords. Lowest.
930  midpoint[i] = x0_ + ( 0.5 + (m2s_[i] % nx_ ) ) * dx_;
931  for ( unsigned int i = 0; i < m2s_.size(); ++i ) { // y coords. Middle.
932  unsigned int k = i + m2s_.size();
933  midpoint[k] = y0_ + ( 0.5 + ( (m2s_[i] / nx_) % ny_ ) ) * dy_;
934  }
935  for ( unsigned int i = 0; i < m2s_.size(); ++i ) { // z coords. Top.
936  unsigned int k = i + m2s_.size() * 2;
937  midpoint[k] = z0_ + ( 0.5 + ( m2s_[i] / ( nx_ * ny_ ) ) ) * dz_;
938  }
939  return midpoint;
940 }
vector< unsigned int > m2s_
of entries in z in surround volume
Definition: CubeMesh.h:330
double x0_
Flag: should all voxels diffuse to any tgt?
Definition: CubeMesh.h:299
double dx_
coords
Definition: CubeMesh.h:307
unsigned int nx_
Cuboid edge.
Definition: CubeMesh.h:311
double dz_
Cuboid edge.
Definition: CubeMesh.h:309
unsigned int ny_
of entries in x in surround volume
Definition: CubeMesh.h:312
double z0_
coords
Definition: CubeMesh.h:301
double dy_
Cuboid edge.
Definition: CubeMesh.h:308
double y0_
coords
Definition: CubeMesh.h:300
const vector< double > & CubeMesh::vGetVoxelVolume ( ) const
virtual

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

Implements ChemCompt.

Definition at line 917 of file CubeMesh.cpp.

References dx_, dy_, dz_, nx_, ny_, and nz_.

Referenced by setCoords().

918 {
919  static vector< double > vol;
920  vol.clear();
921  vol.resize( nx_ * ny_ * nz_, dx_ * dy_ * dz_ );
922  return vol;
923 }
unsigned int nz_
of entries in y in surround volume
Definition: CubeMesh.h:313
double dx_
coords
Definition: CubeMesh.h:307
unsigned int nx_
Cuboid edge.
Definition: CubeMesh.h:311
double dz_
Cuboid edge.
Definition: CubeMesh.h:309
unsigned int ny_
of entries in x in surround volume
Definition: CubeMesh.h:312
double dy_
Cuboid edge.
Definition: CubeMesh.h:308

+ Here is the caller graph for this function:

bool CubeMesh::vSetVolumeNotRates ( double  volume)
virtual

Virtual func, assigns volume, usually to single voxel.

Implements ChemCompt.

Definition at line 969 of file CubeMesh.cpp.

References dx_, dy_, dz_, vGetEntireVolume(), x0_, x1_, y0_, y1_, z0_, and z1_.

970 {
971  // Leave x0,y0.z0 and nx,ny,nz the same. Do NOT update any rates.
972  double oldvol = vGetEntireVolume();
973  double linscale = pow( vol / oldvol , 1.0 / 3.0 );
974  dx_ *= linscale;
975  dy_ *= linscale;
976  dz_ *= linscale;
977  x1_ = x0_ + dx_;
978  y1_ = y0_ + dy_;
979  z1_ = z0_ + dz_;
980 
981  return true;
982 }
double x0_
Flag: should all voxels diffuse to any tgt?
Definition: CubeMesh.h:299
double dx_
coords
Definition: CubeMesh.h:307
double y1_
coords
Definition: CubeMesh.h:304
double z1_
coords
Definition: CubeMesh.h:305
double vGetEntireVolume() const
Virtual func to get volume of entire compartment.
Definition: CubeMesh.cpp:761
double dz_
Cuboid edge.
Definition: CubeMesh.h:309
double x1_
coords
Definition: CubeMesh.h:303
double z0_
coords
Definition: CubeMesh.h:301
double dy_
Cuboid edge.
Definition: CubeMesh.h:308
double y0_
coords
Definition: CubeMesh.h:300

+ Here is the call graph for this function:

Member Data Documentation

const unsigned int CubeMesh::ABUTX = ~2
static

Definition at line 287 of file CubeMesh.h.

Referenced by checkAbut(), setIntersectVoxel(), and testIntersectVoxel().

const unsigned int CubeMesh::ABUTY = ~3
static

Definition at line 288 of file CubeMesh.h.

Referenced by checkAbut(), and setIntersectVoxel().

const unsigned int CubeMesh::ABUTZ = ~4
static

Definition at line 289 of file CubeMesh.h.

Referenced by checkAbut(), and setIntersectVoxel().

bool CubeMesh::alwaysDiffuse_
private

Flag: Should dx change or nx, with vol?

Definition at line 297 of file CubeMesh.h.

Referenced by getAlwaysDiffuse(), matchMeshEntries(), and setAlwaysDiffuse().

bool CubeMesh::isToroid_
private

Definition at line 295 of file CubeMesh.h.

Referenced by getIsToroid(), and setIsToroid().

vector< unsigned int > CubeMesh::m2s_
private

of entries in z in surround volume

For spherical mesh, coords are xyz r0 r1 theta0 theta1 phi0 phi1 For Cylindrical mesh, coords are x1y1z1 x2y2z2 r0 r1 phi0 phi1 For cuboid mesh, coords are x1y1z1 x2y2z2 For tetrahedral mesh, coords are x1y1z1 x2y2z2 x3y3z3 x4y4z4 Later worry about planar meshes. Those would be surfaces Mesh to Space lookup. Indexed by linear mesh index, from 0 to number of actual mesh entries (occupied cuboids). Returns spatial index, from 0 to nx * ny * nz - 1. Needed whenever the cuboid mesh is not filling the entire volume of the cube, that is, in most cases.

Definition at line 330 of file CubeMesh.h.

Referenced by buildStencil(), deriveM2sFromS2m(), deriveS2mFromM2s(), extendedMeshEntryVolume(), fillSpaceToMeshLookup(), getCoordinates(), getDiffusionArea(), getMeshToSpace(), innerGetNumEntries(), matchAllEntries(), setMeshToSpace(), updateCoords(), and vGetVoxelMidpoint().

const unsigned int CubeMesh::MULTI = ~5
static

Definition at line 290 of file CubeMesh.h.

Referenced by checkAbut(), setAbut(), and testIntersectVoxel().

bool CubeMesh::preserveNumEntries_
private

Flag: Should the ends loop around mathemagically?

Definition at line 296 of file CubeMesh.h.

Referenced by getPreserveNumEntries(), innerSetCoords(), setPreserveNumEntries(), and updateCoords().

vector< unsigned int > CubeMesh::s2m_
private

Space to Mesh lookup. Indexed by spatial index, from 0 to nx * ny * nz - 1. Specifically, point x y z is indexed as ( z * ny + y ) * nx + x. Returns mesh index to look up molecules etc in the specific volume. In case the spatial location is outside the included volume of the mesh, returns ~0.

Definition at line 339 of file CubeMesh.h.

Referenced by assignVoxels(), buildStencil(), deriveM2sFromS2m(), deriveS2mFromM2s(), fillSpaceToMeshLookup(), getSpaceToMesh(), matchCubeMeshEntries(), nearest(), neighbor(), setSpaceToMesh(), spaceToIndex(), and updateCoords().

const unsigned int CubeMesh::SURFACE = ~1
static

Definition at line 286 of file CubeMesh.h.

Referenced by checkAbut(), setAbut(), setIntersectVoxel(), and testIntersectVoxel().

vector< unsigned int > CubeMesh::surface_
private

Vector of spatial meshIndices comprising surface of volume in CubeMesh.

Definition at line 345 of file CubeMesh.h.

Referenced by assignVoxels(), fillThreeDimSurface(), fillTwoDimSurface(), getSurface(), matchCubeMeshEntries(), nearest(), setSurface(), surface(), and updateCoords().

double CubeMesh::x1_
private

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