DealOrthoMesh Class Reference

#include <dealorthomesh.h>

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

List of all members.

Public Types

enum  NormalOrientation { NORMAL_X = 0, NORMAL_Y = 1, NORMAL_Z = 2 }
typedef std::vector< FaceInf >
::iterator 
Face_It

Public Member Functions

Point3D getP () const
Point3D getQ () const
 DealOrthoMesh (Triangulation< 3 > &tria)
 ~DealOrthoMesh ()
int numFacesAtBoundary ()
int numElems (unsigned i)
Face_It begin ()
Face_It end ()
Face_It begin (int n)
double faceArea (const Face_It &face)
double faceAreaPerCellVol (const Face_It &face)
double faceValue (const Face_It &face, const VecDouble &fValues)
double getCellVolume ()
double getDX () const
double getDY () const
double getDZ () const
double getCellMeasure () const
void projectCentralValuesAtVertices (const VecDouble &cValues, VecDouble &vValues)
double getL2NormAtCells (const VecDouble &cValues) const
double getIntegralAtCells (const VecDouble &cValues) const
bool nonZeroInwardNormalComponenentIsPositive (FaceDirection3D face_no)
Point3D getBarycenter (Face &face)
double faceArea (FaceDirection3D face_no)
void getFacesInYZSlab (double X, VecIndex &fIndices)

Protected Member Functions

void buildFaceInformation (Triangulation< 3 > &tria)

Private Attributes

std::vector< FaceInfm_faces
unsigned nElems [3]
double m_dX
double m_dY
double m_dZ
double m_FacesArea [3]
double m_FacesAreaFromCellDirection [6]
double m_FacesAreaPerVolume [3]
double m_Vol
int n_boundary_faces
Point3D P
Point3D Q

Detailed Description

