SurfaceRegion_ED.h 3.93 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
34
35
36
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// ============================================================================
// ==                                                                        ==
// == 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:
    MEMORY_MANAGED(SurfaceRegion_ED);

    inline bool isOfType(int typeID) const {
      if(typeID == SURFACE_REGION) 
	return true;
      return false;
    };

    class Creator : public CreatorInterface<ElementData>
    {
    public:
      ElementData* create() {
	return NEW SurfaceRegion_ED;
      };
    };

    SurfaceRegion_ED(ElementData *decorated = NULL)
      : ElementData(decorated),
	side_(-1),
	region_(-1)
    {};

    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);
      if(sideOfChild >= 0) {
	surfaceRegion = NEW SurfaceRegion_ED(child1->getElementData());
	surfaceRegion->setSide(sideOfChild);
	surfaceRegion->setRegion(region_);
	child1->setElementData(surfaceRegion);
      }    

      sideOfChild = parent->getSideOfChild(1, side_, elType);
      if(sideOfChild >= 0) {
	surfaceRegion = NEW SurfaceRegion_ED(child2->getElementData());
	surfaceRegion->side_ = sideOfChild;
	surfaceRegion->region_ = region_;
	child2->setElementData(surfaceRegion);
      }

      return false;
    };

    ElementData *clone() const { 
      SurfaceRegion_ED *newObj = NEW SurfaceRegion_ED;
      newObj->side_ = side_;
      newObj->region_ = region_;
      newObj->decorated_ = ElementData::clone();
      return newObj; 
    };

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

    inline const int getTypeID() const { return SURFACE_REGION; };

96
    void serialize(std::ostream& out) 
97
98
99
100
101
102
    {
      ElementData::serialize(out);
      out.write(reinterpret_cast<const char*>(&side_), sizeof(int));
      out.write(reinterpret_cast<const char*>(&region_), sizeof(int));
    };

103
    void deserialize(std::istream& in) 
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
    {
      ElementData::deserialize(in);
      in.read(reinterpret_cast<char*>(&side_), sizeof(int));
      in.read(reinterpret_cast<char*>(&region_), sizeof(int));
    };

    inline void setSide(int side) { side_ = side; };

    inline int getSide() const { return side_; };

    inline void setRegion(int region) { region_ = region; };

    inline int getRegion() const { return region_; };

  protected:
    int side_;
    int region_;
  };

}

#endif