OrthoCellAccessor Class Reference

#include <orthocellaccessor.h>

Inheritance diagram for OrthoCellAccessor:
Inheritance graph
[legend]
Collaboration diagram for OrthoCellAccessor:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 OrthoCellAccessor (const OrthoMesh &mesh, unsigned index)
 OrthoCellAccessor (const OrthoMesh &mesh, unsigned i, unsigned j, unsigned k)
 OrthoCellAccessor ()
 ~OrthoCellAccessor ()
bool operator!= (OrthoCellAccessor &cell) const
void barycenter (Point3D &p) const
Point3D barycenter () const
bool containPoint (Point3D &p) const
void advance_inner ()
void vertex (VertexDirection3D dir, Point3D &p) const
Point3D vertex (VertexDirection3D dir) const
unsigned vertex_index (VertexDirection3D dir) const
unsigned face_index (FaceDirection3D dir) const
unsigned face_index_up () const
unsigned face_index_bottom () const
unsigned face_index_left () const
unsigned face_index_right () const
unsigned face_index_front () const
unsigned face_index_back () const
OrthoMesh::Raw_Face_It face (FaceDirection3D dir)
OrthoMesh::Raw_Cell_It neighbor (CellDirection3D dir)
unsigned index () const
unsigned neighbor_index (unsigned int dir) const
unsigned index_up () const
unsigned index_bottom () const
unsigned index_left () const
unsigned index_right () const
unsigned index_front () const
unsigned index_back () const
unsigned advance (CellDirection3D dir, unsigned stps)
bool advance (CellDirection3D dir)
unsigned getI () const
unsigned getJ () const
unsigned getK () const
bool isValid () const
bool at_boundary () const
const OrthoMeshgetMesh () const
double volume () const

Protected Member Functions

bool advanceRight ()
bool advanceLeft ()
bool advanceUp ()
bool advanceDown ()
bool advanceBack ()
bool advanceFront ()
void operator++ (int)

Protected Attributes

const OrthoMesh_pMesh
unsigned _i
unsigned _j
unsigned _k
unsigned _index

Friends

class OrthoMesh
class IteratorAccessor< OrthoCellAccessor >

Detailed Description

OrthoCellAccessor

Definition at line 10 of file orthocellaccessor.h.


Constructor & Destructor Documentation

OrthoCellAccessor::OrthoCellAccessor ( const OrthoMesh mesh,
unsigned  index 
)

Definition at line 5 of file orthocellaccessor.cpp.

00006    :_pMesh(&mesh)
00007 {
00008   assert(index < _pMesh->numRawCells());
00009   _index = index;
00010   _pMesh->getCellPositionFromIndex(index,_i,_j,_k);
00011 }

OrthoCellAccessor::OrthoCellAccessor ( const OrthoMesh mesh,
unsigned  i,
unsigned  j,
unsigned  k 
)

Definition at line 13 of file orthocellaccessor.cpp.

00014 :_pMesh(&mesh)
00015 {
00016   _i=i;
00017   _j=j;
00018   _k=k;
00019   _index=_pMesh->getCellIndexFromPosition(_i,_j,_k);
00020 }

OrthoCellAccessor::OrthoCellAccessor (  ) 

Definition at line 22 of file orthocellaccessor.cpp.

00023 {
00024   _pMesh=NULL;
00025   _i=_j=_k=_index=0;
00026 }

OrthoCellAccessor::~OrthoCellAccessor (  )  [inline]

Definition at line 33 of file orthocellaccessor.h.

00033 {}


Member Function Documentation

bool OrthoCellAccessor::advance ( CellDirection3D  dir  ) 

Reimplemented in OrthoCellAccessorWithHoles.

Definition at line 204 of file orthocellaccessor.cpp.

