Flow123d
3.9.0-c2ae2d0a8
|
#include <region.hh>
Classes | |
struct | DimId |
struct | Index |
struct | Label |
struct | OnlyID |
struct | RegionItem |
One item in region database. More... | |
Public Types | |
typedef std::map< unsigned int, unsigned int > | MapElementIDToRegionID |
Public Member Functions | |
TYPEDEF_ERR_INFO (EI_Label, const std::string) | |
TYPEDEF_ERR_INFO (EI_ID, unsigned int) | |
TYPEDEF_ERR_INFO (EI_IDOfOtherLabel, unsigned int) | |
TYPEDEF_ERR_INFO (EI_LabelOfOtherID, const std::string) | |
DECLARE_INPUT_EXCEPTION (ExcAddingIntoClosed,<< "Can not add label="<< EI_Label::qval<< " into closed MaterialDispatch.\n") | |
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") | |
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") | |
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.") | |
DECLARE_INPUT_EXCEPTION (ExcCantAdd,<< "Can not add new elementary region into DB, id: "<< EI_ID::val<<", label: "<< EI_Label::qval) | |
DECLARE_INPUT_EXCEPTION (ExcUnknownRegion,<< "Unknown region with id: "<< EI_ID::val) | |
DECLARE_INPUT_EXCEPTION (ExcUnknownSet,<< "Operation with unknown region set: "<< EI_Label::qval) | |
DECLARE_INPUT_EXCEPTION (ExcUnknownSetOperand,<< "Operation with unknown region set: "<< EI_Label::qval) | |
DECLARE_INPUT_EXCEPTION (ExcUniqueRegionId,<< "Id of elementary region must be unique, id: "<< EI_ID::val) | |
RegionDB () | |
Default constructor. More... | |
Region | add_region (unsigned int id, const std::string &label, unsigned int dim, const std::string &address="implicit") |
Region | rename_region (Region reg, const std::string &new_label) |
Region | get_region (unsigned int id, unsigned int dim) |
Region | find_label (const std::string &label) const |
Region | find_id (unsigned int id, unsigned int dim) const |
Region | find_id (unsigned int id) const |
const std::string & | get_label (unsigned int idx) const |
unsigned int | get_id (unsigned int idx) const |
unsigned int | get_dim (unsigned int idx) const |
void | close () |
unsigned int | size () const |
unsigned int | boundary_size () const |
unsigned int | bulk_size () const |
Region | implicit_boundary_region () |
void | add_to_set (const std::string &set_name, Region region) |
void | add_set (const std::string &set_name, const RegionSet &set) |
RegionSet | get_region_set (const std::string &set_name) const |
std::vector< std::string > | get_and_check_operands (const Input::Array &operands) const |
void | print_region_table (std::ostream &stream) const |
std::string | create_label_from_id (unsigned int id) const |
const std::string & | get_region_address (unsigned int idx) const |
void | mark_used_region (unsigned int idx) |
RegionSet | union_set (std::vector< std::string > set_names) const |
Static Public Attributes | |
static const unsigned int | max_n_regions = 10000 |
static const unsigned int | undefined_dim = 10 |
Private Types | |
typedef std::pair< unsigned int, unsigned int > | DimID |
typedef 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. More... | |
typedef RegionTable::index< Label >::type::iterator | LabelIter |
typedef RegionTable::index< DimId >::type::iterator | DimIDIter |
typedef RegionTable::index< OnlyID >::type::iterator | OnlyIDIter |
Private Member Functions | |
Region | insert_region (unsigned int id, const std::string &label, unsigned int dim, bool boundary, const std::string &address) |
Region | replace_region_dim (DimIDIter it_undef_dim, unsigned int dim, bool boundary) |
Region | find_by_dimid (DimIDIter it_id, unsigned int id, const std::string &label, bool boundary) |
void | erase_from_set (const std::string &set_name, Region region) |
void | check_regions () |
bool | is_boundary (const std::string &label) |
Private Attributes | |
RegionTable | region_table_ |
Database of all regions (both boundary and bulk). More... | |
bool | closed_ |
flag for closed database, no regions can be added, but you can add region sets More... | |
unsigned int | n_boundary_ |
Number of boundary regions. More... | |
unsigned int | n_bulk_ |
Number of bulk regions. More... | |
unsigned int | max_id_ |
Maximal value of Region::id() More... | |
RegionSetTable | sets_ |
Map of region sets. More... | |
RegionSet | all |
Make part of general RegionSet table. More... | |
RegionSet | bulk |
RegionSet | boundary |
Region | implicit_bulk_ |
Region | implicit_boundary_ |
MapElementIDToRegionID | el_to_reg_map_ |
Friends | |
class | Mesh |
class | RegionSetBase |
Class for conversion between an index and string label of an material. Class contains only static members in order to provide globally consistent indexing of materials across various meshes and functions.
The conversion should be performed only through the input and output so that the lookup overhead could be shadowed by IO operations.
Taking sizes and creating region sets should be possible only after the database is closed. We assume that all regions are known at beginning of the program (typically after reading all meshes) however they need not be used through the whole computation.
TODO: In order to support more meshes , possibly changing during the time we need better policy for RegionDB closing. Currently we close RegionDB at first call to any of size
methods. We need size information for initialization of RegionFields. However, every RegionField should be used for assembly over just one mesh (or set of meshes - supermesh?), surly this mesh has to be initialized before assembly so it could be initialized before initialization of RegionField which lives on this mesh. So the solution can be: RegionDB keeps list of meshes that has their regions registered in RegionDB. RegionField has signature of its mesh and check if the mesh is registered in the RegionDB before initialization of REgionField.
Update TODO:
/ map set name to lists of indices of its regions typedef std::vector<RegionIdx> RegionSet; std::map<std::string, RegionSet > sets_;
/ Add region to given set. Creat the set if it does not exist. add_to_set( const string& set_name, RegionIdx region); / Add a set into map, delete possible previous value, do not worry about slow copies of / the set array. add_set( const string& set_name, const RegionSet & set); RegionSet union( const string & set_name_1, const string & set_name_2); // sort + std::set_union RegionSet intersection( const string & set_name_1, const string & set_name_2); RegionSet difference( const string & set_name_1, const string & set_name_2); const RegionSet & get_set(const string & set_name); void read_sets_from_input(Input::Record rec); // see structure of RegionDB::get_region_set_input_type()
region_sets = [ { name="set name", region_ids=[ int ...], region_labels= ["..."], // these are merger together
union=["set_1", "set_2"], // later overwrites previous intersection= difference= } ]
5) Setup topology - we has to connect Boundary with existing boundary elements, and add the remaining elements, 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 BC on them.
|
private |
|
private |
|
private |
typedef std::map<unsigned int, unsigned int> RegionDB::MapElementIDToRegionID |
|
private |
|
private |
Region RegionDB::add_region | ( | unsigned int | id, |
const std::string & | label, | ||
unsigned int | dim, | ||
const std::string & | address = "implicit" |
||
) |
This method adds new region into the database and returns its index. This requires full specification of the region that is given in PhysicalNames section of the GMSH MSH format or in Mesh input record.
If ID or label are found in the DB, we distinguish following cases: 1) ID is found, label is not found : warning ID has already assigned label 2) ID is not found, label is found : report error - assigning same label to different IDs 3) both ID and label are found, in same region : check remaining data, return existing region 4) , in different : warning ID has already assigned label
Parameter id
is any unique non-negative integer, parameter label
is unique string identifier of the region, dim
is dimension of reference elements in the region, boundary
is true if the region consist of boundary elements (where one can apply boundary condition) and address
contains source of region (address in input file or section in mesh file).
When called from GMSH reader the default region name have a form "region_ID".
Definition at line 85 of file region.cc.
void RegionDB::add_set | ( | const std::string & | set_name, |
const RegionSet & | set | ||
) |
void RegionDB::add_to_set | ( | const std::string & | set_name, |
Region | region | ||
) |
unsigned int RegionDB::boundary_size | ( | ) | const |
unsigned int RegionDB::bulk_size | ( | ) | const |
|
private |
void RegionDB::close | ( | ) |
string RegionDB::create_label_from_id | ( | unsigned int | id | ) | const |
RegionDB::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." | |||
) |
RegionDB::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" | |||
) |
RegionDB::DECLARE_INPUT_EXCEPTION | ( | ExcAddingIntoClosed | ) |
RegionDB::DECLARE_INPUT_EXCEPTION | ( | ExcCantAdd | , |
<< "Can not add new elementary region into | DB, | ||
id:"<< EI_ID::val<<" | , | ||
label:"<< EI_Label::qval | |||
) |
RegionDB::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" | |||
) |
RegionDB::DECLARE_INPUT_EXCEPTION | ( | ExcUniqueRegionId | , |
<< "Id of elementary region must be | unique, | ||
id:"<< EI_ID::val | |||
) |
RegionDB::DECLARE_INPUT_EXCEPTION | ( | ExcUnknownRegion | , |
<< "Unknown region with id: "<< EI_ID::val | |||
) |
RegionDB::DECLARE_INPUT_EXCEPTION | ( | ExcUnknownSet | , |
<< "Operation with unknown region set: "<< EI_Label::qval | |||
) |
RegionDB::DECLARE_INPUT_EXCEPTION | ( | ExcUnknownSetOperand | , |
<< "Operation with unknown region set: "<< EI_Label::qval | |||
) |
|
private |
Region RegionDB::find_id | ( | unsigned int | id | ) | const |
Region RegionDB::find_id | ( | unsigned int | id, |
unsigned int | dim | ||
) | const |
Region RegionDB::find_label | ( | const std::string & | label | ) | const |
std::vector< string > RegionDB::get_and_check_operands | ( | const Input::Array & | operands | ) | const |
unsigned int RegionDB::get_dim | ( | unsigned int | idx | ) | const |
unsigned int RegionDB::get_id | ( | unsigned int | idx | ) | const |
const std::string & RegionDB::get_label | ( | unsigned int | idx | ) | const |
Region RegionDB::get_region | ( | unsigned int | id, |
unsigned int | dim | ||
) |
const std::string & RegionDB::get_region_address | ( | unsigned int | idx | ) | const |
RegionSet RegionDB::get_region_set | ( | const std::string & | set_name | ) | const |
Get region set of specified name. Three sets are defined by default: "ALL" - set of all regions both bulk and boundary. "BULK" - set of all bulk regions ".BOUNDARY" - set of all boundary regions
set_name | Name of set |
Definition at line 328 of file region.cc.
Region RegionDB::implicit_boundary_region | ( | ) |
|
private |
|
inlineprivate |
void RegionDB::mark_used_region | ( | unsigned int | idx | ) |
void RegionDB::print_region_table | ( | std::ostream & | stream | ) | const |
unsigned int RegionDB::size | ( | ) | const |
RegionDB::TYPEDEF_ERR_INFO | ( | EI_ID | , |
unsigned int | |||
) |
RegionDB::TYPEDEF_ERR_INFO | ( | EI_IDOfOtherLabel | , |
unsigned int | |||
) |
RegionDB::TYPEDEF_ERR_INFO | ( | EI_Label | , |
const std::string | |||
) |
RegionDB::TYPEDEF_ERR_INFO | ( | EI_LabelOfOtherID | , |
const std::string | |||
) |
RegionSet RegionDB::union_set | ( | std::vector< std::string > | set_names | ) | const |
|
friend |
|
private |
|
private |
|
private |
|
private |
|
private |
Maximal value of Region::id()
|
static |
|
private |
|
private |
|
private |
|
private |
|
static |