ElementObjectDatabase.cc 37 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.


13
#include "VertexVector.h"
14
#include "parallel/ElementObjectDatabase.h"
15
#include "parallel/MeshLevelData.h"
Thomas Witkowski's avatar
Thomas Witkowski committed
16
17
18

namespace AMDiS {

19
  void ElementObjectDatabase::create(map<int, int>& rankMap, MeshLevelData& ld)
20
  {
21
22
23
24
25
    FUNCNAME("ElementObjectDatabase::create()");

    macroElementRankMap = &rankMap;
    levelData = &ld;

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
    // === Fills macro element data structures. ===
    
    TraverseStack stack;
    ElInfo *elInfo = stack.traverseFirst(mesh, -1, 
					 Mesh::CALL_LEAF_EL | 
					 Mesh::FILL_NEIGH | 
					 Mesh::FILL_BOUND);
    while (elInfo) {
      TEST_EXIT_DBG(elInfo->getLevel() == 0)("Should not happen!\n");

      Element *el = elInfo->getElement();
      macroElIndexMap.insert(make_pair(el->getIndex(), el));
      macroElIndexTypeMap.insert(make_pair(el->getIndex(), elInfo->getType()));
     
      // Add all sub object of the element to the variable elObjDb.
      addElement(elInfo);

      elInfo = stack.traverseNext(elInfo);
    }
Thomas Witkowski's avatar
Thomas Witkowski committed
45
46
    
    // Handle periodic boudaries
47
    createPeriodicData();
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

    // Create data about the reverse modes of neighbouring elements.
    createReverseModeData();
  }


  void ElementObjectDatabase::createMacroElementInfo(vector<MacroElement*> &mel)
  {
    macroElIndexMap.clear();
    macroElIndexTypeMap.clear();

    for (vector<MacroElement*>::iterator it = mel.begin(); 
	 it != mel.end(); ++it) {
      macroElIndexMap.insert(make_pair((*it)->getIndex(), (*it)->getElement()));
      macroElIndexTypeMap.insert(make_pair((*it)->getIndex(), (*it)->getElType()));
    }
  }

      
67
  void ElementObjectDatabase::addElement(ElInfo *elInfo)
68
  {
69
    FUNCNAME("ElementObjectDatabase::addElement()");
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

    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);
96
97

	  TEST_EXIT_DBG(neigh)("Should not happen!\n");
98
99
100
101
	  
	  DofEdge edge0 = el->getEdge(i);
	  DofEdge edge1 = neigh->getEdge(elInfo->getOppVertex(i));
	  BoundaryType boundaryType = elInfo->getBoundary(EDGE, i);
102

Thomas Witkowski's avatar
Thomas Witkowski committed
103
104
105
106
107
	  // Add the periodic edge.
	  periodicEdges[make_pair(edge0, edge1)] = boundaryType;
	  periodicEdgeAssoc[edge0].insert(edge1);
	  
	  // Add both vertices of the edge to be periodic.
108
109
110
111
112
113
114
	  DegreeOfFreedom mappedDof0 = 
	    mesh->getPeriodicAssociations(boundaryType)[edge0.first];
	  DegreeOfFreedom mappedDof1 = 
	    mesh->getPeriodicAssociations(boundaryType)[edge0.second];
	  periodicVertices[make_pair(edge0.first, mappedDof0)] = boundaryType;
	  periodicVertices[make_pair(edge0.second, mappedDof1)] = boundaryType;

Thomas Witkowski's avatar
Thomas Witkowski committed
115
	  periodicDofAssoc[edge0.first].insert(boundaryType);
116
	  periodicDofAssoc[edge0.second].insert(boundaryType); 
117
118
119
120
121
122
123
124
	}
      }
      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);
125
126

	  TEST_EXIT_DBG(neigh)("Should not happen!\n");
127
128
129
130
	  
	  DofFace face0 = el->getFace(i);
	  DofFace face1 = neigh->getFace(elInfo->getOppVertex(i));
	  BoundaryType boundaryType = elInfo->getBoundary(FACE, i);
131

132
133
134
135
	  // Add the periodic face.
	  periodicFaces[make_pair(face0, face1)] = elInfo->getBoundary(i);
	  
	  /// Add all three vertices of the face to be periodic.
