dune-alugrid  3.0.0
topology.hh
Go to the documentation of this file.
1 #ifndef DUNE_ALU3DGRIDTOPOLOGY_HH
2 #define DUNE_ALU3DGRIDTOPOLOGY_HH
3 
4 #include <utility>
5 
7 
8 namespace Dune {
9 
10  // types of the elementes,
11  // i.e . tetra or hexa, mixed is not implemeneted
12  enum ALU3dGridElementType { tetra = 4, hexa = 7, mixed, error };
13 
14  template <ALU3dGridElementType type>
15  struct EntityCount {};
16 
17  template <>
18  struct EntityCount<tetra> {
19  enum {numFaces = 4};
20  enum {numVertices = 4};
21  enum {numEdges = 6};
22  enum {numVerticesPerFace = 3};
23  enum {numEdgesPerFace = 3};
24  };
25 
26  template <>
27  struct EntityCount<hexa> {
28  enum {numFaces = 6};
29  enum {numVertices = 8};
30  enum {numEdges = 12};
31  enum {numVerticesPerFace = 4};
32  enum {numEdgesPerFace = 4};
33  };
34 
35 
38  template <ALU3dGridElementType type>
40  {
41  public:
46 
48  static int dune2aluFace(int index);
50  static int alu2duneFace(int index);
51 
53  static int dune2aluEdge(int index);
55  static int alu2duneEdge(int index);
56 
58  static int dune2aluVertex(int index);
60  static int alu2duneVertex(int index);
61 
62  static int generic2aluFace ( const int index );
63  static int alu2genericFace ( const int index );
64 
65  static int generic2aluVertex ( const int index );
66  static int alu2genericVertex ( const int index );
67 
72  static int faceOrientation(int index);
73 
80  static int dune2aluFaceVertex(int face, int localVertex);
87  static int alu2duneFaceVertex(int face, int localVertex);
88 
107  static int duneFaceTwist ( int face );
108 
109  static std::pair< int, int > duneEdgeMap ( int edge );
110 
118  static int faceVertex ( int face, int local );
119 
120  private:
121  const static int dune2aluFace_[numFaces];
122  const static int alu2duneFace_[numFaces];
123 
124  const static int dune2aluEdge_[numEdges];
125  const static int alu2duneEdge_[numEdges];
126 
127  const static int dune2aluVertex_[numVertices];
128  const static int alu2duneVertex_[numVertices];
129 
130  static const int generic2aluFace_[ numFaces ];
131  static const int alu2genericFace_[ numFaces ];
132 
133  static const int generic2aluVertex_[ numVertices ];
134  static const int alu2genericVertex_[ numVertices ];
135 
136  const static int faceOrientation_[numFaces];
137 
138  const static int dune2aluFaceVertex_[numFaces][numVerticesPerFace];
139  const static int alu2duneFaceVertex_[numFaces][numVerticesPerFace];
140 
141  static const int duneFaceTwist_[ numFaces ];
142 
143  static const int duneEdgeMap_[ numEdges ][ 2 ];
144 
145  static const int faceVertex_[ numFaces ][ numVerticesPerFace ];
146  };
147 
150  template <ALU3dGridElementType type>
152  public:
154  static int dune2aluVertex(int index);
162  static int dune2aluVertex(int index, int twist);
164  static int alu2duneVertex(int index);
173  static int alu2duneVertex(int index, int twist);
175  static int dune2aluEdge(int index);
177  static int alu2duneEdge(int index);
178  // private:
179  static int twist(int index, int faceTwist);
180  static int invTwist(int index, int faceTwist);
181 
182  static int twistedDuneIndex( const int idx, const int twist );
183 
184  // for each aluTwist apply additional mapping
185  static int aluTwistMap(const int aluTwist);
186  private:
187  const static int dune2aluVertex_[EntityCount<type>::numVerticesPerFace];
188  const static int alu2duneVertex_[EntityCount<type>::numVerticesPerFace];
189 
190  const static int dune2aluEdge_[EntityCount<type>::numEdgesPerFace];
191  const static int alu2duneEdge_[EntityCount<type>::numEdgesPerFace];
192 
193  const static int alu2duneTwist_[ 2 * EntityCount<type>::numVerticesPerFace ];
194  const static int aluTwistMap_[ 2 * EntityCount<type>::numVerticesPerFace ];
195  };
196 
197  //- IMPLEMENTATION
198  //- class ElementTopologyMapping
199  template <ALU3dGridElementType type>
201  alugrid_assert (index >= 0 && index < numFaces);
202  return dune2aluFace_[index];
203  }
204 
205  template <ALU3dGridElementType type>
207  alugrid_assert (index >= 0 && index < numFaces);
208  return alu2duneFace_[index];
209  }
210 
211  template <ALU3dGridElementType type>
213  alugrid_assert (index >= 0 && index < numEdges);
214  return dune2aluEdge_[index];
215  }
216 
217  template <ALU3dGridElementType type>
219  alugrid_assert (index >= 0 && index < numEdges);
220  return alu2duneEdge_[index];
221  }
222 
223  template <ALU3dGridElementType type>
225  {
226  alugrid_assert (index >= 0 && index < numVertices);
227  return dune2aluVertex_[index];
228  }
229 
230  template <ALU3dGridElementType type>
232  alugrid_assert (index >= 0 && index < numVertices);
233  return alu2duneVertex_[index];
234  }
235 
236  template< ALU3dGridElementType type >
237  inline int ElementTopologyMapping< type >::generic2aluFace ( const int index )
238  {
239  alugrid_assert ( (index >= 0) && (index < numFaces) );
240  return generic2aluFace_[ index ];
241  }
242 
243  template< ALU3dGridElementType type >
244  inline int ElementTopologyMapping< type >::alu2genericFace ( const int index )
245  {
246  alugrid_assert ( (index >= 0) && (index < numFaces) );
247  return alu2genericFace_[ index ];
248  }
249 
250  template< ALU3dGridElementType type >
252  {
253  alugrid_assert ( (index >= 0) && (index < numVertices) );
254  return generic2aluVertex_[ index ];
255  }
256 
257  template< ALU3dGridElementType type >
259  {
260  alugrid_assert ( (index >= 0) && (index < numVertices) );
261  return alu2genericVertex_[ index ];
262  }
263 
264  template <ALU3dGridElementType type>
266  alugrid_assert (index >= 0 && index < numVertices);
267  return faceOrientation_[index];
268  }
269 
270  template <ALU3dGridElementType type>
272  dune2aluFaceVertex(int face, int localVertex) {
273  alugrid_assert (face >= 0 && face < numFaces);
274  alugrid_assert (localVertex >= 0 && localVertex < numVerticesPerFace);
275  return dune2aluFaceVertex_[face][localVertex];
276  }
277 
278  template <ALU3dGridElementType type>
280  alu2duneFaceVertex(int face, int localVertex) {
281  alugrid_assert (face >= 0 && face < numFaces);
282  alugrid_assert (localVertex >= 0 && localVertex < numVerticesPerFace);
283  return alu2duneFaceVertex_[face][localVertex];
284  }
285 
286  template< ALU3dGridElementType type >
288  {
289  alugrid_assert( (face >= 0) && (face < numFaces) );
290  return duneFaceTwist_[ face ];
291  }
292 
293  template< ALU3dGridElementType type >
294  inline std::pair< int, int > ElementTopologyMapping< type >::duneEdgeMap ( int edge )
295  {
296  alugrid_assert( (edge >= 0) && (edge < numEdges ) );
297  return std::make_pair( duneEdgeMap_[ edge ][ 0 ], duneEdgeMap_[ edge ][ 1 ] );
298  }
299 
300  template< ALU3dGridElementType type >
301  inline int ElementTopologyMapping< type >::faceVertex ( int face, int local )
302  {
303  alugrid_assert ( (face >= 0) && (face < numFaces) );
304  alugrid_assert ( (local >= 0) && (local < numVerticesPerFace) );
305  return faceVertex_[ face ][ local ];
306  }
307 
308  //- class FaceTopologyMapping
309  template <ALU3dGridElementType type>
312  return dune2aluVertex_[index];
313  }
314 
315  template <ALU3dGridElementType type>
316  inline int FaceTopologyMapping<type>::dune2aluVertex(int index, int twist) {
318  return invTwist(dune2aluVertex_[index], twist);
319  }
320 
321  template <ALU3dGridElementType type>
324  return alu2duneVertex_[index];
325  }
326 
327  template <ALU3dGridElementType type>
328  inline int FaceTopologyMapping<type>::alu2duneVertex(int index, int twist)
329  {
331  return alu2duneVertex_[invTwist(index, twist)];
332  }
333 
334  template <ALU3dGridElementType type>
336  alugrid_assert (index >= 0 && index < EntityCount<type>::numEdgesPerFace);
337  return alu2duneEdge_[index];
338  }
339 
340  template <ALU3dGridElementType type>
341  inline int FaceTopologyMapping<type>::
342  aluTwistMap(const int aluTwist)
343  {
344  // this map has been calculated by grid/test/checktwists.cc
345  // and the dune-fem twist calculator
346  // this should be revised after the release 2.1
347  return aluTwistMap_[ aluTwist + ((type == tetra) ? 3 : 4) ];
348  }
349 
350  template <ALU3dGridElementType type>
351  inline int FaceTopologyMapping<type>::
352  twistedDuneIndex(const int duneIdx, const int aluTwist)
353  {
354  if( type == tetra )
355  {
356  // apply alu2dune twist mapping (only for tetra)
357  const int twist = alu2duneTwist_[ aluTwist + 3 ];
358  return alu2duneVertex( dune2aluVertex(duneIdx) , twist );
359  }
360  else
361  return alu2duneVertex( dune2aluVertex(duneIdx) , aluTwist );
362  }
363 
364  template <ALU3dGridElementType type>
366  alugrid_assert (index >= 0 && index < EntityCount<type>::numEdgesPerFace);
367  return dune2aluEdge_[index];
368  }
369 
370 } // end namespace Dune
371 #endif
Dune::ElementTopologyMapping::alu2duneVertex
static int alu2duneVertex(int index)
Maps vertex index from ALU3dGrid onto Dune reference element.
Definition: topology.hh:231
Dune::FaceTopologyMapping::aluTwistMap
static int aluTwistMap(const int aluTwist)
Definition: topology.hh:342
Dune::FaceTopologyMapping::alu2duneVertex
static int alu2duneVertex(int index)
Maps vertex index from ALU3dGrid onto Dune reference face.
Definition: topology.hh:322
Dune::ElementTopologyMapping::alu2duneEdge
static int alu2duneEdge(int index)
Maps edge index from ALU3dGrid onto Dune reference element.
Definition: topology.hh:218
Dune::hexa
Definition: topology.hh:12
Dune::ElementTopologyMapping
Definition: topology.hh:39
Dune::ElementTopologyMapping::alu2duneFace
static int alu2duneFace(int index)
Maps face index from ALU3dGrid onto Dune reference element.
Definition: topology.hh:206
Dune::EntityCount
Definition: topology.hh:15
Dune::FaceTopologyMapping::dune2aluEdge
static int dune2aluEdge(int index)
Maps edge index from Dune onto ALU3dGrid reference face.
Definition: topology.hh:365
alugrid_assert.hh
Dune::mixed
Definition: topology.hh:12
Dune::ElementTopologyMapping::dune2aluFace
static int dune2aluFace(int index)
Maps face index from Dune onto ALU3dGrid reference element.
Definition: topology.hh:200
Dune::tetra
Definition: topology.hh:12
Dune::ElementTopologyMapping::dune2aluEdge
static int dune2aluEdge(int index)
Maps edge index from Dune onto ALU3dGrid reference element.
Definition: topology.hh:212
Dune::ElementTopologyMapping::dune2aluFaceVertex
static int dune2aluFaceVertex(int face, int localVertex)
Definition: topology.hh:272
Dune::error
Definition: topology.hh:12
Dune::ElementTopologyMapping::generic2aluVertex
static int generic2aluVertex(const int index)
Definition: topology.hh:251
Dune::ElementTopologyMapping::numEdges
Definition: topology.hh:44
Dune::ElementTopologyMapping::duneFaceTwist
static int duneFaceTwist(int face)
obtain twist of ALU reference face with respect to DUNE reference face
Definition: topology.hh:287
Dune::ElementTopologyMapping::alu2genericVertex
static int alu2genericVertex(const int index)
Definition: topology.hh:258
Dune::ElementTopologyMapping::numVertices
Definition: topology.hh:43
alugrid_assert
#define alugrid_assert(EX)
Definition: alugrid_assert.hh:20
Dune::ElementTopologyMapping::dune2aluVertex
static int dune2aluVertex(int index)
Maps vertex index from Dune onto ALU3dGrid reference element.
Definition: topology.hh:224
Dune::FaceTopologyMapping::twistedDuneIndex
static int twistedDuneIndex(const int idx, const int twist)
Definition: topology.hh:352
Dune::FaceTopologyMapping
Definition: topology.hh:151
Dune::ElementTopologyMapping::numFaces
Definition: topology.hh:42
Dune::FaceTopologyMapping::dune2aluVertex
static int dune2aluVertex(int index)
Maps vertex index from Dune onto ALU3dGrid reference face.
Definition: topology.hh:310
Dune::FaceTopologyMapping::invTwist
static int invTwist(int index, int faceTwist)
Dune::FaceTopologyMapping::alu2duneEdge
static int alu2duneEdge(int index)
Maps edge index from ALU3dGrid onto Dune reference face.
Definition: topology.hh:335
Dune::ALU3dGridElementType
ALU3dGridElementType
Definition: topology.hh:12
Dune::ElementTopologyMapping::alu2genericFace
static int alu2genericFace(const int index)
Definition: topology.hh:244
Dune::ElementTopologyMapping::duneEdgeMap
static std::pair< int, int > duneEdgeMap(int edge)
Definition: topology.hh:294
Dune::ElementTopologyMapping::faceOrientation
static int faceOrientation(int index)
Definition: topology.hh:265
Dune::ElementTopologyMapping::alu2duneFaceVertex
static int alu2duneFaceVertex(int face, int localVertex)
Definition: topology.hh:280
Dune::ElementTopologyMapping::generic2aluFace
static int generic2aluFace(const int index)
Definition: topology.hh:237
Dune::ElementTopologyMapping::faceVertex
static int faceVertex(int face, int local)
Maps a local vertex on a face onto a global vertex.
Definition: topology.hh:301
Dune::FaceTopologyMapping::twist
static int twist(int index, int faceTwist)
Dune
Definition: alu3dinclude.hh:79
Dune::ElementTopologyMapping::numVerticesPerFace
Definition: topology.hh:45