Tetrahedron.h 7.11 KB
Newer Older
1
2
3
4
5
6
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
7
// ==  TU Dresden                                                            ==
8
// ==                                                                        ==
9
10
11
// ==  Institut fr Wissenschaftliches Rechnen                               ==
// ==  Zellescher Weg 12-14                                                  ==
// ==  01069 Dresden                                                         ==
12
13
14
15
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
16
// ==  https://gforge.zih.tu-dresden.de/projects/amdis/                      ==
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// ==                                                                        ==
// ============================================================================

/** \file Tetrahedron.h */

#ifndef AMDIS_TETRAHEDRON_H
#define AMDIS_TETRAHEDRON_H

#include "Element.h"

namespace AMDiS {

  /** \ingroup Triangulation 
   * \brief
   * A Tetrahedron is a 3-dimensional Element. 
   *
   * A Tetrahedron and its refinements:
   *
   * <img src = "tetrahedron.png">
   */
  class Tetrahedron : public Element
  {
  public:
40
41
42
43
44
    
    /// calls base class contructor.
    Tetrahedron(Mesh* aMesh) 
      : Element(aMesh) 
    {}
45

46
    /// implements Element::clone
47
    inline Element *clone() { 
Thomas Witkowski's avatar
Thomas Witkowski committed
48
      return new Tetrahedron(mesh); 
49
    }
50

51
    /// implements Element::getVertexOfEdge
52
53
    inline int getVertexOfEdge(int i, int j) const 
    {
54
      return vertexOfEdge[i][j];
55
    }
56

57
    /// implements Element::getVertexOfPosition
58
    int getVertexOfPosition(GeoIndex position,
59
60
			    int positionIndex,
			    int vertexIndex) const;
61
62


63
64
    virtual int getPositionOfVertex(int side, int vertex) const 
    {
65
66
67
68
69
      static int positionOfVertex[4][4] = {{-1,0,1,2},
					   {0,-1,1,2},
					   {0,1,-1,2},
					   {0,1,2,-1}};
      return positionOfVertex[side][vertex];
70
    }
71

72
    /// implements Element::getGeo
73
74
75
    inline int getGeo(GeoIndex i) const 
    {
      switch (i) {
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
      case VERTEX: case PARTS: case NEIGH:
	return 4;
	break;
      case EDGE:
	return 6;
      case FACE:
	return 4;
      case CENTER:
	return 1;
	break;
      case DIMEN:
	return 3;
	break;
      case BOUNDARY:
	return 14;
	break;
      case PROJECTION:
	return 10;
	break;
      default:
	ERROR_EXIT("invalid geo-index\n");
	return 0;
      }
99
    }
100

101
    /// implements Element::hasSide
102
103
    bool hasSide(Element* sideElem) const;

104
    /// implements Element::sortFaceIndices
105
106
107
    const FixVec<int,WORLD>& sortFaceIndices(int face, 
					     FixVec<int,WORLD> *vec) const;

108
    /// implements Element::isLine. Returns false because this element is a Tetrahedron
109
110
    inline bool isLine() const 
    { 
111
      return false; 
112
    }
113
114
115
116
117

    /** \brief
     * implements Element::isTriangle. Returns false because this element is a 
     * Tetrahedron
     */
118
119
    inline bool isTriangle() const 
    { 
120
      return false; 
121
    }
122
123
124
125
126
 
    /** \brief
     * implements Element::isTetrahedron. Returns true because this element is a 
     * Tetrahedron
     */
127
128
    inline bool isTetrahedron() const 
    { 
129
      return true; 
130
131
    }
 
132
133
    std::string getTypeName() const 
    { 
134
      return "Tetrahedron"; 
135
    }
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182

  public:
    /** \brief
     * nChildEdge[el_type][ichild][dir]                                      
     * gives local index of new edge on child[ichild] part of face [2+dir] on
     * the parent  
     */
    static const unsigned char nChildEdge[3][2][2];

    /** \brief
     * nChildFace[el_type][ichild][dir]                                     
     * gives local index of sub-face on child[ichild] part of face [2+dir] on
     * the parent   
     */
    static const unsigned char nChildFace[3][2][2];

    /** \brief
     * childVertex[el_type][child][i] =
     * parent's local vertex index of new vertex i.
     * 4 stands for the newly generated vertex                            
     */
    static const int childVertex[3][2][4];
 
    /** \brief
     * childEdge[el_type][child][i] =
     * parent's local edge index of new edge i
     * new edge 2 is half of old edge 0,
     * new edges 4,5 are really new edges, and value is different:
     * childEdge[][][4,5] = index of same edge in other child
     */
    static const int childEdge[3][2][6];

    /** \brief
     * adjacentChild[position][ichild]                                      
     * gives number of the adjacent child on a neighbour element:             
     *   position = 0  same position of element and neigh at refinement edge, 
     *   position = 1  different ...                                         
     */
    static const unsigned char adjacentChild[2][2];

    /** \brief
     * childOrientation[el_type][child] =
     *   +1 if orientation is not changed during refinement, 
     *   -1 if orientation is changed during refinement
     */
    static const signed char childOrientation[3][2];

183
    /// edgeOfDOFs[i][j]: gives the local index of edge with vertices i and j 
184
185
    static const unsigned char edgeOfDOFs[4][4];

186
    ///
187
188
    static const int edgeOfFace[4][3];

189
    /// implements Element::getSideOfChild()
190
191
    virtual int getSideOfChild(int child, int side, int elType = 0) const 
    {
192
      FUNCNAME("Tetrahedron::getSideOfChild()");
193
194
195
      TEST_EXIT_DBG(child==0 || child==1)("child must be in (0,1)\n");
      TEST_EXIT_DBG(side >= 0 && side <= 3)("side must be between 0 and 3\n");
      TEST_EXIT_DBG(elType >= 0 && elType <= 2)("elType must be between 0 and 2\n");
196
      return sideOfChild[elType][child][side];
197
    }
198

199
    /// implements Element::getVertexOfParent()
200
201
    virtual int getVertexOfParent(int child, int side, int elType = 0) const 
    {
202
      FUNCNAME("Tetrahedron::getVertexOfParent()");
203
204
205
      TEST_EXIT_DBG(child==0 || child==1)("child must be in (0,1)\n");
      TEST_EXIT_DBG(side >= 0 && side <= 3)("side must be between 0 and 3\n");
      TEST_EXIT_DBG(elType >= 0 && elType <= 2)("elType must be between 0 and 2\n");
206
      return vertexOfParent[elType][child][side];
207
    }
208

209
210
    inline int getEdgeOfFace(int face, int edge) const 
    {
211
212
      TEST_EXIT_DBG(face >= 0 && face < 4)("invalid face\n");
      TEST_EXIT_DBG(edge >= 0 && edge < 3)("invalid edge\n");
213
      return edgeOfFace[face][edge];
214
    }
215
216
217

  protected:

218
    /// vertexOfEdge[i][j] is the local number of the j-vertex of edge i
219
220
    static const int vertexOfEdge[6][2]; 

221
    /// vertexOfFace[i][j] is the local number of the j-vertex of face i
222
223
    static const int vertexOfFace[4][3];

224
    ///
225
    static const int sideOfChild[3][2][4];
226

227
    ///
228
229
230
231
232
233
    static const int vertexOfParent[3][2][4];
  };

}

#endif // AMDIS_TETRAHEDRON_H