InteriorBoundary.cc 1.98 KB
Newer Older
1
#include "InteriorBoundary.h"
2
#include "Serializer.h"
3
4

namespace AMDiS {
Thomas Witkowski's avatar
Thomas Witkowski committed
5

6
  AtomicBoundary& InteriorBoundary::getNewAtomic(int rank)
Thomas Witkowski's avatar
Thomas Witkowski committed
7
8
9
10
11
  {
    boundary[rank].resize(boundary[rank].size() + 1);
    return boundary[rank][boundary[rank].size() - 1];
  }

12
13
  void InteriorBoundary::serialize(std::ostream &out)
  {
14
    int mSize = boundary.size();
15
    SerUtil::serialize(out, mSize);
16
17
18
    for (RankToBoundMap::iterator it = boundary.begin(); it != boundary.end(); ++it) {
      int rank = it->first;
      int boundSize = it->second.size();
19
20
      SerUtil::serialize(out, rank);
      SerUtil::serialize(out, boundSize);
21
22
23
      for (int i = 0; i < boundSize; i++) {
	AtomicBoundary &bound = (it->second)[i];

24
25
26
	SerUtil::serialize(out, bound.rankObject.elIndex);
	SerUtil::serialize(out, bound.rankObject.subObjAtBoundary);
	SerUtil::serialize(out, bound.rankObject.ithObjAtBoundary);
27

28
29
30
	SerUtil::serialize(out, bound.neighbourObject.elIndex);
	SerUtil::serialize(out, bound.neighbourObject.subObjAtBoundary);
	SerUtil::serialize(out, bound.neighbourObject.ithObjAtBoundary);
31
32
      }
    }
33
34
  }

35
36
  void InteriorBoundary::deserialize(std::istream &in, 
				     std::map<int, Element*> &elIndexMap)
37
  {
38
    int mSize = 0;
39
    SerUtil::deserialize(in, mSize);
40
41
42
    for (int i = 0; i < mSize; i++) {
      int rank = 0;
      int boundSize = 0;
43
44
      SerUtil::deserialize(in, rank);
      SerUtil::deserialize(in, boundSize);
45
46
47
48
49

      boundary[rank].resize(boundSize);
      for (int i = 0; i < boundSize; i++) {
	AtomicBoundary &bound = boundary[rank][i];

50
51
52
	SerUtil::deserialize(in, bound.rankObject.elIndex);
	SerUtil::deserialize(in, bound.rankObject.subObjAtBoundary);
	SerUtil::deserialize(in, bound.rankObject.ithObjAtBoundary);
53

54
55
56
	SerUtil::deserialize(in, bound.neighbourObject.elIndex);
	SerUtil::deserialize(in, bound.neighbourObject.subObjAtBoundary);
	SerUtil::deserialize(in, bound.neighbourObject.ithObjAtBoundary);
57
58
59
60
61

	bound.rankObject.el = elIndexMap[bound.rankObject.elIndex];
	bound.neighbourObject.el = NULL;
      }
    }
62
  }
63
}