Flow123d  JS_before_hm-1754-g1847fd3ed
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  * Permute nodes of individual elements so that all elements have same edge orientations and aligned sides have same order of their nodes
220  * Canonical edge orientation in elements and faces is from nodes of lower local index to higher local index.
221  *
222  * Algorithm detals:
223  * 1. Orient all edges from lowe global node id to higher node id, fictional step. (substantial is orientation of yet non-oriented edges of a node in direction out of the node.
224  * Can be proven (!?) that this prevents edge cycles of the length 3 (faces with cyclic edges).
225  * 2. Having all faces non-cyclic there exists a permutation of any element to the reference element.
226  * Pass through the elements. Sort nodes by global ID.
227  */
228  void canonical_faces();
229 
230  /**
231  * Initialize all mesh structures from raw information about nodes and elements (including boundary elements).
232  * Namely: create remaining boundary elements and Boundary objects, find edges and compatible neighborings.
233  */
234  void setup_topology();
235 
236  /**
237  * Returns vector of ID numbers of elements, either bulk or bc elemnts.
238  */
239  void elements_id_maps( vector<LongIdx> & bulk_elements_id, vector<LongIdx> & boundary_elements_id) const;
240 
241  /*
242  * Check if nodes and elements are compatible with continuous \p input_mesh.
243  *
244  * Call this method on computational mesh.
245  * @param input_mesh data mesh of input fields
246  * @return vector that holds mapping between eleemnts of data and computational meshes
247  * for every element in computational mesh hold idx of equivalent element in input mesh.
248  * If element doesn't exist in input mesh value is set to Mesh::undef_idx.
249  * If meshes are not compatible returns empty vector.
250  */
251  virtual std::shared_ptr<std::vector<LongIdx>> check_compatible_mesh( Mesh & input_mesh);
252 
253  /*
254  * Check if nodes and elements are compatible with discontinuous \p input_mesh.
255  *
256  * Call this method on computational mesh.
257  * @param input_mesh data mesh of input fields
258  * @return vector that holds mapping between eleemnts of data and computational meshes
259  * for every element in computational mesh hold idx of equivalent element in input mesh.
260  * If element doesn't exist in input mesh value is set to Mesh::undef_idx.
261  * If meshes are not compatible returns empty vector.
262  */
263  virtual std::shared_ptr<std::vector<LongIdx>> check_compatible_discont_mesh( Mesh & input_mesh);
264 
265  /// Create and return ElementAccessor to element of given idx
266  virtual ElementAccessor<3> element_accessor(unsigned int idx) const;
267 
268  /// Create and return NodeAccessor to node of given idx
269  NodeAccessor<3> node(unsigned int idx) const;
270 
271  /**
272  * Reads elements and their affiliation to regions and region sets defined by user in input file
273  * Format of input record is defined in method RegionSetBase::get_input_type()
274  *
275  * @param region_list Array input AbstractRecords which define regions, region sets and elements
276  */
277  void read_regions_from_input(Input::Array region_list);
278 
279  /**
280  * Returns nodes_elements vector, if doesn't exist creates its.
281  */
283 
284  /// Vector of boundary sides where is prescribed boundary condition.
285  /// TODO: apply all boundary conditions in the main assembling cycle over elements and remove this Vector.
287 
288  //flow::VectorId<int> bcd_group_id; // gives a index of group for an id
289 
290  /**
291  * Vector of individual intersections of two elements.
292  * This is enough for local mortar.
293  */
294  std::shared_ptr<MixedMeshIntersections> intersections;
295 
296  /**
297  * For every element El we have vector of indices into @var intersections array for every intersection in which El is master element.
298  * This is necessary for true mortar.
299  */
301 
303 
304  /**
305  * Vector of compatible neighbourings.
306  */
308 
309  int n_insides; // # of internal sides
310  int n_exsides; // # of external sides
311  mutable int n_sides_; // total number of sides (should be easy to count when we have separated dimensions
312 
313 
314  // Temporary solution for numbering of nodes on sides.
315  // The data are defined in RefElement<dim>::side_nodes,
316  // Mesh::side_nodes can be removed as soon as Element
317  // is templated by dimension.
318  //
319  // side_nodes[dim][elm_side_idx][side_node_idx]
320  // for every side dimension D = 0 .. 2
321  // for every element side 0 .. D+1
322  // for every side node 0 .. D
323  // index into element node array
325 
326  /**
327  * Check usage of regions, set regions to elements defined by user, close RegionDB
328  */
329  void check_and_finish();
330 
331  /// Compute bounding boxes of elements contained in mesh.
333 
334  /// Getter for BIH. Creates and compute BIH at first call.
335  const BIHTree &get_bih_tree();\
336 
337  /**
338  * Find intersection of element lists given by Mesh::node_elements_ for elements givne by @p nodes_list parameter.
339  * The result is placed into vector @p intersection_element_list. If the @p node_list is empty, and empty intersection is
340  * returned.
341  */
342  void intersect_element_lists(vector<unsigned int> const &nodes_list, vector<unsigned int> &intersection_element_list);
343 
344  /// Add new node of given id and coordinates to mesh
345  void add_node(unsigned int node_id, arma::vec3 coords);
346 
347  /// Add new element of given id to mesh
348  void add_element(unsigned int elm_id, unsigned int dim, unsigned int region_id, unsigned int partition_id,
349  std::vector<unsigned int> node_ids);
350 
351  /// Add new node of given id and coordinates to mesh
352  void add_physical_name(unsigned int dim, unsigned int id, std::string name);
353 
354  /// Return FilePath object representing "mesh_file" input key
355  inline FilePath mesh_file() {
356  return in_record_.val<FilePath>("mesh_file");
357  }
358 
359  /// Getter for input type selection for intersection search algorithm.
361 
362  /// Maximal distance of observe point from Mesh relative to its size
363  double global_snap_radius() const;
364 
365  /// Initialize element_vec_, set size and reset counters of boundary and bulk elements.
366  void init_element_vector(unsigned int size);
367 
368  /// Initialize node_vec_, set size
369  void init_node_vector(unsigned int size);
370 
371  // TODO: have also private non-const accessors and ranges
372 
373  /// Returns range of bulk elements
374  virtual Range<ElementAccessor<3>> elements_range() const;
375 
376  /// Returns range of nodes
378 
379  /// Returns range of edges
380  Range<Edge> edge_range() const;
381 
382  /// Returns count of boundary or bulk elements
383  virtual unsigned int n_elements() const {
384  return bulk_size_;
385  }
386 
387  /// For each node the vector contains a list of elements that use this node
389 
390  /// For element of given elem_id returns index in element_vec_ or (-1) if element doesn't exist.
391  inline int elem_index(int elem_id) const
392  {
393  return element_ids_.get_position(elem_id);
394  }
395 
396  /// Return element id (in GMSH file) of element of given position in element vector.
397  inline int find_elem_id(unsigned int pos) const
398  {
399  return element_ids_[pos];
400  }
401 
402  /// Return permutation vector of elements
404  {
405  return elem_permutation_;
406  }
407 
408  /// For node of given node_id returns index in element_vec_ or (-1) if node doesn't exist.
409  inline int node_index(int node_id) const
410  {
411  return node_ids_.get_position(node_id);
412  }
413 
414  /// Return node id (in GMSH file) of node of given position in node vector.
415  inline int find_node_id(unsigned int pos) const
416  {
417  return node_ids_[pos];
418  }
419 
420  /// Return permutation vector of nodes
422  {
423  return node_permutation_;
424  }
425 
426  /// Check if given index is in element_vec_
427  void check_element_size(unsigned int elem_idx) const;
428 
429  /// Create boundary elements from data of temporary structure, this method MUST be call after read mesh from file, return number of read boundary elements
430  unsigned int create_boundary_elements();
431 
432  /// Create boundary mesh if doesn't exist and return it.
433  BCMesh *get_bc_mesh();
434 
435 protected:
436 
437  /**
438  * Part of the constructor whichdoes not depedn on input record.
439  * Initializes node-side numbering according to RefElement.
440  */
441  void init();
442 
443  /**
444  * Allow store boundary element data to temporary structure.
445  *
446  * We need this structure to preserve correct order of boundary elements.
447  */
448  struct ElementTmpData {
449  /// Constructor
450  ElementTmpData(unsigned int e_id, unsigned int dm, RegionIdx reg_idx, unsigned int part_id, std::vector<unsigned int> nodes)
451  : elm_id(e_id), dim(dm), region_idx(reg_idx), partition_id(part_id), node_ids(nodes) {}
452 
453  unsigned int elm_id;
454  unsigned int dim;
456  unsigned int partition_id;
458  };
459 
460  /**
461  * This replaces read_neighbours() in order to avoid using NGH preprocessor.
462  *
463  * TODO:
464  * - Avoid maps:
465  *
466  * 5) need not to have temporary array for Edges, only postpone setting pointers in elements and set them
467  * after edges are found; we can temporary save Edge index instead of pointer in Neigbours and elements
468  *
469  * 6) Try replace Edge * by indexes in Neigbours and elements (anyway we have mesh pointer in elements so it is accessible also from Neigbours)
470  *
471  */
473 
474  /**
475  * Create element lists for nodes in Mesh::nodes_elements.
476  */
478  /**
479  * Remove elements with dimension not equal to @p dim from @p element_list. Index of the first element of dimension @p dim-1,
480  * 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,
481  * if more elements are found we report an user input error.
482  */
483  bool find_lower_dim_element(vector<unsigned int> &element_list, unsigned int dim, unsigned int &element_idx);
484 
485  /**
486  * Returns true if side @p si has same nodes as in the list @p side_nodes.
487  */
489 
490 
491  void element_to_neigh_vb();
492 
493  void count_element_types();
494  void count_side_types();
495 
496  /**
497  * Check the element quality and remove unused nodes.
498  */
499  void check_mesh_on_read();
500 
501  /**
502  * Possibly modify region id of elements sets by user in "regions" part of input file.
503  *
504  * TODO: This method needs check in issue 'Review mesh setting'.
505  * Changes have been done during generalized region key and may be causing problems
506  * during the further development.
507  */
509 
510  /// Adds element to mesh data structures (element_vec_, element_ids_), returns pointer to this element.
511  Element * add_element_to_vector(int id);
512 
513  /// Initialize element
514  void init_element(Element *ele, unsigned int elm_id, unsigned int dim, RegionIdx region_idx, unsigned int partition_id,
515  std::vector<unsigned int> node_ids);
516 
517  unsigned int n_bb_neigh, n_vb_neigh;
518 
519  /// Maximal number of sides per one edge in the actual mesh (set in make_neighbours_and_edges()).
520  unsigned int max_edge_sides_[3];
521 
522  /// Output of neighboring data into raw output.
524 
525  /**
526  * Apply functionality of MeshOptimizer to sort nodes and elements.
527  *
528  * Use Hilbert curve, need call sort_permuted_nodes_elements method.
529  */
530  void optimize();
531 
532  /// Sort elements and nodes by order stored in permutation vectors.
533  void sort_permuted_nodes_elements(std::vector<int> new_node_ids, std::vector<int> new_elem_ids);
534 
535  /**
536  * Flag for optimization perfomed at the beginning of setup_topology.
537  * Default true, can be set to flase by the optimize_mesh key of the input recoed.
538  */
540 
541  /**
542  * Database of regions (both bulk and boundary) of the mesh. Regions are logical parts of the
543  * domain that allows setting of different data and boundary conditions on them.
544  */
546  /**
547  * Mesh partitioning. Created in setup_topology.
548  */
549  std::shared_ptr<Partitioning> part_;
550 
551  /**
552  * BIH Tree for intersection and observe points lookup.
553  */
554  std::shared_ptr<BIHTree> bih_tree_;
555 
556 
557  /**
558  * Accessor to the input record for the mesh.
559  */
561 
562  /**
563  * MPI communicator used for partitioning and ...
564  */
566 
567  /**
568  * Vector of elements of the mesh.
569  *
570  * Store all elements of the mesh in order bulk elements - boundary elements
571  */
573 
574  /// Hold data of boundary elements during reading mesh (allow to preserve correct order during reading of mix bulk-boundary element)
576 
577  /// Count of bulk elements
578  unsigned int bulk_size_;
579 
580  /// Count of boundary elements loaded from mesh file
581  unsigned int boundary_loaded_size_;
582 
583  /// Maps element ids to indexes into vector element_vec_
585 
586  /**
587  * Vector of nodes of the mesh.
588  */
590 
591  /// Maps node ids to indexes into vector node_vec_
593 
594  /// Vector of MH edges, this should not be part of the geometrical mesh
596 
597  /// Vector of node permutations of optimized mesh (see class MeshOptimizer)
599 
600  /// Vector of element permutations of optimized mesh (see class MeshOptimizer)
602 
603 
604  friend class Edge;
605  friend class Side;
606  friend class RegionSetBase;
607  friend class Element;
608  friend class BIHTree;
609  friend class Boundary;
610  friend class BCMesh;
611  template <int spacedim> friend class ElementAccessor;
612  template <int spacedim> friend class NodeAccessor;
613 
614 
615 
616 private:
617 
618  /// Fill array node_4_loc_ and create object node_ds_ according to element distribution.
619  void distribute_nodes();
620 
621  /// Index set assigning to global element index the local index used in parallel vectors.
623  /// Index set assigning to local element index its global index.
625  /// Parallel distribution of elements.
627  /// Index set assigning to local node index its global index.
629  /// Parallel distribution of nodes. Depends on elements distribution.
631  /// Hold number of local nodes (own + ghost), value is equal with size of node_4_loc array.
632  unsigned int n_local_nodes_;
633  /// Boundary mesh, object is created only if it's necessary
635 
636 };
637 
638 #endif
639 //-----------------------------------------------------------------------------
640 // vim: set cindent:
Mesh::node_permutations
const std::vector< unsigned int > & node_permutations() const
Return permutation vector of nodes.
Definition: mesh.h:421
Mesh::ElementTmpData::partition_id
unsigned int partition_id
Definition: mesh.h:456
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:1341
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:589
Mesh::check_compatible_discont_mesh
virtual std::shared_ptr< std::vector< LongIdx > > check_compatible_discont_mesh(Mesh &input_mesh)
Definition: mesh.cc:997
armor.hh
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:65
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:1092
Mesh::node_4_loc_
LongIdx * node_4_loc_
Index set assigning to local node index its global index.
Definition: mesh.h:628
Mesh::in_record_
Input::Record in_record_
Definition: mesh.h:560
Mesh::ElementTmpData::elm_id
unsigned int elm_id
Definition: mesh.h:453
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:1189
Mesh::undef_idx
static const unsigned int undef_idx
Definition: mesh.h:121
Mesh::ElementTmpData::region_idx
RegionIdx region_idx
Definition: mesh.h:455
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:450
Mesh::n_exsides
int n_exsides
Definition: mesh.h:310
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:1156
Mesh::elements_range
virtual Range< ElementAccessor< 3 > > elements_range() const
Returns range of bulk elements.
Definition: mesh.cc:1220
Mesh::n_sides
unsigned int n_sides() const
Definition: mesh.cc:221
Mesh::element_permutations
const std::vector< unsigned int > & element_permutations() const
Return permutation vector of elements.
Definition: mesh.h:403
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:581
Mesh::tree
DuplicateNodes * tree
Definition: mesh.h:302
Mesh::element_vec_
vector< Element > element_vec_
Definition: mesh.h:572
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:435
Mesh::get_input_type
static const Input::Type::Record & get_input_type()
Definition: mesh.cc:76
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:520
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:462
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
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:1226
Mesh::boundary
Boundary boundary(uint edge_idx) const
Definition: mesh.cc:251
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:632
Neighbour
Definition: neighbours.h:117
Mesh::read_regions_from_input
void read_regions_from_input(Input::Array region_list)
Definition: mesh.cc:1067
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:139
storage.hh
Mesh::optimize_memory_locality
bool optimize_memory_locality
Definition: mesh.h:539
Mesh::n_vb_neighbours
unsigned int n_vb_neighbours() const
Definition: mesh.cc:230
exceptions.hh
type_record.hh
Mesh::n_elements
virtual unsigned int n_elements() const
Returns count of boundary or bulk elements.
Definition: mesh.h:383
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:425
Mesh::el_ds
Distribution * el_ds
Parallel distribution of elements.
Definition: mesh.h:626
Mesh::intersect_element_lists
void intersect_element_lists(vector< unsigned int > const &nodes_list, vector< unsigned int > &intersection_element_list)
Definition: mesh.cc:489
Mesh::n_sides_
int n_sides_
Definition: mesh.h:311
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:1246
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:457
Mesh::get_local_part
virtual const LongIdx * get_local_part()
Definition: mesh.cc:261
Distribution
Definition: distribution.hh:50
Mesh::node_ids_
BidirectionalMap< int > node_ids_
Maps node ids to indexes into vector node_vec_.
Definition: mesh.h:592
Mesh::BBsearch
@ BBsearch
Definition: mesh.h:113
Mesh::check_mesh_on_read
void check_mesh_on_read()
Definition: mesh.cc:304
Mesh::n_corners
unsigned int n_corners()
Definition: mesh.cc:235
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:521
Mesh::count_element_types
void count_element_types()
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:1107
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:1361
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:1355
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:624
Mesh::elements_id_maps
void elements_id_maps(vector< LongIdx > &bulk_elements_id, vector< LongIdx > &boundary_elements_id) const
Definition: mesh.cc:821
Mesh::ElementTmpData::dim
unsigned int dim
Definition: mesh.h:454
Mesh::side_nodes
vector< vector< vector< unsigned int > > > side_nodes
Definition: mesh.h:324
Mesh::node_permutation_
std::vector< unsigned int > node_permutation_
Vector of node permutations of optimized mesh (see class MeshOptimizer)
Definition: mesh.h:598
Mesh::canonical_faces
void canonical_faces()
Definition: mesh.cc:377
Mesh::region_db_
RegionDB region_db_
Definition: mesh.h:545
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:397
Mesh::region_db
const RegionDB & region_db() const
Definition: mesh.h:160
Mesh::init
void init()
Definition: mesh.cc:145
Mesh::master_elements
vector< vector< unsigned int > > master_elements
Definition: mesh.h:300
Mesh::mesh_file
FilePath mesh_file()
Return FilePath object representing "mesh_file" input key.
Definition: mesh.h:355
RegionDB
Definition: region.hh:292
Mesh::bih_tree_
std::shared_ptr< BIHTree > bih_tree_
Definition: mesh.h:554
Mesh::node_ds_
Distribution * node_ds_
Parallel distribution of nodes. Depends on elements distribution.
Definition: mesh.h:630
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:543
Mesh::element_to_neigh_vb
void element_to_neigh_vb()
Definition: mesh.cc:759
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:1238
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:1133
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:196
Mesh::n_bb_neigh
unsigned int n_bb_neigh
Definition: mesh.h:517
Mesh::create_node_element_lists
void create_node_element_lists()
Definition: mesh.cc:476
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:387
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:1212
Mesh::modify_element_ids
void modify_element_ids(const RegionDB::MapElementIDToRegionID &map)
Definition: mesh.cc:279
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:391
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:595
Mesh::make_neighbours_and_edges
void make_neighbours_and_edges()
Definition: mesh.cc:560
Mesh::init_node_vector
void init_node_vector(unsigned int size)
Initialize node_vec_, set size.
Definition: mesh.cc:1203
Mesh::check_compatible_mesh
virtual std::shared_ptr< std::vector< LongIdx > > check_compatible_mesh(Mesh &input_mesh)
Definition: mesh.cc:862
Mesh::elem_permutation_
std::vector< unsigned int > elem_permutation_
Vector of element permutations of optimized mesh (see class MeshOptimizer)
Definition: mesh.h:601
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:104
Mesh::n_vb_neigh
unsigned int n_vb_neigh
Definition: mesh.h:517
Mesh::n_boundaries
unsigned int n_boundaries() const
Definition: mesh.h:147
mesh_data.hh
Internal mesh data classes.
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:409
BCMesh
Class represents boundary part of mesh.
Definition: bc_mesh.hh:35
Mesh::check_and_finish
void check_and_finish()
Definition: mesh.cc:1077
Mesh::edge_range
Range< Edge > edge_range() const
Returns range of edges.
Definition: mesh.cc:1232
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:388
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:584
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:1125
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:575
Mesh::part_
std::shared_ptr< Partitioning > part_
Definition: mesh.h:549
Mesh::bulk_size_
unsigned int bulk_size_
Count of bulk elements.
Definition: mesh.h:578
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:622
Mesh::node_elements
const vector< vector< unsigned int > > & node_elements()
Definition: mesh.cc:1181
Mesh::comm_
MPI_Comm comm_
Definition: mesh.h:565
Mesh::global_snap_radius
double global_snap_radius() const
Maximal distance of observe point from Mesh relative to its size.
Definition: mesh.cc:1116
Mesh::boundary_
vector< BoundaryData > boundary_
Definition: mesh.h:286
Mesh::n_local_nodes
unsigned int n_local_nodes() const
Definition: mesh.h:186
Mesh::get_part
virtual Partitioning * get_part()
Definition: mesh.cc:257
Mesh::n_insides
int n_insides
Definition: mesh.h:309
Mesh::bc_mesh_
BCMesh * bc_mesh_
Boundary mesh, object is created only if it's necessary.
Definition: mesh.h:634
Mesh::mixed_intersections
MixedMeshIntersections & mixed_intersections()
Definition: mesh.cc:792
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:815
Mesh::element_accessor
virtual ElementAccessor< 3 > element_accessor(unsigned int idx) const
Create and return ElementAccessor to element of given idx.
Definition: mesh.cc:809
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:415
SideIter
Definition: accessors.hh:461
Mesh::edge
Edge edge(uint edge_idx) const
Definition: mesh.cc:245
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:1120
Mesh::vb_neighbours_
vector< Neighbour > vb_neighbours_
Definition: mesh.h:307
Mesh::x_coord
@ x_coord
Definition: mesh.h:126
Mesh::ElementTmpData
Definition: mesh.h:448
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:294