Flow123d
JS_before_hm-2039-g19af1f327
|
Go to the documentation of this file.
22 : region_db_(*mesh->region_db_),
23 el_to_reg_map_(mesh->region_db_->el_to_reg_map_) {}
26 return IT::Abstract(
"Region",
"Abstract record for Region.")
40 string region_label = rec.
val<
string>(
"name");
41 unsigned int region_id = rec.
val<
unsigned int>(
"id");
45 }
catch(RegionDB::ExcUniqueRegionId &e) {
51 }
catch (RegionDB::ExcNonuniqueLabel &e) {
59 }
catch (RegionDB::ExcNonuniqueLabel &e) {
62 }
catch (RegionDB::ExcAddingIntoClosed &e) {
65 }
catch (RegionDB::ExcCantAdd &e) {
76 return IT::Record(
"From_Id",
"Elementary region declared by its id.\n"
77 "It allows to create a new region with given id and name, "
78 "or to rename an existing region of given id.")
81 "Name (label) of the region. It has to be unique per single mesh.")
83 "Id of the region to which you assign the name.")
85 "Dimension of the region to which you assign the name.\n"
86 "The value is taken into account only if a new region is created.")
93 Input::register_class< RegionSetFromId, const Input::Record &, Mesh * >(
"From_Id") +
105 string new_name = rec.
val<
string>(
"name");
106 string mesh_label = rec.
val<
string>(
"mesh_label");
107 bool allow_empty = rec.
val<
bool>(
"allow_empty");
110 if ( reg.is_valid() ) {
113 }
catch (RegionDB::ExcNonuniqueLabel &e) {
124 catch (RegionDB::ExcNonuniqueLabel &e) {
127 }
catch (RegionDB::ExcAddingIntoClosed &e) {
130 }
catch (RegionDB::ExcCantAdd &e) {
136 WarningOut().fmt(
"Unknown region in mesh with label '{}'\n", mesh_label);
144 return IT::Record(
"From_Label",
"Elementary region declared by its name (label).\n"
145 "It gives a new name to an elementary region "
146 "with the original name (in the mesh file) given by the ```mesh_label.```")
149 "New name (label) of the region. It has to be unique per single mesh.")
151 "The original region name in the input file, e.g. a physical volume name in the GMSH format.")
153 "If true it allows to the region set to be empty (no elements).")
160 Input::register_class< RegionSetFromLabel, const Input::Record &, Mesh * >(
"From_Label") +
172 unsigned int region_id;
173 string region_label = rec.
val<
string>(
"name");
184 }
catch (RegionDB::ExcNonuniqueLabel &e) {
187 }
catch (RegionDB::ExcAddingIntoClosed &e) {
190 }
catch (RegionDB::ExcCantAdd &e) {
197 it_element != element_list.
end();
201 WarningOut().fmt(
"Region assigned to element with id {} will be rewritten.\n", (*it_element));
203 el_to_reg_map_.insert( std::make_pair((*it_element), region_id) );
212 return IT::Record(
"From_Elements",
"Elementary region declared by a list of elements.\n"
213 "The new region is assigned to the list of elements specified by the key "
214 "```element_list```.")
217 "Name (label) of the region. It has to be unique per single mesh.")
220 "If unset, a unique id will be generated automatically.")
222 "List of ids of elements.")
229 Input::register_class< RegionSetFromElements, const Input::Record &, Mesh * >(
"From_Elements") +
256 string name_of_set = rec.
val<
string>(
"name");
266 it_ids != region_ids->end();
271 }
catch(RegionDB::ExcUniqueRegionId &e) {
272 e << region_ids->ei_address();
279 set_names.push_back( reg.
label() );
285 if (region_set.size() == 0) {
286 THROW( ExcEmptyRegionSetResult() << EI_Operation_Type(
"Union") << rec.
ei_address() );
295 return IT::Record(
"Union",
"Defines a new region (set) as a union of two or more regions. "
296 "The regions can be given by their names or ids or both.")
299 "Name (label) of the new region. It has to be unique per single mesh.")
301 "List of region ids to be added to the new region set.")
303 "List of region names (labels) to be added to the new region set.")
310 Input::register_class< RegionSetUnion, const Input::Record &, Mesh * >(
"Union") +
322 string name_of_set = rec.
val<
string>(
"name");
326 OLD_ASSERT( set_names.size() == 2,
"Wrong number of operands. Expect 2.\n" );
332 std::stable_sort(set_1.begin(), set_1.end(),
Region::comp);
333 std::stable_sort(set_2.begin(), set_2.end(),
Region::comp);
334 set_diff.resize(set_1.size() + set_2.size());
336 RegionSet::iterator
it = std::set_difference(set_1.begin(), set_1.end(), set_2.begin(), set_2.end(), set_diff.begin(),
Region::comp);
337 set_diff.resize(
it - set_diff.begin());
339 if (set_diff.size() == 0) {
340 THROW( ExcEmptyRegionSetResult() << EI_Operation_Type(
"Difference") << rec.
ei_address() );
349 return IT::Record(
"Difference",
"Defines a new region (set) as a difference of two regions (sets), given by their names.")
352 "Name (label) of the new region. It has to be unique per single mesh.")
354 "List of exactly two region (set) names.\n"
355 "Supposing region sets r1, r2, the result includes all regions of r1 that are not in r2.")
362 Input::register_class< RegionSetDifference, const Input::Record &, Mesh * >(
"Difference") +
374 string name_of_set = rec.
val<
string>(
"name");
379 for (
unsigned int i=1; i<set_names.size(); i++) {
380 region_set = this->
intersection( region_set, set_names[i] );
383 if (region_set.size() == 0) {
384 THROW( ExcEmptyRegionSetResult() << EI_Operation_Type(
"Intersection") << rec.
ei_address() );
393 return IT::Record(
"Intersection",
"Defines a new region (set) as an intersection of two or more regions (sets)"
394 ", given by their names.")
397 "Name (label) of the new region. It has to be unique per single mesh.")
399 "List of two or more region (set) names.")
405 Input::register_class< RegionSetIntersection, const Input::Record &, Mesh * >(
"Intersection") +
412 RegionSet::iterator
it;
414 std::stable_sort(target_set.begin(), target_set.end(),
Region::comp);
415 std::stable_sort(source_set.begin(), source_set.end(),
Region::comp);
417 set_insec.resize(target_set.size() + source_set.size());
418 it = std::set_intersection(target_set.begin(), target_set.end(), source_set.begin(), source_set.end(), set_insec.begin(),
Region::comp);
419 set_insec.resize(
it - set_insec.begin());
unsigned int get_max_region_id()
RegionSetIntersection(const Input::Record &rec, Mesh *mesh)
Constructor.
RegionSetBase(Mesh *mesh)
Constructor.
static bool comp(const Region &a, const Region &b)
Comparative method of two regions.
std::string label() const
Returns label of the region (using RegionDB)
RegionDB::MapElementIDToRegionID & el_to_reg_map_
Reference to map stored relevance of elements to regions.
const RegionDB & region_db() const
static Input::Type::Abstract & get_input_type()
static const int registrar
Registrar of class to factory.
bool is_valid() const
Returns false if the region has undefined/invalid value.
RegionSet intersection(RegionSet target_set, const std::string &source_set_name) const
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
RegionSetUnion(const Input::Record &rec, Mesh *mesh)
Constructor.
static const int registrar
Registrar of class to factory.
RegionSetFromLabel(const Input::Record &rec, Mesh *mesh)
Constructor.
std::string create_label_from_id(unsigned int id) const
RegionSetFromElements(const Input::Record &rec, Mesh *mesh)
Constructor.
static const unsigned int undefined_dim
static const Input::Type::Record & get_region_input_type()
static const Input::Type::Record & get_region_input_type()
Region rename_region(Region reg, const std::string &new_label)
RegionDB & region_db_
Reference to region_db_ of Mesh.
RegionSet get_region_set(const std::string &set_name) const
static const int registrar
Registrar of class to factory.
Region find_id(unsigned int id, unsigned int dim) const
static const int registrar
Registrar of class to factory.
void add_set(const std::string &set_name, const RegionSet &set)
std::vector< std::string > get_and_check_operands(const Input::Array &operands) const
RegionSetDifference(const Input::Record &rec, Mesh *mesh)
Constructor.
#define WarningOut()
Macro defining 'warning' record of log.
static const Input::Type::Record & get_region_input_type()
static const Input::Type::Record & get_region_input_type()
Region add_region(unsigned int id, const std::string &label, unsigned int dim, const std::string &address="implicit")
static const int registrar
Registrar of class to factory.
static const Input::Type::Record & get_region_input_type()
Region find_label(const std::string &label) const
RegionSetFromId(const Input::Record &rec, Mesh *mesh)
Constructor.
static const int registrar
Registrar of class to factory.
RegionSet union_set(std::vector< std::string > set_names) const
static const Input::Type::Record & get_region_input_type()