Tetrahedron Class Reference

#include <Tetrahedron.hpp>

Inheritance diagram for Tetrahedron:

Inheritance graph
[legend]
Collaboration diagram for Tetrahedron:

Collaboration graph
[legend]

List of all members.

Public Types

enum  { NumberOfVertices = 4, NumberOfFaces = 4, NumberOfEdges = 6 }
typedef Triangle FaceType
enum  Type {
  hexahedron, cartesianHexahedron, hexahedronByEdge, tetrahedron,
  triangle3d, quadrangle3d
}

Public Member Functions

virtual Cell::Type type () const
void getBarycentricCoordinates (const TinyVector< 3, real_t > &X, TinyVector< 4, real_t > &lambda) const
size_t numberOfVertices () const
 Number of Vertices.
size_t numberOfEdges () const
 Number of Edges.
const Tetrahedronoperator= (const Tetrahedron &T)
 sets equal to a given tetrahedron
 Tetrahedron ()
 Default constructor does nothing but reserving memory.
 Tetrahedron (Vertex &x0, Vertex &x1, Vertex &x2, Vertex &x3, const size_t &ref=0)
 ~Tetrahedron ()
bool find (const Vertex *P)
const real_t & volume () const
void replace (Vertex *v0, Vertex *v1)
const bool & isFictitious () const
void setFictitious (const bool &b) const
const size_t & reference () const
size_t & reference ()
Vertexoperator() (const size_t &i)
const Vertexoperator() (const size_t &i) const

Static Public Attributes

static const size_t faces [NumberOfFaces][FaceType::NumberOfVertices] = {{1,2,3},{3,2,0},{0,1,3},{2,1,0}}
static const size_t edges [NumberOfEdges][Edge::NumberOfVertices] = {{0,1},{0,2},{0,3},{1,2},{3,1},{2,3}}

Protected Attributes

size_t __reference
 Reference of the Cell.
real_t __volume
 Volume or surface of the cell.
Vertex ** __vertices
 Pointers on vertices of the cell.
bool __isFictitious
 indicates if the cell is to be taken into accounts for computations


Detailed Description

Definition at line 37 of file Tetrahedron.hpp.


Member Typedef Documentation

Definition at line 47 of file Tetrahedron.hpp.


Member Enumeration Documentation

anonymous enum

Enumerator:
NumberOfVertices  number of vertices
NumberOfFaces  number of faces
NumberOfEdges  number of edges

Definition at line 41 of file Tetrahedron.hpp.

00041        {
00042     NumberOfVertices   = 4,     
00043     NumberOfFaces      = 4,     
00044     NumberOfEdges      = 6      
00045   };

enum Cell::Type [inherited]

Enumerator:
hexahedron 
cartesianHexahedron 
hexahedronByEdge 
tetrahedron 
triangle3d 
quadrangle3d 

Definition at line 40 of file Cell.hpp.

00040             {
00041     hexahedron,
00042     cartesianHexahedron,
00043     hexahedronByEdge,
00044     tetrahedron,
00045     triangle3d,
00046     quadrangle3d
00047   };


Constructor & Destructor Documentation

Tetrahedron::Tetrahedron (  )  [inline]

Default constructor does nothing but reserving memory.

Definition at line 108 of file Tetrahedron.hpp.

00109     : Cell(Tetrahedron::NumberOfVertices)
00110   {
00111     ;
00112   }

Tetrahedron::Tetrahedron ( Vertex x0,
Vertex x1,
Vertex x2,
Vertex x3,
const size_t &  ref = 0 
)

Definition at line 22 of file Tetrahedron.cpp.

References Cell::__vertices, Cell::__volume, and ErrorHandler::normal.

00027   : Cell(Tetrahedron::NumberOfVertices, ref)
00028 {
00029   __vertices[0] = &x0;
00030   __vertices[1] = &x1;
00031   __vertices[2] = &x2;
00032   __vertices[3] = &x3;
00033 
00034   TinyVector<3> A = x1 - x0;
00035   TinyVector<3> B = x2 - x0;
00036   TinyVector<3> C = x3 - x0;
00037 
00038   __volume = 1./6.*((A^B)*C);
00039   if (__volume < 0) {
00040     throw ErrorHandler(__FILE__,__LINE__,
00041                        "negative tetrahedron volume",
00042                        ErrorHandler::normal);
00043   }
00044 }

Tetrahedron::~Tetrahedron (  )  [inline]

Definition at line 120 of file Tetrahedron.hpp.

00121   {
00122     ;
00123   }


Member Function Documentation

virtual Cell::Type Tetrahedron::type (  )  const [inline, virtual]

Access to the type of the cell

Returns:
the cell type

Implements Cell.

Definition at line 52 of file Tetrahedron.hpp.

References Cell::tetrahedron.

00053   {
00054     return Cell::tetrahedron;
00055   }

void Tetrahedron::getBarycentricCoordinates ( const TinyVector< 3, real_t > &  X,
TinyVector< 4, real_t > &  lambda 
) const [inline]

computes barycentric coordinates in the current tetrahedron related to a given X position.

Parameters:
X Cartesian coordinates
lambda barycentric coordinates
Todo:
This could be optimized

Definition at line 66 of file Tetrahedron.hpp.

Referenced by MeshOfTetrahedra::find(), and Convection< MeshOfTetrahedra >::operator()().

