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