00205 {
00206   assert(dir <= 5);
00207   assert(this->isValid());
00208 
00209   switch(dir)
00210   {
00211   case LEFT_CELL:
00212     {
00213       return advanceLeft();
00214     }
00215   case RIGHT_CELL:
00216     {
00217       return advanceRight();
00218     }
00219   case FRONT_CELL:
00220     {
00221       return advanceFront();
00222     }
00223   case BACK_CELL:
00224     {
00225       return advanceBack();
00226     }
00227   case BOTTOM_CELL:
00228     {
00229       return advanceDown();
00230     }  
00231   case UP_CELL:
00232     {
00233       return advanceUp();
00234     }
00235   default:
00236    throw new Exception("OrthoMesh::neighbor_index(): Invalid direction number");
00237   }
00238   return true;
00239 }

unsigned OrthoCellAccessor::advance ( CellDirection3D  dir,
unsigned  stps 
)

Advance the cell stps time in the dir direction.It the cell accessor reaches the end of the domain, the method finish in the boundary of the cell

Parameters:
stps 
dir 
Returns:
The number of stps done by the cell.

Reimplemented in OrthoCellAccessorWithHoles.

Definition at line 187 of file orthocellaccessor.cpp.

00188 {
00189   unsigned i;
00190   for (i=0;i<stps;i++)
00191   {
00192     if (!this->advance(dir))
00193     {
00194       return i;
00195     }
00196   }
00197   return i;
00198 }

void OrthoCellAccessor::advance_inner (  ) 

Definition at line 442 of file orthocellaccessor.cpp.

00443 {
00444   assert(!this->at_boundary());
00445   assert(this->isValid());
00446   _index++;
00447   _i++;
00448   if (_i >= _pMesh->_LastI)
00449   {
00450     _i=1;
00451     _j++;
00452     if (_j >= _pMesh->_LastJ)
00453     {
00454       _j=1;
00455       _k++;
00456     }
00457   }
00458 }

bool OrthoCellAccessor::advanceBack (  )  [protected]

Definition at line 290 of file orthocellaccessor.cpp.

00291 {
00292       if (_j == _pMesh->_LastJ)
00293         return false;
00294       else
00295       {
00296         _index+=_pMesh->_YStride;
00297         _j++;
00298         return true;
00299       }
00300 }

bool OrthoCellAccessor::advanceDown (  )  [protected]

Definition at line 278 of file orthocellaccessor.cpp.

00279 {
00280       if (_k == 0)
00281         return false;
00282       else
00283       {
00284         _index-=_pMesh->_ZStride;
00285         _k--;
00286         return true;
00287       }
00288 }

bool OrthoCellAccessor::advanceFront (  )  [protected]

Definition at line 302 of file orthocellaccessor.cpp.

00303 {
00304       if (_j == 0)
00305         return false;
00306       else
00307       {
00308         _index-=_pMesh->_YStride;
00309         _j--;
00310         return true;
00311       }
00312 }

bool OrthoCellAccessor::advanceLeft (  )  [protected]

Definition at line 254 of file orthocellaccessor.cpp.

00255 {
00256   if (_i == 0)
00257     return false;
00258   else
00259   {
00260     _i--;
00261     _index--;
00262     return true;
00263   }
00264 }

bool OrthoCellAccessor::advanceRight (  )  [protected]

Definition at line 241 of file orthocellaccessor.cpp.

00242 {
00243       if (_i == _pMesh->_LastI)
00244         return false;
00245       else
00246       {
00247         _i++;
00248         _index++;
00249         return true;
00250       }
00251 
00252 }

bool OrthoCellAccessor::advanceUp (  )  [protected]

Definition at line 266 of file orthocellaccessor.cpp.

00267 {
00268       if (_k == _pMesh->_LastK)
00269         return false;
00270       else
00271       {
00272          _index+=_pMesh->_ZStride;
00273          _k++;
00274         return true;
00275       }
00276 }

bool OrthoCellAccessor::at_boundary (  )  const

Definition at line 88 of file orthocellaccessor.cpp.

00089 {
00090   assert(this->isValid());
00091   return _pMesh->isCellAtBoundary(_i,_j,_k);
00092 }

