MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CubeMesh.h
Go to the documentation of this file.
1 /**********************************************************************
2 ** This program is part of 'MOOSE', the
3 ** Messaging Object Oriented Simulation Environment.
4 ** Copyright (C) 2011 Upinder S. Bhalla. and NCBS
5 ** It is made available under the terms of the
6 ** GNU Lesser General Public License version 2.1
7 ** See the file COPYING.LIB for the full notice.
8 **********************************************************************/
9 
10 #ifndef _CUBE_MESH_H
11 #define _CUBE_MESH_H
12 
19 class CubeMesh: public MeshCompt
20 {
21  public:
22  CubeMesh();
23  ~CubeMesh();
24 
26  // Field assignment stuff
28 
29  void setX0( double v );
30  double getX0() const;
31  void setY0( double v );
32  double getY0() const;
33  void setZ0( double v );
34  double getZ0() const;
35 
36  void setX1( double v );
37  double getX1() const;
38  void setY1( double v );
39  double getY1() const;
40  void setZ1( double v );
41  double getZ1() const;
42 
43  void setDx( double v );
44  double getDx() const;
45  void setDy( double v );
46  double getDy() const;
47  void setDz( double v );
48  double getDz() const;
49 
50  void setNx( unsigned int v );
51  unsigned int getNx() const;
52  void setNy( unsigned int v );
53  unsigned int getNy() const;
54  void setNz( unsigned int v );
55  unsigned int getNz() const;
56 
57  void innerSetCoords( const vector< double >& v );
58  void setCoords( const Eref& e, vector< double > v );
59  vector< double > getCoords( const Eref& e ) const;
60 
61  void setMeshToSpace( vector< unsigned int > v );
62  vector< unsigned int > getMeshToSpace() const;
63 
64  void setSpaceToMesh( vector< unsigned int > v );
65  vector< unsigned int > getSpaceToMesh() const;
66 
67  void setSurface( vector< unsigned int > v );
68  vector< unsigned int > getSurface() const;
69 
70  unsigned int innerGetDimensions() const;
71 
72  void setIsToroid( bool v );
73  bool getIsToroid() const;
74 
75  void setPreserveNumEntries( bool v );
76  bool getPreserveNumEntries() const;
77 
78  void setAlwaysDiffuse( bool v );
79  bool getAlwaysDiffuse() const;
80 
82  // FieldElement assignment stuff for MeshEntries
84 
86  unsigned int getMeshType( unsigned int fid ) const;
88  unsigned int getMeshDimensions( unsigned int fid ) const;
90  double getMeshEntryVolume( unsigned int fid ) const;
92  vector< double > getCoordinates( unsigned int fid ) const;
94  vector< double > getDiffusionArea( unsigned int fid ) const;
96  vector< double > getDiffusionScaling( unsigned int fid ) const;
97 
99 
104  double extendedMeshEntryVolume( unsigned int fid ) const;
105 
109  unsigned int innerGetNumEntries() const;
111  void innerSetNumEntries( unsigned int n );
112 
114  const Eref& e,
115  const SrcFinfo2< unsigned int, vector< double > >*
116  meshStatsFinfo
117  );
118 
119  void innerHandleNodeInfo(
120  const Eref& e,
121  unsigned int numNodes, unsigned int numThreads );
122 
124  double vGetEntireVolume() const;
125 
127  // Dest funcs
129 
130  void buildMesh( Id geom, double x, double y, double z );
131 
132  void addStoich( Id stoich );
133 
135  void innerBuildDefaultMesh( const Eref& e,
136  double volume, unsigned int numEntries );
137 
139  bool vSetVolumeNotRates( double volume );
140 
142  // Utility func
144 
148  void updateCoords();
149 
150  unsigned int neighbor( unsigned int spaceIndex,
151  int dx, int dy, int dz ) const;
152 
153  void transmitChange( const Eref& e, double oldvol );
154 
155  bool isInsideCuboid( double x, double y, double z ) const;
156  bool isInsideSpheroid( double x, double y, double z ) const;
157 
159  // Stuff for junctions
161 
166  void matchMeshEntries( const ChemCompt* other,
167  vector< VoxelJunction >& ret ) const;
168 
173  void matchCubeMeshEntries( const CubeMesh* other,
174  vector< VoxelJunction >& ret ) const;
175 
176  // Some ugly stuff here for cyl meshes.
177  void matchCylMeshEntries( const ChemCompt* other,
178  vector< VoxelJunction >& ret ) const;
179 
184  void matchAllEntries( const CubeMesh* other,
185  vector< VoxelJunction >& ret ) const;
186 
187 
188  /*
190  void matchSameSpacing( const CubeMesh* other,
191  vector< pair< unsigned int, unsigned int > >& ret ) const;
192  */
193 
195  unsigned int numDims() const;
196 
198  void indexToSpace( unsigned int index,
199  double& x, double& y, double& z ) const;
200 
202  unsigned int spaceToIndex( double x, double y, double z ) const;
203 
208  double nearest( double x, double y, double z, unsigned int& index )
209  const;
210 
212  int compareMeshSpacing( const CubeMesh* other ) const;
213 
215  void defineIntersection( const CubeMesh* other,
216  double& xmin, double &xmax,
217  double& ymin, double &ymax,
218  double& zmin, double &zmax ) const;
219 
221  void fillTwoDimSurface();
222 
225  void fillThreeDimSurface();
226 
228  const vector< unsigned int >& surface() const;
230  // Stuff for diffusion
232 
234  vector< unsigned int > getParentVoxel() const;
235  const vector< double >& vGetVoxelVolume() const;
236  const vector< double >& vGetVoxelMidpoint() const;
237  const vector< double >& getVoxelArea() const;
238  const vector< double >& getVoxelLength() const;
239 
251  void buildStencil();
252  void fillSpaceToMeshLookup();
253 
259  void deriveM2sFromS2m();
260 
266  void deriveS2mFromM2s();
267 
268  void assignVoxels(
269  vector< pair< unsigned int, unsigned int > >& intersect,
270  double xmin, double xmax,
271  double ymin, double ymax,
272  double zmin, double zmax
273  ) const;
274 
276  void setDiffScale( const CubeMesh* other,
277  vector< VoxelJunction >& ret ) const;
279  void setJunctionVol( const CubeMesh* other,
280  vector< VoxelJunction >& ret ) const;
281 
282  void updateM2s();
283  void updateS2m();
285  static const unsigned int EMPTY;
286  static const unsigned int SURFACE;
287  static const unsigned int ABUTX;
288  static const unsigned int ABUTY;
289  static const unsigned int ABUTZ;
290  static const unsigned int MULTI;
291 
292  static const Cinfo* initCinfo();
293 
294  private:
295  bool isToroid_;
298 
299  double x0_;
300  double y0_;
301  double z0_;
302 
303  double x1_;
304  double y1_;
305  double z1_;
306 
307  double dx_;
308  double dy_;
309  double dz_;
310 
311  unsigned int nx_;
312  unsigned int ny_;
313  unsigned int nz_;
314 
330  vector< unsigned int > m2s_;
331 
339  vector< unsigned int > s2m_;
340 
345  vector< unsigned int > surface_;
346 };
347 
348 #endif // _CUBE_MESH_H
void setDz(double v)
Definition: CubeMesh.cpp:525
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
vector< unsigned int > getSurface() const
Definition: CubeMesh.cpp:682
void deriveM2sFromS2m()
Definition: CubeMesh.cpp:1033
unsigned int getNx() const
Definition: CubeMesh.cpp:542
static const Cinfo * initCinfo()
Definition: CubeMesh.cpp:31
vector< unsigned int > m2s_
of entries in z in surround volume
Definition: CubeMesh.h:330
unsigned int getNz() const
Definition: CubeMesh.cpp:565
double getDz() const
Definition: CubeMesh.cpp:531
unsigned int spaceToIndex(double x, double y, double z) const
Converts the 3-D coords to an index. EMPTY if out of range.
Definition: CubeMesh.cpp:1171
unsigned int nz_
of entries in y in surround volume
Definition: CubeMesh.h:313
void deriveS2mFromM2s()
Definition: CubeMesh.cpp:1046
unsigned int neighbor(unsigned int spaceIndex, int dx, int dy, int dz) const
Definition: CubeMesh.cpp:822
double getX0() const
Definition: CubeMesh.cpp:441
int compareMeshSpacing(const CubeMesh *other) const
Return 0 if spacing same, -1 if self smaller, +1 if self bigger.
Definition: CubeMesh.cpp:1222
void fillThreeDimSurface()
Definition: CubeMesh.cpp:340
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
const vector< double > & getVoxelLength() const
Definition: CubeMesh.cpp:957
double getX1() const
Definition: CubeMesh.cpp:474
double getDx() const
Definition: CubeMesh.cpp:507
double nearest(double x, double y, double z, unsigned int &index) const
Definition: CubeMesh.cpp:1185
void setY0(double v)
Definition: CubeMesh.cpp:446
void setZ0(double v)
Definition: CubeMesh.cpp:457
const int numEntries
Definition: proc.cpp:60
void updateM2s()
void matchCubeMeshEntries(const CubeMesh *other, vector< VoxelJunction > &ret) const
Definition: CubeMesh.cpp:1453
double getY1() const
Definition: CubeMesh.cpp:485
void setZ1(double v)
Definition: CubeMesh.cpp:490
vector< double > getDiffusionScaling(unsigned int fid) const
Virtual function to return scale factor for diffusion. 1 here.
Definition: CubeMesh.cpp:881
unsigned int getNy() const
Definition: CubeMesh.cpp:554
static const unsigned int ABUTY
Definition: CubeMesh.h:288
void innerSetCoords(const vector< double > &v)
Definition: CubeMesh.cpp:602
void updateCoords()
Definition: CubeMesh.cpp:384
double getZ0() const
Definition: CubeMesh.cpp:463
double x0_
Flag: should all voxels diffuse to any tgt?
Definition: CubeMesh.h:299
const vector< unsigned int > & surface() const
Utility and test function to read surface.
Definition: CubeMesh.cpp:1111
bool isToroid_
Definition: CubeMesh.h:295
static const unsigned int MULTI
Definition: CubeMesh.h:290
void setSpaceToMesh(vector< unsigned int > v)
Definition: CubeMesh.cpp:666
void setIsToroid(bool v)
Definition: CubeMesh.cpp:571
void matchCylMeshEntries(const ChemCompt *other, vector< VoxelJunction > &ret) const
Definition: CubeMesh.cpp:1516
bool isInsideSpheroid(double x, double y, double z) const
Definition: CubeMesh.cpp:992
void innerHandleRequestMeshStats(const Eref &e, const SrcFinfo2< unsigned int, vector< double > > *meshStatsFinfo)
More inherited virtual funcs: request comes in for mesh stats.
Definition: CubeMesh.cpp:734
void setNx(unsigned int v)
Definition: CubeMesh.cpp:536
const vector< double > & vGetVoxelVolume() const
Virtual func so that derived classes can pass voxel volume back.
Definition: CubeMesh.cpp:917
bool isInsideCuboid(double x, double y, double z) const
Definition: CubeMesh.cpp:986
double dx_
coords
Definition: CubeMesh.h:307
void matchMeshEntries(const ChemCompt *other, vector< VoxelJunction > &ret) const
Definition: CubeMesh.cpp:1118
unsigned int innerGetDimensions() const
Definition: CubeMesh.cpp:687
vector< unsigned int > getMeshToSpace() const
Definition: CubeMesh.cpp:661
void addStoich(Id stoich)
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
double y1_
coords
Definition: CubeMesh.h:304
bool getIsToroid() const
Definition: CubeMesh.cpp:576
unsigned int getMeshType(unsigned int fid) const
Virtual function to return MeshType of specified entry.
Definition: CubeMesh.cpp:772
void setNz(unsigned int v)
Definition: CubeMesh.cpp:559
const vector< double > & vGetVoxelMidpoint() const
Virtual func so that derived classes can return voxel midpoint.
Definition: CubeMesh.cpp:925
void transmitChange(const Eref &e, double oldvol)
static const unsigned int SURFACE
Definition: CubeMesh.h:286
void buildStencil()
Definition: CubeMesh.cpp:1060
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< double > getDiffusionArea(unsigned int fid) const
Virtual function to return diffusion X-section area.
Definition: CubeMesh.cpp:846
Definition: Eref.h:26
void fillTwoDimSurface()
Fills surface_ vector with spatial meshIndices for a rectangle.
Definition: CubeMesh.cpp:303
bool alwaysDiffuse_
Flag: Should dx change or nx, with vol?
Definition: CubeMesh.h:297
double z1_
coords
Definition: CubeMesh.h:305
void setY1(double v)
Definition: CubeMesh.cpp:479
vector< unsigned int > s2m_
Definition: CubeMesh.h:339
double getZ1() const
Definition: CubeMesh.cpp:496
void fillSpaceToMeshLookup()
Definition: CubeMesh.cpp:1005
void setJunctionVol(const CubeMesh *other, vector< VoxelJunction > &ret) const
Assigns volume info for the voxel junctions.
Definition: CubeMesh.cpp:1557
double vGetEntireVolume() const
Virtual func to get volume of entire compartment.
Definition: CubeMesh.cpp:761
void setDiffScale(const CubeMesh *other, vector< VoxelJunction > &ret) const
Assigns diffusion scaling info for the voxel junctions.
Definition: CubeMesh.cpp:1523
void innerHandleNodeInfo(const Eref &e, unsigned int numNodes, unsigned int numThreads)
Definition: CubeMesh.cpp:743
static unsigned int numNodes
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
void innerSetNumEntries(unsigned int n)
Inherited virtual func.
Definition: CubeMesh.cpp:899
bool preserveNumEntries_
Flag: Should the ends loop around mathemagically?
Definition: CubeMesh.h:296
void setDy(double v)
Definition: CubeMesh.cpp:513
unsigned int ny_
of entries in x in surround volume
Definition: CubeMesh.h:312
void innerBuildDefaultMesh(const Eref &e, double volume, unsigned int numEntries)
Virtual func to make a mesh with specified Volume and numEntries.
Definition: CubeMesh.cpp:707
static const unsigned int EMPTY
Definition: CubeMesh.h:285
double x1_
coords
Definition: CubeMesh.h:303
double extendedMeshEntryVolume(unsigned int fid) const
Virtual function to return volume of mesh Entry, including.
Definition: CubeMesh.cpp:791
Definition: Id.h:17
vector< double > getCoordinates(unsigned int fid) const
Virtual function to return coords of mesh Entry.
Definition: CubeMesh.cpp:801
double z0_
coords
Definition: CubeMesh.h:301
static const unsigned int ABUTZ
Definition: CubeMesh.h:289
void matchAllEntries(const CubeMesh *other, vector< VoxelJunction > &ret) const
Definition: CubeMesh.cpp:1503
void setNy(unsigned int v)
Definition: CubeMesh.cpp:548
vector< unsigned int > getParentVoxel() const
Inherited virtual, do nothing for now.
Definition: CubeMesh.cpp:905
bool vSetVolumeNotRates(double volume)
Virtual func, assigns volume, usually to single voxel.
Definition: CubeMesh.cpp:969
void setPreserveNumEntries(bool v)
Definition: CubeMesh.cpp:581
const vector< double > & getVoxelArea() const
Definition: CubeMesh.cpp:942
bool getAlwaysDiffuse() const
Definition: CubeMesh.cpp:596
static const unsigned int ABUTX
Definition: CubeMesh.h:287
unsigned int getMeshDimensions(unsigned int fid) const
Virtual function to return dimensions of specified entry.
Definition: CubeMesh.cpp:778
double dy_
Cuboid edge.
Definition: CubeMesh.h:308
unsigned int numDims() const
Utility function for returning # of dimensions in mesh.
Definition: CubeMesh.cpp:1148
void setSurface(vector< unsigned int > v)
Definition: CubeMesh.cpp:677
void buildMesh(Id geom, double x, double y, double z)
Definition: CubeMesh.cpp:697
void updateS2m()
double y0_
coords
Definition: CubeMesh.h:300
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
unsigned int innerGetNumEntries() const
Definition: CubeMesh.cpp:891
double getMeshEntryVolume(unsigned int fid) const
Virtual function to return volume of mesh Entry.
Definition: CubeMesh.cpp:784