ElementObjectData.cc 19.3 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology 
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.


Thomas Witkowski's avatar
Thomas Witkowski committed
13
#include "ElementObjectData.h"
14
#include "VertexVector.h"
Thomas Witkowski's avatar
Thomas Witkowski committed
15
16
17

namespace AMDiS {

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
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
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
  void ElementObjects::addElement(ElInfo *elInfo)
  {
    FUNCNAME("ElementObjects::addElement()");

    TEST_EXIT_DBG(mesh)("Mesh not set!\n");

    Element *el = elInfo->getElement();


    // === First, add all element objects to the database. ===

    for (int i = 0; i < el->getGeo(VERTEX); i++)
      addVertex(el, i);
    
    for (int i = 0; i < el->getGeo(EDGE); i++)
      addEdge(el, i);      
    
    for (int i = 0; i < el->getGeo(FACE); i++)
      addFace(el, i);


    // === Get periodic boundary information. === 
    
    switch (mesh->getDim()) {
    case 2:
      for (int i = 0; i < el->getGeo(EDGE); i++) {
	if (mesh->isPeriodicAssociation(elInfo->getBoundary(EDGE, i))) {
	  // The current element's i-th edge is periodic.
	  Element *neigh = elInfo->getNeighbour(i);
	  
	  DofEdge edge0 = el->getEdge(i);
	  DofEdge edge1 = neigh->getEdge(elInfo->getOppVertex(i));
	  BoundaryType boundaryType = elInfo->getBoundary(EDGE, i);
	  
	  // Add the periodic edge.
	  periodicEdges[make_pair(edge0, edge1)] = boundaryType;
	  periodicEdgeAssoc[edge0].insert(edge1);
	  
	  // Add both vertices of the edge to be periodic.
	  periodicVertices[make_pair(edge0.first, edge1.first)] = boundaryType;
	  periodicVertices[make_pair(edge0.second, edge1.second)] = boundaryType;
	  periodicDofAssoc[edge0.first].insert(boundaryType);
	  periodicDofAssoc[edge0.second].insert(boundaryType);
	  
	  TEST_EXIT_DBG(edge0.first == 
			mesh->getPeriodicAssociations(boundaryType)[edge1.first] &&
			edge0.second == 
			mesh->getPeriodicAssociations(boundaryType)[edge1.second])
	    ("Should not happen!\n");
	}
      }
      break;
    case 3:
      for (int i = 0; i < el->getGeo(FACE); i++) {
	if (mesh->isPeriodicAssociation(elInfo->getBoundary(FACE, i))) {
	  // The current element's i-th face is periodic.
	  Element *neigh = elInfo->getNeighbour(i);
	  
	  DofFace face0 = el->getFace(i);
	  DofFace face1 = neigh->getFace(elInfo->getOppVertex(i));
	  BoundaryType boundaryType = elInfo->getBoundary(FACE, i);
	  
	  // Add the periodic face.
	  periodicFaces[make_pair(face0, face1)] = elInfo->getBoundary(i);
	  
	  /// Add all three vertices of the face to be periodic.
	  periodicVertices[make_pair(face0.get<0>(), face1.get<0>())] = boundaryType;
	  periodicVertices[make_pair(face0.get<1>(), face1.get<1>())] = boundaryType;
	  periodicVertices[make_pair(face0.get<2>(), face1.get<2>())] = boundaryType;
	  
	  periodicDofAssoc[face0.get<0>()].insert(boundaryType);
	  periodicDofAssoc[face0.get<1>()].insert(boundaryType);
	  periodicDofAssoc[face0.get<2>()].insert(boundaryType);
	  
	  TEST_EXIT_DBG(face0.get<0>() == 
			mesh->getPeriodicAssociations(boundaryType)[face1.get<0>()] &&
			face0.get<1>() == 
			mesh->getPeriodicAssociations(boundaryType)[face1.get<1>()] &&
			face0.get<2>() == 
			mesh->getPeriodicAssociations(boundaryType)[face1.get<2>()])
	    ("Should not happen!\n");
	  
	  // Create all three edges of the element and add them to be periodic.
	  DofEdge elEdge0 = make_pair(face0.get<0>(), face0.get<1>());
	  DofEdge elEdge1 = make_pair(face0.get<0>(), face0.get<2>());
	  DofEdge elEdge2 = make_pair(face0.get<1>(), face0.get<2>());
	  DofEdge neighEdge0 = make_pair(face1.get<0>(), face1.get<1>());
	  DofEdge neighEdge1 = make_pair(face1.get<0>(), face1.get<2>());
	  DofEdge neighEdge2 = make_pair(face1.get<1>(), face1.get<2>());
	  	  
	  periodicEdges[make_pair(elEdge0, neighEdge0)] = boundaryType;
	  periodicEdges[make_pair(elEdge1, neighEdge1)] = boundaryType;
	  periodicEdges[make_pair(elEdge2, neighEdge2)] = boundaryType;
	  
	  periodicEdgeAssoc[elEdge0].insert(neighEdge0);
	  periodicEdgeAssoc[elEdge1].insert(neighEdge1);
	  periodicEdgeAssoc[elEdge2].insert(neighEdge2);
	}
      }
      break;
    default:
      ERROR_EXIT("Should not happen!\n");
    }       
  }


