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

namespace AMDiS {
Thomas Witkowski's avatar
Thomas Witkowski committed
5
6
7
8
9
10
11

  AtomicBoundary& InteriorBoundary::getNewAtomicBoundary(int rank)
  {
    boundary[rank].resize(boundary[rank].size() + 1);
    return boundary[rank][boundary[rank].size() - 1];
  }

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

	SerUtil::serialize(out, &(bound.rankObject.elIndex));
	SerUtil::serialize(out, &(bound.rankObject.subObjAtBoundary));
	SerUtil::serialize(out, &(bound.rankObject.ithObjAtBoundary));

	SerUtil::serialize(out, &(bound.neighbourObject.elIndex));
	SerUtil::serialize(out, &(bound.neighbourObject.subObjAtBoundary));
	SerUtil::serialize(out, &(bound.neighbourObject.ithObjAtBoundary));
      }
    }
33
34
  }

35
36
  void InteriorBoundary::deserialize(std::istream &in, 
				     std::map<int, Element*> &elIndexMap)
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
    int mSize = 0;
    SerUtil::deserialize(in, &mSize);
    for (int i = 0; i < mSize; i++) {
      int rank = 0;
      int boundSize = 0;
      SerUtil::deserialize(in, &rank);
      SerUtil::deserialize(in, &boundSize);

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

	SerUtil::deserialize(in, &(bound.rankObject.elIndex));
	SerUtil::deserialize(in, &(bound.rankObject.subObjAtBoundary));
	SerUtil::deserialize(in, &(bound.rankObject.ithObjAtBoundary));

	SerUtil::deserialize(in, &(bound.neighbourObject.elIndex));
	SerUtil::deserialize(in, &(bound.neighbourObject.subObjAtBoundary));
	SerUtil::deserialize(in, &(bound.neighbourObject.ithObjAtBoundary));

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