136
137
138
139
140
141
142
143
144
145
	  DegreeOfFreedom mappedDof0 = 
	    mesh->getPeriodicAssociations(boundaryType)[face0.get<0>()];
	  DegreeOfFreedom mappedDof1 = 
	    mesh->getPeriodicAssociations(boundaryType)[face0.get<1>()];
	  DegreeOfFreedom mappedDof2 = 
	    mesh->getPeriodicAssociations(boundaryType)[face0.get<2>()];

	  periodicVertices[make_pair(face0.get<0>(), mappedDof0)] = boundaryType;
	  periodicVertices[make_pair(face0.get<1>(), mappedDof1)] = boundaryType;
	  periodicVertices[make_pair(face0.get<2>(), mappedDof2)] = boundaryType;
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
	  
	  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");
    }       
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
182
183
184
185
186
  void ElementObjectDatabase::addVertex(Element *el, int ith)
  {
    DegreeOfFreedom vertex = el->getDof(ith, 0);
    int elIndex = el->getIndex();
    ElementObjectData elObj(elIndex, ith);
187
   
Thomas Witkowski's avatar
Thomas Witkowski committed
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
    vertexElements[vertex].push_back(elObj);
    vertexLocalMap[elObj] = vertex;
  }


  void ElementObjectDatabase::addEdge(Element *el, int ith)
  {
    FUNCNAME("ElementObjectDatabase::addEdge()");

    DofEdge edge = el->getEdge(ith);
    int elIndex = el->getIndex();
    ElementObjectData elObj(elIndex, ith);
    
    edgeElements[edge].push_back(elObj);
    edgeLocalMap[elObj] = edge;
  }

  
  void ElementObjectDatabase::addFace(Element *el, int ith)
  {
    DofFace face = el->getFace(ith);
    int elIndex = el->getIndex();
    ElementObjectData elObj(elIndex, ith);
    
    faceElements[face].push_back(elObj);
    faceLocalMap[elObj] = face;
  }

216

217
  void ElementObjectDatabase::createPeriodicData()
218
  {
219
    FUNCNAME("ElementObjectDatabase::createPeriodicData()");
220
221
222

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

223
224
    // === Return, if there are no periodic vertices, i.e., there are no  ===
    // === periodic boundaries in the mesh.                               ===
225
226
227
    
    if (periodicVertices.size() == 0)
      return;
228
 
229
230
231
232
233
234
    // === Calculate smallest periodic boundary ID in mesh. ===

    smallestPeriodicBcType = 0;
    for (map<BoundaryType, VertexVector*>::iterator it = mesh->getPeriodicAssociations().begin();
	 it != mesh->getPeriodicAssociations().end(); ++it)
      smallestPeriodicBcType = std::min(smallestPeriodicBcType, it->first);
235
236
237
238

    // === Get all vertex DOFs that have multiple periodic associations. ===
    
    // We group all vertices together, that have either two or three periodic
239
240
241
    // 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.
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261

    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");
    }
262

263
264
265
266
267
    if (mesh->getDim() == 3) {
      TEST_EXIT_DBG(multPeriodicDof3.size() == 0 || 
		    multPeriodicDof3.size() == 8)
	("Should not happen (%d)!\n", multPeriodicDof3.size());
    }
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
    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");
311
312

 	periodicVertices[make_pair(dof0, dof3)] = 
313
	  provideConnectedPeriodicBoundary(type0, type1);
314
 	periodicVertices[make_pair(dof3, dof0)] = 
315
 	  provideConnectedPeriodicBoundary(type0, type1);
316

317
318
319
320
321
322
323
324
	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();
325

326
327
328
329
330
331
332
333
      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) {
334
	    BoundaryType b = getNewBoundaryType();
335
336
	    periodicVertices[perDofs0] = b;
	    periodicVertices[perDofs1] = b;
337
338
339
340
	  }
	}
      }
    }
341
342
  
   
343
344
345
346
347
348
349
350
    // === 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");
	
351
352
353
	DofEdge edge0 = it->first;
	DofEdge edge1 = *(it->second.begin());
	DofEdge edge2 = *(++(it->second.begin()));
354
	
355
356
357
358
359
360
361
362
363
364
	pair<DofEdge, DofEdge> perEdge0 = make_pair(edge1, edge2);
	pair<DofEdge, DofEdge> perEdge1 = make_pair(edge2, edge1);

	TEST_EXIT_DBG(periodicEdges.count(make_pair(edge0, edge1)) == 1)
	  ("Should not happen!\n");
	TEST_EXIT_DBG(periodicEdges.count(make_pair(edge1, edge0)) == 1)
	  ("Should not happen!\n");

	BoundaryType type0 = periodicEdges[make_pair(edge0, edge1)];
	BoundaryType type1 = periodicEdges[make_pair(edge0, edge2)];
365
	BoundaryType type2 = provideConnectedPeriodicBoundary(type0, type1);
366
367
368

 	periodicEdges[perEdge0] = type2;
 	periodicEdges[perEdge1] = type2;
369
370
371
372
373
374
375
376
377
378
379
380
381
382
      }
    }


    // === 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);
      
383
384
385
386
      TEST_EXIT_DBG(periodicVertices.count(testVertex) == 1)
	("Should not happen!\n");
      TEST_EXIT_DBG(periodicVertices[testVertex] == it->second)
	("Should not happen!\n");
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
    }

    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       
  }


410
  BoundaryType ElementObjectDatabase::getNewBoundaryType()
