ElementRegion_ED.h 3.27 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
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  crystal growth group                                                  ==
// ==                                                                        ==
// ==  Stiftung caesar                                                       ==
// ==  Ludwig-Erhard-Allee 2                                                 ==
// ==  53175 Bonn                                                            ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  http://www.caesar.de/cg/AMDiS                                         ==
// ==                                                                        ==
// ============================================================================

/** \file ElementRegion_ED.h */

#ifndef AMDIS_ELEMENTREGION_ED_H
#define AMDIS_ELEMENTREGION_ED_H

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

namespace AMDiS {

  class ElementRegion_ED : public ElementData
  {
  public:
33
34
35
    inline bool isOfType(int typeID) const 
    {
      if (typeID == ELEMENT_REGION) 
36
37
	return true;
      return false;
38
    }
39
40
41
42
43

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

    ElementRegion_ED(ElementData *decorated = NULL)
      : ElementData(decorated),
	region_(-1)
51
    {}
52
53
54
55
56
57
58
59
60
61

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

      ElementRegion_ED *ep;

Thomas Witkowski's avatar
Thomas Witkowski committed
62
      ep = new ElementRegion_ED(child1->getElementData());
63
64
65
      ep->region_ = region_;
      child1->setElementData(ep);

Thomas Witkowski's avatar
Thomas Witkowski committed
66
      ep = new ElementRegion_ED(child2->getElementData());
67
68
69
70
      ep->region_ = region_;
      child2->setElementData(ep);

      return false;
71
    }
72
73

    ElementData *clone() const { 
Thomas Witkowski's avatar
Thomas Witkowski committed
74
      ElementRegion_ED *newObj = new ElementRegion_ED;
75
76
77
      newObj->region_ = region_;
      newObj->decorated_ = ElementData::clone();
      return newObj; 
78
    }
79

80
    inline std::string getTypeName() const { return "ElementRegion_ED"; }
81

82
    inline const int getTypeID() const { return ELEMENT_REGION; }
83

84
    void serialize(std::ostream& out) 
85
86
87
    {
      ElementData::serialize(out);
      out.write(reinterpret_cast<const char*>(&region_), sizeof(int));
88
    }
89

90
    void deserialize(std::istream& in) 
91
92
93
    {
      ElementData::deserialize(in);
      in.read(reinterpret_cast<char*>(&region_), sizeof(int));
94
    }
95

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

98
    inline int getRegion() const { return region_; }
99
100
101
102
103
104
105
106

  protected:
    int region_;
  };

}

#endif