  void ElementObjects::createPeriodicData()
  {
    FUNCNAME("ElementObjects::createPeriodicData()");

    TEST_EXIT_DBG(mesh)("Mesh not set!\n");

    // === Return, if there are no periodic vertices, i.e., there are no no  ===
    // === periodic boundaries in the mesh.                                  ===
    
    if (periodicVertices.size() == 0)
      return;
   

    // === Search for an unsed boundary index. ===

    BoundaryType newPeriodicBoundaryType = 0;
    for (map<BoundaryType, VertexVector*>::iterator it = mesh->getPeriodicAssociations().begin();
	 it != mesh->getPeriodicAssociations().end(); ++it)
      newPeriodicBoundaryType = min(newPeriodicBoundaryType, it->first);
    
    TEST_EXIT_DBG(newPeriodicBoundaryType < 0)("Should not happen!\n");
    newPeriodicBoundaryType--;
    mesh->getPeriodicAssociations()[newPeriodicBoundaryType] = 
      new VertexVector(feSpace->getAdmin(), "");
    
    
    // === Get all vertex DOFs that have multiple periodic associations. ===
    
    // We group all vertices together, that have either two or three periodic
    // associations. For rectangular domains in 2D, the four corner vertices have all
    // two periodic associations. For box domains in 3D, the eight corner vertices
    // have all three periodic associations.

    vector<DegreeOfFreedom> multPeriodicDof2, multPeriodicDof3;
    for (map<DegreeOfFreedom, std::set<BoundaryType> >::iterator it = periodicDofAssoc.begin();
	 it != periodicDofAssoc.end(); ++it) {
      TEST_EXIT_DBG((mesh->getDim() == 2 && it->second.size() <= 2) ||
		    (mesh->getDim() == 3 && it->second.size() <= 3))
	("Should not happen!\n");
      
      if (it->second.size() == 2)
	multPeriodicDof2.push_back(it->first);
      if (it->second.size() == 3)
	multPeriodicDof3.push_back(it->first);
    }


    if (mesh->getDim() == 2) {
      TEST_EXIT_DBG(multPeriodicDof2.size() == 0 || 
		    multPeriodicDof2.size() == 4)
	("Should not happen (%d)!\n", multPeriodicDof2.size());
      TEST_EXIT_DBG(multPeriodicDof3.size() == 0)("Should not happen!\n");
    }
    if (mesh->getDim() == 3) {
      TEST_EXIT_DBG(multPeriodicDof3.size() == 0 || 
		    multPeriodicDof3.size() == 8)
	("Should not happen (%d)!\n", multPeriodicDof3.size());
    }
    
    
    if (multPeriodicDof2.size() > 0) {
      for (unsigned int i = 0; i < multPeriodicDof2.size(); i++) {
	DegreeOfFreedom dof0 = multPeriodicDof2[i];
	if (dof0 == -1)
	  continue;
	
	DegreeOfFreedom dof1 = -1;
	DegreeOfFreedom dof2 = -1;
	BoundaryType type0 = *(periodicDofAssoc[dof0].begin());
	BoundaryType type1 = *(++(periodicDofAssoc[dof0].begin()));
	
	for (PerBoundMap<DegreeOfFreedom>::iterator it = periodicVertices.begin();
	     it != periodicVertices.end(); ++it) {
	  if (it->first.first == dof0 && it->second == type0)
	    dof1 = it->first.second;
	  if (it->first.first == dof0 && it->second == type1)
	    dof2 = it->first.second;
	  
	  if (dof1 != -1 && dof2 != -1)
	    break;
	}
	
	TEST_EXIT_DBG(dof1 != -1 && dof2 != -1)("Should not happen!\n");
	
	DegreeOfFreedom dof3 = -1;
	for (PerBoundMap<DegreeOfFreedom>::iterator it = periodicVertices.begin();
	     it != periodicVertices.end(); ++it) {
	  if (it->first.first == dof1 && it->second == type1) {
	    dof3 = it->first.second;
	    
	    TEST_EXIT_DBG(periodicVertices[make_pair(dof2, dof3)] == type0)
	      ("Should not happen!\n");
	    
	    break;
	  }
	}
	  
	TEST_EXIT_DBG(dof3 != -1)("Should not happen!\n");
	TEST_EXIT_DBG(periodicVertices.count(make_pair(dof0, dof3)) == 0)
	  ("Should not happen!\n");
	TEST_EXIT_DBG(periodicVertices.count(make_pair(dof3, dof0)) == 0)
	  ("Should not happen!\n");
	
	periodicVertices[make_pair(dof0, dof3)] = newPeriodicBoundaryType;
	periodicVertices[make_pair(dof3, dof0)] = newPeriodicBoundaryType;
	
	for (unsigned int j = i + 1; j < multPeriodicDof2.size(); j++)
	  if (multPeriodicDof2[j] == dof3)
	    multPeriodicDof2[j] = -1;
      }
    }

    if (multPeriodicDof3.size() > 0) {
      int nMultPeriodicDofs = multPeriodicDof3.size();
      for (int i = 0; i < nMultPeriodicDofs; i++) {
	for (int j = i + 1; j < nMultPeriodicDofs; j++) {
	  pair<DegreeOfFreedom, DegreeOfFreedom> perDofs0 = 
	    make_pair(multPeriodicDof3[i], multPeriodicDof3[j]);
	  pair<DegreeOfFreedom, DegreeOfFreedom> perDofs1 = 
	    make_pair(multPeriodicDof3[j], multPeriodicDof3[i]);
	  
	  if (periodicVertices.count(perDofs0) == 0) {
	    TEST_EXIT_DBG(periodicVertices.count(perDofs1) == 0)
	      ("Should not happen!\n");
	    
	    periodicVertices[perDofs0] = newPeriodicBoundaryType;
	    periodicVertices[perDofs1] = newPeriodicBoundaryType;
	    newPeriodicBoundaryType--;
	    mesh->getPeriodicAssociations()[newPeriodicBoundaryType] = 
	      new VertexVector(feSpace->getAdmin(), "");
	  }
	}
      }
    }
    
    
    // === Get all edges that have multiple periodic associations (3D only!). ===
    
    for (map<DofEdge, std::set<DofEdge> >::iterator it = periodicEdgeAssoc.begin();
	 it != periodicEdgeAssoc.end(); ++it) {
      if (it->second.size() > 1) {
	TEST_EXIT_DBG(mesh->getDim() == 3)("Should not happen!\n");
	TEST_EXIT_DBG(it->second.size() == 2)("Should not happen!\n");
	
	pair<DofEdge, DofEdge> perEdge0 =
	  make_pair(*(it->second.begin()), *(++(it->second.begin())));
	pair<DofEdge, DofEdge> perEdge1 =
	  make_pair(perEdge0.second, perEdge0.first);
	
	periodicEdges[perEdge0] = newPeriodicBoundaryType;
	periodicEdges[perEdge1] = newPeriodicBoundaryType;
	newPeriodicBoundaryType--;
	mesh->getPeriodicAssociations()[newPeriodicBoundaryType] = 
	  new VertexVector(feSpace->getAdmin(), "");      
      }
    }


    // === In debug mode we make some tests, if the periodic structures are set ===
    // === in a symmetric way, i.e., if A -> B for a specific boundary type,    ===
    // === there must be a mapping B -> A with the same boundary type.          ===
    
#if (DEBUG != 0)
    for (PerBoundMap<DegreeOfFreedom>::iterator it = periodicVertices.begin();
	 it != periodicVertices.end(); ++it) {
      pair<DegreeOfFreedom, DegreeOfFreedom> testVertex = 
	make_pair(it->first.second, it->first.first);
      
      TEST_EXIT_DBG(periodicVertices.count(testVertex) == 1)("Should not happen!\n");
      TEST_EXIT_DBG(periodicVertices[testVertex] == it->second)("Should not happen!\n");
    }

    for (PerBoundMap<DofEdge>::iterator it = periodicEdges.begin();
	 it != periodicEdges.end(); ++it) {
      pair<DofEdge, DofEdge> testEdge = 
	make_pair(it->first.second, it->first.first);
      
      TEST_EXIT_DBG(periodicEdges.count(testEdge) == 1)("Should not happen!\n");
      TEST_EXIT_DBG(periodicEdges[testEdge] == it->second)("Should not happen!\n");
    }
    
    for (PerBoundMap<DofFace>::iterator it = periodicFaces.begin();
	 it != periodicFaces.end(); ++it) {
      pair<DofFace, DofFace> testFace = 
	make_pair(it->first.second, it->first.first);
      
      TEST_EXIT_DBG(periodicFaces.count(testFace) == 1)("Should not happen!\n");
      TEST_EXIT_DBG(periodicFaces[testFace] == it->second)("Should not happen!\n");
    }
#endif       
  }