411
  {
412
    FUNCNAME("ElementObjectDatabase::getNewBoundaryType()");
413
414
415
416
417
418
419
420
421
422

    BoundaryType newPeriodicBoundaryType = 0;
    for (map<BoundaryType, VertexVector*>::iterator it = mesh->getPeriodicAssociations().begin();
	 it != mesh->getPeriodicAssociations().end(); ++it)
      newPeriodicBoundaryType = std::min(newPeriodicBoundaryType, it->first);
    
    TEST_EXIT_DBG(newPeriodicBoundaryType < 0)("Should not happen!\n");
    newPeriodicBoundaryType--;
    
    mesh->getPeriodicAssociations()[newPeriodicBoundaryType] = 
423
      new VertexVector(feSpace->getAdmin(), "");
424
425
426
427
428
    
    return newPeriodicBoundaryType;
  }


429
  BoundaryType 
430
  ElementObjectDatabase::provideConnectedPeriodicBoundary(BoundaryType b0, 
431
							  BoundaryType b1)
432
  {
433
    FUNCNAME("ElementObjectDatabase::provideConnectedPeriodicBoundary()");
434
435

    std::pair<BoundaryType, BoundaryType> bConn = 
436
      (b0 <= b1 ? make_pair(b0, b1) : make_pair(b1, b0));
437
438

    if (bConnMap.count(bConn) == 0) {
439
      BoundaryType newPeriodicBoundaryType = getNewBoundaryType();
440
441
442
443
444

      VertexVector &vecB0 = mesh->getPeriodicAssociations(b0);
      VertexVector &vecB1 = mesh->getPeriodicAssociations(b1);
      VertexVector &vecC = mesh->getPeriodicAssociations(newPeriodicBoundaryType);

445
      DOFIteratorBase it(const_cast<DOFAdmin*>(feSpace->getAdmin()), USED_DOFS);
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463

      for (it.reset(); !it.end(); ++it) {
	if (!it.isDofFree()) {
	  TEST_EXIT_DBG(vecB1[vecB0[it.getDOFIndex()]] == vecB0[vecB1[it.getDOFIndex()]])
	    ("Should not happen!\n");

	  vecC[it.getDOFIndex()] = vecB1[vecB0[it.getDOFIndex()]];
	}
      }
      
      bConnMap[bConn] = newPeriodicBoundaryType;
    }


    return bConnMap[bConn];
  }


464
  void ElementObjectDatabase::updateRankData()
Thomas Witkowski's avatar
Thomas Witkowski committed
465
  {
466
    FUNCNAME("ElementObjectDatabase::updateRankData()");
467
    
Thomas Witkowski's avatar
Thomas Witkowski committed
468
469
    TEST_EXIT(macroElementRankMap)("Should not happen!\n");

Thomas Witkowski's avatar
Thomas Witkowski committed
470
    vertexInRank.clear();
471
    for (map<DegreeOfFreedom, vector<ElementObjectData> >::iterator it = vertexElements.begin();
Thomas Witkowski's avatar
Thomas Witkowski committed
472
	 it != vertexElements.end(); ++it) {
473
      for (vector<ElementObjectData>::iterator it2 = it->second.begin(); 
Thomas Witkowski's avatar
Thomas Witkowski committed
474
	   it2 != it->second.end(); ++it2) {
Thomas Witkowski's avatar
Thomas Witkowski committed
475
	int elementInRank = (*macroElementRankMap)[it2->elIndex];	
Thomas Witkowski's avatar
Thomas Witkowski committed
476
477
	if (it2->elIndex > vertexInRank[it->first][elementInRank].elIndex)
	  vertexInRank[it->first][elementInRank] = *it2;
Thomas Witkowski's avatar
Thomas Witkowski committed
478
479
480
      }
    }
    
Thomas Witkowski's avatar
Thomas Witkowski committed
481
    edgeInRank.clear();
482
    for (map<DofEdge, vector<ElementObjectData> >::iterator it = edgeElements.begin();
Thomas Witkowski's avatar
Thomas Witkowski committed
483
	 it != edgeElements.end(); ++it) {
484
      for (vector<ElementObjectData>::iterator it2 = it->second.begin(); 
Thomas Witkowski's avatar
Thomas Witkowski committed
485
	   it2 != it->second.end(); ++it2) {
486
	int elementInRank = (*macroElementRankMap)[it2->elIndex];
Thomas Witkowski's avatar
Thomas Witkowski committed
487
488
	if (it2->elIndex > edgeInRank[it->first][elementInRank].elIndex)
	  edgeInRank[it->first][elementInRank] = *it2;
Thomas Witkowski's avatar
Thomas Witkowski committed
489
490
491
      }
    }
    
Thomas Witkowski's avatar
Thomas Witkowski committed
492
    faceInRank.clear();
493
    for (map<DofFace, vector<ElementObjectData> >::iterator it = faceElements.begin();
Thomas Witkowski's avatar
Thomas Witkowski committed
494
	 it != faceElements.end(); ++it) {
495
      for (vector<ElementObjectData>::iterator it2 = it->second.begin(); 
Thomas Witkowski's avatar
Thomas Witkowski committed
496
	   it2 != it->second.end(); ++it2) {
497
	int elementInRank = (*macroElementRankMap)[it2->elIndex];
Thomas Witkowski's avatar
Thomas Witkowski committed
498
499
	if (it2->elIndex > faceInRank[it->first][elementInRank].elIndex)
	  faceInRank[it->first][elementInRank] = *it2;
Thomas Witkowski's avatar
Thomas Witkowski committed
500
501
502
503
      }
    }
  }

