ElementRegion_ED.h 3.35 KB
Newer Older
1
2
3
4
5
6
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
7
// ==  TU Dresden                                                            ==
8
// ==                                                                        ==
9
10
11
// ==  Institut fr Wissenschaftliches Rechnen                               ==
// ==  Zellescher Weg 12-14                                                  ==
// ==  01069 Dresden                                                         ==
12
13
14
15
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
16
// ==  https://gforge.zih.tu-dresden.de/projects/amdis/                      ==
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// ==                                                                        ==
// ============================================================================

/** \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

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

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

    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
63
      ep = new ElementRegion_ED(child1->getElementData());
64
65
66
      ep->region_ = region_;
      child1->setElementData(ep);

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

      return false;
72
    }
73

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

Thomas Witkowski's avatar
Thomas Witkowski committed
82
83
84
85
    inline std::string getTypeName() const 
    { 
      return "ElementRegion_ED"; 
    }
86

Thomas Witkowski's avatar
Thomas Witkowski committed
87
88
89
90
    inline const int getTypeID() const 
    { 
      return ELEMENT_REGION; 
    }
91

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

98
    void deserialize(std::istream& in) 
99
100
101
    {
      ElementData::deserialize(in);
      in.read(reinterpret_cast<char*>(&region_), sizeof(int));
102
    }
103

Thomas Witkowski's avatar
Thomas Witkowski committed
104
105
106
107
    inline void setRegion(int region) 
    { 
      region_ = region; 
    }
108

Thomas Witkowski's avatar
Thomas Witkowski committed
109
110
111
112
    inline int getRegion() const 
    { 
      return region_; 
    }
113
114
115
116
117
118
119
120

  protected:
    int region_;
  };

}

#endif