Flow123d
JS_before_hm-2279-gb109077a9
|
Go to the documentation of this file.
37 #include <boost/multi_index/hashed_index.hpp>
38 #include <boost/multi_index/identity_fwd.hpp>
39 #include <boost/multi_index/indexed_by.hpp>
40 #include <boost/multi_index/mem_fun.hpp>
41 #include <boost/multi_index/member.hpp>
42 #include <boost/multi_index/ordered_index.hpp>
43 #include <boost/multi_index/tag.hpp>
44 #include <boost/multi_index_container.hpp>
45 #include <boost/serialization/split_member.hpp>
51 namespace BMI=::boost::multi_index;
75 {
return !(
idx_ & 1); }
82 inline unsigned int idx()
const
92 ASSERT( !
is_boundary() )(
idx_).error(
"Try to get bulk index of boundary region with internal idx\n");
177 std::string
label()
const;
180 unsigned int id()
const;
183 unsigned int dim()
const;
247 typedef std::vector<RegionIdx> RegionSet;
248 std::map<std::string, RegionSet > sets_;
251 add_to_set( const string& set_name, RegionIdx region);
254 add_set( const string& set_name, const RegionSet & set);
255 RegionSet union( const string & set_name_1, const string & set_name_2); // sort + std::set_union
256 RegionSet intersection( const string & set_name_1, const string & set_name_2);
257 RegionSet difference( const string & set_name_1, const string & set_name_2);
258 const RegionSet & get_set(const string & set_name);
259 void read_sets_from_input(Input::Record rec); // see structure of RegionDB::get_region_set_input_type()
263 region_ids=[ int ...],
264 region_labels= ["..."], // these are merger together
266 union=["set_1", "set_2"], // later overwrites previous
272 * - MODIFICATION IN MESH AND READER:
273 * Mesh reading proccess:
274 * 1) Read PhysicalNames form GMSH file, populate RegionDB (DONE in GMSH reader, may need small modifications)
275 * 2) Read region definitions from the input, see
276 * - Mesh::read_regions_from_input(Input::Array region_list);
277 * 3) Read nodes (DONE in GMSH reader)
278 * 4) Read elements, per element:
279 * - possibly modify region according map
281 * if found: add_region(ID, get_label, dim, get_boundary_flag) // possibly set dimension of the region if it is undefined
282 * not found: add_region(ID, default_label, dim, false)
283 * - if region is boundary put element into Mesh::element_vec_
284 * else put it into Mesh::element
286 * 5) Setup topology - we has to connect Boundary with existing boundary elements, and add the remaining elements,
287 * after we remove support for old bCD files we may skip creation of remaining boundary elements since there will be no way how to set
303 DECLARE_INPUT_EXCEPTION( ExcAddingIntoClosed, <<
"Can not add label=" << EI_Label::qval <<
" into closed MaterialDispatch.\n");
304 DECLARE_EXCEPTION( ExcNonuniqueID, <<
"Non-unique ID during add of elementary region id: " << EI_ID::val <<
", label: " << EI_Label::qval <<
"\n" \
305 <<
"other elementary region with same ID but different label: " << EI_LabelOfOtherID::qval <<
" already exists\n");
306 DECLARE_INPUT_EXCEPTION( ExcNonuniqueLabel, <<
"Non-unique label during add of elementary region id: " << EI_ID::val <<
", label: " << EI_Label::qval <<
"\n" \
307 <<
"other elementary region with same label but different ID: " << EI_IDOfOtherLabel::val <<
" already exists\n");
308 DECLARE_EXCEPTION( ExcInconsistentBoundary, <<
"Inconsistent add of elementary region with id: " << EI_ID::val <<
", label: " << EI_Label::qval <<
"\n" \
309 <<
"both ID and label match an existing elementary region with different boundary flag.");
311 DECLARE_INPUT_EXCEPTION( ExcCantAdd, <<
"Can not add new elementary region into DB, id: " << EI_ID::val <<
", label: " << EI_Label::qval);
353 Region add_region(
unsigned int id,
const std::string &label,
unsigned int dim,
const std::string &address =
"implicit");
386 const std::string &
get_label(
unsigned int idx)
const;
391 unsigned int get_id(
unsigned int idx)
const;
396 unsigned int get_dim(
unsigned int idx)
const;
408 unsigned int size()
const;
492 typedef std::pair<unsigned int, unsigned int>
DimID;
499 unsigned int get_id()
const {
return id.second;}
500 unsigned int dim()
const {
return id.first;}
519 typedef BMI::multi_index_container<
528 BMI::ordered_unique< BMI::tag<Index>, BMI::member<RegionItem, unsigned int, &RegionItem::index > >,
530 BMI::hashed_unique< BMI::tag<DimId>, BMI::member<RegionItem, DimID, &RegionItem::id> >,
532 BMI::hashed_non_unique< BMI::tag<OnlyID>, BMI::const_mem_fun<RegionItem, unsigned int, &RegionItem::get_id> >,
534 BMI::ordered_unique< BMI::tag<Label>, BMI::member<RegionItem, std::string, &RegionItem::label> >
539 typedef RegionTable::index<Label>::type::iterator
LabelIter;
540 typedef RegionTable::index<DimId>::type::iterator
DimIDIter;
541 typedef RegionTable::index<OnlyID>::type::iterator
OnlyIDIter;
607 return (label.size() != 0) && (label[0] ==
'.');
RegionTable::index< Label >::type::iterator LabelIter
RegionItem(unsigned int index, unsigned int id, const std::string &label, unsigned int dim, const std::string &address, bool used=false)
RegionIdx(unsigned int index)
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)
Region(unsigned int index, const RegionDB &db)
Region()
Default region is undefined/invalid.
unsigned int size() const
bool is_valid() const
Returns false if the region has undefined/invalid value.
void mark_used_region(unsigned int idx)
std::pair< unsigned int, unsigned int > DimID
RegionDB()
Default constructor.
bool operator==(const RegionIdx &other) const
Equality comparison operators for regions.
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
MapElementIDToRegionID el_to_reg_map_
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
TYPEDEF_ERR_INFO(EI_Label, const std::string)
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
RegionIdx()
Default region is undefined/invalid.
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)
bool operator!=(const RegionIdx &other) const
Equality comparison operators for regions.
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
const RegionDB * db_
Global variable with information about all regions.
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.
std::map< unsigned int, unsigned int > MapElementIDToRegionID
RegionTable region_table_
Database of all regions (both boundary and bulk).
DECLARE_EXCEPTION(ExcNonuniqueID,<< "Non-unique ID during add of elementary region id: "<< EI_ID::val<< ", label: "<< EI_Label::qval<< "\n"<< "other elementary region with same ID but different label: "<< EI_LabelOfOtherID::qval<< " already exists\n")
unsigned int dim() const
Returns dimension of the region.
Region implicit_boundary_region()
RegionIdx operator()(const 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)
std::map< std::string, RegionSet > RegionSetTable
Type representing a map of RegionSets.
BMI::multi_index_container< RegionItem, BMI::indexed_by< BMI::ordered_unique< BMI::tag< Index >, BMI::member< RegionItem, unsigned int, &RegionItem::index > >, BMI::hashed_unique< BMI::tag< DimId >, BMI::member< RegionItem, DimID, &RegionItem::id > >, BMI::hashed_non_unique< BMI::tag< OnlyID >, BMI::const_mem_fun< RegionItem, unsigned int, &RegionItem::get_id > >, BMI::ordered_unique< BMI::tag< Label >, BMI::member< RegionItem, std::string, &RegionItem::label > > > > RegionTable
Region database.
unsigned int boundary_idx() const
Returns index of the region in the boundary set.
Region implicit_boundary_
DECLARE_INPUT_EXCEPTION(ExcAddingIntoClosed,<< "Can not add label="<< EI_Label::qval<< " into closed MaterialDispatch.\n")
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.
unsigned int bulk_idx() const
Returns index of the region in the bulk set.
unsigned int get_id() const
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
RegionSet all
Make part of general RegionSet table.
Region(RegionIdx r_idx, const RegionDB &db)
unsigned int get_id(unsigned int idx) const