504

Thomas Witkowski's avatar
bla    
Thomas Witkowski committed
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
  void ElementObjectDatabase::clear()
  {
    FUNCNAME("ElementObjectDatabase::clear()");

    vertexElements.clear();
    edgeElements.clear();
    faceElements.clear();

    vertexLocalMap.clear();
    edgeLocalMap.clear();
    faceLocalMap.clear();

    vertexInRank.clear();
    edgeInRank.clear();
    faceInRank.clear();

    bConnMap.clear();
    periodicVertices.clear();
    periodicEdges.clear();
    periodicFaces.clear();
    periodicDofAssoc.clear();
    periodicEdgeAssoc.clear();

    edgeReverseMode.clear();
    faceReverseMode.clear();

    macroElementRankMap = NULL;
    macroElIndexMap.clear();
    macroElIndexTypeMap.clear();
  }


537
  void ElementObjectDatabase::createReverseModeData()
538
  {
539
    FUNCNAME("ElementObjectDatabase::createReverseModeData()");
540

541
542
    // === In 2D, all reverse modes are always true! ===

543
544
545
    if (mesh->getDim() == 2)
      return;

546
547
548

    // === First, create reverse modes for all "directly" neighbouring elements. ===

549
550
551
552
553
554
    for (map<DofEdge, vector<ElementObjectData> >::iterator edgeIt = edgeElements.begin();
	 edgeIt != edgeElements.end(); ++edgeIt) {

      vector<ElementObjectData>& els = edgeIt->second;

      for (unsigned int i = 0; i < els.size(); i++) {
555
556
	BoundaryObject obj0(macroElIndexMap[els[i].elIndex], 
			    macroElIndexTypeMap[els[i].elIndex], 
557
558
559
			    EDGE, els[i].ithObject);

	for (unsigned int j = i + 1; j < els.size(); j++) {
560
561
	  BoundaryObject obj1(macroElIndexMap[els[j].elIndex], 
			      macroElIndexTypeMap[els[j].elIndex], 
562
563
564
565
			      EDGE, els[j].ithObject);

	  bool reverseMode = 
	    BoundaryObject::computeReverseMode(obj0, obj1, feSpace, INTERIOR);
566
567
568
569
	  if (reverseMode) {
	    edgeReverseMode.insert(make_pair(els[i], els[j]));
	    edgeReverseMode.insert(make_pair(els[j], els[i]));
	  }
570
571
572
573
574
575
576
577
578
579
	}
      }
    }

    for (map<DofFace, vector<ElementObjectData> >::iterator faceIt = faceElements.begin();
	 faceIt != faceElements.end(); ++faceIt) {

      vector<ElementObjectData>& els = faceIt->second;

      for (unsigned int i = 0; i < els.size(); i++) {
580
581
	BoundaryObject obj0(macroElIndexMap[els[i].elIndex], 
			    macroElIndexTypeMap[els[i].elIndex], 
582
583
584
			    FACE, els[i].ithObject);

	for (unsigned int j = i + 1; j < els.size(); j++) {
585
586
	  BoundaryObject obj1(macroElIndexMap[els[j].elIndex], 
			      macroElIndexTypeMap[els[j].elIndex], 
587
588
589
590
			      FACE, els[j].ithObject);

	  bool reverseMode = 
	    BoundaryObject::computeReverseMode(obj0, obj1, feSpace, INTERIOR);
591
592
593
594
	  if (reverseMode) {
	    faceReverseMode.insert(make_pair(els[i], els[j]));
	    faceReverseMode.insert(make_pair(els[j], els[i]));
	  }
595
596
597
	}
      }
    }
598
599
600
601
602
603
604
605
606
607


    // === And create reverse modes for periodic neighbouring elements. ===

    for (PerBoundMap<DofEdge>::iterator edgeIt = periodicEdges.begin();
	 edgeIt != periodicEdges.end(); ++edgeIt) {
      vector<ElementObjectData> &edges0 = edgeElements[edgeIt->first.first];
      vector<ElementObjectData> &edges1 = edgeElements[edgeIt->first.second];

      for (unsigned int i = 0; i < edges0.size(); i++) {
608
609
	BoundaryObject obj0(macroElIndexMap[edges0[i].elIndex], 
			    macroElIndexTypeMap[edges0[i].elIndex], 
610
611
612
			    EDGE, edges0[i].ithObject);

	for (unsigned int j = 0; j < edges1.size(); j++) {
613
614
	  BoundaryObject obj1(macroElIndexMap[edges1[j].elIndex], 
			      macroElIndexTypeMap[edges1[j].elIndex], 
615
616
617
			      EDGE, edges1[j].ithObject);

	  bool reverseMode = 
618
619
	    BoundaryObject::computeReverseMode(obj0, obj1, feSpace, 
					       edgeIt->second);
620
621
622
623
	  if (reverseMode) {
	    edgeReverseMode.insert(make_pair(edges0[i], edges1[j]));
	    edgeReverseMode.insert(make_pair(edges1[j], edges0[i]));
	  }
624
625
626
627
628
629
630
631
632
633
634
	}
      }
    }

    for (PerBoundMap<DofFace>::iterator faceIt = periodicFaces.begin();
	 faceIt != periodicFaces.end(); ++faceIt) {
      vector<ElementObjectData> &faces0 = faceElements[faceIt->first.first];
      vector<ElementObjectData> &faces1 = faceElements[faceIt->first.second];

      TEST_EXIT_DBG(faces0.size() == faces1.size() == 1)("Should not happen!\n");

635
636
      BoundaryObject obj0(macroElIndexMap[faces0[0].elIndex], 
			  macroElIndexTypeMap[faces0[0].elIndex], 
637
			  FACE, faces0[0].ithObject);      
638
639
      BoundaryObject obj1(macroElIndexMap[faces1[0].elIndex], 
			  macroElIndexTypeMap[faces1[0].elIndex], 
640
641
642
643
			  FACE, faces1[0].ithObject);
      
      bool reverseMode = 
	BoundaryObject::computeReverseMode(obj0, obj1, feSpace, faceIt->second);
644
645
646
647
      if (reverseMode) {
	faceReverseMode.insert(make_pair(faces0[0], faces1[0]));
	faceReverseMode.insert(make_pair(faces1[0], faces0[0]));
      }
648
    }  
649
650
651
  }


