1 #ifndef DUNE_FEM_ALU3DGRIDTOPOLOGY_HH
2 #define DUNE_FEM_ALU3DGRIDTOPOLOGY_HH
3 
4 //- system includes
5 #include <cassert>
6 
7 namespace Dune
8 {
9 
10   namespace Fem
11   {
12 
13     // types of the elementes,
14     // i.e . tetra or hexa, mixed is not implemeneted
15     enum ALU3dGridElementType { tetra = 4, hexa = 7, mixed, error };
16 
17     template <ALU3dGridElementType type>
18     struct EntityCount {};
19 
20     template <>
21     struct EntityCount<tetra> {
22       enum {numFaces = 4};
23       enum {numVertices = 4};
24       enum {numEdges = 6};
25       enum {numVerticesPerFace = 3};
26       enum {numEdgesPerFace = 3};
27     };
28 
29     template <>
30     struct EntityCount<hexa> {
31       enum {numFaces = 6};
32       enum {numVertices = 8};
33       enum {numEdges = 12};
34       enum {numVerticesPerFace = 4};
35       enum {numEdgesPerFace = 4};
36     };
37 
38 
39     //! Maps indices of the Dune reference face onto the indices of the
40     //! ALU3dGrid reference face and vice-versa.
41     template <ALU3dGridElementType type>
42     class FaceTopologyMapping {
43     public:
44       //! Maps vertex index from Dune onto ALU3dGrid reference face
45       static int dune2aluVertex(int index);
46       //! Maps vertex index from Dune onto ALU3dGrid reference face, where the
47       //! face in the ALU3dGrid has the twist <i>twist</i> compared to the orientation
48       //! of the respective face in the reference element
49       //! \param index local Dune vertex index on the particular face (i.e. the
50       //! face which has a twist <i>twist</i> compared to the reference element's face
51       //! \param twist twist of the face in consideration
52       //! \return local ALU3dGrid vertex index on reference element face
53       static int dune2aluVertex(int index, int twist);
54       //! Maps vertex index from ALU3dGrid onto Dune reference face
55       static int alu2duneVertex(int index);
56       //! Maps vertex index from ALU3dGrid onto Dune reference face, where the
57       //! face in the ALU3dGrid has the twist <i>twist</i> compared to the orientation
58       //! of the respective face in the reference element
59       //! \param index local ALU3dGrid vertex index on the particular face (i.e.
60       //! the face which has a twist <i>twist</i> compared to the reference element's
61       //! face
62       //! \param twist twist of the face in consideration
63       //! \return local Dune vertex index on reference element face
64       static int alu2duneVertex(int index, int twist);
65       //! Maps edge index from Dune onto ALU3dGrid reference face
66       static int dune2aluEdge(int index);
67       //! Maps edge index from ALU3dGrid onto Dune reference face
68       static int alu2duneEdge(int index);
69       //  private:
70       static int twist(int index, int faceTwist);
71       static int invTwist(int index, int faceTwist);
72 
73       static int twistedDuneIndex( const int idx, const int twist );
74 
75       // for each aluTwist apply additional mapping
76       static int aluTwistMap(const int aluTwist);
77     private:
78       const static int dune2aluVertex_[EntityCount<type>::numVerticesPerFace];
79       const static int alu2duneVertex_[EntityCount<type>::numVerticesPerFace];
80 
81       const static int dune2aluEdge_[EntityCount<type>::numEdgesPerFace];
82       const static int alu2duneEdge_[EntityCount<type>::numEdgesPerFace];
83 
84       const static int alu2duneTwist_[ 2 * EntityCount<type>::numVerticesPerFace ];
85       const static int aluTwistMap_[ 2 * EntityCount<type>::numVerticesPerFace ];
86     };
87 
88   } // namespace Fem
89 
90 } // namespace Dune
91 
92 #endif // #ifndef DUNE_FEM_ALU3DGRIDTOPOLOGY_HH
93