31 #include <boost/tokenizer.hpp> 32 #include "boost/lexical_cast.hpp" 59 return IT::Record(
"Mesh",
"Record with mesh related data." )
62 "Input file with mesh description.")
64 "List of additional region and region set definitions not contained in the mesh. " 65 "There are three region sets implicitly defined:\n\n" 66 "- ALL (all regions of the mesh)\n" 67 "- .BOUNDARY (all boundary regions)\n" 68 "- BULK (all bulk regions)")
87 istringstream is(
"{mesh_file=\"\"}");
125 for(
int i=0; i < 3; i++) {
127 for(
int j=0; j < i+2; j++)
131 for (
unsigned int sid=0; sid<RefElement<1>::n_sides; sid++)
132 for (
unsigned int nid=0; nid<RefElement<1>::n_nodes_per_side; nid++)
135 for (
unsigned int sid=0; sid<RefElement<2>::n_sides; sid++)
136 for (
unsigned int nid=0; nid<RefElement<2>::n_nodes_per_side; nid++)
139 for (
unsigned int sid=0; sid<RefElement<3>::n_sides; sid++)
140 for (
unsigned int nid=0; nid<RefElement<3>::n_nodes_per_side; nid++)
147 if (edg.side_)
delete[] edg.side_;
150 if (ele->node)
delete[] ele->node;
151 if (ele->edge_idx_)
delete[] ele->edge_idx_;
152 if (ele->permutation_idx_)
delete[] ele->permutation_idx_;
153 if (ele->boundary_idx_)
delete[] ele->boundary_idx_;
180 unsigned int li, count = 0;
200 switch (elm->dim()) {
255 for (
auto elem_to_region : map) {
271 if (ele->quality_measure_smooth() < 0.001)
WarningOut().fmt(
"Bad quality (<0.001) of the element {}.\n", ele.id());
284 id_4_old[i++] = ele.index();
310 for (
unsigned int n=0; n<e->n_nodes(); n++)
314 stable_sort(n->begin(), n->end());
320 if (nodes_list.size() == 0) {
321 intersection_element_list.clear();
322 }
else if (nodes_list.size() == 1) {
327 intersection_element_list.resize(
node_elements[*it1].size() );
329 it1=set_intersection(
332 intersection_element_list.begin());
333 intersection_element_list.resize(it1-intersection_element_list.begin());
335 for(;it2<nodes_list.end();++it2) {
336 it1=set_intersection(
337 intersection_element_list.begin(), intersection_element_list.end(),
339 intersection_element_list.begin());
340 intersection_element_list.resize(it1-intersection_element_list.begin());
347 unsigned int dim,
unsigned int &element_idx) {
348 bool is_neighbour =
false;
352 if (elements[*ele].dim() == dim) {
355 }
else if (elements[*ele].dim() == dim-1) {
356 if (is_neighbour)
xprintf(
UsrErr,
"Too matching elements id: %d and id: %d in the same mesh.\n",
357 elements(*ele).id(), elements(element_idx).id() );
362 element_list.resize( e_dest - element_list.begin());
370 && find(side_nodes.begin(), side_nodes.end(),
node_vector.
index( si->
node(ni) ) ) != side_nodes.end() ) ni++;
371 return ( ni == si->
n_nodes() );
387 unsigned int ngh_element_idx, last_edge_idx;
400 side_nodes.resize(bc_ele->n_nodes());
401 for (
unsigned n=0; n<bc_ele->n_nodes(); n++) side_nodes[n] =
node_vector.
index(bc_ele->node[n]);
405 xprintf(
UsrErr,
"Boundary element (id: %d) match a regular element (id: %d) of lower dimension.\n",
406 bc_ele.id(),
element(ngh_element_idx).id());
408 if (intersection_list.size() == 0) {
410 WarningOut().fmt(
"Lonely boundary element, id: {}, region: {}, dimension {}.\n",
411 bc_ele.id(), bc_ele->region().id(), bc_ele->dim());
414 last_edge_idx=
edges.size();
415 edges.resize(last_edge_idx+1);
416 edg = &(
edges.back() );
418 edg->
side_ =
new struct SideIter[ intersection_list.size() ];
432 for (
unsigned int ecs=0; ecs<elem->
n_sides(); ecs++) {
438 int new_bc_ele_idx=bc_ele.index();
439 THROW( ExcDuplicateBoundary()
441 << EI_RegLast(this->
bc_elements[last_bc_ele_idx].region().label())
443 << EI_RegNew(this->
bc_elements[new_bc_ele_idx].region().label())
465 for (
unsigned int s=0; s<e->n_sides(); s++)
472 side_nodes.resize(e->side(s)->n_nodes());
473 for (
unsigned n=0; n<e->side(s)->n_nodes(); n++) side_nodes[n] =
node_vector.
index(e->side(s)->node(n));
482 last_edge_idx=
edges.size();
483 edges.resize(last_edge_idx+1);
484 edg = &(
edges.back() );
486 edg->
side_ =
new struct SideIter[ intersection_list.size() ];
490 if (intersection_list.size() == 1) {
492 edg->
side_[0] = e->side(s);
493 e->edge_idx_[s] = last_edge_idx;
495 if (e->boundary_idx_ == NULL) {
496 e->boundary_idx_ =
new unsigned int [ e->n_sides() ];
497 std::fill( e->boundary_idx_, e->boundary_idx_ + e->n_sides(),
Mesh::undef_idx);
503 e->boundary_idx_[s] = bdr_idx;
509 for(
unsigned int ni = 0; ni< side_nodes.size(); ni++) bc_ele->node[ni] = &(
node_vector[side_nodes[ni]] );
523 for (
unsigned int ecs=0; ecs<elem->
n_sides(); ecs++) {
529 last_edge_idx=
edges.size();
530 edges.resize(last_edge_idx+1);
531 edg = &(
edges.back() );
549 OLD_ASSERT( is_neighbour || ( (
unsigned int) edg->
n_sides ) == intersection_list.size(),
"Some connected sides were not found.\n");
563 edg->side(0)->element()->permutation_idx_[edg->side(0)->el_idx()] = 0;
565 if (edg->n_sides > 1)
568 unsigned int permutation[edg->side(0)->n_nodes()];
570 for (
unsigned int i=0; i<edg->side(0)->n_nodes(); i++)
571 node_numbers[edg->side(0)->node(i)] = i;
573 for (
int sid=1; sid<edg->n_sides; sid++)
575 for (
unsigned int i=0; i<edg->side(0)->n_nodes(); i++)
576 permutation[node_numbers[edg->side(sid)->node(i)]] = i;
578 switch (edg->side(0)->dim())
597 unsigned int permutation[nb->element()->n_nodes()];
601 for (
unsigned int i=0; i<nb->element()->n_nodes(); i++)
602 node_numbers[nb->element()->node[i]] = i;
604 for (
unsigned int i=0; i<nb->side()->n_nodes(); i++)
605 permutation[node_numbers[nb->side()->node(i)]] = i;
607 switch (nb->side()->dim())
641 if( ele->n_neighs_vb > 0 ) {
642 ele->neigh_vb =
new struct Neighbour* [ele->n_neighs_vb];
649 ele =
ngh->element();
675 for(
unsigned int i_ele=0; i_ele<
n_elements(); i_ele++) {
678 if (ele.
dim() == 1) {
683 for(
unsigned int i_elm : candidate_list) {
685 if (elm->dim() == 2) {
718 for(
unsigned int idx=0; idx <
element.
size(); idx++, ++map_it) {
720 if (last_id >=
id)
xprintf(
UsrErr,
"Element IDs in non-increasing order, ID: %d\n",
id);
721 last_id=*map_it = id;
732 if (
id < 0) last_id=*map_it=-1;
734 if (last_id >=
id)
xprintf(
UsrErr,
"Element IDs in non-increasing order, ID: %d\n",
id);
735 last_id=*map_it = id;
747 it != region_list.
end();
769 bih_tree_ = std::make_shared<BIHTree>(
this);
Distribution * el_ds
Parallel distribution of elements.
Class for the mesh partitioning. This should provide:
Mesh(Input::Record in_record, 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
Base of exceptions used in Flow123d.
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()