29 #include <boost/tokenizer.hpp> 30 #include "boost/lexical_cast.hpp" 31 #include <boost/make_shared.hpp> 58 return IT::Record(
"Mesh",
"Record with mesh related data." )
61 "Input file with mesh description.")
63 "List of additional region and region set definitions not contained in the mesh.\n" 64 "There are three region sets implicitly defined:\n\n" 65 " - ALL (all regions of the mesh)\n - .BOUNDARY (all boundary regions)\n - and BULK (all bulk regions)")
127 for(
int i=0; i < 3; i++) {
129 for(
int j=0; j < i+2; j++)
133 for (
unsigned int sid=0; sid<RefElement<1>::n_sides; sid++)
134 for (
unsigned int nid=0; nid<RefElement<1>::n_nodes_per_side; nid++)
137 for (
unsigned int sid=0; sid<RefElement<2>::n_sides; sid++)
138 for (
unsigned int nid=0; nid<RefElement<2>::n_nodes_per_side; nid++)
141 for (
unsigned int sid=0; sid<RefElement<3>::n_sides; sid++)
142 for (
unsigned int nid=0; nid<RefElement<3>::n_nodes_per_side; nid++)
149 if (edg.side_)
delete[] edg.side_;
152 if (ele->node)
delete[] ele->node;
153 if (ele->edge_idx_)
delete[] ele->edge_idx_;
154 if (ele->permutation_idx_)
delete[] ele->permutation_idx_;
155 if (ele->boundary_idx_)
delete[] ele->boundary_idx_;
182 unsigned int li, count = 0;
202 switch (elm->dim()) {
252 for (
auto elem_to_region : map) {
268 if (ele->quality_measure_smooth() < 0.001)
WarningOut().fmt(
"Bad quality (<0.001) of the element {}.\n", ele.id());
281 id_4_old[i++] = ele.index();
307 for (
unsigned int n=0; n<e->n_nodes(); n++)
311 stable_sort(n->begin(), n->end());
317 if (nodes_list.size() == 0) {
318 intersection_element_list.clear();
319 }
else if (nodes_list.size() == 1) {
324 intersection_element_list.resize(
node_elements[*it1].size() );
326 it1=set_intersection(
329 intersection_element_list.begin());
330 intersection_element_list.resize(it1-intersection_element_list.begin());
332 for(;it2<nodes_list.end();++it2) {
333 it1=set_intersection(
334 intersection_element_list.begin(), intersection_element_list.end(),
336 intersection_element_list.begin());
337 intersection_element_list.resize(it1-intersection_element_list.begin());
344 unsigned int dim,
unsigned int &element_idx) {
345 bool is_neighbour =
false;
349 if (elements[*ele].dim() == dim) {
352 }
else if (elements[*ele].dim() == dim-1) {
353 if (is_neighbour)
xprintf(
UsrErr,
"Too matching elements id: %d and id: %d in the same mesh.\n",
354 elements(*ele).id(), elements(element_idx).id() );
359 element_list.resize( e_dest - element_list.begin());
367 && find(side_nodes.begin(), side_nodes.end(),
node_vector.
index( si->
node(ni) ) ) != side_nodes.end() ) ni++;
368 return ( ni == si->
n_nodes() );
384 unsigned int ngh_element_idx, last_edge_idx;
397 side_nodes.resize(bc_ele->n_nodes());
398 for (
unsigned n=0; n<bc_ele->n_nodes(); n++) side_nodes[n] =
node_vector.
index(bc_ele->node[n]);
402 xprintf(
UsrErr,
"Boundary element (id: %d) match a regular element (id: %d) of lower dimension.\n",
403 bc_ele.id(),
element(ngh_element_idx).id());
405 if (intersection_list.size() == 0) {
407 WarningOut().fmt(
"Lonely boundary element, id: {}, region: {}, dimension {}.\n",
408 bc_ele.id(), bc_ele->region().id(), bc_ele->dim());
411 last_edge_idx=
edges.size();
412 edges.resize(last_edge_idx+1);
413 edg = &(
edges.back() );
415 edg->
side_ =
new struct SideIter[ intersection_list.size() ];
429 for (
unsigned int ecs=0; ecs<elem->
n_sides(); ecs++) {
435 int new_bc_ele_idx=bc_ele.index();
436 THROW( ExcDuplicateBoundary()
438 << EI_RegLast(this->
bc_elements[last_bc_ele_idx].region().label())
440 << EI_RegNew(this->
bc_elements[new_bc_ele_idx].region().label())
462 for (
unsigned int s=0; s<e->n_sides(); s++)
469 side_nodes.resize(e->side(s)->n_nodes());
470 for (
unsigned n=0; n<e->side(s)->n_nodes(); n++) side_nodes[n] =
node_vector.
index(e->side(s)->node(n));
479 last_edge_idx=
edges.size();
480 edges.resize(last_edge_idx+1);
481 edg = &(
edges.back() );
483 edg->
side_ =
new struct SideIter[ intersection_list.size() ];
487 if (intersection_list.size() == 1) {
489 edg->
side_[0] = e->side(s);
490 e->edge_idx_[s] = last_edge_idx;
492 if (e->boundary_idx_ == NULL) {
493 e->boundary_idx_ =
new unsigned int [ e->n_sides() ];
494 std::fill( e->boundary_idx_, e->boundary_idx_ + e->n_sides(),
Mesh::undef_idx);
500 e->boundary_idx_[s] = bdr_idx;
506 for(
unsigned int ni = 0; ni< side_nodes.size(); ni++) bc_ele->node[ni] = &(
node_vector[side_nodes[ni]] );
520 for (
unsigned int ecs=0; ecs<elem->
n_sides(); ecs++) {
526 last_edge_idx=
edges.size();
527 edges.resize(last_edge_idx+1);
528 edg = &(
edges.back() );
546 OLD_ASSERT( is_neighbour || ( (
unsigned int) edg->
n_sides ) == intersection_list.size(),
"Some connected sides were not found.\n");
560 edg->side(0)->element()->permutation_idx_[edg->side(0)->el_idx()] = 0;
562 if (edg->n_sides > 1)
565 unsigned int permutation[edg->side(0)->n_nodes()];
567 for (
unsigned int i=0; i<edg->side(0)->n_nodes(); i++)
568 node_numbers[edg->side(0)->node(i)] = i;
570 for (
int sid=1; sid<edg->n_sides; sid++)
572 for (
unsigned int i=0; i<edg->side(0)->n_nodes(); i++)
573 permutation[node_numbers[edg->side(sid)->node(i)]] = i;
575 switch (edg->side(0)->dim())
594 unsigned int permutation[nb->element()->n_nodes()];
598 for (
unsigned int i=0; i<nb->element()->n_nodes(); i++)
599 node_numbers[nb->element()->node[i]] = i;
601 for (
unsigned int i=0; i<nb->side()->n_nodes(); i++)
602 permutation[node_numbers[nb->side()->node(i)]] = i;
604 switch (nb->side()->dim())
638 if( ele->n_neighs_vb > 0 ) {
639 ele->neigh_vb =
new struct Neighbour* [ele->n_neighs_vb];
646 ele =
ngh->element();
672 for(
unsigned int i_ele=0; i_ele<
n_elements(); i_ele++) {
675 if (ele.
dim() == 1) {
680 for(
unsigned int i_elm : candidate_list) {
682 if (elm->dim() == 2) {
715 for(
unsigned int idx=0; idx <
element.
size(); idx++, ++map_it) {
717 if (last_id >=
id)
xprintf(
UsrErr,
"Element IDs in non-increasing order, ID: %d\n",
id);
718 last_id=*map_it = id;
729 if (
id < 0) last_id=*map_it=-1;
731 if (last_id >=
id)
xprintf(
UsrErr,
"Element IDs in non-increasing order, ID: %d\n",
id);
732 last_id=*map_it = id;
744 it != region_list.
end();
766 bih_tree_ = std::make_shared<BIHTree>(
this);
Distribution * el_ds
Parallel distribution of elements.
Class for the mesh partitioning. This should provide:
Mesh(const std::string &input_str="{mesh_file=\"\"}", MPI_Comm com=MPI_COMM_WORLD)
#define FOR_ELEMENT_NODES(i, j)
vector< vector< unsigned int > > node_elements
unsigned int * boundary_idx_
int get_id(const T *it) const
void make_intersec_elements()
MapElementIDToRegionID el_to_reg_map_
#define FOR_ELEMENTS(_mesh_, __i)
#define MessageOut()
Macro defining 'message' record of log.
unsigned int * permutation_idx_
static const Input::Type::Record & get_input_type()
static const unsigned int undef_idx
void create_node_element_lists()
static unsigned int permutation_index(unsigned int p[n_nodes_per_side])
static const Input::Type::Record & get_input_type()
unsigned int max_edge_sides_[3]
Maximal number of sides per one edge in the actual mesh (set in make_neighbours_and_edges()).
FullIter add_item(int id)
vector< vector< vector< unsigned int > > > side_nodes
FullIter find_id(const int id)
ElementAccessor< 3 > element_accessor(unsigned int idx, bool boundary=false)
vector< Boundary > boundary_
Partitioning * get_part()
int * el_4_loc
Index set assigning to local element index its global index.
int * row_4_el
Index set assigning to global element index the local index used in parallel vectors.
Region get_region(unsigned int id, unsigned int dim)
unsigned int size() const
Returns size of the container. This is independent of the allocated space.
void read_regions_from_input(Input::Array region_list)
unsigned int n_elements() const
bool same_sides(const SideIter &si, vector< unsigned int > &side_nodes)
std::vector< T >::iterator iterator
vector< int > const & elements_id_maps(bool boundary_domain) const
friend class RegionSetBase
unsigned int n_sides() const
#define START_TIMER(tag)
Starts a timer with specified tag.
Class for O(log N) lookup for intersections with a set of bounding boxes.
unsigned int index(const T *pointer) const
#define FOR_NEIGHBOURS(_mesh_, it)
ElementVector bc_elements
SideIter side(const unsigned int loc_index)
Region implicit_boundary_region()
std::shared_ptr< BIHTree > bih_tree_
void read_mesh(Mesh *mesh)
vector< int > boundary_elements_id_
void find_bounding_box(const BoundingBox &boundingBox, std::vector< unsigned int > &result_list) const
void count_element_types()
const BIHTree & get_bih_tree()
Dedicated class for storing path to input and output files.
void read_gmsh_from_stream(istream &in)
void mark_used_region(unsigned int idx)
void print_region_table(ostream &stream) const
Support classes for parallel programing.
vector< vector< unsigned int > > master_elements
vector< Neighbour > vb_neighbours_
void read_physical_names(Mesh *mesh)
std::vector< Edge > edges
Vector of MH edges, this should not be part of the geometrical mesh.
vector< Intersection > intersections
void intersect_element_lists(vector< unsigned int > const &nodes_list, vector< unsigned int > &intersection_element_list)
void modify_element_ids(const RegionDB::MapElementIDToRegionID &map)
#define WarningOut()
Macro defining 'warning' record of log.
void make_edge_permutations()
Class RefElement defines numbering of vertices, sides, calculation of normal vectors etc...
static Input::Type::Abstract & get_input_type()
unsigned int n_nodes() const
void element_to_neigh_vb()
const Node * node(unsigned int i) const
void reinit(Input::Record in_record)
FullIter end()
Returns FullFullIterer of the fictions past the end element.
#define FOR_SIDES(_mesh_, it)
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
void GetIntersection(const TBisector &, const TBisector &, TPosition &, double &, double &)
bool find_lower_dim_element(ElementVector &elements, vector< unsigned int > &element_list, unsigned int dim, unsigned int &element_idx)
vector< int > bulk_elements_id_
IntersectionType get_type() const
std::shared_ptr< Partitioning > part_
void make_neighbours_and_edges()
NodeVector node_vector
Vector of nodes of the mesh.
ElementVector element
Vector of elements of the mesh.
unsigned int n_nodes() const
unsigned int idx() const
Returns a global index of the region.
BoundingBox bounding_box()