ElementObjectData.cc 6.76 KB
Newer Older
Thomas Witkowski's avatar
Thomas Witkowski committed
1
2
3
4
#include "ElementObjectData.h"

namespace AMDiS {

Thomas Witkowski's avatar
Thomas Witkowski committed
5
  void ElementObjects::createRankData(std::map<int, int>& macroElementRankMap) 
Thomas Witkowski's avatar
Thomas Witkowski committed
6
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
7
8
9
10
    FUNCNAME("ElementObjects::createRankData()");

    vertexOwner.clear();
    vertexInRank.clear();
Thomas Witkowski's avatar
Thomas Witkowski committed
11
12
    for (std::map<DegreeOfFreedom, std::vector<ElementObjectData> >::iterator it = vertexElements.begin();
	 it != vertexElements.end(); ++it) {
Thomas Witkowski's avatar
Thomas Witkowski committed
13
14
15
      for (std::vector<ElementObjectData>::iterator it2 = it->second.begin(); 
	   it2 != it->second.end(); ++it2) {
	int elementInRank = macroElementRankMap[it2->elIndex];
Thomas Witkowski's avatar
Thomas Witkowski committed
16
	
Thomas Witkowski's avatar
Thomas Witkowski committed
17
18
19
20
	if (it2->elIndex > vertexInRank[it->first][elementInRank].elIndex)
	  vertexInRank[it->first][elementInRank] = *it2;

	vertexOwner[it->first] = std::max(vertexOwner[it->first], elementInRank);
Thomas Witkowski's avatar
Thomas Witkowski committed
21
22
23
      }
    }
    
Thomas Witkowski's avatar
Thomas Witkowski committed
24
25
26

    edgeOwner.clear();
    edgeInRank.clear();
Thomas Witkowski's avatar
Thomas Witkowski committed
27
28
    for (std::map<DofEdge, std::vector<ElementObjectData> >::iterator it = edgeElements.begin();
	 it != edgeElements.end(); ++it) {
Thomas Witkowski's avatar
Thomas Witkowski committed
29
30
31
      for (std::vector<ElementObjectData>::iterator it2 = it->second.begin(); 
	   it2 != it->second.end(); ++it2) {
	int elementInRank = macroElementRankMap[it2->elIndex];
Thomas Witkowski's avatar
Thomas Witkowski committed
32
	
Thomas Witkowski's avatar
Thomas Witkowski committed
33
34
35
36
	if (it2->elIndex > edgeInRank[it->first][elementInRank].elIndex)
	  edgeInRank[it->first][elementInRank] = *it2;

	edgeOwner[it->first] = std::max(edgeOwner[it->first], elementInRank);
Thomas Witkowski's avatar
Thomas Witkowski committed
37
38
39
      }
    }
    
Thomas Witkowski's avatar
Thomas Witkowski committed
40
41
42

