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] ==
'.');
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")
RegionTable::index< DimId >::type::iterator DimIDIter
void mark_used_region(unsigned int idx)
DECLARE_INPUT_EXCEPTION(ExcUnknownSetOperand,<< "Operation with unknown region set: "<< EI_Label::qval)
Region add_region(unsigned int id, const std::string &label, unsigned int dim, const std::string &address="implicit")
std::map< unsigned int, unsigned int > MapElementIDToRegionID
Region rename_region(Region reg, const std::string &new_label)
RegionTable::index< Label >::type::iterator LabelIter
DECLARE_INPUT_EXCEPTION(ExcUnknownRegion,<< "Unknown region with id: "<< EI_ID::val)
unsigned int boundary_size() const
std::string create_label_from_id(unsigned int id) const
DECLARE_INPUT_EXCEPTION(ExcNonuniqueLabel,<< "Non-unique label during add of elementary region id: "<< EI_ID::val<< ", label: "<< EI_Label::qval<< "\n"<< "other elementary region with same label but different ID: "<< EI_IDOfOtherLabel::val<< " already exists\n")
Region get_region(unsigned int id, unsigned int dim)
TYPEDEF_ERR_INFO(EI_Label, const std::string)
DECLARE_INPUT_EXCEPTION(ExcUniqueRegionId,<< "Id of elementary region must be unique, id: "<< EI_ID::val)
TYPEDEF_ERR_INFO(EI_IDOfOtherLabel, unsigned int)
Region find_label(const std::string &label) const
void print_region_table(std::ostream &stream) const
MapElementIDToRegionID el_to_reg_map_
Region replace_region_dim(DimIDIter it_undef_dim, unsigned int dim, bool boundary)
DECLARE_EXCEPTION(ExcInconsistentBoundary,<< "Inconsistent add of elementary region with id: "<< EI_ID::val<< ", label: "<< EI_Label::qval<< "\n"<< "both ID and label match an existing elementary region with different boundary flag.")
unsigned int n_bulk_
Number of bulk regions.
Region find_id(unsigned int id, unsigned int dim) const
RegionSet all
Make part of general RegionSet table.
RegionSet get_region_set(const std::string &set_name) const
unsigned int bulk_size() const
RegionSetTable sets_
Map of region sets.
DECLARE_INPUT_EXCEPTION(ExcAddingIntoClosed,<< "Can not add label="<< EI_Label::qval<< " into closed MaterialDispatch.\n")
RegionDB()
Default constructor.
Region insert_region(unsigned int id, const std::string &label, unsigned int dim, bool boundary, const std::string &address)
Region find_by_dimid(DimIDIter it_id, unsigned int id, const std::string &label, bool boundary)
unsigned int size() const
bool is_boundary(const std::string &label)
void add_set(const std::string &set_name, const RegionSet &set)
std::pair< unsigned int, unsigned int > DimID
TYPEDEF_ERR_INFO(EI_ID, unsigned int)
DECLARE_INPUT_EXCEPTION(ExcUnknownSet,<< "Operation with unknown region set: "<< EI_Label::qval)
void add_to_set(const std::string &set_name, Region region)
void erase_from_set(const std::string &set_name, Region region)
DECLARE_INPUT_EXCEPTION(ExcCantAdd,<< "Can not add new elementary region into DB, id: "<< EI_ID::val<<", label: "<< EI_Label::qval)
const std::string & get_region_address(unsigned int idx) const
RegionTable region_table_
Database of all regions (both boundary and bulk).
Region implicit_boundary_region()
static const unsigned int undefined_dim
std::vector< std::string > get_and_check_operands(const Input::Array &operands) const
TYPEDEF_ERR_INFO(EI_LabelOfOtherID, const std::string)
unsigned int n_boundary_
Number of boundary regions.
unsigned int get_dim(unsigned int idx) const
Region implicit_boundary_
unsigned int max_id_
Maximal value of Region::id()
static const unsigned int max_n_regions
bool closed_
flag for closed database, no regions can be added, but you can add region sets
RegionSet union_set(std::vector< std::string > set_names) const
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.
const std::string & get_label(unsigned int idx) const
RegionTable::index< OnlyID >::type::iterator OnlyIDIter
unsigned int get_id(unsigned int idx) const
unsigned int boundary_idx() const
Returns index of the region in the boundary set.
unsigned int idx() const
Returns a global index of the region.
RegionIdx(unsigned int index)
bool is_boundary() const
Returns true if it is a Boundary region and false if it is a Bulk region.
bool operator!=(const RegionIdx &other) const
Equality comparison operators for regions.
bool is_valid() const
Returns false if the region has undefined/invalid value.
RegionIdx()
Default region is undefined/invalid.
unsigned int bulk_idx() const
Returns index of the region in the bulk set.
bool operator==(const RegionIdx &other) const
Equality comparison operators for regions.
static const unsigned int undefined
index for undefined region
Region(unsigned int index, const RegionDB &db)
bool is_in_region_set(const RegionSet &set) const
static bool comp(const Region &a, const Region &b)
Comparative method of two regions.
unsigned int id() const
Returns id of the region (using RegionDB)
std::string label() const
Returns label of the region (using RegionDB)
Region(RegionIdx r_idx, const RegionDB &db)
RegionIdx operator()(const Region &)
Region()
Default region is undefined/invalid.
unsigned int dim() const
Returns dimension of the region.
const RegionDB * db_
Global variable with information about all regions.
std::vector< Region > RegionSet
std::map< std::string, RegionSet > RegionSetTable
Type representing a map of RegionSets.
One item in region database.
unsigned int get_id() const
RegionItem(unsigned int index, unsigned int id, const std::string &label, unsigned int dim, const std::string &address, bool used=false)