00068   {
00069     TinyVector<4, real_t> X2;
00070     for (size_t i=0; i<3; ++i) X2[i] = X[i];
00071     X2[3] = 1;
00072 
00073     TinyMatrix<4, 4, real_t> M = 0;
00074     for (size_t i=0; i<4; ++i) {
00075       const Vertex& V = (*this)(i);
00076       for (size_t j=0; j<3; ++j) {
00077         M(j, i) = V[j];
00078       }
00079     }
00080 
00081     for (size_t i=0; i<4; ++i) {
00082       M(3,i) = 1;
00083     }
00084 
00085     lambda = X2/M;
00086   }

size_t Tetrahedron::numberOfVertices (  )  const [inline, virtual]

Number of Vertices.

Implements Cell.

Definition at line 89 of file Tetrahedron.hpp.

References NumberOfVertices.

00090   {
00091     return NumberOfVertices;
00092   }

size_t Tetrahedron::numberOfEdges (  )  const [inline]

Number of Edges.

Definition at line 95 of file Tetrahedron.hpp.

References NumberOfEdges.

00096   {
00097     return NumberOfEdges;
00098   }

const Tetrahedron& Tetrahedron::operator= ( const Tetrahedron T  )  [inline]

sets equal to a given tetrahedron

Definition at line 101 of file Tetrahedron.hpp.

References Cell::operator=().

00102   {
00103     Cell::operator=(T);
00104     return *this;
00105   }

Here is the call graph for this function:

bool Cell::find ( const Vertex P  )  [inline, inherited]

Find the vertex P in the cell

Returns:
bool

Definition at line 69 of file Cell.hpp.

References Cell::__vertices, and Cell::numberOfVertices().

Referenced by Triangulation::__checkLine().

00069                                      {
00070     for(size_t i=0 ; i<numberOfVertices() ; ++i) {
00071       if(__vertices[i]==P) {
00072         return true;
00073       }
00074     }
00075     return false;
00076   }

Here is the call graph for this function:

const real_t& Cell::volume (  )  const [inline, inherited]

void Cell::replace ( Vertex v0,
Vertex v1 
) [inline, inherited]

Replaces a vertex by another

Parameters:
v0 the vertex to replace
v1 the new vertex

Definition at line 94 of file Cell.hpp.

References Cell::__vertices, Cell::numberOfVertices(), stringify(), and ErrorHandler::unexpected.

00095   {
00096     for (size_t i = 0; i<numberOfVertices(); ++i) {
00097       if (__vertices[i] == v0) {
00098         __vertices[i] = v1;
00099         return;
00100       }
00101     }
00102 
00103     const std::string errorMsg
00104       = "vertex "+stringify(v0)+" was not found while replacing "+stringify(v1);
00105 
00106     throw ErrorHandler(__FILE__,__LINE__,
00107                        errorMsg,
00108                        ErrorHandler::unexpected);
00109   }

Here is the call graph for this function:

const bool& Cell::isFictitious (  )  const [inline, inherited]

Read-only access to the fictitious state of the cell

Returns:
true if the cell is fictitious

Definition at line 116 of file Cell.hpp.

References Cell::__isFictitious.

Referenced by FEMDiscretization< Structured3DMesh, TypeOfDiscretization >::assembleSecondMember().

00117   {
00118     return __isFictitious;
00119   }

void Cell::setFictitious ( const bool &  b  )  const [inline, inherited]

Sets fictitious state of the cell

Note:
method is const since this does not change the cell. Fictitious state is a mutable member!

Definition at line 127 of file Cell.hpp.

References Cell::__isFictitious.

Referenced by FictitiousDomainMethod::Compute().

00128   {
00129     __isFictitious = b;
00130   }

const size_t& Cell::reference (  )  const [inline, inherited]

size_t& Cell::reference (  )  [inline, inherited]

Access to the reference of the Cell.

Returns:
a reference to the reference

Definition at line 161 of file Cell.hpp.

References Cell::__reference.

00162   {
00163     return __reference;
00164   }

Vertex& Cell::operator() ( const size_t &  i  )  [inline, inherited]

Access to the ith Vertex of the Cell.

Parameters:
i the local number of the vertex
Returns:
a reference to a the vertex

Definition at line 173 of file Cell.hpp.

References Cell::__vertices, ASSERT, and Cell::numberOfVertices().

00174   {
00175     ASSERT (i<numberOfVertices());
00176     return *__vertices[i];
00177   }

Here is the call graph for this function:

const Vertex& Cell::operator() ( const size_t &  i  )  const [inline, inherited]

Read-only access to the ith Vertex of the Cell.

Parameters:
i the local number of the vertex
Returns:
a const reference to a the vertex

Definition at line 186 of file Cell.hpp.

References Cell::__vertices, ASSERT, and Cell::numberOfVertices().

00187   {
00188     ASSERT (i<numberOfVertices());
00189     return *(__vertices[i]);
00190   }

Here is the call graph for this function:


Member Data Documentation

const size_t Tetrahedron::faces = {{1,2,3},{3,2,0},{0,1,3},{2,1,0}} [static]

Definition at line 49 of file Tetrahedron.hpp.

const size_t Tetrahedron::edges = {{0,1},{0,2},{0,3},{1,2},{3,1},{2,3}} [static]

Definition at line 50 of file Tetrahedron.hpp.

size_t Cell::__reference [protected, inherited]

Reference of the Cell.

Definition at line 51 of file Cell.hpp.

Referenced by Cell::operator=(), and Cell::reference().

real_t Cell::__volume [protected, inherited]

Vertex** Cell::__vertices [protected, inherited]

bool Cell::__isFictitious [mutable, protected, inherited]

indicates if the cell is to be taken into accounts for computations

Definition at line 60 of file Cell.hpp.

Referenced by Cell::isFictitious(), and Cell::setFictitious().


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

Generated on Wed Nov 19 00:16:23 2008 for FreeFEM3D (aka ff3d) by  doxygen 1.5.6