This class allows iteration along the faces. For each face we can ask who is the neighbors cells or, multiply a vector by the normal in the face. Its a class originally designed for finite volume methods which iterates along the cells computing the conservation law using the fluxes along the faces. Every face has two neighbors cells: cell1 and cell2. Since we have an ortho mesh the faces` normals are aligned with the main axes X,Y,Z. We use this to recognize with cell is cell1 and witch one is cell2. The cell1 of a face is the cell that has outward normal at that same face pointing to the positive direction, the cell2 is the one which has the normal pointing to the negative direction in that face. For example, for a face in the YZ plane, cell1 is the cell in the left (outward normal == <1,0,0>) and cell2 is on the right.

Definition at line 21 of file dealorthomesh.h.


Member Typedef Documentation

typedef std::vector<FaceInf>::iterator DealOrthoMesh::Face_It

Definition at line 44 of file dealorthomesh.h.


Member Enumeration Documentation

Enumerator:
NORMAL_X 
NORMAL_Y 
NORMAL_Z 

Definition at line 43 of file dealorthomesh.h.

00043 { NORMAL_X=0,NORMAL_Y=1,NORMAL_Z=2};


Constructor & Destructor Documentation

DealOrthoMesh::DealOrthoMesh ( Triangulation< 3 > &  tria  ) 

Definition at line 5 of file dealorthomesh.cpp.

00006    :DealBase(tria)
00007 {
00008   //Since the mesh is uniform, all cells have the same dimensions, so store these
00009   //values for easy retieval.
00010   Cell cell = getTriangulation().begin_active();
00011   m_dX = DealBase::getDX(cell);
00012   m_dY = DealBase::getDY(cell);
00013   m_dZ = DealBase::getDZ(cell);
00014   m_Vol = m_dX * m_dY * m_dZ;
00015   m_FacesArea[NORMAL_X] = m_dY*m_dZ;
00016   m_FacesArea[NORMAL_Y] = m_dX*m_dZ;
00017   m_FacesArea[NORMAL_Z] = m_dX*m_dY;
00018   P = cell->vertex(VERTEX_000);
00019 
00020   
00021   m_FacesAreaFromCellDirection[LEFT_FACE]=m_FacesArea[NORMAL_X];
00022   m_FacesAreaFromCellDirection[RIGHT_FACE]=m_FacesArea[NORMAL_X];
00023   m_FacesAreaFromCellDirection[FRONT_FACE]=m_FacesArea[NORMAL_Y];
00024   m_FacesAreaFromCellDirection[BACK_FACE]=m_FacesArea[NORMAL_Y];
00025   m_FacesAreaFromCellDirection[BOTTOM_FACE]=m_FacesArea[NORMAL_Z];
00026   m_FacesAreaFromCellDirection[UP_FACE]=m_FacesArea[NORMAL_Z];
00027   
00028   m_FacesAreaPerVolume[NORMAL_X] = 1.0/m_dX;
00029   m_FacesAreaPerVolume[NORMAL_Y] = 1.0/m_dY;
00030   m_FacesAreaPerVolume[NORMAL_Z] = 1.0/m_dZ;
00031   //build the information about the faces.
00032   buildFaceInformation(tria);
00033 
00034   //calculate number of faces at boundary;
00035   Face_It end1 = end();
00036   n_boundary_faces=0;
00037   for(Face_It face = begin();face != end1;face++)
00038   {
00039     if (face->at_boundary())
00040       n_boundary_faces++;
00041   }
00042 
00043   int nX=0,nY=0,nZ=0;
00044   for (Cell cell = beginCell();cell.state()==IteratorState::valid;cell=cell->neighbor(RIGHT_CELL))
00045     nX++;
00046   for (Cell cell = beginCell();cell.state()==IteratorState::valid;cell=cell->neighbor(BACK_CELL))
00047     nY++;
00048   for (Cell cell = beginCell();cell.state()==IteratorState::valid;cell=cell->neighbor(UP_CELL))
00049     nZ++;
00050   nElems[0]=nX;
00051   nElems[1]=nY;
00052   nElems[2]=nZ;
00053   Q[0] = P[0] + nElems[0]*getDX();
00054   Q[1] = P[1] + nElems[1]*getDY();
00055   Q[2] = P[2] + nElems[2]*getDZ();
00056   
00057   
00058   
00059 
00060 }

DealOrthoMesh::~DealOrthoMesh (  ) 

Definition at line 62 of file dealorthomesh.cpp.

00063 {
00064 
00065 }


Member Function Documentation

Face_It DealOrthoMesh::begin ( int  n  )  [inline]

Definition at line 56 of file dealorthomesh.h.

00056 {return m_faces.begin()+n;}

Face_It DealOrthoMesh::begin (  )  [inline]

Definition at line 54 of file dealorthomesh.h.

00054 {return m_faces.begin();}

void DealOrthoMesh::buildFaceInformation ( Triangulation< 3 > &  tria  )  [protected]

Build adjacent cells information for each face

This private method build information telling for each face what are the neighbors cells. The order of the two cells is very important. Since we have orthonormal meshes the faces has normals aligned with the main axes. The first cell in a face entry is the one whose face have outward normal in the positive direction.

Parameters:
tria The triangulation which we build the information.

Definition at line 75 of file dealorthomesh.cpp.

00076 {
00077   m_faces.clear();
00078   m_faces.resize(tria.n_active_faces());
00079   //For each cell.
00080   for (Triangulation<3>::active_cell_iterator cell = tria.begin_active(); cell != tria.end(); cell++)
00081   {
00082     m_faces[cell->face_index(LEFT_FACE  )].setNegNormalCell(cell->index());
00083     m_faces[cell->face_index(LEFT_FACE  )].setNormalDirection(NORMAL_X);
00084 
00085     m_faces[cell->face_index(RIGHT_FACE )].setPosNormalCell(cell->index());
00086     m_faces[cell->face_index(RIGHT_FACE  )].setNormalDirection(NORMAL_X);
00087 
00088     m_faces[cell->face_index(FRONT_FACE )].setNegNormalCell(cell->index());
00089     m_faces[cell->face_index(FRONT_FACE )].setNormalDirection(NORMAL_Y);
00090 
00091     m_faces[cell->face_index(BACK_FACE  )].setPosNormalCell(cell->index());
00092     m_faces[cell->face_index(BACK_FACE  )].setNormalDirection(NORMAL_Y);
00093 
00094     m_faces[cell->face_index(BOTTOM_FACE)].setNegNormalCell(cell->index());
00095     m_faces[cell->face_index(BOTTOM_FACE)].setNormalDirection(NORMAL_Z);
00096 
00097     m_faces[cell->face_index(UP_FACE    )].setPosNormalCell(cell->index());
00098     m_faces[cell->face_index(UP_FACE    )].setNormalDirection(NORMAL_Z);
00099 
00100   }
00101   
00102 }

Face_It DealOrthoMesh::end (  )  [inline]

Definition at line 55 of file dealorthomesh.h.

00055 {return m_faces.end();}

double DealOrthoMesh::faceArea ( FaceDirection3D  face_no  ) 

Get the area of the face given the direction of the face relative to the cell that owns it

Parameters:
face_no index of the face relative to the cell that owns it (LEFT_FACE,RIGHT_FACE,FRONT_FACE....), see FaceDirection3D.
Returns:

Definition at line 300 of file dealorthomesh.cpp.

00301 {
00302   return m_FacesAreaFromCellDirection[face_no];
00303   
00304 }

double DealOrthoMesh::faceArea ( const Face_It face  ) 

Get the area of the face.

Parameters:
face The face to get measure
Returns:
The area of the face

Definition at line 122 of file dealorthomesh.cpp.

00123 {
00124         return m_FacesArea[face->getNormalOrientation()];
00125 }

double DealOrthoMesh::faceAreaPerCellVol ( const Face_It face  ) 

Get the area of the face divided by the volume of the cell

Parameters:
Face 
Returns:

Definition at line 132 of file dealorthomesh.cpp.

00133 {
00134   return m_FacesAreaPerVolume[face->getNormalOrientation()];
00135 }

double DealOrthoMesh::faceValue ( const Face_It face,
const VecDouble fValues 
)

Get the value of the face

Parameters:
fValues Vector indexed by the faces index containing the values of the faces.
face Face to get the value
Returns:
The value fValues(face->index())

Definition at line 148 of file dealorthomesh.cpp.

00149 {
00150   assert( (unsigned) (face-begin()) < fValues.size());
00151   return fValues(face-begin());
00152 }

Point3D DealOrthoMesh::getBarycenter ( Face face  ) 

Definition at line 367 of file dealorthomesh.cpp.

00368 {
00369   Point3D V = face->vertex(BL_VERTEX);
00370   V+=face->vertex(UR_VERTEX);
00371   V/=2.0;
00372   return V;
00373 }

double DealOrthoMesh::getCellMeasure (  )  const [inline]

Definition at line 64 of file dealorthomesh.h.

00064 {return m_Vol;} 

double DealOrthoMesh::getCellVolume (  )  [inline]

Definition at line 60 of file dealorthomesh.h.

00060 {return m_Vol;}

double DealOrthoMesh::getDX (  )  const [inline]

Definition at line 61 of file dealorthomesh.h.

00061 {return m_dX;}

double DealOrthoMesh::getDY (  )  const [inline]

Definition at line 62 of file dealorthomesh.h.

00062 {return m_dY;}

double DealOrthoMesh::getDZ (  )  const [inline]

Definition at line 63 of file dealorthomesh.h.

00063 {return m_dZ;}

void DealOrthoMesh::getFacesInYZSlab ( double  X,
VecIndex fIndices 
)

This function is designed for distributed rectangle domains. In this way the domain are partitioned in slices cutted in the YZ plane alon the X axis. Depending of the distribution of elements in each subdomain the indices of the contact faces between two subdomains have different indices To communicate data between the domains we need to know the indices of the contact faces for each of the subdomains. To do this we use the function above which retrieves the faces indices in a YZ Slab and put in the vector parameter fIndices. The order of the indices are based in a geometry aproach. The first entry in the face index vector fIndices is the face with the braycenter having the lowest Y Z cordinate values. Than the cordinates are incremented in the Y direction than Z direction. In this way the faces in the vector of indices are ordered geometrically. So for the same YZ slab belonging to two different subdomains this method returns the indices with the same geometrically order. For example, if fInd1 contains the indices of the faces in a Slab X=20 in subdomain 1 and fInd2 contains the indices of the faces in the subdomain 2 for the Slab X=20, assuming that the two subdomain share common faces in this Slab, we garantee that fInd1[i] and fInd2[i] are the indices of two faces geometrically equal with the same location and format in 3D space.

Parameters:
X the X coordinate of the slab in the YZ plane
fIndices Vector to contain the indices of the faces in the YZ plane ordered such that the fIndices[i] correspond to the ith face counting from front to back, bottom to up (Y axis first, Z second)

Definition at line 328 of file dealorthomesh.cpp.

00329 {
00330   Cell cell = beginCell();
00331 
00332   double x_tol = getDX()/4.0;
00333   fIndices.reserve(numElems(1)*numElems(2));
00334   
00335   //First find the first face in the slab
00336   Face face = cell->face(LEFT_FACE);
00337   FaceDirection3D faceDir;
00338   if (NumericMethods::a_equal(getBarycenter(face)[0],X,x_tol))
00339     faceDir=LEFT_FACE;
00340   else
00341   {
00342     faceDir = RIGHT_FACE;
00343     face=cell->face(RIGHT_FACE);
00344     while (!NumericMethods::a_equal(getBarycenter(face)[0],X,x_tol))
00345     {
00346       cell = cell->neighbor(RIGHT_CELL);
00347       if (cell.state() != IteratorState::valid)
00348         return; //Oooops did not find the slab in the domain
00349       face = cell->face(RIGHT_FACE);
00350     }
00351   }
00352 
00353   //Found the slab
00354   //Now run in Z direction 
00355   for (;cell.state()==IteratorState::valid;cell=cell->neighbor(UP_CELL))
00356   {
00357     //For each Cell in Z, run in Y direction
00358     for(Cell cellY=cell;cellY.state()==IteratorState::valid;cellY=cellY->neighbor(BACK_CELL))
00359       fIndices.push_back(cellY->face_index(faceDir));
00360   }
00361   
00362   
00363   
00364 }

double DealOrthoMesh::getIntegralAtCells ( const VecDouble cValues  )  const

Reimplemented from DealBase.

Definition at line 242 of file dealorthomesh.cpp.

00243 {
00244   assert(cValues.size() == numCells());
00245   double acum=0.0;
00246   for (unsigned i=0;i<cValues.size();i++)
00247   {
00248     acum+=cValues(i);
00249   }
00250   return acum*getCellMeasure();
00251 }

double DealOrthoMesh::getL2NormAtCells ( const VecDouble cValues  )  const

Reimplemented from DealBase.

Definition at line 224 of file dealorthomesh.cpp.

00225 {
00226   assert(cValues.size() == numCells());
00227   double cellArea = getCellMeasure();
00228   Cell endc = endCell();
00229   double acum=0;
00230   for (Cell cell=beginCell();cell!=endc;cell++)
00231   {
00232     acum+=fabs(getCentralValue(cell,cValues));
00233   }
00234   return acum*cellArea;
00235 }

Point3D DealOrthoMesh::getP (  )  const [inline]

Definition at line 47 of file dealorthomesh.h.

00047 {return P;} 

Point3D DealOrthoMesh::getQ (  )  const [inline]

Definition at line 48 of file dealorthomesh.h.

00048 {return Q;} 

bool DealOrthoMesh::nonZeroInwardNormalComponenentIsPositive ( FaceDirection3D  face_no  ) 

This is a very specific function and used just in the mixed formulation. So dont waste too much time with it, since its functionality is very restricted and used just one time in all the code. Give the position of the boundary face relative to the cell that contains it (e.g LEFT_FACE, BOTTOM_FACE..... ) this function returns true if the non zero component of the normal of the face pointing inward the domain is positive. Note that this makes sense only for meshes which the sides of the elements are parallel to the axis. Otherwise the normals will have more than one non-zero component. This method is used for classes that implements the MixedFormulation and receive a scalar function as boundary conditions for the velocities fields. Values of the scalar function represent the projection of the velocity field with the normal in the boundary face pointing in the direction of the domain

Parameters:
face_no index of the face relative to the cell that owns it.
Returns:

Definition at line 286 of file dealorthomesh.cpp.

00287 {
00288   //Remember that LEFT_FACE=0,RIGHT_FACE=1,FRONT_FACE=2,BACK_FACE=3,BOTTOM_FACE=4,UP_FACE=5
00289   static bool a[] = {1,0,1,0,1,0};
00290   assert(face_no < 6);
00291   return a[face_no];
00292 
00293   
00294 }

int DealOrthoMesh::numElems ( unsigned  i  )  [inline]

Definition at line 53 of file dealorthomesh.h.

00053 {assert(i<3);return nElems[i];}

int DealOrthoMesh::numFacesAtBoundary (  )  [inline]

Definition at line 52 of file dealorthomesh.h.

00052 {assert(n_boundary_faces > 0);return n_boundary_faces;}

void DealOrthoMesh::projectCentralValuesAtVertices ( const VecDouble cValues,
VecDouble vValues 
)

Given a solution (cValues) for each cell of the mesh, interpolate these values at the vertices and store it in the vector vValues indexed by the vertices indexes. In the case of the DealOrthoMesh, the values at vertices are simple the arithmetic media of the cells` values surrounding the vertices