652
  int ElementObjectDatabase::getIterateOwner(int level)
653
654
655
656
657
  {
    FUNCNAME("ElementObjectDatabase::getIterateOwner()");

    TEST_EXIT_DBG(macroElementRankMap)("Should not happen!\n");

658
659
    switch (iterGeoPos) {
    case VERTEX:
660
      return getOwner(vertexElements[vertexIter->first], level);
661
662
      break;
    case EDGE:
663
      return getOwner(edgeElements[edgeIter->first], level);
664
665
      break;
    case FACE:
666
      return getOwner(faceElements[faceIter->first], level);
667
668
669
      break;
    }
    
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
    ERROR_EXIT("There is something reallllly wrong!\n");
    return -1;
  }


  int ElementObjectDatabase::getOwner(DegreeOfFreedom vertex, int level)
  {
    return getOwner(vertexElements[vertex], level);
  }


  int ElementObjectDatabase::getOwner(DofEdge edge, int level)
  {
    return getOwner(edgeElements[edge], level);
  }


  int ElementObjectDatabase::getOwner(DofFace face, int level)
  {
    return getOwner(faceElements[face], level);
  }


  int ElementObjectDatabase::getOwner(vector<ElementObjectData>& objData, 
				      int level)
  {
    int owner = -1;

698
699
700
    std::set<int> &levelRanks = levelData->getLevelRanks(level);
    bool allRanks = (levelRanks.size() == 1 && *(levelRanks.begin()) == -1);
    
701
702
    for (vector<ElementObjectData>::iterator it = objData.begin();
	 it != objData.end(); ++it) {
703
704
705
706
707
708
709
      int elRank = (*macroElementRankMap)[it->elIndex];
      if (allRanks || levelRanks.count(elRank))
	owner = std::max(owner, elRank);
    }
    
    TEST_EXIT_DBG(owner >= 0)("Cannot find owner on level %d\n", level);
    
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
    return owner;
  }


  int ElementObjectDatabase::getIterateMaxLevel()
  {
    FUNCNAME("ElementObjectDatabase::getIterateMaxLevel()");

    int nLevel = levelData->getLevelNumber();
    TEST_EXIT_DBG(nLevel > 0)("Should not happen!\n");

    vector<std::set<int> > ranksInLevel;
    ranksInLevel.resize(nLevel);

    switch (iterGeoPos) {
    case VERTEX:
      {
	vector<ElementObjectData>& vertexData = vertexElements[vertexIter->first];
	for (vector<ElementObjectData>::iterator it = vertexData.begin();
	     it != vertexData.end(); ++it)
	  ranksInLevel[0].insert((*macroElementRankMap)[it->elIndex]);
      }
      break;
    case EDGE:
      {
	vector<ElementObjectData>& edgeData = edgeElements[edgeIter->first];
	for (vector<ElementObjectData>::iterator it = edgeData.begin();
	     it != edgeData.end(); ++it)
	  ranksInLevel[0].insert((*macroElementRankMap)[it->elIndex]);
      }
      break;
    case FACE:
742
743
744
745
746
747
      {
	vector<ElementObjectData>& faceData = faceElements[faceIter->first];
	for (vector<ElementObjectData>::iterator it = faceData.begin();
	     it != faceData.end(); ++it)
	  ranksInLevel[0].insert((*macroElementRankMap)[it->elIndex]);
      }
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
      break;
    default:
      ERROR_EXIT("Should not happen!\n");
    }

    for (std::set<int>::iterator it = ranksInLevel[0].begin(); 
	 it != ranksInLevel[0].end(); ++it) 
      for (int level = 1; level < nLevel; level++)
	ranksInLevel[level].insert(levelData->getLevelId(level, *it));

    int maxLevel = 0;
    for (int level = 1; level < nLevel; level++)
      if (ranksInLevel[level].size() > 1)
	maxLevel = level;
    
    return maxLevel;
  }


767
  void ElementObjectDatabase::serialize(ostream &out)
768
  {
769
    FUNCNAME("ElementObjectDatabase::serialize()");
770
771
772

    int nSize = vertexElements.size();
    SerUtil::serialize(out, nSize);
773
    for (map<DegreeOfFreedom, vector<ElementObjectData> >::iterator it = vertexElements.begin();
774
775
776
777
778
779
780
	 it != vertexElements.end(); ++it) {
      SerUtil::serialize(out, it->first);
      serialize(out, it->second);
    }

    nSize = edgeElements.size();
    SerUtil::serialize(out, nSize);
781
    for (map<DofEdge, vector<ElementObjectData> >::iterator it = edgeElements.begin();
782
783
784
785
786
787
788
	 it != edgeElements.end(); ++it) {
      SerUtil::serialize(out, it->first);
      serialize(out, it->second);
    }

    nSize = faceElements.size();
    SerUtil::serialize(out, nSize);
789
    for (map<DofFace, vector<ElementObjectData> >::iterator it = faceElements.begin();
790
791
792
793
794
795
	 it != faceElements.end(); ++it) {
      SerUtil::serialize(out, it->first);
      serialize(out, it->second);
    }


796

797
798
    nSize = vertexLocalMap.size();
    SerUtil::serialize(out, nSize);
799
    for (map<ElementObjectData, DegreeOfFreedom>::iterator it = vertexLocalMap.begin();
800
801
802
803
804
805
806
	 it != vertexLocalMap.end(); ++it) {
      it->first.serialize(out);
      SerUtil::serialize(out, it->second);
    }

    nSize = edgeLocalMap.size();
    SerUtil::serialize(out, nSize);
807
    for (map<ElementObjectData, DofEdge>::iterator it = edgeLocalMap.begin();
808
809
810
811
812
813
814
	 it != edgeLocalMap.end(); ++it) {
      it->first.serialize(out);
      SerUtil::serialize(out, it->second);
    }

    nSize = faceLocalMap.size();
    SerUtil::serialize(out, nSize);
815
    for (map<ElementObjectData, DofFace>::iterator it = faceLocalMap.begin();
816
817
818
819
820
821
	 it != faceLocalMap.end(); ++it) {
      it->first.serialize(out);
      SerUtil::serialize(out, it->second);
    }


822
    nSize = vertexInRank.size();
823
    SerUtil::serialize(out, nSize);
824
    for (map<DegreeOfFreedom, map<int, ElementObjectData> >::iterator it = vertexInRank.begin();
825
826
827
828
829
830
	 it != vertexInRank.end(); ++it) {
      SerUtil::serialize(out, it->first);
      serialize(out, it->second);
    }

    nSize = edgeInRank.size();
831
    SerUtil::serialize(out, nSize);
832
    for (map<DofEdge, map<int, ElementObjectData> >::iterator it = edgeInRank.begin();
833
834
835
836
837
838
	 it != edgeInRank.end(); ++it) {
      SerUtil::serialize(out, it->first);
      serialize(out, it->second);
    }

    nSize = faceInRank.size();
839
    SerUtil::serialize(out, nSize);
840
    for (map<DofFace, map<int, ElementObjectData> >::iterator it = faceInRank.begin();
841
842
843
844
845
	 it != faceInRank.end(); ++it) {
      SerUtil::serialize(out, it->first);
      serialize(out, it->second);
    }

846
847
848
    SerUtil::serialize(out, periodicVertices);
    SerUtil::serialize(out, periodicEdges);
    SerUtil::serialize(out, periodicFaces);
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869


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

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


    nSize = edgeReverseMode.size();
    SerUtil::serialize(out, nSize);
870
    for (std::set<pair<ElementObjectData, ElementObjectData> >::iterator it = edgeReverseMode.begin();
871
	 it != edgeReverseMode.end(); ++it) {
872
873
      it->first.serialize(out);
      it->second.serialize(out);
874
875
876
877
    }

    nSize = faceReverseMode.size();
    SerUtil::serialize(out, nSize);
878
    for (std::set<pair<ElementObjectData, ElementObjectData> >::iterator it = faceReverseMode.begin();
879
	 it != faceReverseMode.end(); ++it) {
880
881
      it->first.serialize(out);
      it->second.serialize(out);
882
883
      SerUtil::serialize(out, it->second);
    }
884
885
886
  }


887
  void ElementObjectDatabase::deserialize(istream &in)
888
  {
889
    FUNCNAME("ElementObjectDatabase::deserialize()");
890
891
892
893
894
895

    int nSize;
    SerUtil::deserialize(in, nSize);
    vertexElements.clear();
    for (int i = 0; i < nSize; i++) {
      DegreeOfFreedom dof;
896
      vector<ElementObjectData> data;
897
898
899
900
901
902
903
904
905
      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;
906
      vector<ElementObjectData> data;
907
908
909
910
911
912
913
914
915
      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;
916
      vector<ElementObjectData> data;
917
918
919
920
      SerUtil::deserialize(in, face);
      deserialize(in, data);
      faceElements[face] = data;
    }
921
   
922

923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953

    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;
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
954

955
956
957
958
959

    SerUtil::deserialize(in, nSize);
    vertexInRank.clear();
    for (int i = 0; i < nSize; i++) {
      DegreeOfFreedom dof;
960
      map<int, ElementObjectData> data;
961
962
963
964
965
966
967
968
969
      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;
970
      map<int, ElementObjectData> data;
971
972
973
974
975
976
977
978
979
      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;
980
      map<int, ElementObjectData> data;
981
982
983
984
      SerUtil::deserialize(in, face);
      deserialize(in, data);
      faceInRank[face] = data;
    }
985
986
987

    SerUtil::deserialize(in, periodicVertices);
    SerUtil::deserialize(in, periodicEdges);
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
    SerUtil::deserialize(in, periodicFaces);

    

    SerUtil::deserialize(in, nSize);
    periodicDofAssoc.clear();
    for (int i = 0; i < nSize; i++) {
      DegreeOfFreedom dof;
      std::set<DegreeOfFreedom> dofs;
      SerUtil::deserialize(in, dof);
      SerUtil::deserialize(in, dofs);
      periodicDofAssoc[dof] = dofs;
    }

    SerUtil::deserialize(in, nSize);
    periodicEdgeAssoc.clear();
    for (int i = 0; i < nSize; i++) {
      DofEdge edge;
      std::set<DofEdge> edges;
      SerUtil::deserialize(in, edge);
      SerUtil::deserialize(in, edges);
      periodicEdgeAssoc[edge] = edges;
    }



    SerUtil::deserialize(in, nSize);
    edgeReverseMode.clear();
    for (int i = 0; i < nSize; i++) {
      ElementObjectData obj0, obj1;
      obj0.deserialize(in);
      obj1.deserialize(in);

1021
      edgeReverseMode.insert(make_pair(obj0, obj1));
1022
1023
1024
1025
1026
1027
1028
1029
1030
    }

    SerUtil::deserialize(in, nSize);
    faceReverseMode.clear();
    for (int i = 0; i < nSize; i++) {
      ElementObjectData obj0, obj1;
      obj0.deserialize(in);
      obj1.deserialize(in);

1031
      faceReverseMode.insert(make_pair(obj0, obj1));
1032
    }
1033
1034
1035
  }


1036
1037
  void ElementObjectDatabase::serialize(ostream &out, 
					vector<ElementObjectData>& elVec)
1038
1039
1040
1041
1042
1043
1044
1045
  {
    int nSize = elVec.size();
    SerUtil::serialize(out, nSize);
    for (int i = 0; i < nSize; i++)
      elVec[i].serialize(out);
  }


1046
1047
  void ElementObjectDatabase::deserialize(istream &in, 
					  vector<ElementObjectData>& elVec)
1048
1049
1050
1051
1052
1053
1054
1055
1056
  {
    int nSize;
    SerUtil::deserialize(in, nSize);
    elVec.resize(nSize);
    for (int i = 0; i < nSize; i++)
      elVec[i].deserialize(in);
  }

  
1057
1058
  void ElementObjectDatabase::serialize(ostream &out, 
					map<int, ElementObjectData>& data)
1059
1060
1061
  {
    int nSize = data.size();
    SerUtil::serialize(out, nSize);
1062
    for (map<int, ElementObjectData>::iterator it = data.begin();
1063
1064
1065
1066
1067
1068
1069
	 it != data.end(); ++it) {
      SerUtil::serialize(out, it->first);
      it->second.serialize(out);
    }
  }

  
1070
1071
  void ElementObjectDatabase::deserialize(istream &in, 
					  map<int, ElementObjectData>& data)
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
  {
    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;
    }
  }

