00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef CARTESIAN_HEXAHEDRON_HPP
00021 #define CARTESIAN_HEXAHEDRON_HPP
00022
00033 #include <Cell.hpp>
00034 #include <Quadrangle.hpp>
00035
00036 class CartesianHexahedron
00037 : public Cell
00038 {
00039 public:
00040 enum {
00041 NumberOfVertices = 8,
00042 NumberOfFaces = 6,
00043 NumberOfEdges = 12
00044 };
00045
00046 typedef Quadrangle FaceType;
00047
00048 static const size_t faces[NumberOfFaces][FaceType::NumberOfVertices];
00049 static const size_t edges[NumberOfEdges][Edge::NumberOfVertices];
00050
00051 virtual Cell::Type type() const
00052 {
00053 return Cell::cartesianHexahedron;
00054 }
00055
00064 void getLocalCoordinates(const TinyVector<3, real_t>& X,
00065 TinyVector<3, real_t>& lambda) const
00066 {
00067 const TinyVector<3>& a = *__vertices[0];
00068 const TinyVector<3>& b = *__vertices[6];
00069 lambda = X-a;
00070 for (size_t i=0; i<3; ++i) {
00071 lambda[i] /= b[i]-a[i];
00072 }
00073 }
00074
00076 size_t numberOfVertices() const
00077 {
00078 return NumberOfVertices;
00079 }
00080
00082 size_t numberOfEdges() const
00083 {
00084 return NumberOfEdges;
00085 }
00086
00088 inline const CartesianHexahedron& operator=(const CartesianHexahedron& H)
00089 {
00090 Cell::operator=(H);
00091 return *this;
00092 }
00093
00095 CartesianHexahedron()
00096 : Cell(NumberOfVertices)
00097 {
00098 ;
00099 }
00100
00101 CartesianHexahedron(Vertex& x0,
00102 Vertex& x1,
00103 Vertex& x2,
00104 Vertex& x3,
00105 Vertex& x4,
00106 Vertex& x5,
00107 Vertex& x6,
00108 Vertex& x7)
00109 : Cell(NumberOfVertices)
00110 {
00111 __vertices[0] = &x0;
00112 __vertices[1] = &x1;
00113 __vertices[2] = &x2;
00114 __vertices[3] = &x3;
00115 __vertices[4] = &x4;
00116 __vertices[5] = &x5;
00117 __vertices[6] = &x6;
00118 __vertices[7] = &x7;
00119
00120 const TinyVector<3>& a = *__vertices[0];
00121 const TinyVector<3>& b = *__vertices[6];
00122
00123 const real_t hx = b[0] - a[0];
00124 const real_t hy = b[1] - a[1];
00125 const real_t hz = b[2] - a[2];
00126
00127 __volume = hx*hy*hz;
00128 }
00129
00130 ~CartesianHexahedron()
00131 {
00132 ;
00133 }
00134 };
00135
00136 #endif // CARTESIAN_HEXAHEDRON_HPP
00137