dune-grid  2.2.0
topology.hh
Go to the documentation of this file.
1 #ifndef DUNE_ALU3DGRIDTOPOLOGY_HH
2 #define DUNE_ALU3DGRIDTOPOLOGY_HH
3 
4 //- system includes
5 #include <cassert>
6 
7 namespace Dune {
8 
9  // types of the elementes,
10  // i.e . tetra or hexa, mixed is not implemeneted
11  enum ALU3dGridElementType { tetra = 4, hexa = 7, mixed, error };
12 
13  template <ALU3dGridElementType type>
14  struct EntityCount {};
15 
16  template <>
17  struct EntityCount<tetra> {
18  enum {numFaces = 4};
19  enum {numVertices = 4};
20  enum {numEdges = 6};
21  enum {numVerticesPerFace = 3};
22  enum {numEdgesPerFace = 3};
23  };
24 
25  template <>
26  struct EntityCount<hexa> {
27  enum {numFaces = 6};
28  enum {numVertices = 8};
29  enum {numEdges = 12};
30  enum {numVerticesPerFace = 4};
31  enum {numEdgesPerFace = 4};
32  };
33 
34 
37  template <ALU3dGridElementType type>
39  {
40  public:
45 
47  static int dune2aluFace(int index);
49  static int alu2duneFace(int index);
50 
52  static int dune2aluEdge(int index);
54  static int alu2duneEdge(int index);
55 
57  static int dune2aluVertex(int index);
59  static int alu2duneVertex(int index);
60 
61  static int generic2aluFace ( const int index );
62  static int alu2genericFace ( const int index );
63 
64  static int generic2aluVertex ( const int index );
65  static int alu2genericVertex ( const int index );
66 
71  static int faceOrientation(int index);
72 
79  static int dune2aluFaceVertex(int face, int localVertex);
86  static int alu2duneFaceVertex(int face, int localVertex);
87 
95  static int faceVertex ( int face, int local );
96 
97  private:
98  const static int dune2aluFace_[numFaces];
99  const static int alu2duneFace_[numFaces];
100 
101  const static int dune2aluEdge_[numEdges];
102  const static int alu2duneEdge_[numEdges];
103 
104  const static int dune2aluVertex_[numVertices];
105  const static int alu2duneVertex_[numVertices];
106 
107  static const int generic2aluFace_[ numFaces ];
108  static const int alu2genericFace_[ numFaces ];
109 
110  static const int generic2aluVertex_[ numVertices ];
111  static const int alu2genericVertex_[ numVertices ];
112 
113  const static int faceOrientation_[numFaces];
114 
115  const static int dune2aluFaceVertex_[numFaces][numVerticesPerFace];
116  const static int alu2duneFaceVertex_[numFaces][numVerticesPerFace];
117 
118  static const int faceVertex_[ numFaces ][ numVerticesPerFace ];
119  };
120 
123  template <ALU3dGridElementType type>
125  public:
127  static int dune2aluVertex(int index);
135  static int dune2aluVertex(int index, int twist);
137  static int alu2duneVertex(int index);
146  static int alu2duneVertex(int index, int twist);
148  static int dune2aluEdge(int index);
150  static int alu2duneEdge(int index);
151  // private:
152  static int twist(int index, int faceTwist);
153  static int invTwist(int index, int faceTwist);
154 
155  static int twistedDuneIndex( const int idx, const int twist );
156 
157  // for each aluTwist apply additional mapping
158  static int aluTwistMap(const int aluTwist);
159  private:
160  const static int dune2aluVertex_[EntityCount<type>::numVerticesPerFace];
161  const static int alu2duneVertex_[EntityCount<type>::numVerticesPerFace];
162 
163  const static int dune2aluEdge_[EntityCount<type>::numEdgesPerFace];
164  const static int alu2duneEdge_[EntityCount<type>::numEdgesPerFace];
165 
166  const static int alu2duneTwist_[ 2 * EntityCount<type>::numVerticesPerFace ];
167  const static int aluTwistMap_[ 2 * EntityCount<type>::numVerticesPerFace ];
168  };
169 
170  //- IMPLEMENTATION
171  //- class ElementTopologyMapping
172  template <ALU3dGridElementType type>
174  assert(index >= 0 && index < numFaces);
175  return dune2aluFace_[index];
176  }
177 
178  template <ALU3dGridElementType type>
180  assert(index >= 0 && index < numFaces);
181  return alu2duneFace_[index];
182  }
183 
184  template <ALU3dGridElementType type>
186  assert(index >= 0 && index < numEdges);
187  return dune2aluEdge_[index];
188  }
189 
190  template <ALU3dGridElementType type>
192  assert(index >= 0 && index < numEdges);
193  return alu2duneEdge_[index];
194  }
195 
196  template <ALU3dGridElementType type>
198  {
199  assert(index >= 0 && index < numVertices);
200  return dune2aluVertex_[index];
201  }
202 
203  template <ALU3dGridElementType type>
205  assert(index >= 0 && index < numVertices);
206  return alu2duneVertex_[index];
207  }
208 
209  template< ALU3dGridElementType type >
210  inline int ElementTopologyMapping< type >::generic2aluFace ( const int index )
211  {
212  assert( (index >= 0) && (index < numFaces) );
213  return generic2aluFace_[ index ];
214  }
215 
216  template< ALU3dGridElementType type >
217  inline int ElementTopologyMapping< type >::alu2genericFace ( const int index )
218  {
219  assert( (index >= 0) && (index < numFaces) );
220  return alu2genericFace_[ index ];
221  }
222 
223  template< ALU3dGridElementType type >
225  {
226  assert( (index >= 0) && (index < numVertices) );
227  return generic2aluVertex_[ index ];
228  }
229 
230  template< ALU3dGridElementType type >
232  {
233  assert( (index >= 0) && (index < numVertices) );
234  return alu2genericVertex_[ index ];
235  }
236 
237  template <ALU3dGridElementType type>
239  assert(index >= 0 && index < numVertices);
240  return faceOrientation_[index];
241  }
242 
243  template <ALU3dGridElementType type>
245  dune2aluFaceVertex(int face, int localVertex) {
246  assert(face >= 0 && face < numFaces);
247  assert(localVertex >= 0 && localVertex < numVerticesPerFace);
248  return dune2aluFaceVertex_[face][localVertex];
249  }
250 
251  template <ALU3dGridElementType type>
253  alu2duneFaceVertex(int face, int localVertex) {
254  assert(face >= 0 && face < numFaces);
255  assert(localVertex >= 0 && localVertex < numVerticesPerFace);
256  return alu2duneFaceVertex_[face][localVertex];
257  }
258 
259  template< ALU3dGridElementType type >
260  inline int ElementTopologyMapping< type >::faceVertex ( int face, int local )
261  {
262  assert( (face >= 0) && (face < numFaces) );
263  assert( (local >= 0) && (local < numVerticesPerFace) );
264  return faceVertex_[ face ][ local ];
265  }
266 
267  //- class FaceTopologyMapping
268  template <ALU3dGridElementType type>
270  assert(index >= 0 && index < EntityCount<type>::numVerticesPerFace);
271  return dune2aluVertex_[index];
272  }
273 
274  template <ALU3dGridElementType type>
275  inline int FaceTopologyMapping<type>::dune2aluVertex(int index, int twist) {
276  assert(index >= 0 && index < EntityCount<type>::numVerticesPerFace);
277  return invTwist(dune2aluVertex_[index], twist);
278  }
279 
280  template <ALU3dGridElementType type>
282  assert(index >= 0 && index < EntityCount<type>::numVerticesPerFace);
283  return alu2duneVertex_[index];
284  }
285 
286  template <ALU3dGridElementType type>
287  inline int FaceTopologyMapping<type>::alu2duneVertex(int index, int twist)
288  {
289  assert(index >= 0 && index < EntityCount<type>::numVerticesPerFace);
290  return alu2duneVertex_[invTwist(index, twist)];
291  }
292 
293  template <ALU3dGridElementType type>
295  assert(index >= 0 && index < EntityCount<type>::numEdgesPerFace);
296  return alu2duneEdge_[index];
297  }
298 
299  template <ALU3dGridElementType type>
300  inline int FaceTopologyMapping<type>::
301  aluTwistMap(const int aluTwist)
302  {
303  // this map has been calculated by grid/test/checktwists.cc
304  // and the dune-fem twist calculator
305  // this should be revised after the release 2.1
306  return aluTwistMap_[ aluTwist + ((type == tetra) ? 3 : 4) ];
307  }
308 
309  template <ALU3dGridElementType type>
310  inline int FaceTopologyMapping<type>::
311  twistedDuneIndex(const int duneIdx, const int aluTwist)
312  {
313  if( type == tetra )
314  {
315  // apply alu2dune twist mapping (only for tetra)
316  const int twist = alu2duneTwist_[ aluTwist + 3 ];
317  return alu2duneVertex( dune2aluVertex(duneIdx) , twist );
318  }
319  else
320  return alu2duneVertex( dune2aluVertex(duneIdx) , aluTwist );
321  }
322 
323  template <ALU3dGridElementType type>
325  assert(index >= 0 && index < EntityCount<type>::numEdgesPerFace);
326  return dune2aluEdge_[index];
327  }
328 
329 } // end namespace Dune
330 #endif