libMesh
Public Types | Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
libMesh::UnstructuredMesh Class Referenceabstract

The UnstructuredMesh class is derived from the MeshBase class. More...

#include <unstructured_mesh.h>

Inheritance diagram for libMesh::UnstructuredMesh:
[legend]

Public Types

typedef std::set< elemset_id_typeelemset_type
 Typedef for the "set" container used to store elemset ids. More...
 
typedef Predicates::multi_predicate Predicate
 We need an empty, generic class to act as a predicate for this and derived mesh classes. More...
 
typedef std::vector< std::pair< std::pair< const Elem *, unsigned int >, Real > > constraint_rows_mapped_type
 
typedef std::map< const Node *, constraint_rows_mapped_typeconstraint_rows_type
 

Public Member Functions

 UnstructuredMesh (const Parallel::Communicator &comm_in, unsigned char dim=1)
 Constructor. More...
 
 UnstructuredMesh (const UnstructuredMesh &)=default
 UnstructuredMesh uses a defaulted copy constructor. More...
 
 UnstructuredMesh (UnstructuredMesh &&)=delete
 Move-constructor deleted in MeshBase. More...
 
UnstructuredMeshoperator= (const UnstructuredMesh &)=delete
 Copy assignment is not allowed. More...
 
UnstructuredMeshoperator= (UnstructuredMesh &&other_mesh)=default
 Move assignment is allowed, by subclasses who handle post_dofobject_moves() More...
 
virtual MeshBaseassign (MeshBase &&other_mesh) override=0
 Shim to allow operator = (&&) to behave like a virtual function without having to be one. More...
 
virtual ~UnstructuredMesh ()
 Destructor. More...
 
virtual void read (const std::string &name, void *mesh_data=nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false) override
 Reads the file specified by name. More...
 
virtual void write (const std::string &name) override
 Write the file specified by name. More...
 
void write (const std::string &name, const std::vector< Number > &values, const std::vector< std::string > &variable_names)
 Write to the file specified by name. More...
 
virtual void all_first_order () override
 Converts a mesh with higher-order elements into a mesh with linear elements. More...
 
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. More...
 
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 elements, i.e. More...
 
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. More...
 
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 and it_end and adding them to the new mesh. More...
 
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)
 Stitch other_mesh to this mesh so that this mesh is the union of the two meshes. More...
 
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)
 Similar to stitch_meshes, except that we stitch two adjacent surfaces within this mesh. More...
 
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)
 Deep copy of nodes and elements from another mesh object (used by subclass copy constructors and by mesh merging operations) More...
 
virtual void move_nodes_and_elements (MeshBase &&other_mesh)=0
 Move node and elements from other_mesh to this mesh. More...
 
virtual void find_neighbors (const bool reset_remote_elements=false, const bool reset_current_list=true) override
 Other functions from MeshBase requiring re-definition. More...
 
virtual bool contract () override
 Delete subactive (i.e. More...
 
bool operator== (const MeshBase &other_mesh) const
 This tests for exactly-equal data in all the senses that a mathematician would care about (element connectivity, nodal coordinates), but in the senses a programmer would care about it allows for non-equal equivalence in some ways (we accept different Elem/Node addresses in memory) but not others (we do not accept different subclass types, nor even different Elem/Node ids). More...
 
bool operator!= (const MeshBase &other_mesh) const
 
bool locally_equals (const MeshBase &other_mesh) const
 This behaves the same as operator==, but only for the local and ghosted aspects of the mesh; i.e. More...
 
virtual std::unique_ptr< MeshBaseclone () const =0
 Virtual "copy constructor". More...
 
virtual std::unique_ptr< Partitioner > & partitioner ()
 A partitioner to use at each prepare_for_use() More...
 
const BoundaryInfoget_boundary_info () const
 The information about boundary ids on the mesh. More...
 
BoundaryInfoget_boundary_info ()
 Writable information about boundary ids on the mesh. More...
 
virtual void clear ()
 Deletes all the element and node data that is currently stored. More...
 
virtual void clear_elems ()=0
 Deletes all the element data that is currently stored. More...
 
bool is_prepared () const
 
void set_isnt_prepared ()
 Tells this we have done some operation where we should no longer consider ourself prepared. More...
 
virtual bool is_serial () const
 
virtual bool is_serial_on_zero () const
 
virtual void set_distributed ()
 Asserts that not all elements and nodes of the mesh necessarily exist on the current processor. More...
 
virtual bool is_replicated () const
 
virtual void allgather ()
 Gathers all elements and nodes of the mesh onto every processor. More...
 
virtual void gather_to_zero ()
 Gathers all elements and nodes of the mesh onto processor zero. More...
 
virtual void delete_remote_elements ()
 When supported, deletes all nonlocal elements of the mesh except for "ghosts" which touch a local element, and deletes all nodes which are not part of a local or ghost element. More...
 
void reinit_ghosting_functors ()
 Loops over ghosting functors and calls mesh_reinit() More...
 
unsigned int mesh_dimension () const
 
void set_mesh_dimension (unsigned char d)
 Resets the logical dimension of the mesh. More...
 
const std::set< unsigned char > & elem_dimensions () const
 
void set_elem_dimensions (std::set< unsigned char > elem_dims)
 Most of the time you should not need to call this, as the element dimensions will be set automatically by a call to cache_elem_data(), therefore only call this if you know what you're doing. More...
 
void add_elemset_code (dof_id_type code, MeshBase::elemset_type id_set)
 Tabulate a user-defined "code" for elements which belong to the element sets specified in id_set. More...
 
unsigned int n_elemsets () const
 Returns the number of unique elemset ids which have been added via add_elemset_code(), which is the size of the _all_elemset_ids set. More...
 
void get_elemsets (dof_id_type elemset_code, MeshBase::elemset_type &id_set_to_fill) const
 Look up the element sets for a given elemset code and vice-versa. More...
 
dof_id_type get_elemset_code (const MeshBase::elemset_type &id_set) const
 
std::vector< dof_id_typeget_elemset_codes () const
 Return a vector of all elemset codes defined on the mesh. More...
 
void change_elemset_code (dof_id_type old_code, dof_id_type new_code)
 Replace elemset code "old_code" with "new_code". More...
 
void change_elemset_id (elemset_id_type old_id, elemset_id_type new_id)
 Replace elemset id "old_id" with "new_id". More...
 
unsigned int spatial_dimension () const
 
void set_spatial_dimension (unsigned char d)
 Sets the "spatial dimension" of the Mesh. More...
 
virtual dof_id_type n_nodes () const =0
 
virtual dof_id_type parallel_n_nodes () const =0
 
dof_id_type n_nodes_on_proc (const processor_id_type proc) const
 
dof_id_type n_local_nodes () const
 
dof_id_type n_unpartitioned_nodes () const
 
virtual dof_id_type max_node_id () const =0
 
unique_id_type next_unique_id ()
 
virtual void set_next_unique_id (unique_id_type id)=0
 Sets the next available unique id to be used. More...
 
virtual void reserve_nodes (const dof_id_type nn)=0
 Reserves space for a known number of nodes. More...
 
virtual dof_id_type n_elem () const =0
 
virtual dof_id_type parallel_n_elem () const =0
 
virtual dof_id_type max_elem_id () const =0
 
virtual unique_id_type parallel_max_unique_id () const =0
 
virtual void reserve_elem (const dof_id_type ne)=0
 Reserves space for a known number of elements. More...
 
virtual void update_parallel_id_counts ()=0
 Updates parallel caches so that methods like n_elem() accurately reflect changes on other processors. More...
 
virtual dof_id_type n_active_elem () const =0
 
dof_id_type n_elem_on_proc (const processor_id_type proc) const
 
dof_id_type n_local_elem () const
 
dof_id_type n_unpartitioned_elem () const
 
dof_id_type n_active_elem_on_proc (const processor_id_type proc) const
 
dof_id_type n_active_local_elem () const
 
dof_id_type n_sub_elem () const
 
dof_id_type n_active_sub_elem () const
 Same as n_sub_elem(), but only counts active elements. More...
 
virtual const Pointpoint (const dof_id_type i) const =0
 
virtual const Nodenode_ref (const dof_id_type i) const
 
virtual Nodenode_ref (const dof_id_type i)
 
virtual const Nodenode_ptr (const dof_id_type i) const =0
 
virtual Nodenode_ptr (const dof_id_type i)=0
 
virtual const Nodequery_node_ptr (const dof_id_type i) const =0
 
virtual Nodequery_node_ptr (const dof_id_type i)=0
 
virtual const Elemelem_ref (const dof_id_type i) const
 
virtual Elemelem_ref (const dof_id_type i)
 
virtual const Elemelem_ptr (const dof_id_type i) const =0
 
virtual Elemelem_ptr (const dof_id_type i)=0
 
virtual const Elemquery_elem_ptr (const dof_id_type i) const =0
 
virtual Elemquery_elem_ptr (const dof_id_type i)=0
 
virtual Nodeadd_point (const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
 Add a new Node at Point p to the end of the vertex array, with processor_id procid. More...
 
virtual Nodeadd_node (Node *n)=0
 Add Node n to the end of the vertex array. More...
 
virtual Nodeadd_node (std::unique_ptr< Node > n)=0
 Version of add_node() taking a std::unique_ptr by value. More...
 
virtual Nodeinsert_node (Node *n)=0
 This method is deprecated. More...
 
virtual Nodeinsert_node (std::unique_ptr< Node > n)=0
 This method is deprecated. More...
 
virtual void delete_node (Node *n)=0
 Removes the Node n from the mesh. More...
 
virtual void own_node (Node &)
 Takes ownership of node n on this partition of a distributed mesh, by setting n.processor_id() to this->processor_id(), as well as changing n.id() and moving it in the mesh's internal container to give it a new authoritative id. More...
 
virtual void renumber_node (dof_id_type old_id, dof_id_type new_id)=0
 Changes the id of node old_id, both by changing node(old_id)->id() and by moving node(old_id) in the mesh's internal container. More...
 
virtual Elemadd_elem (Elem *e)=0
 Add elem e to the end of the element array. More...
 
virtual Elemadd_elem (std::unique_ptr< Elem > e)=0
 Version of add_elem() taking a std::unique_ptr by value. More...
 
virtual Eleminsert_elem (Elem *e)=0
 Insert elem e to the element array, preserving its id and replacing/deleting any existing element with the same id. More...
 
virtual Eleminsert_elem (std::unique_ptr< Elem > e)=0
 Version of insert_elem() taking a std::unique_ptr by value. More...
 
virtual void delete_elem (Elem *e)=0
 Removes element e from the mesh. More...
 
virtual void renumber_elem (dof_id_type old_id, dof_id_type new_id)=0
 Changes the id of element old_id, both by changing elem(old_id)->id() and by moving elem(old_id) in the mesh's internal container. More...
 
ElemMappingType default_mapping_type () const
 Returns the default master space to physical space mapping basis functions to be used on newly added elements. More...
 
void set_default_mapping_type (const ElemMappingType type)
 Set the default master space to physical space mapping basis functions to be used on newly added elements. More...
 
unsigned char default_mapping_data () const
 Returns any default data value used by the master space to physical space mapping. More...
 
void set_default_mapping_data (const unsigned char data)
 Set the default master space to physical space mapping basis functions to be used on newly added elements. More...
 
void remove_orphaned_nodes ()
 Removes any orphaned nodes, nodes not connected to any elements. More...
 
virtual void renumber_nodes_and_elements ()=0
 After partitioning a mesh it is useful to renumber the nodes and elements so that they lie in contiguous blocks on the processors. More...
 
virtual void fix_broken_node_and_element_numbering ()=0
 There is no reason for a user to ever call this function. More...
 
unsigned int add_elem_integer (std::string name, bool allocate_data=true, dof_id_type default_value=DofObject::invalid_id)
 Register an integer datum (of type dof_id_type) to be added to each element in the mesh. More...
 
std::vector< unsigned intadd_elem_integers (const std::vector< std::string > &names, bool allocate_data=true, const std::vector< dof_id_type > *default_values=nullptr)
 Register integer data (of type dof_id_type) to be added to each element in the mesh, one string name for each new integer. More...
 
unsigned int get_elem_integer_index (std::string_view name) const
 
bool has_elem_integer (std::string_view name) const
 
const std::string & get_elem_integer_name (unsigned int i) const
 
unsigned int n_elem_integers () const
 
template<typename T >
unsigned int add_elem_datum (const std::string &name, bool allocate_data=true, const T *default_value=nullptr)
 Register a datum (of type T) to be added to each element in the mesh. More...
 
template<typename T >
std::vector< unsigned intadd_elem_data (const std::vector< std::string > &names, bool allocate_data=true, const std::vector< T > *default_values=nullptr)
 Register data (of type T) to be added to each element in the mesh. More...
 
unsigned int add_node_integer (std::string name, bool allocate_data=true, dof_id_type default_value=DofObject::invalid_id)
 Register an integer datum (of type dof_id_type) to be added to each node in the mesh. More...
 
std::vector< unsigned intadd_node_integers (const std::vector< std::string > &names, bool allocate_data=true, const std::vector< dof_id_type > *default_values=nullptr)
 Register integer data (of type dof_id_type) to be added to each node in the mesh. More...
 
unsigned int get_node_integer_index (std::string_view name) const
 
bool has_node_integer (std::string_view name) const
 
const std::string & get_node_integer_name (unsigned int i) const
 
unsigned int n_node_integers () const
 
template<typename T >
unsigned int add_node_datum (const std::string &name, bool allocate_data=true, const T *default_value=nullptr)
 Register a datum (of type T) to be added to each node in the mesh. More...
 
template<typename T >
std::vector< unsigned intadd_node_data (const std::vector< std::string > &name, bool allocate_data=true, const std::vector< T > *default_values=nullptr)
 Register data (of type T) to be added to each node in the mesh. More...
 
void prepare_for_use (const bool skip_renumber_nodes_and_elements, const bool skip_find_neighbors)
 Prepare a newly ecreated (or read) mesh for use. More...
 
void prepare_for_use (const bool skip_renumber_nodes_and_elements)
 
void prepare_for_use ()
 
virtual void partition (const unsigned int n_parts)
 Call the default partitioner (currently metis_partition()). More...
 
void partition ()
 
virtual void redistribute ()
 Redistribute elements between processors. More...
 
virtual void update_post_partitioning ()
 Recalculate any cached data after elements and nodes have been repartitioned. More...
 
void allow_renumbering (bool allow)
 If false is passed in then this mesh will no longer be renumbered when being prepared for use. More...
 
bool allow_renumbering () const
 
void allow_find_neighbors (bool allow)
 If false is passed then this mesh will no longer work to find element neighbors when being prepared for use. More...
 
bool allow_find_neighbors () const
 
void allow_remote_element_removal (bool allow)
 If false is passed in then this mesh will no longer have remote elements deleted when being prepared for use; i.e. More...
 
bool allow_remote_element_removal () const
 
void skip_noncritical_partitioning (bool skip)
 If true is passed in then the elements on this mesh will no longer be (re)partitioned, and the nodes on this mesh will only be repartitioned if they are found "orphaned" via coarsening or other removal of the last element responsible for their node/element processor id consistency. More...
 
bool skip_noncritical_partitioning () const
 
void skip_partitioning (bool skip)
 If true is passed in then nothing on this mesh will be (re)partitioned. More...
 
bool skip_partitioning () const
 
void add_ghosting_functor (GhostingFunctor &ghosting_functor)
 Adds a functor which can specify ghosting requirements for use on distributed meshes. More...
 
void add_ghosting_functor (std::shared_ptr< GhostingFunctor > ghosting_functor)
 Adds a functor which can specify ghosting requirements for use on distributed meshes. More...
 
void remove_ghosting_functor (GhostingFunctor &ghosting_functor)
 Removes a functor which was previously added to the set of ghosting functors. More...
 
std::set< GhostingFunctor * >::const_iterator ghosting_functors_begin () const
 Beginning of range of ghosting functors. More...
 
std::set< GhostingFunctor * >::const_iterator ghosting_functors_end () const
 End of range of ghosting functors. More...
 
GhostingFunctordefault_ghosting ()
 Default ghosting functor. More...
 
void subdomain_ids (std::set< subdomain_id_type > &ids, const bool global=true) const
 Constructs a list of all subdomain identifiers in the local mesh if global == false, and in the global mesh if global == true (default). More...
 
subdomain_id_type n_subdomains () const
 
subdomain_id_type n_local_subdomains () const
 
unsigned int n_partitions () const
 
std::string get_info (const unsigned int verbosity=0, const bool global=true) const
 
void print_info (std::ostream &os=libMesh::out, const unsigned int verbosity=0, const bool global=true) const
 Prints relevant information about the mesh. More...
 
void all_second_order (const bool full_ordered=true)
 Calls the range-based version of this function with a range consisting of all elements in the mesh. More...
 
virtual void all_complete_order ()
 Calls the range-based version of this function with a range consisting of all elements in the mesh. More...
 
unsigned int recalculate_n_partitions ()
 In a few (very rare) cases, the user may have manually tagged the elements with specific processor IDs by hand, without using a partitioner. More...
 
std::unique_ptr< PointLocatorBasesub_point_locator () const
 
void set_point_locator_close_to_point_tol (Real val)
 Set value used by PointLocatorBase::close_to_point_tol(). More...
 
Real get_point_locator_close_to_point_tol () const
 
void clear_point_locator ()
 Releases the current PointLocator object. More...
 
void set_count_lower_dim_elems_in_point_locator (bool count_lower_dim_elems)
 In the point locator, do we count lower dimensional elements when we refine point locator regions? This is relevant in tree-based point locators, for example. More...
 
bool get_count_lower_dim_elems_in_point_locator () const
 Get the current value of _count_lower_dim_elems_in_point_locator. More...
 
virtual void libmesh_assert_valid_parallel_ids () const
 Verify id and processor_id consistency of our elements and nodes containers. More...
 
std::string & subdomain_name (subdomain_id_type id)
 
const std::string & subdomain_name (subdomain_id_type id) const
 
subdomain_id_type get_id_by_name (std::string_view name) const
 
 ABSTRACT_ELEM_ITERATORS (,) ABSTRACT_ELEM_ITERATORS(active_
 
 ABSTRACT_ELEM_ITERATORS (ancestor_,) ABSTRACT_ELEM_ITERATORS(subactive_
 
 ABSTRACT_ELEM_ITERATORS (local_,) ABSTRACT_ELEM_ITERATORS(unpartitioned_
 
 ABSTRACT_ELEM_ITERATORS (facelocal_,) ABSTRACT_ELEM_ITERATORS(level_
 
unsigned int level ABSTRACT_ELEM_ITERATORS (pid_, processor_id_type pid) ABSTRACT_ELEM_ITERATORS(type_
 
unsigned int level ElemType type ABSTRACT_ELEM_ITERATORS (active_subdomain_, subdomain_id_type sid) ABSTRACT_ELEM_ITERATORS(active_subdomain_set_
 
unsigned int level ElemType type std::set< subdomain_id_type > ss ABSTRACT_ELEM_ITERATORS (not_active_,) ABSTRACT_ELEM_ITERATORS(not_ancestor_
 
unsigned int level ElemType type std::set< subdomain_id_type > ss ABSTRACT_ELEM_ITERATORS (not_subactive_,) ABSTRACT_ELEM_ITERATORS(not_local_
 
unsigned int level ElemType type std::set< subdomain_id_type > ss ABSTRACT_ELEM_ITERATORS (not_level_, unsigned int level) ABSTRACT_ELEM_ITERATORS(active_local_
 
unsigned int level ElemType type std::set< subdomain_id_type > ss ABSTRACT_ELEM_ITERATORS (active_not_local_,) ABSTRACT_ELEM_ITERATORS(active_unpartitioned_
 
unsigned int level ElemType type std::set< subdomain_id_type > ss ABSTRACT_ELEM_ITERATORS (active_type_, ElemType type) ABSTRACT_ELEM_ITERATORS(active_pid_
 
unsigned int level ElemType type std::set< subdomain_id_type > ss processor_id_type pid ABSTRACT_ELEM_ITERATORS (local_level_, unsigned int level) ABSTRACT_ELEM_ITERATORS(local_not_level_
 
unsigned int level ElemType type std::set< subdomain_id_type > ss processor_id_type pid unsigned int level ABSTRACT_ELEM_ITERATORS (active_local_subdomain_, subdomain_id_type sid) ABSTRACT_ELEM_ITERATORS(active_local_subdomain_set_
 
 ABSTRACT_ELEM_ITERATORS (semilocal_,) ABSTRACT_ELEM_ITERATORS(ghost_
 
 ABSTRACT_ELEM_ITERATORS (active_semilocal_,) ABSTRACT_ELEM_ITERATORS(evaluable_
 
unsigned int level ElemType type std::set< subdomain_id_type > ss processor_id_type pid unsigned int level std::set< subdomain_id_type > virtual ss SimpleRange< element_iteratoractive_subdomain_elements_ptr_range (subdomain_id_type sid)=0
 
virtual SimpleRange< const_element_iteratoractive_subdomain_elements_ptr_range (subdomain_id_type sid) const =0
 
virtual SimpleRange< element_iteratoractive_local_subdomain_elements_ptr_range (subdomain_id_type sid)=0
 
virtual SimpleRange< const_element_iteratoractive_local_subdomain_elements_ptr_range (subdomain_id_type sid) const =0
 
virtual SimpleRange< element_iteratoractive_subdomain_set_elements_ptr_range (std::set< subdomain_id_type > ss)=0
 
virtual SimpleRange< const_element_iteratoractive_subdomain_set_elements_ptr_range (std::set< subdomain_id_type > ss) const =0
 
const DofMap &dof_map LIBMESH_COMMA unsigned int std::string & set_subdomain_name_map ()
 
const std::map< subdomain_id_type, std::string > & get_subdomain_name_map () const
 
void copy_constraint_rows (const MeshBase &other_mesh)
 Copy the constraints from the other mesh to this mesh. More...
 
template<typename T >
void copy_constraint_rows (const SparseMatrix< T > &constraint_operator)
 Copy the constraints from the given matrix to this mesh. More...
 
constraint_rows_typeget_constraint_rows ()
 
const constraint_rows_typeget_constraint_rows () const
 
void cache_elem_dims ()
 
void cache_elem_data ()
 
void detect_interior_parents ()
 Search the mesh for elements that have a neighboring element of dim+1 and set that element as the interior parent. More...
 
const std::set< subdomain_id_type > & get_mesh_subdomains () const
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Public Attributes

const DofMap &dof_map LIBMESH_COMMA unsigned int var_num
 

Protected Types

typedef variant_filter_iterator< MeshBase::Predicate, Elem * > elem_filter_iter
 The original iterator classes weren't properly const-safe; relying on their const-incorrectness is now deprecated. More...
 
typedef variant_filter_iterator< MeshBase::Predicate, Elem *const, Elem *const &, Elem *const *, const Elem *const, const Elem *const &, const Elem *const * > elem_filter_iter
 
typedef variant_filter_iterator< MeshBase::Predicate, Elem *const, Elem *const &, Elem *const * > const_elem_filter_iter
 
typedef variant_filter_iterator< MeshBase::Predicate, const Elem *const, const Elem *const &, const Elem *const * > const_elem_filter_iter
 
typedef variant_filter_iterator< MeshBase::Predicate, Node * > node_filter_iter
 
typedef variant_filter_iterator< MeshBase::Predicate, Node *const, Node *const &, Node *const *, const Node *const, const Node *const &, const Node *const * > node_filter_iter
 
typedef variant_filter_iterator< MeshBase::Predicate, Node *const, Node *const &, Node *const * > const_node_filter_iter
 
typedef variant_filter_iterator< MeshBase::Predicate, const Node *const, const Node *const &, const Node *const * > const_node_filter_iter
 

Protected Member Functions

void post_dofobject_moves (MeshBase &&other_mesh)
 Moves any superclass data (e.g. More...
 
virtual bool subclass_locally_equals (const MeshBase &other_mesh) const =0
 Shim to allow operator == (&) to behave like a virtual function without having to be one. More...
 
bool nodes_and_elements_equal (const MeshBase &other_mesh) const
 Tests for equality of all elements and nodes in the mesh. More...
 
unsigned intset_n_partitions ()
 
void size_elem_extra_integers ()
 Size extra-integer arrays of all elements in the mesh. More...
 
void size_node_extra_integers ()
 Size extra-integer arrays of all nodes in the mesh. More...
 
std::pair< std::vector< unsigned int >, std::vector< unsigned int > > merge_extra_integer_names (const MeshBase &other)
 Merge extra-integer arrays from an other mesh. More...
 

Protected Attributes

std::unique_ptr< BoundaryInfoboundary_info
 This class holds the boundary information. More...
 
unsigned int _n_parts
 The number of partitions the mesh has. More...
 
ElemMappingType _default_mapping_type
 The default mapping type (typically Lagrange) between master and physical space to assign to newly added elements. More...
 
unsigned char _default_mapping_data
 The default mapping data (unused with Lagrange, used for nodal weight lookup index with rational bases) to assign to newly added elements. More...
 
bool _is_prepared
 Flag indicating if the mesh has been prepared for use. More...
 
std::unique_ptr< PointLocatorBase_point_locator
 A PointLocator class for this mesh. More...
 
bool _count_lower_dim_elems_in_point_locator
 Do we count lower dimensional elements in point locator refinement? This is relevant in tree-based point locators, for example. More...
 
std::unique_ptr< Partitioner_partitioner
 A partitioner to use at each prepare_for_use(). More...
 
unique_id_type _next_unique_id
 The next available unique id for assigning ids to DOF objects. More...
 
bool _skip_noncritical_partitioning
 If this is true then no partitioning should be done with the possible exception of orphaned nodes. More...
 
bool _skip_all_partitioning
 If this is true then no partitioning should be done. More...
 
bool _skip_renumber_nodes_and_elements
 If this is true then renumbering will be kept to a minimum. More...
 
bool _skip_find_neighbors
 If this is true then we will skip find_neighbors in prepare_for_use. More...
 
bool _allow_remote_element_removal
 If this is false then even on DistributedMesh remote elements will not be deleted during mesh preparation. More...
 
std::map< subdomain_id_type, std::string > _block_id_to_name
 This structure maintains the mapping of named blocks for file formats that support named blocks. More...
 
std::set< unsigned char > _elem_dims
 We cache the dimension of the elements present in the mesh. More...
 
std::set< subdomain_id_type_mesh_subdomains
 We cache the subdomain ids of the elements present in the mesh. More...
 
std::map< dof_id_type, const MeshBase::elemset_type * > _elemset_codes
 Map from "element set code" to list of set ids to which that element belongs (and vice-versa). More...
 
std::map< MeshBase::elemset_type, dof_id_type_elemset_codes_inverse_map
 
MeshBase::elemset_type _all_elemset_ids
 
unsigned char _spatial_dimension
 The "spatial dimension" of the Mesh. More...
 
std::vector< std::string > _elem_integer_names
 The array of names for integer data associated with each element in the mesh. More...
 
std::vector< dof_id_type_elem_integer_default_values
 The array of default initialization values for integer data associated with each element in the mesh. More...
 
std::vector< std::string > _node_integer_names
 The array of names for integer data associated with each node in the mesh. More...
 
std::vector< dof_id_type_node_integer_default_values
 The array of default initialization values for integer data associated with each node in the mesh. More...
 
std::unique_ptr< GhostingFunctor_default_ghosting
 The default geometric GhostingFunctor, used to implement standard libMesh element ghosting behavior. More...
 
std::set< GhostingFunctor * > _ghosting_functors
 The list of all GhostingFunctor objects to be used when distributing a DistributedMesh. More...
 
std::map< GhostingFunctor *, std::shared_ptr< GhostingFunctor > > _shared_functors
 Hang on to references to any GhostingFunctor objects we were passed in shared_ptr form. More...
 
constraint_rows_type _constraint_rows
 
Real _point_locator_close_to_point_tol
 If nonzero, we will call PointLocatorBase::set_close_to_point_tol() on any PointLocators that we create. More...
 
const Parallel::Communicator_communicator
 

Private Member Functions

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)
 Helper function for stitch_meshes and stitch_surfaces that does the mesh stitching. More...
 

Detailed Description

The UnstructuredMesh class is derived from the MeshBase class.

The user will typically want to instantiate and use the Mesh class in her applications, which is currently a simple derived class of UnstructuredMesh. In order to use the adaptive mesh refinement capabilities of the library, first instantiate a MeshRefinement object with a reference to this class. Then call the appropriate refinement functions from that object. To interact with the boundary, instantiate a BoundaryMesh with a reference to this class, and then use that object's functionality.

Author
Roy Stogner
Date
2007 Base class for Replicated and Distributed meshes.

Definition at line 48 of file unstructured_mesh.h.

Member Typedef Documentation

◆ const_elem_filter_iter [1/2]

typedef variant_filter_iterator<MeshBase::Predicate, Elem * const, Elem * const &, Elem * const *> libMesh::MeshBase::const_elem_filter_iter
protectedinherited

Definition at line 2052 of file mesh_base.h.

◆ const_elem_filter_iter [2/2]

typedef variant_filter_iterator<MeshBase::Predicate, const Elem * const, const Elem * const &, const Elem * const *> libMesh::MeshBase::const_elem_filter_iter
protectedinherited

Definition at line 2072 of file mesh_base.h.

◆ const_node_filter_iter [1/2]

typedef variant_filter_iterator<MeshBase::Predicate, Node * const, Node * const &, Node * const *> libMesh::MeshBase::const_node_filter_iter
protectedinherited

Definition at line 2059 of file mesh_base.h.

◆ const_node_filter_iter [2/2]

typedef variant_filter_iterator<MeshBase::Predicate, const Node * const, const Node * const &, const Node * const *> libMesh::MeshBase::const_node_filter_iter
protectedinherited

Definition at line 2085 of file mesh_base.h.

◆ constraint_rows_mapped_type

typedef std::vector<std::pair<std::pair<const Elem *, unsigned int>, Real> > libMesh::MeshBase::constraint_rows_mapped_type
inherited

Definition at line 1674 of file mesh_base.h.

◆ constraint_rows_type

Definition at line 1675 of file mesh_base.h.

◆ elem_filter_iter [1/2]

The original iterator classes weren't properly const-safe; relying on their const-incorrectness is now deprecated.

Definition at line 2047 of file mesh_base.h.

◆ elem_filter_iter [2/2]

typedef variant_filter_iterator<MeshBase::Predicate, Elem * const, Elem * const &, Elem * const *, const Elem * const, const Elem * const &, const Elem * const *> libMesh::MeshBase::elem_filter_iter
protectedinherited

Definition at line 2067 of file mesh_base.h.

◆ elemset_type

typedef std::set<elemset_id_type> libMesh::MeshBase::elemset_type
inherited

Typedef for the "set" container used to store elemset ids.

The main requirements are that the entries be sorted and unique, so std::set works for this, but there may be more efficient alternatives.

Definition at line 297 of file mesh_base.h.

◆ node_filter_iter [1/2]

Definition at line 2054 of file mesh_base.h.

◆ node_filter_iter [2/2]

typedef variant_filter_iterator<MeshBase::Predicate, Node * const, Node * const &, Node * const *, const Node * const, const Node * const &, const Node * const *> libMesh::MeshBase::node_filter_iter
protectedinherited

Definition at line 2080 of file mesh_base.h.

◆ Predicate

We need an empty, generic class to act as a predicate for this and derived mesh classes.

Definition at line 1380 of file mesh_base.h.

Constructor & Destructor Documentation

◆ UnstructuredMesh() [1/3]

libMesh::UnstructuredMesh::UnstructuredMesh ( const Parallel::Communicator comm_in,
unsigned char  dim = 1 
)
explicit

Constructor.

Takes dim, the dimension of the mesh. The mesh dimension can be changed (and may automatically be changed by mesh generation/loading) later.

Definition at line 636 of file unstructured_mesh.C.

References libMesh::initialized(), and libMesh::libmesh_assert().

637  :
638  MeshBase (comm_in,d)
639 {
641 }
libmesh_assert(ctx)
MeshBase(const Parallel::Communicator &comm_in, unsigned char dim=1)
Constructor.
Definition: mesh_base.C:58
bool initialized()
Checks that library initialization has been done.
Definition: libmesh.C:266

◆ UnstructuredMesh() [2/3]

libMesh::UnstructuredMesh::UnstructuredMesh ( const UnstructuredMesh )
default

UnstructuredMesh uses a defaulted copy constructor.

◆ UnstructuredMesh() [3/3]

libMesh::UnstructuredMesh::UnstructuredMesh ( UnstructuredMesh &&  )
delete

Move-constructor deleted in MeshBase.

◆ ~UnstructuredMesh()

libMesh::UnstructuredMesh::~UnstructuredMesh ( )
virtual

Destructor.

Definition at line 853 of file unstructured_mesh.C.

References libMesh::closed().

854 {
855  // this->clear (); // Nothing to clear at this level
856 
857  libmesh_exceptionless_assert (!libMesh::closed());
858 }
bool closed()
Checks that the library has been closed.
Definition: libmesh.C:273

Member Function Documentation

◆ ABSTRACT_ELEM_ITERATORS() [1/15]

libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( )
inherited

◆ ABSTRACT_ELEM_ITERATORS() [2/15]

libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( ancestor_  )
inherited

◆ ABSTRACT_ELEM_ITERATORS() [3/15]

libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( local_  )
inherited

◆ ABSTRACT_ELEM_ITERATORS() [4/15]

libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( facelocal_  )
inherited

◆ ABSTRACT_ELEM_ITERATORS() [5/15]

unsigned int level libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( pid_  ,
processor_id_type  pid 
)
inherited

◆ ABSTRACT_ELEM_ITERATORS() [6/15]

unsigned int level ElemType type libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( active_subdomain_  ,
subdomain_id_type  sid 
)
inherited

◆ ABSTRACT_ELEM_ITERATORS() [7/15]

unsigned int level ElemType type std::set<subdomain_id_type> ss libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( not_active_  )
inherited

◆ ABSTRACT_ELEM_ITERATORS() [8/15]

unsigned int level ElemType type std::set<subdomain_id_type> ss libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( not_subactive_  )
inherited

◆ ABSTRACT_ELEM_ITERATORS() [9/15]

unsigned int level ElemType type std::set<subdomain_id_type> ss libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( not_level_  ,
unsigned int  level 
)
inherited

◆ ABSTRACT_ELEM_ITERATORS() [10/15]

unsigned int level ElemType type std::set<subdomain_id_type> ss libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( active_not_local_  )
inherited

◆ ABSTRACT_ELEM_ITERATORS() [11/15]

unsigned int level ElemType type std::set<subdomain_id_type> ss libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( active_type_  ,
ElemType  type 
)
inherited

◆ ABSTRACT_ELEM_ITERATORS() [12/15]

unsigned int level ElemType type std::set<subdomain_id_type> ss processor_id_type pid libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( local_level_  ,
unsigned int  level 
)
inherited

◆ ABSTRACT_ELEM_ITERATORS() [13/15]

unsigned int level ElemType type std::set<subdomain_id_type> ss processor_id_type pid unsigned int level libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( active_local_subdomain_  ,
subdomain_id_type  sid 
)
inherited

◆ ABSTRACT_ELEM_ITERATORS() [14/15]

libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( semilocal_  )
inherited

◆ ABSTRACT_ELEM_ITERATORS() [15/15]

libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( active_semilocal_  )
inherited

◆ active_local_subdomain_elements_ptr_range() [1/2]

virtual SimpleRange<element_iterator> libMesh::MeshBase::active_local_subdomain_elements_ptr_range ( subdomain_id_type  sid)
pure virtualinherited

◆ active_local_subdomain_elements_ptr_range() [2/2]

virtual SimpleRange<const_element_iterator> libMesh::MeshBase::active_local_subdomain_elements_ptr_range ( subdomain_id_type  sid) const
pure virtualinherited

◆ active_subdomain_elements_ptr_range() [1/2]

unsigned int level ElemType type std::set<subdomain_id_type> ss processor_id_type pid unsigned int level std::set<subdomain_id_type> virtual ss SimpleRange<element_iterator> libMesh::MeshBase::active_subdomain_elements_ptr_range ( subdomain_id_type  sid)
pure virtualinherited

◆ active_subdomain_elements_ptr_range() [2/2]

virtual SimpleRange<const_element_iterator> libMesh::MeshBase::active_subdomain_elements_ptr_range ( subdomain_id_type  sid) const
pure virtualinherited

◆ active_subdomain_set_elements_ptr_range() [1/2]

virtual SimpleRange<element_iterator> libMesh::MeshBase::active_subdomain_set_elements_ptr_range ( std::set< subdomain_id_type ss)
pure virtualinherited

◆ active_subdomain_set_elements_ptr_range() [2/2]

virtual SimpleRange<const_element_iterator> libMesh::MeshBase::active_subdomain_set_elements_ptr_range ( std::set< subdomain_id_type ss) const
pure virtualinherited

◆ add_elem() [1/2]

virtual Elem* libMesh::MeshBase::add_elem ( Elem e)
pure virtualinherited

Add elem e to the end of the element array.

To add an element locally, set e->processor_id() before adding it. To ensure a specific element id, call e->set_id() before adding it; only do this in parallel if you are manually keeping ids consistent.

Users should call MeshBase::prepare_for_use() after elements are added to and/or deleted from the mesh.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

Referenced by libMesh::GMVIO::_read_one_cell(), libMesh::MeshTools::Subdivision::add_boundary_ghosts(), LinearElasticityWithContact::add_contact_edge_elements(), add_cube_convex_hull_to_mesh(), libMesh::MeshRefinement::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::MeshTools::Modification::all_tri(), AllSecondOrderTest::allCompleteOrderMixed(), AllSecondOrderTest::allCompleteOrderRange(), AllSecondOrderTest::allSecondOrderMixed(), AllSecondOrderTest::allSecondOrderRange(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::MeshBase::copy_constraint_rows(), copy_nodes_and_elements(), libMesh::TriangleWrapper::copy_tri_to_mesh(), create_submesh(), libMesh::TetGenIO::element_in(), libMesh::UNVIO::elements_in(), libMesh::MeshTools::Modification::flatten(), libMesh::Poly2TriTriangulator::insert_refinement_points(), libMesh::mesh_inserter_iterator< T >::operator=(), libMesh::TetGenMeshInterface::pointset_convexhull(), libMesh::Nemesis_IO::read(), libMesh::ExodusII_IO::read(), libMesh::VTKIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::AbaqusIO::read_elements(), libMesh::UCDIO::read_implementation(), libMesh::GmshIO::read_mesh(), libMesh::DynaIO::read_mesh(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::OFFIO::read_stream(), libMesh::MatlabIO::read_stream(), SystemsTest::testDofCouplingWithVarGroups(), MeshTriangulationTest::testEdgesMesh(), MeshTriangulationTest::testHalfDomain(), NodalNeighborsTest::testOrientation(), MeshTriangulationTest::testPoly2TriBad1DMultiBoundary(), MeshTriangulationTest::testPoly2TriBad2DMultiBoundary(), MeshTriangulationTest::testPoly2TriBadEdges(), EquationSystemsTest::testPostInitAddElem(), SystemsTest::testProjectMatrix3D(), InfFERadialTest::testRefinement(), EquationSystemsTest::testReinitWithNodeElem(), BoundaryInfoTest::testShellFaceConstraints(), MeshSubdomainIDTest::testUnpartitioned(), libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole(), libMesh::Poly2TriTriangulator::triangulate_current_points(), and libMesh::TetGenMeshInterface::triangulate_pointset().

◆ add_elem() [2/2]

virtual Elem* libMesh::MeshBase::add_elem ( std::unique_ptr< Elem e)
pure virtualinherited

Version of add_elem() taking a std::unique_ptr by value.

The version taking a dumb pointer will eventually be deprecated in favor of this version. This API is intended to indicate that ownership of the Elem is transferred to the Mesh when this function is called, and it should play more nicely with the Elem::build() API which has always returned a std::unique_ptr.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

◆ add_elem_data()

template<typename T >
std::vector< unsigned int > libMesh::MeshBase::add_elem_data ( const std::vector< std::string > &  names,
bool  allocate_data = true,
const std::vector< T > *  default_values = nullptr 
)
inlineinherited

Register data (of type T) to be added to each element in the mesh.

If the mesh already has elements, data is allocated in each.

Newly allocated values for the new datum with name names[i] will be initialized to default_values[i], or to meaningless memcpy output if default_values is null.

Returns
The starting index number for the new data, or for the existing data if one by the same name has already been added.

If type T is larger than dof_id_type, each datum will end up spanning multiple index values, but will be queried with the starting index number.

No type checking is done with this function! If you add data of type T, don't try to access it with a call specifying type U.

Definition at line 2221 of file mesh_base.h.

References libMesh::MeshBase::_elem_integer_names, libMesh::index_range(), libMesh::libmesh_assert(), and libMesh::MeshBase::size_elem_extra_integers().

2224 {
2225  libmesh_assert(!default_values || default_values->size() == names.size());
2226 
2227  std::vector<unsigned int> returnval(names.size());
2228 
2229  const std::size_t old_size = _elem_integer_names.size();
2230 
2231  for (auto i : index_range(names))
2232  returnval[i] =
2233  this->add_elem_datum<T>(names[i], false,
2234  default_values ?
2235  (*default_values)[i] : nullptr);
2236 
2237  if (allocate_data && old_size != _elem_integer_names.size())
2238  this->size_elem_extra_integers();
2239 
2240  return returnval;
2241 }
std::vector< std::string > _elem_integer_names
The array of names for integer data associated with each element in the mesh.
Definition: mesh_base.h:1938
libmesh_assert(ctx)
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:111
void size_elem_extra_integers()
Size extra-integer arrays of all elements in the mesh.
Definition: mesh_base.C:1843

◆ add_elem_datum()

template<typename T >
unsigned int libMesh::MeshBase::add_elem_datum ( const std::string &  name,
bool  allocate_data = true,
const T *  default_value = nullptr 
)
inlineinherited

Register a datum (of type T) to be added to each element in the mesh.

If the mesh already has elements, data by default is allocated in each of them. This may be expensive to do repeatedly; use add_elem_data instead. Alternatively, the allocate_data option can be manually set to false, but if this is done then a manual call to size_elem_extra_integers() will need to be done before the new space is usable.

Newly allocated values for the new datum will be initialized to *default_value if default_value is not null, or to meaningless memcpy output otherwise.

Returns
The index numbers for the new data, and/or for existing data if data by some of the same names has already been added.

If type T is larger than dof_id_type, its data will end up spanning multiple index values, but will be queried with the starting index number.

No type checking is done with this function! If you add data of type T, don't try to access it with a call specifying type U.

Definition at line 2197 of file mesh_base.h.

References libMesh::MeshBase::_elem_integer_names, libMesh::MeshBase::add_elem_integer(), libMesh::DofObject::invalid_id, and libMesh::MeshBase::size_elem_extra_integers().

Referenced by ExtraIntegersTest::build_mesh().

2200 {
2201  const std::size_t old_size = _elem_integer_names.size();
2202 
2203  unsigned int n_more_integers = (sizeof(T)-1)/sizeof(dof_id_type);
2204  std::vector<dof_id_type> int_data(n_more_integers+1, DofObject::invalid_id);
2205  if (default_value)
2206  std::memcpy(int_data.data(), default_value, sizeof(T));
2207 
2208  unsigned int start_idx = this->add_elem_integer(name, false, int_data[0]);
2209  for (unsigned int i=0; i != n_more_integers; ++i)
2210  this->add_elem_integer(name+"__"+std::to_string(i), false, int_data[i+1]);
2211 
2212  if (allocate_data && old_size != _elem_integer_names.size())
2213  this->size_elem_extra_integers();
2214 
2215  return start_idx;
2216 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
std::vector< std::string > _elem_integer_names
The array of names for integer data associated with each element in the mesh.
Definition: mesh_base.h:1938
unsigned int add_elem_integer(std::string name, bool allocate_data=true, dof_id_type default_value=DofObject::invalid_id)
Register an integer datum (of type dof_id_type) to be added to each element in the mesh...
Definition: mesh_base.C:512
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:477
void size_elem_extra_integers()
Size extra-integer arrays of all elements in the mesh.
Definition: mesh_base.C:1843
uint8_t dof_id_type
Definition: id_types.h:67

◆ add_elem_integer()

unsigned int libMesh::MeshBase::add_elem_integer ( std::string  name,
bool  allocate_data = true,
dof_id_type  default_value = DofObject::invalid_id 
)
inherited

Register an integer datum (of type dof_id_type) to be added to each element in the mesh.

If the mesh already has elements, data by default is allocated in each of them. This may be expensive to do repeatedly; use add_elem_integers instead. Alternatively, the allocate_data option can be manually set to false, but if this is done then a manual call to size_elem_extra_integers() will need to be done before the new space is usable.

Newly allocated values for the new datum will be initialized to default_value

Returns
The index number for the new datum, or for the existing datum if one by the same name has already been added.

Definition at line 512 of file mesh_base.C.

References libMesh::MeshBase::_elem_integer_default_values, libMesh::MeshBase::_elem_integer_names, libMesh::index_range(), libMesh::Quality::name(), and libMesh::MeshBase::size_elem_extra_integers().

Referenced by libMesh::MeshBase::add_elem_datum(), libMesh::BoundaryInfo::add_elements(), ExtraIntegersTest::build_mesh(), ExtraIntegersTest::checkpoint_helper(), libMesh::ExodusII_IO::read(), libMesh::CheckpointIO::read_header(), ExtraIntegersTest::test_helper(), MeshStitchTest::testMeshStitchElemsets(), and WriteElemsetData::testWriteImpl().

515 {
516  for (auto i : index_range(_elem_integer_names))
517  if (_elem_integer_names[i] == name)
518  {
519  libmesh_assert_less(i, _elem_integer_default_values.size());
520  _elem_integer_default_values[i] = default_value;
521  return i;
522  }
523 
524  libmesh_assert_equal_to(_elem_integer_names.size(),
526  _elem_integer_names.push_back(std::move(name));
527  _elem_integer_default_values.push_back(default_value);
528  if (allocate_data)
529  this->size_elem_extra_integers();
530  return _elem_integer_names.size()-1;
531 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
std::vector< std::string > _elem_integer_names
The array of names for integer data associated with each element in the mesh.
Definition: mesh_base.h:1938
std::vector< dof_id_type > _elem_integer_default_values
The array of default initialization values for integer data associated with each element in the mesh...
Definition: mesh_base.h:1944
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:111
void size_elem_extra_integers()
Size extra-integer arrays of all elements in the mesh.
Definition: mesh_base.C:1843

◆ add_elem_integers()

std::vector< unsigned int > libMesh::MeshBase::add_elem_integers ( const std::vector< std::string > &  names,
bool  allocate_data = true,
const std::vector< dof_id_type > *  default_values = nullptr 
)
inherited

Register integer data (of type dof_id_type) to be added to each element in the mesh, one string name for each new integer.

If the mesh already has elements, data by default is allocated in each of them.

Newly allocated values for the new datum with name names[i] will be initialized to default_values[i], or to DofObject::invalid_id if default_values is null.

Returns
The index numbers for the new data, and/or for existing data if data by some of the same names has already been added.

Definition at line 535 of file mesh_base.C.

References libMesh::MeshBase::_elem_integer_default_values, libMesh::MeshBase::_elem_integer_names, libMesh::index_range(), libMesh::DofObject::invalid_id, libMesh::libmesh_assert(), libMesh::Quality::name(), and libMesh::MeshBase::size_elem_extra_integers().

Referenced by libMesh::MeshBase::merge_extra_integer_names(), and libMesh::XdrIO::read_header().

538 {
539  libmesh_assert(!default_values || default_values->size() == names.size());
540  libmesh_assert_equal_to(_elem_integer_names.size(), _elem_integer_default_values.size());
541 
542  std::unordered_map<std::string, std::size_t> name_indices;
543  for (auto i : index_range(_elem_integer_names))
544  name_indices[_elem_integer_names[i]] = i;
545 
546  std::vector<unsigned int> returnval(names.size());
547 
548  bool added_an_integer = false;
549  for (auto i : index_range(names))
550  {
551  const std::string & name = names[i];
552  auto it = name_indices.find(name);
553  if (it != name_indices.end())
554  {
555  returnval[i] = it->second;
556  _elem_integer_default_values[it->second] =
557  default_values ? (*default_values)[i] : DofObject::invalid_id;
558  }
559  else
560  {
561  returnval[i] = _elem_integer_names.size();
562  name_indices[name] = returnval[i];
563  _elem_integer_names.push_back(name);
565  (default_values ? (*default_values)[i] : DofObject::invalid_id);
566  added_an_integer = true;
567  }
568  }
569 
570  if (allocate_data && added_an_integer)
571  this->size_elem_extra_integers();
572 
573  return returnval;
574 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
std::vector< std::string > _elem_integer_names
The array of names for integer data associated with each element in the mesh.
Definition: mesh_base.h:1938
libmesh_assert(ctx)
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:477
std::vector< dof_id_type > _elem_integer_default_values
The array of default initialization values for integer data associated with each element in the mesh...
Definition: mesh_base.h:1944
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:111
void size_elem_extra_integers()
Size extra-integer arrays of all elements in the mesh.
Definition: mesh_base.C:1843

◆ add_elemset_code()

void libMesh::MeshBase::add_elemset_code ( dof_id_type  code,
MeshBase::elemset_type  id_set 
)
inherited

Tabulate a user-defined "code" for elements which belong to the element sets specified in id_set.

For example, suppose that we have two elemsets A and B with the following Elem ids: Elemset A = {1, 3} Elemset B = {2, 3}

This implies the following mapping from elem id to elemset id: Elem 1 -> {A} Elem 2 -> {B} Elem 3 -> {A,B}

In this case, we would need to tabulate three different elemset codes, e.g.: 0 -> {A} 1 -> {B} 2 -> {A,B}

Also sets up the inverse mapping, so that if one knows all the element sets an Elem belongs to, one can look up the corresponding elemset code.

Definition at line 350 of file mesh_base.C.

References libMesh::MeshBase::_all_elemset_ids, libMesh::MeshBase::_elemset_codes, and libMesh::MeshBase::_elemset_codes_inverse_map.

Referenced by libMesh::MeshBase::change_elemset_code(), libMesh::ExodusII_IO::read(), libMesh::XdrIO::read_header(), stitching_helper(), MeshStitchTest::testMeshStitchElemsets(), and WriteElemsetData::testWriteImpl().

351 {
352  // Populate inverse map, stealing id_set's resources
353  auto [it1, inserted1] = _elemset_codes_inverse_map.emplace(std::move(id_set), code);
354 
355  // Reference to the newly inserted (or previously existing) id_set
356  const auto & inserted_id_set = it1->first;
357 
358  // Keep track of all elemset ids ever added for O(1) n_elemsets()
359  // performance. Only need to do this if we didn't know about this
360  // id_set before...
361  if (inserted1)
362  _all_elemset_ids.insert(inserted_id_set.begin(), inserted_id_set.end());
363 
364  // Take the address of the newly emplaced set to use in
365  // _elemset_codes, avoid duplicating std::set storage
366  auto [it2, inserted2] = _elemset_codes.emplace(code, &inserted_id_set);
367 
368  // Throw an error if this code already exists with a pointer to a
369  // different set of ids.
370  libmesh_error_msg_if(!inserted2 && it2->second != &inserted_id_set,
371  "The elemset code " << code << " already exists with a different id_set.");
372 }
std::map< dof_id_type, const MeshBase::elemset_type * > _elemset_codes
Map from "element set code" to list of set ids to which that element belongs (and vice-versa)...
Definition: mesh_base.h:1924
std::map< MeshBase::elemset_type, dof_id_type > _elemset_codes_inverse_map
Definition: mesh_base.h:1925
MeshBase::elemset_type _all_elemset_ids
Definition: mesh_base.h:1926

◆ add_ghosting_functor() [1/2]

void libMesh::MeshBase::add_ghosting_functor ( GhostingFunctor ghosting_functor)
inlineinherited

Adds a functor which can specify ghosting requirements for use on distributed meshes.

Multiple ghosting functors can be added; any element which is required by any functor will be ghosted.

GhostingFunctor memory must be managed by the code which calls this function; the GhostingFunctor lifetime is expected to extend until either the functor is removed or the Mesh is destructed.

Definition at line 1244 of file mesh_base.h.

References libMesh::MeshBase::_ghosting_functors.

Referenced by libMesh::DofMap::add_algebraic_ghosting_functor(), libMesh::DofMap::add_coupling_functor(), libMesh::MeshBase::add_ghosting_functor(), main(), libMesh::MeshBase::MeshBase(), and EquationSystemsTest::testDisableDefaultGhosting().

1245  { _ghosting_functors.insert(&ghosting_functor); }
std::set< GhostingFunctor * > _ghosting_functors
The list of all GhostingFunctor objects to be used when distributing a DistributedMesh.
Definition: mesh_base.h:1991

◆ add_ghosting_functor() [2/2]

void libMesh::MeshBase::add_ghosting_functor ( std::shared_ptr< GhostingFunctor ghosting_functor)
inlineinherited

Adds a functor which can specify ghosting requirements for use on distributed meshes.

Multiple ghosting functors can be added; any element which is required by any functor will be ghosted.

GhostingFunctor memory when using this method is managed by the shared_ptr mechanism.

Definition at line 1255 of file mesh_base.h.

References libMesh::MeshBase::_shared_functors, and libMesh::MeshBase::add_ghosting_functor().

1256  { _shared_functors[ghosting_functor.get()] = ghosting_functor;
1257  this->add_ghosting_functor(*ghosting_functor); }
std::map< GhostingFunctor *, std::shared_ptr< GhostingFunctor > > _shared_functors
Hang on to references to any GhostingFunctor objects we were passed in shared_ptr form...
Definition: mesh_base.h:1997
void add_ghosting_functor(GhostingFunctor &ghosting_functor)
Adds a functor which can specify ghosting requirements for use on distributed meshes.
Definition: mesh_base.h:1244

◆ add_node() [1/2]

virtual Node* libMesh::MeshBase::add_node ( Node n)
pure virtualinherited

◆ add_node() [2/2]

virtual Node* libMesh::MeshBase::add_node ( std::unique_ptr< Node n)
pure virtualinherited

Version of add_node() taking a std::unique_ptr by value.

The version taking a dumb pointer will eventually be deprecated in favor of this version. This API is intended to indicate that ownership of the Node is transferred to the Mesh when this function is called, and it should play more nicely with the Node::build() API which has always returned a std::unique_ptr.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

◆ add_node_data()

template<typename T >
std::vector< unsigned int > libMesh::MeshBase::add_node_data ( const std::vector< std::string > &  name,
bool  allocate_data = true,
const std::vector< T > *  default_values = nullptr 
)
inlineinherited

Register data (of type T) to be added to each node in the mesh.

If the mesh already has nodes, data by default is allocated in each.

Newly allocated values for the new datum with name names[i] will be initialized to default_values[i], or to meaningless memcpy output if default_values is null.

Returns
The starting index number for the new data, or for the existing data if one by the same name has already been added.

If type T is larger than dof_id_type, its data will end up spanning multiple index values, but will be queried with the starting index number.

No type checking is done with this function! If you add data of type T, don't try to access it with a call specifying type U.

Definition at line 2270 of file mesh_base.h.

References libMesh::MeshBase::_node_integer_names, libMesh::index_range(), libMesh::libmesh_assert(), and libMesh::MeshBase::size_node_extra_integers().

2273 {
2274  libmesh_assert(!default_values || default_values->size() == names.size());
2275 
2276  std::vector<unsigned int> returnval(names.size());
2277 
2278  const std::size_t old_size = _node_integer_names.size();
2279 
2280  for (auto i : index_range(names))
2281  returnval[i] =
2282  this->add_node_datum<T>(names[i], false,
2283  default_values ?
2284  (*default_values)[i] : nullptr);
2285 
2286  if (allocate_data && old_size != _node_integer_names.size())
2287  this->size_node_extra_integers();
2288 
2289  return returnval;
2290 }
std::vector< std::string > _node_integer_names
The array of names for integer data associated with each node in the mesh.
Definition: mesh_base.h:1950
libmesh_assert(ctx)
void size_node_extra_integers()
Size extra-integer arrays of all nodes in the mesh.
Definition: mesh_base.C:1852
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:111

◆ add_node_datum()

template<typename T >
unsigned int libMesh::MeshBase::add_node_datum ( const std::string &  name,
bool  allocate_data = true,
const T *  default_value = nullptr 
)
inlineinherited

Register a datum (of type T) to be added to each node in the mesh.

If the mesh already has nodes, data by default is allocated in each of them. This may be expensive to do repeatedly; use add_node_data instead. Alternatively, the allocate_data option can be manually set to false, but if this is done then a manual call to size_node_extra_integers() will need to be done before the new space is usable.

Newly allocated values for the new datum will be initialized to *default_value if default_value is not null, or to meaningless memcpy output otherwise.

Returns
The starting index number for the new datum, or for the existing datum if one by the same name has already been added.

If type T is larger than dof_id_type, its data will end up spanning multiple index values, but will be queried with the starting index number.

No type checking is done with this function! If you add data of type T, don't try to access it with a call specifying type U.

Definition at line 2246 of file mesh_base.h.

References libMesh::MeshBase::_node_integer_names, libMesh::MeshBase::add_node_integer(), libMesh::DofObject::invalid_id, and libMesh::MeshBase::size_node_extra_integers().

Referenced by ExtraIntegersTest::build_mesh(), libMesh::ExodusII_IO::read(), and libMesh::DynaIO::read_mesh().

2249 {
2250  const std::size_t old_size = _node_integer_names.size();
2251 
2252  unsigned int n_more_integers = (sizeof(T)-1)/sizeof(dof_id_type);
2253  std::vector<dof_id_type> int_data(n_more_integers+1, DofObject::invalid_id);
2254  if (default_value)
2255  std::memcpy(int_data.data(), default_value, sizeof(T));
2256 
2257  unsigned int start_idx = this->add_node_integer(name, false, int_data[0]);
2258  for (unsigned int i=0; i != n_more_integers; ++i)
2259  this->add_node_integer(name+"__"+std::to_string(i), false, int_data[i+1]);
2260 
2261  if (allocate_data && old_size != _node_integer_names.size())
2262  this->size_node_extra_integers();
2263 
2264  return start_idx;
2265 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
std::vector< std::string > _node_integer_names
The array of names for integer data associated with each node in the mesh.
Definition: mesh_base.h:1950
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:477
void size_node_extra_integers()
Size extra-integer arrays of all nodes in the mesh.
Definition: mesh_base.C:1852
unsigned int add_node_integer(std::string name, bool allocate_data=true, dof_id_type default_value=DofObject::invalid_id)
Register an integer datum (of type dof_id_type) to be added to each node in the mesh.
Definition: mesh_base.C:601
uint8_t dof_id_type
Definition: id_types.h:67

◆ add_node_integer()

unsigned int libMesh::MeshBase::add_node_integer ( std::string  name,
bool  allocate_data = true,
dof_id_type  default_value = DofObject::invalid_id 
)
inherited

Register an integer datum (of type dof_id_type) to be added to each node in the mesh.

If the mesh already has nodes, data by default is allocated in each of them. This may be expensive to do repeatedly; use add_node_integers instead. Alternatively, the allocate_data option can be manually set to false, but if this is done then a manual call to size_node_extra_integers() will need to be done before the new space is usable.

Newly allocated values for the new datum will be initialized to default_value

Returns
The index number for the new datum, or for the existing datum if one by the same name has already been added.

Definition at line 601 of file mesh_base.C.

References libMesh::MeshBase::_node_integer_default_values, libMesh::MeshBase::_node_integer_names, libMesh::index_range(), libMesh::Quality::name(), and libMesh::MeshBase::size_node_extra_integers().

Referenced by libMesh::MeshBase::add_node_datum(), ExtraIntegersTest::build_mesh(), ExtraIntegersTest::checkpoint_helper(), libMesh::CheckpointIO::read_header(), and ExtraIntegersTest::test_helper().

604 {
605  for (auto i : index_range(_node_integer_names))
606  if (_node_integer_names[i] == name)
607  {
608  libmesh_assert_less(i, _node_integer_default_values.size());
609  _node_integer_default_values[i] = default_value;
610  return i;
611  }
612 
613  libmesh_assert_equal_to(_node_integer_names.size(),
615  _node_integer_names.push_back(std::move(name));
616  _node_integer_default_values.push_back(default_value);
617  if (allocate_data)
618  this->size_node_extra_integers();
619  return _node_integer_names.size()-1;
620 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
std::vector< std::string > _node_integer_names
The array of names for integer data associated with each node in the mesh.
Definition: mesh_base.h:1950
void size_node_extra_integers()
Size extra-integer arrays of all nodes in the mesh.
Definition: mesh_base.C:1852
std::vector< dof_id_type > _node_integer_default_values
The array of default initialization values for integer data associated with each node in the mesh...
Definition: mesh_base.h:1956
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:111

◆ add_node_integers()

std::vector< unsigned int > libMesh::MeshBase::add_node_integers ( const std::vector< std::string > &  names,
bool  allocate_data = true,
const std::vector< dof_id_type > *  default_values = nullptr 
)
inherited

Register integer data (of type dof_id_type) to be added to each node in the mesh.

If the mesh already has nodes, data by default is allocated in each.

Newly allocated values for the new datum with name names[i] will be initialized to default_values[i], or to DofObject::invalid_id if default_values is null.

Returns
The index numbers for the new data, and/or for existing data if data by some of the same names has already been added.

Definition at line 624 of file mesh_base.C.

References libMesh::MeshBase::_node_integer_default_values, libMesh::MeshBase::_node_integer_names, libMesh::index_range(), libMesh::DofObject::invalid_id, libMesh::libmesh_assert(), libMesh::Quality::name(), and libMesh::MeshBase::size_node_extra_integers().

Referenced by libMesh::MeshBase::merge_extra_integer_names(), and libMesh::XdrIO::read_header().

627 {
628  libmesh_assert(!default_values || default_values->size() == names.size());
629  libmesh_assert_equal_to(_node_integer_names.size(), _node_integer_default_values.size());
630 
631  std::unordered_map<std::string, std::size_t> name_indices;
632  for (auto i : index_range(_node_integer_names))
633  name_indices[_node_integer_names[i]] = i;
634 
635  std::vector<unsigned int> returnval(names.size());
636 
637  bool added_an_integer = false;
638  for (auto i : index_range(names))
639  {
640  const std::string & name = names[i];
641  auto it = name_indices.find(name);
642  if (it != name_indices.end())
643  {
644  returnval[i] = it->second;
645  _node_integer_default_values[it->second] =
646  default_values ? (*default_values)[i] : DofObject::invalid_id;
647  }
648  else
649  {
650  returnval[i] = _node_integer_names.size();
651  name_indices[name] = returnval[i];
652  _node_integer_names.push_back(name);
654  (default_values ? (*default_values)[i] : DofObject::invalid_id);
655  added_an_integer = true;
656  }
657  }
658 
659  if (allocate_data && added_an_integer)
660  this->size_node_extra_integers();
661 
662  return returnval;
663 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
std::vector< std::string > _node_integer_names
The array of names for integer data associated with each node in the mesh.
Definition: mesh_base.h:1950
libmesh_assert(ctx)
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:477
void size_node_extra_integers()
Size extra-integer arrays of all nodes in the mesh.
Definition: mesh_base.C:1852
std::vector< dof_id_type > _node_integer_default_values
The array of default initialization values for integer data associated with each node in the mesh...
Definition: mesh_base.h:1956
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:111

◆ add_point()

virtual Node* libMesh::MeshBase::add_point ( const Point p,
const dof_id_type  id = DofObject::invalid_id,
const processor_id_type  proc_id = DofObject::invalid_processor_id 
)
pure virtualinherited

Add a new Node at Point p to the end of the vertex array, with processor_id procid.

Use DofObject::invalid_processor_id (default) to add a node to all processors, or this->processor_id() to add a node to the local processor only. If adding a node locally, passing an id other than DofObject::invalid_id will set that specific node id. Only do this in parallel if you are manually keeping ids consistent.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

Referenced by libMesh::MeshTools::Subdivision::add_boundary_ghosts(), add_cube_convex_hull_to_mesh(), libMesh::MeshRefinement::add_node(), libMesh::MeshTools::Modification::all_tri(), AllSecondOrderTest::allCompleteOrderMixed(), AllSecondOrderTest::allCompleteOrderRange(), AllSecondOrderTest::allSecondOrderMixed(), AllSecondOrderTest::allSecondOrderRange(), libMesh::MeshTools::Generation::build_delaunay_square(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::MeshBase::copy_constraint_rows(), copy_nodes_and_elements(), libMesh::TriangleWrapper::copy_tri_to_mesh(), create_submesh(), libMesh::TriangulatorInterface::insert_any_extra_boundary_points(), libMesh::Poly2TriTriangulator::insert_refinement_points(), libMesh::TetGenIO::node_in(), libMesh::UNVIO::nodes_in(), libMesh::mesh_inserter_iterator< T >::operator=(), libMesh::Nemesis_IO::read(), libMesh::ExodusII_IO::read(), libMesh::VTKIO::read(), libMesh::UCDIO::read_implementation(), libMesh::GmshIO::read_mesh(), libMesh::DynaIO::read_mesh(), libMesh::AbaqusIO::read_nodes(), libMesh::CheckpointIO::read_nodes(), libMesh::OFFIO::read_stream(), libMesh::MatlabIO::read_stream(), libMesh::BoundaryInfo::sync(), SystemsTest::testDofCouplingWithVarGroups(), MeshTriangulationTest::testEdgesMesh(), MeshTriangulationTest::testHalfDomain(), NodalNeighborsTest::testOrientation(), MeshTriangulationTest::testPoly2TriBad1DMultiBoundary(), MeshTriangulationTest::testPoly2TriBad2DMultiBoundary(), MeshTriangulationTest::testPoly2TriBadEdges(), SystemsTest::testProjectMatrix3D(), InfFERadialTest::testRefinement(), BoundaryInfoTest::testShellFaceConstraints(), MeshTriangulationTest::testTriangulator(), MeshTriangulationTest::testTriangulatorHoles(), MeshTriangulationTest::testTriangulatorMeshedHoles(), MeshTriangulationTest::testTriangulatorSegments(), MeshTriangulationTest::testTriangulatorTrapMesh(), MeshSubdomainIDTest::testUnpartitioned(), libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole(), libMesh::Poly2TriTriangulator::triangulate_current_points(), and triangulate_domain().

◆ all_complete_order()

void libMesh::MeshBase::all_complete_order ( )
virtualinherited

Calls the range-based version of this function with a range consisting of all elements in the mesh.

Definition at line 1540 of file mesh_base.C.

References libMesh::MeshBase::all_complete_order_range().

Referenced by AllSecondOrderTest::allCompleteOrder(), and main().

1541 {
1542  this->all_complete_order_range(this->element_ptr_range());
1543 }
virtual void all_complete_order_range(const SimpleRange< element_iterator > &range)=0
Converts a set of elements in this (conforming, non-refined) mesh into "complete" order elements...

◆ all_complete_order_range()

void libMesh::UnstructuredMesh::all_complete_order_range ( const SimpleRange< element_iterator > &  range)
overridevirtual

Converts a (conforming, non-refined) mesh with linear elements into a mesh with "complete" order elements, i.e.

elements which can store degrees of freedom on any vertex, edge, or face. For example, a mesh consisting of Tet4 or Tet10 will be converted to a mesh with Tet14 etc.

Implements libMesh::MeshBase.

Definition at line 1681 of file unstructured_mesh.C.

References libMesh::Elem::complete_order_equivalent_type(), libMesh::MeshBase::mesh_dimension(), libMesh::MeshBase::n_nodes(), and libMesh::MeshBase::reserve_nodes().

1682 {
1683  LOG_SCOPE("all_complete_order()", "Mesh");
1684 
1685  /*
1686  * The maximum number of new higher-order nodes we might be adding,
1687  * for use when picking unique unique_id values later. This variable
1688  * is not used unless unique ids are enabled.
1689  */
1690  unsigned int max_new_nodes_per_elem;
1691 
1692  /*
1693  * for speed-up of the \p add_point() method, we
1694  * can reserve memory. Guess the number of additional
1695  * nodes based on the element spatial dimensions and the
1696  * total number of nodes in the mesh as an upper bound.
1697  */
1698  switch (this->mesh_dimension())
1699  {
1700  case 1:
1701  /*
1702  * in 1D, there can only be order-increase from Edge2
1703  * to Edge3. Something like 1/2 of n_nodes() have
1704  * to be added
1705  */
1706  max_new_nodes_per_elem = 3 - 2;
1707  this->reserve_nodes(static_cast<unsigned int>
1708  (1.5*static_cast<double>(this->n_nodes())));
1709  break;
1710 
1711  case 2:
1712  /*
1713  * in 2D, we typically refine from Tri6 to Tri7 (1.1667 times
1714  * the nodes) but might refine from Quad4 to Quad9
1715  * (2.25 times the nodes)
1716  */
1717  max_new_nodes_per_elem = 9 - 4;
1718  this->reserve_nodes(static_cast<unsigned int>
1719  (2*static_cast<double>(this->n_nodes())));
1720  break;
1721 
1722 
1723  case 3:
1724  /*
1725  * in 3D, we typically refine from Tet10 to Tet14 (factor = 1.4)
1726  * but may go Hex8 to Hex27 (something > 3). Since in 3D there
1727  * _are_ already quite some nodes, and since we do not want to
1728  * overburden the memory by a too conservative guess, use a
1729  * moderate bound
1730  */
1731  max_new_nodes_per_elem = 27 - 8;
1732  this->reserve_nodes(static_cast<unsigned int>
1733  (2.5*static_cast<double>(this->n_nodes())));
1734  break;
1735 
1736  default:
1737  // Hm?
1738  libmesh_error_msg("Unknown mesh dimension " << this->mesh_dimension());
1739  }
1740 
1741  // All the real work is done in the helper function
1742  all_increased_order_range(*this, range, max_new_nodes_per_elem,
1743  [](ElemType t) {
1745  });
1746 }
ElemType
Defines an enum for geometric element types.
virtual void reserve_nodes(const dof_id_type nn)=0
Reserves space for a known number of nodes.
static ElemType complete_order_equivalent_type(const ElemType et)
Definition: elem.C:2937
unsigned int mesh_dimension() const
Definition: mesh_base.C:324
virtual dof_id_type n_nodes() const =0

◆ all_first_order()

void libMesh::UnstructuredMesh::all_first_order ( )
overridevirtual

Converts a mesh with higher-order elements into a mesh with linear elements.

For example, a mesh consisting of Tet10 will be converted to a mesh with Tet4 etc.

Prepare to identify (and then delete) a bunch of no-longer-used nodes.

If the second order element had any boundary conditions they should be transferred to the first-order element. The old boundary conditions will be removed from the BoundaryInfo data structure by insert_elem.

Implements libMesh::MeshBase.

Definition at line 1466 of file unstructured_mesh.C.

References libMesh::MeshBase::_is_prepared, libMesh::Elem::add_child(), libMesh::DofObject::add_extra_integers(), libMesh::Elem::build(), libMesh::Elem::child_ptr(), libMesh::BoundaryInfo::copy_boundary_ids(), libMesh::MeshBase::delete_node(), libMesh::Elem::first_order_equivalent_type(), libMesh::MeshBase::get_boundary_info(), libMesh::MeshBase::insert_elem(), libMesh::libmesh_assert(), libMesh::MeshBase::max_node_id(), libMesh::Elem::n_vertices(), libMesh::Elem::node_id(), libMesh::Elem::parent(), libMesh::MeshBase::prepare_for_use(), libMesh::DofObject::processor_id(), libMesh::BoundaryInfo::regenerate_id_sets(), libMesh::remote_elem, libMesh::MeshBase::renumber_nodes_and_elements(), libMesh::Elem::replace_child(), libMesh::DofObject::set_extra_integer(), libMesh::DofObject::set_id(), libMesh::Elem::set_mapping_data(), libMesh::Elem::set_mapping_type(), libMesh::Elem::set_neighbor(), libMesh::Elem::set_node(), libMesh::Partitioner::set_node_processor_ids(), libMesh::Elem::set_p_level(), libMesh::Elem::set_p_refinement_flag(), libMesh::Elem::set_parent(), libMesh::Elem::set_refinement_flag(), libMesh::DofObject::set_unique_id(), and libMesh::Elem::subdomain_id().

1467 {
1468  LOG_SCOPE("all_first_order()", "Mesh");
1469 
1470  /*
1471  * when the mesh is not prepared,
1472  * at least renumber the nodes and
1473  * elements, so that the node ids
1474  * are correct
1475  */
1476  if (!this->_is_prepared)
1477  this->renumber_nodes_and_elements ();
1478 
1482  std::vector<bool> node_touched_by_me(this->max_node_id(), false);
1483 
1484  // Loop over the high-ordered elements.
1485  // First make sure they _are_ indeed high-order, and then replace
1486  // them with an equivalent first-order element.
1487  for (auto & so_elem : element_ptr_range())
1488  {
1489  libmesh_assert(so_elem);
1490 
1491  /*
1492  * build the first-order equivalent, add to
1493  * the new_elements list.
1494  */
1495  auto lo_elem = Elem::build
1497  (so_elem->type()), so_elem->parent());
1498 
1499  const unsigned short n_sides = so_elem->n_sides();
1500 
1501  for (unsigned short s=0; s != n_sides; ++s)
1502  if (so_elem->neighbor_ptr(s) == remote_elem)
1503  lo_elem->set_neighbor(s, const_cast<RemoteElem *>(remote_elem));
1504 
1505 #ifdef LIBMESH_ENABLE_AMR
1506  /*
1507  * Reset the parent links of any child elements
1508  */
1509  if (so_elem->has_children())
1510  for (unsigned int c = 0, nc = so_elem->n_children(); c != nc; ++c)
1511  {
1512  Elem * child = so_elem->child_ptr(c);
1513  if (child != remote_elem)
1514  child->set_parent(lo_elem.get());
1515  lo_elem->add_child(child, c);
1516  }
1517 
1518  /*
1519  * Reset the child link of any parent element
1520  */
1521  if (so_elem->parent())
1522  {
1523  unsigned int c =
1524  so_elem->parent()->which_child_am_i(so_elem);
1525  lo_elem->parent()->replace_child(lo_elem.get(), c);
1526  }
1527 
1528  /*
1529  * Copy as much data to the new element as makes sense
1530  */
1531  lo_elem->set_p_level(so_elem->p_level());
1532  lo_elem->set_refinement_flag(so_elem->refinement_flag());
1533  lo_elem->set_p_refinement_flag(so_elem->p_refinement_flag());
1534 #endif
1535 
1536  libmesh_assert_equal_to (lo_elem->n_vertices(), so_elem->n_vertices());
1537 
1538  /*
1539  * By definition the vertices of the linear and
1540  * second order element are identically numbered.
1541  * transfer these.
1542  */
1543  for (unsigned int v=0, snv=so_elem->n_vertices(); v < snv; v++)
1544  {
1545  lo_elem->set_node(v) = so_elem->node_ptr(v);
1546  node_touched_by_me[lo_elem->node_id(v)] = true;
1547  }
1548 
1549  /*
1550  * find_neighbors relies on remote_elem neighbor links being
1551  * properly maintained.
1552  */
1553  for (unsigned short s=0; s != n_sides; s++)
1554  {
1555  if (so_elem->neighbor_ptr(s) == remote_elem)
1556  lo_elem->set_neighbor(s, const_cast<RemoteElem*>(remote_elem));
1557  }
1558 
1566  (this->get_boundary_info(), so_elem, lo_elem.get());
1567 
1568  /*
1569  * The new first-order element is ready.
1570  * Inserting it into the mesh will replace and delete
1571  * the second-order element.
1572  */
1573  lo_elem->set_id(so_elem->id());
1574 #ifdef LIBMESH_ENABLE_UNIQUE_ID
1575  lo_elem->set_unique_id(so_elem->unique_id());
1576 #endif
1577  lo_elem->processor_id() = so_elem->processor_id();
1578  lo_elem->subdomain_id() = so_elem->subdomain_id();
1579 
1580  const unsigned int nei = so_elem->n_extra_integers();
1581  lo_elem->add_extra_integers(nei);
1582  for (unsigned int i=0; i != nei; ++i)
1583  lo_elem->set_extra_integer(i, so_elem->get_extra_integer(i));
1584 
1585  // This is probably moot but shouldn't hurt
1586  lo_elem->set_mapping_type(so_elem->mapping_type());
1587  lo_elem->set_mapping_data(so_elem->mapping_data());
1588 
1589  this->insert_elem(std::move(lo_elem));
1590  }
1591 
1592  // Deleting nodes does not invalidate iterators, so this is safe.
1593  for (const auto & node : this->node_ptr_range())
1594  if (!node_touched_by_me[node->id()])
1595  this->delete_node(node);
1596 
1597  // If crazy people applied boundary info to non-vertices and then
1598  // deleted those non-vertices, we should make sure their boundary id
1599  // caches are correct.
1601 
1602  // On hanging nodes that used to also be second order nodes, we
1603  // might now have an invalid nodal processor_id()
1605 
1606  // delete or renumber nodes if desired
1607  this->prepare_for_use();
1608 }
void set_parent(Elem *p)
Sets the pointer to the element&#39;s parent.
Definition: elem.h:2883
static void set_node_processor_ids(MeshBase &mesh)
This function is called after partitioning to set the processor IDs for the nodes.
Definition: partitioner.C:851
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:159
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
Definition: elem.C:273
libmesh_assert(ctx)
virtual void delete_node(Node *n)=0
Removes the Node n from the mesh.
void regenerate_id_sets()
Clears and regenerates the cached sets of ids.
void prepare_for_use()
Definition: mesh_base.C:742
virtual Elem * insert_elem(Elem *e)=0
Insert elem e to the element array, preserving its id and replacing/deleting any existing element wit...
void copy_boundary_ids(const BoundaryInfo &old_boundary_info, const Elem *const old_elem, const Elem *const new_elem)
bool _is_prepared
Flag indicating if the mesh has been prepared for use.
Definition: mesh_base.h:1820
virtual dof_id_type max_node_id() const =0
static ElemType first_order_equivalent_type(const ElemType et)
Definition: elem.C:2692
virtual void renumber_nodes_and_elements()=0
After partitioning a mesh it is useful to renumber the nodes and elements so that they lie in contigu...
const Elem * child_ptr(unsigned int i) const
Definition: elem.h:3000
const RemoteElem * remote_elem
Definition: remote_elem.C:54

◆ all_second_order()

void libMesh::MeshBase::all_second_order ( const bool  full_ordered = true)
inherited

Calls the range-based version of this function with a range consisting of all elements in the mesh.

Definition at line 1535 of file mesh_base.C.

References libMesh::MeshBase::all_second_order_range().

Referenced by AllSecondOrderTest::allSecondOrder(), build_domain(), main(), ExtraIntegersTest::test_helper(), and InfFERadialTest::testRefinement().

1536 {
1537  this->all_second_order_range(this->element_ptr_range(), full_ordered);
1538 }
virtual void all_second_order_range(const SimpleRange< element_iterator > &range, const bool full_ordered=true)=0
Converts a set of this Mesh&#39;s elements defined by range from FIRST order to SECOND order...

◆ all_second_order_range()

void libMesh::UnstructuredMesh::all_second_order_range ( const SimpleRange< element_iterator > &  range,
const bool  full_ordered = true 
)
overridevirtual

Converts a (conforming, non-refined) mesh with linear elements into a mesh with second-order elements.

For example, a mesh consisting of Tet4 will be converted to a mesh with Tet10 etc.

Note
For some elements like Hex8 there exist two higher order equivalents, Hex20 and Hex27. When full_ordered is true (default), then Hex27 is built. Otherwise, Hex20 is built. The same holds obviously for Quad4, Prism6, etc.

Implements libMesh::MeshBase.

Definition at line 1613 of file unstructured_mesh.C.

References libMesh::MeshBase::mesh_dimension(), libMesh::MeshBase::n_nodes(), libMesh::MeshBase::reserve_nodes(), and libMesh::Elem::second_order_equivalent_type().

1615 {
1616  LOG_SCOPE("all_second_order_range()", "Mesh");
1617 
1618  /*
1619  * The maximum number of new second order nodes we might be adding,
1620  * for use when picking unique unique_id values later. This variable
1621  * is not used unless unique ids are enabled.
1622  */
1623  unsigned int max_new_nodes_per_elem;
1624 
1625  /*
1626  * For speed-up of the \p add_point() method, we
1627  * can reserve memory. Guess the number of additional
1628  * nodes based on the element spatial dimensions and the
1629  * total number of nodes in the mesh as an upper bound.
1630  */
1631  switch (this->mesh_dimension())
1632  {
1633  case 1:
1634  /*
1635  * in 1D, there can only be order-increase from Edge2
1636  * to Edge3. Something like 1/2 of n_nodes() have
1637  * to be added
1638  */
1639  max_new_nodes_per_elem = 3 - 2;
1640  this->reserve_nodes(static_cast<unsigned int>
1641  (1.5*static_cast<double>(this->n_nodes())));
1642  break;
1643 
1644  case 2:
1645  /*
1646  * in 2D, either refine from Tri3 to Tri6 (double the nodes)
1647  * or from Quad4 to Quad8 (again, double) or Quad9 (2.25 that much)
1648  */
1649  max_new_nodes_per_elem = 9 - 4;
1650  this->reserve_nodes(static_cast<unsigned int>
1651  (2*static_cast<double>(this->n_nodes())));
1652  break;
1653 
1654 
1655  case 3:
1656  /*
1657  * in 3D, either refine from Tet4 to Tet10 (factor = 2.5) up to
1658  * Hex8 to Hex27 (something > 3). Since in 3D there _are_ already
1659  * quite some nodes, and since we do not want to overburden the memory by
1660  * a too conservative guess, use the lower bound
1661  */
1662  max_new_nodes_per_elem = 27 - 8;
1663  this->reserve_nodes(static_cast<unsigned int>
1664  (2.5*static_cast<double>(this->n_nodes())));
1665  break;
1666 
1667  default:
1668  // Hm?
1669  libmesh_error_msg("Unknown mesh dimension " << this->mesh_dimension());
1670  }
1671 
1672  // All the real work is done in the helper function
1673  all_increased_order_range(*this, range, max_new_nodes_per_elem,
1674  [full_ordered](ElemType t) {
1675  return Elem::second_order_equivalent_type(t, full_ordered);
1676  });
1677 }
ElemType
Defines an enum for geometric element types.
virtual void reserve_nodes(const dof_id_type nn)=0
Reserves space for a known number of nodes.
static ElemType second_order_equivalent_type(const ElemType et, const bool full_ordered=true)
Definition: elem.C:2760
unsigned int mesh_dimension() const
Definition: mesh_base.C:324
virtual dof_id_type n_nodes() const =0

◆ allgather()

virtual void libMesh::MeshBase::allgather ( )
inlinevirtualinherited

Gathers all elements and nodes of the mesh onto every processor.

Reimplemented in libMesh::DistributedMesh.

Definition at line 234 of file mesh_base.h.

Referenced by libMesh::EquationSystems::allgather(), libMesh::MeshSerializer::MeshSerializer(), and PartitionerTest< PartitionerSubclass, MeshClass >::testPartition().

234 {}

◆ allow_find_neighbors() [1/2]

void libMesh::MeshBase::allow_find_neighbors ( bool  allow)
inlineinherited

If false is passed then this mesh will no longer work to find element neighbors when being prepared for use.

Definition at line 1180 of file mesh_base.h.

References libMesh::MeshBase::_skip_find_neighbors.

Referenced by copy_nodes_and_elements().

1180 { _skip_find_neighbors = !allow; }
bool _skip_find_neighbors
If this is true then we will skip find_neighbors in prepare_for_use.
Definition: mesh_base.h:1873

◆ allow_find_neighbors() [2/2]

bool libMesh::MeshBase::allow_find_neighbors ( ) const
inlineinherited

Definition at line 1181 of file mesh_base.h.

References libMesh::MeshBase::_skip_find_neighbors.

Referenced by copy_nodes_and_elements(), libMesh::MeshBase::prepare_for_use(), read(), and stitching_helper().

1181 { return !_skip_find_neighbors; }
bool _skip_find_neighbors
If this is true then we will skip find_neighbors in prepare_for_use.
Definition: mesh_base.h:1873

◆ allow_remote_element_removal() [1/2]

void libMesh::MeshBase::allow_remote_element_removal ( bool  allow)
inlineinherited

If false is passed in then this mesh will no longer have remote elements deleted when being prepared for use; i.e.

even a DistributedMesh will remain (if it is already) serialized. This may adversely affect performance and memory use.

Definition at line 1189 of file mesh_base.h.

References libMesh::MeshBase::_allow_remote_element_removal.

Referenced by AllSecondOrderTest::allCompleteOrder(), AllSecondOrderTest::allCompleteOrderDoNothing(), AllSecondOrderTest::allSecondOrder(), AllSecondOrderTest::allSecondOrderDoNothing(), copy_nodes_and_elements(), main(), libMesh::MeshSerializer::MeshSerializer(), PeriodicBCTest::testPeriodicBC(), and libMesh::MeshSerializer::~MeshSerializer().

1189 { _allow_remote_element_removal = allow; }
bool _allow_remote_element_removal
If this is false then even on DistributedMesh remote elements will not be deleted during mesh prepara...
Definition: mesh_base.h:1881

◆ allow_remote_element_removal() [2/2]

bool libMesh::MeshBase::allow_remote_element_removal ( ) const
inlineinherited

Definition at line 1190 of file mesh_base.h.

References libMesh::MeshBase::_allow_remote_element_removal.

Referenced by copy_nodes_and_elements(), and stitching_helper().

bool _allow_remote_element_removal
If this is false then even on DistributedMesh remote elements will not be deleted during mesh prepara...
Definition: mesh_base.h:1881

◆ allow_renumbering() [1/2]

void libMesh::MeshBase::allow_renumbering ( bool  allow)
inlineinherited

If false is passed in then this mesh will no longer be renumbered when being prepared for use.

This may slightly adversely affect performance during subsequent element access, particularly when using a distributed mesh.

Important! When allow_renumbering(false) is set, ReplicatedMesh::n_elem() and ReplicatedMesh::n_nodes() will return wrong values whenever adaptive refinement is followed by adaptive coarsening. (Uniform refinement followed by uniform coarsening is OK.) This is due to the fact that n_elem() and n_nodes() are currently O(1) functions that just return the size of the respective underlying vectors, and this size is wrong when the numbering includes "gaps" from nodes and elements that have been deleted. We plan to implement a caching mechanism in the near future that will fix this incorrect behavior.

Definition at line 1173 of file mesh_base.h.

References libMesh::MeshBase::_skip_renumber_nodes_and_elements.

Referenced by AllSecondOrderTest::allSecondOrderMixedFixing(), copy_nodes_and_elements(), main(), AllSecondOrderTest::MixedFixingImpl(), libMesh::NameBasedIO::read(), libMesh::GMVIO::read(), WriteVecAndScalar::setupTests(), ConstraintOperatorTest::test1DCoarseningNewNodes(), ConstraintOperatorTest::test1DCoarseningOperator(), MeshGenerationTest::testBuildSphere(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyElementVectorImpl(), MeshInputTest::testCopyNodalSolutionImpl(), MeshGenerationTest::tester(), ExtraIntegersTest::testExtraIntegersExodusReading(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), EquationSystemsTest::testRefineThenReinitPreserveFlags(), EquationSystemsTest::testRepartitionThenReinit(), BoundaryInfoTest::testShellFaceConstraints(), MeshInputTest::testVTKPreserveElemIds(), MeshInputTest::testVTKPreserveSubdomainIds(), WriteNodesetData::testWriteImpl(), WriteSidesetData::testWriteImpl(), and WriteElemsetData::testWriteImpl().

bool _skip_renumber_nodes_and_elements
If this is true then renumbering will be kept to a minimum.
Definition: mesh_base.h:1868

◆ allow_renumbering() [2/2]

bool libMesh::MeshBase::allow_renumbering ( ) const
inlineinherited

Definition at line 1174 of file mesh_base.h.

References libMesh::MeshBase::_skip_renumber_nodes_and_elements.

Referenced by copy_nodes_and_elements(), libMesh::MeshBase::prepare_for_use(), and read().

bool _skip_renumber_nodes_and_elements
If this is true then renumbering will be kept to a minimum.
Definition: mesh_base.h:1868

◆ assign()

virtual MeshBase& libMesh::UnstructuredMesh::assign ( MeshBase &&  other_mesh)
overridepure virtual

Shim to allow operator = (&&) to behave like a virtual function without having to be one.

Implements libMesh::MeshBase.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

◆ cache_elem_data()

void libMesh::MeshBase::cache_elem_data ( )
inherited

Definition at line 1662 of file mesh_base.C.

References libMesh::MeshBase::_elem_dims, libMesh::MeshBase::_mesh_subdomains, libMesh::MeshBase::_spatial_dimension, libMesh::ParallelObject::comm(), libMesh::MeshBase::is_serial(), libMesh::MeshBase::mesh_dimension(), and TIMPI::Communicator::set_union().

Referenced by libMesh::MeshBase::cache_elem_dims(), libMesh::MeshBase::prepare_for_use(), and libMesh::MeshBase::set_elem_dimensions().

1663 {
1664  // This requires an inspection on every processor
1665  parallel_object_only();
1666 
1667  // Need to clear _elem_dims first in case all elements of a
1668  // particular dimension have been deleted.
1669  _elem_dims.clear();
1670  _mesh_subdomains.clear();
1671 
1672  for (const auto & elem : this->active_element_ptr_range())
1673  {
1674  _elem_dims.insert(cast_int<unsigned char>(elem->dim()));
1675  _mesh_subdomains.insert(elem->subdomain_id());
1676  }
1677 
1678  if (!this->is_serial())
1679  {
1680  // Some different dimension elements may only live on other processors
1681  this->comm().set_union(_elem_dims);
1682  this->comm().set_union(_mesh_subdomains);
1683  }
1684 
1685  // If the largest element dimension found is larger than the current
1686  // _spatial_dimension, increase _spatial_dimension.
1687  unsigned int max_dim = this->mesh_dimension();
1688  if (max_dim > _spatial_dimension)
1689  _spatial_dimension = cast_int<unsigned char>(max_dim);
1690 
1691  // _spatial_dimension may need to increase from 1->2 or 2->3 if the
1692  // mesh is full of 1D elements but they are not x-aligned, or the
1693  // mesh is full of 2D elements but they are not in the x-y plane.
1694  // If the mesh is x-aligned or x-y planar, we will end up checking
1695  // every node's coordinates and not breaking out of the loop
1696  // early...
1697 #if LIBMESH_DIM > 1
1698  if (_spatial_dimension < 3)
1699  {
1700  for (const auto & node : this->node_ptr_range())
1701  {
1702  // Note: the exact floating point comparison is intentional,
1703  // we don't want to get tripped up by tolerances.
1704  if ((*node)(1) != 0.)
1705  {
1706  _spatial_dimension = 2;
1707 #if LIBMESH_DIM == 2
1708  // If libmesh is compiled in 2D mode, this is the
1709  // largest spatial dimension possible so we can break
1710  // out.
1711  break;
1712 #endif
1713  }
1714 
1715 #if LIBMESH_DIM > 2
1716  if ((*node)(2) != 0.)
1717  {
1718  // Spatial dimension can't get any higher than this, so
1719  // we can break out.
1720  _spatial_dimension = 3;
1721  break;
1722  }
1723 #endif
1724  }
1725  }
1726 #endif // LIBMESH_DIM > 1
1727 }
std::set< subdomain_id_type > _mesh_subdomains
We cache the subdomain ids of the elements present in the mesh.
Definition: mesh_base.h:1900
const Parallel::Communicator & comm() const
unsigned char _spatial_dimension
The "spatial dimension" of the Mesh.
Definition: mesh_base.h:1932
virtual bool is_serial() const
Definition: mesh_base.h:205
std::set< unsigned char > _elem_dims
We cache the dimension of the elements present in the mesh.
Definition: mesh_base.h:1895
unsigned int mesh_dimension() const
Definition: mesh_base.C:324
void set_union(T &data, const unsigned int root_id) const

◆ cache_elem_dims()

void libMesh::MeshBase::cache_elem_dims ( )
inherited

elem subdomain ids) Search the mesh and cache the different dimensions of the elements present in the mesh. This is done in prepare_for_use(), but can be done manually by other classes after major mesh modifications.

Definition at line 1655 of file mesh_base.C.

References libMesh::MeshBase::cache_elem_data().

1656 {
1657  libmesh_deprecated();
1658 
1659  this->cache_elem_data();
1660 }
void cache_elem_data()
Definition: mesh_base.C:1662

◆ change_elemset_code()

void libMesh::MeshBase::change_elemset_code ( dof_id_type  old_code,
dof_id_type  new_code 
)
inherited

Replace elemset code "old_code" with "new_code".

This function loops over all elements and changes the extra integer corresponding to the "elemset_code" label, and updates the _elemset_codes and _elemset_codes_inverse_map members. Does not change the elemset ids of any of the sets.

Definition at line 406 of file mesh_base.C.

References libMesh::MeshBase::_elemset_codes, libMesh::MeshBase::_elemset_codes_inverse_map, libMesh::MeshBase::add_elemset_code(), libMesh::MeshBase::get_elem_integer_index(), and libMesh::MeshBase::has_elem_integer().

407 {
408  // Look up elemset ids for old_code
409  auto it = _elemset_codes.find(old_code);
410 
411  // If we don't have the old_code, then do nothing. Alternatively, we
412  // could throw an error since trying to change an elemset code you
413  // don't have could indicate there's a problem...
414  if (it == _elemset_codes.end())
415  return;
416 
417  // Make copy of the set of elemset ids. We are not changing these,
418  // only updating the elemset code it corresponds to.
419  elemset_type id_set_copy = *(it->second);
420 
421  // Look up the corresponding entry in the inverse map. Note: we want
422  // the iterator because we are going to remove it.
423  auto inverse_it = _elemset_codes_inverse_map.find(id_set_copy);
424  libmesh_error_msg_if(inverse_it == _elemset_codes_inverse_map.end(),
425  "Expected _elemset_codes_inverse_map entry for elemset code " << old_code);
426 
427  // Erase entry from inverse map
428  _elemset_codes_inverse_map.erase(inverse_it);
429 
430  // Erase entry from forward map
431  _elemset_codes.erase(it);
432 
433  // Add new code with original set of ids.
434  this->add_elemset_code(new_code, id_set_copy);
435 
436  // We can't update any actual elemset codes if there is no extra integer defined for it.
437  if (!this->has_elem_integer("elemset_code"))
438  return;
439 
440  // Get index of elemset_code extra integer
441  unsigned int elemset_index = this->get_elem_integer_index("elemset_code");
442 
443  // Loop over all elems and update code
444  for (auto & elem : this->element_ptr_range())
445  {
446  dof_id_type elemset_code =
447  elem->get_extra_integer(elemset_index);
448 
449  if (elemset_code == old_code)
450  elem->set_extra_integer(elemset_index, new_code);
451  }
452 }
std::map< dof_id_type, const MeshBase::elemset_type * > _elemset_codes
Map from "element set code" to list of set ids to which that element belongs (and vice-versa)...
Definition: mesh_base.h:1924
void add_elemset_code(dof_id_type code, MeshBase::elemset_type id_set)
Tabulate a user-defined "code" for elements which belong to the element sets specified in id_set...
Definition: mesh_base.C:350
bool has_elem_integer(std::string_view name) const
Definition: mesh_base.C:590
std::map< MeshBase::elemset_type, dof_id_type > _elemset_codes_inverse_map
Definition: mesh_base.h:1925
unsigned int get_elem_integer_index(std::string_view name) const
Definition: mesh_base.C:578
std::set< elemset_id_type > elemset_type
Typedef for the "set" container used to store elemset ids.
Definition: mesh_base.h:297
uint8_t dof_id_type
Definition: id_types.h:67

◆ change_elemset_id()

void libMesh::MeshBase::change_elemset_id ( elemset_id_type  old_id,
elemset_id_type  new_id 
)
inherited

Replace elemset id "old_id" with "new_id".

Does not change any of the elemset codes, so does not need to loop over the elements themselves.

Definition at line 454 of file mesh_base.C.

References libMesh::MeshBase::_all_elemset_ids, libMesh::MeshBase::_elemset_codes, and libMesh::MeshBase::_elemset_codes_inverse_map.

455 {
456  // Early return if we don't have old_id
457  if (!_all_elemset_ids.count(old_id))
458  return;
459 
460  // Throw an error if the new_id is already used
461  libmesh_error_msg_if(_all_elemset_ids.count(new_id),
462  "Cannot change elemset id " << old_id <<
463  " to " << new_id << ", " << new_id << " already exists.");
464 
465  // We will build up a new version of the inverse map so we can iterate over
466  // the current one without invalidating anything.
467  std::map<MeshBase::elemset_type, dof_id_type> new_elemset_codes_inverse_map;
468  for (const auto & [id_set, elemset_code] : _elemset_codes_inverse_map)
469  {
470  auto id_set_copy = id_set;
471  if (id_set_copy.count(old_id))
472  {
473  // Remove old_id, insert new_id
474  id_set_copy.erase(old_id);
475  id_set_copy.insert(new_id);
476  }
477 
478  // Store in new version of map
479  new_elemset_codes_inverse_map.emplace(id_set_copy, elemset_code);
480  }
481 
482  // Swap existing map with newly-built one
483  _elemset_codes_inverse_map.swap(new_elemset_codes_inverse_map);
484 
485  // Reconstruct _elemset_codes map
486  _elemset_codes.clear();
487  for (const auto & [id_set, elemset_code] : _elemset_codes_inverse_map)
488  _elemset_codes.emplace(elemset_code, &id_set);
489 
490  // Update _all_elemset_ids
491  _all_elemset_ids.erase(old_id);
492  _all_elemset_ids.insert(new_id);
493 }
std::map< dof_id_type, const MeshBase::elemset_type * > _elemset_codes
Map from "element set code" to list of set ids to which that element belongs (and vice-versa)...
Definition: mesh_base.h:1924
std::map< MeshBase::elemset_type, dof_id_type > _elemset_codes_inverse_map
Definition: mesh_base.h:1925
MeshBase::elemset_type _all_elemset_ids
Definition: mesh_base.h:1926

◆ clear()

void libMesh::MeshBase::clear ( )
virtualinherited

Deletes all the element and node data that is currently stored.

elem and node extra_integer data is nevertheless retained here, for better compatibility between that feature and older code's use of MeshBase::clear()

Reimplemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

Definition at line 862 of file mesh_base.C.

References libMesh::MeshBase::_constraint_rows, libMesh::MeshBase::_elem_dims, libMesh::MeshBase::_elemset_codes, libMesh::MeshBase::_elemset_codes_inverse_map, libMesh::MeshBase::_is_prepared, libMesh::MeshBase::_n_parts, libMesh::MeshBase::boundary_info, and libMesh::MeshBase::clear_point_locator().

Referenced by libMesh::MeshTools::Generation::build_delaunay_square(), libMesh::ReplicatedMesh::clear(), libMesh::DistributedMesh::clear(), libMesh::TriangleWrapper::copy_tri_to_mesh(), create_submesh(), main(), libMesh::AbaqusIO::read(), libMesh::GMVIO::read(), libMesh::ExodusII_IO::read(), libMesh::VTKIO::read(), libMesh::GmshIO::read_mesh(), libMesh::DynaIO::read_mesh(), libMesh::OFFIO::read_stream(), libMesh::MatlabIO::read_stream(), libMesh::BoundaryInfo::sync(), MeshAssignTest::testMeshMoveAssign(), and libMesh::MeshBase::~MeshBase().

863 {
864  // Reset the number of partitions
865  _n_parts = 1;
866 
867  // Reset the _is_prepared flag
868  _is_prepared = false;
869 
870  // Clear boundary information
871  if (boundary_info)
872  boundary_info->clear();
873 
874  // Clear element dimensions
875  _elem_dims.clear();
876 
877  _elemset_codes.clear();
879 
880  _constraint_rows.clear();
881 
882  // Clear our point locator.
883  this->clear_point_locator();
884 }
std::map< dof_id_type, const MeshBase::elemset_type * > _elemset_codes
Map from "element set code" to list of set ids to which that element belongs (and vice-versa)...
Definition: mesh_base.h:1924
constraint_rows_type _constraint_rows
Definition: mesh_base.h:2009
std::unique_ptr< BoundaryInfo > boundary_info
This class holds the boundary information.
Definition: mesh_base.h:1760
std::map< MeshBase::elemset_type, dof_id_type > _elemset_codes_inverse_map
Definition: mesh_base.h:1925
unsigned int _n_parts
The number of partitions the mesh has.
Definition: mesh_base.h:1802
void clear_point_locator()
Releases the current PointLocator object.
Definition: mesh_base.C:1598
std::set< unsigned char > _elem_dims
We cache the dimension of the elements present in the mesh.
Definition: mesh_base.h:1895
bool _is_prepared
Flag indicating if the mesh has been prepared for use.
Definition: mesh_base.h:1820

◆ clear_elems()

virtual void libMesh::MeshBase::clear_elems ( )
pure virtualinherited

Deletes all the element data that is currently stored.

No Node is removed from the mesh, however even NodeElem elements are deleted, so the remaining Nodes will be considered "unused" and cleared unless they are reconnected to new elements before the next prepare_for_use()

This does not affect BoundaryInfo data; any boundary information associated elements should already be cleared.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

Referenced by libMesh::TriangulatorInterface::elems_to_segments(), and libMesh::Poly2TriTriangulator::triangulate_current_points().

◆ clear_point_locator()

void libMesh::MeshBase::clear_point_locator ( )
inherited

Releases the current PointLocator object.

Definition at line 1598 of file mesh_base.C.

References libMesh::MeshBase::_point_locator.

Referenced by libMesh::MeshBase::clear(), contract(), libMesh::MeshCommunication::delete_remote_elements(), and libMesh::MeshBase::prepare_for_use().

1599 {
1600  _point_locator.reset(nullptr);
1601 }
std::unique_ptr< PointLocatorBase > _point_locator
A PointLocator class for this mesh.
Definition: mesh_base.h:1829

◆ clone()

virtual std::unique_ptr<MeshBase> libMesh::MeshBase::clone ( ) const
pure virtualinherited

◆ comm()

const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inlineinherited
Returns
A reference to the Parallel::Communicator object used by this mesh.

Definition at line 97 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_tao_equality_constraints(), libMesh::__libmesh_tao_equality_constraints_jacobian(), libMesh::__libmesh_tao_gradient(), libMesh::__libmesh_tao_hessian(), libMesh::__libmesh_tao_inequality_constraints(), libMesh::__libmesh_tao_inequality_constraints_jacobian(), libMesh::__libmesh_tao_objective(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::Partitioner::_find_global_index_by_pid_map(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::SlepcEigenSolver< libMesh::Number >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< libMesh::Number >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_mult_add(), libMesh::MeshRefinement::_refine_elements(), libMesh::MeshRefinement::_smooth_flags(), libMesh::DofMap::add_constraints_to_send_list(), add_cube_convex_hull_to_mesh(), libMesh::PetscDMWrapper::add_dofs_helper(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::EigenSystem::add_matrices(), libMesh::System::add_matrix(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::System::add_variable(), libMesh::System::add_variables(), libMesh::System::add_vector(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::FEMSystem::assemble_qoi(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::MeshCommunication::assign_global_indices(), libMesh::Partitioner::assign_partitioning(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_section(), libMesh::PetscDMWrapper::build_sf(), libMesh::MeshBase::cache_elem_data(), libMesh::System::calculate_norm(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::RBSCMConstruction::compute_SCM_bounds_on_training_set(), libMesh::DofMap::computed_sparsity_already(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ContinuationSystem::ContinuationSystem(), libMesh::MeshBase::copy_constraint_rows(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshTools::create_bounding_box(), libMesh::DofMap::create_dof_constraints(), libMesh::MeshTools::create_nodal_bounding_box(), libMesh::MeshRefinement::create_parent_error_vector(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::MeshTools::create_subdomain_bounding_box(), libMesh::PetscMatrix< libMesh::Number >::create_submatrix_nosort(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::RBEIMEvaluation::distribute_bfs(), libMesh::DofMap::distribute_dofs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), DMVariableBounds_libMesh(), libMesh::DTKSolutionTransfer::DTKSolutionTransfer(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_nodes(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_sides(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::EpetraVector< T >::EpetraVector(), AssembleOptimization::equality_constraints(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_error_tolerance(), libMesh::MeshRefinement::flag_elements_by_mean_stddev(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::DofMap::gather_constraints(), libMesh::MeshfreeInterpolation::gather_remote_data(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::RBEIMEvaluation::get_eim_basis_function_node_value(), libMesh::RBEIMEvaluation::get_eim_basis_function_side_value(), libMesh::RBEIMEvaluation::get_eim_basis_function_value(), libMesh::MeshBase::get_info(), libMesh::System::get_info(), libMesh::DofMap::get_info(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::RBEIMConstruction::get_max_abs_value(), libMesh::RBEIMConstruction::get_node_max_abs_value(), libMesh::RBEIMEvaluation::get_parametrized_function_node_value(), libMesh::RBEIMEvaluation::get_parametrized_function_side_value(), libMesh::RBEIMEvaluation::get_parametrized_function_value(), libMesh::RBEIMConstruction::get_random_point(), AssembleOptimization::inequality_constraints(), AssembleOptimization::inequality_constraints_jacobian(), libMesh::LocationMap< T >::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set(), libMesh::RBEIMConstruction::inner_product(), integrate_function(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_equal_connectivity(), libMesh::MeshTools::libmesh_assert_equal_points(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_flags(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_p_levels(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshTools::libmesh_assert_valid_unique_ids(), libMesh::libmesh_petsc_linesearch_shellfunc(), libMesh::libmesh_petsc_preconditioner_apply(), libMesh::libmesh_petsc_recalculate_monitor(), libMesh::libmesh_petsc_snes_fd_residual(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_mffd_interface(), libMesh::libmesh_petsc_snes_mffd_residual(), libMesh::libmesh_petsc_snes_postcheck(), libMesh::libmesh_petsc_snes_precheck(), libMesh::libmesh_petsc_snes_residual(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::limit_overrefined_boundary(), libMesh::MeshRefinement::limit_underrefined_boundary(), libMesh::LinearImplicitSystem::LinearImplicitSystem(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshRefinement::make_flags_parallel_consistent(), libMesh::MeshCommunication::make_new_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_new_nodes_parallel_consistent(), libMesh::MeshCommunication::make_node_bcids_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_unique_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshCommunication::make_p_levels_parallel_consistent(), libMesh::MeshRefinement::make_refinement_compatible(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), libMesh::FEMSystem::mesh_position_set(), libMesh::TriangulatorInterface::MeshedHole::MeshedHole(), LinearElasticityWithContact::move_mesh(), libMesh::DistributedMesh::n_active_elem(), libMesh::MeshTools::n_active_levels(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::DofMap::n_constrained_dofs(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::MeshTools::n_levels(), MixedOrderTest::n_neighbor_links(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::SparsityPattern::Build::n_nonzeros(), libMesh::MeshTools::n_p_levels(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::RBEIMEvaluation::node_distribute_bfs(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::RBEIMConstruction::node_inner_product(), libMesh::MeshBase::operator==(), libMesh::DistributedMesh::parallel_max_elem_id(), libMesh::DistributedMesh::parallel_max_node_id(), libMesh::ReplicatedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_n_elem(), libMesh::DistributedMesh::parallel_n_nodes(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::BoundaryInfo::parallel_sync_node_ids(), libMesh::BoundaryInfo::parallel_sync_side_ids(), libMesh::MeshTools::paranoid_n_levels(), libMesh::Partitioner::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::DofMap::print_dof_constraints(), libMesh::DofMap::process_mesh_constraint_rows(), libMesh::Partitioner::processor_pairs_to_interface_nodes(), libMesh::InterMeshProjection::project_system_vectors(), FEMParameters::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::EquationSystems::read(), libMesh::ExodusII_IO::read_header(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), libMesh::RBEIMEvaluation::read_in_interior_basis_functions(), libMesh::RBEIMEvaluation::read_in_node_basis_functions(), libMesh::RBEIMEvaluation::read_in_side_basis_functions(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::System::read_legacy_data(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::Nemesis_IO_Helper::read_var_names_impl(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::DistributedMesh::renumber_nodes_and_elements(), LinearElasticityWithContact::residual_and_jacobian(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), scale_mesh_and_plot(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::send_and_insert_dof_values(), libMesh::TransientRBConstruction::set_error_temporal_data(), libMesh::Partitioner::set_interface_node_processor_ids_BFS(), libMesh::Partitioner::set_interface_node_processor_ids_linear(), libMesh::Partitioner::set_interface_node_processor_ids_petscpartitioner(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::PetscDiffSolver::setup_petsc_data(), libMesh::RBEIMEvaluation::side_distribute_bfs(), libMesh::RBEIMEvaluation::side_gather_bfs(), libMesh::RBEIMConstruction::side_inner_product(), libMesh::Partitioner::single_partition(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::split_mesh(), libMesh::RBEIMConstruction::store_eim_solutions_for_training_set(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), ConstraintOperatorTest::test1DCoarseningNewNodes(), ConstraintOperatorTest::test1DCoarseningOperator(), libMesh::MeshRefinement::test_level_one(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), libMesh::MeshRefinement::test_unflagged(), DofMapTest::testBadElemFECombo(), SystemsTest::testBlockRestrictedVarNDofs(), BoundaryInfoTest::testBoundaryOnChildrenErrors(), MeshInputTest::testExodusIGASidesets(), MeshTriangulationTest::testFoundCenters(), PointLocatorTest::testLocator(), BoundaryInfoTest::testMesh(), PointLocatorTest::testPlanar(), MeshTriangulationTest::testPoly2TriRefinementBase(), SystemsTest::testProjectCubeWithMeshFunction(), BoundaryInfoTest::testRenumber(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), MeshTriangulationTest::testTriangulatorInterp(), MeshTriangulationTest::testTriangulatorMeshedHoles(), libMesh::MeshTools::total_weight(), libMesh::RBConstruction::train_reduced_basis_with_POD(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::Poly2TriTriangulator::triangulate(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::VTKIO::write_nodal_data(), libMesh::RBEIMEvaluation::write_out_interior_basis_functions(), libMesh::RBEIMEvaluation::write_out_node_basis_functions(), libMesh::RBEIMEvaluation::write_out_side_basis_functions(), libMesh::RBEvaluation::write_out_vectors(), libMesh::TransientRBConstruction::write_riesz_representors_to_files(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::RBDataSerialization::RBEvaluationSerialization::write_to_file(), libMesh::RBDataSerialization::TransientRBEvaluationSerialization::write_to_file(), libMesh::RBDataSerialization::RBEIMEvaluationSerialization::write_to_file(), and libMesh::RBDataSerialization::RBSCMEvaluationSerialization::write_to_file().

98  { return _communicator; }
const Parallel::Communicator & _communicator

◆ contract()

bool libMesh::UnstructuredMesh::contract ( )
overridevirtual

Delete subactive (i.e.

children of coarsened) elements. This removes all elements descended from currently active elements in the mesh.

Implements libMesh::MeshBase.

Definition at line 1403 of file unstructured_mesh.C.

References libMesh::as_range(), libMesh::MeshBase::clear_point_locator(), libMesh::MeshBase::delete_elem(), libMesh::MeshBase::ghosting_functors_begin(), libMesh::MeshBase::ghosting_functors_end(), libMesh::libmesh_assert(), and libMesh::MeshBase::renumber_nodes_and_elements().

1404 {
1405  LOG_SCOPE ("contract()", "Mesh");
1406 
1407  // Flag indicating if this call actually changes the mesh
1408  bool mesh_changed = false;
1409 
1410 #ifdef DEBUG
1411  for (const auto & elem : this->element_ptr_range())
1412  libmesh_assert(elem->active() || elem->subactive() || elem->ancestor());
1413 #endif
1414 
1415  // Loop over the elements.
1416  for (auto & elem : this->element_ptr_range())
1417  {
1418  // Delete all the subactive ones
1419  if (elem->subactive())
1420  {
1421  // No level-0 element should be subactive.
1422  // Note that we CAN'T test elem->level(), as that
1423  // touches elem->parent()->dim(), and elem->parent()
1424  // might have already been deleted!
1425  libmesh_assert(elem->parent());
1426 
1427  // Delete the element
1428  // This just sets a pointer to nullptr, and doesn't
1429  // invalidate any iterators
1430  this->delete_elem(elem);
1431 
1432  // the mesh has certainly changed
1433  mesh_changed = true;
1434  }
1435  else
1436  {
1437  // Compress all the active ones
1438  if (elem->active())
1439  elem->contract();
1440  else
1441  libmesh_assert (elem->ancestor());
1442  }
1443  }
1444 
1445  // Strip any newly-created nullptr voids out of the element array
1447 
1448  // FIXME: Need to understand why deleting subactive children
1449  // invalidates the point locator. For now we will clear it explicitly
1450  this->clear_point_locator();
1451 
1452  // Allow our GhostingFunctor objects to reinit if necessary.
1453  for (auto & gf : as_range(this->ghosting_functors_begin(),
1454  this->ghosting_functors_end()))
1455  {
1456  libmesh_assert(gf);
1457  gf->mesh_reinit();
1458  }
1459 
1460  return mesh_changed;
1461 }
virtual void delete_elem(Elem *e)=0
Removes element e from the mesh.
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
Helper function that allows us to treat a homogenous pair as a range.
Definition: simple_range.h:57
void clear_point_locator()
Releases the current PointLocator object.
Definition: mesh_base.C:1598
libmesh_assert(ctx)
std::set< GhostingFunctor * >::const_iterator ghosting_functors_begin() const
Beginning of range of ghosting functors.
Definition: mesh_base.h:1268
virtual void renumber_nodes_and_elements()=0
After partitioning a mesh it is useful to renumber the nodes and elements so that they lie in contigu...
std::set< GhostingFunctor * >::const_iterator ghosting_functors_end() const
End of range of ghosting functors.
Definition: mesh_base.h:1274

◆ copy_constraint_rows() [1/2]

void libMesh::MeshBase::copy_constraint_rows ( const MeshBase other_mesh)
inherited

Copy the constraints from the other mesh to this mesh.

Definition at line 1938 of file mesh_base.C.

References libMesh::MeshBase::_constraint_rows, libMesh::MeshBase::elem_ptr(), libMesh::MeshBase::get_constraint_rows(), and libMesh::MeshBase::node_ptr().

Referenced by libMesh::DistributedMesh::DistributedMesh(), libMesh::ReplicatedMesh::ReplicatedMesh(), ConstraintOperatorTest::test1DCoarseningNewNodes(), and ConstraintOperatorTest::test1DCoarseningOperator().

1939 {
1940  _constraint_rows.clear();
1941 
1942  const auto & other_constraint_rows = other_mesh.get_constraint_rows();
1943  for (const auto & [other_node, other_node_constraints] : other_constraint_rows)
1944  {
1945  const Node * const our_node = this->node_ptr(other_node->id());
1946  constraint_rows_mapped_type our_node_constraints;
1947  for (const auto & [other_inner_key_pair, constraint_value] : other_node_constraints)
1948  {
1949  const auto & [other_elem, local_node_id] = other_inner_key_pair;
1950  const Elem * const our_elem = this->elem_ptr(other_elem->id());
1951  our_node_constraints.emplace_back(std::make_pair(our_elem, local_node_id), constraint_value);
1952  }
1953  _constraint_rows[our_node] = std::move(our_node_constraints);
1954  }
1955 }
std::vector< std::pair< std::pair< const Elem *, unsigned int >, Real > > constraint_rows_mapped_type
Definition: mesh_base.h:1674
constraint_rows_type _constraint_rows
Definition: mesh_base.h:2009
virtual const Elem * elem_ptr(const dof_id_type i) const =0
virtual const Node * node_ptr(const dof_id_type i) const =0

◆ copy_constraint_rows() [2/2]

template<typename T >
void libMesh::MeshBase::copy_constraint_rows ( const SparseMatrix< T > &  constraint_operator)
inherited

Copy the constraints from the given matrix to this mesh.

The constraint_operator should be an mxn matrix, where m == this->n_nodes() and the operator indexing matches the current node indexing. This may require users to disable mesh renumbering in between loading a mesh file and loading a constraint matrix which matches it.

If any "constraint" rows in the matrix are unit vectors, the node corresponding to that row index will be left unconstrained, and will be used to constrain any other nodes which have a non-zero in the column index of that unit vector.

For each matrix column index which does not correspond to an existing node, a new NodeElem will be added to the mesh on which to store the new unconstrained degree(s) of freedom.

T for the constraint_operator in this function should be Real or Number ... and the data should be Real - we just allow complex T for the sake of subclasses which have to be configured and compiled with only one runtime option.

Definition at line 1960 of file mesh_base.C.

References libMesh::MeshBase::_constraint_rows, libMesh::MeshBase::add_elem(), libMesh::MeshBase::add_point(), TIMPI::Communicator::allgather(), libMesh::Elem::build(), libMesh::ParallelObject::comm(), libMesh::MeshBase::elem_ptr(), libMesh::SparseMatrix< T >::get_row(), libMesh::DofObject::id(), libMesh::index_range(), libMesh::libmesh_assert(), libMesh::libmesh_real(), libMesh::SparseMatrix< T >::m(), libMesh::make_range(), libMesh::SparseMatrix< T >::n(), libMesh::MeshBase::n_nodes(), libMesh::MeshBase::node_ptr(), libMesh::MeshBase::node_ref(), libMesh::NODEELEM, libMesh::DofObject::processor_id(), libMesh::Real, libMesh::SparseMatrix< T >::row_start(), libMesh::SparseMatrix< T >::row_stop(), and TIMPI::Communicator::set_union().

1961 {
1962  this->_constraint_rows.clear();
1963 
1964  // We're not going to support doing this distributed yet; it'd be
1965  // pointless unless we temporarily had a linear partitioning to
1966  // better match the constraint operator.
1967  MeshSerializer serialize(*this);
1968 
1969  // Our current mesh should already reflect the desired assembly space
1970  libmesh_error_msg_if(this->n_nodes() != constraint_operator.m(),
1971  "Constraint operator matrix does not match this mesh");
1972 
1973  // First, find what new unconstrained DoFs we need to add. We can't
1974  // iterate over columns in a SparseMatrix, so we'll iterate over
1975  // rows and keep track of columns.
1976 
1977  // If we have nodes that will work unconstrained, keep track of
1978  // their node ids and corresponding column indices.
1979  // existing_unconstrained_nodes[column_id] = node_id
1980  std::map<dof_id_type, dof_id_type> existing_unconstrained_columns;
1981  std::set<dof_id_type> existing_unconstrained_nodes;
1982 
1983  // In case we need new nodes, keep track of their columns.
1984  // columns[j][k] will be the kth row index and value of column j
1985  typedef
1986  std::unordered_map<dof_id_type,
1987  std::vector<std::pair<dof_id_type, Real>>>
1988  columns_type;
1989  columns_type columns(constraint_operator.n());
1990 
1991  // Work in parallel, though we'll have to sync shortly
1992  for (auto i : make_range(constraint_operator.row_start(),
1993  constraint_operator.row_stop()))
1994  {
1995  std::vector<numeric_index_type> indices;
1996  std::vector<T> values;
1997 
1998  constraint_operator.get_row(i, indices, values);
1999  libmesh_assert_equal_to(indices.size(), values.size());
2000 
2001  if (indices.size() == 1 &&
2002  values[0] == T(1))
2003  {
2004  existing_unconstrained_nodes.insert(i);
2005  existing_unconstrained_columns.emplace(indices[0],i);
2006  }
2007  else
2008  for (auto jj : index_range(indices))
2009  {
2010  const auto j = indices[jj];
2011  const Real coef = libmesh_real(values[jj]);
2012  libmesh_assert_equal_to(coef, values[jj]);
2013  columns[j].emplace_back(i, coef);
2014  }
2015  }
2016 
2017  // Merge data from different processors' slabs of the matrix
2018  this->comm().set_union(existing_unconstrained_nodes);
2019  this->comm().set_union(existing_unconstrained_columns);
2020 
2021  std::vector<columns_type> all_columns;
2022  this->comm().allgather(columns, all_columns);
2023 
2024  columns.clear();
2025  for (auto p : index_range(all_columns))
2026  for (auto & [j, subcol] : all_columns[p])
2027  for (auto [i, v] : subcol)
2028  columns[j].emplace_back(i,v);
2029 
2030  // Keep track of elements on which unconstrained nodes exist, and
2031  // their local node indices.
2032  // node_to_elem_ptrs[node] = [elem_id, local_node_num]
2033  std::unordered_map<const Node *, std::pair<dof_id_type, unsigned int>> node_to_elem_ptrs;
2034 
2035  // Find elements attached to any existing nodes that will stay
2036  // unconstrained
2037  for (const Elem * elem : this->element_ptr_range())
2038  for (auto n : make_range(elem->n_nodes()))
2039  {
2040  const Node * node = elem->node_ptr(n);
2041  if (existing_unconstrained_nodes.count(node->id()))
2042  node_to_elem_ptrs.emplace(node, std::make_pair(elem->id(), n));
2043  }
2044 
2045  for (auto j : make_range(constraint_operator.n()))
2046  {
2047  // If we already have a good node for this then we're done
2048  if (existing_unconstrained_columns.find(j) !=
2049  existing_unconstrained_columns.end())
2050  continue;
2051 
2052  // Get a half-decent spot to place a new NodeElem for
2053  // unconstrained DoF(s) here. Getting a *fully*-decent spot
2054  // would require finding a Moore-Penrose pseudoinverse, and I'm
2055  // not going to do that, but scaling a transpose will at least
2056  // get us a little uniqueness to make visualization reasonable.
2057  Point newpt;
2058  Real total_scaling = 0;
2059 
2060  // We'll get a decent initial pid choice here too, if only to
2061  // aid in later repartitioning.
2062  std::map<processor_id_type, int> pids;
2063 
2064  auto & column = columns[j];
2065  for (auto [i, r] : column)
2066  {
2067  Node & constrained_node = this->node_ref(i);
2068  const Point constrained_pt = constrained_node;
2069  newpt += r*constrained_pt;
2070  total_scaling += r;
2071  ++pids[constrained_node.processor_id()];
2072  }
2073  newpt /= total_scaling;
2074 
2075  Node *n = this->add_point(newpt);
2076  std::unique_ptr<Elem> elem = Elem::build(NODEELEM);
2077  elem->set_node(0) = n;
2078 
2079  Elem * added_elem = this->add_elem(std::move(elem));
2080  node_to_elem_ptrs.emplace(n, std::make_pair(added_elem->id(), 0));
2081  existing_unconstrained_columns.emplace(j,n->id());
2082 
2083  // Repartition the new objects *after* adding them, so a
2084  // DistributedMesh doesn't get confused and think you're not
2085  // adding them on all processors at once.
2086  int n_pids = 0;
2087  for (auto [pid, count] : pids)
2088  if (count >= n_pids)
2089  {
2090  n_pids = count;
2091  added_elem->processor_id() = pid;
2092  n->processor_id() = pid;
2093  }
2094  }
2095 
2096  // Calculate constraint rows in an indexed form that's easy for us
2097  // to allgather
2098  std::unordered_map<dof_id_type,
2099  std::vector<std::pair<std::pair<dof_id_type, unsigned int>,Real>>>
2100  indexed_constraint_rows;
2101 
2102  for (auto i : make_range(constraint_operator.row_start(),
2103  constraint_operator.row_stop()))
2104  {
2105  if (existing_unconstrained_nodes.count(i))
2106  continue;
2107 
2108  std::vector<numeric_index_type> indices;
2109  std::vector<T> values;
2110 
2111  constraint_operator.get_row(i, indices, values);
2112 
2113  std::vector<std::pair<std::pair<dof_id_type, unsigned int>, Real>> constraint_row;
2114 
2115  for (auto jj : index_range(indices))
2116  {
2117  const dof_id_type node_id =
2118  existing_unconstrained_columns[indices[jj]];
2119 
2120  Node & constraining_node = this->node_ref(node_id);
2121 
2122  libmesh_assert(node_to_elem_ptrs.count(&constraining_node));
2123 
2124  auto p = node_to_elem_ptrs[&constraining_node];
2125 
2126  const Real coef = libmesh_real(values[jj]);
2127  libmesh_assert_equal_to(coef, values[jj]);
2128  constraint_row.emplace_back(std::make_pair(p, coef));
2129  }
2130 
2131  indexed_constraint_rows.emplace(i, std::move(constraint_row));
2132  }
2133 
2134  this->comm().set_union(indexed_constraint_rows);
2135 
2136  // Add constraint rows as mesh constraint rows
2137  for (auto & [node_id, indexed_row] : indexed_constraint_rows)
2138  {
2139  Node * constrained_node = this->node_ptr(node_id);
2140 
2141  constraint_rows_mapped_type constraint_row;
2142 
2143  for (auto [p, coef] : indexed_row)
2144  {
2145  const Elem * elem = this->elem_ptr(p.first);
2146  constraint_row.emplace_back
2147  (std::make_pair(std::make_pair(elem, p.second), coef));
2148  }
2149 
2150  this->_constraint_rows.emplace(constrained_node,
2151  std::move(constraint_row));
2152  }
2153 }
T libmesh_real(T a)
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
std::vector< std::pair< std::pair< const Elem *, unsigned int >, Real > > constraint_rows_mapped_type
Definition: mesh_base.h:1674
constraint_rows_type _constraint_rows
Definition: mesh_base.h:2009
const Parallel::Communicator & comm() const
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
Add a new Node at Point p to the end of the vertex array, with processor_id procid.
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
Definition: elem.C:273
libmesh_assert(ctx)
virtual const Elem * elem_ptr(const dof_id_type i) const =0
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134
virtual const Node & node_ref(const dof_id_type i) const
Definition: mesh_base.h:575
virtual const Node * node_ptr(const dof_id_type i) const =0
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:111
virtual dof_id_type n_nodes() const =0
uint8_t dof_id_type
Definition: id_types.h:67
void set_union(T &data, const unsigned int root_id) const

◆ copy_nodes_and_elements()

void libMesh::UnstructuredMesh::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 
)
virtual

Deep copy of nodes and elements from another mesh object (used by subclass copy constructors and by mesh merging operations)

This will not copy most "high level" data in the mesh; that is done separately by constructors. An exception is that, if the other_mesh has element or node extra_integer data, any names for that data which do not already exist on this mesh are added so that all such data can be copied.

If an id_remapping map is provided, then element subdomain ids in other_mesh will be converted using it before adding them to this mesh.

Definition at line 645 of file unstructured_mesh.C.

References libMesh::MeshBase::_elem_integer_names, libMesh::MeshBase::_n_parts, libMesh::MeshBase::_node_integer_names, libMesh::Elem::add_child(), libMesh::MeshBase::add_elem(), libMesh::DofObject::add_extra_integers(), libMesh::MeshBase::add_point(), libMesh::MeshBase::allow_find_neighbors(), libMesh::MeshBase::allow_remote_element_removal(), libMesh::MeshBase::allow_renumbering(), libMesh::Elem::build(), libMesh::MeshBase::elem_ptr(), libMesh::MeshTools::libmesh_assert_valid_amr_elem_ids(), libMesh::MeshBase::merge_extra_integer_names(), libMesh::MeshBase::mesh_dimension(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::MeshBase::n_partitions(), libMesh::Elem::neighbor_ptr(), libMesh::MeshBase::node_ptr(), libMesh::MeshBase::parallel_max_unique_id(), libMesh::Elem::parent(), libMesh::MeshBase::prepare_for_use(), libMesh::DofObject::processor_id(), libMesh::remote_elem, libMesh::MeshBase::reserve_elem(), libMesh::MeshBase::reserve_nodes(), libMesh::Elem::set_interior_parent(), libMesh::Elem::set_neighbor(), libMesh::MeshBase::set_next_unique_id(), and libMesh::MeshBase::skip_partitioning().

Referenced by libMesh::DistributedMesh::DistributedMesh(), libMesh::ReplicatedMesh::ReplicatedMesh(), and stitching_helper().

656 {
657  LOG_SCOPE("copy_nodes_and_elements()", "UnstructuredMesh");
658 
659  std::pair<std::vector<unsigned int>, std::vector<unsigned int>>
660  extra_int_maps = this->merge_extra_integer_names(other_mesh);
661 
662  const unsigned int n_old_node_ints = extra_int_maps.second.size(),
663  n_new_node_ints = _node_integer_names.size(),
664  n_old_elem_ints = extra_int_maps.first.size(),
665  n_new_elem_ints = _elem_integer_names.size();
666 
667  // If we are partitioned into fewer parts than the incoming mesh,
668  // then we need to "wrap" the other Mesh's processor ids to fit
669  // within our range. This can happen, for example, while stitching
670  // meshes with small numbers of elements in parallel...
671  bool wrap_proc_ids = (this->n_partitions() <
672  other_mesh.n_partitions());
673 
674  // We're assuming the other mesh has proper element number ordering,
675  // so that we add parents before their children, and that the other
676  // mesh is consistently partitioned.
677 #ifdef DEBUG
679  MeshTools::libmesh_assert_valid_procids<Node>(other_mesh);
680 #endif
681 
682  //Copy in Nodes
683  {
684  //Preallocate Memory if necessary
685  this->reserve_nodes(other_mesh.n_nodes());
686 
687  for (const auto & oldn : other_mesh.node_ptr_range())
688  {
689  processor_id_type added_pid = cast_int<processor_id_type>
690  (wrap_proc_ids ? oldn->processor_id() % _n_parts : oldn->processor_id());
691 
692  // Add new nodes in old node Point locations
693  Node * newn =
694  this->add_point(*oldn,
695  oldn->id() + node_id_offset,
696  added_pid);
697 
698  newn->add_extra_integers(n_new_node_ints);
699  for (unsigned int i = 0; i != n_old_node_ints; ++i)
700  newn->set_extra_integer(extra_int_maps.second[i],
701  oldn->get_extra_integer(i));
702 
703 #ifdef LIBMESH_ENABLE_UNIQUE_ID
704  newn->set_unique_id(oldn->unique_id() + unique_id_offset);
705 #endif
706  }
707  }
708 
709  //Copy in Elements
710  {
711  //Preallocate Memory if necessary
712  this->reserve_elem(other_mesh.n_elem());
713 
714  // Declare a map linking old and new elements, needed to copy the neighbor lists
715  typedef std::unordered_map<const Elem *, Elem *> map_type;
716  map_type old_elems_to_new_elems, ip_map;
717 
718  // Loop over the elements
719  for (const auto & old : other_mesh.element_ptr_range())
720  {
721  // Build a new element
722  Elem * newparent = old->parent() ?
723  this->elem_ptr(old->parent()->id() + element_id_offset) :
724  nullptr;
725  auto el = Elem::build(old->type(), newparent);
726 
727  subdomain_id_type sbd_id = old->subdomain_id();
728  if (id_remapping)
729  {
730  auto remapping_it = id_remapping->find(sbd_id);
731  if (remapping_it != id_remapping->end())
732  sbd_id = remapping_it->second;
733  }
734  el->subdomain_id() = sbd_id;
735 
736  // Hold off on trying to set the interior parent because we may actually
737  // add lower dimensional elements before their interior parents
738  if (el->dim() < other_mesh.mesh_dimension() && old->interior_parent())
739  ip_map[old] = el.get();
740 
741 #ifdef LIBMESH_ENABLE_AMR
742  if (old->has_children())
743  for (unsigned int c = 0, nc = old->n_children(); c != nc; ++c)
744  if (old->child_ptr(c) == remote_elem)
745  el->add_child(const_cast<RemoteElem *>(remote_elem), c);
746 
747  //Create the parent's child pointers if necessary
748  if (newparent)
749  {
750  unsigned int oldc = old->parent()->which_child_am_i(old);
751  newparent->add_child(el.get(), oldc);
752  }
753 
754  // Copy the refinement flags
755  el->set_refinement_flag(old->refinement_flag());
756 
757  // Use hack_p_level since we may not have sibling elements
758  // added yet
759  el->hack_p_level(old->p_level());
760 
761  el->set_p_refinement_flag(old->p_refinement_flag());
762 #endif // #ifdef LIBMESH_ENABLE_AMR
763 
764  //Assign all the nodes
765  for (auto i : el->node_index_range())
766  el->set_node(i) =
767  this->node_ptr(old->node_id(i) + node_id_offset);
768 
769  // And start it off with the same processor id (mod _n_parts).
770  el->processor_id() = cast_int<processor_id_type>
771  (wrap_proc_ids ? old->processor_id() % _n_parts : old->processor_id());
772 
773  // Give it the same element and unique ids
774  el->set_id(old->id() + element_id_offset);
775 
776  el->add_extra_integers(n_new_elem_ints);
777  for (unsigned int i = 0; i != n_old_elem_ints; ++i)
778  el->set_extra_integer(extra_int_maps.first[i],
779  old->get_extra_integer(i));
780 
781 #ifdef LIBMESH_ENABLE_UNIQUE_ID
782  el->set_unique_id(old->unique_id() + unique_id_offset);
783 #endif
784 
785  el->set_mapping_type(old->mapping_type());
786  el->set_mapping_data(old->mapping_data());
787 
788  //Hold onto it
789  if (!skip_find_neighbors)
790  {
791  for (auto s : old->side_index_range())
792  if (old->neighbor_ptr(s) == remote_elem)
793  el->set_neighbor(s, const_cast<RemoteElem *>(remote_elem));
794  this->add_elem(std::move(el));
795  }
796  else
797  {
798  Elem * new_el = this->add_elem(std::move(el));
799  old_elems_to_new_elems[old] = new_el;
800  }
801  }
802 
803  for (auto & elem_pair : ip_map)
804  elem_pair.second->set_interior_parent(
805  this->elem_ptr(elem_pair.first->interior_parent()->id() + element_id_offset));
806 
807  // Loop (again) over the elements to fill in the neighbors
808  if (skip_find_neighbors)
809  {
810  old_elems_to_new_elems[remote_elem] = const_cast<RemoteElem*>(remote_elem);
811 
812  for (const auto & old_elem : other_mesh.element_ptr_range())
813  {
814  Elem * new_elem = old_elems_to_new_elems[old_elem];
815  for (auto s : old_elem->side_index_range())
816  {
817  const Elem * old_neighbor = old_elem->neighbor_ptr(s);
818  Elem * new_neighbor = old_elems_to_new_elems[old_neighbor];
819  new_elem->set_neighbor(s, new_neighbor);
820  }
821  }
822  }
823  }
824 
825 #ifdef LIBMESH_ENABLE_UNIQUE_ID
826  // We set the unique ids of nodes after adding them to the mesh such that our value of
827  // _next_unique_id may be wrong. So we amend that here
828  this->set_next_unique_id(other_mesh.parallel_max_unique_id() + unique_id_offset + 1);
829 #endif
830 
831  //Finally prepare the new Mesh for use. Keep the same numbering and
832  //partitioning for now.
833  this->allow_renumbering(false);
834  this->allow_remote_element_removal(false);
835  this->allow_find_neighbors(!skip_find_neighbors);
836 
837  // We should generally be able to skip *all* partitioning here
838  // because we're only adding one already-consistent mesh to another.
839  this->skip_partitioning(true);
840 
841  this->prepare_for_use();
842 
843  //But in the long term, use the same renumbering and partitioning
844  //policies as our source mesh.
845  this->allow_find_neighbors(other_mesh.allow_find_neighbors());
846  this->allow_renumbering(other_mesh.allow_renumbering());
848  this->skip_partitioning(other_mesh.skip_partitioning());
849 }
virtual void reserve_nodes(const dof_id_type nn)=0
Reserves space for a known number of nodes.
const Elem * parent() const
Definition: elem.h:2867
In parallel meshes where a ghost element has neighbors which do not exist on the local processor...
Definition: remote_elem.h:59
A Node is like a Point, but with more information.
Definition: node.h:52
virtual unique_id_type parallel_max_unique_id() const =0
std::vector< std::string > _elem_integer_names
The array of names for integer data associated with each element in the mesh.
Definition: mesh_base.h:1938
void allow_renumbering(bool allow)
If false is passed in then this mesh will no longer be renumbered when being prepared for use...
Definition: mesh_base.h:1173
void skip_partitioning(bool skip)
If true is passed in then nothing on this mesh will be (re)partitioned.
Definition: mesh_base.h:1231
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
void add_child(Elem *elem)
Adds a child pointer to the array of children of this element.
Definition: elem.C:1668
virtual void set_next_unique_id(unique_id_type id)=0
Sets the next available unique id to be used.
std::vector< std::string > _node_integer_names
The array of names for integer data associated with each node in the mesh.
Definition: mesh_base.h:1950
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
Add a new Node at Point p to the end of the vertex array, with processor_id procid.
void set_interior_parent(Elem *p)
Sets the pointer to the element&#39;s interior_parent.
Definition: elem.C:1056
unsigned int _n_parts
The number of partitions the mesh has.
Definition: mesh_base.h:1802
uint8_t processor_id_type
void allow_remote_element_removal(bool allow)
If false is passed in then this mesh will no longer have remote elements deleted when being prepared ...
Definition: mesh_base.h:1189
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
Definition: elem.C:273
bool allow_find_neighbors() const
Definition: mesh_base.h:1181
std::pair< std::vector< unsigned int >, std::vector< unsigned int > > merge_extra_integer_names(const MeshBase &other)
Merge extra-integer arrays from an other mesh.
Definition: mesh_base.C:1861
void libmesh_assert_valid_amr_elem_ids(const MeshBase &mesh)
A function for verifying that ids of elements are correctly sorted for AMR (parents have lower ids th...
Definition: mesh_tools.C:1193
void allow_find_neighbors(bool allow)
If false is passed then this mesh will no longer work to find element neighbors when being prepared f...
Definition: mesh_base.h:1180
bool allow_remote_element_removal() const
Definition: mesh_base.h:1190
void set_neighbor(const unsigned int i, Elem *n)
Assigns n as the neighbor.
Definition: elem.h:2427
void prepare_for_use()
Definition: mesh_base.C:742
bool skip_partitioning() const
Definition: mesh_base.h:1233
unsigned int n_partitions() const
Definition: mesh_base.h:1322
virtual const Elem * elem_ptr(const dof_id_type i) const =0
const Elem * neighbor_ptr(unsigned int i) const
Definition: elem.h:2407
void add_extra_integers(const unsigned int n_integers)
Assigns a set of extra integers to this DofObject.
Definition: dof_object.C:490
unsigned int mesh_dimension() const
Definition: mesh_base.C:324
bool allow_renumbering() const
Definition: mesh_base.h:1174
virtual dof_id_type n_elem() const =0
virtual const Node * node_ptr(const dof_id_type i) const =0
processor_id_type processor_id() const
Definition: dof_object.h:898
virtual void reserve_elem(const dof_id_type ne)=0
Reserves space for a known number of elements.
virtual dof_id_type n_nodes() const =0
const RemoteElem * remote_elem
Definition: remote_elem.C:54

◆ create_pid_mesh()

void libMesh::UnstructuredMesh::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.

This mesh is written to the pid_mesh reference which you must create and pass to the function.

Definition at line 1275 of file unstructured_mesh.C.

References create_submesh(), libMesh::ParallelObject::n_processors(), and libMesh::out.

1277 {
1278 
1279  // Issue a warning if the number the number of processors
1280  // currently available is less that that requested for
1281  // partitioning. This is not necessarily an error since
1282  // you may run on one processor and still partition the
1283  // mesh into several partitions.
1284 #ifdef DEBUG
1285  if (this->n_processors() < pid)
1286  {
1287  libMesh::out << "WARNING: You are creating a "
1288  << "mesh for a processor id (="
1289  << pid
1290  << ") greater than "
1291  << "the number of processors available for "
1292  << "the calculation. (="
1293  << this->n_processors()
1294  << ")."
1295  << std::endl;
1296  }
1297 #endif
1298 
1299  this->create_submesh (pid_mesh,
1300  this->active_pid_elements_begin(pid),
1301  this->active_pid_elements_end(pid));
1302 }
processor_id_type n_processors() const
OStreamProxy out
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...

◆ create_submesh()

void libMesh::UnstructuredMesh::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 and it_end and adding them to the new mesh.

Definition at line 1310 of file unstructured_mesh.C.

References libMesh::MeshBase::_elem_integer_names, libMesh::MeshBase::_node_integer_names, libMesh::MeshBase::add_elem(), libMesh::DofObject::add_extra_integers(), libMesh::MeshBase::add_point(), libMesh::BoundaryInfo::add_side(), libMesh::as_range(), libMesh::BoundaryInfo::boundary_ids(), libMesh::Elem::build(), libMesh::MeshBase::clear(), libMesh::MeshBase::delete_remote_elements(), libMesh::MeshBase::get_boundary_info(), libMesh::MeshBase::is_serial(), libMesh::libmesh_assert(), libMesh::MeshBase::merge_extra_integer_names(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::MeshBase::node_ptr(), libMesh::MeshBase::prepare_for_use(), libMesh::MeshBase::query_node_ptr(), libMesh::DofObject::set_extra_integer(), libMesh::Elem::set_node(), and libMesh::DofObject::set_unique_id().

Referenced by create_pid_mesh().

1313 {
1314  // Just in case the subdomain_mesh already has some information
1315  // in it, get rid of it.
1316  new_mesh.clear();
1317 
1318  // If we're not serial, our submesh isn't either.
1319  // There are no remote elements to delete on an empty mesh, but
1320  // calling the method to do so marks the mesh as parallel.
1321  if (!this->is_serial())
1322  new_mesh.delete_remote_elements();
1323 
1324  // Fail if (*this == new_mesh), we cannot create a submesh inside ourself!
1325  // This may happen if the user accidentally passes the original mesh into
1326  // this function! We will check this by making sure we did not just
1327  // clear ourself.
1328  libmesh_assert_not_equal_to (this->n_nodes(), 0);
1329  libmesh_assert_not_equal_to (this->n_elem(), 0);
1330 
1331  // Container to catch boundary IDs handed back by BoundaryInfo
1332  std::vector<boundary_id_type> bc_ids;
1333 
1334  // Put any extra integers on the new mesh too
1335  new_mesh.merge_extra_integer_names(*this);
1336  const unsigned int n_node_ints = _node_integer_names.size(),
1337  n_elem_ints = _elem_integer_names.size();
1338 
1339  for (const auto & old_elem : as_range(it, it_end))
1340  {
1341  // Add an equivalent element type to the new_mesh.
1342  // Copy ids for this element.
1343  auto uelem = Elem::build(old_elem->type());
1344  uelem->set_id() = old_elem->id();
1345 #ifdef LIBMESH_ENABLE_UNIQUE_ID
1346  uelem->set_unique_id(old_elem->unique_id());
1347 #endif
1348  uelem->subdomain_id() = old_elem->subdomain_id();
1349  uelem->processor_id() = old_elem->processor_id();
1350 
1351  uelem->add_extra_integers(n_elem_ints);
1352  for (unsigned int i = 0; i != n_elem_ints; ++i)
1353  uelem->set_extra_integer(i, old_elem->get_extra_integer(i));
1354 
1355  uelem->set_mapping_type(old_elem->mapping_type());
1356  uelem->set_mapping_data(old_elem->mapping_data());
1357 
1358  Elem * new_elem = new_mesh.add_elem(std::move(uelem));
1359 
1360  libmesh_assert(new_elem);
1361 
1362  // Loop over the nodes on this element.
1363  for (auto n : old_elem->node_index_range())
1364  {
1365  const dof_id_type this_node_id = old_elem->node_id(n);
1366 
1367  // Add this node to the new mesh if it's not there already
1368  if (!new_mesh.query_node_ptr(this_node_id))
1369  {
1370  Node * newn =
1371  new_mesh.add_point (old_elem->point(n),
1372  this_node_id,
1373  old_elem->node_ptr(n)->processor_id());
1374 
1375  newn->add_extra_integers(n_node_ints);
1376  for (unsigned int i = 0; i != n_node_ints; ++i)
1377  newn->set_extra_integer(i, old_elem->node_ptr(n)->get_extra_integer(i));
1378 
1379 #ifdef LIBMESH_ENABLE_UNIQUE_ID
1380  newn->set_unique_id(old_elem->node_ptr(n)->unique_id());
1381 #endif
1382  }
1383 
1384  // Define this element's connectivity on the new mesh
1385  new_elem->set_node(n) = new_mesh.node_ptr(this_node_id);
1386  }
1387 
1388  // Maybe add boundary conditions for this element
1389  for (auto s : old_elem->side_index_range())
1390  {
1391  this->get_boundary_info().boundary_ids(old_elem, s, bc_ids);
1392  new_mesh.get_boundary_info().add_side (new_elem, s, bc_ids);
1393  }
1394  } // end loop over elements
1395 
1396  // Prepare the new_mesh for use
1397  new_mesh.prepare_for_use();
1398 }
unique_id_type & set_unique_id()
Definition: dof_object.h:852
virtual Node *& set_node(const unsigned int i)
Definition: elem.h:2381
A Node is like a Point, but with more information.
Definition: node.h:52
std::vector< std::string > _elem_integer_names
The array of names for integer data associated with each element in the mesh.
Definition: mesh_base.h:1938
void prepare_for_use(const bool skip_renumber_nodes_and_elements, const bool skip_find_neighbors)
Prepare a newly ecreated (or read) mesh for use.
Definition: mesh_base.C:710
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
void boundary_ids(const Node *node, std::vector< boundary_id_type > &vec_to_fill) const
Fills a user-provided std::vector with the boundary ids associated with Node node.
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:159
std::vector< std::string > _node_integer_names
The array of names for integer data associated with each node in the mesh.
Definition: mesh_base.h:1950
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
Add a new Node at Point p to the end of the vertex array, with processor_id procid.
virtual bool is_serial() const
Definition: mesh_base.h:205
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
Definition: elem.C:273
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
Helper function that allows us to treat a homogenous pair as a range.
Definition: simple_range.h:57
virtual const Node * query_node_ptr(const dof_id_type i) const =0
libmesh_assert(ctx)
std::pair< std::vector< unsigned int >, std::vector< unsigned int > > merge_extra_integer_names(const MeshBase &other)
Merge extra-integer arrays from an other mesh.
Definition: mesh_base.C:1861
virtual void clear()
Deletes all the element and node data that is currently stored.
Definition: mesh_base.C:862
void add_side(const dof_id_type elem, const unsigned short int side, const boundary_id_type id)
Add side side of element number elem with boundary id id to the boundary information data structure...
void add_extra_integers(const unsigned int n_integers)
Assigns a set of extra integers to this DofObject.
Definition: dof_object.C:490
virtual void delete_remote_elements()
When supported, deletes all nonlocal elements of the mesh except for "ghosts" which touch a local ele...
Definition: mesh_base.h:247
virtual dof_id_type n_elem() const =0
virtual const Node * node_ptr(const dof_id_type i) const =0
void set_extra_integer(const unsigned int index, const dof_id_type value)
Sets the value on this object of the extra integer associated with index, which should have been obta...
Definition: dof_object.h:1079
virtual dof_id_type n_nodes() const =0
uint8_t dof_id_type
Definition: id_types.h:67

◆ default_ghosting()

GhostingFunctor& libMesh::MeshBase::default_ghosting ( )
inlineinherited

Default ghosting functor.

Definition at line 1280 of file mesh_base.h.

References libMesh::MeshBase::_default_ghosting.

1280 { return *_default_ghosting; }
std::unique_ptr< GhostingFunctor > _default_ghosting
The default geometric GhostingFunctor, used to implement standard libMesh element ghosting behavior...
Definition: mesh_base.h:1982

◆ default_mapping_data()

unsigned char libMesh::MeshBase::default_mapping_data ( ) const
inlineinherited

Returns any default data value used by the master space to physical space mapping.

Definition at line 809 of file mesh_base.h.

References libMesh::MeshBase::_default_mapping_data.

Referenced by libMesh::ReplicatedMesh::add_elem(), libMesh::DistributedMesh::add_elem(), MeshInputTest::helperTestingDynaQuad(), libMesh::ReplicatedMesh::insert_elem(), libMesh::DistributedMesh::insert_elem(), libMesh::VTKIO::nodes_to_vtk(), and MeshInputTest::testDynaReadPatch().

810  {
811  return _default_mapping_data;
812  }
unsigned char _default_mapping_data
The default mapping data (unused with Lagrange, used for nodal weight lookup index with rational base...
Definition: mesh_base.h:1815

◆ default_mapping_type()

ElemMappingType libMesh::MeshBase::default_mapping_type ( ) const
inlineinherited

Returns the default master space to physical space mapping basis functions to be used on newly added elements.

Definition at line 791 of file mesh_base.h.

References libMesh::MeshBase::_default_mapping_type.

Referenced by libMesh::ReplicatedMesh::add_elem(), libMesh::DistributedMesh::add_elem(), libMesh::VTKIO::cells_to_vtk(), MeshInputTest::helperTestingDynaQuad(), libMesh::ReplicatedMesh::insert_elem(), libMesh::DistributedMesh::insert_elem(), libMesh::VTKIO::nodes_to_vtk(), libMesh::VTKIO::read(), MeshInputTest::testDynaFileMappings(), MeshInputTest::testDynaReadPatch(), and MeshInputTest::testExodusFileMappings().

792  {
793  return _default_mapping_type;
794  }
ElemMappingType _default_mapping_type
The default mapping type (typically Lagrange) between master and physical space to assign to newly ad...
Definition: mesh_base.h:1808

◆ delete_elem()

virtual void libMesh::MeshBase::delete_elem ( Elem e)
pure virtualinherited

Removes element e from the mesh.

This method must be implemented in derived classes in such a way that it does not invalidate element iterators. Users should call MeshBase::prepare_for_use() after elements are added to and/or deleted from the mesh.

Note
Calling this method may produce isolated nodes, i.e. nodes not connected to any element.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

Referenced by libMesh::MeshTools::Modification::all_tri(), libMesh::MeshTools::clear_spline_nodes(), contract(), libMesh::TetGenMeshInterface::delete_2D_hull_elements(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::MeshTools::Modification::flatten(), libMesh::Poly2TriTriangulator::insert_refinement_points(), libMesh::TetGenMeshInterface::pointset_convexhull(), libMesh::AbaqusIO::read(), libMesh::UNVIO::read_implementation(), libMesh::GmshIO::read_mesh(), and MeshDeletionsTest::testDeleteElem().

◆ delete_node()

virtual void libMesh::MeshBase::delete_node ( Node n)
pure virtualinherited

◆ delete_remote_elements()

virtual void libMesh::MeshBase::delete_remote_elements ( )
inlinevirtualinherited

When supported, deletes all nonlocal elements of the mesh except for "ghosts" which touch a local element, and deletes all nodes which are not part of a local or ghost element.

Reimplemented in libMesh::DistributedMesh.

Definition at line 247 of file mesh_base.h.

Referenced by libMesh::MeshTools::Generation::build_extrusion(), create_submesh(), libMesh::MeshBase::prepare_for_use(), libMesh::Nemesis_IO::read(), libMesh::BoundaryInfo::sync(), PeriodicBCTest::testPeriodicBC(), and libMesh::MeshSerializer::~MeshSerializer().

247 {}

◆ detect_interior_parents()

void libMesh::MeshBase::detect_interior_parents ( )
inherited

Search the mesh for elements that have a neighboring element of dim+1 and set that element as the interior parent.

Definition at line 1729 of file mesh_base.C.

References dim, libMesh::MeshBase::elem_dimensions(), libMesh::MeshBase::elem_ptr(), libMesh::MeshBase::elem_ref(), libMesh::make_range(), and libMesh::MeshBase::max_elem_id().

Referenced by libMesh::MeshBase::prepare_for_use().

1730 {
1731  // This requires an inspection on every processor
1732  parallel_object_only();
1733 
1734  // Check if the mesh contains mixed dimensions. If so, then set interior parents, otherwise return.
1735  if (this->elem_dimensions().size() == 1)
1736  return;
1737 
1738  //This map will be used to set interior parents
1739  std::unordered_map<dof_id_type, std::vector<dof_id_type>> node_to_elem;
1740 
1741  for (const auto & elem : this->active_element_ptr_range())
1742  {
1743  // Populating the node_to_elem map, same as MeshTools::build_nodes_to_elem_map
1744  for (auto n : make_range(elem->n_vertices()))
1745  {
1746  libmesh_assert_less (elem->id(), this->max_elem_id());
1747 
1748  node_to_elem[elem->node_id(n)].push_back(elem->id());
1749  }
1750  }
1751 
1752  // Automatically set interior parents
1753  for (const auto & element : this->element_ptr_range())
1754  {
1755  // Ignore an 3D element or an element that already has an interior parent
1756  if (element->dim()>=LIBMESH_DIM || element->interior_parent())
1757  continue;
1758 
1759  // Start by generating a SET of elements that are dim+1 to the current
1760  // element at each vertex of the current element, thus ignoring interior nodes.
1761  // If one of the SET of elements is empty, then we will not have an interior parent
1762  // since an interior parent must be connected to all vertices of the current element
1763  std::vector<std::set<dof_id_type>> neighbors( element->n_vertices() );
1764 
1765  bool found_interior_parents = false;
1766 
1767  for (auto n : make_range(element->n_vertices()))
1768  {
1769  std::vector<dof_id_type> & element_ids = node_to_elem[element->node_id(n)];
1770  for (const auto & eid : element_ids)
1771  if (this->elem_ref(eid).dim() == element->dim()+1)
1772  neighbors[n].insert(eid);
1773 
1774  if (neighbors[n].size()>0)
1775  {
1776  found_interior_parents = true;
1777  }
1778  else
1779  {
1780  // We have found an empty set, no reason to continue
1781  // Ensure we set this flag to false before the break since it could have
1782  // been set to true for previous vertex
1783  found_interior_parents = false;
1784  break;
1785  }
1786  }
1787 
1788  // If we have successfully generated a set of elements for each vertex, we will compare
1789  // the set for vertex 0 will the sets for the vertices until we find a id that exists in
1790  // all sets. If found, this is our an interior parent id. The interior parent id found
1791  // will be the lowest element id if there is potential for multiple interior parents.
1792  if (found_interior_parents)
1793  {
1794  std::set<dof_id_type> & neighbors_0 = neighbors[0];
1795  for (const auto & interior_parent_id : neighbors_0)
1796  {
1797  found_interior_parents = false;
1798  for (auto n : make_range(1u, element->n_vertices()))
1799  {
1800  if (neighbors[n].find(interior_parent_id)!=neighbors[n].end())
1801  {
1802  found_interior_parents=true;
1803  }
1804  else
1805  {
1806  found_interior_parents=false;
1807  break;
1808  }
1809  }
1810  if (found_interior_parents)
1811  {
1812  element->set_interior_parent(this->elem_ptr(interior_parent_id));
1813  break;
1814  }
1815  }
1816  }
1817  }
1818 }
unsigned int dim
virtual dof_id_type max_elem_id() const =0
const std::set< unsigned char > & elem_dimensions() const
Definition: mesh_base.h:276
virtual const Elem * elem_ptr(const dof_id_type i) const =0
virtual const Elem & elem_ref(const dof_id_type i) const
Definition: mesh_base.h:618
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134

◆ elem_dimensions()

const std::set<unsigned char>& libMesh::MeshBase::elem_dimensions ( ) const
inlineinherited
Returns
A const reference to a std::set of element dimensions present in the mesh.

Definition at line 276 of file mesh_base.h.

References libMesh::MeshBase::_elem_dims.

Referenced by libMesh::System::calculate_norm(), libMesh::MeshBase::detect_interior_parents(), libMesh::TreeNode< N >::insert(), and libMesh::RBEIMEvaluation::project_qp_data_map_onto_system().

277  { return _elem_dims; }
std::set< unsigned char > _elem_dims
We cache the dimension of the elements present in the mesh.
Definition: mesh_base.h:1895

◆ elem_ptr() [1/2]

virtual const Elem* libMesh::MeshBase::elem_ptr ( const dof_id_type  i) const
pure virtualinherited
Returns
A pointer to the \( i^{th} \) element, which should be present in this processor's subset of the mesh data structure.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

Referenced by libMesh::MeshTools::Subdivision::add_boundary_ghosts(), libMesh::BoundaryInfo::add_edge(), libMesh::BoundaryInfo::add_elements(), libMesh::BoundaryInfo::add_shellface(), libMesh::BoundaryInfo::add_side(), AllSecondOrderTest::allCompleteOrderMixed(), AllSecondOrderTest::allCompleteOrderRange(), AllSecondOrderTest::allSecondOrderMixed(), AllSecondOrderTest::allSecondOrderRange(), libMesh::connect_families(), libMesh::MeshBase::copy_constraint_rows(), copy_nodes_and_elements(), libMesh::MeshBase::detect_interior_parents(), libMesh::DTKAdapter::DTKAdapter(), libMesh::MeshBase::elem_ref(), libMesh::DTKEvaluator::evaluate(), libMesh::ExodusII_IO_Helper::get_sideset_data_indices(), libMesh::UNVIO::groups_in(), libMesh::ErrorVector::is_active_elem(), libMesh::MeshTools::libmesh_assert_valid_constraint_rows(), main(), LinearElasticityWithContact::move_mesh(), AugmentSparsityOnNodes::operator()(), libMesh::BoundaryInfo::operator=(), libMesh::BoundaryInfo::parallel_sync_side_ids(), libMesh::DofMap::process_mesh_constraint_rows(), libMesh::query_ghosting_functors(), libMesh::Nemesis_IO::read(), libMesh::ExodusII_IO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::ExodusII_IO_Helper::read_edge_blocks(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::ExodusII_IO_Helper::read_sideset_data(), stitching_helper(), VolumeTest::testHex20PLevelTrueCentroid(), InfFERadialTest::testInfQuants(), InfFERadialTest::testInfQuants_numericDeriv(), InfFERadialTest::testRefinement(), EquationSystemsTest::testRefineThenReinitPreserveFlags(), InfFERadialTest::testSides(), InfFERadialTest::testSingleOrder(), VolumeTest::testTwistedVolume(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO_Helper::write_sideset_data(), and libMesh::ExodusII_IO_Helper::write_sidesets().

◆ elem_ptr() [2/2]

virtual Elem* libMesh::MeshBase::elem_ptr ( const dof_id_type  i)
pure virtualinherited
Returns
A writable pointer to the \( i^{th} \) element, which should be present in this processor's subset of the mesh data structure.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

◆ elem_ref() [1/2]

virtual const Elem& libMesh::MeshBase::elem_ref ( const dof_id_type  i) const
inlinevirtualinherited
Returns
A reference to the \( i^{th} \) element, which should be present in this processor's subset of the mesh data structure.

Definition at line 618 of file mesh_base.h.

References libMesh::MeshBase::elem_ptr().

Referenced by libMesh::SyncRefinementFlags::act_on_data(), libMesh::SyncSubdomainIds::act_on_data(), libMesh::SyncElementIntegers::act_on_data(), libMesh::AbaqusIO::assign_sideset_ids(), libMesh::AbaqusIO::assign_subdomain_ids(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::MeshBase::detect_interior_parents(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_sides(), libMesh::SyncRefinementFlags::gather_data(), libMesh::SyncSubdomainIds::gather_data(), libMesh::SyncElementIntegers::gather_data(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), ExodusTest< elem_type >::meshes_equal_enough(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectVertices::operator()(), libMesh::RBParametrizedFunction::preevaluate_parametrized_function_on_mesh(), libMesh::RBParametrizedFunction::preevaluate_parametrized_function_on_mesh_sides(), libMesh::ExodusII_IO::read(), libMesh::CheckpointIO::read_remote_elem(), SystemsTest::testDofCouplingWithVarGroups(), MeshExtruderTest::testExtruder(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::FroIO::write(), libMesh::Nemesis_IO_Helper::write_elements(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::GmshIO::write_mesh(), and libMesh::ExodusII_IO_Helper::write_sidesets().

619  {
620  return *this->elem_ptr(i);
621  }
virtual const Elem * elem_ptr(const dof_id_type i) const =0

◆ elem_ref() [2/2]

virtual Elem& libMesh::MeshBase::elem_ref ( const dof_id_type  i)
inlinevirtualinherited
Returns
A writable reference to the \( i^{th} \) element, which should be present in this processor's subset of the mesh data structure.

Definition at line 628 of file mesh_base.h.

References libMesh::MeshBase::elem_ptr().

629  {
630  return *this->elem_ptr(i);
631  }
virtual const Elem * elem_ptr(const dof_id_type i) const =0

◆ find_neighbors()

void libMesh::UnstructuredMesh::find_neighbors ( const bool  reset_remote_elements = false,
const bool  reset_current_list = true 
)
overridevirtual

Other functions from MeshBase requiring re-definition.

Here we look at all of the child elements which don't already have valid neighbors.

If a child element has a nullptr neighbor it is either because it is on the boundary or because its neighbor is at a different level. In the latter case we must get the neighbor from the parent.

If a child element has a remote_elem neighbor on a boundary it shares with its parent, that info may have become out-dated through coarsening of the neighbor's parent. In this case, if the parent's neighbor is active then the child should share it.

Furthermore, that neighbor better be active, otherwise we missed a child somewhere.

We also need to look through children ordered by increasing refinement level in order to add new interior_parent() links in boundary elements which have just been generated by refinement, and fix links in boundary elements whose previous interior_parent() has just been coarsened away.

Implements libMesh::MeshBase.

Definition at line 864 of file unstructured_mesh.C.

References libMesh::Elem::active(), libMesh::Elem::ancestor(), libMesh::as_range(), libMesh::Elem::child_ptr(), libMesh::Elem::child_ref_range(), libMesh::err, libMesh::Elem::has_children(), libMesh::Elem::hmin(), libMesh::DofObject::id(), libMesh::Elem::interior_parent(), libMesh::Elem::is_ancestor_of(), libMesh::Elem::is_child_on_side(), libMesh::Elem::level(), libMesh::libmesh_assert(), libMesh::MeshTools::libmesh_assert_valid_amr_interior_parents(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::Elem::n_children(), libMesh::MeshTools::n_levels(), libMesh::Elem::neighbor_ptr(), libMesh::Elem::neighbor_ptr_range(), libMesh::Elem::parent(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::Real, libMesh::remote_elem, libMesh::Elem::set_interior_parent(), libMesh::Elem::set_neighbor(), libMesh::Elem::side_ptr(), libMesh::Elem::subactive(), libMesh::TOLERANCE, libMesh::Elem::vertex_average(), libMesh::Elem::which_child_am_i(), and libMesh::NameBasedIO::write().

Referenced by libMesh::TriangleWrapper::copy_tri_to_mesh(), and libMesh::Poly2TriTriangulator::insert_refinement_points().

866 {
867  // We might actually want to run this on an empty mesh
868  // (e.g. the boundary mesh for a nonexistent bcid!)
869  // libmesh_assert_not_equal_to (this->n_nodes(), 0);
870  // libmesh_assert_not_equal_to (this->n_elem(), 0);
871 
872  // This function must be run on all processors at once
873  parallel_object_only();
874 
875  LOG_SCOPE("find_neighbors()", "Mesh");
876 
877  //TODO:[BSK] This should be removed later?!
878  if (reset_current_list)
879  for (const auto & e : this->element_ptr_range())
880  for (auto s : e->side_index_range())
881  if (e->neighbor_ptr(s) != remote_elem || reset_remote_elements)
882  e->set_neighbor(s, nullptr);
883 
884  // Find neighboring elements by first finding elements
885  // with identical side keys and then check to see if they
886  // are neighbors
887  {
888  // data structures -- Use the hash_multimap if available
889  typedef dof_id_type key_type;
890  typedef std::pair<Elem *, unsigned char> val_type;
891  typedef std::unordered_multimap<key_type, val_type> map_type;
892 
893  // A map from side keys to corresponding elements & side numbers
894  map_type side_to_elem_map;
895 
896  // Pull objects out of the loop to reduce heap operations
897  std::unique_ptr<Elem> my_side, their_side;
898 
899  for (const auto & element : this->element_ptr_range())
900  {
901  for (auto ms : element->side_index_range())
902  {
903  next_side:
904  // If we haven't yet found a neighbor on this side, try.
905  // Even if we think our neighbor is remote, that
906  // information may be out of date.
907  if (element->neighbor_ptr(ms) == nullptr ||
908  element->neighbor_ptr(ms) == remote_elem)
909  {
910  // Get the key for the side of this element. Use the
911  // low_order_key so we can find neighbors in
912  // mixed-order meshes if necessary.
913  const dof_id_type key = element->low_order_key(ms);
914 
915  // Look for elements that have an identical side key
916  auto bounds = side_to_elem_map.equal_range(key);
917 
918  // May be multiple keys, check all the possible
919  // elements which _might_ be neighbors.
920  if (bounds.first != bounds.second)
921  {
922  // Get the side for this element
923  element->side_ptr(my_side, ms);
924 
925  // Look at all the entries with an equivalent key
926  while (bounds.first != bounds.second)
927  {
928  // Get the potential element
929  Elem * neighbor = bounds.first->second.first;
930 
931  // Get the side for the neighboring element
932  const unsigned int ns = bounds.first->second.second;
933  neighbor->side_ptr(their_side, ns);
934  //libmesh_assert(my_side.get());
935  //libmesh_assert(their_side.get());
936 
937  // If found a match with my side
938  //
939  // In 1D, since parents and children have an
940  // equal side (i.e. a node) we need to check
941  // for matching level() to avoid setting our
942  // neighbor pointer to any of our neighbor's
943  // descendants.
944  if ((*my_side == *their_side) &&
945  (element->level() == neighbor->level()))
946  {
947  // So share a side. Is this a mixed pair
948  // of subactive and active/ancestor
949  // elements?
950  // If not, then we're neighbors.
951  // If so, then the subactive's neighbor is
952 
953  if (element->subactive() ==
954  neighbor->subactive())
955  {
956  // an element is only subactive if it has
957  // been coarsened but not deleted
958  element->set_neighbor (ms,neighbor);
959  neighbor->set_neighbor(ns,element);
960  }
961  else if (element->subactive())
962  {
963  element->set_neighbor(ms,neighbor);
964  }
965  else if (neighbor->subactive())
966  {
967  neighbor->set_neighbor(ns,element);
968  }
969  side_to_elem_map.erase (bounds.first);
970 
971  // get out of this nested crap
972  goto next_side;
973  }
974 
975  ++bounds.first;
976  }
977  }
978 
979  // didn't find a match...
980  // Build the map entry for this element
981  side_to_elem_map.emplace
982  (key, std::make_pair(element, cast_int<unsigned char>(ms)));
983  }
984  }
985  }
986  }
987 
988 #ifdef LIBMESH_ENABLE_AMR
989 
1017  const unsigned int n_levels = MeshTools::n_levels(*this);
1018  for (unsigned int level = 1; level < n_levels; ++level)
1019  {
1020  for (auto & current_elem : as_range(level_elements_begin(level),
1021  level_elements_end(level)))
1022  {
1023  libmesh_assert(current_elem);
1024  Elem * parent = current_elem->parent();
1025  libmesh_assert(parent);
1026  const unsigned int my_child_num = parent->which_child_am_i(current_elem);
1027 
1028  for (auto s : current_elem->side_index_range())
1029  {
1030  if (current_elem->neighbor_ptr(s) == nullptr ||
1031  (current_elem->neighbor_ptr(s) == remote_elem &&
1032  parent->is_child_on_side(my_child_num, s)))
1033  {
1034  Elem * neigh = parent->neighbor_ptr(s);
1035 
1036  // If neigh was refined and had non-subactive children
1037  // made remote earlier, then our current elem should
1038  // actually have one of those remote children as a
1039  // neighbor
1040  if (neigh &&
1041  (neigh->ancestor() ||
1042  // If neigh has subactive children which should have
1043  // matched as neighbors of the current element but
1044  // did not, then those likewise must be remote
1045  // children.
1046  (current_elem->subactive() && neigh->has_children() &&
1047  (neigh->level()+1) == current_elem->level())))
1048  {
1049 #ifdef DEBUG
1050  // Let's make sure that "had children made remote"
1051  // situation is actually the case
1052  libmesh_assert(neigh->has_children());
1053  bool neigh_has_remote_children = false;
1054  for (auto & child : neigh->child_ref_range())
1055  if (&child == remote_elem)
1056  neigh_has_remote_children = true;
1057  libmesh_assert(neigh_has_remote_children);
1058 
1059  // And let's double-check that we don't have
1060  // a remote_elem neighboring an active local element
1061  if (current_elem->active())
1062  libmesh_assert_not_equal_to (current_elem->processor_id(),
1063  this->processor_id());
1064 #endif // DEBUG
1065  neigh = const_cast<RemoteElem *>(remote_elem);
1066  }
1067  // If neigh and current_elem are more than one level
1068  // apart, figuring out whether we have a remote
1069  // neighbor here becomes much harder.
1070  else if (neigh && (current_elem->subactive() &&
1071  neigh->has_children()))
1072  {
1073  // Find the deepest descendant of neigh which
1074  // we could consider for a neighbor. If we run
1075  // out of neigh children, then that's our
1076  // neighbor. If we find a potential neighbor
1077  // with remote_children and we don't find any
1078  // potential neighbors among its non-remote
1079  // children, then our neighbor must be remote.
1080  while (neigh != remote_elem &&
1081  neigh->has_children())
1082  {
1083  bool found_neigh = false;
1084  for (unsigned int c = 0, nc = neigh->n_children();
1085  !found_neigh && c != nc; ++c)
1086  {
1087  Elem * child = neigh->child_ptr(c);
1088  if (child == remote_elem)
1089  continue;
1090  for (auto ncn : child->neighbor_ptr_range())
1091  {
1092  if (ncn != remote_elem &&
1093  ncn->is_ancestor_of(current_elem))
1094  {
1095  neigh = ncn;
1096  found_neigh = true;
1097  break;
1098  }
1099  }
1100  }
1101  if (!found_neigh)
1102  neigh = const_cast<RemoteElem *>(remote_elem);
1103  }
1104  }
1105  current_elem->set_neighbor(s, neigh);
1106 #ifdef DEBUG
1107  if (neigh != nullptr && neigh != remote_elem)
1108  // We ignore subactive elements here because
1109  // we don't care about neighbors of subactive element.
1110  if ((!neigh->active()) && (!current_elem->subactive()))
1111  {
1112  libMesh::err << "On processor " << this->processor_id()
1113  << std::endl;
1114  libMesh::err << "Bad element ID = " << current_elem->id()
1115  << ", Side " << s << ", Bad neighbor ID = " << neigh->id() << std::endl;
1116  libMesh::err << "Bad element proc_ID = " << current_elem->processor_id()
1117  << ", Bad neighbor proc_ID = " << neigh->processor_id() << std::endl;
1118  libMesh::err << "Bad element size = " << current_elem->hmin()
1119  << ", Bad neighbor size = " << neigh->hmin() << std::endl;
1120  libMesh::err << "Bad element center = " << current_elem->vertex_average()
1121  << ", Bad neighbor center = " << neigh->vertex_average() << std::endl;
1122  libMesh::err << "ERROR: "
1123  << (current_elem->active()?"Active":"Ancestor")
1124  << " Element at level "
1125  << current_elem->level() << std::endl;
1126  libMesh::err << "with "
1127  << (parent->active()?"active":
1128  (parent->subactive()?"subactive":"ancestor"))
1129  << " parent share "
1130  << (neigh->subactive()?"subactive":"ancestor")
1131  << " neighbor at level " << neigh->level()
1132  << std::endl;
1133  NameBasedIO(*this).write ("bad_mesh.gmv");
1134  libmesh_error_msg("Problematic mesh written to bad_mesh.gmv.");
1135  }
1136 #endif // DEBUG
1137  }
1138  }
1139 
1140  // We can skip to the next element if we're full-dimension
1141  // and therefore don't have any interior parents
1142  if (current_elem->dim() >= LIBMESH_DIM)
1143  continue;
1144 
1145  // We have no interior parents unless we can find one later
1146  current_elem->set_interior_parent(nullptr);
1147 
1148  Elem * pip = parent->interior_parent();
1149 
1150  if (!pip)
1151  continue;
1152 
1153  // If there's no interior_parent children, whether due to a
1154  // remote element or a non-conformity, then there's no
1155  // children to search.
1156  if (pip == remote_elem || pip->active())
1157  {
1158  current_elem->set_interior_parent(pip);
1159  continue;
1160  }
1161 
1162  // For node comparisons we'll need a sensible tolerance
1163  Real node_tolerance = current_elem->hmin() * TOLERANCE;
1164 
1165  // Otherwise our interior_parent should be a child of our
1166  // parent's interior_parent.
1167  for (auto & child : pip->child_ref_range())
1168  {
1169  // If we have a remote_elem, that might be our
1170  // interior_parent. We'll set it provisionally now and
1171  // keep trying to find something better.
1172  if (&child == remote_elem)
1173  {
1174  current_elem->set_interior_parent
1175  (const_cast<RemoteElem *>(remote_elem));
1176  continue;
1177  }
1178 
1179  bool child_contains_our_nodes = true;
1180  for (auto & n : current_elem->node_ref_range())
1181  {
1182  bool child_contains_this_node = false;
1183  for (auto & cn : child.node_ref_range())
1184  if (cn.absolute_fuzzy_equals
1185  (n, node_tolerance))
1186  {
1187  child_contains_this_node = true;
1188  break;
1189  }
1190  if (!child_contains_this_node)
1191  {
1192  child_contains_our_nodes = false;
1193  break;
1194  }
1195  }
1196  if (child_contains_our_nodes)
1197  {
1198  current_elem->set_interior_parent(&child);
1199  break;
1200  }
1201  }
1202 
1203  // We should have found *some* interior_parent at this
1204  // point, whether semilocal or remote.
1205  libmesh_assert(current_elem->interior_parent());
1206  }
1207  }
1208 
1209 #endif // AMR
1210 
1211 
1212 #ifdef DEBUG
1214  !reset_remote_elements);
1216 #endif
1217 }
OStreamProxy err
This class supports simple reads and writes in any libMesh-supported format, by dispatching to one of...
Definition: namebased_io.h:44
const Elem * parent() const
Definition: elem.h:2867
In parallel meshes where a ghost element has neighbors which do not exist on the local processor...
Definition: remote_elem.h:59
bool is_ancestor_of(const Elem *descendant) const
Definition: elem.h:2846
void libmesh_assert_valid_amr_interior_parents(const MeshBase &mesh)
A function for verifying that any interior_parent pointers on elements are consistent with AMR (paren...
Definition: mesh_tools.C:1213
const Elem * interior_parent() const
Definition: elem.C:994
static constexpr Real TOLERANCE
virtual bool is_child_on_side(const unsigned int c, const unsigned int s) const =0
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
virtual unsigned int n_children() const =0
void set_interior_parent(Elem *p)
Sets the pointer to the element&#39;s interior_parent.
Definition: elem.C:1056
SimpleRange< ChildRefIter > child_ref_range()
Returns a range with all children of a parent element, usable in range-based for loops.
Definition: elem.h:2188
bool ancestor() const
Definition: elem.C:1634
dof_id_type id() const
Definition: dof_object.h:823
virtual Real hmin() const
Definition: elem.C:512
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
Helper function that allows us to treat a homogenous pair as a range.
Definition: simple_range.h:57
unsigned int n_levels(const MeshBase &mesh)
Definition: mesh_tools.C:801
virtual void write(const std::string &mesh_file) override
This method implements writing a mesh to a specified file.
Definition: namebased_io.C:310
libmesh_assert(ctx)
void set_neighbor(const unsigned int i, Elem *n)
Assigns n as the neighbor.
Definition: elem.h:2427
unsigned int which_child_am_i(const Elem *e) const
Definition: elem.h:3029
SimpleRange< NodeRefIter > node_ref_range()
Returns a range with all nodes of an element, usable in range-based for loops.
Definition: elem.h:2474
const Elem * neighbor_ptr(unsigned int i) const
Definition: elem.h:2407
unsigned int level() const
Definition: elem.h:2911
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual std::unique_ptr< Elem > side_ptr(unsigned int i)=0
bool subactive() const
Definition: elem.h:2796
SimpleRange< NeighborPtrIter > neighbor_ptr_range()
Returns a range with all neighbors of an element, usable in range-based for loops.
Definition: elem.h:3326
void libmesh_assert_valid_neighbors(const MeshBase &mesh, bool assert_valid_remote_elems=true)
A function for verifying that neighbor connectivity is correct (each element is a neighbor of or desc...
Definition: mesh_tools.C:2031
processor_id_type processor_id() const
bool active() const
Definition: elem.h:2778
processor_id_type processor_id() const
Definition: dof_object.h:898
bool has_children() const
Definition: elem.h:2816
Point vertex_average() const
Definition: elem.C:498
const Elem * child_ptr(unsigned int i) const
Definition: elem.h:3000
uint8_t dof_id_type
Definition: id_types.h:67
const RemoteElem * remote_elem
Definition: remote_elem.C:54

◆ fix_broken_node_and_element_numbering()

virtual void libMesh::MeshBase::fix_broken_node_and_element_numbering ( )
pure virtualinherited

There is no reason for a user to ever call this function.

This function restores a previously broken element/node numbering such that mesh.node_ref(n).id() == n.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

Referenced by libMesh::EquationSystems::read(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), and libMesh::RBEvaluation::write_out_vectors().

◆ gather_to_zero()

virtual void libMesh::MeshBase::gather_to_zero ( )
inlinevirtualinherited

Gathers all elements and nodes of the mesh onto processor zero.

Reimplemented in libMesh::DistributedMesh.

Definition at line 240 of file mesh_base.h.

Referenced by libMesh::MeshSerializer::MeshSerializer().

240 {}

◆ get_boundary_info() [1/2]

const BoundaryInfo& libMesh::MeshBase::get_boundary_info ( ) const
inlineinherited

The information about boundary ids on the mesh.

Definition at line 159 of file mesh_base.h.

References libMesh::MeshBase::boundary_info.

Referenced by libMesh::MeshRefinement::_coarsen_elements(), libMesh::MeshTools::Subdivision::add_boundary_ghosts(), all_first_order(), libMesh::MeshTools::Subdivision::all_subdivision(), libMesh::MeshTools::Modification::all_tri(), LinearElasticity::assemble(), HDGProblem::assemble(), assemble_elasticity(), assemble_poisson(), assemble_shell(), libMesh::AbaqusIO::assign_boundary_node_ids(), libMesh::AbaqusIO::assign_sideset_ids(), AssemblyA0::boundary_assembly(), AssemblyA1::boundary_assembly(), AssemblyF0::boundary_assembly(), AssemblyF1::boundary_assembly(), AssemblyA2::boundary_assembly(), AssemblyF2::boundary_assembly(), libMesh::MeshTools::Generation::build_delaunay_square(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::MeshTools::Modification::change_boundary_id(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::FEGenericBase< FEOutputType< T >::type >::compute_periodic_constraints(), libMesh::TriangleWrapper::copy_tri_to_mesh(), create_submesh(), libMesh::TetGenMeshInterface::delete_2D_hull_elements(), libMesh::ReplicatedMesh::delete_elem(), libMesh::DistributedMesh::delete_elem(), libMesh::ReplicatedMesh::delete_node(), libMesh::DistributedMesh::delete_node(), libMesh::DistributedMesh::DistributedMesh(), libMesh::MeshTools::Modification::flatten(), libMesh::MeshBase::get_info(), libMesh::UNVIO::groups_in(), HDGProblem::init(), libMesh::ExodusII_IO_Helper::initialize(), LinearElasticityWithContact::initialize_contact_load_paths(), libMesh::Poly2TriTriangulator::insert_refinement_points(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), main(), AugmentSparsityOnInterface::mesh_reinit(), libMesh::TriangulatorInterface::MeshedHole::MeshedHole(), libMesh::MeshTools::Modification::orient_elements(), libMesh::TetGenMeshInterface::pointset_convexhull(), libMesh::MeshBase::prepare_for_use(), libMesh::Nemesis_IO::prepare_to_write_nodal_data(), libMesh::AbaqusIO::read(), libMesh::Nemesis_IO::read(), libMesh::ExodusII_IO::read(), libMesh::CheckpointIO::read_bcs(), libMesh::ExodusII_IO_Helper::read_edge_blocks(), libMesh::CheckpointIO::read_header(), libMesh::GmshIO::read_mesh(), libMesh::CheckpointIO::read_nodesets(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_nodesets(), MeshStitchTest::renameAndShift(), libMesh::ReplicatedMesh::renumber_nodes_and_elements(), libMesh::DistributedMesh::renumber_nodes_and_elements(), libMesh::ReplicatedMesh::ReplicatedMesh(), SolidSystem::side_time_derivative(), libMesh::PetscDiffSolver::solve(), stitching_helper(), libMesh::BoundaryInfo::sync(), AllTriTest::test_helper_2D(), AllTriTest::test_helper_3D(), BoundaryInfoTest::testBoundaryOnChildrenBoundaryIDs(), BoundaryInfoTest::testBoundaryOnChildrenBoundarySides(), BoundaryInfoTest::testBoundaryOnChildrenElementsRefineCoarsen(), BoundaryInfoTest::testBoundaryOnChildrenErrors(), SystemsTest::testBoundaryProjectCube(), BoundaryInfoTest::testEdgeBoundaryConditions(), MeshInputTest::testExodusIGASidesets(), MeshInputTest::testLowOrderEdgeBlocks(), BoundaryInfoTest::testMesh(), BoundaryInfoTest::testNameCopying(), PeriodicBCTest::testPeriodicBC(), MeshTriangulationTest::testPoly2TriHolesInteriorRefinedBase(), BoundaryInfoTest::testRenumber(), BoundaryInfoTest::testShellFaceConstraints(), WriteNodesetData::testWriteImpl(), WriteEdgesetData::testWriteImpl(), WriteSidesetData::testWriteImpl(), libMesh::Poly2TriTriangulator::triangulate_current_points(), libMesh::FroIO::write(), libMesh::Nemesis_IO::write(), libMesh::XdrIO::write(), libMesh::CheckpointIO::write(), libMesh::ExodusII_IO::write(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::GmshIO::write_mesh(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_nodesets(), and libMesh::ExodusII_IO_Helper::write_sidesets().

159 { return *boundary_info; }
std::unique_ptr< BoundaryInfo > boundary_info
This class holds the boundary information.
Definition: mesh_base.h:1760

◆ get_boundary_info() [2/2]

BoundaryInfo& libMesh::MeshBase::get_boundary_info ( )
inlineinherited

Writable information about boundary ids on the mesh.

Definition at line 164 of file mesh_base.h.

References libMesh::MeshBase::boundary_info.

164 { return *boundary_info; }
std::unique_ptr< BoundaryInfo > boundary_info
This class holds the boundary information.
Definition: mesh_base.h:1760

◆ get_constraint_rows() [1/2]

constraint_rows_type& libMesh::MeshBase::get_constraint_rows ( )
inlineinherited

◆ get_constraint_rows() [2/2]

const constraint_rows_type& libMesh::MeshBase::get_constraint_rows ( ) const
inlineinherited

Definition at line 1686 of file mesh_base.h.

References libMesh::MeshBase::_constraint_rows.

1687  { return _constraint_rows; }
constraint_rows_type _constraint_rows
Definition: mesh_base.h:2009

◆ get_count_lower_dim_elems_in_point_locator()

bool libMesh::MeshBase::get_count_lower_dim_elems_in_point_locator ( ) const
inherited

Get the current value of _count_lower_dim_elems_in_point_locator.

Definition at line 1612 of file mesh_base.C.

References libMesh::MeshBase::_count_lower_dim_elems_in_point_locator.

Referenced by libMesh::TreeNode< N >::insert().

1613 {
1615 }
bool _count_lower_dim_elems_in_point_locator
Do we count lower dimensional elements in point locator refinement? This is relevant in tree-based po...
Definition: mesh_base.h:1835

◆ get_elem_integer_index()

unsigned int libMesh::MeshBase::get_elem_integer_index ( std::string_view  name) const
inherited

Definition at line 578 of file mesh_base.C.

References libMesh::MeshBase::_elem_integer_names, libMesh::index_range(), libMesh::invalid_uint, and libMesh::Quality::name().

Referenced by libMesh::MeshBase::change_elemset_code(), WriteElemsetData::checkElemsetCodes(), ExtraIntegersTest::testExtraIntegersExodusReading(), and libMesh::ExodusII_IO_Helper::write_elemsets().

579 {
580  for (auto i : index_range(_elem_integer_names))
581  if (_elem_integer_names[i] == name)
582  return i;
583 
584  libmesh_error_msg("Unknown elem integer " << name);
585  return libMesh::invalid_uint;
586 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
Definition: libmesh.h:286
std::vector< std::string > _elem_integer_names
The array of names for integer data associated with each element in the mesh.
Definition: mesh_base.h:1938
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:111

◆ get_elem_integer_name()

const std::string& libMesh::MeshBase::get_elem_integer_name ( unsigned int  i) const
inlineinherited

Definition at line 923 of file mesh_base.h.

References libMesh::MeshBase::_elem_integer_names.

Referenced by libMesh::XdrIO::write(), and libMesh::CheckpointIO::write().

924  { return _elem_integer_names[i]; }
std::vector< std::string > _elem_integer_names
The array of names for integer data associated with each element in the mesh.
Definition: mesh_base.h:1938

◆ get_elemset_code()

dof_id_type libMesh::MeshBase::get_elemset_code ( const MeshBase::elemset_type id_set) const
inherited

Definition at line 391 of file mesh_base.C.

References libMesh::MeshBase::_elemset_codes_inverse_map, and libMesh::DofObject::invalid_id.

Referenced by WriteElemsetData::checkElemsetCodes(), and libMesh::ExodusII_IO::read().

392 {
393  auto it = _elemset_codes_inverse_map.find(id_set);
394  return (it == _elemset_codes_inverse_map.end()) ? DofObject::invalid_id : it->second;
395 }
std::map< MeshBase::elemset_type, dof_id_type > _elemset_codes_inverse_map
Definition: mesh_base.h:1925
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:477

◆ get_elemset_codes()

std::vector< dof_id_type > libMesh::MeshBase::get_elemset_codes ( ) const
inherited

Return a vector of all elemset codes defined on the mesh.

We get this by looping over the _elemset_codes map.

Definition at line 397 of file mesh_base.C.

References libMesh::MeshBase::_elemset_codes.

Referenced by stitching_helper(), and libMesh::XdrIO::write().

398 {
399  std::vector<dof_id_type> ret;
400  ret.reserve(_elemset_codes.size());
401  for (const auto & pr : _elemset_codes)
402  ret.push_back(pr.first);
403  return ret;
404 }
std::map< dof_id_type, const MeshBase::elemset_type * > _elemset_codes
Map from "element set code" to list of set ids to which that element belongs (and vice-versa)...
Definition: mesh_base.h:1924

◆ get_elemsets()

void libMesh::MeshBase::get_elemsets ( dof_id_type  elemset_code,
MeshBase::elemset_type id_set_to_fill 
) const
inherited

Look up the element sets for a given elemset code and vice-versa.

The elemset must have been previously stored by calling add_elemset_code(). If no such code/set is found, returns the empty set or DofObject::invalid_id, respectively.

Definition at line 381 of file mesh_base.C.

References libMesh::MeshBase::_elemset_codes.

Referenced by stitching_helper(), WriteElemsetData::testWriteImpl(), libMesh::XdrIO::write(), and libMesh::ExodusII_IO_Helper::write_elemsets().

382 {
383  // If we don't recognize this elemset_code, hand back an empty set
384  id_set_to_fill.clear();
385 
386  auto it = _elemset_codes.find(elemset_code);
387  if (it != _elemset_codes.end())
388  id_set_to_fill.insert(it->second->begin(), it->second->end());
389 }
std::map< dof_id_type, const MeshBase::elemset_type * > _elemset_codes
Map from "element set code" to list of set ids to which that element belongs (and vice-versa)...
Definition: mesh_base.h:1924

◆ get_id_by_name()

subdomain_id_type libMesh::MeshBase::get_id_by_name ( std::string_view  name) const
inherited
Returns
The id of the named subdomain if it exists, Elem::invalid_subdomain_id otherwise.

Definition at line 1639 of file mesh_base.C.

References libMesh::MeshBase::_block_id_to_name, libMesh::Elem::invalid_subdomain_id, and libMesh::Quality::name().

1640 {
1641  // Linear search over the map values.
1642  std::map<subdomain_id_type, std::string>::const_iterator
1643  iter = _block_id_to_name.begin(),
1644  end_iter = _block_id_to_name.end();
1645 
1646  for ( ; iter != end_iter; ++iter)
1647  if (iter->second == name)
1648  return iter->first;
1649 
1650  // If we made it here without returning, we don't have a subdomain
1651  // with the requested name, so return Elem::invalid_subdomain_id.
1653 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
static const subdomain_id_type invalid_subdomain_id
A static integral constant representing an invalid subdomain id.
Definition: elem.h:238
std::map< subdomain_id_type, std::string > _block_id_to_name
This structure maintains the mapping of named blocks for file formats that support named blocks...
Definition: mesh_base.h:1888

◆ get_info()

std::string libMesh::MeshBase::get_info ( const unsigned int  verbosity = 0,
const bool  global = true 
) const
inherited
Returns
A string containing relevant information about the mesh.

verbosity sets the verbosity, with 0 being the least and 2 being the greatest. 0 - Dimensions, number of nodes, number of elems, number of subdomains, number of partitions, prepared status. 1 - Adds the mesh bounding box, mesh element types, specific nodesets/edgesets/sidesets with element types, number of nodes/edges/sides. 2 - Adds volume information and bounding boxes to boundary information.

The global parameter pertains primarily to verbosity levels 1 and above. When global == true, information is only output on rank 0 and the information is reduced. When global == false, information is output on all ranks that pertains only to that local partition.

Definition at line 1022 of file mesh_base.C.

References libMesh::MeshBase::_elem_dims, libMesh::MeshBase::_elemset_codes, libMesh::Elem::build_edge_ptr(), libMesh::ParallelObject::comm(), libMesh::MeshTools::create_bounding_box(), libMesh::MeshTools::create_local_bounding_box(), libMesh::MeshTools::elem_types(), libMesh::Utility::enum_to_string(), libMesh::MeshBase::get_boundary_info(), libMesh::BoundaryInfo::get_edge_boundary_ids(), libMesh::BoundaryInfo::get_edgeset_name_map(), libMesh::BoundaryInfo::get_node_boundary_ids(), libMesh::BoundaryInfo::get_nodeset_name_map(), libMesh::BoundaryInfo::get_side_boundary_ids(), libMesh::BoundaryInfo::get_sideset_name_map(), libMesh::MeshBase::get_subdomain_name_map(), libMesh::DofObject::id(), libMesh::DofObject::invalid_processor_id, libMesh::MeshBase::is_prepared(), libMesh::MeshBase::is_replicated(), libMesh::libmesh_assert(), libMesh::Elem::loose_bounding_box(), TIMPI::Communicator::max(), TIMPI::Communicator::min(), libMesh::MeshBase::n_active_elem(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_elemsets(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::MeshBase::n_local_subdomains(), libMesh::MeshBase::n_nodes(), libMesh::MeshBase::n_partitions(), libMesh::ParallelObject::n_processors(), libMesh::MeshBase::n_subdomains(), libMesh::n_threads(), libMesh::Quality::name(), libMesh::Elem::node_ref_range(), libMesh::ParallelObject::processor_id(), libMesh::Real, TIMPI::Communicator::set_union(), libMesh::MeshBase::spatial_dimension(), TIMPI::Communicator::sum(), libMesh::Elem::type(), libMesh::BoundingBox::union_with(), and libMesh::Elem::volume().

Referenced by libMesh::MeshBase::print_info().

1023 {
1024  std::ostringstream oss;
1025 
1026  oss << " Mesh Information:" << '\n';
1027 
1028  if (!_elem_dims.empty())
1029  {
1030  oss << " elem_dimensions()={";
1031  std::copy(_elem_dims.begin(),
1032  --_elem_dims.end(), // --end() is valid if the set is non-empty
1033  std::ostream_iterator<unsigned int>(oss, ", "));
1034  oss << cast_int<unsigned int>(*_elem_dims.rbegin());
1035  oss << "}\n";
1036  }
1037 
1038  oss << " spatial_dimension()=" << this->spatial_dimension() << '\n'
1039  << " n_nodes()=" << this->n_nodes() << '\n'
1040  << " n_local_nodes()=" << this->n_local_nodes() << '\n'
1041  << " n_elem()=" << this->n_elem() << '\n'
1042  << " n_local_elem()=" << this->n_local_elem() << '\n';
1043 #ifdef LIBMESH_ENABLE_AMR
1044  oss << " n_active_elem()=" << this->n_active_elem() << '\n';
1045 #endif
1046  if (global)
1047  oss << " n_subdomains()=" << static_cast<std::size_t>(this->n_subdomains()) << '\n';
1048  else
1049  oss << " n_local_subdomains()= " << static_cast<std::size_t>(this->n_local_subdomains()) << '\n';
1050  oss << " n_elemsets()=" << static_cast<std::size_t>(this->n_elemsets()) << '\n';
1051  if (!_elemset_codes.empty())
1052  oss << " n_elemset_codes=" << _elemset_codes.size() << '\n';
1053  oss << " n_partitions()=" << static_cast<std::size_t>(this->n_partitions()) << '\n'
1054  << " n_processors()=" << static_cast<std::size_t>(this->n_processors()) << '\n'
1055  << " n_threads()=" << static_cast<std::size_t>(libMesh::n_threads()) << '\n'
1056  << " processor_id()=" << static_cast<std::size_t>(this->processor_id()) << '\n'
1057  << " is_prepared()=" << (this->is_prepared() ? "true" : "false") << '\n'
1058  << " is_replicated()=" << (this->is_replicated() ? "true" : "false") << '\n';
1059 
1060  if (verbosity > 0)
1061  {
1062  if (global)
1063  {
1064  libmesh_parallel_only(this->comm());
1065  if (this->processor_id() != 0)
1066  oss << "\n Detailed global get_info() (verbosity > 0) is reduced and output to only rank 0.";
1067  }
1068 
1069  // Helper for printing element types
1070  const auto elem_type_helper = [](const std::set<int> & elem_types) {
1071  std::stringstream ss;
1072  for (auto it = elem_types.begin(); it != elem_types.end();)
1073  {
1074  ss << Utility::enum_to_string((ElemType)*it);
1075  if (++it != elem_types.end())
1076  ss << ", ";
1077  }
1078  return ss.str();
1079  };
1080 
1081  // Helper for whether or not the given DofObject is to be included. If we're doing
1082  // a global reduction, we also count unpartitioned objects on rank 0.
1083  const auto include_object = [this, &global](const DofObject & dof_object) {
1084  return this->processor_id() == dof_object.processor_id() ||
1085  (global &&
1086  this->processor_id() == 0 &&
1087  dof_object.processor_id() == DofObject::invalid_processor_id);
1088  };
1089 
1090  Real volume = 0;
1091 
1092  // Add bounding box information
1093  const auto bbox = global ? MeshTools::create_bounding_box(*this) : MeshTools::create_local_bounding_box(*this);
1094  if (!global || this->processor_id() == 0)
1095  oss << "\n " << (global ? "" : "Local ") << "Mesh Bounding Box:\n"
1096  << " Minimum: " << bbox.min() << "\n"
1097  << " Maximum: " << bbox.max() << "\n"
1098  << " Delta: " << (bbox.max() - bbox.min()) << "\n";
1099 
1100  // Obtain the global or local element types
1101  std::set<int> elem_types;
1102  for (const Elem * elem : this->active_local_element_ptr_range())
1103  elem_types.insert(elem->type());
1104  if (global)
1105  {
1106  // Pick up unpartitioned elems on rank 0
1107  if (this->processor_id() == 0)
1108  for (const Elem * elem : this->active_unpartitioned_element_ptr_range())
1109  elem_types.insert(elem->type());
1110 
1111  this->comm().set_union(elem_types);
1112  }
1113 
1114  // Add element types
1115  if (!global || this->processor_id() == 0)
1116  oss << "\n " << (global ? "" : "Local ") << "Mesh Element Type(s):\n "
1117  << elem_type_helper(elem_types) << "\n";
1118 
1119  // Reduce the nodeset ids
1120  auto nodeset_ids = this->get_boundary_info().get_node_boundary_ids();
1121  if (global)
1122  this->comm().set_union(nodeset_ids);
1123 
1124  // Accumulate local information for each nodeset
1125  struct NodesetInfo
1126  {
1127  std::size_t num_nodes = 0;
1128  BoundingBox bbox;
1129  };
1130  std::map<boundary_id_type, NodesetInfo> nodeset_info_map;
1131  for (const auto & [node, id] : this->get_boundary_info().get_nodeset_map())
1132  {
1133  if (!include_object(*node))
1134  continue;
1135 
1136  NodesetInfo & info = nodeset_info_map[id];
1137 
1138  ++info.num_nodes;
1139 
1140  if (verbosity > 1)
1141  info.bbox.union_with(*node);
1142  }
1143 
1144  // Add nodeset info
1145  if (!global || this->processor_id() == 0)
1146  {
1147  oss << "\n " << (global ? "" : "Local ") << "Mesh Nodesets:\n";
1148  if (nodeset_ids.empty())
1149  oss << " None\n";
1150  }
1151 
1152  const auto & nodeset_name_map = this->get_boundary_info().get_nodeset_name_map();
1153  for (const auto id : nodeset_ids)
1154  {
1155  NodesetInfo & info = nodeset_info_map[id];
1156 
1157  // Reduce the local information for this nodeset if required
1158  if (global)
1159  {
1160  this->comm().sum(info.num_nodes);
1161  if (verbosity > 1)
1162  {
1163  this->comm().min(info.bbox.min());
1164  this->comm().max(info.bbox.max());
1165  }
1166  }
1167 
1168  const bool has_name = nodeset_name_map.count(id) && nodeset_name_map.at(id).size();
1169  const std::string name = has_name ? nodeset_name_map.at(id) : "";
1170  if (global)
1171  libmesh_assert(this->comm().verify(name));
1172 
1173  if (global ? this->processor_id() == 0 : info.num_nodes > 0)
1174  {
1175  oss << " Nodeset " << id;
1176  if (has_name)
1177  oss << " (" << name << ")";
1178  oss << ", " << info.num_nodes << " " << (global ? "" : "local ") << "nodes\n";
1179 
1180  if (verbosity > 1)
1181  {
1182  oss << " " << (global ? "Bounding" : "Local bounding") << " box minimum: "
1183  << info.bbox.min() << "\n"
1184  << " " << (global ? "Bounding" : "Local bounding") << " box maximum: "
1185  << info.bbox.max() << "\n"
1186  << " " << (global ? "Bounding" : "Local bounding") << " box delta: "
1187  << (info.bbox.max() - info.bbox.min()) << "\n";
1188  }
1189  }
1190  }
1191 
1192  // Reduce the sideset ids
1193  auto sideset_ids = this->get_boundary_info().get_side_boundary_ids();
1194  if (global)
1195  this->comm().set_union(sideset_ids);
1196 
1197  // Accumulate local information for each sideset
1198  struct SidesetInfo
1199  {
1200  std::size_t num_sides = 0;
1201  Real volume = 0;
1202  std::set<int> side_elem_types;
1203  std::set<int> elem_types;
1204  std::set<dof_id_type> elem_ids;
1205  std::set<dof_id_type> node_ids;
1206  BoundingBox bbox;
1207  };
1208  ElemSideBuilder side_builder;
1209  std::map<boundary_id_type, SidesetInfo> sideset_info_map;
1210  for (const auto & pair : this->get_boundary_info().get_sideset_map())
1211  {
1212  const Elem * elem = pair.first;
1213  if (!include_object(*elem))
1214  continue;
1215 
1216  const auto id = pair.second.second;
1217  SidesetInfo & info = sideset_info_map[id];
1218 
1219  const auto s = pair.second.first;
1220  const Elem & side = side_builder(*elem, s);
1221 
1222  ++info.num_sides;
1223  info.side_elem_types.insert(side.type());
1224  info.elem_types.insert(elem->type());
1225  info.elem_ids.insert(elem->id());
1226 
1227  for (const Node & node : side.node_ref_range())
1228  if (include_object(node))
1229  info.node_ids.insert(node.id());
1230 
1231  if (verbosity > 1)
1232  {
1233  info.volume += side.volume();
1234  info.bbox.union_with(side.loose_bounding_box());
1235  }
1236  }
1237 
1238  // Add sideset info
1239  if (!global || this->processor_id() == 0)
1240  {
1241  oss << "\n " << (global ? "" : "Local ") << "Mesh Sidesets:\n";
1242  if (sideset_ids.empty())
1243  oss << " None\n";
1244  }
1245  const auto & sideset_name_map = this->get_boundary_info().get_sideset_name_map();
1246  for (const auto id : sideset_ids)
1247  {
1248  SidesetInfo & info = sideset_info_map[id];
1249 
1250  auto num_elems = info.elem_ids.size();
1251  auto num_nodes = info.node_ids.size();
1252 
1253  // Reduce the local information for this sideset if required
1254  if (global)
1255  {
1256  this->comm().sum(info.num_sides);
1257  this->comm().set_union(info.side_elem_types, 0);
1258  this->comm().sum(num_elems);
1259  this->comm().set_union(info.elem_types, 0);
1260  this->comm().sum(num_nodes);
1261  if (verbosity > 1)
1262  {
1263  this->comm().sum(info.volume);
1264  this->comm().min(info.bbox.min());
1265  this->comm().max(info.bbox.max());
1266  }
1267  }
1268 
1269  const bool has_name = sideset_name_map.count(id) && sideset_name_map.at(id).size();
1270  const std::string name = has_name ? sideset_name_map.at(id) : "";
1271  if (global)
1272  libmesh_assert(this->comm().verify(name));
1273 
1274  if (global ? this->processor_id() == 0 : info.num_sides > 0)
1275  {
1276  oss << " Sideset " << id;
1277  if (has_name)
1278  oss << " (" << name << ")";
1279  oss << ", " << info.num_sides << " sides (" << elem_type_helper(info.side_elem_types) << ")"
1280  << ", " << num_elems << " " << (global ? "" : "local ") << "elems (" << elem_type_helper(info.elem_types) << ")"
1281  << ", " << num_nodes << " " << (global ? "" : "local ") << "nodes\n";
1282 
1283  if (verbosity > 1)
1284  {
1285  oss << " " << (global ? "Side" : "Local side") << " volume: " << info.volume << "\n"
1286  << " " << (global ? "Bounding" : "Local bounding") << " box minimum: "
1287  << info.bbox.min() << "\n"
1288  << " " << (global ? "Bounding" : "Local bounding") << " box maximum: "
1289  << info.bbox.max() << "\n"
1290  << " " << (global ? "Bounding" : "Local bounding") << " box delta: "
1291  << (info.bbox.max() - info.bbox.min()) << "\n";
1292  }
1293  }
1294  }
1295 
1296  // Reduce the edgeset ids
1297  auto edgeset_ids = this->get_boundary_info().get_edge_boundary_ids();
1298  if (global)
1299  this->comm().set_union(edgeset_ids);
1300 
1301  // Accumulate local information for each edgeset
1302  struct EdgesetInfo
1303  {
1304  std::size_t num_edges = 0;
1305  std::set<int> edge_elem_types;
1306  BoundingBox bbox;
1307  };
1308  std::map<boundary_id_type, EdgesetInfo> edgeset_info_map;
1309  std::unique_ptr<const Elem> edge;
1310 
1311  for (const auto & pair : this->get_boundary_info().get_edgeset_map())
1312  {
1313  const Elem * elem = pair.first;
1314  if (!include_object(*elem))
1315  continue;
1316 
1317  const auto id = pair.second.second;
1318  EdgesetInfo & info = edgeset_info_map[id];
1319 
1320  elem->build_edge_ptr(edge, pair.second.first);
1321 
1322  ++info.num_edges;
1323  info.edge_elem_types.insert(edge->type());
1324 
1325  if (verbosity > 1)
1326  info.bbox.union_with(edge->loose_bounding_box());
1327  }
1328 
1329  // Add edgeset info
1330  if (!global || this->processor_id() == 0)
1331  {
1332  oss << "\n " << (global ? "" : "Local ") << "Mesh Edgesets:\n";
1333  if (edgeset_ids.empty())
1334  oss << " None\n";
1335  }
1336 
1337  const auto & edgeset_name_map = this->get_boundary_info().get_edgeset_name_map();
1338  for (const auto id : edgeset_ids)
1339  {
1340  EdgesetInfo & info = edgeset_info_map[id];
1341 
1342  // Reduce the local information for this edgeset if required
1343  if (global)
1344  {
1345  this->comm().sum(info.num_edges);
1346  this->comm().set_union(info.edge_elem_types, 0);
1347  if (verbosity > 1)
1348  {
1349  this->comm().min(info.bbox.min());
1350  this->comm().min(info.bbox.max());
1351  }
1352  }
1353 
1354  const bool has_name = edgeset_name_map.count(id) && edgeset_name_map.at(id).size();
1355  const std::string name = has_name ? edgeset_name_map.at(id) : "";
1356  if (global)
1357  libmesh_assert(this->comm().verify(name));
1358 
1359  if (global ? this->processor_id() == 0 : info.num_edges > 0)
1360  {
1361  oss << " Edgeset " << id;
1362  if (has_name)
1363  oss << " (" << name << ")";
1364  oss << ", " << info.num_edges << " " << (global ? "" : "local ") << "edges ("
1365  << elem_type_helper(info.edge_elem_types) << ")\n";
1366 
1367  if (verbosity > 1)
1368  {
1369  oss << " " << (global ? "Bounding" : "Local bounding") << " box minimum: "
1370  << info.bbox.min() << "\n"
1371  << " " << (global ? "Bounding" : "Local bounding") << " box maximum: "
1372  << info.bbox.max() << "\n"
1373  << " " << (global ? "Bounding" : "Local bounding") << " box delta: "
1374  << (info.bbox.max() - info.bbox.min()) << "\n";
1375  }
1376  }
1377  }
1378 
1379  // Reduce the block IDs and block names
1380  std::set<subdomain_id_type> subdomains;
1381  for (const Elem * elem : this->active_element_ptr_range())
1382  if (include_object(*elem))
1383  subdomains.insert(elem->subdomain_id());
1384  if (global)
1385  this->comm().set_union(subdomains);
1386 
1387  // Accumulate local information for each subdomain
1388  struct SubdomainInfo
1389  {
1390  std::size_t num_elems = 0;
1391  Real volume = 0;
1392  std::set<int> elem_types;
1393  std::set<dof_id_type> active_node_ids;
1394 #ifdef LIBMESH_ENABLE_AMR
1395  std::size_t num_active_elems = 0;
1396 #endif
1397  BoundingBox bbox;
1398  };
1399  std::map<subdomain_id_type, SubdomainInfo> subdomain_info_map;
1400  for (const Elem * elem : this->element_ptr_range())
1401  if (include_object(*elem))
1402  {
1403  SubdomainInfo & info = subdomain_info_map[elem->subdomain_id()];
1404 
1405  ++info.num_elems;
1406  info.elem_types.insert(elem->type());
1407 
1408 #ifdef LIBMESH_ENABLE_AMR
1409  if (elem->active())
1410  ++info.num_active_elems;
1411 #endif
1412 
1413  for (const Node & node : elem->node_ref_range())
1414  if (include_object(node) && node.active())
1415  info.active_node_ids.insert(node.id());
1416 
1417  if (verbosity > 1 && elem->active())
1418  {
1419  info.volume += elem->volume();
1420  info.bbox.union_with(elem->loose_bounding_box());
1421  }
1422  }
1423 
1424  // Add subdomain info
1425  oss << "\n " << (global ? "" : "Local ") << "Mesh Subdomains:\n";
1426  const auto & subdomain_name_map = this->get_subdomain_name_map();
1427  for (const auto id : subdomains)
1428  {
1429  SubdomainInfo & info = subdomain_info_map[id];
1430 
1431  auto num_active_nodes = info.active_node_ids.size();
1432 
1433  // Reduce the information for this subdomain if needed
1434  if (global)
1435  {
1436  this->comm().sum(info.num_elems);
1437 #ifdef LIBMESH_ENABLE_AMR
1438  this->comm().sum(info.num_active_elems);
1439 #endif
1440  this->comm().sum(num_active_nodes);
1441  this->comm().set_union(info.elem_types, 0);
1442  if (verbosity > 1)
1443  {
1444  this->comm().min(info.bbox.min());
1445  this->comm().max(info.bbox.max());
1446  this->comm().sum(info.volume);
1447  }
1448  }
1449  if (verbosity > 1)
1450  volume += info.volume;
1451 
1452  const bool has_name = subdomain_name_map.count(id);
1453  const std::string name = has_name ? subdomain_name_map.at(id) : "";
1454  if (global)
1455  libmesh_assert(this->comm().verify(name));
1456 
1457  if (!global || this->processor_id() == 0)
1458  {
1459  oss << " Subdomain " << id;
1460  if (has_name)
1461  oss << " (" << name << ")";
1462  oss << ": " << info.num_elems << " " << (global ? "" : "local ") << "elems "
1463  << "(" << elem_type_helper(info.elem_types);
1464 #ifdef LIBMESH_ENABLE_AMR
1465  oss << ", " << info.num_active_elems << " active";
1466 #endif
1467  oss << "), " << num_active_nodes << " " << (global ? "" : "local ") << "active nodes\n";
1468  if (verbosity > 1)
1469  {
1470  oss << " " << (global ? "Volume" : "Local volume") << ": " << info.volume << "\n";
1471  oss << " " << (global ? "Bounding" : "Local bounding") << " box minimum: "
1472  << info.bbox.min() << "\n"
1473  << " " << (global ? "Bounding" : "Local bounding") << " box maximum: "
1474  << info.bbox.max() << "\n"
1475  << " " << (global ? "Bounding" : "Local bounding") << " box delta: "
1476  << (info.bbox.max() - info.bbox.min()) << "\n";
1477  }
1478  }
1479  }
1480 
1481  oss << " " << (global ? "Global" : "Local") << " mesh volume = " << volume << "\n";
1482 
1483  }
1484 
1485  return oss.str();
1486 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
ElemType
Defines an enum for geometric element types.
void elem_types(const MeshBase &mesh, std::vector< ElemType > &et)
Fills in a vector of all element types in the mesh.
Definition: mesh_tools.C:715
const std::set< boundary_id_type > & get_side_boundary_ids() const
bool is_prepared() const
Definition: mesh_base.h:192
virtual dof_id_type n_active_elem() const =0
unsigned int n_threads()
Definition: libmesh_base.h:96
MPI_Info info
libMesh::BoundingBox create_bounding_box(const MeshBase &mesh)
Definition: mesh_tools.C:558
subdomain_id_type n_local_subdomains() const
Definition: mesh_base.C:951
std::map< dof_id_type, const MeshBase::elemset_type * > _elemset_codes
Map from "element set code" to list of set ids to which that element belongs (and vice-versa)...
Definition: mesh_base.h:1924
void sum(T &r) const
const std::map< boundary_id_type, std::string > & get_sideset_name_map() const
dof_id_type n_local_nodes() const
Definition: mesh_base.h:421
const Parallel::Communicator & comm() const
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:159
dof_id_type n_local_elem() const
Definition: mesh_base.h:527
libMesh::BoundingBox create_local_bounding_box(const MeshBase &mesh)
Definition: mesh_tools.C:623
const std::set< boundary_id_type > & get_node_boundary_ids() const
processor_id_type n_processors() const
const std::map< boundary_id_type, std::string > & get_nodeset_name_map() const
void min(const T &r, T &o, Request &req) const
const std::map< subdomain_id_type, std::string > & get_subdomain_name_map() const
Definition: mesh_base.h:1671
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:488
const Point & min() const
Definition: bounding_box.h:76
const std::map< boundary_id_type, std::string > & get_edgeset_name_map() const
libmesh_assert(ctx)
unsigned int n_elemsets() const
Returns the number of unique elemset ids which have been added via add_elemset_code(), which is the size of the _all_elemset_ids set.
Definition: mesh_base.C:376
std::set< unsigned char > _elem_dims
We cache the dimension of the elements present in the mesh.
Definition: mesh_base.h:1895
std::string enum_to_string(const T e)
unsigned int n_partitions() const
Definition: mesh_base.h:1322
subdomain_id_type n_subdomains() const
Definition: mesh_base.C:937
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void max(const T &r, T &o, Request &req) const
unsigned int spatial_dimension() const
Definition: mesh_base.C:495
const std::set< boundary_id_type > & get_edge_boundary_ids() const
virtual bool is_replicated() const
Definition: mesh_base.h:227
virtual dof_id_type n_elem() const =0
processor_id_type processor_id() const
virtual dof_id_type n_nodes() const =0
void set_union(T &data, const unsigned int root_id) const

◆ get_mesh_subdomains()

const std::set<subdomain_id_type>& libMesh::MeshBase::get_mesh_subdomains ( ) const
inlineinherited
Returns
The cached mesh subdomains. As long as the mesh is prepared, this should contain all the subdomain ids across processors. Relies on the mesh being prepared

Definition at line 1744 of file mesh_base.h.

References libMesh::MeshBase::_mesh_subdomains, libMesh::MeshBase::is_prepared(), and libMesh::libmesh_assert().

1745  { libmesh_assert(this->is_prepared()); return _mesh_subdomains; }
std::set< subdomain_id_type > _mesh_subdomains
We cache the subdomain ids of the elements present in the mesh.
Definition: mesh_base.h:1900
bool is_prepared() const
Definition: mesh_base.h:192
libmesh_assert(ctx)

◆ get_node_integer_index()

unsigned int libMesh::MeshBase::get_node_integer_index ( std::string_view  name) const
inherited

Definition at line 667 of file mesh_base.C.

References libMesh::MeshBase::_node_integer_names, libMesh::index_range(), libMesh::invalid_uint, and libMesh::Quality::name().

668 {
669  for (auto i : index_range(_node_integer_names))
670  if (_node_integer_names[i] == name)
671  return i;
672 
673  libmesh_error_msg("Unknown node integer " << name);
674  return libMesh::invalid_uint;
675 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
Definition: libmesh.h:286
std::vector< std::string > _node_integer_names
The array of names for integer data associated with each node in the mesh.
Definition: mesh_base.h:1950
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:111

◆ get_node_integer_name()

const std::string& libMesh::MeshBase::get_node_integer_name ( unsigned int  i) const
inlineinherited

Definition at line 1045 of file mesh_base.h.

References libMesh::MeshBase::_node_integer_names.

Referenced by libMesh::XdrIO::write(), and libMesh::CheckpointIO::write().

1046  { return _node_integer_names[i]; }
std::vector< std::string > _node_integer_names
The array of names for integer data associated with each node in the mesh.
Definition: mesh_base.h:1950

◆ get_point_locator_close_to_point_tol()

Real libMesh::MeshBase::get_point_locator_close_to_point_tol ( ) const
inherited

Definition at line 1836 of file mesh_base.C.

References libMesh::MeshBase::_point_locator_close_to_point_tol.

1837 {
1839 }
Real _point_locator_close_to_point_tol
If nonzero, we will call PointLocatorBase::set_close_to_point_tol() on any PointLocators that we crea...
Definition: mesh_base.h:2015

◆ get_subdomain_name_map()

const std::map<subdomain_id_type, std::string>& libMesh::MeshBase::get_subdomain_name_map ( ) const
inlineinherited

Definition at line 1671 of file mesh_base.h.

References libMesh::MeshBase::_block_id_to_name.

Referenced by libMesh::DistributedMesh::DistributedMesh(), libMesh::MeshBase::get_info(), libMesh::ReplicatedMesh::ReplicatedMesh(), stitching_helper(), libMesh::XdrIO::write_serialized_subdomain_names(), and libMesh::CheckpointIO::write_subdomain_names().

1672  { return _block_id_to_name; }
std::map< subdomain_id_type, std::string > _block_id_to_name
This structure maintains the mapping of named blocks for file formats that support named blocks...
Definition: mesh_base.h:1888

◆ ghosting_functors_begin()

std::set<GhostingFunctor *>::const_iterator libMesh::MeshBase::ghosting_functors_begin ( ) const
inlineinherited

Beginning of range of ghosting functors.

Definition at line 1268 of file mesh_base.h.

References libMesh::MeshBase::_ghosting_functors.

Referenced by contract(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::query_ghosting_functors(), libMesh::MeshBase::redistribute(), and EquationSystemsTest::testDisableDefaultGhosting().

1269  { return _ghosting_functors.begin(); }
std::set< GhostingFunctor * > _ghosting_functors
The list of all GhostingFunctor objects to be used when distributing a DistributedMesh.
Definition: mesh_base.h:1991

◆ ghosting_functors_end()

std::set<GhostingFunctor *>::const_iterator libMesh::MeshBase::ghosting_functors_end ( ) const
inlineinherited

End of range of ghosting functors.

Definition at line 1274 of file mesh_base.h.

References libMesh::MeshBase::_ghosting_functors.

Referenced by contract(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::query_ghosting_functors(), libMesh::MeshBase::redistribute(), and EquationSystemsTest::testDisableDefaultGhosting().

1275  { return _ghosting_functors.end(); }
std::set< GhostingFunctor * > _ghosting_functors
The list of all GhostingFunctor objects to be used when distributing a DistributedMesh.
Definition: mesh_base.h:1991

◆ has_elem_integer()

bool libMesh::MeshBase::has_elem_integer ( std::string_view  name) const
inherited

Definition at line 590 of file mesh_base.C.

References libMesh::MeshBase::_elem_integer_names, and libMesh::Quality::name().

Referenced by libMesh::MeshBase::change_elemset_code(), WriteElemsetData::checkElemsetCodes(), ExtraIntegersTest::checkpoint_helper(), libMesh::ExodusII_IO_Helper::initialize(), ExtraIntegersTest::testExtraIntegersExodusReading(), and libMesh::ExodusII_IO_Helper::write_elemsets().

591 {
592  for (auto & entry : _elem_integer_names)
593  if (entry == name)
594  return true;
595 
596  return false;
597 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
std::vector< std::string > _elem_integer_names
The array of names for integer data associated with each element in the mesh.
Definition: mesh_base.h:1938

◆ has_node_integer()

bool libMesh::MeshBase::has_node_integer ( std::string_view  name) const
inherited

Definition at line 679 of file mesh_base.C.

References libMesh::MeshBase::_node_integer_names, and libMesh::Quality::name().

Referenced by ExtraIntegersTest::checkpoint_helper().

680 {
681  for (auto & entry : _node_integer_names)
682  if (entry == name)
683  return true;
684 
685  return false;
686 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
std::vector< std::string > _node_integer_names
The array of names for integer data associated with each node in the mesh.
Definition: mesh_base.h:1950

◆ insert_elem() [1/2]

virtual Elem* libMesh::MeshBase::insert_elem ( Elem e)
pure virtualinherited

Insert elem e to the element array, preserving its id and replacing/deleting any existing element with the same id.

Users should call MeshBase::prepare_for_use() after elements are added to and/or deleted from the mesh.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

Referenced by all_first_order(), and libMesh::MeshTools::Subdivision::all_subdivision().

◆ insert_elem() [2/2]

virtual Elem* libMesh::MeshBase::insert_elem ( std::unique_ptr< Elem e)
pure virtualinherited

Version of insert_elem() taking a std::unique_ptr by value.

The version taking a dumb pointer will eventually be deprecated in favor of this version. This API is intended to indicate that ownership of the Elem is transferred to the Mesh when this function is called, and it should play more nicely with the Elem::build() API which has always returned a std::unique_ptr.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

◆ insert_node() [1/2]

virtual Node* libMesh::MeshBase::insert_node ( Node n)
pure virtualinherited

This method is deprecated.

Please use add_node instead Insert Node n into the Mesh at a location consistent with n->id(), allocating extra storage if necessary. Will error rather than overwriting an existing Node. Only use if you know what you are doing...

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

Referenced by libMesh::mesh_inserter_iterator< T >::operator=().

◆ insert_node() [2/2]

virtual Node* libMesh::MeshBase::insert_node ( std::unique_ptr< Node n)
pure virtualinherited

This method is deprecated.

Please use add_node instead Version of insert_node() taking a std::unique_ptr by value. This API is intended to indicate that ownership of the Node is transferred to the Mesh when this function is called, and it should play more nicely with the Node::build() API which has always returned a std::unique_ptr.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

◆ is_prepared()

bool libMesh::MeshBase::is_prepared ( ) const
inlineinherited

◆ is_replicated()

virtual bool libMesh::MeshBase::is_replicated ( ) const
inlinevirtualinherited
Returns
true if new elements and nodes can and should be created in synchronization on all processors, false otherwise

Reimplemented in libMesh::DistributedMesh.

Definition at line 227 of file mesh_base.h.

Referenced by libMesh::MeshRefinement::_refine_elements(), libMesh::MeshTools::Modification::all_tri(), libMesh::MeshTools::Modification::flatten(), libMesh::MeshBase::get_info(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::CheckpointIO::read(), and libMesh::MeshRefinement::uniformly_coarsen().

228  { return true; }

◆ is_serial()

virtual bool libMesh::MeshBase::is_serial ( ) const
inlinevirtualinherited
Returns
true if all elements and nodes of the mesh exist on the current processor, false otherwise

Reimplemented in libMesh::DistributedMesh.

Definition at line 205 of file mesh_base.h.

Referenced by libMesh::MeshRefinement::_coarsen_elements(), libMesh::MeshRefinement::_smooth_flags(), libMesh::BoundaryInfo::add_elements(), libMesh::MeshTools::Modification::all_tri(), libMesh::EquationSystems::allgather(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::MeshTools::build_nodes_to_elem_map(), libMesh::MeshBase::cache_elem_data(), libMesh::DofMap::create_dof_constraints(), create_submesh(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::LocationMap< T >::init(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshSerializer::MeshSerializer(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::MeshBase::partition(), libMesh::MeshBase::prepare_for_use(), libMesh::Nemesis_IO::read(), libMesh::BoundaryInfo::regenerate_id_sets(), scale_mesh_and_plot(), libMesh::DofMap::scatter_constraints(), libMesh::Partitioner::set_node_processor_ids(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::BoundaryInfo::sync(), MeshInputTest::testExodusIGASidesets(), PointLocatorTest::testLocator(), MeshInputTest::testLowOrderEdgeBlocks(), BoundaryInfoTest::testMesh(), PointLocatorTest::testPlanar(), BoundaryInfoTest::testRenumber(), MeshInputTest::testTetgenIO(), WriteNodesetData::testWriteImpl(), WriteSidesetData::testWriteImpl(), libMesh::MeshTools::total_weight(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::CheckpointIO::write(), and libMesh::XdrIO::write_parallel().

206  { return true; }

◆ is_serial_on_zero()

virtual bool libMesh::MeshBase::is_serial_on_zero ( ) const
inlinevirtualinherited
Returns
true if all elements and nodes of the mesh exist on the processor 0, false otherwise

Reimplemented in libMesh::DistributedMesh.

Definition at line 212 of file mesh_base.h.

Referenced by libMesh::ExodusII_IO::copy_elemental_solution(), and libMesh::ExodusII_IO::copy_nodal_solution().

213  { return true; }

◆ libmesh_assert_valid_parallel_ids()

virtual void libMesh::MeshBase::libmesh_assert_valid_parallel_ids ( ) const
inlinevirtualinherited

Verify id and processor_id consistency of our elements and nodes containers.

Calls libmesh_assert() on each possible failure. Currently only implemented on DistributedMesh; a serial data structure is much harder to get out of sync.

Reimplemented in libMesh::DistributedMesh.

Definition at line 1493 of file mesh_base.h.

Referenced by libMesh::MeshRefinement::_refine_elements(), libMesh::InfElemBuilder::build_inf_elem(), and libMesh::MeshRefinement::refine_and_coarsen_elements().

1493 {}

◆ locally_equals()

bool libMesh::MeshBase::locally_equals ( const MeshBase other_mesh) const
inherited

This behaves the same as operator==, but only for the local and ghosted aspects of the mesh; i.e.

operator== is true iff local equality is true on every rank.

Definition at line 222 of file mesh_base.C.

References libMesh::MeshBase::_all_elemset_ids, libMesh::MeshBase::_allow_remote_element_removal, libMesh::MeshBase::_block_id_to_name, libMesh::MeshBase::_constraint_rows, libMesh::MeshBase::_count_lower_dim_elems_in_point_locator, libMesh::MeshBase::_default_ghosting, libMesh::MeshBase::_default_mapping_data, libMesh::MeshBase::_default_mapping_type, libMesh::MeshBase::_elem_dims, libMesh::MeshBase::_elem_integer_default_values, libMesh::MeshBase::_elem_integer_names, libMesh::MeshBase::_elemset_codes, libMesh::MeshBase::_ghosting_functors, libMesh::MeshBase::_is_prepared, libMesh::MeshBase::_mesh_subdomains, libMesh::MeshBase::_n_parts, libMesh::MeshBase::_node_integer_default_values, libMesh::MeshBase::_node_integer_names, libMesh::MeshBase::_partitioner, libMesh::MeshBase::_point_locator_close_to_point_tol, libMesh::MeshBase::_skip_all_partitioning, libMesh::MeshBase::_skip_find_neighbors, libMesh::MeshBase::_skip_noncritical_partitioning, libMesh::MeshBase::_skip_renumber_nodes_and_elements, libMesh::MeshBase::_spatial_dimension, libMesh::MeshBase::boundary_info, libMesh::MeshBase::get_constraint_rows(), libMesh::index_range(), libMesh::libmesh_assert(), libMesh::MeshBase::query_node_ptr(), and libMesh::MeshBase::subclass_locally_equals().

Referenced by libMesh::MeshBase::operator==().

223 {
224  // Check whether everything in the base is equal
225  if (_n_parts != other_mesh._n_parts ||
226  _default_mapping_type != other_mesh._default_mapping_type ||
227  _default_mapping_data != other_mesh._default_mapping_data ||
228  _is_prepared != other_mesh._is_prepared ||
230  other_mesh._count_lower_dim_elems_in_point_locator ||
231  // We expect this to change in a DistributeMesh prepare_for_use();
232  // it's conceptually "mutable"...
233 /*
234 #ifdef LIBMESH_ENABLE_UNIQUE_ID
235  _next_unique_id != other_mesh._next_unique_id ||
236 #endif
237 */
238  _skip_noncritical_partitioning != other_mesh._skip_noncritical_partitioning ||
239  _skip_all_partitioning != other_mesh._skip_all_partitioning ||
240  _skip_renumber_nodes_and_elements != other_mesh._skip_renumber_nodes_and_elements ||
241  _skip_find_neighbors != other_mesh._skip_find_neighbors ||
242  _allow_remote_element_removal != other_mesh._allow_remote_element_removal ||
243  _spatial_dimension != other_mesh._spatial_dimension ||
244  _point_locator_close_to_point_tol != other_mesh._point_locator_close_to_point_tol ||
245  _block_id_to_name != other_mesh._block_id_to_name ||
246  _elem_dims != other_mesh._elem_dims ||
247  _mesh_subdomains != other_mesh._mesh_subdomains ||
248  _all_elemset_ids != other_mesh._all_elemset_ids ||
249  _elem_integer_names != other_mesh._elem_integer_names ||
250  _elem_integer_default_values != other_mesh._elem_integer_default_values ||
251  _node_integer_names != other_mesh._node_integer_names ||
252  _node_integer_default_values != other_mesh._node_integer_default_values ||
253  bool(_default_ghosting) != bool(other_mesh._default_ghosting) ||
254  bool(_partitioner) != bool(other_mesh._partitioner) ||
255  *boundary_info != *other_mesh.boundary_info)
256  return false;
257 
258  const constraint_rows_type & other_rows =
259  other_mesh.get_constraint_rows();
260  for (const auto & [node, row] : this->_constraint_rows)
261  {
262  const dof_id_type node_id = node->id();
263  const Node * other_node = other_mesh.query_node_ptr(node_id);
264  if (!other_node)
265  return false;
266 
267  auto it = other_rows.find(other_node);
268  if (it == other_rows.end())
269  return false;
270 
271  const auto & other_row = it->second;
272  if (row.size() != other_row.size())
273  return false;
274 
275  for (auto i : index_range(row))
276  {
277  const auto & [elem_pair, coef] = row[i];
278  const auto & [other_elem_pair, other_coef] = other_row[i];
279  libmesh_assert(elem_pair.first);
280  libmesh_assert(other_elem_pair.first);
281  if (elem_pair.first->id() !=
282  other_elem_pair.first->id() ||
283  elem_pair.second !=
284  other_elem_pair.second ||
285  coef != other_coef)
286  return false;
287  }
288  }
289 
290  for (const auto & [elemset_code, elemset_ptr] : this->_elemset_codes)
291  {
292  auto it = other_mesh._elemset_codes.find(elemset_code);
293  if (it == other_mesh._elemset_codes.end() ||
294  *elemset_ptr != *it->second)
295  return false;
296  }
297 
298  // FIXME: we have no good way to compare ghosting functors, since
299  // they're in a set sorted by pointer, and we have no way *at all*
300  // to compare ghosting functors, since they don't have operator==
301  // defined and we encourage users to subclass them. We can check if
302  // we have the same number, is all.
303  if (_ghosting_functors.size() !=
304  other_mesh._ghosting_functors.size())
305  return false;
306 
307  // Same deal for partitioners. We tested that we both have one or
308  // both don't, but are they equivalent? Let's guess "yes".
309 
310  // Now let the subclasses decide whether everything else is equal
311  return this->subclass_locally_equals(other_mesh);
312 }
std::set< subdomain_id_type > _mesh_subdomains
We cache the subdomain ids of the elements present in the mesh.
Definition: mesh_base.h:1900
virtual bool subclass_locally_equals(const MeshBase &other_mesh) const =0
Shim to allow operator == (&) to behave like a virtual function without having to be one...
bool _skip_renumber_nodes_and_elements
If this is true then renumbering will be kept to a minimum.
Definition: mesh_base.h:1868
std::vector< std::string > _elem_integer_names
The array of names for integer data associated with each element in the mesh.
Definition: mesh_base.h:1938
std::map< dof_id_type, const MeshBase::elemset_type * > _elemset_codes
Map from "element set code" to list of set ids to which that element belongs (and vice-versa)...
Definition: mesh_base.h:1924
constraint_rows_type _constraint_rows
Definition: mesh_base.h:2009
bool _skip_noncritical_partitioning
If this is true then no partitioning should be done with the possible exception of orphaned nodes...
Definition: mesh_base.h:1856
unsigned char _spatial_dimension
The "spatial dimension" of the Mesh.
Definition: mesh_base.h:1932
std::unique_ptr< BoundaryInfo > boundary_info
This class holds the boundary information.
Definition: mesh_base.h:1760
bool _allow_remote_element_removal
If this is false then even on DistributedMesh remote elements will not be deleted during mesh prepara...
Definition: mesh_base.h:1881
std::vector< std::string > _node_integer_names
The array of names for integer data associated with each node in the mesh.
Definition: mesh_base.h:1950
MeshBase::elemset_type _all_elemset_ids
Definition: mesh_base.h:1926
std::set< GhostingFunctor * > _ghosting_functors
The list of all GhostingFunctor objects to be used when distributing a DistributedMesh.
Definition: mesh_base.h:1991
unsigned int _n_parts
The number of partitions the mesh has.
Definition: mesh_base.h:1802
unsigned char _default_mapping_data
The default mapping data (unused with Lagrange, used for nodal weight lookup index with rational base...
Definition: mesh_base.h:1815
ElemMappingType _default_mapping_type
The default mapping type (typically Lagrange) between master and physical space to assign to newly ad...
Definition: mesh_base.h:1808
std::unique_ptr< Partitioner > _partitioner
A partitioner to use at each prepare_for_use().
Definition: mesh_base.h:1843
libmesh_assert(ctx)
bool _skip_find_neighbors
If this is true then we will skip find_neighbors in prepare_for_use.
Definition: mesh_base.h:1873
std::set< unsigned char > _elem_dims
We cache the dimension of the elements present in the mesh.
Definition: mesh_base.h:1895
std::vector< dof_id_type > _node_integer_default_values
The array of default initialization values for integer data associated with each node in the mesh...
Definition: mesh_base.h:1956
std::vector< dof_id_type > _elem_integer_default_values
The array of default initialization values for integer data associated with each element in the mesh...
Definition: mesh_base.h:1944
std::map< const Node *, constraint_rows_mapped_type > constraint_rows_type
Definition: mesh_base.h:1675
bool _is_prepared
Flag indicating if the mesh has been prepared for use.
Definition: mesh_base.h:1820
std::unique_ptr< GhostingFunctor > _default_ghosting
The default geometric GhostingFunctor, used to implement standard libMesh element ghosting behavior...
Definition: mesh_base.h:1982
bool _skip_all_partitioning
If this is true then no partitioning should be done.
Definition: mesh_base.h:1861
Real _point_locator_close_to_point_tol
If nonzero, we will call PointLocatorBase::set_close_to_point_tol() on any PointLocators that we crea...
Definition: mesh_base.h:2015
bool _count_lower_dim_elems_in_point_locator
Do we count lower dimensional elements in point locator refinement? This is relevant in tree-based po...
Definition: mesh_base.h:1835
std::map< subdomain_id_type, std::string > _block_id_to_name
This structure maintains the mapping of named blocks for file formats that support named blocks...
Definition: mesh_base.h:1888
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:111
uint8_t dof_id_type
Definition: id_types.h:67

◆ max_elem_id()

virtual dof_id_type libMesh::MeshBase::max_elem_id ( ) const
pure virtualinherited
Returns
A number greater than or equal to the maximum element id in the mesh.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

Referenced by libMesh::BoundaryInfo::add_elements(), libMesh::MeshTools::Modification::all_tri(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), CopyNodesAndElementsTest::collectMeshes(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::MeshBase::detect_interior_parents(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::Poly2TriTriangulator::insert_refinement_points(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_equal_connectivity(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshTools::libmesh_assert_valid_unique_ids(), main(), AllSecondOrderTest::MixedFixingImpl(), libMesh::MeshTools::Modification::permute_elements(), libMesh::Partitioner::set_parent_processor_ids(), stitching_helper(), EquationSystemsTest::testPostInitAddElem(), BoundaryInfoTest::testShellFaceConstraints(), MeshInputTest::testVTKPreserveElemIds(), libMesh::ExodusII_IO_Helper::write_elements(), and libMesh::GmshIO::write_mesh().

◆ max_node_id()

virtual dof_id_type libMesh::MeshBase::max_node_id ( ) const
pure virtualinherited

◆ merge_extra_integer_names()

std::pair< std::vector< unsigned int >, std::vector< unsigned int > > libMesh::MeshBase::merge_extra_integer_names ( const MeshBase other)
protectedinherited

Merge extra-integer arrays from an other mesh.

Returns two mappings from index values in other to (possibly newly created) index values with the same string name in this mesh, the first for element integers and the second for node integers.

Definition at line 1861 of file mesh_base.C.

References libMesh::MeshBase::_elem_integer_default_values, libMesh::MeshBase::_elem_integer_names, libMesh::MeshBase::_node_integer_default_values, libMesh::MeshBase::_node_integer_names, libMesh::MeshBase::add_elem_integers(), and libMesh::MeshBase::add_node_integers().

Referenced by copy_nodes_and_elements(), and create_submesh().

1862 {
1863  std::pair<std::vector<unsigned int>, std::vector<unsigned int>> returnval;
1864  returnval.first = this->add_elem_integers(other._elem_integer_names, true, &other._elem_integer_default_values);
1865  returnval.second = this->add_node_integers(other._node_integer_names, true, &other._node_integer_default_values);
1866  return returnval;
1867 }
std::vector< unsigned int > add_elem_integers(const std::vector< std::string > &names, bool allocate_data=true, const std::vector< dof_id_type > *default_values=nullptr)
Register integer data (of type dof_id_type) to be added to each element in the mesh, one string name for each new integer.
Definition: mesh_base.C:535
std::vector< unsigned int > add_node_integers(const std::vector< std::string > &names, bool allocate_data=true, const std::vector< dof_id_type > *default_values=nullptr)
Register integer data (of type dof_id_type) to be added to each node in the mesh. ...
Definition: mesh_base.C:624

◆ mesh_dimension()

unsigned int libMesh::MeshBase::mesh_dimension ( ) const
inherited
Returns
The logical dimension of the mesh; i.e. the manifold dimension of the elements in the mesh. If we ever support multi-dimensional meshes (e.g. hexes and quads in the same mesh) then this will return the largest such dimension.

Definition at line 324 of file mesh_base.C.

References libMesh::MeshBase::_elem_dims.

Referenced by libMesh::HPCoarsenTest::add_projection(), all_complete_order_range(), all_second_order_range(), libMesh::MeshTools::Modification::all_tri(), alternative_fe_assembly(), assemble(), LinearElasticity::assemble(), assemble_1D(), AssembleOptimization::assemble_A_and_F(), assemble_biharmonic(), assemble_cd(), assemble_divgrad(), assemble_elasticity(), assemble_ellipticdg(), assemble_func(), assemble_helmholtz(), assemble_laplace(), assemble_mass(), assemble_matrices(), assemble_poisson(), assemble_SchroedingerEquation(), assemble_shell(), assemble_stokes(), assemble_wave(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::EquationSystems::build_variable_names(), libMesh::MeshBase::cache_elem_data(), compute_enriched_soln(), compute_jacobian(), compute_residual(), compute_stresses(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), LargeDeformationElasticity::compute_stresses(), copy_nodes_and_elements(), libMesh::DofMap::create_dof_constraints(), libMesh::MeshTools::Modification::distort(), SolidSystem::element_time_derivative(), HeatSystem::element_time_derivative(), fe_assembly(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::ReplicatedMesh::get_boundary_points(), libMesh::LaplaceMeshSmoother::init(), SolidSystem::init_data(), libMesh::ExodusII_IO_Helper::initialize(), integrate_function(), LaplaceYoung::jacobian(), LargeDeformationElasticity::jacobian(), main(), libMesh::GMVIO::read(), libMesh::Nemesis_IO::read(), libMesh::ExodusII_IO::read(), libMesh::VTKIO::read(), libMesh::System::read_header(), libMesh::UCDIO::read_implementation(), libMesh::XdrIO::read_serialized_connectivity(), LaplaceYoung::residual(), LargeDeformationElasticity::residual(), LinearElasticityWithContact::residual_and_jacobian(), SolidSystem::save_initial_mesh(), setup(), libMesh::MeshTools::Modification::smooth(), MeshSpatialDimensionTest::test1D(), MeshSpatialDimensionTest::test2D(), InfFERadialTest::testInfQuants(), InfFERadialTest::testInfQuants_numericDeriv(), InfFERadialTest::testSides(), InfFERadialTest::testSingleOrder(), libMesh::BoundaryVolumeSolutionTransfer::transfer(), libMesh::DTKSolutionTransfer::transfer(), libMesh::PostscriptIO::write(), libMesh::CheckpointIO::write(), libMesh::TecplotIO::write_binary(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::UCDIO::write_implementation(), libMesh::UCDIO::write_nodal_data(), libMesh::EnsightIO::write_scalar_ascii(), libMesh::GnuPlotIO::write_solution(), and libMesh::EnsightIO::write_vector_ascii().

325 {
326  if (!_elem_dims.empty())
327  return cast_int<unsigned int>(*_elem_dims.rbegin());
328  return 0;
329 }
std::set< unsigned char > _elem_dims
We cache the dimension of the elements present in the mesh.
Definition: mesh_base.h:1895

◆ move_nodes_and_elements()

virtual void libMesh::UnstructuredMesh::move_nodes_and_elements ( MeshBase &&  other_mesh)
pure virtual

Move node and elements from other_mesh to this mesh.

Implemented in libMesh::ReplicatedMesh.

◆ n_active_elem()

virtual dof_id_type libMesh::MeshBase::n_active_elem ( ) const
pure virtualinherited

◆ n_active_elem_on_proc()

dof_id_type libMesh::MeshBase::n_active_elem_on_proc ( const processor_id_type  proc) const
inherited
Returns
The number of active elements on processor proc.

Definition at line 989 of file mesh_base.C.

References distance(), and libMesh::ParallelObject::n_processors().

Referenced by libMesh::MeshBase::n_active_local_elem().

990 {
991  libmesh_assert_less (proc_id, this->n_processors());
992  return static_cast<dof_id_type>(std::distance (this->active_pid_elements_begin(proc_id),
993  this->active_pid_elements_end (proc_id)));
994 }
Real distance(const Point &p)
processor_id_type n_processors() const
uint8_t dof_id_type
Definition: id_types.h:67

◆ n_active_local_elem()

dof_id_type libMesh::MeshBase::n_active_local_elem ( ) const
inlineinherited

◆ n_active_sub_elem()

dof_id_type libMesh::MeshBase::n_active_sub_elem ( ) const
inherited

Same as n_sub_elem(), but only counts active elements.

Definition at line 1010 of file mesh_base.C.

Referenced by libMesh::TecplotIO::write_ascii(), libMesh::GMVIO::write_ascii_old_impl(), and libMesh::TecplotIO::write_binary().

1011 {
1012  dof_id_type ne=0;
1013 
1014  for (const auto & elem : this->active_element_ptr_range())
1015  ne += elem->n_sub_elem();
1016 
1017  return ne;
1018 }
uint8_t dof_id_type
Definition: id_types.h:67

◆ n_elem()

virtual dof_id_type libMesh::MeshBase::n_elem ( ) const
pure virtualinherited
Returns
The number of elements in the mesh.

The standard n_elem() function may return a cached value on distributed meshes, and so can be called by any processor at any time.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

Referenced by libMesh::MeshTools::Subdivision::add_boundary_ghosts(), libMesh::MeshTools::Modification::all_tri(), AllSecondOrderTest::allCompleteOrderDoNothing(), AllSecondOrderTest::allCompleteOrderMixed(), AllSecondOrderTest::allCompleteOrderRange(), AllSecondOrderTest::allSecondOrderDoNothing(), AllSecondOrderTest::allSecondOrderMixed(), AllSecondOrderTest::allSecondOrderRange(), libMesh::MeshCommunication::assign_global_indices(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::MeshTools::build_nodes_to_elem_map(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::TetGenMeshInterface::check_hull_integrity(), copy_nodes_and_elements(), libMesh::DofMap::create_dof_constraints(), create_submesh(), libMesh::MeshTools::Modification::distort(), libMesh::TriangulatorInterface::elems_to_segments(), libMesh::MeshBase::get_info(), main(), AllSecondOrderTest::MixedFixingImpl(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read_serialized_nodes(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::MeshTools::Modification::redistribute(), ConstraintOperatorTest::test1DCoarseningNewNodes(), AllTriTest::test_helper_2D(), AllTriTest::test_helper_3D(), MeshInputTest::testAbaqusRead(), MeshGenerationTest::testBuildCube(), MeshGenerationTest::testBuildLine(), MeshGenerationTest::testBuildSquare(), MeshDeletionsTest::testDeleteElem(), MeshInputTest::testDynaNoSplines(), MeshInputTest::testDynaReadElem(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusIGASidesets(), InfFERadialTest::testInfQuants(), InfFERadialTest::testInfQuants_numericDeriv(), MeshAssignTest::testMeshMoveAssign(), MeshInputTest::testNemesisReadImpl(), MeshTriangulationTest::testPoly2TriRefinementBase(), EquationSystemsTest::testSelectivePRefine(), InfFERadialTest::testSides(), InfFERadialTest::testSingleOrder(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), MeshTriangulationTest::testTriangulatorBase(), MeshTriangulationTest::testTriangulatorHoles(), MeshTriangulationTest::testTriangulatorInterp(), MeshTriangulationTest::testTriangulatorMeshedHoles(), MeshInputTest::testVTKPreserveElemIds(), MeshInputTest::testVTKPreserveSubdomainIds(), libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole(), libMesh::FroIO::write(), libMesh::TetGenIO::write(), libMesh::XdrIO::write(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::UCDIO::write_implementation(), libMesh::UCDIO::write_nodal_data(), libMesh::XdrIO::write_serialized_connectivity(), and libMesh::System::write_serialized_vectors().

◆ n_elem_integers()

unsigned int libMesh::MeshBase::n_elem_integers ( ) const
inlineinherited

Definition at line 934 of file mesh_base.h.

References libMesh::MeshBase::_elem_integer_names.

Referenced by libMesh::CheckpointIO::read_connectivity(), libMesh::XdrIO::write(), and libMesh::CheckpointIO::write().

934 { return _elem_integer_names.size(); }
std::vector< std::string > _elem_integer_names
The array of names for integer data associated with each element in the mesh.
Definition: mesh_base.h:1938

◆ n_elem_on_proc()

dof_id_type libMesh::MeshBase::n_elem_on_proc ( const processor_id_type  proc) const
inherited
Returns
The number of elements on processor proc.

Definition at line 976 of file mesh_base.C.

References distance(), libMesh::DofObject::invalid_processor_id, libMesh::libmesh_assert(), and libMesh::ParallelObject::n_processors().

Referenced by libMesh::MeshBase::n_local_elem(), and libMesh::MeshBase::n_unpartitioned_elem().

977 {
978  // We're either counting a processor's elements or unpartitioned
979  // elements
980  libmesh_assert (proc_id < this->n_processors() ||
982 
983  return static_cast<dof_id_type>(std::distance (this->pid_elements_begin(proc_id),
984  this->pid_elements_end (proc_id)));
985 }
Real distance(const Point &p)
processor_id_type n_processors() const
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:488
libmesh_assert(ctx)
uint8_t dof_id_type
Definition: id_types.h:67

◆ n_elemsets()

unsigned int libMesh::MeshBase::n_elemsets ( ) const
inherited

Returns the number of unique elemset ids which have been added via add_elemset_code(), which is the size of the _all_elemset_ids set.

Definition at line 376 of file mesh_base.C.

References libMesh::MeshBase::_all_elemset_ids.

Referenced by libMesh::MeshBase::get_info(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO::read(), and libMesh::ExodusII_IO_Helper::write_elemsets().

377 {
378  return _all_elemset_ids.size();
379 }
MeshBase::elemset_type _all_elemset_ids
Definition: mesh_base.h:1926

◆ n_local_elem()

dof_id_type libMesh::MeshBase::n_local_elem ( ) const
inlineinherited
Returns
The number of elements on the local processor.

Definition at line 527 of file mesh_base.h.

References libMesh::MeshBase::n_elem_on_proc(), and libMesh::ParallelObject::processor_id().

Referenced by libMesh::DTKAdapter::DTKAdapter(), libMesh::MeshBase::get_info(), libMesh::DistributedMesh::parallel_n_elem(), and DofMapTest::testBadElemFECombo().

528  { return this->n_elem_on_proc (this->processor_id()); }
dof_id_type n_elem_on_proc(const processor_id_type proc) const
Definition: mesh_base.C:976
processor_id_type processor_id() const

◆ n_local_nodes()

dof_id_type libMesh::MeshBase::n_local_nodes ( ) const
inlineinherited
Returns
The number of nodes on the local processor.

Definition at line 421 of file mesh_base.h.

References libMesh::MeshBase::n_nodes_on_proc(), and libMesh::ParallelObject::processor_id().

Referenced by libMesh::MeshBase::get_info(), libMesh::VTKIO::nodes_to_vtk(), and libMesh::DistributedMesh::parallel_n_nodes().

422  { return this->n_nodes_on_proc (this->processor_id()); }
dof_id_type n_nodes_on_proc(const processor_id_type proc) const
Definition: mesh_base.C:963
processor_id_type processor_id() const

◆ n_local_subdomains()

subdomain_id_type libMesh::MeshBase::n_local_subdomains ( ) const
inherited
Returns
The number of subdomains in the local mesh. Subdomains correspond to separate subsets of the mesh which could correspond e.g. to different materials in a solid mechanics application, or regions where different physical processes are important. The subdomain mapping is independent from the parallel decomposition.

Definition at line 951 of file mesh_base.C.

References libMesh::MeshBase::subdomain_ids().

Referenced by libMesh::MeshBase::get_info().

952 {
953  std::set<subdomain_id_type> ids;
954 
955  this->subdomain_ids (ids, /* global = */ false);
956 
957  return cast_int<subdomain_id_type>(ids.size());
958 }
void subdomain_ids(std::set< subdomain_id_type > &ids, const bool global=true) const
Constructs a list of all subdomain identifiers in the local mesh if global == false, and in the global mesh if global == true (default).
Definition: mesh_base.C:899

◆ n_node_integers()

unsigned int libMesh::MeshBase::n_node_integers ( ) const
inlineinherited

Definition at line 1056 of file mesh_base.h.

References libMesh::MeshBase::_node_integer_names.

Referenced by libMesh::CheckpointIO::read_nodes(), libMesh::XdrIO::write(), and libMesh::CheckpointIO::write().

1056 { return _node_integer_names.size(); }
std::vector< std::string > _node_integer_names
The array of names for integer data associated with each node in the mesh.
Definition: mesh_base.h:1950

◆ n_nodes()

virtual dof_id_type libMesh::MeshBase::n_nodes ( ) const
pure virtualinherited
Returns
The number of nodes in the mesh.

This function and others must be defined in derived classes since the MeshBase class has no specific storage for nodes or elements. The standard n_nodes() function may return a cached value on distributed meshes, and so can be called by any processor at any time.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

Referenced by all_complete_order_range(), all_second_order_range(), AllSecondOrderTest::allCompleteOrderDoNothing(), AllSecondOrderTest::allCompleteOrderMixed(), AllSecondOrderTest::allCompleteOrderRange(), AllSecondOrderTest::allSecondOrderDoNothing(), AllSecondOrderTest::allSecondOrderMixed(), AllSecondOrderTest::allSecondOrderRange(), libMesh::MeshCommunication::assign_global_indices(), libMesh::MeshTools::Generation::build_delaunay_square(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::MeshBase::copy_constraint_rows(), copy_nodes_and_elements(), create_submesh(), libMesh::MeshTools::Modification::distort(), fill_dirichlet_bc(), libMesh::TetGenMeshInterface::fill_pointlist(), libMesh::MeshBase::get_info(), libMesh::VTKIO::get_local_node_values(), libMesh::TreeNode< N >::insert(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), main(), libMesh::VariationalMeshSmoother::metr_data_gen(), AllSecondOrderTest::MixedFixingImpl(), libMesh::Nemesis_IO::read(), libMesh::ExodusII_IO::read(), libMesh::UCDIO::read_implementation(), libMesh::XdrIO::read_serialized_nodes(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::MeshTools::Modification::redistribute(), libMesh::VariationalMeshSmoother::smooth(), libMesh::MeshTools::Modification::smooth(), ConstraintOperatorTest::test1DCoarseningNewNodes(), MeshInputTest::testAbaqusRead(), SystemsTest::testBoundaryProjectCube(), MeshGenerationTest::testBuildCube(), MeshGenerationTest::testBuildLine(), MeshGenerationTest::testBuildSquare(), SystemsTest::testDofCouplingWithVarGroups(), MeshInputTest::testDynaNoSplines(), MeshInputTest::testDynaReadElem(), MeshInputTest::testDynaReadPatch(), VolumeTest::testEdge3Volume(), MeshInputTest::testExodusIGASidesets(), MeshInputTest::testNemesisReadImpl(), MeshInputTest::testTetgenIO(), MeshTriangulationTest::testTriangulatorInterp(), MeshInputTest::testVTKPreserveElemIds(), MeshInputTest::testVTKPreserveSubdomainIds(), libMesh::DirectSolutionTransfer::transfer(), libMesh::TreeNode< N >::transform_nodes_to_elements(), libMesh::TriangleInterface::triangulate(), libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole(), libMesh::Poly2TriTriangulator::triangulate_current_points(), libMesh::FroIO::write(), libMesh::TetGenIO::write(), libMesh::MEDITIO::write_ascii(), libMesh::TecplotIO::write_ascii(), libMesh::GMVIO::write_ascii_new_impl(), libMesh::GMVIO::write_ascii_old_impl(), libMesh::TecplotIO::write_binary(), libMesh::GMVIO::write_binary(), libMesh::UCDIO::write_header(), libMesh::GmshIO::write_mesh(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::GmshIO::write_post(), libMesh::System::write_serialized_vectors(), libMesh::UCDIO::write_soln(), and libMesh::VariationalMeshSmoother::writegr().

◆ n_nodes_on_proc()

dof_id_type libMesh::MeshBase::n_nodes_on_proc ( const processor_id_type  proc) const
inherited
Returns
The number of nodes on processor proc.

Definition at line 963 of file mesh_base.C.

References distance(), libMesh::DofObject::invalid_processor_id, libMesh::libmesh_assert(), and libMesh::ParallelObject::n_processors().

Referenced by libMesh::MeshBase::n_local_nodes(), and libMesh::MeshBase::n_unpartitioned_nodes().

964 {
965  // We're either counting a processor's nodes or unpartitioned
966  // nodes
967  libmesh_assert (proc_id < this->n_processors() ||
969 
970  return static_cast<dof_id_type>(std::distance (this->pid_nodes_begin(proc_id),
971  this->pid_nodes_end (proc_id)));
972 }
Real distance(const Point &p)
processor_id_type n_processors() const
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:488
libmesh_assert(ctx)
uint8_t dof_id_type
Definition: id_types.h:67

◆ n_partitions()

unsigned int libMesh::MeshBase::n_partitions ( ) const
inlineinherited
Returns
The number of partitions which have been defined via a call to either mesh.partition() or by building a Partitioner object and calling partition.
Note
The partitioner object is responsible for setting this value.

Definition at line 1322 of file mesh_base.h.

References libMesh::MeshBase::_n_parts.

Referenced by libMesh::Partitioner::assign_partitioning(), copy_nodes_and_elements(), libMesh::MeshBase::get_info(), libMesh::BoundaryInfo::sync(), libMesh::NameBasedIO::write(), libMesh::GMVIO::write_ascii_new_impl(), and libMesh::GMVIO::write_ascii_old_impl().

1323  { return _n_parts; }
unsigned int _n_parts
The number of partitions the mesh has.
Definition: mesh_base.h:1802

◆ n_processors()

processor_id_type libMesh::ParallelObject::n_processors ( ) const
inlineinherited
Returns
The number of processors in the group.

Definition at line 103 of file parallel_object.h.

References libMesh::ParallelObject::_communicator, libMesh::libmesh_assert(), and TIMPI::Communicator::size().

Referenced by libMesh::Partitioner::_find_global_index_by_pid_map(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::DofMap::add_constraints_to_send_list(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::System::add_vector(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::Partitioner::assign_partitioning(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::DistributedMesh::clear(), libMesh::DistributedMesh::clear_elems(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), create_pid_mesh(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_scalar_dofs(), libMesh::DistributedMesh::DistributedMesh(), libMesh::EnsightIO::EnsightIO(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::MeshBase::get_info(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::DistributedMesh::insert_elem(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_elem_on_proc(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::Partitioner::partition(), libMesh::MeshBase::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::DofMap::prepare_send_list(), libMesh::DofMap::print_dof_constraints(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::XdrIO::read_header(), libMesh::CheckpointIO::read_nodes(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::System::read_serialized_vector(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::Partitioner::repartition(), OverlappingFunctorTest::run_partitioner_test(), libMesh::DofMap::scatter_constraints(), libMesh::DistributedMesh::set_next_unique_id(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), WriteVecAndScalar::setupTests(), libMesh::RBEIMEvaluation::side_gather_bfs(), DistributedMeshTest::testRemoteElemError(), CheckpointIOTest::testSplitter(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::VTKIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

104  {
105  processor_id_type returnval =
106  cast_int<processor_id_type>(_communicator.size());
107  libmesh_assert(returnval); // We never have an empty comm
108  return returnval;
109  }
const Parallel::Communicator & _communicator
processor_id_type size() const
uint8_t processor_id_type
libmesh_assert(ctx)

◆ n_sub_elem()

dof_id_type libMesh::MeshBase::n_sub_elem ( ) const
inherited
Returns
The number of elements that will be written out in certain I/O formats.

For example, a 9-noded quadrilateral will be broken into 4 linear sub-elements for plotting purposes. Thus, for a mesh of 2 QUAD9 elements n_tecplot_elem() will return 8. Implemented in terms of element_iterators.

Definition at line 998 of file mesh_base.C.

999 {
1000  dof_id_type ne=0;
1001 
1002  for (const auto & elem : this->element_ptr_range())
1003  ne += elem->n_sub_elem();
1004 
1005  return ne;
1006 }
uint8_t dof_id_type
Definition: id_types.h:67

◆ n_subdomains()

subdomain_id_type libMesh::MeshBase::n_subdomains ( ) const
inherited
Returns
The number of subdomains in the global mesh. Subdomains correspond to separate subsets of the mesh which could correspond e.g. to different materials in a solid mechanics application, or regions where different physical processes are important. The subdomain mapping is independent from the parallel decomposition.

Definition at line 937 of file mesh_base.C.

References libMesh::MeshBase::subdomain_ids().

Referenced by libMesh::MeshBase::get_info(), MeshSubdomainIDTest::testUnpartitioned(), libMesh::XdrIO::write(), and libMesh::NameBasedIO::write_nodal_data().

938 {
939  // This requires an inspection on every processor
940  parallel_object_only();
941 
942  std::set<subdomain_id_type> ids;
943 
944  this->subdomain_ids (ids);
945 
946  return cast_int<subdomain_id_type>(ids.size());
947 }
void subdomain_ids(std::set< subdomain_id_type > &ids, const bool global=true) const
Constructs a list of all subdomain identifiers in the local mesh if global == false, and in the global mesh if global == true (default).
Definition: mesh_base.C:899

◆ n_unpartitioned_elem()

dof_id_type libMesh::MeshBase::n_unpartitioned_elem ( ) const
inlineinherited
Returns
The number of elements owned by no processor.

Definition at line 533 of file mesh_base.h.

References libMesh::DofObject::invalid_processor_id, and libMesh::MeshBase::n_elem_on_proc().

Referenced by libMesh::DistributedMesh::parallel_n_elem(), and libMesh::MeshBase::partition().

dof_id_type n_elem_on_proc(const processor_id_type proc) const
Definition: mesh_base.C:976
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:488

◆ n_unpartitioned_nodes()

dof_id_type libMesh::MeshBase::n_unpartitioned_nodes ( ) const
inlineinherited
Returns
The number of nodes owned by no processor.

Definition at line 427 of file mesh_base.h.

References libMesh::DofObject::invalid_processor_id, and libMesh::MeshBase::n_nodes_on_proc().

Referenced by libMesh::DistributedMesh::parallel_n_nodes().

static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:488
dof_id_type n_nodes_on_proc(const processor_id_type proc) const
Definition: mesh_base.C:963

◆ next_unique_id()

unique_id_type libMesh::MeshBase::next_unique_id ( )
inlineinherited
Returns
The next unique id to be used.

Definition at line 440 of file mesh_base.h.

References libMesh::MeshBase::_next_unique_id.

440 { return _next_unique_id; }
unique_id_type _next_unique_id
The next available unique id for assigning ids to DOF objects.
Definition: mesh_base.h:1849

◆ node_ptr() [1/2]

virtual const Node* libMesh::MeshBase::node_ptr ( const dof_id_type  i) const
pure virtualinherited
Returns
A pointer to the \( i^{th} \) node, which should be present in this processor's subset of the mesh data structure.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

Referenced by libMesh::GMVIO::_read_one_cell(), add_cube_convex_hull_to_mesh(), libMesh::MeshRefinement::add_node(), AllSecondOrderTest::allCompleteOrderMixed(), AllSecondOrderTest::allCompleteOrderRange(), libMesh::DofMap::allgather_recursive_constraints(), AllSecondOrderTest::allSecondOrderMixed(), AllSecondOrderTest::allSecondOrderRange(), libMesh::AbaqusIO::assign_boundary_node_ids(), libMesh::TetGenMeshInterface::assign_nodes_to_elem(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::MeshBase::copy_constraint_rows(), copy_nodes_and_elements(), libMesh::TriangleWrapper::copy_tri_to_mesh(), create_submesh(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::TetGenIO::element_in(), libMesh::TriangulatorInterface::elems_to_segments(), libMesh::TriangulatorInterface::insert_any_extra_boundary_points(), libMesh::Poly2TriTriangulator::insert_refinement_points(), libMesh::MeshTools::libmesh_assert_valid_constraint_rows(), main(), libMesh::MeshBase::node_ref(), libMesh::BoundaryInfo::operator=(), libMesh::BoundaryInfo::parallel_sync_node_ids(), libMesh::DofMap::process_mesh_constraint_rows(), libMesh::Nemesis_IO::read(), libMesh::ExodusII_IO::read(), libMesh::VTKIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::ExodusII_IO_Helper::read_edge_blocks(), libMesh::AbaqusIO::read_elements(), libMesh::UCDIO::read_implementation(), libMesh::GmshIO::read_mesh(), libMesh::OFFIO::read_stream(), libMesh::MatlabIO::read_stream(), libMesh::DofMap::scatter_constraints(), stitching_helper(), libMesh::BoundaryInfo::sync(), NodalNeighborsTest::testOrientation(), EquationSystemsTest::testPostInitAddElem(), SystemsTest::testProjectMatrix3D(), InfFERadialTest::testRefinement(), EquationSystemsTest::testReinitWithNodeElem(), BoundaryInfoTest::testShellFaceConstraints(), MeshSubdomainIDTest::testUnpartitioned(), and libMesh::CheckpointIO::write_nodesets().

◆ node_ptr() [2/2]

virtual Node* libMesh::MeshBase::node_ptr ( const dof_id_type  i)
pure virtualinherited
Returns
A writable pointer to the \( i^{th} \) node, which should be present in this processor's subset of the mesh data structure.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

◆ node_ref() [1/2]

virtual const Node& libMesh::MeshBase::node_ref ( const dof_id_type  i) const
inlinevirtualinherited

◆ node_ref() [2/2]

virtual Node& libMesh::MeshBase::node_ref ( const dof_id_type  i)
inlinevirtualinherited
Returns
A reference to the \( i^{th} \) node, which should be present in this processor's subset of the mesh data structure.

Definition at line 584 of file mesh_base.h.

References libMesh::MeshBase::node_ptr().

585  {
586  return *this->node_ptr(i);
587  }
virtual const Node * node_ptr(const dof_id_type i) const =0

◆ nodes_and_elements_equal()

bool libMesh::MeshBase::nodes_and_elements_equal ( const MeshBase other_mesh) const
protectedinherited

Tests for equality of all elements and nodes in the mesh.

Helper function for subclass_equals() in unstructured mesh subclasses.

Definition at line 1906 of file mesh_base.C.

References libMesh::MeshBase::query_elem_ptr(), and libMesh::MeshBase::query_node_ptr().

1907 {
1908  for (const auto & other_node : other_mesh.node_ptr_range())
1909  {
1910  const Node * node = this->query_node_ptr(other_node->id());
1911  if (!node)
1912  return false;
1913  if (*other_node != *node)
1914  return false;
1915  }
1916  for (const auto & node : this->node_ptr_range())
1917  if (!other_mesh.query_node_ptr(node->id()))
1918  return false;
1919 
1920  for (const auto & other_elem : other_mesh.element_ptr_range())
1921  {
1922  const Elem * elem = this->query_elem_ptr(other_elem->id());
1923  if (!elem)
1924  return false;
1925  if (!other_elem->topologically_equal(*elem))
1926  return false;
1927  }
1928  for (const auto & elem : this->element_ptr_range())
1929  if (!other_mesh.query_elem_ptr(elem->id()))
1930  return false;
1931 
1932  return true;
1933 }
virtual const Node * query_node_ptr(const dof_id_type i) const =0
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0

◆ operator!=()

bool libMesh::MeshBase::operator!= ( const MeshBase other_mesh) const
inlineinherited

Definition at line 128 of file mesh_base.h.

129  {
130  return !(*this == other_mesh);
131  }

◆ operator=() [1/2]

UnstructuredMesh& libMesh::UnstructuredMesh::operator= ( const UnstructuredMesh )
delete

Copy assignment is not allowed.

Referenced by libMesh::ReplicatedMesh::operator=().

◆ operator=() [2/2]

UnstructuredMesh& libMesh::UnstructuredMesh::operator= ( UnstructuredMesh &&  other_mesh)
default

Move assignment is allowed, by subclasses who handle post_dofobject_moves()

◆ operator==()

bool libMesh::MeshBase::operator== ( const MeshBase other_mesh) const
inherited

This tests for exactly-equal data in all the senses that a mathematician would care about (element connectivity, nodal coordinates), but in the senses a programmer would care about it allows for non-equal equivalence in some ways (we accept different Elem/Node addresses in memory) but not others (we do not accept different subclass types, nor even different Elem/Node ids).

Definition at line 212 of file mesh_base.C.

References libMesh::ParallelObject::comm(), libMesh::MeshBase::locally_equals(), and TIMPI::Communicator::min().

213 {
214  LOG_SCOPE("operator==()", "MeshBase");
215 
216  bool is_equal = this->locally_equals(other_mesh);
217  this->comm().min(is_equal);
218  return is_equal;
219 }
const Parallel::Communicator & comm() const
void min(const T &r, T &o, Request &req) const
bool locally_equals(const MeshBase &other_mesh) const
This behaves the same as operator==, but only for the local and ghosted aspects of the mesh; i...
Definition: mesh_base.C:222

◆ own_node()

virtual void libMesh::MeshBase::own_node ( Node )
inlinevirtualinherited

Takes ownership of node n on this partition of a distributed mesh, by setting n.processor_id() to this->processor_id(), as well as changing n.id() and moving it in the mesh's internal container to give it a new authoritative id.

Reimplemented in libMesh::DistributedMesh.

Definition at line 719 of file mesh_base.h.

719 {}

◆ parallel_max_unique_id()

virtual unique_id_type libMesh::MeshBase::parallel_max_unique_id ( ) const
pure virtualinherited

◆ parallel_n_elem()

virtual dof_id_type libMesh::MeshBase::parallel_n_elem ( ) const
pure virtualinherited
Returns
The number of elements in the mesh.

The parallel_n_elem() function computes a parallel-synchronized value on distributed meshes, and so must be called in parallel only.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

Referenced by libMesh::Nemesis_IO_Helper::initialize(), and libMesh::Nemesis_IO::read().

◆ parallel_n_nodes()

virtual dof_id_type libMesh::MeshBase::parallel_n_nodes ( ) const
pure virtualinherited
Returns
The number of nodes in the mesh.

This function and others must be overridden in derived classes since the MeshBase class has no specific storage for nodes or elements. The parallel_n_nodes() function computes a parallel-synchronized value on distributed meshes, and so must be called in parallel only.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

Referenced by libMesh::Nemesis_IO_Helper::initialize(), and libMesh::Nemesis_IO::read().

◆ partition() [1/2]

void libMesh::MeshBase::partition ( const unsigned int  n_parts)
virtualinherited

Call the default partitioner (currently metis_partition()).

Definition at line 1503 of file mesh_base.C.

References libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshBase::is_serial(), libMesh::libmesh_assert(), libMesh::MeshBase::n_unpartitioned_elem(), libMesh::MeshBase::partitioner(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshBase::skip_noncritical_partitioning(), and libMesh::MeshBase::update_post_partitioning().

Referenced by main(), libMesh::split_mesh(), ExtraIntegersTest::test_helper(), MappedSubdomainPartitionerTest::testMappedSubdomainPartitioner(), EquationSystemsTest::testRepartitionThenReinit(), and CheckpointIOTest::testSplitter().

1504 {
1505  // If we get here and we have unpartitioned elements, we need that
1506  // fixed.
1507  if (this->n_unpartitioned_elem() > 0)
1508  {
1509  libmesh_assert (partitioner().get());
1510  libmesh_assert (this->is_serial());
1511  partitioner()->partition (*this, n_parts);
1512  }
1513  // A nullptr partitioner or a skip_partitioning(true) call or a
1514  // skip_noncritical_partitioning(true) call means don't repartition;
1515  // skip_noncritical_partitioning() checks all these.
1516  else if (!skip_noncritical_partitioning())
1517  {
1518  partitioner()->partition (*this, n_parts);
1519  }
1520  else
1521  {
1522  // Adaptive coarsening may have "orphaned" nodes on processors
1523  // whose elements no longer share them. We need to check for
1524  // and possibly fix that.
1526 
1527  // Make sure locally cached partition count is correct
1528  this->recalculate_n_partitions();
1529 
1530  // Make sure any other locally cached data is correct
1531  this->update_post_partitioning();
1532  }
1533 }
void correct_node_proc_ids(MeshBase &)
Changes the processor ids on each node so be the same as the id of the lowest element touching that n...
Definition: mesh_tools.C:2219
bool skip_noncritical_partitioning() const
Definition: mesh_base.h:1216
virtual std::unique_ptr< Partitioner > & partitioner()
A partitioner to use at each prepare_for_use()
Definition: mesh_base.h:154
dof_id_type n_unpartitioned_elem() const
Definition: mesh_base.h:533
virtual bool is_serial() const
Definition: mesh_base.h:205
libmesh_assert(ctx)
unsigned int recalculate_n_partitions()
In a few (very rare) cases, the user may have manually tagged the elements with specific processor ID...
Definition: mesh_base.C:1545
virtual void update_post_partitioning()
Recalculate any cached data after elements and nodes have been repartitioned.
Definition: mesh_base.h:1154

◆ partition() [2/2]

void libMesh::MeshBase::partition ( )
inlineinherited

Definition at line 1139 of file mesh_base.h.

References libMesh::ParallelObject::n_processors().

Referenced by libMesh::MeshBase::prepare_for_use().

1140  { this->partition(this->n_processors()); }
processor_id_type n_processors() const

◆ partitioner()

virtual std::unique_ptr<Partitioner>& libMesh::MeshBase::partitioner ( )
inlinevirtualinherited

A partitioner to use at each prepare_for_use()

Definition at line 154 of file mesh_base.h.

References libMesh::MeshBase::_partitioner.

Referenced by main(), libMesh::MeshBase::partition(), libMesh::BoundaryInfo::sync(), MultiEvaluablePredTest::test(), MeshDeletionsTest::testDeleteElem(), and MappedSubdomainPartitionerTest::testMappedSubdomainPartitioner().

154 { return _partitioner; }
std::unique_ptr< Partitioner > _partitioner
A partitioner to use at each prepare_for_use().
Definition: mesh_base.h:1843

◆ point()

virtual const Point& libMesh::MeshBase::point ( const dof_id_type  i) const
pure virtualinherited

◆ post_dofobject_moves()

void libMesh::MeshBase::post_dofobject_moves ( MeshBase &&  other_mesh)
protectedinherited

Moves any superclass data (e.g.

GhostingFunctors that might rely on element and nodal data (which is managed by subclasses!) being already moved first.

Must be manually called in dofobject-managing subclass move operators.

Definition at line 1872 of file mesh_base.C.

References libMesh::MeshBase::_constraint_rows, libMesh::MeshBase::_default_ghosting, libMesh::MeshBase::_ghosting_functors, libMesh::MeshBase::_partitioner, and libMesh::MeshBase::_shared_functors.

Referenced by libMesh::ReplicatedMesh::operator=().

1873 {
1874  // Now that all the DofObject moving is done, we can move the GhostingFunctor objects
1875  // which include the _default_ghosting,_ghosting_functors and _shared_functors. We also need
1876  // to set the mesh object associated with these functors to the assignee mesh.
1877 
1878  // _default_ghosting
1879  _default_ghosting = std::move(other_mesh._default_ghosting);
1880  _default_ghosting->set_mesh(this);
1881 
1882  // _ghosting_functors
1883  _ghosting_functors = std::move(other_mesh._ghosting_functors);
1884 
1885  for (const auto gf : _ghosting_functors )
1886  {
1887  gf->set_mesh(this);
1888  }
1889 
1890  // _shared_functors
1891  _shared_functors = std::move(other_mesh._shared_functors);
1892 
1893  for (const auto & sf : _shared_functors )
1894  {
1895  (sf.second)->set_mesh(this);
1896  }
1897 
1898  // _constraint_rows
1899  _constraint_rows = std::move(other_mesh._constraint_rows);
1900 
1901  if (other_mesh.partitioner())
1902  _partitioner = std::move(other_mesh.partitioner());
1903 }
constraint_rows_type _constraint_rows
Definition: mesh_base.h:2009
std::set< GhostingFunctor * > _ghosting_functors
The list of all GhostingFunctor objects to be used when distributing a DistributedMesh.
Definition: mesh_base.h:1991
std::unique_ptr< Partitioner > _partitioner
A partitioner to use at each prepare_for_use().
Definition: mesh_base.h:1843
std::map< GhostingFunctor *, std::shared_ptr< GhostingFunctor > > _shared_functors
Hang on to references to any GhostingFunctor objects we were passed in shared_ptr form...
Definition: mesh_base.h:1997
std::unique_ptr< GhostingFunctor > _default_ghosting
The default geometric GhostingFunctor, used to implement standard libMesh element ghosting behavior...
Definition: mesh_base.h:1982

◆ prepare_for_use() [1/3]

void libMesh::MeshBase::prepare_for_use ( const bool  skip_renumber_nodes_and_elements,
const bool  skip_find_neighbors 
)
inherited

Prepare a newly ecreated (or read) mesh for use.

This involves 4 steps: 1.) call find_neighbors() 2.) call partition() 3.) call renumber_nodes_and_elements() 4.) call cache_elem_data()

The argument to skip renumbering is now deprecated - to prevent a mesh from being renumbered, set allow_renumbering(false). The argument to skip finding neighbors is also deprecated. To prevent find_neighbors, set allow_find_neighbors(false)

If this is a distributed mesh, local copies of remote elements will be deleted here - to keep those elements replicated during preparation, set allow_remote_element_removal(false).

Definition at line 710 of file mesh_base.C.

References libMesh::MeshBase::allow_find_neighbors(), libMesh::MeshBase::allow_renumbering(), and libMesh::MeshBase::prepare_for_use().

Referenced by LinearElasticityWithContact::add_contact_edge_elements(), libMesh::MeshTools::Subdivision::all_subdivision(), libMesh::MeshTools::Modification::all_tri(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::MeshRefinement::coarsen_elements(), create_submesh(), libMesh::MeshTools::Modification::flatten(), main(), libMesh::MeshTools::Subdivision::prepare_subdivision_mesh(), libMesh::GMVIO::read(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::MeshRefinement::refine_elements(), libMesh::BoundaryInfo::sync(), MeshSpatialDimensionTest::test1D(), MeshSpatialDimensionTest::test2D(), ExodusTest< elem_type >::test_read_gold(), ExodusTest< elem_type >::test_write(), MeshInputTest::testAbaqusRead(), SystemsTest::testBlockRestrictedVarNDofs(), BoundaryInfoTest::testBoundaryOnChildrenBoundaryIDs(), BoundaryInfoTest::testBoundaryOnChildrenBoundarySides(), BoundaryInfoTest::testBoundaryOnChildrenElementsRefineCoarsen(), BoundaryInfoTest::testBoundaryOnChildrenErrors(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyElementVectorImpl(), MeshInputTest::testCopyNodalSolutionImpl(), MeshDeletionsTest::testDeleteElem(), SystemsTest::testDofCouplingWithVarGroups(), MeshInputTest::testDynaFileMappings(), MeshInputTest::testDynaNoSplines(), MeshInputTest::testDynaReadElem(), MeshInputTest::testDynaReadPatch(), MeshTriangulationTest::testEdgesMesh(), MeshInputTest::testExodusFileMappings(), MeshInputTest::testExodusIGASidesets(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), MeshInputTest::testLowOrderEdgeBlocks(), MeshInputTest::testNemesisReadImpl(), NodalNeighborsTest::testOrientation(), MeshTriangulationTest::testPoly2TriBad1DMultiBoundary(), MeshTriangulationTest::testPoly2TriBad2DMultiBoundary(), MeshTriangulationTest::testPoly2TriBadEdges(), EquationSystemsTest::testPostInitAddElem(), SystemsTest::testProjectMatrix3D(), InfFERadialTest::testRefinement(), EquationSystemsTest::testReinitWithNodeElem(), BoundaryInfoTest::testShellFaceConstraints(), MeshInputTest::testSingleElementImpl(), MeshInputTest::testTetgenIO(), MeshInputTest::testVTKPreserveElemIds(), MeshInputTest::testVTKPreserveSubdomainIds(), tetrahedralize_domain(), libMesh::TriangleInterface::triangulate(), libMesh::Poly2TriTriangulator::triangulate(), libMesh::MeshRefinement::uniformly_coarsen(), and libMesh::MeshRefinement::uniformly_refine().

711 {
712  libmesh_deprecated();
713 
714  // We only respect the users wish if they tell us to skip renumbering. If they tell us not to
715  // skip renumbering but someone previously called allow_renumbering(false), then the latter takes
716  // precedence
717  if (skip_renumber_nodes_and_elements)
718  this->allow_renumbering(false);
719 
720  // We always accept the user's value for skip_find_neighbors, in contrast to skip_renumber
721  const bool old_allow_find_neighbors = this->allow_find_neighbors();
722  this->allow_find_neighbors(!skip_find_neighbors);
723 
724  this->prepare_for_use();
725 
726  this->allow_find_neighbors(old_allow_find_neighbors);
727 }
bool allow_find_neighbors() const
Definition: mesh_base.h:1181
void prepare_for_use()
Definition: mesh_base.C:742
bool allow_renumbering() const
Definition: mesh_base.h:1174

◆ prepare_for_use() [2/3]

void libMesh::MeshBase::prepare_for_use ( const bool  skip_renumber_nodes_and_elements)
inherited

Definition at line 729 of file mesh_base.C.

References libMesh::MeshBase::allow_renumbering(), and libMesh::MeshBase::prepare_for_use().

730 {
731  libmesh_deprecated();
732 
733  // We only respect the users wish if they tell us to skip renumbering. If they tell us not to
734  // skip renumbering but someone previously called allow_renumbering(false), then the latter takes
735  // precedence
736  if (skip_renumber_nodes_and_elements)
737  this->allow_renumbering(false);
738 
739  this->prepare_for_use();
740 }
void prepare_for_use()
Definition: mesh_base.C:742
bool allow_renumbering() const
Definition: mesh_base.h:1174

◆ prepare_for_use() [3/3]

void libMesh::MeshBase::prepare_for_use ( )
inherited

Definition at line 742 of file mesh_base.C.

References libMesh::MeshBase::_allow_remote_element_removal, libMesh::MeshBase::_is_prepared, libMesh::MeshBase::_skip_find_neighbors, libMesh::MeshBase::_skip_renumber_nodes_and_elements, libMesh::MeshBase::cache_elem_data(), libMesh::MeshBase::clear_point_locator(), libMesh::ParallelObject::comm(), libMesh::MeshBase::delete_remote_elements(), libMesh::MeshBase::detect_interior_parents(), libMesh::MeshBase::find_neighbors(), libMesh::MeshBase::get_boundary_info(), libMesh::MeshBase::is_serial(), libMesh::libmesh_assert(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_unique_ids(), libMesh::MeshBase::partition(), libMesh::BoundaryInfo::regenerate_id_sets(), libMesh::MeshBase::reinit_ghosting_functors(), libMesh::MeshBase::remove_orphaned_nodes(), libMesh::MeshBase::renumber_nodes_and_elements(), libMesh::MeshBase::skip_partitioning(), and libMesh::MeshBase::update_parallel_id_counts().

Referenced by all_first_order(), copy_nodes_and_elements(), libMesh::MeshBase::prepare_for_use(), read(), and stitching_helper().

743 {
744  LOG_SCOPE("prepare_for_use()", "MeshBase");
745 
746  parallel_object_only();
747 
748  libmesh_assert(this->comm().verify(this->is_serial()));
749 
750  // A distributed mesh may have processors with no elements (or
751  // processors with no elements of higher dimension, if we ever
752  // support mixed-dimension meshes), but we want consistent
753  // mesh_dimension anyways.
754  //
755  // cache_elem_data() should get the elem_dimensions() and
756  // mesh_dimension() correct later, and we don't need it earlier.
757 
758 
759  // Renumber the nodes and elements so that they in contiguous
760  // blocks. By default, _skip_renumber_nodes_and_elements is false.
761  //
762  // Instances where you if prepare_for_use() should not renumber the nodes
763  // and elements include reading in e.g. an xda/r or gmv file. In
764  // this case, the ordering of the nodes may depend on an accompanying
765  // solution, and the node ordering cannot be changed.
766 
767 
768  // Mesh modification operations might not leave us with consistent
769  // id counts, or might leave us with orphaned nodes we're no longer
770  // using, but our partitioner might need that consistency and/or
771  // might be confused by orphaned nodes.
774  else
775  {
776  this->remove_orphaned_nodes();
778  }
779 
780  // Let all the elements find their neighbors
782  this->find_neighbors();
783 
784  // The user may have set boundary conditions. We require that the
785  // boundary conditions were set consistently. Because we examine
786  // neighbors when evaluating non-raw boundary condition IDs, this
787  // assert is only valid when our neighbor links are in place.
788 #ifdef DEBUG
790 #endif
791 
792  // Search the mesh for all the dimensions of the elements
793  // and cache them.
794  this->cache_elem_data();
795 
796  // Search the mesh for elements that have a neighboring element
797  // of dim+1 and set that element as the interior parent
798  this->detect_interior_parents();
799 
800  // Fix up node unique ids in case mesh generation code didn't take
801  // exceptional care to do so.
802  // MeshCommunication().make_node_unique_ids_parallel_consistent(*this);
803 
804  // We're going to still require that mesh generation code gets
805  // element unique ids consistent.
806 #if defined(DEBUG) && defined(LIBMESH_ENABLE_UNIQUE_ID)
808 #endif
809 
810  // Reset our PointLocator. Any old locator is invalidated any time
811  // the elements in the underlying elements in the mesh have changed,
812  // so we clear it here.
813  this->clear_point_locator();
814 
815  // Allow our GhostingFunctor objects to reinit if necessary.
816  // Do this before partitioning and redistributing, and before
817  // deleting remote elements.
818  this->reinit_ghosting_functors();
819 
820  // Partition the mesh unless *all* partitioning is to be skipped.
821  // If only noncritical partitioning is to be skipped, the
822  // partition() call will still check for orphaned nodes.
823  if (!skip_partitioning())
824  this->partition();
825 
826  // If we're using DistributedMesh, we'll probably want it
827  // parallelized.
829  this->delete_remote_elements();
830 
831  // Much of our boundary info may have been for now-remote parts of the mesh,
832  // in which case we don't want to keep local copies of data meant to be
833  // local. On the other hand we may have deleted, or the user may have added in
834  // a distributed fashion, boundary data that is meant to be global. So we
835  // handle both of those scenarios here
837 
840 
841  // The mesh is now prepared for use.
842  _is_prepared = true;
843 
844 #ifdef DEBUG
846 #ifdef LIBMESH_ENABLE_UNIQUE_ID
848 #endif
849 #endif
850 }
bool _skip_renumber_nodes_and_elements
If this is true then renumbering will be kept to a minimum.
Definition: mesh_base.h:1868
void remove_orphaned_nodes()
Removes any orphaned nodes, nodes not connected to any elements.
Definition: mesh_base.C:690
void detect_interior_parents()
Search the mesh for elements that have a neighboring element of dim+1 and set that element as the int...
Definition: mesh_base.C:1729
const Parallel::Communicator & comm() const
bool _allow_remote_element_removal
If this is false then even on DistributedMesh remote elements will not be deleted during mesh prepara...
Definition: mesh_base.h:1881
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:159
virtual bool is_serial() const
Definition: mesh_base.h:205
virtual void find_neighbors(const bool reset_remote_elements=false, const bool reset_current_list=true)=0
Locate element face (edge in 2D) neighbors.
virtual void update_parallel_id_counts()=0
Updates parallel caches so that methods like n_elem() accurately reflect changes on other processors...
void cache_elem_data()
Definition: mesh_base.C:1662
void clear_point_locator()
Releases the current PointLocator object.
Definition: mesh_base.C:1598
libmesh_assert(ctx)
void libmesh_assert_valid_boundary_ids(const MeshBase &mesh)
A function for verifying that boundary condition ids match across processors.
Definition: mesh_tools.C:1534
bool _skip_find_neighbors
If this is true then we will skip find_neighbors in prepare_for_use.
Definition: mesh_base.h:1873
void regenerate_id_sets()
Clears and regenerates the cached sets of ids.
bool skip_partitioning() const
Definition: mesh_base.h:1233
bool _is_prepared
Flag indicating if the mesh has been prepared for use.
Definition: mesh_base.h:1820
virtual void delete_remote_elements()
When supported, deletes all nonlocal elements of the mesh except for "ghosts" which touch a local ele...
Definition: mesh_base.h:247
void reinit_ghosting_functors()
Loops over ghosting functors and calls mesh_reinit()
Definition: mesh_base.C:853
void libmesh_assert_valid_unique_ids(const MeshBase &mesh)
A function for verifying that unique ids match across processors.
Definition: mesh_tools.C:1732
virtual void renumber_nodes_and_elements()=0
After partitioning a mesh it is useful to renumber the nodes and elements so that they lie in contigu...

◆ print_info()

void libMesh::MeshBase::print_info ( std::ostream &  os = libMesh::out,
const unsigned int  verbosity = 0,
const bool  global = true 
) const
inherited

Prints relevant information about the mesh.

Take note of the docstring for get_info() for more information pretaining to the verbosity and global parameters.

Definition at line 1489 of file mesh_base.C.

References libMesh::MeshBase::get_info().

Referenced by assemble_and_solve(), libMesh::InfElemBuilder::build_inf_elem(), main(), libMesh::operator<<(), and setup().

1490 {
1491  os << this->get_info(verbosity, global)
1492  << std::endl;
1493 }
std::string get_info(const unsigned int verbosity=0, const bool global=true) const
Definition: mesh_base.C:1022

◆ processor_id()

processor_id_type libMesh::ParallelObject::processor_id ( ) const
inlineinherited
Returns
The rank of this processor in the group.

Definition at line 114 of file parallel_object.h.

References libMesh::ParallelObject::_communicator, and TIMPI::Communicator::rank().

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::MeshTools::Modification::all_tri(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::Partitioner::assign_partitioning(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::Partitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::DistributedMesh::clear(), libMesh::DistributedMesh::clear_elems(), libMesh::ExodusII_IO_Helper::close(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::compute_communication_map_parameters(), libMesh::Nemesis_IO_Helper::compute_internal_and_border_elems_and_internal_nodes(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::Nemesis_IO_Helper::compute_node_communication_maps(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::ExodusII_IO_Helper::create(), libMesh::DistributedMesh::delete_elem(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DofMap::distribute_scalar_dofs(), libMesh::DistributedMesh::DistributedMesh(), libMesh::DofMap::end_dof(), libMesh::DofMap::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::find_dofs_to_send(), libMesh::MeshFunction::find_element(), libMesh::MeshFunction::find_elements(), find_neighbors(), libMesh::DofMap::first_dof(), libMesh::DofMap::first_old_dof(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::MeshBase::get_info(), libMesh::DofMap::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::DofMap::get_local_constraints(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), libMesh::SparsityPattern::Build::handle_vi_vj(), libMesh::LaplaceMeshSmoother::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), HeatSystem::init_data(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::DistributedMesh::insert_elem(), libMesh::DofMap::is_evaluable(), libMesh::SparsityPattern::Build::join(), libMesh::TransientRBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEvaluation::legacy_write_offline_data_to_files(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DofMap::local_variable_indices(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), AugmentSparsityOnInterface::mesh_reinit(), libMesh::TriangulatorInterface::MeshedHole::MeshedHole(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::DofMap::n_local_dofs(), libMesh::System::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::SparsityPattern::Build::operator()(), libMesh::DistributedMesh::own_node(), libMesh::BoundaryInfo::parallel_sync_node_ids(), libMesh::BoundaryInfo::parallel_sync_side_ids(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::DofMap::print_dof_constraints(), libMesh::DofMap::process_mesh_constraint_rows(), libMesh::Nemesis_IO_Helper::put_cmap_params(), libMesh::Nemesis_IO_Helper::put_elem_cmap(), libMesh::Nemesis_IO_Helper::put_elem_map(), libMesh::Nemesis_IO_Helper::put_loadbal_param(), libMesh::Nemesis_IO_Helper::put_node_cmap(), libMesh::Nemesis_IO_Helper::put_node_map(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read(), libMesh::EquationSystems::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_global_values(), libMesh::ExodusII_IO::read_header(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::DynaIO::read_mesh(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::System::read_parallel_data(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::System::read_serialized_data(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::Nemesis_IO_Helper::read_var_names_impl(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::DistributedMesh::renumber_nodes_and_elements(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::DistributedMesh::set_next_unique_id(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::RBEIMEvaluation::side_gather_bfs(), ExodusTest< elem_type >::test_read_gold(), ExodusTest< elem_type >::test_write(), MeshInputTest::testAbaqusRead(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyElementVectorImpl(), MeshInputTest::testCopyNodalSolutionImpl(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshInputTest::testDynaFileMappings(), MeshInputTest::testDynaNoSplines(), MeshInputTest::testDynaReadElem(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusFileMappings(), MeshInputTest::testExodusIGASidesets(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), MeshInputTest::testLowOrderEdgeBlocks(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), BoundaryInfoTest::testShellFaceConstraints(), MeshInputTest::testSingleElementImpl(), WriteVecAndScalar::testSolution(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::DTKAdapter::update_variable_values(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::CheckpointIO::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_element_values_element_major(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO_Helper::write_elemset_data(), libMesh::ExodusII_IO_Helper::write_elemsets(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), libMesh::System::write_header(), libMesh::ExodusII_IO::write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::UCDIO::write_nodal_data(), libMesh::VTKIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_common(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), libMesh::ExodusII_IO_Helper::write_nodeset_data(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::RBEIMEvaluation::write_out_interior_basis_functions(), libMesh::RBEIMEvaluation::write_out_node_basis_functions(), libMesh::RBEIMEvaluation::write_out_side_basis_functions(), write_output_solvedata(), libMesh::System::write_parallel_data(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::System::write_serialized_data(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), libMesh::ExodusII_IO_Helper::write_sideset_data(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), libMesh::ExodusII_IO_Helper::write_timestep(), and libMesh::ExodusII_IO::write_timestep_discontinuous().

115  { return cast_int<processor_id_type>(_communicator.rank()); }
processor_id_type rank() const
const Parallel::Communicator & _communicator

◆ query_elem_ptr() [1/2]

virtual const Elem* libMesh::MeshBase::query_elem_ptr ( const dof_id_type  i) const
pure virtualinherited
Returns
A pointer to the \( i^{th} \) element, or nullptr if no such element exists in this processor's mesh data structure.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

Referenced by libMesh::connect_families(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::Nemesis_IO::copy_elemental_solution(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_equal_connectivity(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::MeshTools::libmesh_assert_valid_unique_ids(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshBase::nodes_and_elements_equal(), libMesh::BoundaryInfo::operator==(), libMesh::MeshTools::Modification::permute_elements(), libMesh::VTKIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::XdrIO::read_serialized_bcs_helper(), ParsedFEMFunctionTest::setUp(), MeshDeletionsTest::testDeleteElem(), VolumeTest::testEdge3Volume(), ExtraIntegersTest::testExtraIntegersExodusReading(), MeshBaseTest::testMeshBaseVerifyIsPrepared(), EquationSystemsTest::testRefineThenReinitPreserveFlags(), EquationSystemsTest::testSelectivePRefine(), BoundaryInfoTest::testShellFaceConstraints(), and MeshInputTest::testTetgenIO().

◆ query_elem_ptr() [2/2]

virtual Elem* libMesh::MeshBase::query_elem_ptr ( const dof_id_type  i)
pure virtualinherited
Returns
A writable pointer to the \( i^{th} \) element, or nullptr if no such element exists in this processor's mesh data structure.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

◆ query_node_ptr() [1/2]

virtual const Node* libMesh::MeshBase::query_node_ptr ( const dof_id_type  i) const
pure virtualinherited

◆ query_node_ptr() [2/2]

virtual Node* libMesh::MeshBase::query_node_ptr ( const dof_id_type  i)
pure virtualinherited
Returns
A writable pointer to the \( i^{th} \) node, or nullptr if no such node exists in this processor's mesh data structure.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

◆ read()

void libMesh::UnstructuredMesh::read ( const std::string &  name,
void *  mesh_data = nullptr,
bool  skip_renumber_nodes_and_elements = false,
bool  skip_find_neighbors = false 
)
overridevirtual

Reads the file specified by name.

Attempts to figure out the proper method by the file extension. This is now the only way to read a mesh. The UnstructuredMesh then initializes its data structures and is ready for use.

The skip_renumber_nodes_and_elements argument is now deprecated - to disallow renumbering, set MeshBase::allow_renumbering(false).

Set skip_find_neighbors=true to skip the find-neighbors operation during prepare_for_use. This operation isn't always necessary and it can be time-consuming, which is why we provide an option to skip it.

Implements libMesh::MeshBase.

Definition at line 1221 of file unstructured_mesh.C.

References libMesh::MeshBase::allow_find_neighbors(), libMesh::MeshBase::allow_renumbering(), libMesh::Quality::name(), libMesh::MeshBase::prepare_for_use(), and libMesh::NameBasedIO::read().

Referenced by ExtraIntegersTest::checkpoint_helper(), main(), ExtraIntegersTest::test_helper(), SlitMeshRefinedSystemTest::testRestart(), and WriteElemsetData::testWriteImpl().

1225 {
1226  // Set the skip_renumber_nodes_and_elements flag on all processors
1227  // if necessary.
1228  // This ensures that renumber_nodes_and_elements is *not* called
1229  // during prepare_for_use() for certain types of mesh files.
1230  // This is required in cases where there is an associated solution
1231  // file which expects a certain ordering of the nodes.
1232  if (name.rfind(".gmv") == name.size() - 4)
1233  this->allow_renumbering(false);
1234 
1235  NameBasedIO(*this).read(name);
1236 
1237  if (skip_renumber_nodes_and_elements)
1238  {
1239  // Use MeshBase::allow_renumbering() yourself instead.
1240  libmesh_deprecated();
1241  this->allow_renumbering(false);
1242  }
1243 
1244  // Done reading the mesh. Now prepare it for use.
1245  const bool old_allow_find_neighbors = this->allow_find_neighbors();
1246  this->allow_find_neighbors(!skip_find_neighbors);
1247  this->prepare_for_use();
1248  this->allow_find_neighbors(old_allow_find_neighbors);
1249 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
This class supports simple reads and writes in any libMesh-supported format, by dispatching to one of...
Definition: namebased_io.h:44
virtual void read(const std::string &mesh_file) override
This method implements reading a mesh from a specified file.
Definition: namebased_io.C:80
bool allow_find_neighbors() const
Definition: mesh_base.h:1181
void prepare_for_use()
Definition: mesh_base.C:742
bool allow_renumbering() const
Definition: mesh_base.h:1174

◆ recalculate_n_partitions()

unsigned int libMesh::MeshBase::recalculate_n_partitions ( )
inherited

In a few (very rare) cases, the user may have manually tagged the elements with specific processor IDs by hand, without using a partitioner.

In this case, the Mesh will not know that the total number of partitions, _n_parts, has changed, unless you call this function. This is an O(N active elements) calculation. The return value is the number of partitions, and _n_parts is also set by this function.

Definition at line 1545 of file mesh_base.C.

References libMesh::MeshBase::_n_parts, libMesh::ParallelObject::comm(), and TIMPI::Communicator::max().

Referenced by libMesh::MeshBase::partition().

1546 {
1547  // This requires an inspection on every processor
1548  parallel_object_only();
1549 
1550  unsigned int max_proc_id=0;
1551 
1552  for (const auto & elem : this->active_local_element_ptr_range())
1553  max_proc_id = std::max(max_proc_id, static_cast<unsigned int>(elem->processor_id()));
1554 
1555  // The number of partitions is one more than the max processor ID.
1556  _n_parts = max_proc_id+1;
1557 
1558  this->comm().max(_n_parts);
1559 
1560  return _n_parts;
1561 }
const Parallel::Communicator & comm() const
unsigned int _n_parts
The number of partitions the mesh has.
Definition: mesh_base.h:1802
void max(const T &r, T &o, Request &req) const

◆ redistribute()

void libMesh::MeshBase::redistribute ( )
virtualinherited

Redistribute elements between processors.

This gets called automatically by the Partitioner, and merely notifies any GhostingFunctors of redistribution in the case of a ReplicatedMesh or serialized DistributedMesh

Reimplemented in libMesh::DistributedMesh.

Definition at line 925 of file mesh_base.C.

References libMesh::as_range(), libMesh::MeshBase::ghosting_functors_begin(), and libMesh::MeshBase::ghosting_functors_end().

Referenced by libMesh::Partitioner::partition(), libMesh::DistributedMesh::redistribute(), and libMesh::Partitioner::single_partition().

926 {
927  // We now have all elements and nodes redistributed; our ghosting
928  // functors should be ready to redistribute and/or recompute any
929  // cached data they use too.
930  for (auto & gf : as_range(this->ghosting_functors_begin(),
931  this->ghosting_functors_end()))
932  gf->redistribute();
933 }
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
Helper function that allows us to treat a homogenous pair as a range.
Definition: simple_range.h:57
std::set< GhostingFunctor * >::const_iterator ghosting_functors_begin() const
Beginning of range of ghosting functors.
Definition: mesh_base.h:1268
std::set< GhostingFunctor * >::const_iterator ghosting_functors_end() const
End of range of ghosting functors.
Definition: mesh_base.h:1274

◆ reinit_ghosting_functors()

void libMesh::MeshBase::reinit_ghosting_functors ( )
inherited

Loops over ghosting functors and calls mesh_reinit()

Definition at line 853 of file mesh_base.C.

References libMesh::MeshBase::_ghosting_functors, and libMesh::libmesh_assert().

Referenced by libMesh::MeshBase::prepare_for_use().

854 {
855  for (auto & gf : _ghosting_functors)
856  {
857  libmesh_assert(gf);
858  gf->mesh_reinit();
859  }
860 }
std::set< GhostingFunctor * > _ghosting_functors
The list of all GhostingFunctor objects to be used when distributing a DistributedMesh.
Definition: mesh_base.h:1991
libmesh_assert(ctx)

◆ remove_ghosting_functor()

void libMesh::MeshBase::remove_ghosting_functor ( GhostingFunctor ghosting_functor)
inherited

Removes a functor which was previously added to the set of ghosting functors.

Definition at line 888 of file mesh_base.C.

References libMesh::MeshBase::_ghosting_functors, and libMesh::MeshBase::_shared_functors.

Referenced by libMesh::DofMap::clear(), libMesh::DofMap::remove_algebraic_ghosting_functor(), libMesh::DofMap::remove_coupling_functor(), EquationSystemsTest::testDisableDefaultGhosting(), and libMesh::DofMap::~DofMap().

889 {
890  _ghosting_functors.erase(&ghosting_functor);
891 
892  auto it = _shared_functors.find(&ghosting_functor);
893  if (it != _shared_functors.end())
894  _shared_functors.erase(it);
895 }
std::set< GhostingFunctor * > _ghosting_functors
The list of all GhostingFunctor objects to be used when distributing a DistributedMesh.
Definition: mesh_base.h:1991
std::map< GhostingFunctor *, std::shared_ptr< GhostingFunctor > > _shared_functors
Hang on to references to any GhostingFunctor objects we were passed in shared_ptr form...
Definition: mesh_base.h:1997

◆ remove_orphaned_nodes()

void libMesh::MeshBase::remove_orphaned_nodes ( )
inherited

Removes any orphaned nodes, nodes not connected to any elements.

Typically done automatically in prepare_for_use

Definition at line 690 of file mesh_base.C.

References libMesh::MeshBase::delete_node().

Referenced by libMesh::MeshBase::prepare_for_use().

691 {
692  LOG_SCOPE("remove_orphaned_nodes()", "MeshBase");
693 
694  // Will hold the set of nodes that are currently connected to elements
695  std::unordered_set<Node *> connected_nodes;
696 
697  // Loop over the elements. Find which nodes are connected to at
698  // least one of them.
699  for (const auto & element : this->element_ptr_range())
700  for (auto & n : element->node_ref_range())
701  connected_nodes.insert(&n);
702 
703  for (const auto & node : this->node_ptr_range())
704  if (!connected_nodes.count(node))
705  this->delete_node(node);
706 }
virtual void delete_node(Node *n)=0
Removes the Node n from the mesh.

◆ renumber_elem()

virtual void libMesh::MeshBase::renumber_elem ( dof_id_type  old_id,
dof_id_type  new_id 
)
pure virtualinherited

Changes the id of element old_id, both by changing elem(old_id)->id() and by moving elem(old_id) in the mesh's internal container.

No element with the id new_id should already exist.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

Referenced by libMesh::MeshCommunication::make_elems_parallel_consistent(), and MeshInputTest::testVTKPreserveElemIds().

◆ renumber_node()

virtual void libMesh::MeshBase::renumber_node ( dof_id_type  old_id,
dof_id_type  new_id 
)
pure virtualinherited

Changes the id of node old_id, both by changing node(old_id)->id() and by moving node(old_id) in the mesh's internal container.

No element with the id new_id should already exist.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

◆ renumber_nodes_and_elements()

virtual void libMesh::MeshBase::renumber_nodes_and_elements ( )
pure virtualinherited

After partitioning a mesh it is useful to renumber the nodes and elements so that they lie in contiguous blocks on the processors.

This method does just that.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

Referenced by all_first_order(), contract(), libMesh::MeshBase::prepare_for_use(), and write_output().

◆ reserve_elem()

virtual void libMesh::MeshBase::reserve_elem ( const dof_id_type  ne)
pure virtualinherited

Reserves space for a known number of elements.

Note
This method may or may not do anything, depending on the actual Mesh implementation. If you know the number of elements you will add and call this method before repeatedly calling add_point() the implementation will be more efficient.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

Referenced by libMesh::MeshTools::Generation::build_extrusion(), copy_nodes_and_elements(), libMesh::ExodusII_IO::read(), libMesh::XdrIO::read_header(), and libMesh::GmshIO::read_mesh().

◆ reserve_nodes()

virtual void libMesh::MeshBase::reserve_nodes ( const dof_id_type  nn)
pure virtualinherited

Reserves space for a known number of nodes.

Note
This method may or may not do anything, depending on the actual Mesh implementation. If you know the number of nodes you will add and call this method before repeatedly calling add_point() the implementation will be more efficient.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

Referenced by all_complete_order_range(), all_second_order_range(), libMesh::MeshTools::Generation::build_extrusion(), copy_nodes_and_elements(), libMesh::ExodusII_IO::read(), libMesh::XdrIO::read_header(), and libMesh::GmshIO::read_mesh().

◆ set_count_lower_dim_elems_in_point_locator()

void libMesh::MeshBase::set_count_lower_dim_elems_in_point_locator ( bool  count_lower_dim_elems)
inherited

In the point locator, do we count lower dimensional elements when we refine point locator regions? This is relevant in tree-based point locators, for example.

Definition at line 1605 of file mesh_base.C.

References libMesh::MeshBase::_count_lower_dim_elems_in_point_locator.

1606 {
1607  _count_lower_dim_elems_in_point_locator = count_lower_dim_elems;
1608 }
bool _count_lower_dim_elems_in_point_locator
Do we count lower dimensional elements in point locator refinement? This is relevant in tree-based po...
Definition: mesh_base.h:1835

◆ set_default_mapping_data()

void libMesh::MeshBase::set_default_mapping_data ( const unsigned char  data)
inlineinherited

Set the default master space to physical space mapping basis functions to be used on newly added elements.

Definition at line 818 of file mesh_base.h.

References libMesh::MeshBase::_default_mapping_data.

Referenced by libMesh::ExodusII_IO::read(), and libMesh::DynaIO::read_mesh().

819  {
820  _default_mapping_data = data;
821  }
unsigned char _default_mapping_data
The default mapping data (unused with Lagrange, used for nodal weight lookup index with rational base...
Definition: mesh_base.h:1815

◆ set_default_mapping_type()

void libMesh::MeshBase::set_default_mapping_type ( const ElemMappingType  type)
inlineinherited

Set the default master space to physical space mapping basis functions to be used on newly added elements.

Definition at line 800 of file mesh_base.h.

References libMesh::MeshBase::_default_mapping_type.

Referenced by libMesh::ExodusII_IO::read(), and libMesh::DynaIO::read_mesh().

801  {
802  _default_mapping_type = type;
803  }
ElemMappingType _default_mapping_type
The default mapping type (typically Lagrange) between master and physical space to assign to newly ad...
Definition: mesh_base.h:1808

◆ set_distributed()

virtual void libMesh::MeshBase::set_distributed ( )
inlinevirtualinherited

Asserts that not all elements and nodes of the mesh necessarily exist on the current processor.

Only valid to call on classes which can be created in a distributed form.

Reimplemented in libMesh::DistributedMesh.

Definition at line 220 of file mesh_base.h.

Referenced by libMesh::CheckpointIO::read().

221  { libmesh_error(); }

◆ set_elem_dimensions()

void libMesh::MeshBase::set_elem_dimensions ( std::set< unsigned char >  elem_dims)
inherited

Most of the time you should not need to call this, as the element dimensions will be set automatically by a call to cache_elem_data(), therefore only call this if you know what you're doing.

In some specialized situations, for example when adding a single Elem on all procs, it can be faster to skip calling cache_elem_data() and simply specify the element dimensions manually, which is why this setter exists.

Definition at line 333 of file mesh_base.C.

References libMesh::MeshBase::_elem_dims, and libMesh::MeshBase::cache_elem_data().

334 {
335 #ifdef DEBUG
336  // In debug mode, we call cache_elem_data() and then make sure
337  // the result actually agrees with what the user specified.
338  parallel_object_only();
339 
340  this->cache_elem_data();
341  libmesh_assert_msg(_elem_dims == elem_dims, \
342  "Specified element dimensions does not match true element dimensions!");
343 #endif
344 
345  _elem_dims = std::move(elem_dims);
346 }
void cache_elem_data()
Definition: mesh_base.C:1662
std::set< unsigned char > _elem_dims
We cache the dimension of the elements present in the mesh.
Definition: mesh_base.h:1895

◆ set_isnt_prepared()

void libMesh::MeshBase::set_isnt_prepared ( )
inlineinherited

Tells this we have done some operation where we should no longer consider ourself prepared.

Definition at line 198 of file mesh_base.h.

References libMesh::MeshBase::_is_prepared.

199  { _is_prepared = false; }
bool _is_prepared
Flag indicating if the mesh has been prepared for use.
Definition: mesh_base.h:1820

◆ set_mesh_dimension()

void libMesh::MeshBase::set_mesh_dimension ( unsigned char  d)
inlineinherited

Resets the logical dimension of the mesh.

If the mesh has elements of multiple dimensions, this should be set to the largest dimension. E.g. if the mesh has 1D and 2D elements, this should be set to 2. If the mesh has 2D and 3D elements, this should be set to 3.

Definition at line 269 of file mesh_base.h.

References libMesh::MeshBase::_elem_dims.

Referenced by libMesh::MeshTools::Generation::build_delaunay_square(), libMesh::TriangleWrapper::copy_tri_to_mesh(), libMesh::AbaqusIO::read(), libMesh::GMVIO::read(), libMesh::Nemesis_IO::read(), libMesh::ExodusII_IO::read(), libMesh::VTKIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::CheckpointIO::read_header(), libMesh::UCDIO::read_implementation(), libMesh::GmshIO::read_mesh(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::OFFIO::read_stream(), libMesh::MatlabIO::read_stream(), InfFERadialTest::testRefinement(), libMesh::TriangleInterface::triangulate(), and libMesh::Poly2TriTriangulator::triangulate().

270  { _elem_dims.clear(); _elem_dims.insert(d); }
std::set< unsigned char > _elem_dims
We cache the dimension of the elements present in the mesh.
Definition: mesh_base.h:1895

◆ set_n_partitions()

unsigned int& libMesh::MeshBase::set_n_partitions ( )
inlineprotectedinherited
Returns
A writable reference to the number of partitions.

Definition at line 1789 of file mesh_base.h.

References libMesh::MeshBase::_n_parts.

Referenced by libMesh::Partitioner::partition(), libMesh::Partitioner::repartition(), and libMesh::BoundaryInfo::sync().

1790  { return _n_parts; }
unsigned int _n_parts
The number of partitions the mesh has.
Definition: mesh_base.h:1802

◆ set_next_unique_id()

virtual void libMesh::MeshBase::set_next_unique_id ( unique_id_type  id)
pure virtualinherited

Sets the next available unique id to be used.

On a ReplicatedMesh, or when adding unpartitioned objects to a DistributedMesh, this must be kept in sync on all processors.

On a DistributedMesh, other unique_id values (larger than this one) may be chosen next, to allow unique_id assignment without communication.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

Referenced by copy_nodes_and_elements(), libMesh::Nemesis_IO::read(), and libMesh::XdrIO::read_serialized_nodes().

◆ set_point_locator_close_to_point_tol()

void libMesh::MeshBase::set_point_locator_close_to_point_tol ( Real  val)
inherited

Set value used by PointLocatorBase::close_to_point_tol().

Defaults to 0.0. If nonzero, calls close_to_point_tol() whenever a new PointLocator is built for use by this Mesh. Since the Mesh controls the creation and destruction of the PointLocator, if there are any parameters we need to customize on it, the Mesh will need to know about them.

Definition at line 1822 of file mesh_base.C.

References libMesh::MeshBase::_point_locator, and libMesh::MeshBase::_point_locator_close_to_point_tol.

1823 {
1825  if (_point_locator)
1826  {
1827  if (val > 0.)
1828  _point_locator->set_close_to_point_tol(val);
1829  else
1830  _point_locator->unset_close_to_point_tol();
1831  }
1832 }
std::unique_ptr< PointLocatorBase > _point_locator
A PointLocator class for this mesh.
Definition: mesh_base.h:1829
Real _point_locator_close_to_point_tol
If nonzero, we will call PointLocatorBase::set_close_to_point_tol() on any PointLocators that we crea...
Definition: mesh_base.h:2015

◆ set_spatial_dimension()

void libMesh::MeshBase::set_spatial_dimension ( unsigned char  d)
inherited

Sets the "spatial dimension" of the Mesh.

See the documentation for Mesh::spatial_dimension() for more information.

Definition at line 502 of file mesh_base.C.

References libMesh::MeshBase::_spatial_dimension.

Referenced by MeshSpatialDimensionTest::test2D(), and InfFERadialTest::testRefinement().

503 {
504  // The user can set the _spatial_dimension however they wish,
505  // libMesh will only *increase* the spatial dimension, however,
506  // never decrease it.
507  _spatial_dimension = d;
508 }
unsigned char _spatial_dimension
The "spatial dimension" of the Mesh.
Definition: mesh_base.h:1932

◆ set_subdomain_name_map()

const DofMap& dof_map LIBMESH_COMMA unsigned int std::string& libMesh::MeshBase::set_subdomain_name_map ( )
inlineinherited

Definition at line 1669 of file mesh_base.h.

References libMesh::MeshBase::_block_id_to_name.

Referenced by libMesh::DistributedMesh::DistributedMesh(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::CheckpointIO::read_subdomain_names(), and libMesh::ReplicatedMesh::ReplicatedMesh().

1670  { return _block_id_to_name; }
std::map< subdomain_id_type, std::string > _block_id_to_name
This structure maintains the mapping of named blocks for file formats that support named blocks...
Definition: mesh_base.h:1888

◆ size_elem_extra_integers()

void libMesh::MeshBase::size_elem_extra_integers ( )
protectedinherited

Size extra-integer arrays of all elements in the mesh.

Definition at line 1843 of file mesh_base.C.

References libMesh::MeshBase::_elem_integer_default_values, and libMesh::MeshBase::_elem_integer_names.

Referenced by libMesh::MeshBase::add_elem_data(), libMesh::MeshBase::add_elem_datum(), libMesh::MeshBase::add_elem_integer(), and libMesh::MeshBase::add_elem_integers().

1844 {
1845  const std::size_t new_size = _elem_integer_names.size();
1846  for (auto elem : this->element_ptr_range())
1847  elem->add_extra_integers(new_size, _elem_integer_default_values);
1848 }
std::vector< std::string > _elem_integer_names
The array of names for integer data associated with each element in the mesh.
Definition: mesh_base.h:1938
std::vector< dof_id_type > _elem_integer_default_values
The array of default initialization values for integer data associated with each element in the mesh...
Definition: mesh_base.h:1944

◆ size_node_extra_integers()

void libMesh::MeshBase::size_node_extra_integers ( )
protectedinherited

Size extra-integer arrays of all nodes in the mesh.

Definition at line 1852 of file mesh_base.C.

References libMesh::MeshBase::_node_integer_default_values, and libMesh::MeshBase::_node_integer_names.

Referenced by libMesh::MeshBase::add_node_data(), libMesh::MeshBase::add_node_datum(), libMesh::MeshBase::add_node_integer(), and libMesh::MeshBase::add_node_integers().

1853 {
1854  const std::size_t new_size = _node_integer_names.size();
1855  for (auto node : this->node_ptr_range())
1856  node->add_extra_integers(new_size, _node_integer_default_values);
1857 }
std::vector< std::string > _node_integer_names
The array of names for integer data associated with each node in the mesh.
Definition: mesh_base.h:1950
std::vector< dof_id_type > _node_integer_default_values
The array of default initialization values for integer data associated with each node in the mesh...
Definition: mesh_base.h:1956

◆ skip_noncritical_partitioning() [1/2]

void libMesh::MeshBase::skip_noncritical_partitioning ( bool  skip)
inlineinherited

If true is passed in then the elements on this mesh will no longer be (re)partitioned, and the nodes on this mesh will only be repartitioned if they are found "orphaned" via coarsening or other removal of the last element responsible for their node/element processor id consistency.

Note
It would probably be a bad idea to call this on a DistributedMesh before the first partitioning has happened... because no elements would get assigned to your processor pool.
Skipping partitioning can have adverse effects on your performance when using AMR... i.e. you could get large load imbalances. However you might still want to use this if the communication and computation of the rebalance and repartition is too high for your application.

It is also possible, for backwards-compatibility purposes, to skip noncritical partitioning by resetting the partitioner() pointer for this mesh.

Definition at line 1213 of file mesh_base.h.

References libMesh::MeshBase::_skip_noncritical_partitioning.

Referenced by libMesh::MeshTools::correct_node_proc_ids(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyElementVectorImpl(), and MeshInputTest::testCopyNodalSolutionImpl().

1214  { _skip_noncritical_partitioning = skip; }
bool _skip_noncritical_partitioning
If this is true then no partitioning should be done with the possible exception of orphaned nodes...
Definition: mesh_base.h:1856

◆ skip_noncritical_partitioning() [2/2]

bool libMesh::MeshBase::skip_noncritical_partitioning ( ) const
inlineinherited

Definition at line 1216 of file mesh_base.h.

References libMesh::MeshBase::_partitioner, libMesh::MeshBase::_skip_all_partitioning, and libMesh::MeshBase::_skip_noncritical_partitioning.

Referenced by libMesh::MeshBase::partition().

bool _skip_noncritical_partitioning
If this is true then no partitioning should be done with the possible exception of orphaned nodes...
Definition: mesh_base.h:1856
std::unique_ptr< Partitioner > _partitioner
A partitioner to use at each prepare_for_use().
Definition: mesh_base.h:1843
bool _skip_all_partitioning
If this is true then no partitioning should be done.
Definition: mesh_base.h:1861

◆ skip_partitioning() [1/2]

void libMesh::MeshBase::skip_partitioning ( bool  skip)
inlineinherited

If true is passed in then nothing on this mesh will be (re)partitioned.

Note
The caveats for skip_noncritical_partitioning() still apply, and removing elements from a mesh with this setting enabled can leave node processor ids in an inconsistent state (not matching any attached element), causing failures in other library code. Do not use this setting along with element deletion or coarsening.

Definition at line 1231 of file mesh_base.h.

References libMesh::MeshBase::_skip_all_partitioning.

Referenced by copy_nodes_and_elements().

1231 { _skip_all_partitioning = skip; }
bool _skip_all_partitioning
If this is true then no partitioning should be done.
Definition: mesh_base.h:1861

◆ skip_partitioning() [2/2]

bool libMesh::MeshBase::skip_partitioning ( ) const
inlineinherited

Definition at line 1233 of file mesh_base.h.

References libMesh::MeshBase::_skip_all_partitioning.

Referenced by copy_nodes_and_elements(), and libMesh::MeshBase::prepare_for_use().

1233 { return _skip_all_partitioning; }
bool _skip_all_partitioning
If this is true then no partitioning should be done.
Definition: mesh_base.h:1861

◆ spatial_dimension()

unsigned int libMesh::MeshBase::spatial_dimension ( ) const
inherited
Returns
The "spatial dimension" of the mesh.

The spatial dimension is defined as:

1 - for an exactly x-aligned mesh of 1D elements 2 - for an exactly x-y planar mesh of 2D elements 3 - otherwise

No tolerance checks are performed to determine whether the Mesh is x-aligned or x-y planar, only strict equality with zero in the higher dimensions is checked. Also, x-z and y-z planar meshes are considered to have spatial dimension == 3.

The spatial dimension is updated during prepare_for_use() based on the dimensions of the various elements present in the Mesh, but is never automatically decreased by this function.

For example, if the user calls set_spatial_dimension(2) and then later inserts 3D elements into the mesh, Mesh::spatial_dimension() will return 3 after the next call to prepare_for_use(). On the other hand, if the user calls set_spatial_dimension(3) and then inserts only x-aligned 1D elements into the Mesh, mesh.spatial_dimension() will remain 3.

Definition at line 495 of file mesh_base.C.

References libMesh::MeshBase::_spatial_dimension.

Referenced by libMesh::MeshBase::get_info(), libMesh::ExodusII_IO_Helper::initialize(), MeshSpatialDimensionTest::test1D(), and MeshSpatialDimensionTest::test2D().

496 {
497  return cast_int<unsigned int>(_spatial_dimension);
498 }
unsigned char _spatial_dimension
The "spatial dimension" of the Mesh.
Definition: mesh_base.h:1932

◆ stitch_meshes()

std::size_t libMesh::UnstructuredMesh::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 
)

Stitch other_mesh to this mesh so that this mesh is the union of the two meshes.

this_mesh_boundary and other_mesh_boundary are used to specify a dim-1 dimensional surface on which we seek to merge any "overlapping" nodes, where we use the parameter tol as a relative tolerance (relative to the smallest edge length on the surfaces being stitched) to determine whether or not nodes are overlapping. If clear_stitched_boundary_ids==true, this function clears boundary_info IDs in this mesh associated this_mesh_boundary and other_mesh_boundary. If use_binary_search is true, we use an optimized "sort then binary search" algorithm for finding matching nodes. Otherwise we use a N^2 algorithm (which can be more reliable at dealing with slightly misaligned meshes). If enforce_all_nodes_match_on_boundaries is true, we throw an error if the number of nodes on the specified boundaries don't match the number of nodes that were merged. This is a helpful error check in some cases. If this is true, it overrides the value of merge_boundary_nodes_all_or_nothing. If skip_find_neighbors is true, a faster stitching method is used, where the lists of neighbors for each elements are copied as well and patched, without calling the time-consuming find_neighbors() function. This option is now hard-coded to true. If merge_boundary_nodes_all_or_nothing is true, instead of throwing an error like enforce_all_nodes_match_on_boundaries, the meshes are combined anyway but coincident nodes are not merged into single nodes. This is useful in cases where you are not sure if the boundaries are fully conforming beforehand and you want to handle the non-conforming cases differently.

Note that the element IDs for elements in the stitched mesh corresponding to "this" mesh will be unchanged. The IDs for elements corresponding to other_mesh will be incremented by this->max_elem_id().

There is no simple a priori relationship between node IDs in "this" mesh and other_mesh and node IDs in the stitched mesh because the number of nodes (and hence the node IDs) in the stitched mesh depend on how many nodes are stitched.

If remap_subdomain_ids is true then we assume that some subdomain ids might have been autogenerated, so we remap them as necessary, treating subdomain names as the important thing for consistency; if we have missing names and cannot infer a consistent resolution to an id conflict then we exit with an error. If remap_subdomain_ids is false then we revert to the older libMesh behavior: leave all subdomain ids alone and woe unto you if you weren't keeping track of them.

Returns
the count of how many nodes were merged between the two meshes. This can be zero in the case of no matching nodes or if merge_boundary_nodes_all_or_nothing was active and relevant.

Definition at line 1750 of file unstructured_mesh.C.

References stitching_helper().

1760 {
1761  LOG_SCOPE("stitch_meshes()", "UnstructuredMesh");
1762  return stitching_helper(&other_mesh,
1763  this_mesh_boundary_id,
1764  other_mesh_boundary_id,
1765  tol,
1766  clear_stitched_boundary_ids,
1767  verbose,
1768  use_binary_search,
1769  enforce_all_nodes_match_on_boundaries,
1770  true,
1771  merge_boundary_nodes_all_or_nothing,
1772  remap_subdomain_ids);
1773 }
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)
Helper function for stitch_meshes and stitch_surfaces that does the mesh stitching.

◆ stitch_surfaces()

std::size_t libMesh::UnstructuredMesh::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 
)

Similar to stitch_meshes, except that we stitch two adjacent surfaces within this mesh.

Definition at line 1777 of file unstructured_mesh.C.

References stitching_helper().

1786 {
1787  return stitching_helper(nullptr,
1788  boundary_id_1,
1789  boundary_id_2,
1790  tol,
1791  clear_stitched_boundary_ids,
1792  verbose,
1793  use_binary_search,
1794  enforce_all_nodes_match_on_boundaries,
1795  true,
1796  merge_boundary_nodes_all_or_nothing,
1797  false);
1798 }
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)
Helper function for stitch_meshes and stitch_surfaces that does the mesh stitching.

◆ stitching_helper()

std::size_t libMesh::UnstructuredMesh::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 
)
private

Helper function for stitch_meshes and stitch_surfaces that does the mesh stitching.

Definition at line 1802 of file unstructured_mesh.C.

References libMesh::BoundaryInfo::add_edge(), libMesh::MeshBase::add_elemset_code(), libMesh::BoundaryInfo::add_node(), libMesh::BoundaryInfo::add_shellface(), libMesh::BoundaryInfo::add_side(), libMesh::MeshBase::allow_find_neighbors(), libMesh::MeshBase::allow_remote_element_removal(), libMesh::Utility::binary_find(), libMesh::BoundaryInfo::boundary_ids(), libMesh::BoundaryInfo::build_edge_list(), libMesh::BoundaryInfo::build_node_list(), libMesh::BoundaryInfo::build_shellface_list(), libMesh::BoundaryInfo::build_side_list(), libMesh::BoundaryInfo::clear_stitched_boundary_side_ids(), copy_nodes_and_elements(), libMesh::MeshBase::delete_node(), libMesh::Elem::dim(), libMesh::BoundaryInfo::edge_boundary_ids(), libMesh::MeshBase::elem_ptr(), libMesh::MeshBase::get_boundary_info(), libMesh::BoundaryInfo::get_edgeset_name_map(), libMesh::MeshBase::get_elemset_codes(), libMesh::MeshBase::get_elemsets(), libMesh::BoundaryInfo::get_nodeset_name_map(), libMesh::BoundaryInfo::get_sideset_name(), libMesh::BoundaryInfo::get_sideset_name_map(), libMesh::MeshBase::get_subdomain_name_map(), libMesh::BoundaryInfo::invalid_id, libMesh::invalid_uint, libMesh::Elem::level(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::Elem::local_node(), libMesh::Elem::low_order_key(), libMesh::MeshBase::max_elem_id(), libMesh::MeshBase::max_node_id(), mesh, libMesh::Elem::neighbor_ptr(), libMesh::Elem::node_ptr(), libMesh::MeshBase::node_ptr(), libMesh::MeshBase::node_ref(), libMesh::TensorTools::norm(), libMesh::out, libMesh::MeshBase::parallel_max_unique_id(), libMesh::MeshBase::point(), libMesh::MeshBase::prepare_for_use(), libMesh::Real, libMesh::BoundaryInfo::set_edgeset_name_map(), libMesh::Elem::set_neighbor(), libMesh::Elem::set_node(), libMesh::BoundaryInfo::set_nodeset_name_map(), libMesh::BoundaryInfo::set_sideset_name_map(), side_id, libMesh::Elem::side_index_range(), libMesh::Elem::side_ptr(), libMesh::Elem::subactive(), libMesh::MeshBase::subdomain_name(), and libMesh::TOLERANCE.

Referenced by stitch_meshes(), and stitch_surfaces().

1813 {
1814 #ifdef DEBUG
1815  // We rely on neighbor links here
1817 #endif
1818 
1819  // FIXME: make distributed mesh support efficient.
1820  // Yes, we currently suck.
1821  MeshSerializer serialize(*this);
1822 
1823  // *Badly*.
1824  std::unique_ptr<MeshSerializer> serialize_other;
1825  if (other_mesh)
1826  serialize_other = std::make_unique<MeshSerializer>
1827  (*const_cast<MeshBase *>(other_mesh));
1828 
1829  std::map<dof_id_type, dof_id_type> node_to_node_map, other_to_this_node_map; // The second is the inverse map of the first
1830  std::map<dof_id_type, std::vector<dof_id_type>> node_to_elems_map;
1831 
1832  typedef dof_id_type key_type;
1833  typedef std::pair<const Elem *, unsigned char> val_type;
1834  typedef std::pair<key_type, val_type> key_val_pair;
1835  typedef std::unordered_multimap<key_type, val_type> map_type;
1836  // Mapping between all side keys in this mesh and elements+side numbers relevant to the boundary in this mesh as well.
1837  map_type side_to_elem_map;
1838 
1839  // If there is only one mesh (i.e. other_mesh == nullptr), then loop over this mesh twice
1840  if (!other_mesh)
1841  {
1842  other_mesh = this;
1843  }
1844 
1845  if ((this_mesh_boundary_id != BoundaryInfo::invalid_id) &&
1846  (other_mesh_boundary_id != BoundaryInfo::invalid_id))
1847  {
1848  LOG_SCOPE("stitch_meshes node merging", "UnstructuredMesh");
1849 
1850  // While finding nodes on the boundary, also find the minimum edge length
1851  // of all faces on both boundaries. This will later be used in relative
1852  // distance checks when stitching nodes.
1853  Real h_min = std::numeric_limits<Real>::max();
1854  bool h_min_updated = false;
1855 
1856  // Loop below fills in these sets for the two meshes.
1857  std::set<dof_id_type> this_boundary_node_ids, other_boundary_node_ids;
1858 
1859  // Pull objects out of the loop to reduce heap operations
1860  std::unique_ptr<const Elem> side;
1861 
1862  {
1863  // Make temporary fixed-size arrays for loop
1864  boundary_id_type id_array[2] = {this_mesh_boundary_id, other_mesh_boundary_id};
1865  std::set<dof_id_type> * set_array[2] = {&this_boundary_node_ids, &other_boundary_node_ids};
1866  const MeshBase * mesh_array[2] = {this, other_mesh};
1867 
1868  for (unsigned i=0; i<2; ++i)
1869  {
1870  // First we deal with node boundary IDs.
1871  // We only enter this loop if we have at least one
1872  // nodeset.
1873  if (mesh_array[i]->get_boundary_info().n_nodeset_conds() > 0)
1874  {
1875  // build_node_list() returns a vector of (node-id, bc-id) tuples
1876  for (const auto & t : mesh_array[i]->get_boundary_info().build_node_list())
1877  {
1878  boundary_id_type node_bc_id = std::get<1>(t);
1879  if (node_bc_id == id_array[i])
1880  {
1881  dof_id_type this_node_id = std::get<0>(t);
1882  set_array[i]->insert( this_node_id );
1883 
1884  // We need to set h_min to some value. It's too expensive to
1885  // search for the element that actually contains this node,
1886  // since that would require a PointLocator. As a result, we
1887  // just use the first (non-NodeElem!) element in the mesh to
1888  // give us hmin if it's never been set before.
1889  if (!h_min_updated)
1890  {
1891  for (const auto & elem : mesh_array[i]->active_element_ptr_range())
1892  {
1893  Real current_h_min = elem->hmin();
1894  if (current_h_min > 0.)
1895  {
1896  h_min = current_h_min;
1897  h_min_updated = true;
1898  break;
1899  }
1900  }
1901 
1902  // If, after searching all the active elements, we did not update
1903  // h_min, give up and set h_min to 1 so that we don't repeat this
1904  // fruitless search
1905  if (!h_min_updated)
1906  {
1907  h_min_updated = true;
1908  h_min = 1.0;
1909  }
1910  }
1911  }
1912  }
1913  }
1914 
1915  // Container to catch boundary IDs passed back from BoundaryInfo.
1916  std::vector<boundary_id_type> bc_ids;
1917 
1918  for (auto & el : mesh_array[i]->element_ptr_range())
1919  {
1920  // Now check whether elem has a face on the specified boundary
1921  for (auto side_id : el->side_index_range())
1922  if (el->neighbor_ptr(side_id) == nullptr)
1923  {
1924  // Get *all* boundary IDs on this side, not just the first one!
1925  mesh_array[i]->get_boundary_info().boundary_ids (el, side_id, bc_ids);
1926 
1927  if (std::find(bc_ids.begin(), bc_ids.end(), id_array[i]) != bc_ids.end())
1928  {
1929  el->build_side_ptr(side, side_id);
1930  for (auto & n : side->node_ref_range())
1931  set_array[i]->insert(n.id());
1932 
1933  h_min = std::min(h_min, side->hmin());
1934  h_min_updated = true;
1935 
1936  // This side is on the boundary, add its information to side_to_elem
1937  if (skip_find_neighbors && (i==0))
1938  {
1939  key_type key = el->low_order_key(side_id);
1940  val_type val;
1941  val.first = el;
1942  val.second = cast_int<unsigned char>(side_id);
1943 
1944  key_val_pair kvp;
1945  kvp.first = key;
1946  kvp.second = val;
1947  side_to_elem_map.insert (kvp);
1948  }
1949  }
1950 
1951  // Also, check the edges on this side. We don't have to worry about
1952  // updating neighbor info in this case since elements don't store
1953  // neighbor info on edges.
1954  for (auto edge_id : el->edge_index_range())
1955  {
1956  if (el->is_edge_on_side(edge_id, side_id))
1957  {
1958  // Get *all* boundary IDs on this edge, not just the first one!
1959  mesh_array[i]->get_boundary_info().edge_boundary_ids (el, edge_id, bc_ids);
1960 
1961  if (std::find(bc_ids.begin(), bc_ids.end(), id_array[i]) != bc_ids.end())
1962  {
1963  std::unique_ptr<const Elem> edge (el->build_edge_ptr(edge_id));
1964  for (auto & n : edge->node_ref_range())
1965  set_array[i]->insert( n.id() );
1966 
1967  h_min = std::min(h_min, edge->hmin());
1968  h_min_updated = true;
1969  }
1970  }
1971  }
1972  }
1973  }
1974  }
1975  }
1976 
1977  if (verbose)
1978  {
1979  libMesh::out << "In UnstructuredMesh::stitch_meshes:\n"
1980  << "This mesh has " << this_boundary_node_ids.size()
1981  << " nodes on boundary `"
1982  << this->get_boundary_info().get_sideset_name(this_mesh_boundary_id)
1983  << "' (" << this_mesh_boundary_id << ").\n"
1984  << "Other mesh has " << other_boundary_node_ids.size()
1985  << " nodes on boundary `"
1986  << this->get_boundary_info().get_sideset_name(other_mesh_boundary_id)
1987  << "' (" << other_mesh_boundary_id << ").\n";
1988 
1989  if (h_min_updated)
1990  {
1991  libMesh::out << "Minimum edge length on both surfaces is " << h_min << ".\n";
1992  }
1993  else
1994  {
1995  libMesh::out << "No elements on specified surfaces." << std::endl;
1996  }
1997  }
1998 
1999  // At this point, if h_min==0 it means that there were at least two coincident
2000  // nodes on the surfaces being stitched, and we don't currently support that case.
2001  // (It might be possible to support, but getting it exactly right would be tricky
2002  // and probably not worth the extra complications to the "normal" case.)
2003  libmesh_error_msg_if(h_min < std::numeric_limits<Real>::epsilon(),
2004  "Coincident nodes detected on source and/or target "
2005  "surface, stitching meshes is not possible.");
2006 
2007  // We require nanoflann for the "binary search" (really kd-tree)
2008  // option to work. If it's not available, turn that option off,
2009  // warn the user, and fall back on the N^2 search algorithm.
2010  if (use_binary_search)
2011  {
2012 #ifndef LIBMESH_HAVE_NANOFLANN
2013  use_binary_search = false;
2014  libmesh_warning("The use_binary_search option in the "
2015  "UnstructuredMesh stitching algorithms requires nanoflann "
2016  "support. Falling back on N^2 search algorithm.");
2017 #endif
2018  }
2019 
2020  if (this_boundary_node_ids.size())
2021  {
2022  if (use_binary_search)
2023  {
2024 #ifdef LIBMESH_HAVE_NANOFLANN
2025  typedef nanoflann::KDTreeSingleIndexAdaptor<nanoflann::L2_Simple_Adaptor<Real, VectorOfNodesAdaptor>,
2026  VectorOfNodesAdaptor, 3, std::size_t> kd_tree_t;
2027 
2028  // Create the dataset needed to build the kd tree with nanoflann
2029  std::vector<std::pair<Point, dof_id_type>> this_mesh_nodes(this_boundary_node_ids.size());
2030  std::set<dof_id_type>::iterator current_node = this_boundary_node_ids.begin(),
2031  node_ids_end = this_boundary_node_ids.end();
2032  for (unsigned int ctr = 0; current_node != node_ids_end; ++current_node, ++ctr)
2033  {
2034  this_mesh_nodes[ctr].first = this->point(*current_node);
2035  this_mesh_nodes[ctr].second = *current_node;
2036  }
2037 
2038  VectorOfNodesAdaptor vec_nodes_adaptor(this_mesh_nodes);
2039 
2040  kd_tree_t this_kd_tree(3, vec_nodes_adaptor, 10);
2041  this_kd_tree.buildIndex();
2042 
2043  // Storage for nearest neighbor in the loop below
2044  std::size_t ret_index;
2045  Real ret_dist_sqr;
2046 
2047  // Loop over other mesh. For each node, find its nearest neighbor in this mesh, and fill in the maps.
2048  for (auto node : other_boundary_node_ids)
2049  {
2050  const Real query_pt[] = {other_mesh->point(node)(0), other_mesh->point(node)(1), other_mesh->point(node)(2)};
2051  this_kd_tree.knnSearch(&query_pt[0], 1, &ret_index, &ret_dist_sqr);
2052  if (ret_dist_sqr < TOLERANCE*TOLERANCE)
2053  {
2054  node_to_node_map[this_mesh_nodes[ret_index].second] = node;
2055  other_to_this_node_map[node] = this_mesh_nodes[ret_index].second;
2056  }
2057  }
2058 
2059  // If the 2 maps don't have the same size, it means we have overwritten a value in node_to_node_map
2060  // It means one node in this mesh is the nearest neighbor of several nodes in other mesh.
2061  // Not possible !
2062  libmesh_error_msg_if(node_to_node_map.size() != other_to_this_node_map.size(),
2063  "Error: Found multiple matching nodes in stitch_meshes");
2064 #endif
2065  }
2066  else
2067  {
2068  // In the unlikely event that two meshes composed entirely of
2069  // NodeElems are being stitched together, we will not have
2070  // selected a valid h_min value yet, and the distance
2071  // comparison below will be true for essentially any two
2072  // nodes. In this case we simply fall back on an absolute
2073  // distance check.
2074  if (!h_min_updated)
2075  {
2076  libmesh_warning("No valid h_min value was found, falling back on "
2077  "absolute distance check in the N^2 search algorithm.");
2078  h_min = 1.;
2079  }
2080 
2081  // Otherwise, use a simple N^2 search to find the closest matching points. This can be helpful
2082  // in the case that we have tolerance issues which cause mismatch between the two surfaces
2083  // that are being stitched.
2084  for (const auto & this_node_id : this_boundary_node_ids)
2085  {
2086  Node & this_node = this->node_ref(this_node_id);
2087 
2088  bool found_matching_nodes = false;
2089 
2090  for (const auto & other_node_id : other_boundary_node_ids)
2091  {
2092  const Node & other_node = other_mesh->node_ref(other_node_id);
2093 
2094  Real node_distance = (this_node - other_node).norm();
2095 
2096  if (node_distance < tol*h_min)
2097  {
2098  // Make sure we didn't already find a matching node!
2099  libmesh_error_msg_if(found_matching_nodes,
2100  "Error: Found multiple matching nodes in stitch_meshes");
2101 
2102  node_to_node_map[this_node_id] = other_node_id;
2103  other_to_this_node_map[other_node_id] = this_node_id;
2104 
2105  found_matching_nodes = true;
2106  }
2107  }
2108  }
2109  }
2110  }
2111 
2112  // Build up the node_to_elems_map, using only one loop over other_mesh
2113  for (auto & el : other_mesh->element_ptr_range())
2114  {
2115  // For each node on the element, find the corresponding node
2116  // on "this" Mesh, 'this_node_id', if it exists, and push
2117  // the current element ID back onto node_to_elems_map[this_node_id].
2118  // For that we will use the reverse mapping we created at
2119  // the same time as the forward mapping.
2120  for (auto & n : el->node_ref_range())
2121  {
2122  dof_id_type other_node_id = n.id();
2123  std::map<dof_id_type, dof_id_type>::iterator it =
2124  other_to_this_node_map.find(other_node_id);
2125 
2126  if (it != other_to_this_node_map.end())
2127  {
2128  dof_id_type this_node_id = it->second;
2129  node_to_elems_map[this_node_id].push_back( el->id() );
2130  }
2131  }
2132  }
2133 
2134  if (verbose)
2135  {
2136  libMesh::out << "In UnstructuredMesh::stitch_meshes:\n"
2137  << "Found " << node_to_node_map.size()
2138  << " matching nodes.\n"
2139  << std::endl;
2140  }
2141 
2142  if (enforce_all_nodes_match_on_boundaries)
2143  {
2144  std::size_t n_matching_nodes = node_to_node_map.size();
2145  std::size_t this_mesh_n_nodes = this_boundary_node_ids.size();
2146  std::size_t other_mesh_n_nodes = other_boundary_node_ids.size();
2147  libmesh_error_msg_if((n_matching_nodes != this_mesh_n_nodes) || (n_matching_nodes != other_mesh_n_nodes),
2148  "Error: We expected the number of nodes to match.");
2149  }
2150 
2151  if (merge_boundary_nodes_all_or_nothing)
2152  {
2153  std::size_t n_matching_nodes = node_to_node_map.size();
2154  std::size_t this_mesh_n_nodes = this_boundary_node_ids.size();
2155  std::size_t other_mesh_n_nodes = other_boundary_node_ids.size();
2156  if ((n_matching_nodes != this_mesh_n_nodes) || (n_matching_nodes != other_mesh_n_nodes))
2157  {
2158  if (verbose)
2159  {
2160  libMesh::out << "Skipping node merging in "
2161  "UnstructuredMesh::stitch_meshes because not "
2162  "all boundary nodes were matched."
2163  << std::endl;
2164  }
2165  node_to_node_map.clear();
2166  other_to_this_node_map.clear();
2167  node_to_elems_map.clear();
2168  }
2169  }
2170  }
2171  else
2172  {
2173  if (verbose)
2174  {
2175  libMesh::out << "Skip node merging in UnstructuredMesh::stitch_meshes:" << std::endl;
2176  }
2177  }
2178 
2179  dof_id_type node_delta = this->max_node_id();
2180  dof_id_type elem_delta = this->max_elem_id();
2181 
2182  unique_id_type unique_delta =
2183 #ifdef LIBMESH_ENABLE_UNIQUE_ID
2184  this->parallel_max_unique_id();
2185 #else
2186  0;
2187 #endif
2188 
2189  // If other_mesh != nullptr, then we have to do a bunch of work
2190  // in order to copy it to this mesh
2191  if (this!=other_mesh)
2192  {
2193  LOG_SCOPE("stitch_meshes copying", "UnstructuredMesh");
2194 
2195  // Increment the node_to_node_map and node_to_elems_map
2196  // to account for id offsets
2197  for (auto & pr : node_to_node_map)
2198  pr.second += node_delta;
2199 
2200  for (auto & pr : node_to_elems_map)
2201  for (auto & entry : pr.second)
2202  entry += elem_delta;
2203 
2204  // We run into problems when the libMesh subdomain standard (the
2205  // id defines the subdomain; the name was an afterthought) and
2206  // the MOOSE standard (the name defines the subdomain; the id
2207  // might be autogenerated) clash.
2208  //
2209  // Subdomain ids with the same name in both meshes are surely
2210  // meant to represent the same subdomain. We can just merge
2211  // them.
2212  //
2213  // Subdomain ids which don't have a name in either mesh are
2214  // almost surely meant to represent the same subdomain. We'll
2215  // just merge them.
2216  //
2217  // Subdomain ids with different names in different meshes, or
2218  // names with different ids in different meshes, are trickier.
2219  // For backwards compatibility we default to the old "just copy
2220  // all the subdomain ids over" behavior, but if requested we'll
2221  // remap any ids that appear to be clear conflicts, and we'll
2222  // scream and die if we see any ids that are ambiguous due to
2223  // being named in one mesh but not the other.
2224  std::unordered_map<subdomain_id_type, subdomain_id_type> id_remapping;
2225  if (remap_subdomain_ids)
2226  {
2227  const auto & this_map = this->get_subdomain_name_map();
2228  const auto & other_map = other_mesh->get_subdomain_name_map();
2229  std::unordered_map<std::string, subdomain_id_type> other_map_reversed;
2230  for (auto & [sid, sname] : other_map)
2231  other_map_reversed.emplace(sname, sid);
2232 
2233  std::unordered_map<std::string, subdomain_id_type> this_map_reversed;
2234  for (auto & [sid, sname] : this_map)
2235  this_map_reversed.emplace(sname, sid);
2236 
2237  // We don't require either mesh to be prepared, but that
2238  // means we need to check for subdomains manually.
2239  auto get_subdomains = [](const MeshBase & mesh) {
2240  std::set<subdomain_id_type> all_subdomains;
2241  for (auto & el : mesh.element_ptr_range())
2242  all_subdomains.insert(el->subdomain_id());
2243  return all_subdomains;
2244  };
2245 
2246  const auto this_subdomains = get_subdomains(*this);
2247  const auto other_subdomains = get_subdomains(*other_mesh);
2248 
2249  for (auto & [sid, sname] : this_map)
2250  {
2251  auto other_reverse_it = other_map_reversed.find(sname);
2252 
2253  // The same name with the same id means we're fine. The
2254  // same name with another id means we remap their id to
2255  // ours
2256  if (other_reverse_it != other_map_reversed.end())
2257  {
2258  if (other_reverse_it->second != sid)
2259  id_remapping[other_reverse_it->second] = sid;
2260  }
2261 
2262  // The same id with a different name, we'll get to
2263  // later. The same id without any name means we don't
2264  // know what the user wants.
2265  if (other_subdomains.count(sid) && !other_map.count(sid))
2266  libmesh_error_msg("Can't safely stitch with a mesh sharing subdomain id "
2267  << sid << " but not subdomain name " << sname);
2268  }
2269 
2270  subdomain_id_type next_free_id = 0;
2271  // We might try to stitch empty meshes ...
2272  if (!this_subdomains.empty())
2273  next_free_id = *this_subdomains.rbegin() + 1;
2274  if (!other_subdomains.empty())
2275  next_free_id =
2276  std::max(next_free_id,
2277  cast_int<subdomain_id_type>
2278  (*other_subdomains.rbegin() + 1));
2279 
2280  for (auto & [sid, sname] : other_map)
2281  {
2282  auto reverse_it = this_map_reversed.find(sname);
2283 
2284  // At this point we've figured out any remapping
2285  // necessary for an sname that we share. And we don't
2286  // need to remap any sid we don't share.
2287  if (reverse_it == this_map_reversed.end())
2288  {
2289  // But if we don't have this sname and we do have this
2290  // sid then we can't just merge into that.
2291  if (this_subdomains.count(sid))
2292  {
2293  // If we have this sid with no name, we don't
2294  // know what the user wants.
2295  if (!this_map.count(sid))
2296  libmesh_error_msg("Can't safely stitch with a mesh sharing subdomain id "
2297  << sid << " but under subdomain name " << sname);
2298 
2299  // We have this sid under a different name, so
2300  // we just need to give the other elements a new
2301  // id.
2302 
2303  // Users might have done crazy things with id
2304  // choice so let's make sure they didn't get too
2305  // crazy.
2306  libmesh_error_msg_if ((!this_subdomains.empty() &&
2307  next_free_id < *this_subdomains.rbegin()) ||
2308  (!other_subdomains.empty() &&
2309  next_free_id < *other_subdomains.rbegin()),
2310  "Subdomain id overflow");
2311 
2312  id_remapping[sid] = next_free_id++;
2313  this->subdomain_name(next_free_id) = sname;
2314  }
2315  // If we don't have this subdomain id, well, we're
2316  // about to, so we should have its name too.
2317  else
2318  this->subdomain_name(sid) = sname;
2319  }
2320  }
2321  }
2322 
2323  // Copy mesh data. If we skip the call to find_neighbors(), the lists
2324  // of neighbors will be copied verbatim from the other mesh
2325  this->copy_nodes_and_elements(*other_mesh, skip_find_neighbors,
2326  elem_delta, node_delta,
2327  unique_delta, &id_remapping);
2328 
2329  // Copy BoundaryInfo from other_mesh too. We do this via the
2330  // list APIs rather than element-by-element for speed.
2331  BoundaryInfo & boundary = this->get_boundary_info();
2332  const BoundaryInfo & other_boundary = other_mesh->get_boundary_info();
2333 
2334  for (const auto & t : other_boundary.build_node_list())
2335  boundary.add_node(std::get<0>(t) + node_delta,
2336  std::get<1>(t));
2337 
2338  for (const auto & t : other_boundary.build_side_list())
2339  boundary.add_side(std::get<0>(t) + elem_delta,
2340  std::get<1>(t),
2341  std::get<2>(t));
2342 
2343  for (const auto & t : other_boundary.build_edge_list())
2344  boundary.add_edge(std::get<0>(t) + elem_delta,
2345  std::get<1>(t),
2346  std::get<2>(t));
2347 
2348  for (const auto & t : other_boundary.build_shellface_list())
2349  boundary.add_shellface(std::get<0>(t) + elem_delta,
2350  std::get<1>(t),
2351  std::get<2>(t));
2352 
2353  const auto & other_ns_id_to_name = other_boundary.get_nodeset_name_map();
2354  auto & ns_id_to_name = boundary.set_nodeset_name_map();
2355  ns_id_to_name.insert(other_ns_id_to_name.begin(), other_ns_id_to_name.end());
2356 
2357  const auto & other_ss_id_to_name = other_boundary.get_sideset_name_map();
2358  auto & ss_id_to_name = boundary.set_sideset_name_map();
2359  ss_id_to_name.insert(other_ss_id_to_name.begin(), other_ss_id_to_name.end());
2360 
2361  const auto & other_es_id_to_name = other_boundary.get_edgeset_name_map();
2362  auto & es_id_to_name = boundary.set_edgeset_name_map();
2363  es_id_to_name.insert(other_es_id_to_name.begin(), other_es_id_to_name.end());
2364 
2365  // Merge other_mesh's elemset information with ours. Throw an
2366  // error if this and other_mesh have overlapping elemset codes
2367  // that refer to different elemset ids.
2368  std::vector<dof_id_type> this_elemset_codes = this->get_elemset_codes();
2369  MeshBase::elemset_type this_id_set_to_fill, other_id_set_to_fill;
2370  for (const auto & elemset_code : other_mesh->get_elemset_codes())
2371  {
2372  // Get the elemset ids for this elemset_code on other_mesh
2373  other_mesh->get_elemsets(elemset_code, other_id_set_to_fill);
2374 
2375  // Check that this elemset code does not already exist
2376  // in this mesh, or if it does, that it has the same elemset
2377  // ids associated with it.
2378  //
2379  // Note: get_elemset_codes() is guaranteed to return a
2380  // sorted vector, so we can binary search in it.
2381  auto it = Utility::binary_find(this_elemset_codes.begin(),
2382  this_elemset_codes.end(),
2383  elemset_code);
2384 
2385  if (it != this_elemset_codes.end())
2386  {
2387  // This mesh has the same elemset code. Does it refer to
2388  // the same elemset ids?
2389  this->get_elemsets(elemset_code, this_id_set_to_fill);
2390 
2391  // Throw an error if they don't match, otherwise we
2392  // don't need to do anything
2393  libmesh_error_msg_if(other_id_set_to_fill != this_id_set_to_fill,
2394  "Attempted to stitch together meshes with conflicting elemset codes.");
2395  }
2396  else
2397  {
2398  // Add other_mesh's elemset code to this mesh
2399  this->add_elemset_code(elemset_code, other_id_set_to_fill);
2400  }
2401  }
2402  } // end if (other_mesh)
2403 
2404  // Finally, we need to "merge" the overlapping nodes
2405  // We do this by iterating over node_to_elems_map and updating
2406  // the elements so that they "point" to the nodes that came
2407  // from this mesh, rather than from other_mesh.
2408  // Then we iterate over node_to_node_map and delete the
2409  // duplicate nodes that came from other_mesh.
2410 
2411  {
2412  LOG_SCOPE("stitch_meshes node updates", "UnstructuredMesh");
2413 
2414  // Container to catch boundary IDs passed back from BoundaryInfo.
2415  std::vector<boundary_id_type> bc_ids;
2416 
2417  for (const auto & [target_node_id, elem_vec] : node_to_elems_map)
2418  {
2419  dof_id_type other_node_id = node_to_node_map[target_node_id];
2420  Node & target_node = this->node_ref(target_node_id);
2421 
2422  std::size_t n_elems = elem_vec.size();
2423  for (std::size_t i=0; i<n_elems; i++)
2424  {
2425  dof_id_type elem_id = elem_vec[i];
2426  Elem * el = this->elem_ptr(elem_id);
2427 
2428  // find the local node index that we want to update
2429  unsigned int local_node_index = el->local_node(other_node_id);
2430  libmesh_assert_not_equal_to(local_node_index, libMesh::invalid_uint);
2431 
2432  // We also need to copy over the nodeset info here,
2433  // because the node will get deleted below
2434  this->get_boundary_info().boundary_ids(el->node_ptr(local_node_index), bc_ids);
2435  el->set_node(local_node_index) = &target_node;
2436  this->get_boundary_info().add_node(&target_node, bc_ids);
2437  }
2438  }
2439  }
2440 
2441  {
2442  LOG_SCOPE("stitch_meshes node deletion", "UnstructuredMesh");
2443  for (const auto & [other_node_id, this_node_id] : node_to_node_map)
2444  {
2445  // In the case that this==other_mesh, the two nodes might be the same (e.g. if
2446  // we're stitching a "sliver"), hence we need to skip node deletion in that case.
2447  if ((this == other_mesh) && (this_node_id == other_node_id))
2448  continue;
2449 
2450  this->delete_node( this->node_ptr(this_node_id) );
2451  }
2452  }
2453 
2454  // If find_neighbors() wasn't called in prepare_for_use(), we need to
2455  // manually loop once more over all elements adjacent to the stitched boundary
2456  // and fix their lists of neighbors.
2457  // This is done according to the following steps:
2458  // 1. Loop over all copied elements adjacent to the boundary using node_to_elems_map (trying to avoid duplicates)
2459  // 2. Look at all their sides with a nullptr neighbor and update them using side_to_elem_map if necessary
2460  // 3. Update the corresponding side in side_to_elem_map as well
2461  if (skip_find_neighbors)
2462  {
2463  LOG_SCOPE("stitch_meshes neighbor fixes", "UnstructuredMesh");
2464 
2465  // Pull objects out of the loop to reduce heap operations
2466  std::unique_ptr<const Elem> my_side, their_side;
2467 
2468  std::set<dof_id_type> fixed_elems;
2469  for (const auto & pr : node_to_elems_map)
2470  {
2471  std::size_t n_elems = pr.second.size();
2472  for (std::size_t i=0; i<n_elems; i++)
2473  {
2474  dof_id_type elem_id = pr.second[i];
2475  if (fixed_elems.find(elem_id) == fixed_elems.end())
2476  {
2477  Elem * el = this->elem_ptr(elem_id);
2478  fixed_elems.insert(elem_id);
2479  for (auto s : el->side_index_range())
2480  {
2481  if (el->neighbor_ptr(s) == nullptr)
2482  {
2483  key_type key = el->low_order_key(s);
2484  auto bounds = side_to_elem_map.equal_range(key);
2485 
2486  if (bounds.first != bounds.second)
2487  {
2488  // Get the side for this element
2489  el->side_ptr(my_side, s);
2490 
2491  // Look at all the entries with an equivalent key
2492  while (bounds.first != bounds.second)
2493  {
2494  // Get the potential element
2495  Elem * neighbor = const_cast<Elem *>(bounds.first->second.first);
2496 
2497  // Get the side for the neighboring element
2498  const unsigned int ns = bounds.first->second.second;
2499  neighbor->side_ptr(their_side, ns);
2500  //libmesh_assert(my_side.get());
2501  //libmesh_assert(their_side.get());
2502 
2503  // If found a match with my side
2504  //
2505  // We need special tests here for 1D:
2506  // since parents and children have an equal
2507  // side (i.e. a node), we need to check
2508  // ns != ms, and we also check level() to
2509  // avoid setting our neighbor pointer to
2510  // any of our neighbor's descendants
2511  if ((*my_side == *their_side) &&
2512  (el->level() == neighbor->level()) &&
2513  ((el->dim() != 1) || (ns != s)))
2514  {
2515  // So share a side. Is this a mixed pair
2516  // of subactive and active/ancestor
2517  // elements?
2518  // If not, then we're neighbors.
2519  // If so, then the subactive's neighbor is
2520 
2521  if (el->subactive() ==
2522  neighbor->subactive())
2523  {
2524  // an element is only subactive if it has
2525  // been coarsened but not deleted
2526  el->set_neighbor (s,neighbor);
2527  neighbor->set_neighbor(ns,el);
2528  }
2529  else if (el->subactive())
2530  {
2531  el->set_neighbor(s,neighbor);
2532  }
2533  else if (neighbor->subactive())
2534  {
2535  neighbor->set_neighbor(ns,el);
2536  }
2537  // It's OK to invalidate the
2538  // bounds.first iterator here,
2539  // as we are immediately going
2540  // to break out of this while
2541  // loop. bounds.first will
2542  // therefore not be used for
2543  // anything else.
2544  side_to_elem_map.erase (bounds.first);
2545  break;
2546  }
2547 
2548  ++bounds.first;
2549  }
2550  }
2551  }
2552  }
2553  }
2554  }
2555  }
2556  }
2557 
2558  const bool old_allow_find_neighbors = this->allow_find_neighbors();
2559  const bool old_allow_remote_element_removal = this->allow_remote_element_removal();
2560  this->allow_find_neighbors(!skip_find_neighbors);
2561  this->allow_remote_element_removal(false);
2562  this->prepare_for_use();
2563  this->allow_find_neighbors(old_allow_find_neighbors);
2564  this->allow_remote_element_removal(old_allow_remote_element_removal);
2565 
2566  // After the stitching, we may want to clear boundary IDs from element
2567  // faces that are now internal to the mesh
2568  if (clear_stitched_boundary_ids)
2569  {
2570  LOG_SCOPE("stitch_meshes clear bcids", "UnstructuredMesh");
2571 
2573  this_mesh_boundary_id, other_mesh_boundary_id, /*clear_nodeset_data=*/true);
2574  }
2575 
2576  // Return the number of nodes which were merged.
2577  return node_to_node_map.size();
2578 }
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)
Deep copy of nodes and elements from another mesh object (used by subclass copy constructors and by m...
virtual Node *& set_node(const unsigned int i)
Definition: elem.h:2381
A Node is like a Point, but with more information.
Definition: node.h:52
virtual unique_id_type parallel_max_unique_id() const =0
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
Definition: libmesh.h:286
std::vector< dof_id_type > get_elemset_codes() const
Return a vector of all elemset codes defined on the mesh.
Definition: mesh_base.C:397
IntRange< unsigned short > side_index_range() const
Definition: elem.h:2510
static constexpr Real TOLERANCE
virtual dof_id_type low_order_key(const unsigned int s) const =0
const boundary_id_type side_id
void add_elemset_code(dof_id_type code, MeshBase::elemset_type id_set)
Tabulate a user-defined "code" for elements which belong to the element sets specified in id_set...
Definition: mesh_base.C:350
const std::map< boundary_id_type, std::string > & get_sideset_name_map() const
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
MeshBase & mesh
void boundary_ids(const Node *node, std::vector< boundary_id_type > &vec_to_fill) const
Fills a user-provided std::vector with the boundary ids associated with Node node.
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:159
This is the MeshBase class.
Definition: mesh_base.h:74
void build_side_list(std::vector< dof_id_type > &element_id_list, std::vector< unsigned short int > &side_list, std::vector< boundary_id_type > &bc_id_list) const
Creates a list of element numbers, sides, and ids for those sides.
void get_elemsets(dof_id_type elemset_code, MeshBase::elemset_type &id_set_to_fill) const
Look up the element sets for a given elemset code and vice-versa.
Definition: mesh_base.C:381
std::map< boundary_id_type, std::string > & set_sideset_name_map()
void build_node_list(std::vector< dof_id_type > &node_id_list, std::vector< boundary_id_type > &bc_id_list) const
Creates a list of nodes and ids for those nodes.
void add_node(const Node *node, const boundary_id_type id)
Add Node node with boundary id id to the boundary information data structures.
const std::map< boundary_id_type, std::string > & get_nodeset_name_map() const
int8_t boundary_id_type
Definition: id_types.h:51
static const boundary_id_type invalid_id
Number used for internal use.
const std::map< subdomain_id_type, std::string > & get_subdomain_name_map() const
Definition: mesh_base.h:1671
const std::map< boundary_id_type, std::string > & get_edgeset_name_map() const
virtual dof_id_type max_elem_id() const =0
bool allow_find_neighbors() const
Definition: mesh_base.h:1181
The BoundaryInfo class contains information relevant to boundary conditions including storing faces...
Definition: boundary_info.h:57
virtual void delete_node(Node *n)=0
Removes the Node n from the mesh.
std::string & subdomain_name(subdomain_id_type id)
Definition: mesh_base.C:1619
auto norm(const T &a) -> decltype(std::abs(a))
Definition: tensor_tools.h:74
bool allow_remote_element_removal() const
Definition: mesh_base.h:1190
void set_neighbor(const unsigned int i, Elem *n)
Assigns n as the neighbor.
Definition: elem.h:2427
void build_shellface_list(std::vector< dof_id_type > &element_id_list, std::vector< unsigned short int > &shellface_list, std::vector< boundary_id_type > &bc_id_list) const
Creates a list of element numbers, shellfaces, and boundary ids for those shellfaces.
void prepare_for_use()
Definition: mesh_base.C:742
virtual const Elem * elem_ptr(const dof_id_type i) const =0
const Elem * neighbor_ptr(unsigned int i) const
Definition: elem.h:2407
std::set< elemset_id_type > elemset_type
Typedef for the "set" container used to store elemset ids.
Definition: mesh_base.h:297
unsigned int level() const
Definition: elem.h:2911
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual std::unique_ptr< Elem > side_ptr(unsigned int i)=0
virtual unsigned short dim() const =0
Temporarily serialize a DistributedMesh for non-distributed-mesh capable code paths.
const Node * node_ptr(const unsigned int i) const
Definition: elem.h:2331
std::map< boundary_id_type, std::string > & set_nodeset_name_map()
void build_edge_list(std::vector< dof_id_type > &element_id_list, std::vector< unsigned short int > &edge_list, std::vector< boundary_id_type > &bc_id_list) const
Creates a list of element numbers, edges, and boundary ids for those edges.
void clear_stitched_boundary_side_ids(boundary_id_type sideset_id, boundary_id_type other_sideset_id, bool clear_nodeset_data=false)
Clear sideset information along a stitched mesh interface.
OStreamProxy out
void add_side(const dof_id_type elem, const unsigned short int side, const boundary_id_type id)
Add side side of element number elem with boundary id id to the boundary information data structure...
const std::string & get_sideset_name(boundary_id_type id) const
void add_shellface(const dof_id_type elem, const unsigned short int shellface, const boundary_id_type id)
Add shell face shellface of element number elem with boundary id id to the boundary information data ...
bool subactive() const
Definition: elem.h:2796
ForwardIterator binary_find(ForwardIterator first, ForwardIterator last, const T &value)
The STL provides std::binary_search() which returns true or false depending on whether the searched-f...
Definition: utility.h:265
virtual const Node & node_ref(const dof_id_type i) const
Definition: mesh_base.h:575
virtual const Point & point(const dof_id_type i) const =0
unsigned int local_node(const dof_id_type i) const
Definition: elem.h:2311
void edge_boundary_ids(const Elem *const elem, const unsigned short int edge, std::vector< boundary_id_type > &vec_to_fill) const
void libmesh_assert_valid_neighbors(const MeshBase &mesh, bool assert_valid_remote_elems=true)
A function for verifying that neighbor connectivity is correct (each element is a neighbor of or desc...
Definition: mesh_tools.C:2031
virtual dof_id_type max_node_id() const =0
virtual const Node * node_ptr(const dof_id_type i) const =0
uint8_t unique_id_type
Definition: id_types.h:86
uint8_t dof_id_type
Definition: id_types.h:67
std::map< boundary_id_type, std::string > & set_edgeset_name_map()
void add_edge(const dof_id_type elem, const unsigned short int edge, const boundary_id_type id)
Add edge edge of element number elem with boundary id id to the boundary information data structure...

◆ sub_point_locator()

std::unique_ptr< PointLocatorBase > libMesh::MeshBase::sub_point_locator ( ) const
inherited
Returns
A pointer to a subordinate PointLocatorBase object for this mesh, constructing a master PointLocator first if necessary. This should not be used in threaded or non-parallel_only code unless the master has already been constructed.

Definition at line 1565 of file mesh_base.C.

References libMesh::MeshBase::_point_locator, libMesh::MeshBase::_point_locator_close_to_point_tol, libMesh::PointLocatorBase::build(), libMesh::Threads::in_threads, libMesh::libmesh_assert(), libMesh::NANOFLANN, and libMesh::TREE_ELEMENTS.

Referenced by WriteElemsetData::checkElemsetCodes(), libMesh::DofMap::create_dof_constraints(), libMesh::MeshFunction::init(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshRefinement::make_refinement_compatible(), libMesh::DefaultCoupling::mesh_reinit(), libMesh::PointNeighborCoupling::mesh_reinit(), ExodusTest< elem_type >::meshes_equal_enough(), libMesh::MeshRefinement::test_level_one(), PointLocatorTest::testLocator(), MeshInputTest::testMasterCenters(), PointLocatorTest::testPlanar(), SystemsTest::testProjectCube(), SystemsTest::testProjectLine(), and SystemsTest::testProjectSquare().

1566 {
1567  // If there's no master point locator, then we need one.
1568  if (_point_locator.get() == nullptr)
1569  {
1570  // PointLocator construction may not be safe within threads
1572 
1573  // And it may require parallel communication
1574  parallel_object_only();
1575 
1576 #ifdef LIBMESH_ENABLE_NANOFLANN_POINTLOCATOR
1578 #else
1580 #endif
1581 
1583  _point_locator->set_close_to_point_tol(_point_locator_close_to_point_tol);
1584  }
1585 
1586  // Otherwise there was a master point locator, and we can grab a
1587  // sub-locator easily.
1588  return
1589 #ifdef LIBMESH_ENABLE_NANOFLANN_POINTLOCATOR
1591 #else
1593 #endif
1594 }
bool in_threads
A boolean which is true iff we are in a Threads:: function It may be useful to assert(!Threadsin_thre...
Definition: threads.C:32
libmesh_assert(ctx)
std::unique_ptr< PointLocatorBase > _point_locator
A PointLocator class for this mesh.
Definition: mesh_base.h:1829
Real _point_locator_close_to_point_tol
If nonzero, we will call PointLocatorBase::set_close_to_point_tol() on any PointLocators that we crea...
Definition: mesh_base.h:2015
static std::unique_ptr< PointLocatorBase > build(PointLocatorType t, const MeshBase &mesh, const PointLocatorBase *master=nullptr)
Builds an PointLocator for the mesh mesh.

◆ subclass_locally_equals()

virtual bool libMesh::MeshBase::subclass_locally_equals ( const MeshBase other_mesh) const
protectedpure virtualinherited

Shim to allow operator == (&) to behave like a virtual function without having to be one.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

Referenced by libMesh::MeshBase::locally_equals().

◆ subdomain_ids()

void libMesh::MeshBase::subdomain_ids ( std::set< subdomain_id_type > &  ids,
const bool  global = true 
) const
inherited

Constructs a list of all subdomain identifiers in the local mesh if global == false, and in the global mesh if global == true (default).

Subdomains correspond to separate subsets of the mesh which could correspond e.g. to different materials in a solid mechanics application, or regions where different physical processes are important. The subdomain mapping is independent from the parallel decomposition.

Unpartitioned elements are included in the set in the case that global == true. If global == false, the unpartitioned elements are not included because unpartitioned elements do not have a sense of locality.

Definition at line 899 of file mesh_base.C.

References libMesh::ParallelObject::comm(), and TIMPI::Communicator::set_union().

Referenced by libMesh::ReplicatedMesh::get_disconnected_subdomains(), libMesh::MeshBase::n_local_subdomains(), libMesh::MeshBase::n_subdomains(), libMesh::TecplotIO::TecplotIO(), MeshSubdomainIDTest::testMultiple(), and MeshSubdomainIDTest::testUnpartitioned().

900 {
901  // This requires an inspection on every processor
902  if (global)
903  parallel_object_only();
904 
905  ids.clear();
906 
907  for (const auto & elem : this->active_local_element_ptr_range())
908  ids.insert(elem->subdomain_id());
909 
910  if (global)
911  {
912  // Only include the unpartitioned elements if the user requests the global IDs.
913  // In the case of the local subdomain IDs, it doesn't make sense to include the
914  // unpartitioned elements because said elements do not have a sense of locality.
915  for (const auto & elem : this->active_unpartitioned_element_ptr_range())
916  ids.insert(elem->subdomain_id());
917 
918  // Some subdomains may only live on other processors
919  this->comm().set_union(ids);
920  }
921 }
const Parallel::Communicator & comm() const
void set_union(T &data, const unsigned int root_id) const

◆ subdomain_name() [1/2]

std::string & libMesh::MeshBase::subdomain_name ( subdomain_id_type  id)
inherited
Returns
A writable reference for getting/setting an optional name for a subdomain.

Definition at line 1619 of file mesh_base.C.

References libMesh::MeshBase::_block_id_to_name.

Referenced by libMesh::AbaqusIO::assign_subdomain_ids(), DMlibMeshSetSystem_libMesh(), libMesh::UNVIO::groups_in(), libMesh::Nemesis_IO::read(), libMesh::ExodusII_IO::read(), libMesh::GmshIO::read_mesh(), stitching_helper(), MeshStitchTest::testAmbiguousRemappingStitch(), MeshStitchTest::testRemappingStitch(), libMesh::TecplotIO::write_binary(), and libMesh::ExodusII_IO_Helper::write_elements().

1620 {
1621  return _block_id_to_name[id];
1622 }
std::map< subdomain_id_type, std::string > _block_id_to_name
This structure maintains the mapping of named blocks for file formats that support named blocks...
Definition: mesh_base.h:1888

◆ subdomain_name() [2/2]

const std::string & libMesh::MeshBase::subdomain_name ( subdomain_id_type  id) const
inherited

Definition at line 1624 of file mesh_base.C.

References libMesh::MeshBase::_block_id_to_name.

1625 {
1626  // An empty string to return when no matching subdomain name is found
1627  static const std::string empty;
1628 
1629  std::map<subdomain_id_type, std::string>::const_iterator iter = _block_id_to_name.find(id);
1630  if (iter == _block_id_to_name.end())
1631  return empty;
1632  else
1633  return iter->second;
1634 }
std::map< subdomain_id_type, std::string > _block_id_to_name
This structure maintains the mapping of named blocks for file formats that support named blocks...
Definition: mesh_base.h:1888

◆ update_parallel_id_counts()

virtual void libMesh::MeshBase::update_parallel_id_counts ( )
pure virtualinherited

Updates parallel caches so that methods like n_elem() accurately reflect changes on other processors.

Implemented in libMesh::DistributedMesh, and libMesh::ReplicatedMesh.

Referenced by libMesh::MeshRefinement::_coarsen_elements(), libMesh::MeshRefinement::_refine_elements(), and libMesh::MeshBase::prepare_for_use().

◆ update_post_partitioning()

virtual void libMesh::MeshBase::update_post_partitioning ( )
inlinevirtualinherited

Recalculate any cached data after elements and nodes have been repartitioned.

Reimplemented in libMesh::DistributedMesh.

Definition at line 1154 of file mesh_base.h.

Referenced by libMesh::Partitioner::partition(), libMesh::MeshBase::partition(), and libMesh::Nemesis_IO::read().

1154 {}

◆ write() [1/2]

void libMesh::UnstructuredMesh::write ( const std::string &  name)
overridevirtual

Write the file specified by name.

Attempts to figure out the proper method by the file extension.

Implements libMesh::MeshBase.

Definition at line 1253 of file unstructured_mesh.C.

References libMesh::Quality::name(), and libMesh::NameBasedIO::write().

Referenced by main().

1254 {
1255  LOG_SCOPE("write()", "Mesh");
1256 
1257  NameBasedIO(*this).write(name);
1258 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
This class supports simple reads and writes in any libMesh-supported format, by dispatching to one of...
Definition: namebased_io.h:44
virtual void write(const std::string &mesh_file) override
This method implements writing a mesh to a specified file.
Definition: namebased_io.C:310

◆ write() [2/2]

void libMesh::UnstructuredMesh::write ( const std::string &  name,
const std::vector< Number > &  values,
const std::vector< std::string > &  variable_names 
)

Write to the file specified by name.

Attempts to figure out the proper method by the file extension. Also writes data.

Definition at line 1262 of file unstructured_mesh.C.

References libMesh::Quality::name(), and libMesh::NameBasedIO::write_nodal_data().

1265 {
1266  LOG_SCOPE("write()", "Mesh");
1267 
1268  NameBasedIO(*this).write_nodal_data(name, v, vn);
1269 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
This class supports simple reads and writes in any libMesh-supported format, by dispatching to one of...
Definition: namebased_io.h:44
virtual void write_nodal_data(const std::string &, const std::vector< Number > &, const std::vector< std::string > &) override
This method implements writing a mesh with nodal data to a specified file where the nodal data and va...
Definition: namebased_io.C:467

Member Data Documentation

◆ _all_elemset_ids

MeshBase::elemset_type libMesh::MeshBase::_all_elemset_ids
protectedinherited

◆ _allow_remote_element_removal

bool libMesh::MeshBase::_allow_remote_element_removal
protectedinherited

If this is false then even on DistributedMesh remote elements will not be deleted during mesh preparation.

This is true by default.

Definition at line 1881 of file mesh_base.h.

Referenced by libMesh::MeshBase::allow_remote_element_removal(), libMesh::MeshBase::locally_equals(), libMesh::MeshBase::operator=(), and libMesh::MeshBase::prepare_for_use().

◆ _block_id_to_name

std::map<subdomain_id_type, std::string> libMesh::MeshBase::_block_id_to_name
protectedinherited

This structure maintains the mapping of named blocks for file formats that support named blocks.

Currently this is only implemented for ExodusII

Definition at line 1888 of file mesh_base.h.

Referenced by libMesh::MeshBase::get_id_by_name(), libMesh::MeshBase::get_subdomain_name_map(), libMesh::MeshBase::locally_equals(), libMesh::MeshBase::operator=(), libMesh::MeshBase::set_subdomain_name_map(), and libMesh::MeshBase::subdomain_name().

◆ _communicator

const Parallel::Communicator& libMesh::ParallelObject::_communicator
protectedinherited

◆ _constraint_rows

constraint_rows_type libMesh::MeshBase::_constraint_rows
protectedinherited

◆ _count_lower_dim_elems_in_point_locator

bool libMesh::MeshBase::_count_lower_dim_elems_in_point_locator
protectedinherited

Do we count lower dimensional elements in point locator refinement? This is relevant in tree-based point locators, for example.

Definition at line 1835 of file mesh_base.h.

Referenced by libMesh::MeshBase::get_count_lower_dim_elems_in_point_locator(), libMesh::MeshBase::locally_equals(), libMesh::MeshBase::operator=(), and libMesh::MeshBase::set_count_lower_dim_elems_in_point_locator().

◆ _default_ghosting

std::unique_ptr<GhostingFunctor> libMesh::MeshBase::_default_ghosting
protectedinherited

The default geometric GhostingFunctor, used to implement standard libMesh element ghosting behavior.

We use a base class pointer here to avoid dragging in more header dependencies.

Definition at line 1982 of file mesh_base.h.

Referenced by libMesh::MeshBase::default_ghosting(), libMesh::MeshBase::locally_equals(), libMesh::MeshBase::MeshBase(), and libMesh::MeshBase::post_dofobject_moves().

◆ _default_mapping_data

unsigned char libMesh::MeshBase::_default_mapping_data
protectedinherited

The default mapping data (unused with Lagrange, used for nodal weight lookup index with rational bases) to assign to newly added elements.

Definition at line 1815 of file mesh_base.h.

Referenced by libMesh::MeshBase::default_mapping_data(), libMesh::MeshBase::locally_equals(), libMesh::MeshBase::operator=(), and libMesh::MeshBase::set_default_mapping_data().

◆ _default_mapping_type

ElemMappingType libMesh::MeshBase::_default_mapping_type
protectedinherited

The default mapping type (typically Lagrange) between master and physical space to assign to newly added elements.

Definition at line 1808 of file mesh_base.h.

Referenced by libMesh::MeshBase::default_mapping_type(), libMesh::MeshBase::locally_equals(), libMesh::MeshBase::operator=(), and libMesh::MeshBase::set_default_mapping_type().

◆ _elem_dims

std::set<unsigned char> libMesh::MeshBase::_elem_dims
protectedinherited

◆ _elem_integer_default_values

std::vector<dof_id_type> libMesh::MeshBase::_elem_integer_default_values
protectedinherited

◆ _elem_integer_names

std::vector<std::string> libMesh::MeshBase::_elem_integer_names
protectedinherited

◆ _elemset_codes

std::map<dof_id_type, const MeshBase::elemset_type *> libMesh::MeshBase::_elemset_codes
protectedinherited

Map from "element set code" to list of set ids to which that element belongs (and vice-versa).

Remarks: 1.) The elemset code is a dof_id_type because (if used) it is stored as an extra_integer (named "elemset_code") on all elements, and extra_integers are of type dof_id_type. Elements which do not belong to any set should be assigned an elemset code of DofObject::invalid_id. 2.) Element sets can be thought of as a generalization of the concept of a subdomain. Subdomains have the following restrictions: a.) A given element can only belong to a single subdomain b.) When using Exodus file input/output, subdomains are (unfortunately) tied to the concept of exodus element blocks, which consist of a single geometric element type, somewhat limiting their generality. 3.) The user is responsible for filling in the values of this map in a consistent manner, unless the elemsets are read in from an Exodus file, in which case the elemset codes will be set up automatically. The codes can basically be chosen arbitrarily, with the one requirement that elements which belong to no sets should have a set code of DofObject::invalid_id. 4.) We also keep a list of all the elemset ids which have been added in order to support O(1) performance behavior in n_elemsets() calls.

Definition at line 1924 of file mesh_base.h.

Referenced by libMesh::MeshBase::add_elemset_code(), libMesh::MeshBase::change_elemset_code(), libMesh::MeshBase::change_elemset_id(), libMesh::MeshBase::clear(), libMesh::MeshBase::get_elemset_codes(), libMesh::MeshBase::get_elemsets(), libMesh::MeshBase::get_info(), libMesh::MeshBase::locally_equals(), libMesh::MeshBase::MeshBase(), and libMesh::MeshBase::operator=().

◆ _elemset_codes_inverse_map

std::map<MeshBase::elemset_type, dof_id_type> libMesh::MeshBase::_elemset_codes_inverse_map
protectedinherited

◆ _ghosting_functors

std::set<GhostingFunctor *> libMesh::MeshBase::_ghosting_functors
protectedinherited

◆ _is_prepared

bool libMesh::MeshBase::_is_prepared
protectedinherited

◆ _mesh_subdomains

std::set<subdomain_id_type> libMesh::MeshBase::_mesh_subdomains
protectedinherited

We cache the subdomain ids of the elements present in the mesh.

Definition at line 1900 of file mesh_base.h.

Referenced by libMesh::MeshBase::cache_elem_data(), libMesh::MeshBase::get_mesh_subdomains(), and libMesh::MeshBase::locally_equals().

◆ _n_parts

unsigned int libMesh::MeshBase::_n_parts
protectedinherited

The number of partitions the mesh has.

This is set by the partitioners, and may not be changed directly by the user.

Note
The number of partitions need not equal this->n_processors(), consider for example the case where you simply want to partition a mesh on one processor and view the result in GMV.

Definition at line 1802 of file mesh_base.h.

Referenced by libMesh::MeshBase::clear(), copy_nodes_and_elements(), libMesh::MeshBase::locally_equals(), libMesh::MeshBase::n_partitions(), libMesh::MeshBase::operator=(), libMesh::MeshBase::recalculate_n_partitions(), and libMesh::MeshBase::set_n_partitions().

◆ _next_unique_id

unique_id_type libMesh::MeshBase::_next_unique_id
protectedinherited

◆ _node_integer_default_values

std::vector<dof_id_type> libMesh::MeshBase::_node_integer_default_values
protectedinherited

◆ _node_integer_names

std::vector<std::string> libMesh::MeshBase::_node_integer_names
protectedinherited

◆ _partitioner

std::unique_ptr<Partitioner> libMesh::MeshBase::_partitioner
protectedinherited

◆ _point_locator

std::unique_ptr<PointLocatorBase> libMesh::MeshBase::_point_locator
mutableprotectedinherited

A PointLocator class for this mesh.

This will not actually be built unless needed. Further, since we want our point_locator() method to be const (yet do the dynamic allocating) this needs to be mutable. Since the PointLocatorBase::build() member is used, and it operates on a constant reference to the mesh, this is OK.

Definition at line 1829 of file mesh_base.h.

Referenced by libMesh::MeshBase::clear_point_locator(), libMesh::MeshBase::operator=(), libMesh::MeshBase::set_point_locator_close_to_point_tol(), and libMesh::MeshBase::sub_point_locator().

◆ _point_locator_close_to_point_tol

Real libMesh::MeshBase::_point_locator_close_to_point_tol
protectedinherited

◆ _shared_functors

std::map<GhostingFunctor *, std::shared_ptr<GhostingFunctor> > libMesh::MeshBase::_shared_functors
protectedinherited

Hang on to references to any GhostingFunctor objects we were passed in shared_ptr form.

Definition at line 1997 of file mesh_base.h.

Referenced by libMesh::MeshBase::add_ghosting_functor(), libMesh::MeshBase::post_dofobject_moves(), and libMesh::MeshBase::remove_ghosting_functor().

◆ _skip_all_partitioning

bool libMesh::MeshBase::_skip_all_partitioning
protectedinherited

◆ _skip_find_neighbors

bool libMesh::MeshBase::_skip_find_neighbors
protectedinherited

If this is true then we will skip find_neighbors in prepare_for_use.

Definition at line 1873 of file mesh_base.h.

Referenced by libMesh::MeshBase::allow_find_neighbors(), libMesh::MeshBase::locally_equals(), libMesh::MeshBase::operator=(), and libMesh::MeshBase::prepare_for_use().

◆ _skip_noncritical_partitioning

bool libMesh::MeshBase::_skip_noncritical_partitioning
protectedinherited

If this is true then no partitioning should be done with the possible exception of orphaned nodes.

Definition at line 1856 of file mesh_base.h.

Referenced by libMesh::MeshBase::locally_equals(), libMesh::MeshBase::operator=(), and libMesh::MeshBase::skip_noncritical_partitioning().

◆ _skip_renumber_nodes_and_elements

bool libMesh::MeshBase::_skip_renumber_nodes_and_elements
protectedinherited

◆ _spatial_dimension

unsigned char libMesh::MeshBase::_spatial_dimension
protectedinherited

◆ boundary_info

std::unique_ptr<BoundaryInfo> libMesh::MeshBase::boundary_info
protectedinherited

This class holds the boundary information.

It can store nodes, edges, and faces with a corresponding id that facilitates setting boundary conditions.

Direct access to this class is now officially deprecated and will be removed in future libMesh versions. Use the get_boundary_info() accessor instead.

Definition at line 1760 of file mesh_base.h.

Referenced by libMesh::MeshBase::clear(), libMesh::MeshBase::get_boundary_info(), libMesh::MeshBase::locally_equals(), and libMesh::MeshBase::operator=().

◆ var_num

const DofMap& dof_map LIBMESH_COMMA unsigned int libMesh::MeshBase::var_num
inherited
Initial value:
ABSTRACT_ELEM_ITERATORS(multi_evaluable_,std::vector<const DofMap *> dof_maps)
#ifdef LIBMESH_ENABLE_AMR
ABSTRACT_ELEM_ITERATORS(flagged_,unsigned char rflag)
ABSTRACT_ELEM_ITERATORS(flagged_pid_,unsigned char rflag LIBMESH_COMMA processor_id_type pid)
#endif
ABSTRACT_NODE_ITERATORS(,)
ABSTRACT_NODE_ITERATORS(active_,)
ABSTRACT_NODE_ITERATORS(local_,)
ABSTRACT_NODE_ITERATORS(bnd_,)
ABSTRACT_NODE_ITERATORS(pid_,processor_id_type pid)
ABSTRACT_NODE_ITERATORS(bid_,boundary_id_type bid)
ABSTRACT_NODE_ITERATORS(evaluable_,const DofMap & dof_map LIBMESH_COMMA unsigned int var_num = libMesh::invalid_uint)
ABSTRACT_NODE_ITERATORS(multi_evaluable_,std::vector<const DofMap *> dof_maps)

Definition at line 1621 of file mesh_base.h.


The documentation for this class was generated from the following files: