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