  void ElementObjects::createRankData(map<int, int>& macroElementRankMap) 
Thomas Witkowski's avatar
Thomas Witkowski committed
318
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
319
320
321
322
    FUNCNAME("ElementObjects::createRankData()");

    vertexOwner.clear();
    vertexInRank.clear();
323
    for (map<DegreeOfFreedom, vector<ElementObjectData> >::iterator it = vertexElements.begin();
Thomas Witkowski's avatar
Thomas Witkowski committed
324
	 it != vertexElements.end(); ++it) {
325
      for (vector<ElementObjectData>::iterator it2 = it->second.begin(); 
Thomas Witkowski's avatar
Thomas Witkowski committed
326
327
	   it2 != it->second.end(); ++it2) {
	int elementInRank = macroElementRankMap[it2->elIndex];
Thomas Witkowski's avatar
Thomas Witkowski committed
328
	
Thomas Witkowski's avatar
Thomas Witkowski committed
329
330
331
	if (it2->elIndex > vertexInRank[it->first][elementInRank].elIndex)
	  vertexInRank[it->first][elementInRank] = *it2;

332
	vertexOwner[it->first] = max(vertexOwner[it->first], elementInRank);
Thomas Witkowski's avatar
Thomas Witkowski committed
333
334
335
      }
    }
    
Thomas Witkowski's avatar
Thomas Witkowski committed
336
337
338

