00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _CUBE_MESH_H
00011 #define _CUBE_MESH_H
00012
00019 class CubeMesh: public MeshCompt
00020 {
00021 public:
00022 CubeMesh();
00023 ~CubeMesh();
00024
00026
00028
00029 void setX0( double v );
00030 double getX0() const;
00031 void setY0( double v );
00032 double getY0() const;
00033 void setZ0( double v );
00034 double getZ0() const;
00035
00036 void setX1( double v );
00037 double getX1() const;
00038 void setY1( double v );
00039 double getY1() const;
00040 void setZ1( double v );
00041 double getZ1() const;
00042
00043 void setDx( double v );
00044 double getDx() const;
00045 void setDy( double v );
00046 double getDy() const;
00047 void setDz( double v );
00048 double getDz() const;
00049
00050 void setNx( unsigned int v );
00051 unsigned int getNx() const;
00052 void setNy( unsigned int v );
00053 unsigned int getNy() const;
00054 void setNz( unsigned int v );
00055 unsigned int getNz() const;
00056
00057 void innerSetCoords( const vector< double >& v );
00058 void setCoords( const Eref& e, vector< double > v );
00059 vector< double > getCoords( const Eref& e ) const;
00060
00061 void setMeshToSpace( vector< unsigned int > v );
00062 vector< unsigned int > getMeshToSpace() const;
00063
00064 void setSpaceToMesh( vector< unsigned int > v );
00065 vector< unsigned int > getSpaceToMesh() const;
00066
00067 void setSurface( vector< unsigned int > v );
00068 vector< unsigned int > getSurface() const;
00069
00070 unsigned int innerGetDimensions() const;
00071
00072 void setIsToroid( bool v );
00073 bool getIsToroid() const;
00074
00075 void setPreserveNumEntries( bool v );
00076 bool getPreserveNumEntries() const;
00077
00078 void setAlwaysDiffuse( bool v );
00079 bool getAlwaysDiffuse() const;
00080
00082
00084
00086 unsigned int getMeshType( unsigned int fid ) const;
00088 unsigned int getMeshDimensions( unsigned int fid ) const;
00090 double getMeshEntryVolume( unsigned int fid ) const;
00092 vector< double > getCoordinates( unsigned int fid ) const;
00094 vector< double > getDiffusionArea( unsigned int fid ) const;
00096 vector< double > getDiffusionScaling( unsigned int fid ) const;
00097
00099
00104 double extendedMeshEntryVolume( unsigned int fid ) const;
00105
00109 unsigned int innerGetNumEntries() const;
00111 void innerSetNumEntries( unsigned int n );
00112
00113 void innerHandleRequestMeshStats(
00114 const Eref& e,
00115 const SrcFinfo2< unsigned int, vector< double > >*
00116 meshStatsFinfo
00117 );
00118
00119 void innerHandleNodeInfo(
00120 const Eref& e,
00121 unsigned int numNodes, unsigned int numThreads );
00122
00124 double vGetEntireVolume() const;
00125
00127
00129
00130 void buildMesh( Id geom, double x, double y, double z );
00131
00132 void addStoich( Id stoich );
00133
00135 void innerBuildDefaultMesh( const Eref& e,
00136 double volume, unsigned int numEntries );
00137
00139 bool vSetVolumeNotRates( double volume );
00140
00142
00144
00148 void updateCoords();
00149
00150 unsigned int neighbor( unsigned int spaceIndex,
00151 int dx, int dy, int dz ) const;
00152
00153 void transmitChange( const Eref& e, double oldvol );
00154
00155 bool isInsideCuboid( double x, double y, double z ) const;
00156 bool isInsideSpheroid( double x, double y, double z ) const;
00157
00159
00161
00166 void matchMeshEntries( const ChemCompt* other,
00167 vector< VoxelJunction >& ret ) const;
00168
00173 void matchCubeMeshEntries( const CubeMesh* other,
00174 vector< VoxelJunction >& ret ) const;
00175
00176
00177 void matchCylMeshEntries( const ChemCompt* other,
00178 vector< VoxelJunction >& ret ) const;
00179
00184 void matchAllEntries( const CubeMesh* other,
00185 vector< VoxelJunction >& ret ) const;
00186
00187
00188
00190
00191
00192
00193
00195 unsigned int numDims() const;
00196
00198 void indexToSpace( unsigned int index,
00199 double& x, double& y, double& z ) const;
00200
00202 unsigned int spaceToIndex( double x, double y, double z ) const;
00203
00208 double nearest( double x, double y, double z, unsigned int& index )
00209 const;
00210
00212 int compareMeshSpacing( const CubeMesh* other ) const;
00213
00215 void defineIntersection( const CubeMesh* other,
00216 double& xmin, double &xmax,
00217 double& ymin, double &ymax,
00218 double& zmin, double &zmax ) const;
00219
00221 void fillTwoDimSurface();
00222
00225 void fillThreeDimSurface();
00226
00228 const vector< unsigned int >& surface() const;
00230
00232
00234 vector< unsigned int > getParentVoxel() const;
00235 const vector< double >& vGetVoxelVolume() const;
00236 const vector< double >& vGetVoxelMidpoint() const;
00237 const vector< double >& getVoxelArea() const;
00238 const vector< double >& getVoxelLength() const;
00239
00251 void buildStencil();
00252 void fillSpaceToMeshLookup();
00253
00259 void deriveM2sFromS2m();
00260
00266 void deriveS2mFromM2s();
00267
00268 void assignVoxels(
00269 vector< pair< unsigned int, unsigned int > >& intersect,
00270 double xmin, double xmax,
00271 double ymin, double ymax,
00272 double zmin, double zmax
00273 ) const;
00274
00276 void setDiffScale( const CubeMesh* other,
00277 vector< VoxelJunction >& ret ) const;
00279 void setJunctionVol( const CubeMesh* other,
00280 vector< VoxelJunction >& ret ) const;
00281
00282 void updateM2s();
00283 void updateS2m();
00285 static const unsigned int EMPTY;
00286 static const unsigned int SURFACE;
00287 static const unsigned int ABUTX;
00288 static const unsigned int ABUTY;
00289 static const unsigned int ABUTZ;
00290 static const unsigned int MULTI;
00291
00292 static const Cinfo* initCinfo();
00293
00294 private:
00295 bool isToroid_;
00296 bool preserveNumEntries_;
00297 bool alwaysDiffuse_;
00298
00299 double x0_;
00300 double y0_;
00301 double z0_;
00302
00303 double x1_;
00304 double y1_;
00305 double z1_;
00306
00307 double dx_;
00308 double dy_;
00309 double dz_;
00310
00311 unsigned int nx_;
00312 unsigned int ny_;
00313 unsigned int nz_;
00314
00330 vector< unsigned int > m2s_;
00331
00339 vector< unsigned int > s2m_;
00340
00345 vector< unsigned int > surface_;
00346 };
00347
00348 #endif // _CUBE_MESH_H