1
#ifndef DUNE_ALU3DGRIDTOPOLOGY_HH
2
#define DUNE_ALU3DGRIDTOPOLOGY_HH
9
// types of the elementes,
10
// i.e . tetra or hexa, mixed is not implemeneted
11
enum ALU3dGridElementType { tetra = 4, hexa = 7, mixed, error };
13
template <ALU3dGridElementType type>
14
struct EntityCount {};
17
struct EntityCount<tetra> {
19
enum {numVertices = 4};
21
enum {numVerticesPerFace = 3};
22
enum {numEdgesPerFace = 3};
26
struct EntityCount<hexa> {
28
enum {numVertices = 8};
30
enum {numVerticesPerFace = 4};
31
enum {numEdgesPerFace = 4};
35
//! Maps indices of the Dune reference element onto the indices of the
36
//! ALU3dGrid reference element and vice-versa.
37
template <ALU3dGridElementType type>
38
class ElementTopologyMapping
41
enum { numFaces = EntityCount<type>::numFaces };
42
enum { numVertices = EntityCount<type>::numVertices };
43
enum { numEdges = EntityCount<type>::numEdges };
44
enum { numVerticesPerFace = EntityCount<type>::numVerticesPerFace };
46
//! Maps face index from Dune onto ALU3dGrid reference element
47
static int dune2aluFace(int index);
48
//! Maps face index from ALU3dGrid onto Dune reference element
49
static int alu2duneFace(int index);
51
//! Maps edge index from Dune onto ALU3dGrid reference element
52
static int dune2aluEdge(int index);
53
//! Maps edge index from ALU3dGrid onto Dune reference element
54
static int alu2duneEdge(int index);
56
//! Maps vertex index from Dune onto ALU3dGrid reference element
57
static int dune2aluVertex(int index);
58
//! Maps vertex index from ALU3dGrid onto Dune reference element
59
static int alu2duneVertex(int index);
61
static int generic2aluFace ( const int index );
62
static int alu2genericFace ( const int index );
64
static int generic2aluVertex ( const int index );
65
static int alu2genericVertex ( const int index );
67
//! Return 1 if faces in ALU3dGrid and Dune reference element
68
//! have the same orientation (edge 0->1 is taken as reference as
69
//! they are the same in both reference elements), -1 otherwise.
70
//! The index is a Dune face index
71
static int faceOrientation(int index);
73
//! Maps local vertex index of a face onto a global vertex index
75
//! \param face Face index (Dune reference element)
76
//! \param localVertex Local vertex index on face <i>face</i> (Dune reference
78
//! \return global vertex index in ALU3dGrid reference element
79
static int dune2aluFaceVertex(int face, int localVertex);
80
//! Maps local vertex index of a face onto a global vertex index
82
//! \param face Face index (ALU3dGrid reference element)
83
//! \param localVertex Local vertex index on face <i>face</i>
84
//! (ALU3dGrid reference element)
85
//! \return global vertex index in Dune reference element
86
static int alu2duneFaceVertex(int face, int localVertex);
88
/** \brief Maps a local vertex on a face onto a global vertex
90
* \param[in] face index of the face (with respect to ALU reference
92
* \param[in] local local index of vertex on the face
93
* \returns global index of vertex in ALU reference element
95
static int faceVertex ( int face, int local );
98
const static int dune2aluFace_[numFaces];
99
const static int alu2duneFace_[numFaces];
101
const static int dune2aluEdge_[numEdges];
102
const static int alu2duneEdge_[numEdges];
104
const static int dune2aluVertex_[numVertices];
105
const static int alu2duneVertex_[numVertices];
107
static const int generic2aluFace_[ numFaces ];
108
static const int alu2genericFace_[ numFaces ];
110
static const int generic2aluVertex_[ numVertices ];
111
static const int alu2genericVertex_[ numVertices ];
113
const static int faceOrientation_[numFaces];
115
const static int dune2aluFaceVertex_[numFaces][numVerticesPerFace];
116
const static int alu2duneFaceVertex_[numFaces][numVerticesPerFace];
118
static const int faceVertex_[ numFaces ][ numVerticesPerFace ];
121
//! Maps indices of the Dune reference face onto the indices of the
122
//! ALU3dGrid reference face and vice-versa.
123
template <ALU3dGridElementType type>
124
class FaceTopologyMapping {
126
//! Maps vertex index from Dune onto ALU3dGrid reference face
127
static int dune2aluVertex(int index);
128
//! Maps vertex index from Dune onto ALU3dGrid reference face, where the
129
//! face in the ALU3dGrid has the twist <i>twist</i> compared to the orientation
130
//! of the respective face in the reference element
131
//! \param index local Dune vertex index on the particular face (i.e. the
132
//! face which has a twist <i>twist</i> compared to the reference element's face
133
//! \param twist twist of the face in consideration
134
//! \return local ALU3dGrid vertex index on reference element face
135
static int dune2aluVertex(int index, int twist);
136
//! Maps vertex index from ALU3dGrid onto Dune reference face
137
static int alu2duneVertex(int index);
138
//! Maps vertex index from ALU3dGrid onto Dune reference face, where the
139
//! face in the ALU3dGrid has the twist <i>twist</i> compared to the orientation
140
//! of the respective face in the reference element
141
//! \param index local ALU3dGrid vertex index on the particular face (i.e.
142
//! the face which has a twist <i>twist</i> compared to the reference element's
144
//! \param twist twist of the face in consideration
145
//! \return local Dune vertex index on reference element face
146
static int alu2duneVertex(int index, int twist);
147
//! Maps edge index from Dune onto ALU3dGrid reference face
148
static int dune2aluEdge(int index);
149
//! Maps edge index from ALU3dGrid onto Dune reference face
150
static int alu2duneEdge(int index);
152
static int twist(int index, int faceTwist);
153
static int invTwist(int index, int faceTwist);
155
static int twistedDuneIndex( const int idx, const int twist );
157
// for each aluTwist apply additional mapping
158
static int aluTwistMap(const int aluTwist);
160
const static int dune2aluVertex_[EntityCount<type>::numVerticesPerFace];
161
const static int alu2duneVertex_[EntityCount<type>::numVerticesPerFace];
163
const static int dune2aluEdge_[EntityCount<type>::numEdgesPerFace];
164
const static int alu2duneEdge_[EntityCount<type>::numEdgesPerFace];
166
const static int alu2duneTwist_[ 2 * EntityCount<type>::numVerticesPerFace ];
167
const static int aluTwistMap_[ 2 * EntityCount<type>::numVerticesPerFace ];
171
//- class ElementTopologyMapping
172
template <ALU3dGridElementType type>
173
inline int ElementTopologyMapping<type>::dune2aluFace(int index) {
174
assert(index >= 0 && index < numFaces);
175
return dune2aluFace_[index];
178
template <ALU3dGridElementType type>
179
inline int ElementTopologyMapping<type>::alu2duneFace(int index) {
180
assert(index >= 0 && index < numFaces);
181
return alu2duneFace_[index];
184
template <ALU3dGridElementType type>
185
inline int ElementTopologyMapping<type>::dune2aluEdge(int index) {
186
assert(index >= 0 && index < numEdges);
187
return dune2aluEdge_[index];
190
template <ALU3dGridElementType type>
191
inline int ElementTopologyMapping<type>::alu2duneEdge(int index) {
192
assert(index >= 0 && index < numEdges);
193
return alu2duneEdge_[index];
196
template <ALU3dGridElementType type>
197
inline int ElementTopologyMapping<type>::dune2aluVertex(int index)
199
assert(index >= 0 && index < numVertices);
200
return dune2aluVertex_[index];
203
template <ALU3dGridElementType type>
204
inline int ElementTopologyMapping<type>::alu2duneVertex(int index) {
205
assert(index >= 0 && index < numVertices);
206
return alu2duneVertex_[index];
209
template< ALU3dGridElementType type >
210
inline int ElementTopologyMapping< type >::generic2aluFace ( const int index )
212
assert( (index >= 0) && (index < numFaces) );
213
return generic2aluFace_[ index ];
216
template< ALU3dGridElementType type >
217
inline int ElementTopologyMapping< type >::alu2genericFace ( const int index )
219
assert( (index >= 0) && (index < numFaces) );
220
return alu2genericFace_[ index ];
223
template< ALU3dGridElementType type >
224
inline int ElementTopologyMapping< type >::generic2aluVertex ( const int index )
226
assert( (index >= 0) && (index < numVertices) );
227
return generic2aluVertex_[ index ];
230
template< ALU3dGridElementType type >
231
inline int ElementTopologyMapping< type >::alu2genericVertex ( const int index )
233
assert( (index >= 0) && (index < numVertices) );
234
return alu2genericVertex_[ index ];
237
template <ALU3dGridElementType type>
238
inline int ElementTopologyMapping<type>::faceOrientation(int index) {
239
assert(index >= 0 && index < numVertices);
240
return faceOrientation_[index];
243
template <ALU3dGridElementType type>
244
inline int ElementTopologyMapping<type>::
245
dune2aluFaceVertex(int face, int localVertex) {
246
assert(face >= 0 && face < numFaces);
247
assert(localVertex >= 0 && localVertex < numVerticesPerFace);
248
return dune2aluFaceVertex_[face][localVertex];
251
template <ALU3dGridElementType type>
252
inline int ElementTopologyMapping<type>::
253
alu2duneFaceVertex(int face, int localVertex) {
254
assert(face >= 0 && face < numFaces);
255
assert(localVertex >= 0 && localVertex < numVerticesPerFace);
256
return alu2duneFaceVertex_[face][localVertex];
259
template< ALU3dGridElementType type >
260
inline int ElementTopologyMapping< type >::faceVertex ( int face, int local )
262
assert( (face >= 0) && (face < numFaces) );
263
assert( (local >= 0) && (local < numVerticesPerFace) );
264
return faceVertex_[ face ][ local ];
267
//- class FaceTopologyMapping
268
template <ALU3dGridElementType type>
269
inline int FaceTopologyMapping<type>::dune2aluVertex(int index) {
270
assert(index >= 0 && index < EntityCount<type>::numVerticesPerFace);
271
return dune2aluVertex_[index];
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);
280
template <ALU3dGridElementType type>
281
inline int FaceTopologyMapping<type>::alu2duneVertex(int index) {
282
assert(index >= 0 && index < EntityCount<type>::numVerticesPerFace);
283
return alu2duneVertex_[index];
286
template <ALU3dGridElementType type>
287
inline int FaceTopologyMapping<type>::alu2duneVertex(int index, int twist)
289
assert(index >= 0 && index < EntityCount<type>::numVerticesPerFace);
290
return alu2duneVertex_[invTwist(index, twist)];
293
template <ALU3dGridElementType type>
294
inline int FaceTopologyMapping<type>::alu2duneEdge(int index) {
295
assert(index >= 0 && index < EntityCount<type>::numEdgesPerFace);
296
return alu2duneEdge_[index];
299
template <ALU3dGridElementType type>
300
inline int FaceTopologyMapping<type>::
301
aluTwistMap(const int aluTwist)
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) ];
309
template <ALU3dGridElementType type>
310
inline int FaceTopologyMapping<type>::
311
twistedDuneIndex(const int duneIdx, const int aluTwist)
315
// apply alu2dune twist mapping (only for tetra)
316
const int twist = alu2duneTwist_[ aluTwist + 3 ];
317
return alu2duneVertex( dune2aluVertex(duneIdx) , twist );
320
return alu2duneVertex( dune2aluVertex(duneIdx) , aluTwist );
323
template <ALU3dGridElementType type>
324
inline int FaceTopologyMapping<type>::dune2aluEdge(int index) {
325
assert(index >= 0 && index < EntityCount<type>::numEdgesPerFace);
326
return dune2aluEdge_[index];
329
} // end namespace Dune