SurfaceRegion_ED.h 4 KB
Newer Older
1
2
3
4
5
6
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
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  crystal growth group                                                  ==
// ==                                                                        ==
// ==  Stiftung caesar                                                       ==
// ==  Ludwig-Erhard-Allee 2                                                 ==
// ==  53175 Bonn                                                            ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  http://www.caesar.de/cg/AMDiS                                         ==
// ==                                                                        ==
// ============================================================================

/** \file SurfaceRegion_ED.h */

#ifndef AMDIS_SURFACEREGION_H
#define AMDIS_SURFACEREGION_H

#include "ElementData.h"
#include "FixVec.h"

namespace AMDiS {

  class SurfaceRegion_ED : public ElementData
  {
  public:
    inline bool isOfType(int typeID) const {
34
      if (typeID == SURFACE_REGION) 
35
36
	return true;
      return false;
Thomas Witkowski's avatar
Thomas Witkowski committed
37
    }
38
39
40
41

    class Creator : public CreatorInterface<ElementData>
    {
    public:
42
43
      ElementData* create() 
      {
Thomas Witkowski's avatar
Thomas Witkowski committed
44
	return new SurfaceRegion_ED;
Thomas Witkowski's avatar
Thomas Witkowski committed
45
      }
46
47
48
49
50
51
    };

    SurfaceRegion_ED(ElementData *decorated = NULL)
      : ElementData(decorated),
	side_(-1),
	region_(-1)
Thomas Witkowski's avatar
Thomas Witkowski committed
52
    {}
53
54
55
56
57
58
59
60
61
62
63
64

    bool refineElementData(Element* parent, 
			   Element* child1,
			   Element* child2,
			   int elType)
    {
      ElementData::refineElementData(parent, child1, child2, elType);

      int sideOfChild;
      SurfaceRegion_ED *surfaceRegion;

      sideOfChild = parent->getSideOfChild(0, side_, elType);
65
      if (sideOfChild >= 0) {
Thomas Witkowski's avatar
Thomas Witkowski committed
66
	surfaceRegion = new SurfaceRegion_ED(child1->getElementData());
67
68
69
70
71
72
	surfaceRegion->setSide(sideOfChild);
	surfaceRegion->setRegion(region_);
	child1->setElementData(surfaceRegion);
      }    

      sideOfChild = parent->getSideOfChild(1, side_, elType);
73
      if (sideOfChild >= 0) {
Thomas Witkowski's avatar
Thomas Witkowski committed
74
	surfaceRegion = new SurfaceRegion_ED(child2->getElementData());
75
76
77
78
79
80
	surfaceRegion->side_ = sideOfChild;
	surfaceRegion->region_ = region_;
	child2->setElementData(surfaceRegion);
      }

      return false;
81
    }
82

83
84
    ElementData *clone() const 
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
85
      SurfaceRegion_ED *newObj = new SurfaceRegion_ED;
86
87
88
89
      newObj->side_ = side_;
      newObj->region_ = region_;
      newObj->decorated_ = ElementData::clone();
      return newObj; 
90
    }
91

92
93
94
95
    inline std::string getTypeName() const 
    { 
      return "SurfaceRegion_ED"; 
    }
96

97
98
99
100
    inline const int getTypeID() const 
    { 
      return SURFACE_REGION; 
    }
101

102
    void serialize(std::ostream& out) 
103
104
105
106
    {
      ElementData::serialize(out);
      out.write(reinterpret_cast<const char*>(&side_), sizeof(int));
      out.write(reinterpret_cast<const char*>(&region_), sizeof(int));
107
    }
108

109
    void deserialize(std::istream& in) 
110
111
112
113
    {
      ElementData::deserialize(in);
      in.read(reinterpret_cast<char*>(&side_), sizeof(int));
      in.read(reinterpret_cast<char*>(&region_), sizeof(int));
114
    }
115

116
117
118
119
    inline void setSide(int side) 
    { 
      side_ = side; 
    }
120

121
122
123
124
    inline int getSide() const 
    { 
      return side_; 
    }
125

126
127
128
129
    inline void setRegion(int region) 
    { 
      region_ = region; 
    }
130

131
132
133
134
    inline int getRegion() const 
    { 
      return region_; 
    }
135
136
137
138
139
140
141
142
143

  protected:
    int side_;
    int region_;
  };

}

#endif