Point3D OrthoCellAccessor::barycenter (  )  const

Definition at line 98 of file orthocellaccessor.cpp.

00099 {
00100   assert(this->isValid());
00101   Point3D p;
00102   barycenter(p);
00103   return p;
00104 }

void OrthoCellAccessor::barycenter ( Point3D p  )  const

Definition at line 35 of file orthocellaccessor.cpp.

00036 {
00037   assert(_index < _pMesh->numRawCells());
00038   _pMesh->getBarycenterFromCell(_i,_j,_k,p);
00039 }

bool OrthoCellAccessor::containPoint ( Point3D p  )  const

Definition at line 433 of file orthocellaccessor.cpp.

00434 {
00435   Point3D v1 = vertex(VERTEX_000);
00436   Point3D v2 = vertex(VERTEX_111);
00437   return NumericMethods::isInCube(p,v1,v2);
00438 
00439 }

OrthoMesh::Raw_Face_It OrthoCellAccessor::face ( FaceDirection3D  dir  ) 

Reimplemented in OrthoCellAccessorWithHoles.

Definition at line 80 of file orthocellaccessor.cpp.

00081 {
00082   assert(this->isValid());
00083   OrthoFaceAccessor face(*_pMesh,_pMesh->getFaceIndexFromCell(dir,_i,_j,_k));
00084   return OrthoMesh::Raw_Face_It(face);
00085 }

unsigned OrthoCellAccessor::face_index ( FaceDirection3D  dir  )  const

Index of the face in the direction dir from the cell

Definition at line 74 of file orthocellaccessor.cpp.

00075 {
00076   assert(this->isValid());
00077   return _pMesh->getFaceIndexFromCell(dir,_i,_j,_k);
00078 }

unsigned OrthoCellAccessor::face_index_back (  )  const

Definition at line 344 of file orthocellaccessor.cpp.

00345 {
00346   return  _i + (_j+1)*_pMesh->_fyYStride + _k*_pMesh->_fyZStride + _pMesh->_fyOff;
00347 }

unsigned OrthoCellAccessor::face_index_bottom (  )  const

Definition at line 322 of file orthocellaccessor.cpp.

00323 {
00324     return  _i + _j*_pMesh->_fzYStride + _k*_pMesh->_fzZStride + _pMesh->_fzOff;
00325 }

unsigned OrthoCellAccessor::face_index_front (  )  const

Definition at line 338 of file orthocellaccessor.cpp.

00339 {
00340     return _i + _j*_pMesh->_fyYStride + _k*_pMesh->_fyZStride + _pMesh->_fyOff;
00341 
00342 }

unsigned OrthoCellAccessor::face_index_left (  )  const

Definition at line 327 of file orthocellaccessor.cpp.

00328 {
00329   return _i  + _j*_pMesh->_fxYStride + _k*_pMesh->_fxZStride;
00330   
00331 }

unsigned OrthoCellAccessor::face_index_right (  )  const

Definition at line 333 of file orthocellaccessor.cpp.

00334 {
00335     return _i + 1  + _j*_pMesh->_fxYStride + _k*_pMesh->_fxZStride;
00336 }

unsigned OrthoCellAccessor::face_index_up (  )  const

Definition at line 317 of file orthocellaccessor.cpp.

00318 {
00319     return _i + _j*_pMesh->_fzYStride + (_k +1)*_pMesh->_fzZStride + _pMesh->_fzOff;
00320 }

unsigned OrthoCellAccessor::getI (  )  const [inline]

Definition at line 69 of file orthocellaccessor.h.

00069 {return _i;}

unsigned OrthoCellAccessor::getJ (  )  const [inline]

Definition at line 70 of file orthocellaccessor.h.

00070 {return _j;}

unsigned OrthoCellAccessor::getK (  )  const [inline]

Definition at line 71 of file orthocellaccessor.h.

00071 {return _k;}

const OrthoMesh& OrthoCellAccessor::getMesh (  )  const [inline]

