Flow123d  JS_before_hm-1730-gbf8dc60dc
mesh.h
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 mesh.h
15  * @brief
16  */
17 
18 #ifndef MAKE_MESH_H
19 #define MAKE_MESH_H
20 
21 #include <mpi.h> // for MPI_Comm, MPI_COMM_WORLD
22 
23 //#include <boost/range.hpp>
24 #include <memory> // for shared_ptr
25 #include <string> // for string
26 #include <vector> // for vector, vector<>::iterator
27 #include "input/accessors.hh" // for Record, Array (ptr only)
28 #include "input/accessors_impl.hh" // for Record::val
29 #include "input/storage.hh" // for ExcStorageTypeMismatch
30 #include "input/type_record.hh" // for Record (ptr only), Recor...
31 #include "mesh/region.hh" // for RegionDB, RegionDB::MapE...
32 #include "mesh/elements.h"
33 #include "mesh/bounding_box.hh" // for BoundingBox
34 #include "mesh/range_wrapper.hh"
35 #include "mesh/mesh_data.hh"
38 #include "system/index_types.hh" // for LongIdx
39 #include "system/exceptions.hh" // for operator<<, ExcStream, EI
40 #include "system/file_path.hh" // for FilePath
41 #include "system/armor.hh"
42 
43 
44 class BIHTree;
45 class Distribution;
46 class Partitioning;
48 class Neighbour;
49 class SideIter;
50 class Boundary;
51 class Edge;
52 class BCMesh;
53 class DuplicateNodes;
54 template <int spacedim> class ElementAccessor;
55 template <int spacedim> class NodeAccessor;
56 
57 
58 
59 #define ELM 0
60 #define BC 1
61 #define NODE 2
62 
63 /**
64  * This parameter limits volume of elements from below.
65  */
66 #define MESH_CRITICAL_VOLUME 1.0E-12
67 
69 public:
71 };
72 
73 //=============================================================================
74 // STRUCTURE OF THE MESH
75 //=============================================================================
76 
77 class Mesh {
78 public:
79  TYPEDEF_ERR_INFO( EI_ElemLast, int);
80  TYPEDEF_ERR_INFO( EI_ElemNew, int);
81  TYPEDEF_ERR_INFO( EI_RegLast, std::string);
82  TYPEDEF_ERR_INFO( EI_RegNew, std::string);
83  TYPEDEF_ERR_INFO( EI_ElemId, int);
84  TYPEDEF_ERR_INFO( EI_ElemIdOther, int);
85  TYPEDEF_ERR_INFO( EI_Region, std::string);
86  TYPEDEF_ERR_INFO( EI_RegIdx, unsigned int);
87  TYPEDEF_ERR_INFO( EI_Dim, unsigned int);
88  TYPEDEF_ERR_INFO( EI_DimOther, unsigned int);
89 
90  DECLARE_EXCEPTION(ExcDuplicateBoundary,
91  << "Duplicate boundary elements! \n"
92  << "Element id: " << EI_ElemLast::val << " on region name: " << EI_RegLast::val << "\n"
93  << "Element id: " << EI_ElemNew::val << " on region name: " << EI_RegNew::val << "\n");
94  DECLARE_EXCEPTION(ExcElmWrongOrder,
95  << "Element IDs in non-increasing order, ID: " << EI_ElemId::val << "\n");
96  DECLARE_EXCEPTION(ExcRegionElmDiffDim,
97  << "User defined region " << EI_Region::qval << " (id " << EI_RegIdx::val
98  << ") by 'From_Elements' cannot have elements of different dimensions.\n"
99  << "Thrown due to: dim " << EI_Dim::val << " neq dim " << EI_DimOther::val << " (ele id " << EI_ElemId::val << ").\n"
100  << "Split elements by dim, create separate regions and then possibly use Union.\n" );
101  DECLARE_EXCEPTION(ExcTooMatchingIds,
102  << "Mesh: Duplicate dim-join lower dim elements: " << EI_ElemId::val << ", " << EI_ElemIdOther::val << ".\n" );
103  DECLARE_EXCEPTION(ExcBdrElemMatchRegular,
104  << "Boundary element (id: " << EI_ElemId::val << ") match a regular element (id: " << EI_ElemIdOther::val << ") of lower dimension.\n" );
105 
106 
107  /**
108  * \brief Types of search algorithm for finding intersection candidates.
109  */
110  typedef enum IntersectionSearch {
112  BIHonly = 2,
115 
116  /**
117  * \brief The definition of input record for selection of variant of file format
118  */
120 
121  static const unsigned int undef_idx=-1;
122  static const Input::Type::Record & get_input_type();
123 
124 
125  /** Labels for coordinate indexes in arma::vec3 representing vectors and points.*/
126  enum {x_coord=0, y_coord=1, z_coord=2};
127 
128  /**
129  * Empty constructor.
130  *
131  * Use only for unit tests!!!
132  */
133  Mesh();
134  /**
135  * Constructor from an input record.
136  * Do not process input record. That is done in init_from_input.
137  */
138  Mesh(Input::Record in_record, MPI_Comm com = MPI_COMM_WORLD);
139 
140  /// Destructor.
141  virtual ~Mesh();
142 
143  virtual inline unsigned int n_nodes() const {
144  return nodes_.size();
145  }
146 
147  inline unsigned int n_boundaries() const {
148  return boundary_.size();
149  }
150 
151  inline unsigned int n_edges() const {
152  return edges.size();
153  }
154 
155  Edge edge(uint edge_idx) const;
156  Boundary boundary(uint edge_idx) const;
157 
158  unsigned int n_corners();
159 
160  inline const RegionDB &region_db() const {
161  return region_db_;
162  }
163 
164  /**
165  * Returns pointer to partitioning object. Partitioning is created during setup_topology.
166  */
167  virtual Partitioning *get_part();
168 
169  virtual const LongIdx *get_local_part();
170 
172  { return el_ds; }
173 
175  { return row_4_el; }
176 
178  { return el_4_loc; }
179 
181  { return node_ds_; }
182 
184  { return node_4_loc_; }
185 
186  unsigned int n_local_nodes() const
187  { return n_local_nodes_; }
188 
189  /**
190  * Returns MPI communicator of the mesh.
191  */
192  inline MPI_Comm get_comm() const { return comm_; }
193 
194 
196 
197  unsigned int n_sides() const;
198 
199  unsigned int n_vb_neighbours() const;
200 
201  /**
202  * Returns maximal number of sides of one edge, which connects elements of dimension @p dim.
203  * @param dim Dimension of elements sharing the edge.
204  */
205  unsigned int max_edge_sides(unsigned int dim) const { return max_edge_sides_[dim-1]; }
206 
207  /**
208  * Reads mesh from stream.
209  *
210  * Method is especially used in unit tests.
211  */
212  void read_gmsh_from_stream(istream &in);
213  /**
214  * Reads input record, creates regions, read the mesh, setup topology. creates region sets.
215  */
216  void init_from_input();
217 
218 
219  /**
220  * Initialize all mesh structures from raw information about nodes and elements (including boundary elements).
221  * Namely: create remaining boundary elements and Boundary objects, find edges and compatible neighborings.
222  */
223  void setup_topology();
224 
225  /**
226  * Returns vector of ID numbers of elements, either bulk or bc elemnts.
227  */
228  void elements_id_maps( vector<LongIdx> & bulk_elements_id, vector<LongIdx> & boundary_elements_id) const;
229 
230  /*
231  * Check if nodes and elements are compatible with continuous \p input_mesh.
232  *
233  * Call this method on computational mesh.
234  * @param input_mesh data mesh of input fields
235  * @return vector that holds mapping between eleemnts of data and computational meshes
236  * for every element in computational mesh hold idx of equivalent element in input mesh.
237  * If element doesn't exist in input mesh value is set to Mesh::undef_idx.
238  * If meshes are not compatible returns empty vector.
239  */
240  virtual std::shared_ptr<std::vector<LongIdx>> check_compatible_mesh( Mesh & input_mesh);
241 
242  /*
243  * Check if nodes and elements are compatible with discontinuous \p input_mesh.
244  *
245  * Call this method on computational mesh.
246  * @param input_mesh data mesh of input fields
247  * @return vector that holds mapping between eleemnts of data and computational meshes
248  * for every element in computational mesh hold idx of equivalent element in input mesh.
249  * If element doesn't exist in input mesh value is set to Mesh::undef_idx.
250  * If meshes are not compatible returns empty vector.
251  */
252  virtual std::shared_ptr<std::vector<LongIdx>> check_compatible_discont_mesh( Mesh & input_mesh);
253 
254  /// Create and return ElementAccessor to element of given idx
255  virtual ElementAccessor<3> element_accessor(unsigned int idx) const;
256 
257  /// Create and return NodeAccessor to node of given idx
258  NodeAccessor<3> node(unsigned int idx) const;
259 
260  /**
261  * Reads elements and their affiliation to regions and region sets defined by user in input file
262  * Format of input record is defined in method RegionSetBase::get_input_type()
263  *
264  * @param region_list Array input AbstractRecords which define regions, region sets and elements
265  */
266  void read_regions_from_input(Input::Array region_list);
267 
268  /**
269  * Returns nodes_elements vector, if doesn't exist creates its.
270  */
272 
273  /// Vector of boundary sides where is prescribed boundary condition.
274  /// TODO: apply all boundary conditions in the main assembling cycle over elements and remove this Vector.
276 
277  //flow::VectorId<int> bcd_group_id; // gives a index of group for an id
278 
279  /**
280  * Vector of individual intersections of two elements.
281  * This is enough for local mortar.
282  */
283  std::shared_ptr<MixedMeshIntersections> intersections;
284 
285  /**
286  * For every element El we have vector of indices into @var intersections array for every intersection in which El is master element.
287  * This is necessary for true mortar.
288  */
290 
292 
293  /**
294  * Vector of compatible neighbourings.
295  */
297 
298  int n_insides; // # of internal sides
299  int n_exsides; // # of external sides
300  mutable int n_sides_; // total number of sides (should be easy to count when we have separated dimensions
301 
302  int n_lines; // Number of line elements
303  int n_triangles; // Number of triangle elements
304  int n_tetrahedras; // Number of tetrahedra elements
305 
306  // Temporary solution for numbering of nodes on sides.
307  // The data are defined in RefElement<dim>::side_nodes,
308  // Mesh::side_nodes can be removed as soon as Element
309  // is templated by dimension.
310  //
311  // side_nodes[dim][elm_side_idx][side_node_idx]
312  // for every side dimension D = 0 .. 2
313  // for every element side 0 .. D+1
314  // for every side node 0 .. D
315  // index into element node array
317 
318  /**
319  * Check usage of regions, set regions to elements defined by user, close RegionDB
320  */
321  void check_and_finish();
322 
323  /// Compute bounding boxes of elements contained in mesh.
325 
326  /// Getter for BIH. Creates and compute BIH at first call.
327  const BIHTree &get_bih_tree();\
328 
329  /**
330  * Find intersection of element lists given by Mesh::node_elements_ for elements givne by @p nodes_list parameter.
331  * The result is placed into vector @p intersection_element_list. If the @p node_list is empty, and empty intersection is
332  * returned.
333  */
334  void intersect_element_lists(vector<unsigned int> const &nodes_list, vector<unsigned int> &intersection_element_list);
335 
336  /// Add new node of given id and coordinates to mesh
337  void add_node(unsigned int node_id, arma::vec3 coords);
338 
339  /// Add new element of given id to mesh
340  void add_element(unsigned int elm_id, unsigned int dim, unsigned int region_id, unsigned int partition_id,
341  std::vector<unsigned int> node_ids);
342 
343  /// Add new node of given id and coordinates to mesh
344  void add_physical_name(unsigned int dim, unsigned int id, std::string name);
345 
346  /// Return FilePath object representing "mesh_file" input key
347  inline FilePath mesh_file() {
348  return in_record_.val<FilePath>("mesh_file");
349  }
350 
351  /// Getter for input type selection for intersection search algorithm.
353 
354  /// Maximal distance of observe point from Mesh relative to its size
355  double global_snap_radius() const;
356 
357  /// Initialize element_vec_, set size and reset counters of boundary and bulk elements.
358  void init_element_vector(unsigned int size);
359 
360  /// Initialize node_vec_, set size
361  void init_node_vector(unsigned int size);
362 
363  /// Returns range of bulk elements
364  virtual Range<ElementAccessor<3>> elements_range() const;
365 
366  /// Returns range of nodes
368 
369  /// Returns range of edges
370  Range<Edge> edge_range() const;
371 
372  /// Returns count of boundary or bulk elements
373  virtual unsigned int n_elements() const {
374  return bulk_size_;
375  }
376 
377  /// For each node the vector contains a list of elements that use this node
379 
380  /// For element of given elem_id returns index in element_vec_ or (-1) if element doesn't exist.
381  inline int elem_index(int elem_id) const
382  {
383  return element_ids_.get_position(elem_id);
384  }
385 
386  /// Return element id (in GMSH file) of element of given position in element vector.
387  inline int find_elem_id(unsigned int pos) const
388  {
389  return element_ids_[pos];
390  }
391 
392  /// Return permutation vector of elements
394  {
395  return elem_permutation_;
396  }
397 
398  /// For node of given node_id returns index in element_vec_ or (-1) if node doesn't exist.
399  inline int node_index(int node_id) const
400  {
401  return node_ids_.get_position(node_id);
402  }
403 
404  /// Return node id (in GMSH file) of node of given position in node vector.
405  inline int find_node_id(unsigned int pos) const
406  {
407  return node_ids_[pos];
408  }
409 
410  /// Return permutation vector of nodes
412  {
413  return node_permutation_;
414  }
415 
416  /// Check if given index is in element_vec_
417  void check_element_size(unsigned int elem_idx) const;
418 
419  /// Create boundary elements from data of temporary structure, this method MUST be call after read mesh from file, return number of read boundary elements
420  unsigned int create_boundary_elements();
421 
422  /// Permute nodes of 3D elements of given elm_idx
423  void permute_tetrahedron(unsigned int elm_idx, std::vector<unsigned int> permutation_vec);
424 
425  /// Permute nodes of 2D elements of given elm_idx
426  void permute_triangle(unsigned int elm_idx, std::vector<unsigned int> permutation_vec);
427 
428  /// Create boundary mesh if doesn't exist and return it.
429  BCMesh *get_bc_mesh();
430 
431 protected:
432 
433  /**
434  * Part of the constructor whichdoes not depedn on input record.
435  * Initializes node-side numbering according to RefElement.
436  */
437  void init();
438 
439  /**
440  * Allow store boundary element data to temporary structure.
441  *
442  * We need this structure to preserve correct order of boundary elements.
443  */
444  struct ElementTmpData {
445  /// Constructor
446  ElementTmpData(unsigned int e_id, unsigned int dm, RegionIdx reg_idx, unsigned int part_id, std::vector<unsigned int> nodes)
447  : elm_id(e_id), dim(dm), region_idx(reg_idx), partition_id(part_id), node_ids(nodes) {}
448 
449  unsigned int elm_id;
450  unsigned int dim;
452  unsigned int partition_id;
454  };
455 
456  /**
457  * This replaces read_neighbours() in order to avoid using NGH preprocessor.
458  *
459  * TODO:
460  * - Avoid maps:
461  *
462  * 5) need not to have temporary array for Edges, only postpone setting pointers in elements and set them
463  * after edges are found; we can temporary save Edge index instead of pointer in Neigbours and elements
464  *
465  * 6) Try replace Edge * by indexes in Neigbours and elements (anyway we have mesh pointer in elements so it is accessible also from Neigbours)
466  *
467  */
469 
470  /**
471  * On edges sharing sides of many elements it may happen that each side has its nodes ordered in a different way.
472  * This method finds the permutation for each side so as to obtain the ordering of side 0.
473  */
474  void make_edge_permutations();
475  /**
476  * Create element lists for nodes in Mesh::nodes_elements.
477  */
479  /**
480  * Remove elements with dimension not equal to @p dim from @p element_list. Index of the first element of dimension @p dim-1,
481  * is returned in @p element_idx. If no such element is found the method returns false, if one such element is found the method returns true,
482  * if more elements are found we report an user input error.
483  */
484  bool find_lower_dim_element(vector<unsigned int> &element_list, unsigned int dim, unsigned int &element_idx);
485 
486  /**
487  * Returns true if side @p si has same nodes as in the list @p side_nodes.
488  */
490 
491 
492  void element_to_neigh_vb();
493 
494  void count_element_types();
495  void count_side_types();
496 
497  /**
498  * Check the element quality and remove unused nodes.
499  */
500  void check_mesh_on_read();
501 
502  /**
503  * Possibly modify region id of elements sets by user in "regions" part of input file.
504  *
505  * TODO: This method needs check in issue 'Review mesh setting'.
506  * Changes have been done during generalized region key and may be causing problems
507  * during the further development.
508  */
510 
511  /// Adds element to mesh data structures (element_vec_, element_ids_), returns pointer to this element.
512  Element * add_element_to_vector(int id);
513 
514  /// Initialize element
515  void init_element(Element *ele, unsigned int elm_id, unsigned int dim, RegionIdx region_idx, unsigned int partition_id,
516  std::vector<unsigned int> node_ids);
517 
518  unsigned int n_bb_neigh, n_vb_neigh;
519 
520  /// Maximal number of sides per one edge in the actual mesh (set in make_neighbours_and_edges()).
521  unsigned int max_edge_sides_[3];
522 
523  /// Output of neighboring data into raw output.
525 
526  /**
527  * Apply functionality of MeshOptimizer to sort nodes and elements.
528  *
529  * Use Hilbert curve, need call sort_permuted_nodes_elements method.
530  */
531  void optimize();
532 
533  /// Sort elements and nodes by order stored in permutation vectors.
534  void sort_permuted_nodes_elements(std::vector<int> new_node_ids, std::vector<int> new_elem_ids);
535 
536  /**
537  * Flag for optimization perfomed at the beginning of setup_topology.
538  * Default true, can be set to flase by the optimize_mesh key of the input recoed.
539  */
541 
542  /**
543  * Database of regions (both bulk and boundary) of the mesh. Regions are logical parts of the
544  * domain that allows setting of different data and boundary conditions on them.
545  */
547  /**
548  * Mesh partitioning. Created in setup_topology.
549  */
550  std::shared_ptr<Partitioning> part_;
551 
552  /**
553  * BIH Tree for intersection and observe points lookup.
554  */
555  std::shared_ptr<BIHTree> bih_tree_;
556 
557 
558  /**
559  * Accessor to the input record for the mesh.
560  */
562 
563  /**
564  * MPI communicator used for partitioning and ...
565  */
567 
568  /**
569  * Vector of elements of the mesh.
570  *
571  * Store all elements of the mesh in order bulk elements - boundary elements
572  */
574 
575  /// Hold data of boundary elements during reading mesh (allow to preserve correct order during reading of mix bulk-boundary element)
577 
578  /// Count of bulk elements
579  unsigned int bulk_size_;
580 
581  /// Count of boundary elements loaded from mesh file
582  unsigned int boundary_loaded_size_;
583 
584  /// Maps element ids to indexes into vector element_vec_
586 
587  /**
588  * Vector of nodes of the mesh.
589  */
591 
592  /// Maps node ids to indexes into vector node_vec_
594 
595  /// Vector of MH edges, this should not be part of the geometrical mesh
597 
598  /// Vector of node permutations of optimized mesh (see class MeshOptimizer)
600 
601  /// Vector of element permutations of optimized mesh (see class MeshOptimizer)
603 
604 
605  friend class Edge;
606  friend class Side;
607  friend class RegionSetBase;
608  friend class Element;
609  friend class BIHTree;
610  friend class Boundary;
611  friend class BCMesh;
612  template <int spacedim> friend class ElementAccessor;
613  template <int spacedim> friend class NodeAccessor;
614 
615 
616 
617 private:
618 
619  /// Fill array node_4_loc_ and create object node_ds_ according to element distribution.
620  void distribute_nodes();
621 
622  /// Index set assigning to global element index the local index used in parallel vectors.
624  /// Index set assigning to local element index its global index.
626  /// Parallel distribution of elements.
628  /// Index set assigning to local node index its global index.
630  /// Parallel distribution of nodes. Depends on elements distribution.
632  /// Hold number of local nodes (own + ghost), value is equal with size of node_4_loc array.
633  unsigned int n_local_nodes_;
634  /// Boundary mesh, object is created only if it's necessary
636 
637 };
638 
639 #endif
640 //-----------------------------------------------------------------------------
641 // vim: set cindent:
Mesh::node_permutations
const std::vector< unsigned int > & node_permutations() const
Return permutation vector of nodes.
Definition: mesh.h:411
Mesh::ElementTmpData::partition_id
unsigned int partition_id
Definition: mesh.h:452
Mesh::get_el_ds
Distribution * get_el_ds() const
Definition: mesh.h:171
Mesh::y_coord
@ y_coord
Definition: mesh.h:126
Mesh::create_boundary_elements
unsigned int create_boundary_elements()
Create boundary elements from data of temporary structure, this method MUST be call after read mesh f...
Definition: mesh.cc:1441
Mesh::n_tetrahedras
int n_tetrahedras
Definition: mesh.h:304
Mesh::permute_triangle
void permute_triangle(unsigned int elm_idx, std::vector< unsigned int > permutation_vec)
Permute nodes of 2D elements of given elm_idx.
Definition: mesh.cc:1472
Boundary
Definition: accessors.hh:320
BidirectionalMap< int >
general_iterator.hh
Template Iter serves as general template for internal iterators.
Mesh::nodes_
Armor::Array< double > nodes_
Definition: mesh.h:590
Mesh::check_compatible_discont_mesh
virtual std::shared_ptr< std::vector< LongIdx > > check_compatible_discont_mesh(Mesh &input_mesh)
Definition: mesh.cc:1101
armor.hh
Mesh::permute_tetrahedron
void permute_tetrahedron(unsigned int elm_idx, std::vector< unsigned int > permutation_vec)
Permute nodes of 3D elements of given elm_idx.
Definition: mesh.cc:1455
Mesh::get_input_intersection_variant
static const Input::Type::Selection & get_input_intersection_variant()
The definition of input record for selection of variant of file format.
Definition: mesh.cc:64
BoundarySegment
Definition: mesh.h:68
Mesh::get_element_boxes
std::vector< BoundingBox > get_element_boxes()
Compute bounding boxes of elements contained in mesh.
Definition: mesh.cc:1196
Mesh::node_4_loc_
LongIdx * node_4_loc_
Index set assigning to local node index its global index.
Definition: mesh.h:629
Mesh::in_record_
Input::Record in_record_
Definition: mesh.h:561
Mesh::ElementTmpData::elm_id
unsigned int elm_id
Definition: mesh.h:449
Mesh::init_element_vector
void init_element_vector(unsigned int size)
Initialize element_vec_, set size and reset counters of boundary and bulk elements.
Definition: mesh.cc:1289
Mesh::undef_idx
static const unsigned int undef_idx
Definition: mesh.h:121
Mesh::ElementTmpData::region_idx
RegionIdx region_idx
Definition: mesh.h:451
Mesh::ElementTmpData::ElementTmpData
ElementTmpData(unsigned int e_id, unsigned int dm, RegionIdx reg_idx, unsigned int part_id, std::vector< unsigned int > nodes)
Constructor.
Definition: mesh.h:446
Mesh::n_exsides
int n_exsides
Definition: mesh.h:299
Mesh::init_element
void init_element(Element *ele, unsigned int elm_id, unsigned int dim, RegionIdx region_idx, unsigned int partition_id, std::vector< unsigned int > node_ids)
Initialize element.
Definition: mesh.cc:1260
Mesh::elements_range
virtual Range< ElementAccessor< 3 > > elements_range() const
Returns range of bulk elements.
Definition: mesh.cc:1320
Mesh::n_sides
unsigned int n_sides() const
Definition: mesh.cc:225
Mesh::element_permutations
const std::vector< unsigned int > & element_permutations() const
Return permutation vector of elements.
Definition: mesh.h:393
file_path.hh
MixedMeshIntersections
Main class for computation of intersection of meshes of combined dimensions.
Definition: mixed_mesh_intersections.hh:64
Input::Record::val
const Ret val(const string &key) const
Definition: accessors_impl.hh:31
Mesh::boundary_loaded_size_
unsigned int boundary_loaded_size_
Count of boundary elements loaded from mesh file.
Definition: mesh.h:582
Mesh::tree
DuplicateNodes * tree
Definition: mesh.h:291
Mesh::element_vec_
vector< Element > element_vec_
Definition: mesh.h:573
FilePath
Dedicated class for storing path to input and output files.
Definition: file_path.hh:54
Mesh::sort_permuted_nodes_elements
void sort_permuted_nodes_elements(std::vector< int > new_node_ids, std::vector< int > new_elem_ids)
Sort elements and nodes by order stored in permutation vectors.
Definition: mesh.cc:427
Mesh::get_input_type
static const Input::Type::Record & get_input_type()
Definition: mesh.cc:75
BIHTree
Class for O(log N) lookup for intersections with a set of bounding boxes.
Definition: bih_tree.hh:38
Mesh::max_edge_sides_
unsigned int max_edge_sides_[3]
Maximal number of sides per one edge in the actual mesh (set in make_neighbours_and_edges()).
Definition: mesh.h:521
std::vector< LongIdx >
Mesh::n_edges
unsigned int n_edges() const
Definition: mesh.h:151
Mesh::count_side_types
void count_side_types()
Definition: mesh.cc:454
ElementAccessor
Definition: dh_cell_accessor.hh:32
Mesh::TYPEDEF_ERR_INFO
TYPEDEF_ERR_INFO(EI_ElemLast, int)
Partitioning
Class for the mesh partitioning. This should provide:
Definition: partitioning.hh:52
Mesh::make_edge_permutations
void make_edge_permutations()
Definition: mesh.cc:743
arma::vec3
Definition: doxy_dummy_defs.hh:17
Mesh::get_row_4_el
LongIdx * get_row_4_el() const
Definition: mesh.h:174
Mesh::node_range
Range< NodeAccessor< 3 > > node_range() const
Returns range of nodes.
Definition: mesh.cc:1326
Mesh::boundary
Boundary boundary(uint edge_idx) const
Definition: mesh.cc:255
uint
unsigned int uint
Definition: mh_dofhandler.hh:101
Mesh::n_local_nodes_
unsigned int n_local_nodes_
Hold number of local nodes (own + ghost), value is equal with size of node_4_loc array.
Definition: mesh.h:633
Neighbour
Definition: neighbours.h:117
Mesh::read_regions_from_input
void read_regions_from_input(Input::Array region_list)
Definition: mesh.cc:1171
index_types.hh
Mesh::z_coord
@ z_coord
Definition: mesh.h:126
Mesh::get_intersection_search
IntersectionSearch get_intersection_search()
Getter for input type selection for intersection search algorithm.
Definition: mesh.cc:138
storage.hh
Mesh::optimize_memory_locality
bool optimize_memory_locality
Definition: mesh.h:540
Mesh::n_vb_neighbours
unsigned int n_vb_neighbours() const
Definition: mesh.cc:234
exceptions.hh
type_record.hh
Mesh::n_elements
virtual unsigned int n_elements() const
Returns count of boundary or bulk elements.
Definition: mesh.h:373
Mesh::get_node_ds
Distribution * get_node_ds() const
Definition: mesh.h:180
Element
Definition: elements.h:39
Mesh::optimize
void optimize()
Definition: mesh.cc:417
Mesh::el_ds
Distribution * el_ds
Parallel distribution of elements.
Definition: mesh.h:627
Mesh::intersect_element_lists
void intersect_element_lists(vector< unsigned int > const &nodes_list, vector< unsigned int > &intersection_element_list)
Definition: mesh.cc:481
Mesh::n_sides_
int n_sides_
Definition: mesh.h:300
BidirectionalMap::get_position
int get_position(T val) const
Return position of item of given value.
Definition: bidirectional_map.hh:114
RegionSetBase
Definition: region_set.hh:35
Mesh::init_from_input
void init_from_input()
Mesh::output_internal_ngh_data
void output_internal_ngh_data()
Output of neighboring data into raw output.
Definition: mesh.cc:1346
Mesh::DECLARE_EXCEPTION
DECLARE_EXCEPTION(ExcDuplicateBoundary,<< "Duplicate boundary elements! \n"<< "Element id: "<< EI_ElemLast::val<< " on region name: "<< EI_RegLast::val<< "\n"<< "Element id: "<< EI_ElemNew::val<< " on region name: "<< EI_RegNew::val<< "\n")
Mesh::ElementTmpData::node_ids
std::vector< unsigned int > node_ids
Definition: mesh.h:453
Mesh::get_local_part
virtual const LongIdx * get_local_part()
Definition: mesh.cc:265
Distribution
Definition: distribution.hh:50
Mesh::node_ids_
BidirectionalMap< int > node_ids_
Maps node ids to indexes into vector node_vec_.
Definition: mesh.h:593
Mesh::BBsearch
@ BBsearch
Definition: mesh.h:113
Mesh::check_mesh_on_read
void check_mesh_on_read()
Definition: mesh.cc:316
Mesh::n_corners
unsigned int n_corners()
Definition: mesh.cc:239
Mesh::find_lower_dim_element
bool find_lower_dim_element(vector< unsigned int > &element_list, unsigned int dim, unsigned int &element_idx)
Definition: mesh.cc:513
Mesh::count_element_types
void count_element_types()
Definition: mesh.cc:274
Input::Record
Accessor to the data with type Type::Record.
Definition: accessors.hh:291
Mesh::get_bih_tree
const BIHTree & get_bih_tree()
Getter for BIH. Creates and compute BIH at first call.
Definition: mesh.cc:1211
elements.h
Mesh::distribute_nodes
void distribute_nodes()
Fill array node_4_loc_ and create object node_ds_ according to element distribution.
Definition: mesh.cc:1495
Mesh::get_node_4_loc
LongIdx * get_node_4_loc() const
Definition: mesh.h:183
Mesh::read_gmsh_from_stream
void read_gmsh_from_stream(istream &in)
Mesh::get_bc_mesh
BCMesh * get_bc_mesh()
Create boundary mesh if doesn't exist and return it.
Definition: mesh.cc:1489
mpi.h
accessors.hh
Mesh::el_4_loc
LongIdx * el_4_loc
Index set assigning to local element index its global index.
Definition: mesh.h:625
Mesh::elements_id_maps
void elements_id_maps(vector< LongIdx > &bulk_elements_id, vector< LongIdx > &boundary_elements_id) const
Definition: mesh.cc:925
Mesh::ElementTmpData::dim
unsigned int dim
Definition: mesh.h:450
Mesh::side_nodes
vector< vector< vector< unsigned int > > > side_nodes
Definition: mesh.h:316
Mesh::node_permutation_
std::vector< unsigned int > node_permutation_
Vector of node permutations of optimized mesh (see class MeshOptimizer)
Definition: mesh.h:599
Mesh::region_db_
RegionDB region_db_
Definition: mesh.h:546
Side
Definition: accessors.hh:361
bidirectional_map.hh
Implementation of bidirectional map.
Mesh::IntersectionSearch
IntersectionSearch
Types of search algorithm for finding intersection candidates.
Definition: mesh.h:110
Mesh::find_elem_id
int find_elem_id(unsigned int pos) const
Return element id (in GMSH file) of element of given position in element vector.
Definition: mesh.h:387
Mesh::region_db
const RegionDB & region_db() const
Definition: mesh.h:160
Mesh::init
void init()
Definition: mesh.cc:144
Mesh::master_elements
vector< vector< unsigned int > > master_elements
Definition: mesh.h:289
Mesh::mesh_file
FilePath mesh_file()
Return FilePath object representing "mesh_file" input key.
Definition: mesh.h:347
RegionDB
Definition: region.hh:292
Mesh::bih_tree_
std::shared_ptr< BIHTree > bih_tree_
Definition: mesh.h:555
Mesh::node_ds_
Distribution * node_ds_
Parallel distribution of nodes. Depends on elements distribution.
Definition: mesh.h:631
Input::Type::Selection
Template for classes storing finite set of named values.
Definition: type_selection.hh:65
std::map< unsigned int, unsigned int >
bounding_box.hh
Mesh::same_sides
bool same_sides(const SideIter &si, vector< unsigned int > &side_nodes)
Definition: mesh.cc:532
Mesh::element_to_neigh_vb
void element_to_neigh_vb()
Definition: mesh.cc:863
Armor::Array::size
unsigned int size() const
Definition: armor.hh:728
Mesh::check_element_size
void check_element_size(unsigned int elem_idx) const
Check if given index is in element_vec_.
Definition: mesh.cc:1338
Mesh::get_comm
MPI_Comm get_comm() const
Definition: mesh.h:192
Mesh::add_element
void add_element(unsigned int elm_id, unsigned int dim, unsigned int region_id, unsigned int partition_id, std::vector< unsigned int > node_ids)
Add new element of given id to mesh.
Definition: mesh.cc:1237
Input::Type::Record
Record type proxy class.
Definition: type_record.hh:182
MPI_Comm
int MPI_Comm
Definition: mpi.h:141
Mesh::~Mesh
virtual ~Mesh()
Destructor.
Definition: mesh.cc:200
Mesh::n_bb_neigh
unsigned int n_bb_neigh
Definition: mesh.h:518
Mesh::create_node_element_lists
void create_node_element_lists()
Definition: mesh.cc:468
LongIdx
int LongIdx
Define type that represents indices of large arrays (elements, nodes, dofs etc.)
Definition: index_types.hh:24
Mesh::setup_topology
void setup_topology()
Definition: mesh.cc:381
Mesh::add_element_to_vector
Element * add_element_to_vector(int id)
Adds element to mesh data structures (element_vec_, element_ids_), returns pointer to this element.
Definition: mesh.cc:1312
Mesh::modify_element_ids
void modify_element_ids(const RegionDB::MapElementIDToRegionID &map)
Definition: mesh.cc:291
Mesh
Definition: mesh.h:77
Mesh::BIHsearch
@ BIHsearch
Definition: mesh.h:111
Mesh::elem_index
int elem_index(int elem_id) const
For element of given elem_id returns index in element_vec_ or (-1) if element doesn't exist.
Definition: mesh.h:381
Range
Range helper class.
Definition: range_wrapper.hh:65
accessors_impl.hh
Mesh::edges
std::vector< EdgeData > edges
Vector of MH edges, this should not be part of the geometrical mesh.
Definition: mesh.h:596
Mesh::make_neighbours_and_edges
void make_neighbours_and_edges()
Definition: mesh.cc:549
Mesh::init_node_vector
void init_node_vector(unsigned int size)
Initialize node_vec_, set size.
Definition: mesh.cc:1303
Mesh::check_compatible_mesh
virtual std::shared_ptr< std::vector< LongIdx > > check_compatible_mesh(Mesh &input_mesh)
Definition: mesh.cc:966
Mesh::elem_permutation_
std::vector< unsigned int > elem_permutation_
Vector of element permutations of optimized mesh (see class MeshOptimizer)
Definition: mesh.h:602
Edge
Definition: accessors.hh:265
Input::Array
Accessor to input data conforming to declared Array.
Definition: accessors.hh:566
Mesh::Mesh
Mesh()
Definition: mesh.cc:103
Mesh::n_vb_neigh
unsigned int n_vb_neigh
Definition: mesh.h:518
Mesh::n_boundaries
unsigned int n_boundaries() const
Definition: mesh.h:147
mesh_data.hh
Internal mesh data classes.
Mesh::n_lines
int n_lines
Definition: mesh.h:302
RegionIdx
Definition: region.hh:67
Mesh::node_index
int node_index(int node_id) const
For node of given node_id returns index in element_vec_ or (-1) if node doesn't exist.
Definition: mesh.h:399
BCMesh
Class represents boundary part of mesh.
Definition: bc_mesh.hh:35
Mesh::check_and_finish
void check_and_finish()
Definition: mesh.cc:1181
Mesh::edge_range
Range< Edge > edge_range() const
Returns range of edges.
Definition: mesh.cc:1332
BoundarySegment::input_type
static Input::Type::Record input_type
Definition: mesh.h:70
NodeAccessor
Definition: mesh.h:55
Mesh::node_elements_
vector< vector< unsigned int > > node_elements_
For each node the vector contains a list of elements that use this node.
Definition: mesh.h:378
MPI_COMM_WORLD
#define MPI_COMM_WORLD
Definition: mpi.h:123
region.hh
Mesh::element_ids_
BidirectionalMap< int > element_ids_
Maps element ids to indexes into vector element_vec_.
Definition: mesh.h:585
Armor::Array< double >
Mesh::add_node
void add_node(unsigned int node_id, arma::vec3 coords)
Add new node of given id and coordinates to mesh.
Definition: mesh.cc:1229
Mesh::max_edge_sides
unsigned int max_edge_sides(unsigned int dim) const
Definition: mesh.h:205
Mesh::bc_element_tmp_
vector< ElementTmpData > bc_element_tmp_
Hold data of boundary elements during reading mesh (allow to preserve correct order during reading of...
Definition: mesh.h:576
Mesh::part_
std::shared_ptr< Partitioning > part_
Definition: mesh.h:550
Mesh::bulk_size_
unsigned int bulk_size_
Count of bulk elements.
Definition: mesh.h:579
Mesh::row_4_el
LongIdx * row_4_el
Index set assigning to global element index the local index used in parallel vectors.
Definition: mesh.h:623
Mesh::node_elements
const vector< vector< unsigned int > > & node_elements()
Definition: mesh.cc:1281
Mesh::comm_
MPI_Comm comm_
Definition: mesh.h:566
Mesh::global_snap_radius
double global_snap_radius() const
Maximal distance of observe point from Mesh relative to its size.
Definition: mesh.cc:1220
Mesh::boundary_
vector< BoundaryData > boundary_
Definition: mesh.h:275
Mesh::n_local_nodes
unsigned int n_local_nodes() const
Definition: mesh.h:186
Mesh::get_part
virtual Partitioning * get_part()
Definition: mesh.cc:261
Mesh::n_insides
int n_insides
Definition: mesh.h:298
Mesh::bc_mesh_
BCMesh * bc_mesh_
Boundary mesh, object is created only if it's necessary.
Definition: mesh.h:635
Mesh::mixed_intersections
MixedMeshIntersections & mixed_intersections()
Definition: mesh.cc:896
Mesh::BIHonly
@ BIHonly
Definition: mesh.h:112
Mesh::node
NodeAccessor< 3 > node(unsigned int idx) const
Create and return NodeAccessor to node of given idx.
Definition: mesh.cc:919
Mesh::element_accessor
virtual ElementAccessor< 3 > element_accessor(unsigned int idx) const
Create and return ElementAccessor to element of given idx.
Definition: mesh.cc:913
Mesh::n_nodes
virtual unsigned int n_nodes() const
Definition: mesh.h:143
Mesh::find_node_id
int find_node_id(unsigned int pos) const
Return node id (in GMSH file) of node of given position in node vector.
Definition: mesh.h:405
SideIter
Definition: accessors.hh:461
Mesh::edge
Edge edge(uint edge_idx) const
Definition: mesh.cc:249
Mesh::add_physical_name
void add_physical_name(unsigned int dim, unsigned int id, std::string name)
Add new node of given id and coordinates to mesh.
Definition: mesh.cc:1224
Mesh::vb_neighbours_
vector< Neighbour > vb_neighbours_
Definition: mesh.h:296
Mesh::x_coord
@ x_coord
Definition: mesh.h:126
Mesh::ElementTmpData
Definition: mesh.h:444
Mesh::n_triangles
int n_triangles
Definition: mesh.h:303
DuplicateNodes
Definition: duplicate_nodes.h:96
range_wrapper.hh
Implementation of range helper class.
Mesh::get_el_4_loc
LongIdx * get_el_4_loc() const
Definition: mesh.h:177
Mesh::intersections
std::shared_ptr< MixedMeshIntersections > intersections
Definition: mesh.h:283