Flow123d  JS_before_hm-1879-g0c4ed93bc
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 /** Auxiliary structure that keeps the separate
74  * element maps (bulk and boundary) for reading mesh and elementwise data.
75  * The mapping is considered from the source mesh (reading) to the target mesh (computation).
76  * Used by @p check_compatible_mesh().
77  */
81 
83 
84  EquivalentMeshMap(unsigned int bulk_size, unsigned int boundary_size, LongIdx def_val)
85  : bulk(bulk_size, def_val),
86  boundary(boundary_size, def_val)
87  {}
88 
89  bool empty()
90  { return bulk.empty() && boundary.empty(); }
91 };
92 
93 
94 //=============================================================================
95 // STRUCTURE OF THE MESH
96 //=============================================================================
97 
98 class Mesh {
99 public:
100  TYPEDEF_ERR_INFO( EI_ElemLast, int);
101  TYPEDEF_ERR_INFO( EI_ElemNew, int);
102  TYPEDEF_ERR_INFO( EI_RegLast, std::string);
103  TYPEDEF_ERR_INFO( EI_RegNew, std::string);
104  TYPEDEF_ERR_INFO( EI_ElemId, int);
105  TYPEDEF_ERR_INFO( EI_ElemIdOther, int);
106  TYPEDEF_ERR_INFO( EI_Region, std::string);
107  TYPEDEF_ERR_INFO( EI_RegIdx, unsigned int);
108  TYPEDEF_ERR_INFO( EI_Dim, unsigned int);
109  TYPEDEF_ERR_INFO( EI_DimOther, unsigned int);
110  TYPEDEF_ERR_INFO( EI_Quality, double);
111 
112 
113  DECLARE_EXCEPTION(ExcDuplicateBoundary,
114  << "Duplicate boundary elements! \n"
115  << "Element id: " << EI_ElemLast::val << " on region name: " << EI_RegLast::val << "\n"
116  << "Element id: " << EI_ElemNew::val << " on region name: " << EI_RegNew::val << "\n");
117  DECLARE_EXCEPTION(ExcElmWrongOrder,
118  << "Element IDs in non-increasing order, ID: " << EI_ElemId::val << "\n");
119  DECLARE_EXCEPTION(ExcRegionElmDiffDim,
120  << "User defined region " << EI_Region::qval << " (id " << EI_RegIdx::val
121  << ") by 'From_Elements' cannot have elements of different dimensions.\n"
122  << "Thrown due to: dim " << EI_Dim::val << " neq dim " << EI_DimOther::val << " (ele id " << EI_ElemId::val << ").\n"
123  << "Split elements by dim, create separate regions and then possibly use Union.\n" );
124  DECLARE_EXCEPTION(ExcBadElement,
125  << "Extremely bad quality element ID=" << EI_ElemId::val << ",(" << EI_Quality::val << "<4*epsilon).\n");
126  DECLARE_EXCEPTION(ExcTooMatchingIds,
127  << "Mesh: Duplicate dim-join lower dim elements: " << EI_ElemId::val << ", " << EI_ElemIdOther::val << ".\n" );
128  DECLARE_EXCEPTION(ExcBdrElemMatchRegular,
129  << "Boundary element (id: " << EI_ElemId::val << ") match a regular element (id: " << EI_ElemIdOther::val << ") of lower dimension.\n" );
130 
131 
132  /**
133  * \brief Types of search algorithm for finding intersection candidates.
134  */
135  typedef enum IntersectionSearch {
137  BIHonly = 2,
140 
141  /**
142  * \brief The definition of input record for selection of variant of file format
143  */
145 
146 
147  static const Input::Type::Record & get_input_type();
148 
149 
150  /** Labels for coordinate indexes in arma::vec3 representing vectors and points.*/
151  enum {x_coord=0, y_coord=1, z_coord=2};
152 
153  /**
154  * Empty constructor.
155  *
156  * Use only for unit tests!!!
157  */
158  Mesh();
159  /**
160  * Constructor from an input record.
161  * Do not process input record. That is done in init_from_input.
162  */
163  Mesh(Input::Record in_record, MPI_Comm com = MPI_COMM_WORLD);
164 
165  Mesh(Mesh &other);
166 
167  /// Destructor.
168  virtual ~Mesh();
169 
170  virtual inline unsigned int n_nodes() const {
171  return nodes_.size();
172  }
173 
174  inline unsigned int n_boundaries() const {
175  return boundary_.size();
176  }
177 
178  inline unsigned int n_edges() const {
179  return edges.size();
180  }
181 
182  Edge edge(uint edge_idx) const;
183  Boundary boundary(uint edge_idx) const;
184 
185  unsigned int n_corners();
186 
187  inline const RegionDB &region_db() const {
188  return region_db_;
189  }
190 
191  /**
192  * Returns pointer to partitioning object. Partitioning is created during setup_topology.
193  */
194  virtual Partitioning *get_part();
195 
196  virtual const LongIdx *get_local_part();
197 
199  { return el_ds; }
200 
202  { return row_4_el; }
203 
205  { return el_4_loc; }
206 
208  { return node_ds_; }
209 
211  { return node_4_loc_; }
212 
213  unsigned int n_local_nodes() const
214  { return n_local_nodes_; }
215 
216  /**
217  * Returns MPI communicator of the mesh.
218  */
219  inline MPI_Comm get_comm() const { return comm_; }
220 
221 
223 
224  unsigned int n_sides() const;
225 
226  unsigned int n_vb_neighbours() const;
227 
228  /**
229  * Returns maximal number of sides of one edge, which connects elements of dimension @p dim.
230  * @param dim Dimension of elements sharing the edge.
231  */
232  unsigned int max_edge_sides(unsigned int dim) const { return max_edge_sides_[dim-1]; }
233 
234  /**
235  * Reads mesh from stream.
236  *
237  * Method is especially used in unit tests.
238  */
239  void read_gmsh_from_stream(istream &in);
240  /**
241  * Reads input record, creates regions, read the mesh, setup topology. creates region sets.
242  */
243  void init_from_input();
244 
245  /**
246  * Permute nodes of individual elements so that all elements have same edge orientations and aligned sides have same order of their nodes
247  * Canonical edge orientation in elements and faces is from nodes of lower local index to higher local index.
248  *
249  * Algorithm detals:
250  * 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.
251  * Can be proven (!?) that this prevents edge cycles of the length 3 (faces with cyclic edges).
252  * 2. Having all faces non-cyclic there exists a permutation of any element to the reference element.
253  * Pass through the elements. Sort nodes by global ID.
254  */
255  void canonical_faces();
256 
257  /**
258  * Initialize all mesh structures from raw information about nodes and elements (including boundary elements).
259  * Namely: create remaining boundary elements and Boundary objects, find edges and compatible neighborings.
260  */
261  void setup_topology();
262 
263  /**
264  * Returns vector of ID numbers of elements, either bulk or bc elemnts.
265  */
266  void elements_id_maps( vector<LongIdx> & bulk_elements_id, vector<LongIdx> & boundary_elements_id) const;
267 
268  /*
269  * Check if nodes and elements are compatible with continuous \p input_mesh.
270  *
271  * Call this method on computational mesh.
272  * @param input_mesh data mesh of input fields
273  * @return vector that holds mapping between eleemnts of data and computational meshes
274  * for every element in computational mesh hold idx of equivalent element in input mesh.
275  * If element doesn't exist in input mesh value is set to undef_idx.
276  * If meshes are not compatible returns empty vector.
277  */
278  virtual std::shared_ptr<EquivalentMeshMap> check_compatible_mesh(Mesh & input_mesh);
279 
280  /// Create and return ElementAccessor to element of given idx
281  virtual ElementAccessor<3> element_accessor(unsigned int idx) const;
282 
283  /// Create and return NodeAccessor to node of given idx
284  NodeAccessor<3> node(unsigned int idx) const;
285 
286  /**
287  * Reads elements and their affiliation to regions and region sets defined by user in input file
288  * Format of input record is defined in method RegionSetBase::get_input_type()
289  *
290  * @param region_list Array input AbstractRecords which define regions, region sets and elements
291  */
292  void read_regions_from_input(Input::Array region_list);
293 
294  /**
295  * Returns nodes_elements vector, if doesn't exist creates its.
296  */
298 
299  /// Vector of boundary sides where is prescribed boundary condition.
300  /// TODO: apply all boundary conditions in the main assembling cycle over elements and remove this Vector.
302 
303  //flow::VectorId<int> bcd_group_id; // gives a index of group for an id
304 
305  /**
306  * Vector of individual intersections of two elements.
307  * This is enough for local mortar.
308  */
309  std::shared_ptr<MixedMeshIntersections> intersections;
310 
311  /**
312  * For every element El we have vector of indices into @var intersections array for every intersection in which El is master element.
313  * This is necessary for true mortar.
314  */
316 
318 
319  /**
320  * Vector of compatible neighbourings.
321  */
323 
324  int n_insides; // # of internal sides
325  int n_exsides; // # of external sides
326  mutable int n_sides_; // total number of sides (should be easy to count when we have separated dimensions
327 
328 
329  // Temporary solution for numbering of nodes on sides.
330  // The data are defined in RefElement<dim>::side_nodes,
331  // Mesh::side_nodes can be removed as soon as Element
332  // is templated by dimension.
333  //
334  // side_nodes[dim][elm_side_idx][side_node_idx]
335  // for every side dimension D = 0 .. 2
336  // for every element side 0 .. D+1
337  // for every side node 0 .. D
338  // index into element node array
340 
341  /**
342  * Check usage of regions, set regions to elements defined by user, close RegionDB
343  */
344  void check_and_finish();
345 
346  /// Compute bounding boxes of elements contained in mesh.
348 
349  /// Getter for BIH. Creates and compute BIH at first call.
350  const BIHTree &get_bih_tree();\
351 
352  /**
353  * Find intersection of element lists given by Mesh::node_elements_ for elements givne by @p nodes_list parameter.
354  * The result is placed into vector @p intersection_element_list. If the @p node_list is empty, and empty intersection is
355  * returned.
356  */
357  void intersect_element_lists(vector<unsigned int> const &nodes_list, vector<unsigned int> &intersection_element_list);
358 
359  /// Add new node of given id and coordinates to mesh
360  void add_node(unsigned int node_id, arma::vec3 coords);
361 
362  /// Add new element of given id to mesh
363  void add_element(unsigned int elm_id, unsigned int dim, unsigned int region_id, unsigned int partition_id,
364  std::vector<unsigned int> node_ids);
365 
366  /// Add new node of given id and coordinates to mesh
367  void add_physical_name(unsigned int dim, unsigned int id, std::string name);
368 
369  /// Return FilePath object representing "mesh_file" input key
370  inline FilePath mesh_file() {
371  return in_record_.val<FilePath>("mesh_file");
372  }
373 
374  /// Getter for input type selection for intersection search algorithm.
376 
377  /// Maximal distance of observe point from Mesh relative to its size
378  double global_snap_radius() const;
379 
380  /// Initialize element_vec_, set size and reset counters of boundary and bulk elements.
381  void init_element_vector(unsigned int size);
382 
383  /// Initialize node_vec_, set size
384  void init_node_vector(unsigned int size);
385 
386  // TODO: have also private non-const accessors and ranges
387 
388  /// Returns range of bulk elements
389  virtual Range<ElementAccessor<3>> elements_range() const;
390 
391  /// Returns range of nodes
393 
394  /// Returns range of edges
395  Range<Edge> edge_range() const;
396 
397  /// Returns count of boundary or bulk elements
398  virtual unsigned int n_elements() const {
399  return bulk_size_;
400  }
401 
402  /// For each node the vector contains a list of elements that use this node
404 
405  /// For element of given elem_id returns index in element_vec_ or (-1) if element doesn't exist.
406  inline int elem_index(int elem_id) const
407  {
408  return element_ids_.get_position(elem_id);
409  }
410 
411  /// Return element id (in GMSH file) of element of given position in element vector.
412  inline int find_elem_id(unsigned int pos) const
413  {
414  return element_ids_[pos];
415  }
416 
417  /// Return permutation vector of elements
419  {
420  return elem_permutation_;
421  }
422 
423  /// For node of given node_id returns index in element_vec_ or (-1) if node doesn't exist.
424  inline int node_index(int node_id) const
425  {
426  return node_ids_.get_position(node_id);
427  }
428 
429  /// Return node id (in GMSH file) of node of given position in node vector.
430  inline int find_node_id(unsigned int pos) const
431  {
432  return node_ids_[pos];
433  }
434 
435  /// Return permutation vector of nodes
437  {
438  return node_permutation_;
439  }
440 
441  /// Check if given index is in element_vec_
442  void check_element_size(unsigned int elem_idx) const;
443 
444  /// Create boundary elements from data of temporary structure, this method MUST be call after read mesh from file, return number of read boundary elements
445  unsigned int create_boundary_elements();
446 
447  /// Create boundary mesh if doesn't exist and return it.
448  BCMesh *get_bc_mesh();
449 
450 protected:
451 
452  /**
453  * Part of the constructor whichdoes not depedn on input record.
454  * Initializes node-side numbering according to RefElement.
455  */
456  void init();
457 
458  /**
459  * Allow store boundary element data to temporary structure.
460  *
461  * We need this structure to preserve correct order of boundary elements.
462  */
463  struct ElementTmpData {
464  /// Constructor
465  ElementTmpData(unsigned int e_id, unsigned int dm, RegionIdx reg_idx, unsigned int part_id, std::vector<unsigned int> nodes)
466  : elm_id(e_id), dim(dm), region_idx(reg_idx), partition_id(part_id), node_ids(nodes) {}
467 
468  unsigned int elm_id;
469  unsigned int dim;
471  unsigned int partition_id;
473  };
474 
475  /**
476  * This replaces read_neighbours() in order to avoid using NGH preprocessor.
477  *
478  * TODO:
479  * - Avoid maps:
480  *
481  * 5) need not to have temporary array for Edges, only postpone setting pointers in elements and set them
482  * after edges are found; we can temporary save Edge index instead of pointer in Neigbours and elements
483  *
484  * 6) Try replace Edge * by indexes in Neigbours and elements (anyway we have mesh pointer in elements so it is accessible also from Neigbours)
485  *
486  */
488 
489  /**
490  * Create element lists for nodes in Mesh::nodes_elements.
491  */
493  /**
494  * Remove elements with dimension not equal to @p dim from @p element_list. Index of the first element of dimension @p dim-1,
495  * 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,
496  * if more elements are found we report an user input error.
497  */
498  bool find_lower_dim_element(vector<unsigned int> &element_list, unsigned int dim, unsigned int &element_idx);
499 
500  /**
501  * Returns true if side @p si has same nodes as in the list @p side_nodes.
502  */
504 
505 
506  void element_to_neigh_vb();
507 
508  void count_element_types();
509  void count_side_types();
510 
511  /**
512  * Check the element quality and remove unused nodes.
513  */
514  void check_mesh_on_read();
515 
516  /**
517  * Possibly modify region id of elements sets by user in "regions" part of input file.
518  *
519  * TODO: This method needs check in issue 'Review mesh setting'.
520  * Changes have been done during generalized region key and may be causing problems
521  * during the further development.
522  */
524 
525  /// Adds element to mesh data structures (element_vec_, element_ids_), returns pointer to this element.
526  Element * add_element_to_vector(int id);
527 
528  /// Initialize element
529  void init_element(Element *ele, unsigned int elm_id, unsigned int dim, RegionIdx region_idx, unsigned int partition_id,
530  std::vector<unsigned int> node_ids);
531 
532  unsigned int n_bb_neigh, n_vb_neigh;
533 
534  /// Maximal number of sides per one edge in the actual mesh (set in make_neighbours_and_edges()).
535  unsigned int max_edge_sides_[3];
536 
537  /// Output of neighboring data into raw output.
539 
540  /**
541  * Apply functionality of MeshOptimizer to sort nodes and elements.
542  *
543  * Use Hilbert curve, need call sort_permuted_nodes_elements method.
544  */
545  void optimize();
546 
547  /// Sort elements and nodes by order stored in permutation vectors.
548  void sort_permuted_nodes_elements(std::vector<int> new_node_ids, std::vector<int> new_elem_ids);
549 
550  /**
551  * Looks for the same (compatible) elements between the @p source_mesh and @p target_mesh.
552  * Auxiliary function for check_compatible_mesh().
553  * Uses the nodal mapping @p node_ids.
554  * Fills the element mapping @p map.
555  * Returns the number of compatible elements.
556  */
557  unsigned int check_compatible_elements(Mesh* source_mesh, Mesh* target_mesh,
558  const std::vector<unsigned int>& node_ids,
560 
561  /**
562  * Flag for optimization perfomed at the beginning of setup_topology.
563  * Default true, can be set to flase by the optimize_mesh key of the input recoed.
564  */
566 
567  /**
568  * Database of regions (both bulk and boundary) of the mesh. Regions are logical parts of the
569  * domain that allows setting of different data and boundary conditions on them.
570  */
572  /**
573  * Mesh partitioning. Created in setup_topology.
574  */
575  std::shared_ptr<Partitioning> part_;
576 
577  /**
578  * BIH Tree for intersection and observe points lookup.
579  */
580  std::shared_ptr<BIHTree> bih_tree_;
581 
582 
583  /**
584  * Accessor to the input record for the mesh.
585  */
587 
588  /**
589  * MPI communicator used for partitioning and ...
590  */
592 
593  /**
594  * Vector of elements of the mesh.
595  *
596  * Store all elements of the mesh in order bulk elements - boundary elements
597  */
599 
600  /// Hold data of boundary elements during reading mesh (allow to preserve correct order during reading of mix bulk-boundary element)
602 
603  /// Count of bulk elements
604  unsigned int bulk_size_;
605 
606  /// Count of boundary elements loaded from mesh file
607  unsigned int boundary_loaded_size_;
608 
609  /// Maps element ids to indexes into vector element_vec_
611 
612  /**
613  * Vector of nodes of the mesh.
614  */
616 
617  /// Maps node ids to indexes into vector node_vec_
619 
620  /// Vector of MH edges, this should not be part of the geometrical mesh
622 
623  /// Vector of node permutations of optimized mesh (see class MeshOptimizer)
625 
626  /// Vector of element permutations of optimized mesh (see class MeshOptimizer)
628 
629 
630  friend class Edge;
631  friend class Side;
632  friend class RegionSetBase;
633  friend class Element;
634  friend class BIHTree;
635  friend class Boundary;
636  friend class BCMesh;
637  template <int spacedim> friend class ElementAccessor;
638  template <int spacedim> friend class NodeAccessor;
639 
640 
641 
642 private:
643 
644  /// Fill array node_4_loc_ and create object node_ds_ according to element distribution.
645  void distribute_nodes();
646 
647  /// Index set assigning to global element index the local index used in parallel vectors.
649  /// Index set assigning to local element index its global index.
651  /// Parallel distribution of elements.
653  /// Index set assigning to local node index its global index.
655  /// Parallel distribution of nodes. Depends on elements distribution.
657  /// Hold number of local nodes (own + ghost), value is equal with size of node_4_loc array.
658  unsigned int n_local_nodes_;
659  /// Boundary mesh, object is created only if it's necessary
661 
662 };
663 
664 #endif
665 //-----------------------------------------------------------------------------
666 // vim: set cindent:
Mesh::node_permutations
const std::vector< unsigned int > & node_permutations() const
Return permutation vector of nodes.
Definition: mesh.h:436
Mesh::ElementTmpData::partition_id
unsigned int partition_id
Definition: mesh.h:471
Mesh::get_el_ds
Distribution * get_el_ds() const
Definition: mesh.h:198
Mesh::y_coord
@ y_coord
Definition: mesh.h:151
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:1251
Boundary
Definition: accessors.hh:363
BidirectionalMap< int >
general_iterator.hh
Template Iter serves as general template for internal iterators.
Mesh::nodes_
Armor::Array< double > nodes_
Definition: mesh.h:615
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:1004
EquivalentMeshMap::boundary
std::vector< LongIdx > boundary
Definition: mesh.h:80
Mesh::node_4_loc_
LongIdx * node_4_loc_
Index set assigning to local node index its global index.
Definition: mesh.h:654
Mesh::in_record_
Input::Record in_record_
Definition: mesh.h:586
Mesh::ElementTmpData::elm_id
unsigned int elm_id
Definition: mesh.h:468
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:1099
Mesh::ElementTmpData::region_idx
RegionIdx region_idx
Definition: mesh.h:470
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:465
Mesh::n_exsides
int n_exsides
Definition: mesh.h:325
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:1068
EquivalentMeshMap::bulk
std::vector< LongIdx > bulk
Definition: mesh.h:79
Mesh::elements_range
virtual Range< ElementAccessor< 3 > > elements_range() const
Returns range of bulk elements.
Definition: mesh.cc:1130
Mesh::n_sides
unsigned int n_sides() const
Definition: mesh.cc:238
Mesh::element_permutations
const std::vector< unsigned int > & element_permutations() const
Return permutation vector of elements.
Definition: mesh.h:418
Mesh::check_compatible_mesh
virtual std::shared_ptr< EquivalentMeshMap > check_compatible_mesh(Mesh &input_mesh)
Definition: mesh.cc:870
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:607
Mesh::tree
DuplicateNodes * tree
Definition: mesh.h:317
Mesh::element_vec_
vector< Element > element_vec_
Definition: mesh.h:598
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:445
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:535
std::vector< LongIdx >
Mesh::n_edges
unsigned int n_edges() const
Definition: mesh.h:178
Mesh::count_side_types
void count_side_types()
Definition: mesh.cc:472
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:201
Mesh::node_range
Range< NodeAccessor< 3 > > node_range() const
Returns range of nodes.
Definition: mesh.cc:1136
Mesh::boundary
Boundary boundary(uint edge_idx) const
Definition: mesh.cc:268
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:658
Neighbour
Definition: neighbours.h:117
Mesh::read_regions_from_input
void read_regions_from_input(Input::Array region_list)
Definition: mesh.cc:979
index_types.hh
Mesh::z_coord
@ z_coord
Definition: mesh.h:151
Mesh::get_intersection_search
IntersectionSearch get_intersection_search()
Getter for input type selection for intersection search algorithm.
Definition: mesh.cc:156
storage.hh
Mesh::optimize_memory_locality
bool optimize_memory_locality
Definition: mesh.h:565
Mesh::n_vb_neighbours
unsigned int n_vb_neighbours() const
Definition: mesh.cc:247
exceptions.hh
type_record.hh
Mesh::n_elements
virtual unsigned int n_elements() const
Returns count of boundary or bulk elements.
Definition: mesh.h:398
Mesh::get_node_ds
Distribution * get_node_ds() const
Definition: mesh.h:207
Element
Definition: elements.h:40
Mesh::optimize
void optimize()
Definition: mesh.cc:435
Mesh::el_ds
Distribution * el_ds
Parallel distribution of elements.
Definition: mesh.h:652
Mesh::intersect_element_lists
void intersect_element_lists(vector< unsigned int > const &nodes_list, vector< unsigned int > &intersection_element_list)
Definition: mesh.cc:499
Mesh::n_sides_
int n_sides_
Definition: mesh.h:326
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:1156
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:472
Mesh::get_local_part
virtual const LongIdx * get_local_part()
Definition: mesh.cc:278
Distribution
Definition: distribution.hh:50
Mesh::node_ids_
BidirectionalMap< int > node_ids_
Maps node ids to indexes into vector node_vec_.
Definition: mesh.h:618
Mesh::BBsearch
@ BBsearch
Definition: mesh.h:138
Mesh::check_mesh_on_read
void check_mesh_on_read()
Definition: mesh.cc:310
Mesh::n_corners
unsigned int n_corners()
Definition: mesh.cc:252
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:531
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:1019
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:1271
Mesh::get_node_4_loc
LongIdx * get_node_4_loc() const
Definition: mesh.h:210
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:1265
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:650
Mesh::elements_id_maps
void elements_id_maps(vector< LongIdx > &bulk_elements_id, vector< LongIdx > &boundary_elements_id) const
Definition: mesh.cc:829
Mesh::ElementTmpData::dim
unsigned int dim
Definition: mesh.h:469
Mesh::side_nodes
vector< vector< vector< unsigned int > > > side_nodes
Definition: mesh.h:339
Mesh::node_permutation_
std::vector< unsigned int > node_permutation_
Vector of node permutations of optimized mesh (see class MeshOptimizer)
Definition: mesh.h:624
Mesh::canonical_faces
void canonical_faces()
Definition: mesh.cc:390
EquivalentMeshMap::empty
bool empty()
Definition: mesh.h:89
Mesh::region_db_
RegionDB region_db_
Definition: mesh.h:571
Side
Definition: accessors.hh:404
bidirectional_map.hh
Implementation of bidirectional map.
Mesh::IntersectionSearch
IntersectionSearch
Types of search algorithm for finding intersection candidates.
Definition: mesh.h:135
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:412
Mesh::region_db
const RegionDB & region_db() const
Definition: mesh.h:187
Mesh::init
void init()
Definition: mesh.cc:162
Mesh::master_elements
vector< vector< unsigned int > > master_elements
Definition: mesh.h:315
Mesh::mesh_file
FilePath mesh_file()
Return FilePath object representing "mesh_file" input key.
Definition: mesh.h:370
RegionDB
Definition: region.hh:292
Mesh::bih_tree_
std::shared_ptr< BIHTree > bih_tree_
Definition: mesh.h:580
Mesh::node_ds_
Distribution * node_ds_
Parallel distribution of nodes. Depends on elements distribution.
Definition: mesh.h:656
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:553
Mesh::element_to_neigh_vb
void element_to_neigh_vb()
Definition: mesh.cc:767
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:1148
Mesh::get_comm
MPI_Comm get_comm() const
Definition: mesh.h:219
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:1045
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:213
Mesh::n_bb_neigh
unsigned int n_bb_neigh
Definition: mesh.h:532
Mesh::create_node_element_lists
void create_node_element_lists()
Definition: mesh.cc:486
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:399
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:1122
EquivalentMeshMap::EquivalentMeshMap
EquivalentMeshMap(unsigned int bulk_size, unsigned int boundary_size, LongIdx def_val)
Definition: mesh.h:84
Mesh::modify_element_ids
void modify_element_ids(const RegionDB::MapElementIDToRegionID &map)
Definition: mesh.cc:285
Mesh
Definition: mesh.h:98
Mesh::BIHsearch
@ BIHsearch
Definition: mesh.h:136
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:406
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:621
Mesh::make_neighbours_and_edges
void make_neighbours_and_edges()
Definition: mesh.cc:570
Mesh::init_node_vector
void init_node_vector(unsigned int size)
Initialize node_vec_, set size.
Definition: mesh.cc:1113
Mesh::elem_permutation_
std::vector< unsigned int > elem_permutation_
Vector of element permutations of optimized mesh (see class MeshOptimizer)
Definition: mesh.h:627
Edge
Definition: accessors.hh:308
Input::Array
Accessor to input data conforming to declared Array.
Definition: accessors.hh:566
Mesh::Mesh
Mesh()
Definition: mesh.cc:102
Mesh::n_vb_neigh
unsigned int n_vb_neigh
Definition: mesh.h:532
Mesh::n_boundaries
unsigned int n_boundaries() const
Definition: mesh.h:174
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:424
BCMesh
Class represents boundary part of mesh.
Definition: bc_mesh.hh:35
Mesh::check_and_finish
void check_and_finish()
Definition: mesh.cc:989
Mesh::edge_range
Range< Edge > edge_range() const
Returns range of edges.
Definition: mesh.cc:1142
BoundarySegment::input_type
static Input::Type::Record input_type
Definition: mesh.h:70
NodeAccessor
Definition: mesh.h:55
EquivalentMeshMap
Definition: mesh.h:78
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:403
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:610
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:1037
Mesh::max_edge_sides
unsigned int max_edge_sides(unsigned int dim) const
Definition: mesh.h:232
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:601
Mesh::part_
std::shared_ptr< Partitioning > part_
Definition: mesh.h:575
Mesh::check_compatible_elements
unsigned int check_compatible_elements(Mesh *source_mesh, Mesh *target_mesh, const std::vector< unsigned int > &node_ids, std::vector< LongIdx > &map)
Definition: mesh.cc:935
Mesh::bulk_size_
unsigned int bulk_size_
Count of bulk elements.
Definition: mesh.h:604
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:648
Mesh::node_elements
const vector< vector< unsigned int > > & node_elements()
Definition: mesh.cc:1091
Mesh::comm_
MPI_Comm comm_
Definition: mesh.h:591
Mesh::global_snap_radius
double global_snap_radius() const
Maximal distance of observe point from Mesh relative to its size.
Definition: mesh.cc:1028
Mesh::boundary_
vector< BoundaryData > boundary_
Definition: mesh.h:301
Mesh::n_local_nodes
unsigned int n_local_nodes() const
Definition: mesh.h:213
Mesh::get_part
virtual Partitioning * get_part()
Definition: mesh.cc:274
Mesh::n_insides
int n_insides
Definition: mesh.h:324
Mesh::bc_mesh_
BCMesh * bc_mesh_
Boundary mesh, object is created only if it's necessary.
Definition: mesh.h:660
Mesh::mixed_intersections
MixedMeshIntersections & mixed_intersections()
Definition: mesh.cc:800
Mesh::BIHonly
@ BIHonly
Definition: mesh.h:137
Mesh::node
NodeAccessor< 3 > node(unsigned int idx) const
Create and return NodeAccessor to node of given idx.
Definition: mesh.cc:823
Mesh::element_accessor
virtual ElementAccessor< 3 > element_accessor(unsigned int idx) const
Create and return ElementAccessor to element of given idx.
Definition: mesh.cc:817
Mesh::n_nodes
virtual unsigned int n_nodes() const
Definition: mesh.h:170
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:430
SideIter
Definition: accessors.hh:504
Mesh::edge
Edge edge(uint edge_idx) const
Definition: mesh.cc:262
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:1032
Mesh::vb_neighbours_
vector< Neighbour > vb_neighbours_
Definition: mesh.h:322
Mesh::x_coord
@ x_coord
Definition: mesh.h:151
Mesh::ElementTmpData
Definition: mesh.h:463
DuplicateNodes
Definition: duplicate_nodes.h:96
range_wrapper.hh
Implementation of range helper class.
EquivalentMeshMap::EquivalentMeshMap
EquivalentMeshMap()
Definition: mesh.h:82
Mesh::get_el_4_loc
LongIdx * get_el_4_loc() const
Definition: mesh.h:204
Mesh::intersections
std::shared_ptr< MixedMeshIntersections > intersections
Definition: mesh.h:309