30 #include <boost/multi_index_container.hpp>
31 #include <boost/multi_index/ordered_index.hpp>
32 #include <boost/multi_index/random_access_index.hpp>
33 #include <boost/multi_index/hashed_index.hpp>
34 #include <boost/multi_index/member.hpp>
36 namespace BMI=::boost::multi_index;
42 namespace Type {
class Record; }
67 {
return !(
idx_ & 1); }
74 inline unsigned int idx()
const
155 std::string
label()
const;
158 unsigned int id()
const;
161 unsigned int dim()
const;
167 //inline explicit operator RegionIdx() const {
168 // return RegionIdx(this->idx_);
242 typedef std::vector<RegionIdx> RegionSet;
243 std::map<std::string, RegionSet > sets_;
246 add_to_set( const string& set_name, RegionIdx region);
249 add_set( const string& set_name, const RegionSet & set);
250 RegionSet union( const string & set_name_1, const string & set_name_2); // sort + std::set_union
251 RegionSet intersection( const string & set_name_1, const string & set_name_2);
252 RegionSet difference( const string & set_name_1, const string & set_name_2);
253 const RegionSet & get_set(const string & set_name);
254 void read_sets_from_input(Input::Record rec); // see structure of RegionDB::region_set_input_type
258 region_ids=[ int ...],
259 region_labels= ["..."], // these are merger together
261 union=["set_1", "set_2"], // later overwrites previous
267 * - MODIFICATION IN MESH AND READER:
268 * Mesh reading proccess:
269 * 1) Read PhysicalNames form GMSH file, populate RegionDB (DONE in GMSH reader, may need small modifications)
270 * 2) Read region definitions from the input, see
272 * typedef std::map<unsigned int, unsigned int> MapElementIDToRegionID;
273 * RegionDB::read_regions_from_input(Input::Array region_list, MapElementIDToRegionID &map);
276 * (TODO in RegionDB, also creates (and return to Mesh) element regions modification map: std::map< unsigned int, RegionIdx>
277 * that maps element IDs to the new region names, GMSH reader should have setter method to accept this map
278 * and modify the elements during reading)
279 * 3) Read region sets - TODO in RegionDB
280 * 4) Read boundary key of the Mesh record and mark appropriate regions as boundary (TODO in RegionDB)
281 * 5) Read nodes (DONE in GMSH reader)
282 * 6) Read elements, per element:
283 * - possibly modify region according map
285 * if found: add_region(ID, get_label, dim, get_boundary_flag) // possibly set dimension of the region if it is undefined
286 * not found: add_region(ID, default_label, dim, false)
287 * - if region is boundary put element into Mesh::bc_elements
288 * else put it into Mesh::element
290 * 7) Setup topology - we has to connect Boundary with existing bc_elements, and add the remaining elements,
291 * 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
316 DECLARE_EXCEPTION( ExcAddingIntoClosed, <<
"Can not add label=" << EI_Label::qval <<
" into closed MaterialDispatch.\n");
318 DECLARE_EXCEPTION( ExcNonuniqueID, <<
"Non-unique ID during add of region id: " << EI_ID::val <<
", label: " << EI_Label::qval <<
"\n" \
319 <<
"other region with same ID but different label: " << EI_LabelOfOtherID::qval <<
" already exists\n");
320 DECLARE_EXCEPTION( ExcNonuniqueLabel, <<
"Non-unique label during add of region id: " << EI_ID::val <<
", label: " << EI_Label::qval <<
"\n" \
321 <<
"other region with same label but different ID: " << EI_IDOfOtherLabel::val <<
" already exists\n");
322 DECLARE_EXCEPTION( ExcInconsistentBoundary, <<
"Inconsistent add of region with id: " << EI_ID::val <<
", label: " << EI_Label::qval <<
"\n" \
323 <<
"both ID and label match an existing region with different boundary flag.");
324 DECLARE_EXCEPTION( ExcInconsistentDimension, <<
"Inconsistent add of region with id: " << EI_ID::val <<
", label: " << EI_Label::qval <<
"\n" \
325 <<
"both ID and label match an existing region with different dimension.");
327 DECLARE_EXCEPTION( ExcCantAdd, <<
"Can not add new region into DB, id: " << EI_ID::val <<
", label: " << EI_Label::qval);
329 DECLARE_EXCEPTION( ExcUnknownSet, <<
"Operation with unknown region set: " << EI_Label::qval );
372 Region add_region(
unsigned int id,
const std::string &label,
unsigned int dim);
393 const std::string &
get_label(
unsigned int idx)
const;
398 unsigned int get_id(
unsigned int idx)
const;
403 unsigned int get_dim(
unsigned int idx)
const;
415 unsigned int size()
const;
520 : index(index), id(id), label(label),
dim_(dim) {}
536 typedef BMI::multi_index_container<
545 BMI::ordered_unique< BMI::tag<Index>, BMI::member<RegionItem, unsigned int, &RegionItem::index > >,
547 BMI::hashed_unique< BMI::tag<ID>, BMI::member<RegionItem, unsigned int, &RegionItem::id> >,
549 BMI::ordered_unique< BMI::tag<Label>, BMI::member<RegionItem, std::string, &RegionItem::label> >
554 typedef RegionTable::index<Label>::type::iterator
LabelIter;
555 typedef RegionTable::index<ID>::type::iterator
IDIter;