SurfaceRegion_ED.h 3.89 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
// ============================================================================
// ==                                                                        ==
// == 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 {
      if(typeID == SURFACE_REGION) 
	return true;
      return false;
Thomas Witkowski's avatar
Thomas Witkowski committed
37
    }
38
39
40
41
42

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

    SurfaceRegion_ED(ElementData *decorated = NULL)
      : ElementData(decorated),
	side_(-1),
	region_(-1)
Thomas Witkowski's avatar
Thomas Witkowski committed
51
    {}
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);
      if(sideOfChild >= 0) {
Thomas Witkowski's avatar
Thomas Witkowski committed
65
	surfaceRegion = new SurfaceRegion_ED(child1->getElementData());
66
67
68
69
70
71
72
	surfaceRegion->setSide(sideOfChild);
	surfaceRegion->setRegion(region_);
	child1->setElementData(surfaceRegion);
      }    

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

      return false;
    };

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

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

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

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

101
    void deserialize(std::istream& in) 
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
    {
      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