libMesh
unstructured_mesh.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2026 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_UNSTRUCTURED_MESH_H
21 #define LIBMESH_UNSTRUCTURED_MESH_H
22 
23 // Local Includes
24 #include "libmesh/mesh_base.h"
25 
26 // C++ Includes
27 #include <cstddef>
28 
29 namespace libMesh
30 {
31 
48 class UnstructuredMesh : public MeshBase
49 {
50 public:
51 
57  explicit
59  unsigned char dim=1);
60 
64  UnstructuredMesh(const UnstructuredMesh &) = default;
65 
70  UnstructuredMesh(const MeshBase &);
71 
76 
80  UnstructuredMesh & operator= (const UnstructuredMesh &) = delete;
81 
86  UnstructuredMesh & operator= (UnstructuredMesh && other_mesh) = default;
87 
88  virtual MeshBase & assign(MeshBase && other_mesh) override = 0;
89 
93  virtual ~UnstructuredMesh();
94 
109  virtual void read (const std::string & name,
110  void * mesh_data=nullptr,
111  bool skip_renumber_nodes_and_elements=false,
112  bool skip_find_neighbors=false,
113  bool skip_detect_interior_parents=false) override;
118  virtual void write (const std::string & name) const override;
119 
124  void write (const std::string & name,
125  const std::vector<Number> & values,
126  const std::vector<std::string> & variable_names) const;
127 
134  virtual void all_first_order () override;
135 
147  virtual void all_second_order_range (const SimpleRange<element_iterator> & range,
148  const bool full_ordered=true) override;
149 
157  virtual void all_complete_order_range (const SimpleRange<element_iterator> & range) override;
158 
165  void create_pid_mesh (UnstructuredMesh & pid_mesh,
166  const processor_id_type pid) const;
167 
173  void create_submesh (UnstructuredMesh & new_mesh,
174  const const_element_iterator & it,
175  const const_element_iterator & it_end) const;
176 
229  std::size_t stitch_meshes (const MeshBase & other_mesh,
230  boundary_id_type this_mesh_boundary,
231  boundary_id_type other_mesh_boundary,
232  Real tol=TOLERANCE,
233  bool clear_stitched_boundary_ids=false,
234  bool verbose=true,
235  bool use_binary_search=true,
236  bool enforce_all_nodes_match_on_boundaries=false,
237  bool merge_boundary_nodes_all_or_nothing=false,
238  bool remap_subdomain_ids=false,
239  bool prepare_after_stitching=true);
240 
244  std::size_t stitch_surfaces (boundary_id_type boundary_id_1,
245  boundary_id_type boundary_id_2,
246  Real tol=TOLERANCE,
247  bool clear_stitched_boundary_ids=false,
248  bool verbose=true,
249  bool use_binary_search=true,
250  bool enforce_all_nodes_match_on_boundaries=false,
251  bool merge_boundary_nodes_all_or_nothing=false,
252  bool prepare_after_stitching=true);
253 
278  virtual void copy_nodes_and_elements (const MeshBase & other_mesh,
279  const bool skip_find_neighbors = false,
280  dof_id_type element_id_offset = 0,
281  dof_id_type node_id_offset = 0,
282  unique_id_type unique_id_offset = 0,
283  std::unordered_map<subdomain_id_type, subdomain_id_type> *
284  id_remapping = nullptr,
285  const bool skip_preparation = false);
286 
290  virtual void move_nodes_and_elements(MeshBase && other_mesh) = 0;
291 
292 
296  virtual void find_neighbors (const bool reset_remote_elements = false,
297  const bool reset_current_list = true,
298  const bool assert_valid = true) override;
299 
300 #ifdef LIBMESH_ENABLE_AMR
301 
306  virtual bool contract () override;
307 #endif // #ifdef LIBMESH_ENABLE_AMR
308 
309 private:
310 
315  std::size_t stitching_helper (const MeshBase * other_mesh,
316  boundary_id_type boundary_id_1,
317  boundary_id_type boundary_id_2,
318  Real tol,
319  bool clear_stitched_boundary_ids,
320  bool verbose,
321  bool use_binary_search,
322  bool enforce_all_nodes_match_on_boundaries,
323  bool skip_find_neighbors,
324  bool merge_boundary_nodes_all_or_nothing,
325  bool remap_subdomain_ids,
326  bool prepare_after_stitching);
327 };
328 
329 
330 } // namespace libMesh
331 
332 #endif // LIBMESH_UNSTRUCTURED_MESH_H
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
UnstructuredMesh & operator=(const UnstructuredMesh &)=delete
Copy assignment is not allowed.
The SimpleRange templated class is intended to make it easy to construct ranges from pairs of iterato...
Definition: simple_range.h:36
virtual void all_complete_order_range(const SimpleRange< element_iterator > &range) override
Converts a (conforming, non-refined) mesh with linear elements into a mesh with "complete" order elem...
The definition of the const_element_iterator struct.
Definition: mesh_base.h:2521
static constexpr Real TOLERANCE
unsigned int dim
virtual void find_neighbors(const bool reset_remote_elements=false, const bool reset_current_list=true, const bool assert_valid=true) override
Other functions from MeshBase requiring re-definition.
virtual void all_first_order() override
Converts a mesh with higher-order elements into a mesh with linear elements.
The libMesh namespace provides an interface to certain functionality in the library.
void create_pid_mesh(UnstructuredMesh &pid_mesh, const processor_id_type pid) const
Generates a new mesh containing all the elements which are assigned to processor pid.
std::size_t stitching_helper(const MeshBase *other_mesh, boundary_id_type boundary_id_1, boundary_id_type boundary_id_2, Real tol, bool clear_stitched_boundary_ids, bool verbose, bool use_binary_search, bool enforce_all_nodes_match_on_boundaries, bool skip_find_neighbors, bool merge_boundary_nodes_all_or_nothing, bool remap_subdomain_ids, bool prepare_after_stitching)
Helper function for stitch_meshes and stitch_surfaces that does the mesh stitching.
virtual void all_second_order_range(const SimpleRange< element_iterator > &range, const bool full_ordered=true) override
Converts a (conforming, non-refined) mesh with linear elements into a mesh with second-order elements...
uint8_t processor_id_type
Definition: id_types.h:104
This is the MeshBase class.
Definition: mesh_base.h:80
virtual bool contract() override
Delete subactive (i.e.
int8_t boundary_id_type
Definition: id_types.h:51
virtual void move_nodes_and_elements(MeshBase &&other_mesh)=0
Move node and elements from other_mesh to this mesh.
The UnstructuredMesh class is derived from the MeshBase class.
UnstructuredMesh(const Parallel::Communicator &comm_in, unsigned char dim=1)
Constructor.
virtual MeshBase & assign(MeshBase &&other_mesh) override=0
Shim to allow operator = (&&) to behave like a virtual function without having to be one...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual ~UnstructuredMesh()
Destructor.
virtual void copy_nodes_and_elements(const MeshBase &other_mesh, const bool skip_find_neighbors=false, dof_id_type element_id_offset=0, dof_id_type node_id_offset=0, unique_id_type unique_id_offset=0, std::unordered_map< subdomain_id_type, subdomain_id_type > *id_remapping=nullptr, const bool skip_preparation=false)
Deep copy of nodes and elements from another mesh object (used by subclass copy constructors and by m...
virtual void read(const std::string &name, void *mesh_data=nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false, bool skip_detect_interior_parents=false) override
Reads the file specified by name.
std::size_t stitch_surfaces(boundary_id_type boundary_id_1, boundary_id_type boundary_id_2, Real tol=TOLERANCE, bool clear_stitched_boundary_ids=false, bool verbose=true, bool use_binary_search=true, bool enforce_all_nodes_match_on_boundaries=false, bool merge_boundary_nodes_all_or_nothing=false, bool prepare_after_stitching=true)
Similar to stitch_meshes, except that we stitch two adjacent surfaces within this mesh...
uint8_t unique_id_type
Definition: id_types.h:86
virtual void write(const std::string &name) const override
Write the file specified by name.
std::size_t stitch_meshes(const MeshBase &other_mesh, boundary_id_type this_mesh_boundary, boundary_id_type other_mesh_boundary, Real tol=TOLERANCE, bool clear_stitched_boundary_ids=false, bool verbose=true, bool use_binary_search=true, bool enforce_all_nodes_match_on_boundaries=false, bool merge_boundary_nodes_all_or_nothing=false, bool remap_subdomain_ids=false, bool prepare_after_stitching=true)
Stitch other_mesh to this mesh so that this mesh is the union of the two meshes.
void create_submesh(UnstructuredMesh &new_mesh, const const_element_iterator &it, const const_element_iterator &it_end) const
Constructs a mesh called "new_mesh" from the current mesh by iterating over the elements between it a...
uint8_t dof_id_type
Definition: id_types.h:67