Flow123d  release_2.2.0-914-gf1a3a4f
region_set.hh
Go to the documentation of this file.
1 /*
2  * region_set.hh
3  *
4  * Created on: Nov 27, 2012
5  * Author: jb
6  */
7 
8 #ifndef REGION_SET_HH_
9 #define REGION_SET_HH_
10 
11 
12 #include "mesh/region.hh"
13 #include "input/accessors.hh"
14 #include "input/input_type.hh"
15 
16 class Mesh;
17 
18 /**
19  * Base class represented regions.
20  *
21  * Every descendant must contain:
22  * - constructor what adds region to RegionDB with arguments Input::Record and Mesh
23  * - static generating function created Input Type Record
24  * - static registrar class member for registration class to factory
25  */
27 public:
28  /**
29  * Returns whole tree of input types for Region with all descendants.
30  */
32 
33  TYPEDEF_ERR_INFO( EI_Operation_Type, const std::string);
34  DECLARE_INPUT_EXCEPTION( ExcEmptyRegionSetResult, << "Empty result of " << EI_Operation_Type::val << " operation.");
35 
36 protected:
37  /// Constructor
38  RegionSetBase(Mesh *mesh);
39  /// Reference to region_db_ of Mesh
41  /// Reference to map stored relevance of elements to regions.
43 
44  unsigned int get_max_region_id() {
45  return region_db_.max_id_+1;
46  }
47 };
48 
49 
50 /**
51  * Region declared by id and name.
52  *
53  * Allows to create new region with given id and label or specify existing region by id
54  * which will be renamed. If existing label is given, it must correspond with appropriate
55  * id in RegionDB.
56  */
58 public:
60 
61  /// Constructor
62  RegionSetFromId(const Input::Record &rec, Mesh *mesh);
63 
64  /**
65  * Returns Input Type Record of Region
66  */
67  static const Input::Type::Record & get_region_input_type();
68 
69 private:
70  /// Registrar of class to factory
71  static const int registrar;
72 
73 };
74 
75 
76 /**
77  * Region allows to rename existing region specified by mesh_label (e.g. physical volume
78  * name in GMSH format).
79  */
81 public:
83 
84  /// Constructor
85  RegionSetFromLabel(const Input::Record &rec, Mesh *mesh);
86 
87  /**
88  * Returns Input Type Record of Region
89  */
90  static const Input::Type::Record & get_region_input_type();
91 
92 private:
93  /// Registrar of class to factory
94  static const int registrar;
95 
96 };
97 
98 
99 /**
100  * Region declared by name, ID and enum of elements.
101  *
102  * Allows to get existing region or create new and assign elements to its. Elements are
103  * specified by ids. If id of new region is not set, it is generated automatically.
104  */
106 public:
108 
109  /// Constructor
110  RegionSetFromElements(const Input::Record &rec, Mesh *mesh);
111 
112  /**
113  * Returns Input Type Record of Region
114  */
115  static const Input::Type::Record & get_region_input_type();
116 
117 private:
118  /// Registrar of class to factory
119  static const int registrar;
120 
121 };
122 
123 
124 /**
125  * Need new implementation, will be solved later.
126  */
127 /*
128 class RegionSetBoundary : public RegionSetBase {
129 public:
130  typedef RegionSetBase FactoryBaseType;
131 
132  /// Constructor
133  RegionSetBoundary(const Input::Record &rec, Mesh *mesh);
134 
135  /// Returns Input Type Record of Region
136  static const Input::Type::Record & get_region_input_type();
137 
138 private:
139  /// Registrar of class to factory
140  static const int registrar;
141 
142 };
143 */
144 
145 
146 /**
147  * Defines region as a union of given two or more other regions.
148  *
149  * Regions can be given by names or IDs or both ways together. Non-empty set must be the result
150  * of the operation.
151  */
153 public:
155 
156  /// Constructor
157  RegionSetUnion(const Input::Record &rec, Mesh *mesh);
158 
159  /**
160  * Returns Input Type Record of Region
161  */
162  static const Input::Type::Record & get_region_input_type();
163 
164 private:
165  /// Registrar of class to factory
166  static const int registrar;
167 
168 };
169 
170 
171 /**
172  * Defines region as a difference of given pair of regions.
173  *
174  * Non-empty set must be the result of the operation.
175  */
177 public:
179 
180  /// Constructor
181  RegionSetDifference(const Input::Record &rec, Mesh *mesh);
182 
183  /**
184  * Returns Input Type Record of Region
185  */
186  static const Input::Type::Record & get_region_input_type();
187 
188 private:
189  /// Registrar of class to factory
190  static const int registrar;
191 
192 };
193 
194 
195 /**
196  * Defines region as an intersection of given two or more regions.
197  *
198  * Non-empty set must be the result of the operation.
199  */
201 public:
203 
204  /// Constructor
205  RegionSetIntersection(const Input::Record &rec, Mesh *mesh);
206 
207  /**
208  * Returns Input Type Record of Region
209  */
210  static const Input::Type::Record & get_region_input_type();
211 
212 private:
213  /// Registrar of class to factory
214  static const int registrar;
215 
216  /**
217  * Get RegionSet of specified name and create its intersection with target RegionSet.
218  *
219  * @param target_set First RegionSet
220  * @param set_name Name of second RegionSet
221  * @return RegionSet created of intersection operation
222  */
223  RegionSet intersection( RegionSet target_set, const string & source_set_name) const;
224 };
225 
226 
227 
228 #endif /* REGION_SET_HH_ */
RegionDB & region_db_
Reference to region_db_ of Mesh.
Definition: region_set.hh:40
static const int registrar
Registrar of class to factory.
Definition: region_set.hh:94
RegionSetBase FactoryBaseType
Definition: region_set.hh:107
RegionSetBase FactoryBaseType
Definition: region_set.hh:59
Definition: mesh.h:99
unsigned int max_id_
Maximal value of Region::id()
Definition: region.hh:553
static const int registrar
Registrar of class to factory.
Definition: region_set.hh:190
static const int registrar
Registrar of class to factory.
Definition: region_set.hh:119
RegionSetBase(Mesh *mesh)
Constructor.
Definition: region_set.cc:21
RegionDB::MapElementIDToRegionID & el_to_reg_map_
Reference to map stored relevance of elements to regions.
Definition: region_set.hh:42
static const int registrar
Registrar of class to factory.
Definition: region_set.hh:166
static const int registrar
Registrar of class to factory.
Definition: region_set.hh:71
Accessor to the data with type Type::Record.
Definition: accessors.hh:292
RegionSetBase FactoryBaseType
Definition: region_set.hh:178
static const int registrar
Registrar of class to factory.
Definition: region_set.hh:214
Class for declaration of polymorphic Record.
TYPEDEF_ERR_INFO(EI_Operation_Type, const std::string)
RegionSetBase FactoryBaseType
Definition: region_set.hh:82
RegionSetBase FactoryBaseType
Definition: region_set.hh:154
RegionSetBase FactoryBaseType
Definition: region_set.hh:202
static Input::Type::Abstract & get_input_type()
Definition: region_set.cc:25
Record type proxy class.
Definition: type_record.hh:182
DECLARE_INPUT_EXCEPTION(ExcEmptyRegionSetResult,<< "Empty result of "<< EI_Operation_Type::val<< " operation.")
unsigned int get_max_region_id()
Definition: region_set.hh:44