- Home
- About DUNE
- Download
- Documentation
- Community
- Development
00001 #ifndef DUNE_ALU3DGRIDTOPOLOGY_HH 00002 #define DUNE_ALU3DGRIDTOPOLOGY_HH 00003 00004 //- system includes 00005 #include <cassert> 00006 00007 namespace Dune { 00008 00009 // types of the elementes, 00010 // i.e . tetra or hexa, mixed is not implemeneted 00011 enum ALU3dGridElementType { tetra = 4, hexa = 7, mixed, error }; 00012 00013 template <ALU3dGridElementType type> 00014 struct EntityCount {}; 00015 00016 template <> 00017 struct EntityCount<tetra> { 00018 enum {numFaces = 4}; 00019 enum {numVertices = 4}; 00020 enum {numEdges = 6}; 00021 enum {numVerticesPerFace = 3}; 00022 enum {numEdgesPerFace = 3}; 00023 }; 00024 00025 template <> 00026 struct EntityCount<hexa> { 00027 enum {numFaces = 6}; 00028 enum {numVertices = 8}; 00029 enum {numEdges = 12}; 00030 enum {numVerticesPerFace = 4}; 00031 enum {numEdgesPerFace = 4}; 00032 }; 00033 00034 00037 template <ALU3dGridElementType type> 00038 class ElementTopologyMapping 00039 { 00040 public: 00041 enum { numFaces = EntityCount<type>::numFaces }; 00042 enum { numVertices = EntityCount<type>::numVertices }; 00043 enum { numEdges = EntityCount<type>::numEdges }; 00044 enum { numVerticesPerFace = EntityCount<type>::numVerticesPerFace }; 00045 00047 static int dune2aluFace(int index); 00049 static int alu2duneFace(int index); 00050 00052 static int dune2aluEdge(int index); 00054 static int alu2duneEdge(int index); 00055 00057 static int dune2aluVertex(int index); 00059 static int alu2duneVertex(int index); 00060 00061 static int generic2aluFace ( const int index ); 00062 static int alu2genericFace ( const int index ); 00063 00064 static int generic2aluVertex ( const int index ); 00065 static int alu2genericVertex ( const int index ); 00066 00071 static int faceOrientation(int index); 00072 00079 static int dune2aluFaceVertex(int face, int localVertex); 00086 static int alu2duneFaceVertex(int face, int localVertex); 00087 00095 static int faceVertex ( int face, int local ); 00096 00097 private: 00098 const static int dune2aluFace_[numFaces]; 00099 const static int alu2duneFace_[numFaces]; 00100 00101 const static int dune2aluEdge_[numEdges]; 00102 const static int alu2duneEdge_[numEdges]; 00103 00104 const static int dune2aluVertex_[numVertices]; 00105 const static int alu2duneVertex_[numVertices]; 00106 00107 static const int generic2aluFace_[ numFaces ]; 00108 static const int alu2genericFace_[ numFaces ]; 00109 00110 static const int generic2aluVertex_[ numVertices ]; 00111 static const int alu2genericVertex_[ numVertices ]; 00112 00113 const static int faceOrientation_[numFaces]; 00114 00115 const static int dune2aluFaceVertex_[numFaces][numVerticesPerFace]; 00116 const static int alu2duneFaceVertex_[numFaces][numVerticesPerFace]; 00117 00118 static const int faceVertex_[ numFaces ][ numVerticesPerFace ]; 00119 }; 00120 00123 template <ALU3dGridElementType type> 00124 class FaceTopologyMapping { 00125 public: 00127 static int dune2aluVertex(int index); 00135 static int dune2aluVertex(int index, int twist); 00137 static int alu2duneVertex(int index); 00146 static int alu2duneVertex(int index, int twist); 00148 static int dune2aluEdge(int index); 00150 static int alu2duneEdge(int index); 00151 // private: 00152 static int twist(int index, int faceTwist); 00153 static int invTwist(int index, int faceTwist); 00154 00155 static int twistedDuneIndex( const int idx, const int twist ); 00156 00157 // for each aluTwist apply additional mapping 00158 static int aluTwistMap(const int aluTwist); 00159 private: 00160 const static int dune2aluVertex_[EntityCount<type>::numVerticesPerFace]; 00161 const static int alu2duneVertex_[EntityCount<type>::numVerticesPerFace]; 00162 00163 const static int dune2aluEdge_[EntityCount<type>::numEdgesPerFace]; 00164 const static int alu2duneEdge_[EntityCount<type>::numEdgesPerFace]; 00165 00166 const static int alu2duneTwist_[ 2 * EntityCount<type>::numVerticesPerFace ]; 00167 const static int aluTwistMap_[ 2 * EntityCount<type>::numVerticesPerFace ]; 00168 }; 00169 00170 //- IMPLEMENTATION 00171 //- class ElementTopologyMapping 00172 template <ALU3dGridElementType type> 00173 inline int ElementTopologyMapping<type>::dune2aluFace(int index) { 00174 assert(index >= 0 && index < numFaces); 00175 return dune2aluFace_[index]; 00176 } 00177 00178 template <ALU3dGridElementType type> 00179 inline int ElementTopologyMapping<type>::alu2duneFace(int index) { 00180 assert(index >= 0 && index < numFaces); 00181 return alu2duneFace_[index]; 00182 } 00183 00184 template <ALU3dGridElementType type> 00185 inline int ElementTopologyMapping<type>::dune2aluEdge(int index) { 00186 assert(index >= 0 && index < numEdges); 00187 return dune2aluEdge_[index]; 00188 } 00189 00190 template <ALU3dGridElementType type> 00191 inline int ElementTopologyMapping<type>::alu2duneEdge(int index) { 00192 assert(index >= 0 && index < numEdges); 00193 return alu2duneEdge_[index]; 00194 } 00195 00196 template <ALU3dGridElementType type> 00197 inline int ElementTopologyMapping<type>::dune2aluVertex(int index) 00198 { 00199 assert(index >= 0 && index < numVertices); 00200 return dune2aluVertex_[index]; 00201 } 00202 00203 template <ALU3dGridElementType type> 00204 inline int ElementTopologyMapping<type>::alu2duneVertex(int index) { 00205 assert(index >= 0 && index < numVertices); 00206 return alu2duneVertex_[index]; 00207 } 00208 00209 template< ALU3dGridElementType type > 00210 inline int ElementTopologyMapping< type >::generic2aluFace ( const int index ) 00211 { 00212 assert( (index >= 0) && (index < numFaces) ); 00213 return generic2aluFace_[ index ]; 00214 } 00215 00216 template< ALU3dGridElementType type > 00217 inline int ElementTopologyMapping< type >::alu2genericFace ( const int index ) 00218 { 00219 assert( (index >= 0) && (index < numFaces) ); 00220 return alu2genericFace_[ index ]; 00221 } 00222 00223 template< ALU3dGridElementType type > 00224 inline int ElementTopologyMapping< type >::generic2aluVertex ( const int index ) 00225 { 00226 assert( (index >= 0) && (index < numVertices) ); 00227 return generic2aluVertex_[ index ]; 00228 } 00229 00230 template< ALU3dGridElementType type > 00231 inline int ElementTopologyMapping< type >::alu2genericVertex ( const int index ) 00232 { 00233 assert( (index >= 0) && (index < numVertices) ); 00234 return alu2genericVertex_[ index ]; 00235 } 00236 00237 template <ALU3dGridElementType type> 00238 inline int ElementTopologyMapping<type>::faceOrientation(int index) { 00239 assert(index >= 0 && index < numVertices); 00240 return faceOrientation_[index]; 00241 } 00242 00243 template <ALU3dGridElementType type> 00244 inline int ElementTopologyMapping<type>:: 00245 dune2aluFaceVertex(int face, int localVertex) { 00246 assert(face >= 0 && face < numFaces); 00247 assert(localVertex >= 0 && localVertex < numVerticesPerFace); 00248 return dune2aluFaceVertex_[face][localVertex]; 00249 } 00250 00251 template <ALU3dGridElementType type> 00252 inline int ElementTopologyMapping<type>:: 00253 alu2duneFaceVertex(int face, int localVertex) { 00254 assert(face >= 0 && face < numFaces); 00255 assert(localVertex >= 0 && localVertex < numVerticesPerFace); 00256 return alu2duneFaceVertex_[face][localVertex]; 00257 } 00258 00259 template< ALU3dGridElementType type > 00260 inline int ElementTopologyMapping< type >::faceVertex ( int face, int local ) 00261 { 00262 assert( (face >= 0) && (face < numFaces) ); 00263 assert( (local >= 0) && (local < numVerticesPerFace) ); 00264 return faceVertex_[ face ][ local ]; 00265 } 00266 00267 //- class FaceTopologyMapping 00268 template <ALU3dGridElementType type> 00269 inline int FaceTopologyMapping<type>::dune2aluVertex(int index) { 00270 assert(index >= 0 && index < EntityCount<type>::numVerticesPerFace); 00271 return dune2aluVertex_[index]; 00272 } 00273 00274 template <ALU3dGridElementType type> 00275 inline int FaceTopologyMapping<type>::dune2aluVertex(int index, int twist) { 00276 assert(index >= 0 && index < EntityCount<type>::numVerticesPerFace); 00277 return invTwist(dune2aluVertex_[index], twist); 00278 } 00279 00280 template <ALU3dGridElementType type> 00281 inline int FaceTopologyMapping<type>::alu2duneVertex(int index) { 00282 assert(index >= 0 && index < EntityCount<type>::numVerticesPerFace); 00283 return alu2duneVertex_[index]; 00284 } 00285 00286 template <ALU3dGridElementType type> 00287 inline int FaceTopologyMapping<type>::alu2duneVertex(int index, int twist) 00288 { 00289 assert(index >= 0 && index < EntityCount<type>::numVerticesPerFace); 00290 return alu2duneVertex_[invTwist(index, twist)]; 00291 } 00292 00293 template <ALU3dGridElementType type> 00294 inline int FaceTopologyMapping<type>::alu2duneEdge(int index) { 00295 assert(index >= 0 && index < EntityCount<type>::numEdgesPerFace); 00296 return alu2duneEdge_[index]; 00297 } 00298 00299 template <ALU3dGridElementType type> 00300 inline int FaceTopologyMapping<type>:: 00301 aluTwistMap(const int aluTwist) 00302 { 00303 // this map has been calculated by grid/test/checktwists.cc 00304 // and the dune-fem twist calculator 00305 // this should be revised after the release 2.1 00306 return aluTwistMap_[ aluTwist + ((type == tetra) ? 3 : 4) ]; 00307 } 00308 00309 template <ALU3dGridElementType type> 00310 inline int FaceTopologyMapping<type>:: 00311 twistedDuneIndex(const int duneIdx, const int aluTwist) 00312 { 00313 if( type == tetra ) 00314 { 00315 // apply alu2dune twist mapping (only for tetra) 00316 const int twist = alu2duneTwist_[ aluTwist + 3 ]; 00317 return alu2duneVertex( dune2aluVertex(duneIdx) , twist ); 00318 } 00319 else 00320 return alu2duneVertex( dune2aluVertex(duneIdx) , aluTwist ); 00321 } 00322 00323 template <ALU3dGridElementType type> 00324 inline int FaceTopologyMapping<type>::dune2aluEdge(int index) { 00325 assert(index >= 0 && index < EntityCount<type>::numEdgesPerFace); 00326 return dune2aluEdge_[index]; 00327 } 00328 00329 } // end namespace Dune 00330 #endif
Generated on Fri Apr 29 2011 with Doxygen (ver 1.7.1) [doxygen-log,error-log].