Flow123d
JB_transport-112d700
|
Go to the documentation of this file.
33 {
return db_->get_label(idx_); }
38 {
return db_->get_id(idx_); }
43 {
return db_->get_dim(idx_); }
47 for(
const Region ® : set)
48 if (reg.idx_ == this->idx_)
return true;
64 : closed_(false), n_boundary_(0), n_bulk_(0), max_id_(0) {
78 return Region(it_id->index, *
this);
102 THROW(ExcNonuniqueLabel() << EI_Label(label) << EI_ID(
id) << EI_IDOfOtherLabel(it_label->get_id()) );
110 ASSERT(reg.
is_valid())(new_label).error(
"Non-existing region can't be renamed.\n");
115 if ( reg.
id() == it_label->index ) {
119 THROW(ExcNonuniqueLabel() << EI_Label(new_label) << EI_ID(reg.
id()) << EI_IDOfOtherLabel(it_label->get_id()) );
124 unsigned int index = reg.
idx();
130 RegionItem item(index, reg.
id(), new_label, reg.
dim(), this->get_region_address(index));
136 WarningOut().fmt(
"Change boundary flag of region with id {} and label {}.\n", reg.
id(), new_label);
137 if (old_boundary_flag) {
146 return Region(index, *
this);
154 return Region(it_id->index, *
this);
173 return Region(it_label->index, *
this);
184 return Region(it_id->index, *
this);
193 THROW( ExcUniqueRegionId() << EI_ID(
id ) );
197 return Region(it_id->index, *
this);
239 unsigned int index =
it->index;
277 RegionSetTable::iterator
it =
sets_.find(set_name);
281 set.push_back(region);
283 sets_.insert( std::make_pair(set_name, set) );
286 if ( std::find(set.begin(), set.end(), region)==set.end() ) {
287 set.push_back(region);
296 sets_.insert( std::make_pair(set_name, set) );
302 RegionSetTable::iterator
it =
sets_.find(set_name);
306 auto set_it = std::find(set.begin(), set.end(), region);
307 ASSERT_PERMANENT(set_it != set.end())(set_name).error(
"Erased region was not found in set.");
317 for (
string name : names) {
319 THROW( ExcUnknownSet() << EI_Label( name )
329 RegionSetTable::const_iterator
it =
sets_.find(set_name);
339 ss <<
"region_" << id;
344 if (
closed_)
THROW( ExcAddingIntoClosed() << EI_Label(label) << EI_ID(
id) );
356 THROW( ExcCantAdd() << EI_Label(label) << EI_ID(
id) );
364 region_set.push_back( reg );
377 unsigned int reg_id = it_undef_dim->get_id();
379 .error(
"Dimension of replaced region with 'reg_id' must be undefined_dim\n");
381 unsigned int index = it_undef_dim->index;
383 RegionItem item(index, reg_id, it_undef_dim->label, dim, this->get_region_address(index));
391 THROW(ExcInconsistentBoundary() << EI_Label(it_undef_dim->label) << EI_ID(reg_id) );
397 unsigned int index = it_id->index;
400 THROW(ExcNonuniqueID() << EI_Label(label) << EI_ID(
id) << EI_LabelOfOtherID(it_id->label) );
405 THROW(ExcInconsistentBoundary() << EI_Label(label) << EI_ID(
id) );
415 for (RegionSetTable::const_iterator
it =
sets_.begin();
it !=
sets_.end(); ++
it) {
416 string rset_label =
it->first;
419 if ( (rset_label.size() > 0) && (rset_label[0] ==
'.') ) boundaries.push_back(rset_label);
420 else bulks.push_back(rset_label);
422 sets.push_back(rset_label);
428 stream <<
"----------- Table of all regions: -----------";
429 if (boundaries.size()) {
430 stream << endl <<
" - Boundary elementary regions -" << endl;
431 stream << std::setfill(
' ') <<
"name" << setw(14) <<
"" << setw(6) <<
"id" <<
" dim" << endl;
434 stream << std::left << setw(18) << (*it) << std::right << setw(6) << label_it->get_id() << setw(4) << label_it->dim() << endl;
438 stream << endl <<
" - Bulk elementary regions -" << endl;
439 stream <<
"name" << setw(14) <<
"" << setw(6) <<
"id" <<
" dim" << endl;
442 stream << std::left << setw(18) << (*it) << std::right << setw(6) << label_it->get_id() << setw(4) << label_it->dim() << endl;
446 stream << endl <<
" - Sets of regions -" << endl;
447 stream <<
"name" << setw(14) <<
"" <<
"contains regions" << endl;
449 RegionSetTable::const_iterator set_it =
sets_.find(*
it);
450 stream << std::left << setw(18) << (*it) << std::right <<
"[";
451 for (RegionSet::const_iterator r_it = set_it->second.begin(); r_it!=set_it->second.end(); ++r_it) {
452 if (r_it != set_it->second.begin()) stream <<
", ";
453 stream <<
"\"" << r_it->label() <<
"\"";
455 stream <<
"]" << endl;
458 stream << std::setfill(
'-') << setw(45) <<
"" << std::setfill(
' ') << endl << endl;
466 WarningOut().fmt(
"Too many regions are defined (bulk {} + boundary {} >= {}). This may have negative impact on performace.\n"
467 "The user is adviced to simplify the input data and to decrease the number of regions (e.g. using FieldFE input).\n",
475 WarningOut().fmt(
"Region [id = {}, label = '{}'] is not used in any element.",
476 it->get_id(),
it->label);
485 for (
string set_name : set_names) {
487 set.insert(r_set.begin(), r_set.end());
490 return RegionSet(set.begin(), set.end());
RegionTable::index< Label >::type::iterator LabelIter
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)
const std::string & get_label(unsigned int idx) const
Region insert_region(unsigned int id, const std::string &label, unsigned int dim, bool boundary, const std::string &address)
void swap(nlohmann::json &j1, nlohmann::json &j2) noexcept(is_nothrow_move_constructible< nlohmann::json >::value and is_nothrow_move_assignable< nlohmann::json >::value)
exchanges the values of two JSON objects
unsigned int size() const
bool is_valid() const
Returns false if the region has undefined/invalid value.
void mark_used_region(unsigned int idx)
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
std::pair< unsigned int, unsigned int > DimID
RegionDB()
Default constructor.
Region get_region(unsigned int id, unsigned int dim)
unsigned int idx() const
Returns a global index of the region.
std::vector< Region > RegionSet
std::string create_label_from_id(unsigned int id) const
static const unsigned int undefined
index for undefined region
unsigned int id() const
Returns id of the region (using RegionDB)
unsigned int boundary_size() const
static const unsigned int undefined_dim
Region replace_region_dim(DimIDIter it_undef_dim, unsigned int dim, bool boundary)
bool is_in_region_set(const RegionSet &set) const
const std::string & get_region_address(unsigned int idx) const
#define ASSERT_PERMANENT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
One item in region database.
unsigned int bulk_size() const
bool is_boundary() const
Returns true if it is a Boundary region and false if it is a Bulk region.
unsigned int n_boundary_
Number of boundary regions.
RegionTable::index< OnlyID >::type::iterator OnlyIDIter
Region rename_region(Region reg, const std::string &new_label)
RegionSet get_region_set(const std::string &set_name) const
Region find_id(unsigned int id, unsigned int dim) const
bool closed_
flag for closed database, no regions can be added, but you can add region sets
void add_set(const std::string &set_name, const RegionSet &set)
std::vector< std::string > get_and_check_operands(const Input::Array &operands) const
void add_to_set(const std::string &set_name, Region region)
RegionSetTable sets_
Map of region sets.
RegionTable region_table_
Database of all regions (both boundary and bulk).
unsigned int dim() const
Returns dimension of the region.
#define ASSERT_PERMANENT_EQ(a, b)
Definition of comparative assert macro (EQual)
Region implicit_boundary_region()
unsigned int max_id_
Maximal value of Region::id()
RegionTable::index< DimId >::type::iterator DimIDIter
unsigned int get_dim(unsigned int idx) const
Region find_by_dimid(DimIDIter it_id, unsigned int id, const std::string &label, bool boundary)
#define WarningOut()
Macro defining 'warning' record of log.
Region add_region(unsigned int id, const std::string &label, unsigned int dim, const std::string &address="implicit")
void print_region_table(std::ostream &stream) const
Region find_label(const std::string &label) const
static const unsigned int max_n_regions
unsigned int n_bulk_
Number of bulk regions.
bool is_boundary(const std::string &label)
void erase_from_set(const std::string &set_name, Region region)
RegionSet union_set(std::vector< std::string > set_names) const
unsigned int get_id(unsigned int idx) const