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