Flow123d  jenkins-Flow123d-windows32-release-multijob-51
region.hh
Go to the documentation of this file.
1 /*
2  * region.hh
3  *
4  * Created on: Nov 27, 2012
5  * Author: jb
6  *
7  * TODO:
8  * - komentar k RegionIdx
9  * - presun enum RegionType do public Region - komentar + pouzit v kodu
10  * - zkontrolovat chybove hlasky a ASSERTY, co z toho by melo byt pres exception?
11  *
12  * - Seems that GMSH allows repeating ID and Label on regions of different dimension, therefore
13  * label and ID are not unique without dimension.
14  *
15  */
16 
17 #ifndef REGION_HH_
18 #define REGION_HH_
19 
20 #include <string>
21 #include <vector>
22 #include <map>
23 
24 #include "system/system.hh"
25 #include "system/global_defs.h"
26 #include "system/exceptions.hh"
27 
28 #include "input/accessors.hh"
29 
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>
35 #include <boost/multi_index/mem_fun.hpp>
36 #include <boost/functional/hash.hpp>
37 
38 namespace BMI=::boost::multi_index;
39 
40 // forward declarations
41 class Region;
42 class RegionDB;
43 namespace Input {
44  namespace Type { class Record; }
45  class Record;
46  class Array;
47 }
48 
49 /**
50  * Base class that contains information about region:
51  * 1) contains integer value that specifies region
52  * 2) detects if region is valid
53  * 3) detects if the region is the bulk or boundary
54  * 4) detects boundary index of boundary region or bulk index of bulk region
55  */
56 class RegionIdx {
57 public:
58 
59  /// Default region is undefined/invalid
61 
62  /// Returns true if it is a Boundary region and false if it is a Bulk region.
63  inline bool is_boundary() const
64  { return !(idx_ & 1); }
65 
66  /// Returns false if the region has undefined/invalid value
67  inline bool is_valid() const
68  { return idx_!=undefined;}
69 
70  /// Returns a global index of the region.
71  inline unsigned int idx() const
72  { return idx_; }
73 
74  /// Returns index of the region in the boundary set.
75  inline unsigned int boundary_idx() const {
76  ASSERT( is_boundary(), "Try to get boundary index of a bulk region with internal idx: %d\n", idx_ );
77  return idx_ >> 1; }
78 
79  /// Returns index of the region in the bulk set.
80  inline unsigned int bulk_idx() const {
81  ASSERT( ! is_boundary(), "Try to get bulk index of boundary region with internal idx: %d\n", idx_ );
82  return idx_ >> 1; }
83 
84  /// Equality comparison operators for regions.
85  inline bool operator==(const RegionIdx &other) const
86  { return idx_ == other.idx_; }
87 
88  /// Equality comparison operators for regions.
89  inline bool operator!=(const RegionIdx &other) const
90  { return idx_ != other.idx_; }
91 
92 
93 protected:
94  /**
95  * Create accessor from the index. Should be private since implementation specific.
96  * We need some way how to iterate over: all regions, boundary regions, bulk regions -
97  * solution: have specific RegionSets for these three cases.
98  */
99  RegionIdx(unsigned int index)
100  : idx_(index) { }
101 
102  /**
103  * Internal region index. Regions of one RegionDB (corresponding to one mesh) forms more or less continuous sequence.
104  */
105  unsigned int idx_;
106 
107  /// index for undefined region
108  static const unsigned int undefined=0xffffffff;
109 
110  friend class Region;
111 };
112 
113 
114 
115 /**
116  * Class that represents disjoint part of computational domain (or domains). It consists of one integer value
117  * but provides access to other data stored in RegionDB. In particular provides string label and integer ID (unordered)
118  * further it provides fast (inlined) methods to:
119  * 1) detect if the region is the bulk region or boundary region
120  * 2) return index (this is used to select correct Field, possibly we can distinguish boundary_index and bulk_index)
121  *
122  * Implementation: currently we number bulk regions by odd indices and boundary regions by even indices.
123  *
124  */
125 class Region : public RegionIdx {
126 public:
127 
128  /**
129  * Types of region in mesh (bulk or boundary)
130  */
131  enum RegionType {
132  bulk=false,
133  boundary=true
134  };
135 
136 
137  /// Default region is undefined/invalid
139  : RegionIdx(), db_(NULL)
140  {}
141 
142  /// This should be used for construction from known RegionIdx. (e.g. in Mesh)
143  /// Do not use unless you can not get Region in other way.
144  Region(RegionIdx r_idx, const RegionDB & db)
145  : RegionIdx(r_idx), db_(&db)
146  {}
147 
149  {return RegionIdx(idx_); }
150 
151  /// Returns label of the region (using RegionDB)
152  std::string label() const;
153 
154  /// Returns id of the region (using RegionDB)
155  unsigned int id() const;
156 
157  /// Returns dimension of the region.
158  unsigned int dim() const;
159 
160  /**
161  * Returns static region database. Meant to be used for getting range of
162  * global, boundary, and bulk region indices.
163  */
164  const RegionDB &db() {
165  return *db_;
166  }
167 
168 private:
169  /**
170  * Create accessor from the index. Should be private since implementation specific.
171  * We need some way how to iterate over: all regions, boundary regions, bulk regions -
172  * solution: have specific RegionSets for these three cases.
173  */
174  Region(unsigned int index, const RegionDB &db)
175  : RegionIdx(index), db_(&db)
176  {}
177 
178  /// Comparative method of two regions
179  static bool comp(const Region &a, const Region &b)
180  { return a.idx_ < b.idx_; }
181 
182  /// Global variable with information about all regions.
183  const RegionDB *db_;
184 
185  friend class RegionDB;
186 };
187 
188 
189 
190 
191 /**
192  * Type representing a set of regions.
193  * CAn be used to set function(field) on more regions at once, possibly across meshes
194  *
195  * Regions stored in region set are always unique
196  */
198 
199 
200 
201 /**
202  * Class for conversion between an index and string label of an material.
203  * Class contains only static members in order to provide globally consistent
204  * indexing of materials across various meshes and functions.
205  *
206  * The conversion should be performed only through the input and output so
207  * that the lookup overhead could be shadowed by IO operations.
208  *
209  * Taking sizes and creating region sets should be possible only after the database is closed.
210  * We assume that all regions are known at beginning of the program (typically after reading all meshes)
211  * however they need not be used through the whole computation.
212  *
213  * TODO:
214  * In order to support more meshes , possibly changing during the time we need better policy for RegionDB closing.
215  * Currently we close RegionDB at first call to any of @p size methods. We need size information for initialization of
216  * RegionFields. However, every RegionField should be used for assembly over just one mesh (or set of meshes - supermesh?),
217  * surly this mesh has to be initialized before assembly so it could be initialized before initialization of RegionField which
218  * lives on this mesh. So the solution can be: RegionDB keeps list of meshes that has their regions registered in RegionDB.
219  * RegionField has signature of its mesh and check if the mesh is registered in the RegionDB before initialization of REgionField.
220  *
221  * Update TODO:
222  *
223  * - make one instance of Region DB per mesh; put region indices into mesh elements make them private and provide
224  * method that returns Region accessor. ?? Speed concerns? This introduce needless copies of mesh pointer since
225  * in most cases we do not need methods label, id, dim where whole RegionnDB is needed. Thus possibly make
226  * class RegionIdx (without Mesh) and make some asking methods for label, id in RegionDB.
227  * - in RegionDB make support for sets:
228 
229 /// map set name to lists of indices of its regions
230 typedef std::vector<RegionIdx> RegionSet;
231 std::map<std::string, RegionSet > sets_;
232 
233 /// Add region to given set. Creat the set if it does not exist.
234 add_to_set( const string& set_name, RegionIdx region);
235 /// Add a set into map, delete possible previous value, do not worry about slow copies of
236 /// the set array.
237 add_set( const string& set_name, const RegionSet & set);
238 RegionSet union( const string & set_name_1, const string & set_name_2); // sort + std::set_union
239 RegionSet intersection( const string & set_name_1, const string & set_name_2);
240 RegionSet difference( const string & set_name_1, const string & set_name_2);
241 const RegionSet & get_set(const string & set_name);
242 void read_sets_from_input(Input::Record rec); // see structure of RegionDB::region_set_input_type
243 
244 region_sets = [
245  { name="set name",
246  region_ids=[ int ...],
247  region_labels= ["..."], // these are merger together
248 
249  union=["set_1", "set_2"], // later overwrites previous
250  intersection=
251  difference=
252  }
253 ]
254  *
255  * - MODIFICATION IN MESH AND READER:
256  * Mesh reading proccess:
257  * 1) Read PhysicalNames form GMSH file, populate RegionDB (DONE in GMSH reader, may need small modifications)
258  * 2) Read region definitions from the input, see
259  *
260  * typedef std::map<unsigned int, unsigned int> MapElementIDToRegionID;
261  * RegionDB::read_regions_from_input(Input::Array region_list, MapElementIDToRegionID &map);
262  *
263  *
264  * (TODO in RegionDB, also creates (and return to Mesh) element regions modification map: std::map< unsigned int, RegionIdx>
265  * that maps element IDs to the new region names, GMSH reader should have setter method to accept this map
266  * and modify the elements during reading)
267  * 3) Read region sets - TODO in RegionDB
268  * 4) Read boundary key of the Mesh record and mark appropriate regions as boundary (TODO in RegionDB)
269  * 5) Read nodes (DONE in GMSH reader)
270  * 6) Read elements, per element:
271  * - possibly modify region according map
272  * - find element ID:
273  * if found: add_region(ID, get_label, dim, get_boundary_flag) // possibly set dimension of the region if it is undefined
274  * not found: add_region(ID, default_label, dim, false)
275  * - if region is boundary put element into Mesh::bc_elements
276  * else put it into Mesh::element
277  * ---
278  * 7) Setup topology - we has to connect Boundary with existing bc_elements, and add the remaining elements,
279  * 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
280  * BC on them.
281  *
282  */
283 
284 class RegionDB {
285 public:
286  /**
287  * Map representing the relevance of elements to regions
288  */
290 
291  /**
292  * Format of input record which defined elements and their affiliation to region sets
293  */
295  /**
296  * Format of input record which defined regions and their affiliation to region sets
297  */
299 
300  TYPEDEF_ERR_INFO( EI_Label, const std::string);
301  TYPEDEF_ERR_INFO( EI_ID, unsigned int);
302  TYPEDEF_ERR_INFO( EI_IDOfOtherLabel, unsigned int);
303  TYPEDEF_ERR_INFO( EI_LabelOfOtherID, const std::string);
304  DECLARE_EXCEPTION( ExcAddingIntoClosed, << "Can not add label=" << EI_Label::qval << " into closed MaterialDispatch.\n");
305  DECLARE_EXCEPTION( ExcNonuniqueID, << "Non-unique ID during add of region id: " << EI_ID::val << ", label: " << EI_Label::qval << "\n" \
306  << "other region with same ID but different label: " << EI_LabelOfOtherID::qval << " already exists\n");
307  DECLARE_EXCEPTION( ExcNonuniqueLabel, << "Non-unique label during add of region id: " << EI_ID::val << ", label: " << EI_Label::qval << "\n" \
308  << "other region with same label but different ID: " << EI_IDOfOtherLabel::val << " already exists\n");
309  DECLARE_EXCEPTION( ExcInconsistentBoundary, << "Inconsistent add of region with id: " << EI_ID::val << ", label: " << EI_Label::qval << "\n" \
310  << "both ID and label match an existing region with different boundary flag.");
311  DECLARE_EXCEPTION( ExcInconsistentDimension, << "Inconsistent add of region with id: " << EI_ID::val << ", label: " << EI_Label::qval << "\n" \
312  << "both ID and label match an existing region with different dimension.");
313 
314  DECLARE_EXCEPTION( ExcCantAdd, << "Can not add new region into DB, id: " << EI_ID::val <<", label: " << EI_Label::qval);
315 
316  DECLARE_EXCEPTION( ExcUnknownSet, << "Operation with unknown region set: " << EI_Label::qval );
317 
318  DECLARE_INPUT_EXCEPTION( ExcUnknownSetOperand, << "Operation with unknown region set: " << EI_Label::qval);
319 
320  TYPEDEF_ERR_INFO( EI_NumOp, unsigned int);
321  DECLARE_INPUT_EXCEPTION( ExcWrongOpNumber, << "Wrong number of operands. Expect 2, given: " << EI_NumOp::val);
322 
323  DECLARE_INPUT_EXCEPTION(ExcUniqueRegionId, << "Id of region must be unique, id: " << EI_ID::val );
324 
325  /// Default constructor
326  RegionDB();
327 
328  /**
329  * Introduce an artificial limit to keep all material indexed arrays
330  * of reasonable size.
331  */
332  static const unsigned int max_n_regions = 64000;
333 
334  /// Undefined dimension for regions introduced from mesh input record.
335  /// Dimensions 0,1,2,3 are valid.
336  static const unsigned int undefined_dim;
337 
338 
339  /**
340  * This method adds new region into the database and returns its index. This requires full
341  * specification of the region that is given in PhysicalNames section of the GMSH MSH format
342  * or in Mesh input record.
343  *
344  * If ID or label are found in the DB, we distinguish following cases:
345  * 1) ID is found, label is not found : warning ID has already assigned label
346  * 2) ID is not found, label is found : report error - assigning same label to different IDs
347  * 3) both ID and label are found, in same region : check remaining data, return existing region
348  * 4) , in different : warning ID has already assigned label
349  *
350  * Parameter @p id is any unique non-negative integer, parameter @p label is unique string identifier of the region,
351  * @p dim is dimension of reference elements in the region and @p boundary is true if the region consist of boundary elements
352  * (where one can apply boundary condition).
353  *
354  */
355  Region add_region(unsigned int id, const std::string &label, unsigned int dim);
356 
357  /**
358  * As the previous, but set the 'boundary; flag according to the label (labels starting with dot '.' are boundary).
359  * Used in read_regions_from_input ( with undefined dimension) to read regions given in 'regions' key of the 'mesh' input record.
360  */
361  Region add_region(unsigned int id, const std::string &label);
362 
363  /**
364  * As the previous, but generates automatic label of form 'region_ID' if the region with same ID is not already present. Set bulk region.
365  * Meant to be used when reading elements from MSH file. Again, if the region is defined already, we just check consistency.
366  */
367  Region add_region(unsigned int id, unsigned int dim);
368 
369  /**
370  * Returns a @p Region with given @p label. If it is not found it returns @p undefined Region.
371  */
372  Region find_label(const std::string &label) const;
373 
374  /**
375  * Returns a @p Region with given @p id. If it is not found it returns @p undefined Region.
376  * Gmsh ID numbers are unique only over one dimension, so dimension @p dim must be provided as well.
377  */
378  Region find_id(unsigned int id, unsigned int dim) const;
379 
380  /**
381  * Slower version that tries to find region for given ID. If it is not unique it throws.
382  */
383  Region find_id(unsigned int id) const;
384 
385  /**
386  * Return original label for given index @p idx.
387  */
388  const std::string &get_label(unsigned int idx) const;
389 
390  /**
391  * Return original ID for given index @p idx.
392  */
393  unsigned int get_id(unsigned int idx) const;
394 
395  /**
396  * Return dimension of region with given index @p idx.
397  */
398  unsigned int get_dim(unsigned int idx) const;
399 
400  /**
401  * Close this class for adding labels. This is necessary to return correct size
402  * for material indexed arrays and vectors. After calling this method you can
403  * call method @p size and method @p idx_of_label rise an exception for any unknown label.
404  */
405  void close();
406 
407  /**
408  * Returns maximal index + 1
409  */
410  unsigned int size() const;
411 
412  /**
413  * Returns total number boundary regions.
414  */
415  unsigned int boundary_size() const;
416 
417  /**
418  * Returns total number bulk regions.
419  */
420  unsigned int bulk_size() const;
421 
422  /**
423  * Returns implicit boundary region. Is used for boundary elements created by Flow123d itself.
424  * This region has label "IMPLICIT_BOUNDARY" and it is obsolete, the name is not consistent
425  * with boundary label notation.
426  */
428 
429  /*
430  * Add region to given set. Create the set if it does not exist.
431  *
432  * @param set_name Set to which it is added region
433  * @param region Added region
434  */
435  void add_to_set( const string& set_name, Region region);
436 
437  /**
438  * Add a set into map, delete possible previous value.
439  *
440  * @param set_name Name of added set
441  * @param set Added RegionSet
442  */
443  void add_set( const string& set_name, const RegionSet & set);
444 
445  /**
446  * Get RegionSets of specified names and create their union
447  *
448  * @param set_name_1 Name of first RegionSet
449  * @param set_name_2 Name of second RegionSet
450  * @return RegionSet created of union operation
451  */
452  RegionSet union_sets( const string & set_name_1, const string & set_name_2);
453 
454  /**
455  * Get RegionSets of specified names and create their intersection.
456  * Throws ExcUnknownSet for invalid name.
457  *
458  * @param set_name_1 Name of first RegionSet
459  * @param set_name_2 Name of second RegionSet
460  * @return RegionSet created of intersection operation
461  */
462  RegionSet intersection( const string & set_name_1, const string & set_name_2);
463 
464  /**
465  * Get RegionSets of specified names and create their difference
466  * Throws ExcUnknownSet for invalid name.
467  *
468  * @param set_name_1 Name of first RegionSet
469  * @param set_name_2 Name of second RegionSet
470  * @return RegionSet created of difference operation
471  */
472  RegionSet difference( const string & set_name_1, const string & set_name_2);
473 
474  /**
475  * Get region set of specified name. Three sets are defined by default:
476  * "ALL" - set of all regions both bulk and boundary.
477  * "BULK" - set of all bulk regions
478  * "BOUNDARY" - set of all boundary regions
479  *
480  * @param set_name Name of set
481  * @return RegionSet of specified name. Returns Empty vector if the set of given name doesn't exist.
482  */
483  RegionSet get_region_set(const string & set_name) const;
484 
485  /**
486  * Reads region sets defined by user in input file
487  * Format of input record is defined in variable RegionDB::region_set_input_type
488  *
489  * @param arr Array input records which define region sets
490  */
492 
493  /**
494  * Reads elements and their affiliation to region sets defined by user in input file
495  * Format of input record is defined in variable RegionDB::region_input_type
496  *
497  * @param region_list Array input records which define region sets and elements
498  * @param map Map to which is loaded data
499  */
501 
502 
503 private:
504 
505 
506  typedef std::pair<unsigned int, unsigned int> DimID;
507 
508  /// One item in region database
509  struct RegionItem {
510  RegionItem(unsigned int index, unsigned int id, const std::string &label, unsigned int dim)
511  : index(index), id(dim, id), label(label) {}
512 
513  unsigned int get_id() const {return id.second;}
514  unsigned int dim() const {return id.first;}
515 
516  // unique identifiers
517  unsigned int index;
519  std::string label;
520  };
521 
522  // tags
523  struct DimId {};
524  struct OnlyID {};
525  struct Label {};
526  struct Index {};
527 
528  /// Region database
529  typedef BMI::multi_index_container<
530  RegionItem,
531  BMI::indexed_by<
532  // access by index
533  // Can not use random access without introducing "empty" RegionItems to fill holes in the case
534  // n_boundary != n_bulk. Empty items must be unsince we may have empty (and unmodifiable) holes ?? why)
535  //
536  // we need O(1) access
537  //BMI::random_access< BMI::tag<RandomIndex > >,
538  BMI::ordered_unique< BMI::tag<Index>, BMI::member<RegionItem, unsigned int, &RegionItem::index > >,
539  // use hashing for IDs, to get O(1) find complexity .. necessary for large meshes
540  BMI::hashed_unique< BMI::tag<DimId>, BMI::member<RegionItem, DimID, &RegionItem::id> >,
541  // non unique index for sole ID
542  BMI::hashed_non_unique< BMI::tag<OnlyID>, BMI::const_mem_fun<RegionItem, unsigned int, &RegionItem::get_id> >,
543  // ordered access (like stl::map) by label
544  BMI::ordered_unique< BMI::tag<Label>, BMI::member<RegionItem, std::string, &RegionItem::label> >
545  >
547 
548  // DimID and Label index iterators
549  typedef RegionTable::index<Label>::type::iterator LabelIter;
550  typedef RegionTable::index<DimId>::type::iterator DimIDIter;
551  typedef RegionTable::index<OnlyID>::type::iterator OnlyIDIter;
552 
553 
554  /// Database of all regions (both boundary and bulk).
556 
557  /// flag for closed database, no regions can be added, but you can add region sets
558  bool closed_;
559  /// Number of boundary regions
560  unsigned int n_boundary_;
561  /// Number of bulk regions
562  unsigned int n_bulk_;
563 
564  /// Map of region sets
566 
567  /// Make part of general RegionSet table.
569 
570  /**
571  * Implicit bulk and boundary regions. For GMSH mesh format only implicit_boundary is used for boundary elements
572  * that are not explicitly in the mesh file.
573  */
575 
576  /**
577  * Prepare region sets for union, intersection and difference operation.
578  * Get sets of names set_name_1 and set_name_2 and sort them.
579  * Throws ExcUnknownSet if the set with given name does not exist.
580  */
581  void prepare_sets( const string & set_name_1, const string & set_name_2, RegionSet & set_1, RegionSet & set_2);
582 
583  /**
584  * Read two operands from input array of strings and check if given names
585  * are existing sets. Return pair of checked set names.
586  */
587  pair<string,string> get_and_check_operands(const Input::Array & operands);
588 
589  /**
590  * Create label of region in format: "region_"+id
591  *
592  * Use if label is not set.
593  */
594  void create_label_from_id(const string & label, unsigned int id);
595 
596  /**
597  * Insert new region into database.
598  */
599  Region insert_region(unsigned int id, const std::string &label, unsigned int dim, bool boundary);
600 
601  /**
602  * Replace dimension of existing region with undefined_dim.
603  */
604  Region replace_region_dim(DimIDIter it_undef_dim, unsigned int dim, bool boundary);
605 
606  /**
607  * Find existing region given by pair (dim, id).
608  */
609  Region find_by_dimid(DimIDIter it_id, unsigned int id, const std::string &label, bool boundary);
610 
611  /**
612  * Return boundary flag for given label. Label of boundary region must start by '.' symbol.
613  */
614  inline bool is_boundary(const std::string &label) {
615  return (label.size() != 0) && (label[0] == '.');
616  }
617 
618 };
619 
620 
621 
622 #endif /* REGION_HH_ */
std::map< std::string, RegionSet > sets_
Map of region sets.
Definition: region.hh:565
void prepare_sets(const string &set_name_1, const string &set_name_2, RegionSet &set_1, RegionSet &set_2)
Definition: region.cc:327
unsigned int size() const
Definition: region.cc:238
const std::string & get_label(unsigned int idx) const
Definition: region.cc:196
pair< string, string > get_and_check_operands(const Input::Array &operands)
Definition: region.cc:344
void read_regions_from_input(Input::Array region_list, MapElementIDToRegionID &map)
Definition: region.cc:455
Accessor to input data conforming to declared Array.
Definition: accessors.hh:521
RegionIdx()
Default region is undefined/invalid.
Definition: region.hh:60
bool is_boundary() const
Returns true if it is a Boundary region and false if it is a Bulk region.
Definition: region.hh:63
void read_sets_from_input(Input::Array arr)
Definition: region.cc:370
std::string label
Definition: region.hh:519
RegionSet union_sets(const string &set_name_1, const string &set_name_2)
Definition: region.cc:285
std::map< unsigned int, unsigned int > MapElementIDToRegionID
Definition: region.hh:289
unsigned int bulk_size() const
Definition: region.cc:252
RegionSet get_region_set(const string &set_name) const
Definition: region.cc:361
RegionItem(unsigned int index, unsigned int id, const std::string &label, unsigned int dim)
Definition: region.hh:510
static bool comp(const Region &a, const Region &b)
Comparative method of two regions.
Definition: region.hh:179
void add_set(const string &set_name, const RegionSet &set)
Definition: region.cc:277
unsigned int index
Definition: region.hh:517
static const unsigned int undefined
index for undefined region
Definition: region.hh:108
Region replace_region_dim(DimIDIter it_undef_dim, unsigned int dim, bool boundary)
Definition: region.cc:507
DECLARE_INPUT_EXCEPTION(ExcUnknownSetOperand,<< "Operation with unknown region set: "<< EI_Label::qval)
unsigned int idx_
Definition: region.hh:105
One item in region database.
Definition: region.hh:509
std::vector< Region > RegionSet
Definition: region.hh:197
const RegionDB * db_
Global variable with information about all regions.
Definition: region.hh:183
void create_label_from_id(const string &label, unsigned int id)
Definition: region.cc:484
unsigned int boundary_idx() const
Returns index of the region in the boundary set.
Definition: region.hh:75
Global macros to enhance readability and debugging, general constants.
unsigned int dim() const
Definition: region.hh:514
Region implicit_bulk_
Definition: region.hh:574
#define ASSERT(...)
Definition: global_defs.h:121
Region find_by_dimid(DimIDIter it_id, unsigned int id, const std::string &label, bool boundary)
Definition: region.cc:526
RegionIdx operator()(const Region &)
Definition: region.hh:148
Region find_id(unsigned int id, unsigned int dim) const
Definition: region.cc:173
RegionSet bulk
Definition: region.hh:568
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.
Definition: region.hh:546
Region implicit_boundary_
Definition: region.hh:574
void add_to_set(const string &set_name, Region region)
Definition: region.cc:260
RegionType
Definition: region.hh:131
unsigned int get_id() const
Definition: region.hh:513
RegionTable::index< Label >::type::iterator LabelIter
Definition: region.hh:549
bool is_boundary(const std::string &label)
Definition: region.hh:614
void close()
Definition: region.cc:220
Region implicit_boundary_region()
Definition: region.cc:87
unsigned int n_bulk_
Number of bulk regions.
Definition: region.hh:562
std::pair< unsigned int, unsigned int > DimID
Definition: region.hh:506
RegionDB()
Default constructor.
Definition: region.cc:75
Region add_region(unsigned int id, const std::string &label, unsigned int dim)
Definition: region.cc:97
RegionIdx(unsigned int index)
Definition: region.hh:99
RegionTable::index< OnlyID >::type::iterator OnlyIDIter
Definition: region.hh:551
Region insert_region(unsigned int id, const std::string &label, unsigned int dim, bool boundary)
Definition: region.cc:490
RegionSet boundary
Definition: region.hh:568
RegionTable::index< DimId >::type::iterator DimIDIter
Definition: region.hh:550
bool operator!=(const RegionIdx &other) const
Equality comparison operators for regions.
Definition: region.hh:89
static const unsigned int max_n_regions
Definition: region.hh:332
unsigned int get_id(unsigned int idx) const
Definition: region.cc:204
RegionSet difference(const string &set_name_1, const string &set_name_2)
Definition: region.cc:313
static Input::Type::Record region_input_type
Definition: region.hh:294
unsigned int boundary_size() const
Definition: region.cc:245
RegionSet all
Make part of general RegionSet table.
Definition: region.hh:568
RegionSet intersection(const string &set_name_1, const string &set_name_2)
Definition: region.cc:299
const RegionDB & db()
Definition: region.hh:164
unsigned int get_dim(unsigned int idx) const
Definition: region.cc:212
RegionTable region_set_
Database of all regions (both boundary and bulk).
Definition: region.hh:555
unsigned int bulk_idx() const
Returns index of the region in the bulk set.
Definition: region.hh:80
Region(RegionIdx r_idx, const RegionDB &db)
Definition: region.hh:144
TYPEDEF_ERR_INFO(EI_Label, const std::string)
Record type proxy class.
Definition: type_record.hh:161
static const unsigned int undefined_dim
Definition: region.hh:336
Region find_label(const std::string &label) const
Definition: region.cc:162
bool is_valid() const
Returns false if the region has undefined/invalid value.
Definition: region.hh:67
std::string label() const
Returns label of the region (using RegionDB)
Definition: region.cc:23
static Input::Type::Record region_set_input_type
Definition: region.hh:298
Region(unsigned int index, const RegionDB &db)
Definition: region.hh:174
bool closed_
flag for closed database, no regions can be added, but you can add region sets
Definition: region.hh:558
Region()
Default region is undefined/invalid.
Definition: region.hh:138
bool operator==(const RegionIdx &other) const
Equality comparison operators for regions.
Definition: region.hh:85
unsigned int n_boundary_
Number of boundary regions.
Definition: region.hh:560
unsigned int id() const
Returns id of the region (using RegionDB)
Definition: region.cc:28
unsigned int dim() const
Returns dimension of the region.
Definition: region.cc:33
DECLARE_EXCEPTION(ExcAddingIntoClosed,<< "Can not add label="<< EI_Label::qval<< " into closed MaterialDispatch.\n")
unsigned int idx() const
Returns a global index of the region.
Definition: region.hh:71