    faceOwner.clear();
    faceInRank.clear();
Thomas Witkowski's avatar
Thomas Witkowski committed
43
44
    for (std::map<DofFace, std::vector<ElementObjectData> >::iterator it = faceElements.begin();
	 it != faceElements.end(); ++it) {
Thomas Witkowski's avatar
Thomas Witkowski committed
45
46
47
      for (std::vector<ElementObjectData>::iterator it2 = it->second.begin(); 
	   it2 != it->second.end(); ++it2) {
	int elementInRank = macroElementRankMap[it2->elIndex];
Thomas Witkowski's avatar
Thomas Witkowski committed
48
	
Thomas Witkowski's avatar
Thomas Witkowski committed
49
50
51
52
	if (it2->elIndex > faceInRank[it->first][elementInRank].elIndex)
	  faceInRank[it->first][elementInRank] = *it2;

	faceOwner[it->first] = std::max(faceOwner[it->first], elementInRank);
Thomas Witkowski's avatar
Thomas Witkowski committed
53
54
55
56
      }
    }
  }

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

  void ElementObjects::serialize(std::ostream &out)
  {
    FUNCNAME("ElementObjects::serialize()");

    int nSize = vertexElements.size();
    SerUtil::serialize(out, nSize);
    for (std::map<DegreeOfFreedom, std::vector<ElementObjectData> >::iterator it = vertexElements.begin();
	 it != vertexElements.end(); ++it) {
      SerUtil::serialize(out, it->first);
      serialize(out, it->second);
    }

    nSize = edgeElements.size();
    SerUtil::serialize(out, nSize);
    for (std::map<DofEdge, std::vector<ElementObjectData> >::iterator it = edgeElements.begin();
	 it != edgeElements.end(); ++it) {
      SerUtil::serialize(out, it->first);
      serialize(out, it->second);
    }

    nSize = faceElements.size();
    SerUtil::serialize(out, nSize);
    for (std::map<DofFace, std::vector<ElementObjectData> >::iterator it = faceElements.begin();
	 it != faceElements.end(); ++it) {
      SerUtil::serialize(out, it->first);
      serialize(out, it->second);
    }


87

88
89
90
91
92
93
    SerUtil::serialize(out, vertexOwner);
    SerUtil::serialize(out, edgeOwner);
    SerUtil::serialize(out, faceOwner);


    nSize = vertexInRank.size();
94
    SerUtil::serialize(out, nSize);
95
96
97
98
99
100
101
    for (std::map<DegreeOfFreedom, std::map<int, ElementObjectData> >::iterator it = vertexInRank.begin();
	 it != vertexInRank.end(); ++it) {
      SerUtil::serialize(out, it->first);
      serialize(out, it->second);
    }

    nSize = edgeInRank.size();
102
    SerUtil::serialize(out, nSize);
103
104
105
106
107
108
109
    for (std::map<DofEdge, std::map<int, ElementObjectData> >::iterator it = edgeInRank.begin();
	 it != edgeInRank.end(); ++it) {
      SerUtil::serialize(out, it->first);
      serialize(out, it->second);
    }

    nSize = faceInRank.size();
110
    SerUtil::serialize(out, nSize);
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
    for (std::map<DofFace, std::map<int, ElementObjectData> >::iterator it = faceInRank.begin();
	 it != faceInRank.end(); ++it) {
      SerUtil::serialize(out, it->first);
      serialize(out, it->second);
    }

  }


  void ElementObjects::deserialize(std::istream &in)
  {
    FUNCNAME("ElementObjects::deserialize()");

    int nSize;
    SerUtil::deserialize(in, nSize);
    vertexElements.clear();
    for (int i = 0; i < nSize; i++) {
      DegreeOfFreedom dof;
      std::vector<ElementObjectData> data;
      SerUtil::deserialize(in, dof);
      deserialize(in, data);
      vertexElements[dof] = data;
    }

    SerUtil::deserialize(in, nSize);
    edgeElements.clear();
    for (int i = 0; i < nSize; i++) {
      DofEdge edge;
      std::vector<ElementObjectData> data;
      SerUtil::deserialize(in, edge);
      deserialize(in, data);
      edgeElements[edge] = data;
    }

    SerUtil::deserialize(in, nSize);
    faceElements.clear();
    for (int i = 0; i < nSize; i++) {
      DofFace face;
      std::vector<ElementObjectData> data;
      SerUtil::deserialize(in, face);
      deserialize(in, data);
      faceElements[face] = data;
    }
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
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

    SerUtil::deserialize(in, vertexOwner);
    SerUtil::deserialize(in, edgeOwner);
    SerUtil::deserialize(in, faceOwner);


    SerUtil::deserialize(in, nSize);
    vertexInRank.clear();
    for (int i = 0; i < nSize; i++) {
      DegreeOfFreedom dof;
      std::map<int, ElementObjectData> data;
      SerUtil::deserialize(in, dof);
      deserialize(in, data);
      vertexInRank[dof] = data;
    }

    SerUtil::deserialize(in, nSize);
    edgeInRank.clear();
    for (int i = 0; i < nSize; i++) {
      DofEdge edge;
      std::map<int, ElementObjectData> data;
      SerUtil::deserialize(in, edge);
      deserialize(in, data);
      edgeInRank[edge] = data;
    }

    SerUtil::deserialize(in, nSize);
    faceInRank.clear();
    for (int i = 0; i < nSize; i++) {
      DofFace face;
      std::map<int, ElementObjectData> data;
      SerUtil::deserialize(in, face);
      deserialize(in, data);
      faceInRank[face] = data;
    }
  }


  void ElementObjects::serialize(std::ostream &out, std::vector<ElementObjectData>& elVec)
  {
    int nSize = elVec.size();
    SerUtil::serialize(out, nSize);
    for (int i = 0; i < nSize; i++)
      elVec[i].serialize(out);
  }


  void ElementObjects::deserialize(std::istream &in, std::vector<ElementObjectData>& elVec)
  {
    int nSize;
    SerUtil::deserialize(in, nSize);
    elVec.resize(nSize);
    for (int i = 0; i < nSize; i++)
      elVec[i].deserialize(in);
  }

  
  void ElementObjects::serialize(std::ostream &out, std::map<int, ElementObjectData>& data)
  {
    int nSize = data.size();
    SerUtil::serialize(out, nSize);
    for (std::map<int, ElementObjectData>::iterator it = data.begin();
	 it != data.end(); ++it) {
      SerUtil::serialize(out, it->first);
      it->second.serialize(out);
    }
  }

  
  void ElementObjects::deserialize(std::istream &in, std::map<int, ElementObjectData>& data)
  {
    int nSize;
    SerUtil::deserialize(in, nSize);
    for (int i = 0; i < nSize; i++) {
      int index;
      ElementObjectData elObj;
      SerUtil::deserialize(in, index);
      elObj.deserialize(in);

      data[index] = elObj;
    }
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
238
}