    edgeOwner.clear();
    edgeInRank.clear();
339
    for (map<DofEdge, vector<ElementObjectData> >::iterator it = edgeElements.begin();
Thomas Witkowski's avatar
Thomas Witkowski committed
340
	 it != edgeElements.end(); ++it) {
341
      for (vector<ElementObjectData>::iterator it2 = it->second.begin(); 
Thomas Witkowski's avatar
Thomas Witkowski committed
342
343
	   it2 != it->second.end(); ++it2) {
	int elementInRank = macroElementRankMap[it2->elIndex];
Thomas Witkowski's avatar
Thomas Witkowski committed
344
	
Thomas Witkowski's avatar
Thomas Witkowski committed
345
346
347
	if (it2->elIndex > edgeInRank[it->first][elementInRank].elIndex)
	  edgeInRank[it->first][elementInRank] = *it2;

348
	edgeOwner[it->first] = max(edgeOwner[it->first], elementInRank);
Thomas Witkowski's avatar
Thomas Witkowski committed
349
350
351
      }
    }
    
Thomas Witkowski's avatar
Thomas Witkowski committed
352
353
354

    faceOwner.clear();
    faceInRank.clear();
355
    for (map<DofFace, vector<ElementObjectData> >::iterator it = faceElements.begin();
Thomas Witkowski's avatar
Thomas Witkowski committed
356
	 it != faceElements.end(); ++it) {
357
      for (vector<ElementObjectData>::iterator it2 = it->second.begin(); 
Thomas Witkowski's avatar
Thomas Witkowski committed
358
359
	   it2 != it->second.end(); ++it2) {
	int elementInRank = macroElementRankMap[it2->elIndex];
Thomas Witkowski's avatar
Thomas Witkowski committed
360
	
Thomas Witkowski's avatar
Thomas Witkowski committed
361
362
363
	if (it2->elIndex > faceInRank[it->first][elementInRank].elIndex)
	  faceInRank[it->first][elementInRank] = *it2;

364
	faceOwner[it->first] = max(faceOwner[it->first], elementInRank);
Thomas Witkowski's avatar
Thomas Witkowski committed
365
366
367
368
      }
    }
  }

