ElementObjectData.h 6.42 KB
Newer Older
Thomas Witkowski's avatar
Thomas Witkowski committed
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
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  TU Dresden                                                            ==
// ==                                                                        ==
// ==  Institut fr Wissenschaftliches Rechnen                               ==
// ==  Zellescher Weg 12-14                                                  ==
// ==  01069 Dresden                                                         ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  https://gforge.zih.tu-dresden.de/projects/amdis/                      ==
// ==                                                                        ==
// ============================================================================

/** \file ElementObjectData.h */

#ifndef AMDIS_ELEMENTOBJECTDATA_H
#define AMDIS_ELEMENTOBJECTDATA_H

#include <map>
#include <vector>
#include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_comparison.hpp>

#include "Global.h"
#include "Boundary.h"

namespace AMDiS {

  struct ElementObjectData {
    ElementObjectData(int a = -1, int b = 0, BoundaryType c = INTERIOR)
      : elIndex(a),
	ithObject(b),
	boundaryType(c)
    {}
    
    int elIndex;
    
    int ithObject;
    
    BoundaryType boundaryType;
  };



  class ElementObjects {
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
53
54
    ElementObjects()
      : iterGeoPos(CENTER)
Thomas Witkowski's avatar
Thomas Witkowski committed
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
    {}

    void addVertex(DegreeOfFreedom vertex, 
		   int elIndex, int ith, BoundaryType bound = INTERIOR)
    {
      vertexElements[vertex].push_back(ElementObjectData(elIndex, ith, bound));
    }

    void addEdge(DofEdge edge, 
		 int elIndex, int ith, BoundaryType bound = INTERIOR)
    {
      edgeElements[edge].push_back(ElementObjectData(elIndex, ith, bound));
    }

    void addFace(DofFace face, 
		 int elIndex, int ith, BoundaryType bound = INTERIOR)
    {
      faceElements[face].push_back(ElementObjectData(elIndex, ith, bound));
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
75
    void createRankData(std::map<int, int>& macroElementRankMap);
Thomas Witkowski's avatar
Thomas Witkowski committed
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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

    bool iterate(GeoIndex pos)
    {
      if (iterGeoPos == CENTER) {
	iterGeoPos = pos;
	switch (iterGeoPos) {
	case VERTEX:
	  vertexIter = vertexInRank.begin();
	  break;
	case EDGE:
	  edgeIter = edgeInRank.begin();
	  break;
	case FACE:
	  faceIter = faceInRank.begin();
	  break;
	default:
	  ERROR_EXIT("Not GeoIndex %d!\n", iterGeoPos);
	}
      } else {
	switch (iterGeoPos) {
	case VERTEX:
	  ++vertexIter;
	  break;
	case EDGE:
	  ++edgeIter;
	  break;
	case FACE:
	  ++faceIter;
	  break;
	default:
	  ERROR_EXIT("Not GeoIndex %d!\n", iterGeoPos);
	}
      }

      switch (iterGeoPos) {
      case VERTEX:
	if (vertexIter == vertexInRank.end()) {
	  iterGeoPos = CENTER;
	  return false;
	}
	break;
      case EDGE:
	if (edgeIter == edgeInRank.end()) {
	  iterGeoPos = CENTER;
	  return false;
	}
	break;
      case FACE:
	if (faceIter == faceInRank.end()) {
	  iterGeoPos = CENTER;
	  return false;
	}
	break;
      default:
	ERROR_EXIT("Should not happen!\n");	
      }

      return true;
    }


    std::map<int, ElementObjectData>& getIterateData()
    {
      switch (iterGeoPos) {
      case VERTEX:
	return vertexIter->second;
	break;
      case EDGE:
	return edgeIter->second;
	break;
      case FACE:
	return faceIter->second;
	break;
      default:
	ERROR_EXIT("Should not happen!\n");

	// Will never be reached, just to avoid compiler warnings.
	return faceIter->second;
      }
    }


    int getIterateOwner()
    {
      switch (iterGeoPos) {
      case VERTEX:
	return vertexOwner[vertexIter->first];
	break;
      case EDGE:
	return edgeOwner[edgeIter->first];
	break;
      case FACE:
	return faceOwner[faceIter->first];
	break;
      default:
	ERROR_EXIT("Should not happen!\n");

	// Will never be reached, just to avoid compiler warnings.
	return -1;
      }
    }

178

Thomas Witkowski's avatar
Thomas Witkowski committed
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
    int getOwner(DegreeOfFreedom vertex)
    {
      return vertexOwner[vertex];
    }

    int getOwner(DofEdge edge)
    {
      return edgeOwner[edge];
    }

    int getOwner(DofFace face)
    {
      return faceOwner[face];
    }

194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210

    int isInRank(DegreeOfFreedom vertex, int rank)
    {
      return (vertexInRank[vertex].count(rank));
    }

    int isInRank(DofEdge edge, int rank)
    {
      return (edgeInRank[edge].count(rank));
    }

    int isInRank(DofFace face, int rank)
    {
      return (faceInRank[face].count(rank));
    }


Thomas Witkowski's avatar
Thomas Witkowski committed
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
    std::vector<ElementObjectData>& getElements(DegreeOfFreedom vertex)
    {
      return vertexElements[vertex];
    }

    std::vector<ElementObjectData>& getElements(DofEdge edge)
    {
      return edgeElements[edge];
    }

    std::vector<ElementObjectData>& getElements(DofFace face)
    {
      return faceElements[face];
    }

226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241

    std::map<int, ElementObjectData>& getElementsInRank(DegreeOfFreedom vertex)
    {
      return vertexInRank[vertex];
    }

    std::map<int, ElementObjectData>& getElementsInRank(DofEdge edge)
    {
      return edgeInRank[edge];
    }

    std::map<int, ElementObjectData>& getElementsInRank(DofFace face)
    {
      return faceInRank[face];
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
  private:
    std::map<DegreeOfFreedom, std::vector<ElementObjectData> > vertexElements;
    std::map<DofEdge, std::vector<ElementObjectData> > edgeElements;
    std::map<DofFace, std::vector<ElementObjectData> > faceElements;

    std::map<DegreeOfFreedom, int> vertexOwner;
    std::map<DofEdge, int> edgeOwner;
    std::map<DofFace, int> faceOwner;

    std::map<DegreeOfFreedom, std::map<int, ElementObjectData> > vertexInRank;
    std::map<DofEdge, std::map<int, ElementObjectData> > edgeInRank;
    std::map<DofFace, std::map<int, ElementObjectData> > faceInRank;

    std::map<DegreeOfFreedom, std::map<int, ElementObjectData> >::iterator vertexIter;
    std::map<DofEdge, std::map<int, ElementObjectData> >::iterator edgeIter;
    std::map<DofFace, std::map<int, ElementObjectData> >::iterator faceIter;

    GeoIndex iterGeoPos;
  };

}

#endif