Flow123d
master-eb60559f2
|
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>
50 namespace BMI=::boost::multi_index;
74 {
return !(
idx_ & 1); }
81 inline unsigned int idx()
const
91 ASSERT( !
is_boundary() )(
idx_).error(
"Try to get bulk index of boundary region with internal idx\n");
176 std::string
label()
const;
179 unsigned int id()
const;
182 unsigned int dim()
const;
246 typedef std::vector<RegionIdx> RegionSet;
247 std::map<std::string, RegionSet > sets_;
250 add_to_set( const string& set_name, RegionIdx region);
253 add_set( const string& set_name, const RegionSet & set);
254 RegionSet union( const string & set_name_1, const string & set_name_2); // sort + std::set_union
255 RegionSet intersection( const string & set_name_1, const string & set_name_2);
256 RegionSet difference( const string & set_name_1, const string & set_name_2);
257 const RegionSet & get_set(const string & set_name);
258 void read_sets_from_input(Input::Record rec); // see structure of RegionDB::get_region_set_input_type()
262 region_ids=[ int ...],
263 region_labels= ["..."], // these are merger together
265 union=["set_1", "set_2"], // later overwrites previous
271 * - MODIFICATION IN MESH AND READER:
272 * Mesh reading proccess:
273 * 1) Read PhysicalNames form GMSH file, populate RegionDB (DONE in GMSH reader, may need small modifications)
274 * 2) Read region definitions from the input, see
275 * - Mesh::read_regions_from_input(Input::Array region_list);
276 * 3) Read nodes (DONE in GMSH reader)
277 * 4) Read elements, per element:
278 * - possibly modify region according map
280 * if found: add_region(ID, get_label, dim, get_boundary_flag) // possibly set dimension of the region if it is undefined
281 * not found: add_region(ID, default_label, dim, false)
282 * - if region is boundary put element into Mesh::element_vec_
283 * else put it into Mesh::element
285 * 5) Setup topology - we has to connect Boundary with existing boundary elements, and add the remaining elements,
286 * 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
302 DECLARE_INPUT_EXCEPTION( ExcAddingIntoClosed, <<
"Can not add label=" << EI_Label::qval <<
" into closed MaterialDispatch.\n");
303 DECLARE_EXCEPTION( ExcNonuniqueID, <<
"Non-unique ID during add of elementary region id: " << EI_ID::val <<
", label: " << EI_Label::qval <<
"\n" \
304 <<
"other elementary region with same ID but different label: " << EI_LabelOfOtherID::qval <<
" already exists\n");
305 DECLARE_INPUT_EXCEPTION( ExcNonuniqueLabel, <<
"Non-unique label during add of elementary region id: " << EI_ID::val <<
", label: " << EI_Label::qval <<
"\n" \
306 <<
"other elementary region with same label but different ID: " << EI_IDOfOtherLabel::val <<
" already exists\n");
307 DECLARE_EXCEPTION( ExcInconsistentBoundary, <<
"Inconsistent add of elementary region with id: " << EI_ID::val <<
", label: " << EI_Label::qval <<
"\n" \
308 <<
"both ID and label match an existing elementary region with different boundary flag.");
310 DECLARE_INPUT_EXCEPTION( ExcCantAdd, <<
"Can not add new elementary region into DB, id: " << EI_ID::val <<
", label: " << EI_Label::qval);
352 Region add_region(
unsigned int id,
const std::string &label,
unsigned int dim,
const std::string &address =
"implicit");
385 const std::string &
get_label(
unsigned int idx)
const;
390 unsigned int get_id(
unsigned int idx)
const;
395 unsigned int get_dim(
unsigned int idx)
const;
407 unsigned int size()
const;
491 typedef std::pair<unsigned int, unsigned int>
DimID;
498 unsigned int get_id()
const {
return id.second;}
499 unsigned int dim()
const {
return id.first;}
518 typedef BMI::multi_index_container<
527 BMI::ordered_unique< BMI::tag<Index>, BMI::member<RegionItem, unsigned int, &RegionItem::index > >,
529 BMI::hashed_unique< BMI::tag<DimId>, BMI::member<RegionItem, DimID, &RegionItem::id> >,
531 BMI::hashed_non_unique< BMI::tag<OnlyID>, BMI::const_mem_fun<RegionItem, unsigned int, &RegionItem::get_id> >,
533 BMI::ordered_unique< BMI::tag<Label>, BMI::member<RegionItem, std::string, &RegionItem::label> >
538 typedef RegionTable::index<Label>::type::iterator
LabelIter;
539 typedef RegionTable::index<DimId>::type::iterator
DimIDIter;
540 typedef RegionTable::index<OnlyID>::type::iterator
OnlyIDIter;
606 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