Parameters:
vValues To contain the values at vertices
cValues Values at cells

Definition at line 168 of file dealorthomesh.cpp.

00169 {
00170   //Check the size of the vectors;
00171   assert(vValues.size() == numVertices());
00172   assert(cValues.size() == numCells());
00173 
00174   //This vector is a counter of the number of cells contributing to each vertice
00175   //It is initialized as zero.
00176   std::vector<unsigned> nCellsPerVertice(numVertices(),0);
00177 
00178   //Initialize the values of the vector vValues.
00179   vValues=0.0;
00180 
00181   Cell endc = endCell();
00182   for (Cell cell = beginCell();cell != endc;cell++)
00183   {
00184     vValues(cell->vertex_index(VERTEX_000)) += cValues(cell->index());
00185     vValues(cell->vertex_index(VERTEX_001)) += cValues(cell->index());
00186     vValues(cell->vertex_index(VERTEX_010)) += cValues(cell->index());
00187     vValues(cell->vertex_index(VERTEX_011)) += cValues(cell->index());
00188     vValues(cell->vertex_index(VERTEX_100)) += cValues(cell->index());
00189     vValues(cell->vertex_index(VERTEX_101)) += cValues(cell->index());
00190     vValues(cell->vertex_index(VERTEX_110)) += cValues(cell->index());
00191     vValues(cell->vertex_index(VERTEX_111)) += cValues(cell->index());
00192 
00193     nCellsPerVertice[cell->vertex_index(VERTEX_000)]++;
00194     nCellsPerVertice[cell->vertex_index(VERTEX_001)]++;
00195     nCellsPerVertice[cell->vertex_index(VERTEX_010)]++;
00196     nCellsPerVertice[cell->vertex_index(VERTEX_011)]++;
00197     nCellsPerVertice[cell->vertex_index(VERTEX_100)]++;
00198     nCellsPerVertice[cell->vertex_index(VERTEX_101)]++;
00199     nCellsPerVertice[cell->vertex_index(VERTEX_110)]++;
00200     nCellsPerVertice[cell->vertex_index(VERTEX_111)]++;
00201 
00202   }
00203 
00204   //Now in vValues we have the sum of all sunrounding cells
00205   //and in nCellsPerVertice the number of cells sunrounding the vertices.
00206   //Rember that these number of cells sunrounding a vertice can differ
00207   //for vertices at boundary.
00208   for (unsigned i =0;i<vValues.size();i++)
00209       vValues(i)/=nCellsPerVertice[i];
00210 }


