InteriorBoundary.cc 3.12 KB
Newer Older
1
#include "InteriorBoundary.h"
2
3
#include "FiniteElemSpace.h"
#include "BasisFunction.h"
4
#include "Serializer.h"
5
6

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

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  void BoundaryObject::setReverseMode(BoundaryObject &otherBound, 
				      FiniteElemSpace *feSpace)
  {
    FUNCNAME("BoundaryObject::setReverseMode()");

    bool otherMode = false;

    const BasisFunction *basFcts = feSpace->getBasisFcts();
    int nBasFcts = basFcts->getNumber();
    std::vector<DegreeOfFreedom> localDofs0(nBasFcts), localDofs1(nBasFcts);
    
    switch (feSpace->getMesh()->getDim()) {
    case 2:
      ERROR_EXIT("Not yet implemented!\n");
      break;
    case 3:
      if (ithObj == 2 || ithObj == 3) {
	basFcts->getLocalIndices(el, feSpace->getAdmin(), localDofs0);
	basFcts->getLocalIndices(otherBound.el, feSpace->getAdmin(), localDofs1);
	otherMode = (localDofs0[0] != localDofs1[0]);
      }

      break;
    default:
      ERROR_EXIT("This should not happen!\n");
    }

    otherBound.reverseMode = otherMode;
  }


39
  AtomicBoundary& InteriorBoundary::getNewAtomic(int rank)
Thomas Witkowski's avatar
Thomas Witkowski committed
40
41
42
43
44
  {
    boundary[rank].resize(boundary[rank].size() + 1);
    return boundary[rank][boundary[rank].size() - 1];
  }

45

46
47
  void InteriorBoundary::serialize(std::ostream &out)
  {
48
    int mSize = boundary.size();
49
    SerUtil::serialize(out, mSize);
50
51
52
    for (RankToBoundMap::iterator it = boundary.begin(); it != boundary.end(); ++it) {
      int rank = it->first;
      int boundSize = it->second.size();
53
54
      SerUtil::serialize(out, rank);
      SerUtil::serialize(out, boundSize);
55
56
57
      for (int i = 0; i < boundSize; i++) {
	AtomicBoundary &bound = (it->second)[i];

58
	SerUtil::serialize(out, bound.rankObj.elIndex);
59
	SerUtil::serialize(out, bound.rankObj.elType);
60
61
	SerUtil::serialize(out, bound.rankObj.subObj);
	SerUtil::serialize(out, bound.rankObj.ithObj);
62
	SerUtil::serialize(out, bound.rankObj.reverseMode);
63

64
	SerUtil::serialize(out, bound.neighObj.elIndex);
65
	SerUtil::serialize(out, bound.neighObj.elType);
66
67
	SerUtil::serialize(out, bound.neighObj.subObj);
	SerUtil::serialize(out, bound.neighObj.ithObj);
68
	SerUtil::serialize(out, bound.neighObj.reverseMode);
69
70
      }
    }
71
72
  }

73

74
75
  void InteriorBoundary::deserialize(std::istream &in, 
				     std::map<int, Element*> &elIndexMap)
76
  {
77
    int mSize = 0;
78
    SerUtil::deserialize(in, mSize);
79
80
81
    for (int i = 0; i < mSize; i++) {
      int rank = 0;
      int boundSize = 0;
82
83
      SerUtil::deserialize(in, rank);
      SerUtil::deserialize(in, boundSize);
84
85
86
87
88

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

89
	SerUtil::deserialize(in, bound.rankObj.elIndex);
90
	SerUtil::deserialize(in, bound.rankObj.elType);
91
92
	SerUtil::deserialize(in, bound.rankObj.subObj);
	SerUtil::deserialize(in, bound.rankObj.ithObj);
93
	SerUtil::deserialize(in, bound.rankObj.reverseMode);
94

95
	SerUtil::deserialize(in, bound.neighObj.elIndex);
96
	SerUtil::deserialize(in, bound.neighObj.elType);
97
98
	SerUtil::deserialize(in, bound.neighObj.subObj);
	SerUtil::deserialize(in, bound.neighObj.ithObj);
99
	SerUtil::deserialize(in, bound.neighObj.reverseMode);
100

101
102
	bound.rankObj.el = elIndexMap[bound.rankObj.elIndex];
	bound.neighObj.el = NULL;
103
104
      }
    }
105
  }
106
}