369

370
  void ElementObjects::serialize(ostream &out)
371
372
373
374
375
  {
    FUNCNAME("ElementObjects::serialize()");

    int nSize = vertexElements.size();
    SerUtil::serialize(out, nSize);
376
    for (map<DegreeOfFreedom, vector<ElementObjectData> >::iterator it = vertexElements.begin();
377
378
379
380
381
382
383
	 it != vertexElements.end(); ++it) {
      SerUtil::serialize(out, it->first);
      serialize(out, it->second);
    }

    nSize = edgeElements.size();
    SerUtil::serialize(out, nSize);
384
    for (map<DofEdge, vector<ElementObjectData> >::iterator it = edgeElements.begin();
385
386
387
388
389
390
391
	 it != edgeElements.end(); ++it) {
      SerUtil::serialize(out, it->first);
      serialize(out, it->second);
    }

    nSize = faceElements.size();
    SerUtil::serialize(out, nSize);
392
    for (map<DofFace, vector<ElementObjectData> >::iterator it = faceElements.begin();
393
394
395
396
397
398
	 it != faceElements.end(); ++it) {
      SerUtil::serialize(out, it->first);
      serialize(out, it->second);
    }


399

400
401
    nSize = vertexLocalMap.size();
    SerUtil::serialize(out, nSize);
402
    for (map<ElementObjectData, DegreeOfFreedom>::iterator it = vertexLocalMap.begin();
403
404
405
406
407
408
409
	 it != vertexLocalMap.end(); ++it) {
      it->first.serialize(out);
      SerUtil::serialize(out, it->second);
    }

    nSize = edgeLocalMap.size();
    SerUtil::serialize(out, nSize);
410
    for (map<ElementObjectData, DofEdge>::iterator it = edgeLocalMap.begin();
411
412
413
414
415
416
417
	 it != edgeLocalMap.end(); ++it) {
      it->first.serialize(out);
      SerUtil::serialize(out, it->second);
    }

    nSize = faceLocalMap.size();
    SerUtil::serialize(out, nSize);
418
    for (map<ElementObjectData, DofFace>::iterator it = faceLocalMap.begin();
419
420
421
422
423
424
425
	 it != faceLocalMap.end(); ++it) {
      it->first.serialize(out);
      SerUtil::serialize(out, it->second);
    }



426
427
428
429
430
431
    SerUtil::serialize(out, vertexOwner);
    SerUtil::serialize(out, edgeOwner);
    SerUtil::serialize(out, faceOwner);


    nSize = vertexInRank.size();
432
    SerUtil::serialize(out, nSize);
433
    for (map<DegreeOfFreedom, map<int, ElementObjectData> >::iterator it = vertexInRank.begin();
434
435
436
437
438
439
	 it != vertexInRank.end(); ++it) {
      SerUtil::serialize(out, it->first);
      serialize(out, it->second);
    }

    nSize = edgeInRank.size();
440
    SerUtil::serialize(out, nSize);
441
    for (map<DofEdge, map<int, ElementObjectData> >::iterator it = edgeInRank.begin();
442
443
444
445
446
447
	 it != edgeInRank.end(); ++it) {
      SerUtil::serialize(out, it->first);
      serialize(out, it->second);
    }

    nSize = faceInRank.size();
448
    SerUtil::serialize(out, nSize);
449
    for (map<DofFace, map<int, ElementObjectData> >::iterator it = faceInRank.begin();
450
451
452
453
454
	 it != faceInRank.end(); ++it) {
      SerUtil::serialize(out, it->first);
      serialize(out, it->second);
    }

455
456
457
    SerUtil::serialize(out, periodicVertices);
    SerUtil::serialize(out, periodicEdges);
    SerUtil::serialize(out, periodicFaces);
458
459
460
  }


