21 : region_db_(mesh->region_db_),
22 el_to_reg_map_(mesh->region_db_.el_to_reg_map_) {}
25 return IT::Abstract(
"Region",
"Abstract record for Region.")
39 string region_label = rec.
val<
string>(
"name");
40 unsigned int region_id = rec.
val<
unsigned int>(
"id");
44 }
catch(RegionDB::ExcUniqueRegionId &e) {
50 }
catch (RegionDB::ExcNonuniqueLabel &e) {
58 }
catch (RegionDB::ExcNonuniqueLabel &e) {
61 }
catch (RegionDB::ExcAddingIntoClosed &e) {
64 }
catch (RegionDB::ExcCantAdd &e) {
75 return IT::Record(
"From_Id",
"Region declared by id and name.\n" 76 "Allows to create new region with given id and label\n" 77 "or specify existing region by id which will be renamed.")
80 "Label (name) of the region. Has to be unique in one mesh.\n")
82 "The ID of the region to which you assign label.")
84 "The dim of the region to which you assign label. " 85 "Value is taken into account only if new region is created.")
92 Input::register_class< RegionSetFromId, const Input::Record &, Mesh * >(
"From_Id") +
104 string new_name = rec.
val<
string>(
"name");
105 string mesh_label = rec.
val<
string>(
"mesh_label");
108 if ( reg.is_valid() ) {
111 }
catch (RegionDB::ExcNonuniqueLabel &e) {
116 xprintf(
Warn,
"Unknown region in mesh with label '%s'\n", mesh_label.c_str());
124 return IT::Record(
"From_Label",
"Allows to rename existing region specified by mesh_label.")
127 "New label (name) of the region. Has to be unique in one mesh.")
129 "The mesh_label is e.g. physical volume name in GMSH format.")
136 Input::register_class< RegionSetFromLabel, const Input::Record &, Mesh * >(
"From_Label") +
148 unsigned int region_id;
149 string region_label = rec.
val<
string>(
"name");
162 }
catch (RegionDB::ExcNonuniqueLabel &e) {
165 }
catch (RegionDB::ExcAddingIntoClosed &e) {
168 }
catch (RegionDB::ExcCantAdd &e) {
176 it_element != element_list.
end();
180 xprintf(
Warn,
"Region assigned to element with id %u will be rewritten.\n", (*it_element));
182 el_to_reg_map_.insert( std::make_pair((*it_element), region_id) );
191 return IT::Record(
"From_Elements",
"Region declared by name, ID and enum of elements.\n" 192 "Allows to create new region and assign elements to its.\n" 193 "Elements are specified by ids.")
196 "Label (name) of the region. Has to be unique in one mesh.\n")
198 "The ID of the region to which you assign label.\n" 199 "If new region is created and ID is not set, unique ID will be generated automatically.")
201 "Specification of the region by the list of elements.")
208 Input::register_class< RegionSetFromElements, const Input::Record &, Mesh * >(
"From_Elements") +
235 string name_of_set = rec.
val<
string>(
"name");
245 it_ids != region_ids->end();
250 }
catch(RegionDB::ExcUniqueRegionId &e) {
251 e << region_ids->ei_address();
255 set_names.push_back( reg.
label() );
257 xprintf(
Warn,
"Region with id %d doesn't exist. Skipping\n", (*it_ids));
264 if (region_set.size() == 0) {
265 THROW( ExcEmptyRegionSetResult() << EI_Operation_Type(
"Union") << rec.
ei_address() );
274 return IT::Record(
"Union",
"Defines region as a union of given two or more regions.\n" 275 "Regions can be given by names or IDs or both ways together.")
278 "Label (name) of the region. Has to be unique in one mesh.\n")
280 "List of region ID numbers that has to be added to the region set.")
282 "Defines region as a union of given pair of regions.")
289 Input::register_class< RegionSetUnion, const Input::Record &, Mesh * >(
"Union") +
301 string name_of_set = rec.
val<
string>(
"name");
305 OLD_ASSERT( set_names.size() == 2,
"Wrong number of operands. Expect 2.\n" );
311 std::stable_sort(set_1.begin(), set_1.end(),
Region::comp);
312 std::stable_sort(set_2.begin(), set_2.end(),
Region::comp);
313 set_diff.resize(set_1.size() + set_2.size());
315 RegionSet::iterator
it = std::set_difference(set_1.begin(), set_1.end(), set_2.begin(), set_2.end(), set_diff.begin(),
Region::comp);
316 set_diff.resize(it - set_diff.begin());
318 if (set_diff.size() == 0) {
319 THROW( ExcEmptyRegionSetResult() << EI_Operation_Type(
"Difference") << rec.
ei_address() );
328 return IT::Record(
"Difference",
"Defines region as a difference of given pair of regions.")
331 "Label (name) of the region. Has to be unique in one mesh.\n")
333 "Defines region as a difference of given pair of regions.")
340 Input::register_class< RegionSetDifference, const Input::Record &, Mesh * >(
"Difference") +
352 string name_of_set = rec.
val<
string>(
"name");
357 for (
unsigned int i=1; i<set_names.size(); i++) {
358 region_set = this->
intersection( region_set, set_names[i] );
361 if (region_set.size() == 0) {
362 THROW( ExcEmptyRegionSetResult() << EI_Operation_Type(
"Intersection") << rec.
ei_address() );
371 return IT::Record(
"Intersection",
"Defines region as an intersection of given two or more regions.")
374 "Label (name) of the region. Has to be unique in one mesh.\n")
376 "Defines region as an intersection of given pair of regions.")
382 Input::register_class< RegionSetIntersection, const Input::Record &, Mesh * >(
"Intersection") +
389 RegionSet::iterator
it;
391 std::stable_sort(target_set.begin(), target_set.end(),
Region::comp);
392 std::stable_sort(source_set.begin(), source_set.end(),
Region::comp);
394 set_insec.resize(target_set.size() + source_set.size());
395 it = std::set_intersection(target_set.begin(), target_set.end(), source_set.begin(), source_set.end(), set_insec.begin(),
Region::comp);
396 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.
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.
RegionSet union_set(std::vector< string > set_names) const
RegionSetFromLabel(const Input::Record &rec, Mesh *mesh)
Constructor.
RegionSet intersection(RegionSet target_set, const string &source_set_name) const
RegionSetFromId(const Input::Record &rec, Mesh *mesh)
Constructor.
RegionSet get_region_set(const string &set_name) const
static bool comp(const Region &a, const Region &b)
Comparative method of two regions.
void add_set(const string &set_name, const RegionSet &set)
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< string > get_and_check_operands(const Input::Array &operands) const
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.
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)
unsigned int get_max_region_id()
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.