mesh_tools.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_MESH_TOOLS_H
21 #define LIBMESH_MESH_TOOLS_H
22 
23 // Local Includes
24 #include "libmesh/libmesh.h"
25 #include "libmesh/bounding_box.h"
26 #include "libmesh/id_types.h"
27 #include "libmesh/mesh_base.h"
28 
29 #ifdef LIBMESH_FORWARD_DECLARE_ENUMS
30 namespace libMesh
31 {
32 enum ElemType : int;
33 }
34 #else
35 #include "libmesh/enum_elem_type.h"
36 #endif
37 
38 // C++ Includes
39 #include <limits>
40 #include <set>
41 #include <unordered_set>
42 #include <unordered_map>
43 #include <vector>
44 
45 namespace libMesh
46 {
47 
48 // forward declarations
49 class Sphere;
50 class Elem;
51 
61 namespace MeshTools
62 {
63 
69 #ifdef LIBMESH_ENABLE_DEPRECATED
71 {
72 public:
73  BoundingBox (const Point & new_min,
74  const Point & new_max) :
75  libMesh::BoundingBox(new_min, new_max) {
76  libmesh_deprecated(); // Switch to libMesh::BoundingBox
77  }
78 
79  BoundingBox (const std::pair<Point, Point> & bbox) :
80  libMesh::BoundingBox(bbox) {
81  libmesh_deprecated(); // Switch to libMesh::BoundingBox
82  }
83 
85  libmesh_deprecated(); // Switch to libMesh::BoundingBox
86  }
87 };
88 #endif
89 
90 
100 
110  const processor_id_type pid);
111 
112 inline
114 { return MeshTools::weight (mesh, mesh.processor_id()); }
115 
123  std::vector<std::vector<dof_id_type>> & nodes_to_elem_map);
124 
129  std::vector<std::vector<const Elem *>> & nodes_to_elem_map);
130 
138  std::unordered_map<dof_id_type, std::vector<dof_id_type>> & nodes_to_elem_map);
139 
144  std::unordered_map<dof_id_type, std::vector<const Elem *>> & nodes_to_elem_map);
145 
146 
147 // /**
148 // * Calling this function on a 2D mesh will convert all the elements
149 // * to triangles. \p QUAD4s will be converted to \p TRI3s, \p QUAD8s
150 // * and \p QUAD9s will be converted to \p TRI6s.
151 // */
152 // void all_tri (MeshBase & mesh);
153 
154 #ifdef LIBMESH_ENABLE_DEPRECATED
155 
159 void find_boundary_nodes (const MeshBase & mesh,
160  std::vector<bool> & on_boundary);
161 #endif
162 
166 std::unordered_set<dof_id_type> find_boundary_nodes(const MeshBase & mesh);
167 
174 std::unordered_set<dof_id_type> find_block_boundary_nodes(const MeshBase & mesh);
175 
183 #ifdef LIBMESH_ENABLE_DEPRECATED
185 bounding_box (const MeshBase & mesh);
186 #endif
187 
195 
199 Sphere
200 bounding_sphere (const MeshBase & mesh);
201 
211 
222 
229 #ifdef LIBMESH_ENABLE_DEPRECATED
232  const processor_id_type pid);
233 #endif
234 
242  const processor_id_type pid);
243 
247 Sphere
249  const processor_id_type pid);
250 
257 #ifdef LIBMESH_ENABLE_DEPRECATED
260  const subdomain_id_type sid);
261 #endif
262 
263 
271  const subdomain_id_type sid);
272 
276 Sphere
278  const subdomain_id_type sid);
279 
280 
285 void elem_types (const MeshBase & mesh,
286  std::vector<ElemType> & et);
287 
294  const ElemType type);
295 
302  const ElemType type);
303 
313  const ElemType type,
314  const unsigned int level);
315 
323 unsigned int n_levels(const MeshBase & mesh);
324 
331 unsigned int n_local_levels(const MeshBase & mesh);
332 
339 unsigned int n_active_levels(const MeshBase & mesh);
340 
347 unsigned int n_active_local_levels(const MeshBase & mesh);
348 
355 unsigned int n_p_levels (const MeshBase & mesh);
356 
366 unsigned int paranoid_n_levels(const MeshBase & mesh);
367 
375  std::set<dof_id_type> & not_subactive_node_ids);
376 
383 
384 
391 
392 
396 unsigned int max_level (const MeshBase & mesh);
397 
402 void find_nodal_neighbors(const MeshBase & mesh,
403  const Node & n,
404  const std::vector<std::vector<const Elem *>> & nodes_to_elem_map,
405  std::vector<const Node *> & neighbors);
406 
411 void find_nodal_neighbors(const MeshBase & mesh,
412  const Node & n,
413  const std::unordered_map<dof_id_type, std::vector<const Elem *>> & nodes_to_elem_map,
414  std::vector<const Node *> & neighbors);
415 
423  std::map<dof_id_type, std::vector<dof_id_type>> & hanging_nodes);
424 
436 
437 
438 #ifdef DEBUG
439 
444  const Elem * bad_elem);
445 
451 
458 
464 
470 
476 
482 
489 
501 
507 
516  unsigned int sysnum = libMesh::invalid_uint);
517 
526  unsigned int sysnum);
527 
528 #ifdef LIBMESH_ENABLE_UNIQUE_ID
529 
535 #endif
536 
543 
550 
558 
564 template <typename DofObjectSubclass>
566 
573 template <typename DofObjectSubclass>
575 
580 template <typename DofObjectSubclass>
582  libmesh_assert_parallel_consistent_procids<DofObjectSubclass>(mesh);
583  libmesh_assert_topology_consistent_procids<DofObjectSubclass>(mesh);
584 }
585 
591 
597 
603 
615  bool assert_valid_remote_elems=true);
616 #endif
617 
618 // There is no reason for users to call functions in the MeshTools::Private namespace.
619 namespace Private {
635 } // end namespace Private
636 
637 } // end namespace MeshTools
638 
639 } // namespace libMesh
640 
641 
642 #endif // LIBMESH_MESH_TOOLS_H
unsigned int n_active_local_levels(const MeshBase &mesh)
Definition: mesh_tools.C:611
void libmesh_assert_valid_procids(const MeshBase &mesh)
Definition: mesh_tools.h:581
void elem_types(const MeshBase &mesh, std::vector< ElemType > &et)
Definition: mesh_tools.C:567
dof_id_type n_nodes(const MeshBase::const_node_iterator &begin, const MeshBase::const_node_iterator &end)
Definition: mesh_tools.C:710
A geometric point in (x,y,z) space associated with a DOF.
Definition: node.h:52
void libmesh_assert_valid_amr_interior_parents(const MeshBase &mesh)
Definition: mesh_tools.C:1340
const unsigned int invalid_uint
Definition: libmesh.h:245
A geometric object representing a sphere.
Definition: sphere.h:72
void libmesh_assert_valid_remote_elems(const MeshBase &mesh)
Definition: mesh_tools.C:1247
void libmesh_assert_consistent_distributed_nodes(const MeshBase &mesh)
Definition: mesh_tools.C:1701
void correct_node_proc_ids(MeshBase &)
Definition: mesh_tools.C:2259
dof_id_type n_elem(const MeshBase::const_element_iterator &begin, const MeshBase::const_element_iterator &end)
Definition: mesh_tools.C:702
libMesh::BoundingBox create_bounding_box(const MeshBase &mesh)
Definition: mesh_tools.C:386
Sphere processor_bounding_sphere(const MeshBase &mesh, const processor_id_type pid)
Definition: mesh_tools.C:502
BoundingBox(const Point &new_min, const Point &new_max)
Definition: mesh_tools.h:73
void libmesh_assert_valid_refinement_tree(const MeshBase &mesh)
Definition: mesh_tools.C:2033
std::unordered_set< dof_id_type > find_block_boundary_nodes(const MeshBase &mesh)
Definition: mesh_tools.C:351
The base class for all geometric element types.
Definition: elem.h:100
MeshBase & mesh
uint8_t processor_id_type
Definition: id_types.h:99
void find_nodal_neighbors(const MeshBase &mesh, const Node &n, const std::vector< std::vector< const Elem *>> &nodes_to_elem_map, std::vector< const Node *> &neighbors)
Definition: mesh_tools.C:740
unsigned int n_local_levels(const MeshBase &mesh)
Definition: mesh_tools.C:640
void libmesh_assert_parallel_consistent_new_node_procids(const MeshBase &mesh)
Definition: mesh_tools.C:1877
void build_nodes_to_elem_map(const MeshBase &mesh, std::vector< std::vector< dof_id_type >> &nodes_to_elem_map)
Definition: mesh_tools.C:245
IterBase * end
unsigned int max_level(const MeshBase &mesh)
dof_id_type n_elem_of_type(const MeshBase &mesh, const ElemType type)
Definition: mesh_tools.C:579
libMesh::BoundingBox create_local_bounding_box(const MeshBase &mesh)
Definition: mesh_tools.C:451
Base class for Mesh.
Definition: mesh_base.h:77
void libmesh_assert_consistent_distributed(const MeshBase &mesh)
Definition: mesh_tools.C:1671
unsigned int paranoid_n_levels(const MeshBase &mesh)
Definition: mesh_tools.C:677
void libmesh_assert_equal_n_systems(const MeshBase &mesh)
Definition: mesh_tools.C:1173
BoundingBox bounding_box(const MeshBase &mesh)
Definition: mesh_tools.C:373
void libmesh_assert_valid_node_pointers(const MeshBase &mesh)
Definition: mesh_tools.C:1223
void libmesh_assert_valid_dof_ids(const MeshBase &mesh, unsigned int sysnum)
Definition: mesh_tools.C:1571
void libmesh_assert_canonical_node_procids(const MeshBase &mesh)
Definition: mesh_tools.C:1968
void libmesh_assert_no_links_to_elem(const MeshBase &mesh, const Elem *bad_elem)
Definition: mesh_tools.C:1277
dof_id_type weight(const MeshBase &mesh, const processor_id_type pid)
Definition: mesh_tools.C:233
unsigned int n_levels(const MeshBase &mesh)
Definition: mesh_tools.C:653
void libmesh_assert_valid_boundary_ids(const MeshBase &mesh)
Definition: mesh_tools.C:1401
void libmesh_assert_valid_amr_elem_ids(const MeshBase &mesh)
Definition: mesh_tools.C:1320
Sphere subdomain_bounding_sphere(const MeshBase &mesh, const subdomain_id_type sid)
Definition: mesh_tools.C:553
void globally_renumber_nodes_and_elements(MeshBase &)
Definition: mesh_tools.C:2424
BoundingBox processor_bounding_box(const MeshBase &mesh, const processor_id_type pid)
Definition: mesh_tools.C:466
void find_hanging_nodes_and_parents(const MeshBase &mesh, std::map< dof_id_type, std::vector< dof_id_type >> &hanging_nodes)
Definition: mesh_tools.C:1083
void libmesh_assert_topology_consistent_procids(const MeshBase &mesh)
dof_id_type total_weight(const MeshBase &mesh)
Definition: mesh_tools.C:210
libMesh::BoundingBox create_subdomain_bounding_box(const MeshBase &mesh, const subdomain_id_type sid)
Definition: mesh_tools.C:529
void libmesh_assert_parallel_consistent_procids(const MeshBase &mesh)
Sphere bounding_sphere(const MeshBase &mesh)
Definition: mesh_tools.C:438
BoundingBox(const std::pair< Point, Point > &bbox)
Definition: mesh_tools.h:79
void libmesh_assert_connected_nodes(const MeshBase &mesh)
Definition: mesh_tools.C:1376
void get_not_subactive_node_ids(const MeshBase &mesh, std::set< dof_id_type > &not_subactive_node_ids)
Definition: mesh_tools.C:691
dof_id_type n_active_elem_of_type(const MeshBase &mesh, const ElemType type)
Definition: mesh_tools.C:588
void libmesh_assert_valid_neighbors(const MeshBase &mesh, bool assert_valid_remote_elems=true)
Definition: mesh_tools.C:2068
libMesh::BoundingBox create_nodal_bounding_box(const MeshBase &mesh)
Definition: mesh_tools.C:411
void libmesh_assert_valid_unique_ids(const MeshBase &mesh)
Definition: mesh_tools.C:1641
libMesh::BoundingBox create_processor_bounding_box(const MeshBase &mesh, const processor_id_type pid)
Definition: mesh_tools.C:477
unsigned int n_p_levels(const MeshBase &mesh)
Definition: mesh_tools.C:718
void libmesh_assert_old_dof_objects(const MeshBase &mesh)
Definition: mesh_tools.C:1199
A geometric point in (x,y,z) space.
Definition: point.h:38
void libmesh_assert_contiguous_dof_ids(const MeshBase &mesh, unsigned int sysnum)
Definition: mesh_tools.C:1598
dof_id_type n_non_subactive_elem_of_type_at_level(const MeshBase &mesh, const ElemType type, const unsigned int level)
Definition: mesh_tools.C:595
void find_boundary_nodes(const MeshBase &mesh, std::vector< bool > &on_boundary)
Definition: mesh_tools.C:303
BoundingBox subdomain_bounding_box(const MeshBase &mesh, const subdomain_id_type sid)
Definition: mesh_tools.C:518
uint8_t dof_id_type
Definition: id_types.h:64
unsigned int n_active_levels(const MeshBase &mesh)
Definition: mesh_tools.C:623
void libmesh_assert_valid_elem_ids(const MeshBase &mesh)
Definition: mesh_tools.C:1297
void libmesh_assert_valid_refinement_flags(const MeshBase &mesh)
Definition: mesh_tools.C:1985