Member Data Documentation

double DealOrthoMesh::m_dX [private]

Step in X

Definition at line 27 of file dealorthomesh.h.

double DealOrthoMesh::m_dY [private]

Step in Y

Definition at line 28 of file dealorthomesh.h.

double DealOrthoMesh::m_dZ [private]

Step in Z

Definition at line 29 of file dealorthomesh.h.

std::vector<FaceInf> DealOrthoMesh::m_faces [private]

Definition at line 25 of file dealorthomesh.h.

double DealOrthoMesh::m_FacesArea[3] [private]

Area for the faces in the planes YZ,XZ,XY respectively at each cell

Definition at line 30 of file dealorthomesh.h.

Area for the faces indexed by the direction of the faces relative to the cells that owns them (eg LEFT_FACE, RIGHT_FACE..., see VerticeDirection3D at (globals.h)).

Definition at line 31 of file dealorthomesh.h.

Area diveded by the cell`s volume for the faces in the planes YZ,XZ,XY respectively at each cell

Definition at line 32 of file dealorthomesh.h.

double DealOrthoMesh::m_Vol [private]

Volume of cell

Definition at line 33 of file dealorthomesh.h.

Definition at line 34 of file dealorthomesh.h.

unsigned DealOrthoMesh::nElems[3] [private]

Definition at line 26 of file dealorthomesh.h.

Definition at line 35 of file dealorthomesh.h.

Definition at line 35 of file dealorthomesh.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:00 2012 for CO2INJECTION by  doxygen 1.6.3