Definition at line 74 of file orthocellaccessor.h.

00074 {return *_pMesh;}

unsigned OrthoCellAccessor::index (  )  const [inline]

Index of the cell

Reimplemented in OrthoCellAccessorWithHoles.

Definition at line 54 of file orthocellaccessor.h.

unsigned OrthoCellAccessor::index_back (  )  const

Definition at line 422 of file orthocellaccessor.cpp.

00423 {
00424   assert(this->isValid());
00425   if (_j == _pMesh->_LastJ)
00426     return OrthoMesh::INVALID_INDEX;
00427   else
00428     return _index+_pMesh->_YStride;
00429 
00430 }

unsigned OrthoCellAccessor::index_bottom (  )  const

Definition at line 379 of file orthocellaccessor.cpp.

00380 {
00381   assert(this->isValid());
00382   if (_k == 0)
00383     return OrthoMesh::INVALID_INDEX;
00384   else
00385     return _index-_pMesh->_ZStride;
00386 
00387 }

unsigned OrthoCellAccessor::index_front (  )  const

Definition at line 410 of file orthocellaccessor.cpp.

00411 {
00412   assert(this->isValid());
00413   if (_j == 0)
00414     return OrthoMesh::INVALID_INDEX;
00415   else
00416     return _index-_pMesh->_YStride;
00417 }

unsigned OrthoCellAccessor::index_left (  )  const

Definition at line 389 of file orthocellaccessor.cpp.

00390 {
00391   assert(this->isValid());
00392   if (_i == 0)
00393     return OrthoMesh::INVALID_INDEX;
00394   else
00395     return _index-1;
00396 }

unsigned OrthoCellAccessor::index_right (  )  const

Definition at line 398 of file orthocellaccessor.cpp.

00399 {
00400   assert(this->isValid());
00401   if (_i == _pMesh->_LastI)
00402     return OrthoMesh::INVALID_INDEX;
00403   else
00404     return _index+1;
00405 
00406 }

unsigned OrthoCellAccessor::index_up (  )  const

Definition at line 368 of file orthocellaccessor.cpp.

00369 {
00370   assert(this->isValid());
00371 
00372   if (_k == _pMesh->_LastK)
00373     return OrthoMesh::INVALID_INDEX;
00374   else
00375     return _index+_pMesh->_ZStride;
00376 
00377 }

bool OrthoCellAccessor::isValid (  )  const

Definition at line 163 of file orthocellaccessor.cpp.

00164 {
00165 
00166   return (_pMesh != NULL && _index < _pMesh->numRawCells());
00167 }

OrthoMesh::Raw_Cell_It OrthoCellAccessor::neighbor ( CellDirection3D  dir  ) 

Reimplemented in OrthoCellAccessorWithHoles.

Definition at line 170 of file orthocellaccessor.cpp.

00171 {
00172   unsigned index = this->neighbor_index(dir);
00173   if (index == _pMesh->invalidIndex())
00174     return _pMesh->end_raw_cell();
00175   
00176   OrthoCellAccessor result(*_pMesh,index);
00177   return OrthoMesh::Raw_Cell_It(result);
00178 }

unsigned OrthoCellAccessor::neighbor_index ( unsigned int  dir  )  const

Reimplemented in OrthoCellAccessorWithHoles.

Definition at line 107 of file orthocellaccessor.cpp.

