Flow123d  JS_before_hm-2210-gb57a0a528
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 
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  */
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  */
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  */
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  */
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  */
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  */
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  */
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_ */
RegionSetBase::get_max_region_id
unsigned int get_max_region_id()
Definition: region_set.hh:53
RegionSetIntersection::RegionSetIntersection
RegionSetIntersection(const Input::Record &rec, Mesh *mesh)
Constructor.
Definition: region_set.cc:371
RegionSetBase::RegionSetBase
RegionSetBase(Mesh *mesh)
Constructor.
Definition: region_set.cc:21
RegionSetBase::el_to_reg_map_
RegionDB::MapElementIDToRegionID & el_to_reg_map_
Reference to map stored relevance of elements to regions.
Definition: region_set.hh:51
Input
Abstract linear system class.
Definition: balance.hh:40
RegionSetFromLabel
Definition: region_set.hh:89
RegionSetBase::get_input_type
static Input::Type::Abstract & get_input_type()
Definition: region_set.cc:25
RegionSetFromId::registrar
static const int registrar
Registrar of class to factory.
Definition: region_set.hh:80
RegionSetIntersection
Definition: region_set.hh:209
RegionSetDifference::FactoryBaseType
RegionSetBase FactoryBaseType
Definition: region_set.hh:187
RegionSetIntersection::intersection
RegionSet intersection(RegionSet target_set, const std::string &source_set_name) const
Definition: region_set.cc:409
std::vector< Region >
RegionSetUnion::RegionSetUnion
RegionSetUnion(const Input::Record &rec, Mesh *mesh)
Constructor.
Definition: region_set.cc:253
RegionSetFromElements::registrar
static const int registrar
Registrar of class to factory.
Definition: region_set.hh:128
RegionSetFromLabel::RegionSetFromLabel
RegionSetFromLabel(const Input::Record &rec, Mesh *mesh)
Constructor.
Definition: region_set.cc:102
RegionSetFromElements::FactoryBaseType
RegionSetBase FactoryBaseType
Definition: region_set.hh:116
exceptions.hh
RegionSetFromElements::RegionSetFromElements
RegionSetFromElements(const Input::Record &rec, Mesh *mesh)
Constructor.
Definition: region_set.cc:169
RegionSetBase
Definition: region_set.hh:35
RegionSetFromElements
Definition: region_set.hh:114
RegionSetBase::DECLARE_INPUT_EXCEPTION
DECLARE_INPUT_EXCEPTION(ExcEmptyRegionSetResult,<< "Empty result of "<< EI_Operation_Type::val<< " operation.")
RegionSetFromElements::get_region_input_type
static const Input::Type::Record & get_region_input_type()
Definition: region_set.cc:210
Input::Record
Accessor to the data with type Type::Record.
Definition: accessors.hh:291
RegionSetIntersection::FactoryBaseType
RegionSetBase FactoryBaseType
Definition: region_set.hh:211
RegionSetDifference
Definition: region_set.hh:185
RegionSetFromLabel::get_region_input_type
static const Input::Type::Record & get_region_input_type()
Definition: region_set.cc:142
Input::Type::Abstract
Class for declaration of polymorphic Record.
Definition: type_abstract.hh:62
RegionSetBase::region_db_
RegionDB & region_db_
Reference to region_db_ of Mesh.
Definition: region_set.hh:49
RegionSetBase::TYPEDEF_ERR_INFO
TYPEDEF_ERR_INFO(EI_Operation_Type, const std::string)
RegionSetIntersection::registrar
static const int registrar
Registrar of class to factory.
Definition: region_set.hh:223
RegionSetFromLabel::registrar
static const int registrar
Registrar of class to factory.
Definition: region_set.hh:103
input_exception.hh
RegionDB
Definition: region.hh:292
std::map< unsigned int, unsigned int >
Input::Type::Record
Record type proxy class.
Definition: type_record.hh:182
RegionDB::max_id_
unsigned int max_id_
Maximal value of Region::id()
Definition: region.hh:554
Mesh
Definition: mesh.h:359
RegionSetUnion::FactoryBaseType
RegionSetBase FactoryBaseType
Definition: region_set.hh:163
RegionSetDifference::RegionSetDifference
RegionSetDifference(const Input::Record &rec, Mesh *mesh)
Constructor.
Definition: region_set.cc:319
RegionSetFromLabel::FactoryBaseType
RegionSetBase FactoryBaseType
Definition: region_set.hh:91
region.hh
RegionSetFromId::get_region_input_type
static const Input::Type::Record & get_region_input_type()
Definition: region_set.cc:74
RegionSetDifference::get_region_input_type
static const Input::Type::Record & get_region_input_type()
Definition: region_set.cc:347
RegionSetDifference::registrar
static const int registrar
Registrar of class to factory.
Definition: region_set.hh:199
RegionSetIntersection::get_region_input_type
static const Input::Type::Record & get_region_input_type()
Definition: region_set.cc:391
RegionSetUnion
Definition: region_set.hh:161
RegionSetFromId::FactoryBaseType
RegionSetBase FactoryBaseType
Definition: region_set.hh:68
RegionSetFromId::RegionSetFromId
RegionSetFromId(const Input::Record &rec, Mesh *mesh)
Constructor.
Definition: region_set.cc:36
RegionSetUnion::registrar
static const int registrar
Registrar of class to factory.
Definition: region_set.hh:175
RegionSetFromId
Definition: region_set.hh:66
RegionSetUnion::get_region_input_type
static const Input::Type::Record & get_region_input_type()
Definition: region_set.cc:293