MacroElement.h 6.67 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  crystal growth group                                                  ==
// ==                                                                        ==
// ==  Stiftung caesar                                                       ==
// ==  Ludwig-Erhard-Allee 2                                                 ==
// ==  53175 Bonn                                                            ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  http://www.caesar.de/cg/AMDiS                                         ==
// ==                                                                        ==
// ============================================================================

/** \file MacroElement.h */

#ifndef AMDIS_MACROELEMENT_H
#define AMDIS_MACROELEMENT_H

#include <deque>
#include <stdio.h>
#include "Boundary.h"
#include "Global.h"
#include "MemoryManager.h"
#include "Projection.h"
#include "FixVec.h"
#include "Serializable.h"

namespace AMDiS {

  class Element;
  class ElInfo;
  class Mesh;

  template<typename T> class WorldVector;
  template<typename T> class DimVec;

  // ============================================================================
  // ===== class MacroElement ===================================================
  // ============================================================================

  /** \ingroup Triangulation
   * \brief
   * MacroElements form the macro triangulation of a Mesh. In a MacroElement
   * geometrical information are stored, which are used in mesh traversal,
   * to calculate the desired information and fill it in an ElInfo object. 
   */ 
  class MacroElement : public Serializable
  {
  public:
    MEMORY_MANAGED(MacroElement);

    /** \brief
     * Creates a new MacroElement. The mesh is needed only to get the dimension
     */
    MacroElement(int dim); 

    /** \brief
     * Destructor.
     */
    virtual ~MacroElement();

    // ===== getting methods ======================================================

    /** \name getting methods
     * \{
     */

    /** \brief
     * Returns \ref index.
     */
77
    inline int getIndex() const {
78
79
80
81
82
83
      return index; 
    };

    /** \brief
     * Returns ref projection[i]. 
     */
84
    inline Projection *getProjection(int i) const {
85
86
87
88
89
90
      return projection[i];
    };

    /** \brief
     * Returns \ref el
     */
91
    inline Element* getElement() const {
92
93
94
95
96
97
      return element; 
    };

    /** \brief
     * Returns the i-th neighbour of this MacroElement \ref neighbour[i]
     */
98
    inline MacroElement* getNeighbour(int i) const {
99
100
101
102
103
104
      return neighbour[i];
    };

    /** \brief
     * Returns the i-th opp-vertex of this MacroElement \ref oppVertex[i]
     */
105
    inline char getOppVertex(int i) const {
106
107
108
109
110
111
      return oppVertex[i];
    };

    /** \brief
     * Returns \ref coord[i]
     */
112
    inline WorldVector<double>& getCoord(int i) {
113
114
115
116
117
118
      return coord[i];    
    };

    /** \brief
     * Returns \ref coord
     */
119
    inline FixVec<WorldVector<double>, VERTEX>& getCoord() {
120
121
122
123
124
125
      return coord;    
    };

    /** \brief
     * Returns \ref boundary[i]
     */
126
    inline BoundaryType getBoundary(int i) const {
127
128
129
130
131
132
      return boundary[i]; 
    };

    /** \brief
     * Returns \ref elType
     */
133
    inline unsigned char getElType() const {
134
135
136
137
138
139
140
141
142
143
144
145
146
147
      return elType; 
    };

    /** \} */

    // ===== setting methods ======================================================

    /** \name setting methods
     * \{
     */

    /** \brief
     * Sets \ref index
     */
148
    inline void setIndex(int n) {
149
150
151
152
153
154
      index = n ; 
    };

    /** \brief
     * Sets \ref element if not yet set.
     */
155
156
157
158
159
160
161
    inline void setElement(Element* element_) {
      if (!element) {
	element = element_; 
      } else {
	if (element != element_) 
	  ERROR("Trying to change element in MacroElement\n");   
      }
162
163
164
165
166
    };

    /** \brief
     * Sets \ref elType
     */
167
168
    inline void setElType(unsigned char typ) {
      elType = typ; 
169
170
171
172
173
174
    };


    /** \brief
     * Sets \ref projection[i] = p.
     */
175
    inline void setProjection(int i, Projection *p) {
176
177
178
179
180
181
      projection[i] = p;
    };

    /** \brief
     * Sets the i-th Neighbour to n
     */
182
    inline void setNeighbour(int i, MacroElement *n) {
183
184
185
186
187
188
      neighbour[i] = n;
    };

    /** \brief
     * Sets the i-th opp vertex to c
     */
189
190
    inline void  setOppVertex(int i, char c) {
      oppVertex[i] = c;
191
192
193
194
195
    };

    /** \brief
     * Sets \ref boundary[i] to b
     */
196
    inline void setBoundary(int i, BoundaryType b) {
197
198
199
      boundary[i] = b; 
    };

200
    inline void setCoord(int i, const WorldVector<double> &c) {
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
      coord[i] = c;
    };

    /** \} */

    // ===== Serializable implementation =====

    void serialize(::std::ostream &out);

    void deserialize(::std::istream &in);

    inline void writeNeighboursTo(::std::vector<int> *indices) {
      deserializedNeighbourIndices_ = indices;
    };

  protected:
    /** \brief
     * Element of this MacroElement.
     */
    Element *element;

    /** \brief
     * Coordinates of the vertices.
     */
    FixVec<WorldVector<double>, VERTEX> coord;

    /** \brief
     * Boundary type of each boundary part (face/edge/vertex)
     */
    FixVec<BoundaryType, BOUNDARY> boundary;

    /** \brief
     * Boundary projection to curved boundaries or element projections.
     */
    FixVec<Projection*, PROJECTION> projection;

    /** \brief
     * Pointers to all neighbours of this MacroElement 
     */
    FixVec<MacroElement*, NEIGH> neighbour;

    /** \brief
     * opp vertices of this MacroElement
     */
    FixVec<char, NEIGH> oppVertex;

    /** \brief
     * index of this MacroElement
     */
    int index;  

    /** \brief
     * Element type of the MacroElement
     */
    unsigned char elType;  

257
258
259
    /** \brief
     *
     */
260
261
262
263
264
265
266
267
268
269
270
271
272
273
    ::std::vector<int> *deserializedNeighbourIndices_;

    // friend classes
    friend class MacroInfo;
    friend class MacroReader;
    friend class ElInfo1d;
    friend class ElInfo2d;
    friend class ElInfo3d;
  };

}


#endif  // AMDIS_MACROELEMENT_H