00108 {
00109   assert(dir <= 5);
00110   assert(this->isValid());
00111 
00112   switch(dir)
00113   {
00114   case LEFT_CELL:
00115     {
00116       if (_i == 0)
00117         return OrthoMesh::INVALID_INDEX;
00118       else
00119         return _index-1;
00120     }
00121   case RIGHT_CELL:
00122     {
00123       if (_i == _pMesh->_nElemX-1)
00124         return OrthoMesh::INVALID_INDEX;
00125       else
00126         return _index+1;
00127     }
00128   case FRONT_CELL:
00129     {
00130       if (_j == 0)
00131         return OrthoMesh::INVALID_INDEX;
00132       else
00133         return _index-_pMesh->_YStride;
00134     }
00135   case BACK_CELL:
00136     {
00137       if (_j == _pMesh->_nElemY-1)
00138         return OrthoMesh::INVALID_INDEX;
00139       else
00140         return _index+_pMesh->_YStride;
00141     }
00142   case BOTTOM_CELL:
00143     {
00144       if (_k == 0)
00145         return OrthoMesh::INVALID_INDEX;
00146       else
00147         return _index-_pMesh->_ZStride;
00148     }  
00149   case UP_CELL:
00150     {
00151       if (_k == _pMesh->_nElemZ-1)
00152         return OrthoMesh::INVALID_INDEX;
00153       else
00154         return _index+_pMesh->_ZStride;
00155     }
00156   default:
00157    throw new Exception("OrthoMesh::neighbor_index(): Invalid direction number");
00158   }
00159   
00160 }

bool OrthoCellAccessor::operator!= ( OrthoCellAccessor cell  )  const

Definition at line 358 of file orthocellaccessor.cpp.

00359 {
00360   assert(_index <= _pMesh->numRawCells());
00361   assert(cell._index <= _pMesh->numRawCells());
00362   return _index != cell._index;
00363 }

void OrthoCellAccessor::operator++ ( int   )  [protected]

Reimplemented in OrthoCellAccessorWithHoles.

Definition at line 56 of file orthocellaccessor.cpp.

00057 {
00058   assert(this->isValid());
00059   assert(_index < _pMesh->numRawCells());
00060   _index++;
00061   _i++;
00062   if (_i >= _pMesh->_nElemX)
00063   {
00064     _i=0;
00065     _j++;
00066     if (_j >= _pMesh->_nElemY)
00067     {
00068       _j=0;
00069       _k++;
00070     }
00071   }
00072 }

Point3D OrthoCellAccessor::vertex ( VertexDirection3D  dir  )  const

Definition at line 49 of file orthocellaccessor.cpp.

00050 {
00051   Point3D p;
00052   vertex(dir,p);
00053   return p;
00054 }

void OrthoCellAccessor::vertex ( VertexDirection3D  dir,
Point3D p 
) const

Definition at line 42 of file orthocellaccessor.cpp.

00043 {
00044   assert(this->isValid());
00045   assert(_index < _pMesh->numRawCells());
00046   _pMesh->getVerticeFromCell(dir, _i,_j,_k,p);
00047 }

unsigned OrthoCellAccessor::vertex_index ( VertexDirection3D  dir  )  const

return the index of the vertice given the relative position of the vertex within the cell

Definition at line 28 of file orthocellaccessor.cpp.

00029 {
00030   assert(this->isValid());
00031   assert(_index < _pMesh->numRawCells());
00032   return _pMesh->getVerticeIndexFromCell(dir,_i,_j,_k);
00033 }

double OrthoCellAccessor::volume (  )  const [inline]

Definition at line 75 of file orthocellaccessor.h.

00075 {return _pMesh->cellVolume();}


Friends And Related Function Documentation

friend class IteratorAccessor< OrthoCellAccessor > [friend]

Definition at line 13 of file orthocellaccessor.h.

friend class OrthoMesh [friend]

Reimplemented in OrthoCellAccessorWithHoles.

Definition at line 12 of file orthocellaccessor.h.


Member Data Documentation

unsigned OrthoCellAccessor::_i [protected]

Definition at line 18 of file orthocellaccessor.h.

unsigned OrthoCellAccessor::_index [protected]

Definition at line 18 of file orthocellaccessor.h.

unsigned OrthoCellAccessor::_j [protected]

Definition at line 18 of file orthocellaccessor.h.

unsigned OrthoCellAccessor::_k [protected]

Definition at line 18 of file orthocellaccessor.h.

Definition at line 17 of file orthocellaccessor.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Sun Apr 8 23:13:24 2012 for CO2INJECTION by  doxygen 1.6.3