461
  void ElementObjects::deserialize(istream &in)
462
463
464
465
466
467
468
469
  {
    FUNCNAME("ElementObjects::deserialize()");

    int nSize;
    SerUtil::deserialize(in, nSize);
    vertexElements.clear();
    for (int i = 0; i < nSize; i++) {
      DegreeOfFreedom dof;
470
      vector<ElementObjectData> data;
471
472
473
474
475
476
477
478
479
      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;
480
      vector<ElementObjectData> data;
481
482
483
484
485
486
487
488
489
      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;
490
      vector<ElementObjectData> data;
491
492
493
494
      SerUtil::deserialize(in, face);
      deserialize(in, data);
      faceElements[face] = data;
    }
495
   
496

497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528

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

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

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


529
530
531
532
533
534
535
536
537
    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;
538
      map<int, ElementObjectData> data;
539
540
541
542
543
544
545
546
547
      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;
548
      map<int, ElementObjectData> data;
549
550
551
552
553
554
555
556
557
      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;
558
      map<int, ElementObjectData> data;
559
560
561
562
      SerUtil::deserialize(in, face);
      deserialize(in, data);
      faceInRank[face] = data;
    }
563
564
565
566

    SerUtil::deserialize(in, periodicVertices);
    SerUtil::deserialize(in, periodicEdges);
    SerUtil::deserialize(in, periodicFaces);  
567
568
569
  }


570
  void ElementObjects::serialize(ostream &out, vector<ElementObjectData>& elVec)
571
572
573
574
575
576
577
578
  {
    int nSize = elVec.size();
    SerUtil::serialize(out, nSize);
    for (int i = 0; i < nSize; i++)
      elVec[i].serialize(out);
  }


579
  void ElementObjects::deserialize(istream &in, vector<ElementObjectData>& elVec)
580
581
582
583
584
585
586
587
588
  {
    int nSize;
    SerUtil::deserialize(in, nSize);
    elVec.resize(nSize);
    for (int i = 0; i < nSize; i++)
      elVec[i].deserialize(in);
  }

  
589
  void ElementObjects::serialize(ostream &out, map<int, ElementObjectData>& data)
590
591
592
  {
    int nSize = data.size();
    SerUtil::serialize(out, nSize);
593
    for (map<int, ElementObjectData>::iterator it = data.begin();
594
595
596
597
598
599
600
	 it != data.end(); ++it) {
      SerUtil::serialize(out, it->first);
      it->second.serialize(out);
    }
  }

  
601
  void ElementObjects::deserialize(istream &in, map<int, ElementObjectData>& data)
602
603
604
605
606
607
608
609
610
611
612
613
614
  {
    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
615
}