MacroElement.h 6.73 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
// ============================================================================
// ==                                                                        ==
// == 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();

68
69
    MacroElement& operator=(const MacroElement &el);

70
71
72
73
74
75
76
77
78
    // ===== getting methods ======================================================

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

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

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

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

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

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

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

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

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

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

    /** \} */

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

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

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

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

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


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

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

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

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

202
    inline void setCoord(int i, const WorldVector<double> c) {
203
      coord[i] = c;
204
    }
205
206
207
208
209

    /** \} */

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

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

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

214
    inline void writeNeighboursTo(std::vector<int> *indices) {
215
      deserializedNeighbourIndices_ = indices;
216
217
218
    }

    int calcMemoryUsage();
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
257
258
259
260

  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;  

261
262
263
    /** \brief
     *
     */
264
    std::vector<int> *deserializedNeighbourIndices_;
265
266
267
268
269
270
271
272
273
274
275
276
277

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

}


#endif  // AMDIS_MACROELEMENT_H