InteriorBoundary.cc 3.48 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
  bool BoundaryObject::operator==(const BoundaryObject& other) const
  {
    return (other.elIndex == elIndex && 
	    other.subObj == subObj && 
	    other.ithObj == ithObj);
  }


  bool BoundaryObject::operator!=(const BoundaryObject& other) const
  {
    return (other.elIndex != elIndex || 
	    other.subObj != subObj || 
	    other.ithObj != ithObj);
  }


55
  AtomicBoundary& InteriorBoundary::getNewAtomic(int rank)
Thomas Witkowski's avatar
Thomas Witkowski committed
56
57
58
59
60
  {
    boundary[rank].resize(boundary[rank].size() + 1);
    return boundary[rank][boundary[rank].size() - 1];
  }

61

62
63
  void InteriorBoundary::serialize(std::ostream &out)
  {
64
    int mSize = boundary.size();
65
    SerUtil::serialize(out, mSize);
66
67
68
    for (RankToBoundMap::iterator it = boundary.begin(); it != boundary.end(); ++it) {
      int rank = it->first;
      int boundSize = it->second.size();
69
70
      SerUtil::serialize(out, rank);
      SerUtil::serialize(out, boundSize);
71
72
73
      for (int i = 0; i < boundSize; i++) {
	AtomicBoundary &bound = (it->second)[i];

74
	SerUtil::serialize(out, bound.rankObj.elIndex);
75
	SerUtil::serialize(out, bound.rankObj.elType);
76
77
	SerUtil::serialize(out, bound.rankObj.subObj);
	SerUtil::serialize(out, bound.rankObj.ithObj);
78
	SerUtil::serialize(out, bound.rankObj.reverseMode);
79

80
	SerUtil::serialize(out, bound.neighObj.elIndex);
81
	SerUtil::serialize(out, bound.neighObj.elType);
82
83
	SerUtil::serialize(out, bound.neighObj.subObj);
	SerUtil::serialize(out, bound.neighObj.ithObj);
84
	SerUtil::serialize(out, bound.neighObj.reverseMode);
85
86
      }
    }
87
88
  }

89

90
91
  void InteriorBoundary::deserialize(std::istream &in, 
				     std::map<int, Element*> &elIndexMap)
92
  {
93
    int mSize = 0;
94
    SerUtil::deserialize(in, mSize);
95
96
97
    for (int i = 0; i < mSize; i++) {
      int rank = 0;
      int boundSize = 0;
98
99
      SerUtil::deserialize(in, rank);
      SerUtil::deserialize(in, boundSize);
100
101
102
103
104

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

105
	SerUtil::deserialize(in, bound.rankObj.elIndex);
106
	SerUtil::deserialize(in, bound.rankObj.elType);
107
108
	SerUtil::deserialize(in, bound.rankObj.subObj);
	SerUtil::deserialize(in, bound.rankObj.ithObj);
109
	SerUtil::deserialize(in, bound.rankObj.reverseMode);
110

111
	SerUtil::deserialize(in, bound.neighObj.elIndex);
112
	SerUtil::deserialize(in, bound.neighObj.elType);
113
114
	SerUtil::deserialize(in, bound.neighObj.subObj);
	SerUtil::deserialize(in, bound.neighObj.ithObj);
115
	SerUtil::deserialize(in, bound.neighObj.reverseMode);
116

117
118
	bound.rankObj.el = elIndexMap[bound.rankObj.elIndex];
	bound.neighObj.el = NULL;
119
120
      }
    }
121
  }
122
}