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 ID." 77 "Allows to create new region with given id and label" 78 "or specify existing region by id which will be renamed.")
81 "Label (name) of the region. Has to be unique in one mesh.\n")
83 "The ID of the region to which you assign label.")
85 "The dim of the region to which you assign label. " 86 "Value is taken into account only if 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");
109 if ( reg.is_valid() ) {
112 }
catch (RegionDB::ExcNonuniqueLabel &e) {
117 WarningOut().fmt(
"Unknown region in mesh with label '%s'\n", mesh_label);
125 return IT::Record(
"From_Label",
"Gives a new name to an elementary region" 126 "with original name (in the mesh file) given by ```mesh_label.```")
129 "New label (name) of the region. Has to be unique in one mesh.")
131 "The mesh_label is e.g. physical volume name in GMSH format.")
138 Input::register_class< RegionSetFromLabel, const Input::Record &, Mesh * >(
"From_Label") +
150 unsigned int region_id;
151 string region_label = rec.
val<
string>(
"name");
162 }
catch (RegionDB::ExcNonuniqueLabel &e) {
165 }
catch (RegionDB::ExcAddingIntoClosed &e) {
168 }
catch (RegionDB::ExcCantAdd &e) {
175 it_element != element_list.
end();
179 WarningOut().fmt(
"Region assigned to element with id {} will be rewritten.\n", (*it_element));
181 el_to_reg_map_.insert( std::make_pair((*it_element), region_id) );
190 return IT::Record(
"From_Elements",
"Elementary region declared by a list of elements. " 191 "The new region is assigned to the list of elements spefied by the key" 192 "```element_list```.")
195 "Label (name) of the region. Has to be unique in one mesh.\n")
197 "The ID of the region. " 198 "If unset a unique ID will be generated automatically.")
200 "List of IDs of elements.")
207 Input::register_class< RegionSetFromElements, const Input::Record &, Mesh * >(
"From_Elements") +
234 string name_of_set = rec.
val<
string>(
"name");
244 it_ids != region_ids->end();
249 }
catch(RegionDB::ExcUniqueRegionId &e) {
250 e << region_ids->ei_address();
257 set_names.push_back( reg.
label() );
263 if (region_set.size() == 0) {
264 THROW( ExcEmptyRegionSetResult() << EI_Operation_Type(
"Union") << rec.
ei_address() );
273 return IT::Record(
"Union",
"Defines region (set) as a union of given two or more regions. " 274 "Regions can be given by names or IDs or both ways together.")
277 "Label (name) of the region. Has to be unique in one mesh.\n")
279 "List of region ID numbers that has to be added to the region set.")
281 "Defines region as a union of given pair of regions.")
288 Input::register_class< RegionSetUnion, const Input::Record &, Mesh * >(
"Union") +
300 string name_of_set = rec.
val<
string>(
"name");
304 OLD_ASSERT( set_names.size() == 2,
"Wrong number of operands. Expect 2.\n" );
310 std::stable_sort(set_1.begin(), set_1.end(),
Region::comp);
311 std::stable_sort(set_2.begin(), set_2.end(),
Region::comp);
312 set_diff.resize(set_1.size() + set_2.size());
314 RegionSet::iterator
it = std::set_difference(set_1.begin(), set_1.end(), set_2.begin(), set_2.end(), set_diff.begin(),
Region::comp);
315 set_diff.resize(it - set_diff.begin());
317 if (set_diff.size() == 0) {
318 THROW( ExcEmptyRegionSetResult() << EI_Operation_Type(
"Difference") << rec.
ei_address() );
327 return IT::Record(
"Difference",
"Defines region (set) as a difference of given pair of regions.")
330 "Label (name) of the region. Has to be unique in one mesh.")
332 "List of exactly two regions given by their names.")
339 Input::register_class< RegionSetDifference, const Input::Record &, Mesh * >(
"Difference") +
351 string name_of_set = rec.
val<
string>(
"name");
356 for (
unsigned int i=1; i<set_names.size(); i++) {
357 region_set = this->
intersection( region_set, set_names[i] );
360 if (region_set.size() == 0) {
361 THROW( ExcEmptyRegionSetResult() << EI_Operation_Type(
"Intersection") << rec.
ei_address() );
370 return IT::Record(
"Intersection",
"Defines region (set) as an intersection of given two or more regions.")
373 "Label (name) of the region. Has to be unique in one mesh.\n")
375 "List of two or more regions given by their names.")
381 Input::register_class< RegionSetIntersection, const Input::Record &, Mesh * >(
"Intersection") +
388 RegionSet::iterator
it;
390 std::stable_sort(target_set.begin(), target_set.end(),
Region::comp);
391 std::stable_sort(source_set.begin(), source_set.end(),
Region::comp);
393 set_insec.resize(target_set.size() + source_set.size());
394 it = std::set_intersection(target_set.begin(), target_set.end(), source_set.begin(), source_set.end(), set_insec.begin(),
Region::comp);
395 set_insec.resize(it - set_insec.begin());
RegionDB & region_db_
Reference to region_db_ of Mesh.
static const int registrar
Registrar of class to factory.
RegionSet get_region_set(const std::string &set_name) const
Region rename_region(Region reg, const std::string &new_label)
static const Input::Type::Record & get_region_input_type()
RegionSetIntersection(const Input::Record &rec, Mesh *mesh)
Constructor.
RegionSetFromLabel(const Input::Record &rec, Mesh *mesh)
Constructor.
RegionSetFromId(const Input::Record &rec, Mesh *mesh)
Constructor.
static bool comp(const Region &a, const Region &b)
Comparative method of two regions.
std::string create_label_from_id(unsigned int id) const
RegionSet union_set(std::vector< std::string > set_names) const
const RegionDB & region_db() const
static const int registrar
Registrar of class to factory.
static const int registrar
Registrar of class to factory.
static const Input::Type::Record & get_region_input_type()
RegionSetBase(Mesh *mesh)
Constructor.
RegionDB::MapElementIDToRegionID & el_to_reg_map_
Reference to map stored relevance of elements to regions.
static const int registrar
Registrar of class to factory.
static const Input::Type::Record & get_region_input_type()
static const Input::Type::Record & get_region_input_type()
static const Input::Type::Record & get_region_input_type()
static const Input::Type::Record & get_region_input_type()
static const int registrar
Registrar of class to factory.
Region find_id(unsigned int id, unsigned int dim) const
std::vector< std::string > get_and_check_operands(const Input::Array &operands) const
void add_set(const std::string &set_name, const RegionSet &set)
static const int registrar
Registrar of class to factory.
Region add_region(unsigned int id, const std::string &label, unsigned int dim, const std::string &address="implicit")
RegionSetUnion(const Input::Record &rec, Mesh *mesh)
Constructor.
#define WarningOut()
Macro defining 'warning' record of log.
static Input::Type::Abstract & get_input_type()
RegionSetDifference(const Input::Record &rec, Mesh *mesh)
Constructor.
static const unsigned int undefined_dim
Region find_label(const std::string &label) const
RegionSetFromElements(const Input::Record &rec, Mesh *mesh)
Constructor.
bool is_valid() const
Returns false if the region has undefined/invalid value.
std::string label() const
Returns label of the region (using RegionDB)
RegionSet intersection(RegionSet target_set, const std::string &source_set_name) const
unsigned int get_max_region_id()
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.