1085
1086
1087

  unsigned long ElementObjectDatabase::calculateMemoryUsage()
  {
1088
1089
    FUNCNAME("ElementObjectDatabase::calculateMemoryUsage()");

1090
1091
1092
1093
1094
1095
1096
    const unsigned int structElObjDataSize = sizeof(ElementObjectData);
    const unsigned int dofSize = sizeof(DegreeOfFreedom);
    const unsigned int edgeSize = sizeof(DofEdge);
    const unsigned int faceSize = sizeof(DofFace);
    const unsigned int vectorOverhead = sizeof(vector<int>);
    const unsigned int mapOverhead = 48; //sizeof(_Rb_tree<int, int>);
    const unsigned int mapEntryOverhead = 40; // sizeof(_Rb_tree_node_base);
1097
1098
1099
    const unsigned int setOverhead = 48; 
    const unsigned int setEntryOverhead = 40;

1100
1101

    unsigned long value = 0;
1102
    unsigned long tmp = 0;
1103
1104

    // vertexElements
1105
    tmp = mapOverhead + vertexElements.size() * mapEntryOverhead;
1106
    for (map<DegreeOfFreedom, vector<ElementObjectData> >::iterator mapIt =
1107
1108
1109
1110
	   vertexElements.begin(); mapIt != vertexElements.end(); ++mapIt)      
      tmp += dofSize + vectorOverhead + mapIt->second.size() * structElObjDataSize;
    MSG("EL-OBJ-DB MEM 01: %d\n", tmp);
    value += tmp;
1111
1112

    // edgeElements
1113
    tmp = mapOverhead + edgeElements.size() * mapEntryOverhead;
1114
1115
    for (map<DofEdge, vector<ElementObjectData> >::iterator mapIt =
	   edgeElements.begin(); mapIt != edgeElements.end(); ++mapIt)
1116
1117
1118
      tmp += dofSize + vectorOverhead + mapIt->second.size() * structElObjDataSize;
    MSG("EL-OBJ-DB MEM 02: %d\n", tmp);
    value += tmp;
1119
1120

    // faceElements
1121
    tmp += mapOverhead + faceElements.size() * mapEntryOverhead;
1122
1123
    for (map<DofFace, vector<ElementObjectData> >::iterator mapIt =
	   faceElements.begin(); mapIt != faceElements.end(); ++mapIt)
1124
1125
1126
1127
      tmp += dofSize + vectorOverhead + mapIt->second.size() * structElObjDataSize;
    MSG("EL-OBJ-DB MEM 03: %d\n", tmp);
    value += tmp;
    tmp = 0;
1128
1129

    // vertexLocalMap
1130
    tmp += mapOverhead + vertexLocalMap.size() * (mapEntryOverhead + structElObjDataSize + dofSize);
1131
1132

    // edgeLocalMap
1133
    tmp += mapOverhead + edgeLocalMap.size() * (mapEntryOverhead + structElObjDataSize + edgeSize);
1134
1135

    // faceLocalMap
1136
1137
1138
1139
    tmp += mapOverhead + faceLocalMap.size() * (mapEntryOverhead + structElObjDataSize + faceSize);

    MSG("EL-OBJ-DB MEM 04: %d\n", tmp);
    value += tmp;
1140
1141

    // vertexInRank
1142
    tmp = mapOverhead + vertexInRank.size() * mapEntryOverhead;
1143
1144
    for (map<DegreeOfFreedom, map<int, ElementObjectData> >::iterator mapIt = 
	   vertexInRank.begin(); mapIt != vertexInRank.end(); ++mapIt)
1145
      tmp += dofSize + mapOverhead + 
1146
	mapIt->second.size() * (mapEntryOverhead + sizeof(int) + structElObjDataSize);
1147
1148
    MSG("EL-OBJ-DB MEM 05: %d\n", tmp);
    value += tmp;
1149
1150

    // edgeInRank
1151
    tmp += mapOverhead + edgeInRank.size() * mapEntryOverhead;
1152
1153
    for (map<DofEdge, map<int, ElementObjectData> >::iterator mapIt = 
	   edgeInRank.begin(); mapIt != edgeInRank.end(); ++mapIt)
1154
      tmp += edgeSize + mapOverhead + 
1155
	mapIt->second.size() * (mapEntryOverhead + sizeof(int) + structElObjDataSize);
1156
1157
    MSG("EL-OBJ-DB MEM 06: %d\n", tmp);
    value += tmp;
1158
1159

    // faceInRank
1160
    tmp = mapOverhead + faceInRank.size() * mapEntryOverhead;
1161
1162
    for (map<DofFace, map<int, ElementObjectData> >::iterator mapIt = 
	   faceInRank.begin(); mapIt != faceInRank.end(); ++mapIt)
1163
      tmp += faceSize + mapOverhead + 
1164
	mapIt->second.size() * (mapEntryOverhead + sizeof(int) + structElObjDataSize);
1165
1166
1167
    MSG("EL-OBJ-DB MEM 07: %d\n", tmp);
    value += tmp;
    tmp = 0;
1168
1169
1170
1171
1172
1173

    if (bConnMap.size() || periodicVertices.size() || periodicDofAssoc.size()) {
      ERROR_EXIT("Not yet implemented for periodic meshes!\n");
    }

    // edgeReverseMode
1174
    tmp += setOverhead + edgeReverseMode.size() * (setEntryOverhead + 2 * structElObjDataSize);
1175
1176

    // faceReverseMode
1177
    tmp += setOverhead + faceReverseMode.size() * (setEntryOverhead + 2 * structElObjDataSize);
1178
1179

    // macroElIndexMap
1180
    tmp += mapOverhead + macroElIndexMap.size() * (mapEntryOverhead + sizeof(int) + sizeof(int*));
1181
1182

    // macroElIndexTypeMap
1183
1184
1185
1186
    tmp += mapOverhead + macroElIndexTypeMap.size() * (mapEntryOverhead + sizeof(int) + sizeof(int*));

    MSG("EL-OBJ-DB MEM 08: %d\n", tmp);
    value += tmp;
1187
1188
1189
1190

    return value;
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
1191
}