libMesh
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | List of all members
libMesh::Mesh Class Referenceabstract

The Mesh class is a thin wrapper, around the ReplicatedMesh class by default. More...

#include <mesh.h>

Inheritance diagram for libMesh::Mesh:
[legend]

Public Types

template<typename Obj >
using dofobject_container = mapvector< Obj *, dof_id_type >
 
using dofobject_container = chunked_mapvector< Obj *, dof_id_type, LIBMESH_MAPVECTOR_CHUNK_SIZE >
 
typedef std::set< elemset_id_typeelemset_type
 Typedef for the "set" container used to store elemset ids.
 
typedef std::vector< GhostingFunctor * >::const_iterator GhostingFunctorIterator
 Iterator type for ghosting functor ranges.
 
typedef Predicates::multi_predicate Predicate
 We need an empty, generic class to act as a predicate for this and derived mesh classes.
 
typedef StoredRange< MeshBase::const_element_iterator, const Elem * > ConstElemRange
 
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

 Mesh (const Parallel::Communicator &comm_in, unsigned char dim=1)
 Constructor.
 
 Mesh (const UnstructuredMesh &other_mesh)
 Copy-constructor.
 
 Mesh (const Mesh &)=default
 Default copy constructors and destructor.
 
 ~Mesh ()=default
 
 Mesh (Mesh &&)=delete
 Move-constructor deleted in MeshBase.
 
Meshoperator= (const Mesh &)=delete
 Copy assignment is not allowed.
 
Meshoperator= (Mesh &&)=default
 Move assignment is allowed.
 
virtual MeshBaseassign (MeshBase &&other_mesh) override
 Shim to call the move assignment operator for this class.
 
virtual bool subclass_locally_equals (const MeshBase &other_mesh) const override
 Shim to allow operator == (&) to behave like a virtual function without having to be one.
 
virtual std::unique_ptr< MeshBaseclone () const override
 Virtual copy-constructor, creates a copy of this mesh.
 
virtual void clear () override
 Clear all internal data.
 
virtual void clear_elems () override
 Clear internal Elem data.
 
virtual void redistribute () override
 Redistribute elements between processors.
 
virtual void update_post_partitioning () override
 Recalculate cached data after elements and nodes have been repartitioned.
 
virtual bool is_serial () const override final
 
virtual bool is_serial_on_zero () const override final
 
virtual void set_distributed () override final
 Asserts that not all elements and nodes of the mesh necessarily exist on the current processor.
 
virtual bool is_replicated () const override final
 
template<typename T >
void libmesh_assert_valid_parallel_object_ids (const dofobject_container< T > &) const
 Verify id, processor_id, and if applicable unique_id consistency of a parallel objects container.
 
virtual void libmesh_assert_valid_parallel_ids () const override
 Verify id and processor_id consistency of our elements and nodes containers.
 
void libmesh_assert_valid_parallel_p_levels () const
 Verify p_level consistency of our elements containers.
 
void libmesh_assert_valid_parallel_flags () const
 Verify refinement_flag and p_refinement_flag consistency of our elements containers.
 
template<typename T >
dof_id_type renumber_dof_objects (dofobject_container< T > &)
 Renumber a parallel objects container.
 
virtual void renumber_nodes_and_elements () override
 Remove nullptr elements from arrays.
 
virtual void allgather () override
 Gathers all elements and nodes of the mesh onto every processor.
 
virtual void gather_to_zero () override
 Gathers all elements and nodes of the mesh onto processor zero.
 
virtual void delete_remote_elements () override
 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.
 
virtual void add_extra_ghost_elem (Elem *e)
 Inserts the element and adds it to a list of elements that should not get deleted or have their descendants deleted by delete_remote_elements.
 
virtual void clear_extra_ghost_elems ()
 Clears extra ghost elements.
 
virtual void clear_extra_ghost_elems (const std::set< Elem * > &extra_ghost_elems)
 Clears specified extra ghost elements.
 
const std::set< Elem * > & extra_ghost_elems () const
 Const accessor to the ghosted elements.
 
virtual dof_id_type n_nodes () const override final
 
virtual dof_id_type max_node_id () const override final
 
virtual void reserve_nodes (const dof_id_type) override final
 Reserves space for a known number of nodes.
 
virtual dof_id_type n_elem () const override final
 
virtual dof_id_type n_active_elem () const override final
 
virtual dof_id_type max_elem_id () const override final
 
virtual void reserve_elem (const dof_id_type) override final
 Reserves space for a known number of elements.
 
virtual void update_parallel_id_counts () override
 Updates parallel caches so that methods like n_elem() accurately reflect changes on other processors.
 
virtual dof_id_type parallel_n_nodes () const override
 
dof_id_type parallel_max_node_id () const
 
virtual dof_id_type parallel_n_elem () const override
 
dof_id_type parallel_max_elem_id () const
 
virtual unique_id_type parallel_max_unique_id () const override
 
virtual void set_next_unique_id (unique_id_type id) override
 Sets the next available unique id to be used.
 
virtual const Pointpoint (const dof_id_type i) const override final
 
virtual const Nodenode_ptr (const dof_id_type i) const override final
 
virtual Nodenode_ptr (const dof_id_type i) override final
 
virtual const Nodequery_node_ptr (const dof_id_type i) const override final
 
virtual Nodequery_node_ptr (const dof_id_type i) override final
 
virtual const Elemelem_ptr (const dof_id_type i) const override final
 
virtual Elemelem_ptr (const dof_id_type i) override final
 
virtual const Elemquery_elem_ptr (const dof_id_type i) const override final
 
virtual Elemquery_elem_ptr (const dof_id_type i) override final
 
virtual Nodeadd_point (const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id) override final
 functions for adding /deleting nodes elements.
 
virtual Nodeadd_node (Node *n) override final
 Add Node n to the end of the vertex array.
 
virtual Nodeadd_node (std::unique_ptr< Node > n) override final
 Version of add_node() taking a std::unique_ptr by value.
 
virtual void own_node (Node &n) override final
 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.
 
virtual void delete_node (Node *n) override final
 Removes the Node n from the mesh.
 
virtual void renumber_node (dof_id_type old_id, dof_id_type new_id) override final
 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.
 
virtual Elemadd_elem (Elem *e) override final
 Add elem e to the end of the element array.
 
virtual Elemadd_elem (std::unique_ptr< Elem > e) override final
 Version of add_elem() taking a std::unique_ptr by value.
 
virtual Eleminsert_elem (Elem *e) override final
 Insert elem e to the element array, preserving its id and replacing/deleting any existing element with the same id.
 
virtual Eleminsert_elem (std::unique_ptr< Elem > e) override final
 Version of insert_elem() taking a std::unique_ptr by value.
 
virtual void delete_elem (Elem *e) override final
 Removes element e from the mesh.
 
virtual void renumber_elem (dof_id_type old_id, dof_id_type new_id) override final
 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.
 
virtual void fix_broken_node_and_element_numbering () override
 There is no reason for a user to ever call this function.
 
 DECLARE_ELEM_ITERATORS (,,)
 Elem and Node iterator accessor functions.
 
 DECLARE_ELEM_ITERATORS (active_,,)
 
 DECLARE_ELEM_ITERATORS (ancestor_,,) DECLARE_ELEM_ITERATORS(subactive_
 
 DECLARE_ELEM_ITERATORS (local_,,) DECLARE_ELEM_ITERATORS(unpartitioned_
 
 DECLARE_ELEM_ITERATORS (facelocal_,,) DECLARE_ELEM_ITERATORS(level_
 
unsigned int level DECLARE_ELEM_ITERATORS (pid_, processor_id_type pid, pid) DECLARE_ELEM_ITERATORS(type_
 
unsigned int level ElemType type DECLARE_ELEM_ITERATORS (active_subdomain_, subdomain_id_type sid, sid) DECLARE_ELEM_ITERATORS(active_subdomain_set_
 
 DECLARE_ELEM_ITERATORS (not_active_,,)
 
 DECLARE_ELEM_ITERATORS (not_ancestor_,,)
 
 DECLARE_ELEM_ITERATORS (not_subactive_,,)
 
 DECLARE_ELEM_ITERATORS (not_local_,,)
 
 DECLARE_ELEM_ITERATORS (not_level_, unsigned int level, level) DECLARE_ELEM_ITERATORS(active_local_
 
 DECLARE_ELEM_ITERATORS (active_not_local_,,) DECLARE_ELEM_ITERATORS(active_unpartitioned_
 
 DECLARE_ELEM_ITERATORS (active_type_, ElemType type, type) DECLARE_ELEM_ITERATORS(active_pid_
 
processor_id_type pid DECLARE_ELEM_ITERATORS (local_level_, unsigned int level, level) DECLARE_ELEM_ITERATORS(local_not_level_
 
processor_id_type pid unsigned int level DECLARE_ELEM_ITERATORS (active_local_subdomain_, subdomain_id_type sid, sid) DECLARE_ELEM_ITERATORS(active_local_subdomain_set_
 
processor_id_type pid unsigned int level std::set< subdomain_id_type > ss DECLARE_ELEM_ITERATORS (semilocal_,,) DECLARE_ELEM_ITERATORS(ghost_
 
processor_id_type pid unsigned int level std::set< subdomain_id_type > ss DECLARE_ELEM_ITERATORS (active_semilocal_,,) DECLARE_ELEM_ITERATORS(evaluable_
 
processor_id_type pid unsigned int level std::set< subdomain_id_type > ss const DofMap &dof_map LIBMESH_COMMA unsigned int dof_map LIBMESH_COMMA var_num DECLARE_ELEM_ITERATORS (multi_evaluable_, std::vector< const DofMap * > dof_maps, dof_maps) DECLARE_ELEM_ITERATORS(flagged_
 
processor_id_type pid unsigned int level std::set< subdomain_id_type > ss const DofMap &dof_map LIBMESH_COMMA unsigned int dof_map LIBMESH_COMMA var_num unsigned char rflag DECLARE_ELEM_ITERATORS (flagged_pid_, unsigned char rflag LIBMESH_COMMA processor_id_type pid, rflag LIBMESH_COMMA pid) DECLARE_NODE_ITERATORS(
 
unsigned int level ElemType type std::set< subdomain_id_type > virtual ss SimpleRange< element_iteratoractive_subdomain_elements_ptr_range (subdomain_id_type sid) override final
 
virtual SimpleRange< const_element_iteratoractive_subdomain_elements_ptr_range (subdomain_id_type sid) const override final
 
virtual SimpleRange< element_iteratoractive_local_subdomain_elements_ptr_range (subdomain_id_type sid) override final
 
virtual SimpleRange< const_element_iteratoractive_local_subdomain_elements_ptr_range (subdomain_id_type sid) const override final
 
virtual SimpleRange< element_iteratoractive_subdomain_set_elements_ptr_range (std::set< subdomain_id_type > ss) override final
 
virtual SimpleRange< const_element_iteratoractive_subdomain_set_elements_ptr_range (std::set< subdomain_id_type > ss) const override final
 
processor_id_type pid unsigned int level std::set< subdomain_id_type > ss const DofMap &dof_map LIBMESH_COMMA unsigned int dof_map LIBMESH_COMMA var_num unsigned char rflag DECLARE_NODE_ITERATORS (active_,,) DECLARE_NODE_ITERATORS(local_
 
processor_id_type pid unsigned int level std::set< subdomain_id_type > ss const DofMap &dof_map LIBMESH_COMMA unsigned int dof_map LIBMESH_COMMA var_num unsigned char rflag DECLARE_NODE_ITERATORS (bnd_,,) DECLARE_NODE_ITERATORS(pid_
 
processor_id_type pid unsigned int level std::set< subdomain_id_type > ss const DofMap &dof_map LIBMESH_COMMA unsigned int dof_map LIBMESH_COMMA var_num unsigned char rflag processor_id_type pid DECLARE_NODE_ITERATORS (bid_, boundary_id_type bid, bid) DECLARE_NODE_ITERATORS(evaluable_
 
virtual void read (const std::string &name, void *mesh_data=nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false, bool skip_detect_interior_parents=false) override
 Reads the file specified by name.
 
virtual void write (const std::string &name) const override
 Write the file specified by name.
 
void write (const std::string &name, const std::vector< Number > &values, const std::vector< std::string > &variable_names) const
 Write to the file specified by name.
 
virtual void all_first_order () override
 Converts a mesh with higher-order elements into a mesh with linear elements.
 
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.
 
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.
 
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.
 
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.
 
std::size_t stitch_meshes (const MeshBase &other_mesh, boundary_id_type this_mesh_boundary, boundary_id_type other_mesh_boundary, Real tol=TOLERANCE, bool clear_stitched_boundary_ids=false, bool verbose=true, bool use_binary_search=true, bool enforce_all_nodes_match_on_boundaries=false, bool merge_boundary_nodes_all_or_nothing=false, bool remap_subdomain_ids=false, bool prepare_after_stitching=true)
 Stitch other_mesh to this mesh so that this mesh is the union of the two meshes.
 
std::size_t stitch_surfaces (boundary_id_type boundary_id_1, boundary_id_type boundary_id_2, Real tol=TOLERANCE, bool clear_stitched_boundary_ids=false, bool verbose=true, bool use_binary_search=true, bool enforce_all_nodes_match_on_boundaries=false, bool merge_boundary_nodes_all_or_nothing=false, bool prepare_after_stitching=true)
 Similar to stitch_meshes, except that we stitch two adjacent surfaces within this mesh.
 
virtual void copy_nodes_and_elements (const MeshBase &other_mesh, const bool skip_find_neighbors=false, dof_id_type element_id_offset=0, dof_id_type node_id_offset=0, unique_id_type unique_id_offset=0, std::unordered_map< subdomain_id_type, subdomain_id_type > *id_remapping=nullptr, const bool skip_preparation=false)
 Deep copy of nodes and elements from another mesh object (used by subclass copy constructors and by mesh merging operations)
 
virtual void move_nodes_and_elements (MeshBase &&other_mesh)=0
 Move node and elements from other_mesh to this mesh.
 
virtual void find_neighbors (const bool reset_remote_elements=false, const bool reset_current_list=true, const bool assert_valid=true) override
 Other functions from MeshBase requiring re-definition.
 
virtual bool contract () override
 Delete subactive (i.e.
 
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).
 
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.
 
virtual std::unique_ptr< Partitioner > & partitioner ()
 A partitioner to use at each partitioning.
 
const BoundaryInfoget_boundary_info () const
 The information about boundary ids on the mesh.
 
BoundaryInfoget_boundary_info ()
 Writable information about boundary ids on the mesh.
 
bool is_prepared () const
 
Preparation preparation () const
 
void set_isnt_prepared ()
 Tells this we have done some operation where we should no longer consider ourself prepared.
 
void unset_is_prepared ()
 Tells this we have done some operation where we should no longer consider ourself prepared.
 
void unset_is_partitioned ()
 Tells this we have done some operation creating unpartitioned elements.
 
void unset_has_synched_id_counts ()
 Tells this we have done some operation (e.g.
 
void unset_has_neighbor_ptrs ()
 Tells this we have done some operation (e.g.
 
void unset_has_cached_elem_data ()
 Tells this we have done some operation (e.g.
 
void unset_has_interior_parent_ptrs ()
 Tells this we have done some operation (e.g.
 
void unset_has_removed_remote_elements ()
 Tells this we have done some operation (e.g.
 
void unset_has_removed_orphaned_nodes ()
 Tells this we have done some operation (e.g.
 
void unset_has_reinit_ghosting_functors ()
 Tells this we have done some operation (e.g.
 
void unset_has_boundary_id_sets ()
 Tells this we have done some operation which may have invalidated our cached boundary id sets.
 
void unset_has_synched_subdomain_name_map ()
 Tells this we have done some operation which may have left the subdomain id to name map inconsistent across processors.
 
void reinit_ghosting_functors ()
 Loops over ghosting functors and calls mesh_reinit()
 
unsigned int mesh_dimension () const
 
void set_mesh_dimension (unsigned char d)
 Resets the logical dimension of the mesh.
 
const std::set< unsigned char > & elem_dimensions () const
 
const std::set< Order > & elem_default_orders () const
 
Order supported_nodal_order () 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.
 
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.
 
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.
 
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.
 
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.
 
void change_elemset_code (dof_id_type old_code, dof_id_type new_code)
 Replace elemset code "old_code" with "new_code".
 
void change_elemset_id (elemset_id_type old_id, elemset_id_type new_id)
 Replace elemset id "old_id" with "new_id".
 
unsigned int spatial_dimension () const
 
void set_spatial_dimension (unsigned char d)
 Sets the "spatial dimension" of the Mesh.
 
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
 
unique_id_type next_unique_id () const
 
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.
 
virtual const Nodenode_ref (const dof_id_type i) const
 
virtual Nodenode_ref (const dof_id_type i)
 
virtual const Elemelem_ref (const dof_id_type i) const
 
virtual Elemelem_ref (const dof_id_type i)
 
ElemMappingType default_mapping_type () const
 Returns the default master space to physical space mapping basis functions to be used on newly added elements.
 
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.
 
unsigned char default_mapping_data () const
 Returns any default data value used by the master space to physical space mapping.
 
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.
 
void remove_orphaned_nodes ()
 Removes any orphaned nodes, nodes not connected to any elements.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
void prepare_for_use (const bool skip_renumber_nodes_and_elements, const bool skip_find_neighbors)
 Prepare a newly created (or read) mesh for use.
 
void prepare_for_use (const bool skip_renumber_nodes_and_elements)
 
void prepare_for_use ()
 
void complete_preparation ()
 
virtual void partition (const unsigned int n_parts)
 Call the default partitioner (currently metis_partition()).
 
void partition ()
 
void allow_renumbering (bool allow)
 If false is passed in then this mesh will no longer be renumbered when being prepared for use.
 
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.
 
bool allow_find_neighbors () const
 
void allow_detect_interior_parents (bool allow)
 If false is passed then this mesh will no longer work to detect interior parents when being prepared for use.
 
bool allow_detect_interior_parents () 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.
 
bool allow_remote_element_removal () const
 
void allow_node_and_elem_unique_id_overlap (bool allow)
 If true is passed, then this mesh will no longer require unique_ids to be unique across the set of all DofObjects.
 
bool allow_node_and_elem_unique_id_overlap () 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.
 
bool skip_noncritical_partitioning () const
 
void skip_partitioning (bool skip)
 If true is passed in then nothing on this mesh will be (re)partitioned.
 
bool skip_partitioning () const
 
void add_ghosting_functor (GhostingFunctor &ghosting_functor)
 Adds a functor which can specify ghosting requirements for use on distributed meshes.
 
void add_ghosting_functor (std::shared_ptr< GhostingFunctor > ghosting_functor)
 Adds a functor which can specify ghosting requirements for use on distributed meshes.
 
void remove_ghosting_functor (GhostingFunctor &ghosting_functor)
 Removes a functor which was previously added to the set of ghosting functors.
 
GhostingFunctorIterator ghosting_functors_begin () const
 Beginning of range of ghosting functors.
 
GhostingFunctorIterator ghosting_functors_end () const
 End of range of ghosting functors.
 
GhostingFunctordefault_ghosting ()
 Default ghosting functor.
 
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).
 
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.
 
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.
 
virtual void all_complete_order ()
 Calls the range-based version of this function with a range consisting of all elements in the mesh.
 
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.
 
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().
 
Real get_point_locator_close_to_point_tol () const
 
void clear_point_locator ()
 Releases the current PointLocator object.
 
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.
 
bool get_count_lower_dim_elems_in_point_locator () const
 Get the current value of _count_lower_dim_elems_in_point_locator.
 
std::string & subdomain_name (subdomain_id_type id)
 
const std::string & subdomain_name (subdomain_id_type id) const
 
void set_subdomain_name (subdomain_id_type id, const std::string &name, bool synchronous=false)
 Sets the name for the provided id.
 
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_
 
const ElemRangeelement_stored_range ()
 
const ConstElemRangeactive_local_element_stored_range () const
 
void clear_stored_ranges ()
 Clears stored ranges, to indicate that the mesh has changed and they should be regenerated when next needed.
 
std::map< subdomain_id_type, std::string > & set_subdomain_name_map ()
 
const std::map< subdomain_id_type, std::string > & get_subdomain_name_map () const
 
constraint_rows_typeget_constraint_rows ()
 Constraint rows accessors.
 
const constraint_rows_typeget_constraint_rows () const
 
dof_id_type n_constraint_rows () const
 
void copy_constraint_rows (const MeshBase &other_mesh)
 Copy the constraints from the other mesh to this mesh.
 
template<typename T >
void copy_constraint_rows (const SparseMatrix< T > &constraint_operator, bool precondition_constraint_operator=false)
 Copy the constraints from the given matrix to this mesh.
 
void print_constraint_rows (std::ostream &os=libMesh::out, bool print_nonlocal=false) const
 Prints (from processor 0) all mesh constraint rows.
 
std::string get_local_constraints (bool print_nonlocal=false) const
 Gets a string reporting all mesh constraint rows local to this processor.
 
void cache_elem_dims ()
 
void cache_elem_data ()
 
void sync_subdomain_name_map ()
 libMesh often expects all processors to know about names of all subdomain ids, but distributed mesh generators may only know about part of a mesh when creating names.
 
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.
 
const MeshBaseinterior_mesh () const
 
MeshBaseinterior_mesh ()
 
void set_interior_mesh (MeshBase &int_mesh)
 Sets the interior mesh.
 
const std::set< subdomain_id_type > & get_mesh_subdomains () const
 
void add_disjoint_neighbor_boundary_pairs (const boundary_id_type b1, const boundary_id_type b2, const RealVectorValue &translation)
 Register a pair of boundaries as disjoint neighbor boundary pairs.
 
PeriodicBoundariesget_disjoint_neighbor_boundary_pairs ()
 
const PeriodicBoundariesget_disjoint_neighbor_boundary_pairs () const
 
void remove_disjoint_boundary_pair (const boundary_id_type b1, const boundary_id_type b2)
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Public Attributes

unsigned int level
 
processor_id_type pid unsigned int level
 
unsigned int level ElemType type
 
unsigned int level ElemType type std::set< subdomain_id_typess
 
processor_id_type pid unsigned int level std::set< subdomain_id_typess
 
processor_id_type pid
 
processor_id_type pid unsigned int level std::set< subdomain_id_type > ss const DofMap &dof_map LIBMESH_COMMA unsigned int dof_map LIBMESH_COMMA var_num unsigned char rflag processor_id_type pid
 
processor_id_type pid unsigned int level std::set< subdomain_id_type > ss const DofMap &dof_map LIBMESH_COMMA unsigned int var_num = libMesh::invalid_uint
 
processor_id_type pid unsigned int level std::set< subdomain_id_type > ss const DofMap &dof_map LIBMESH_COMMA unsigned int dof_map LIBMESH_COMMA var_num unsigned char rflag processor_id_type pid const DofMap &dof_map LIBMESH_COMMA unsigned int var_num = libMesh::invalid_uint
 
processor_id_type pid unsigned int level std::set< subdomain_id_type > ss const DofMap &dof_map LIBMESH_COMMA unsigned int dof_map LIBMESH_COMMA var_num unsigned char rflag
 
processor_id_type pid unsigned int level std::set< subdomain_id_type > ss const DofMap &dof_map LIBMESH_COMMA unsigned int dof_map LIBMESH_COMMA var_num unsigned char rflag processor_id_type pid const DofMap &dof_map LIBMESH_COMMA unsigned int dof_map LIBMESH_COMMA var_num DECLARE_NODE_ITERATORS(multi_evaluable_, std::vector< const DofMap * > dof_maps, dof_maps) protected dofobject_container< Node_nodes
 Move node and elements from a DistributedMesh.
 
dofobject_container< Elem_elements
 The elements in the mesh.
 
bool _is_serial
 A boolean remembering whether we're serialized or not.
 
bool _is_serial_on_proc_0
 A boolean remembering whether we're serialized to proc 0 or not.
 
bool _deleted_coarse_elements
 A boolean remembering whether we've recently deleted top-level elements or not.
 
dof_id_type _n_nodes
 Cached data from the last renumber_nodes_and_elements call.
 
dof_id_type _n_elem
 
dof_id_type _max_node_id
 
dof_id_type _max_elem_id
 
dof_id_type _next_free_local_node_id
 Guaranteed globally unused IDs for use when adding new nodes or elements.
 
dof_id_type _next_free_local_elem_id
 
dof_id_type _next_free_unpartitioned_node_id
 
dof_id_type _next_free_unpartitioned_elem_id
 
unique_id_type _next_unpartitioned_unique_id
 The next available unique id for assigning ids to unpartitioned DOF objects.
 
std::set< Elem * > _extra_ghost_elems
 These are extra ghost elements that we want to make sure not to delete when we call delete_remote_elements()
 
const DofMap &dof_map LIBMESH_COMMA unsigned int ElemElemRange
 

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.
 
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.
 
void copy_cached_data (const MeshBase &other_mesh)
 Helper class to copy cached data, to synchronize with a possibly unprepared other_mesh.
 
bool nodes_and_elements_equal (const MeshBase &other_mesh) const
 Tests for equality of all elements and nodes in the mesh.
 
unsigned intset_n_partitions ()
 
void size_elem_extra_integers ()
 Size extra-integer arrays of all elements in the mesh.
 
void size_node_extra_integers ()
 Size extra-integer arrays of all nodes in the mesh.
 
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.
 

Protected Attributes

std::unique_ptr< PeriodicBoundaries_disjoint_neighbor_boundary_pairs
 The disjoint neighbor boundary id pairs.
 
std::unique_ptr< BoundaryInfoboundary_info
 This class holds the boundary information.
 
unsigned int _n_parts
 The number of partitions the mesh has.
 
ElemMappingType _default_mapping_type
 The default mapping type (typically Lagrange) between master and physical space to assign to newly added elements.
 
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.
 
Preparation _preparation
 Flags indicating in what ways this mesh has been prepared.
 
std::unique_ptr< ElemRange_element_stored_range
 A cached ElemRange for threaded mutation of all semilocal elements of this mesh.
 
std::unique_ptr< ConstElemRange_const_active_local_element_stored_range
 A cached ConstElemRange for threaded calculation on all local elements of this mesh.
 
std::unique_ptr< PointLocatorBase_point_locator
 A PointLocator class for this mesh.
 
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.
 
std::unique_ptr< Partitioner_partitioner
 A partitioner to use at each prepare_for_use().
 
unique_id_type _next_unique_id
 The next available unique id for assigning ids to DOF objects.
 
MeshBase_interior_mesh
 Defaulting to this, a pointer to the mesh used to generate boundary elements on this.
 
bool _skip_noncritical_partitioning
 If this is true then no partitioning should be done with the possible exception of orphaned nodes.
 
bool _skip_all_partitioning
 If this is true then no partitioning should be done.
 
bool _skip_renumber_nodes_and_elements
 If this is true then renumbering will be kept to a minimum.
 
bool _skip_find_neighbors
 If this is true then we will skip find_neighbors in prepare_for_use.
 
bool _skip_detect_interior_parents
 If this is true then we will skip detect_interior_parents in prepare_for_use.
 
bool _allow_remote_element_removal
 If this is false then even on DistributedMesh remote elements will not be deleted during mesh preparation.
 
bool _allow_node_and_elem_unique_id_overlap
 The Exodus reader (and potentially other readers in the future?) now supports setting Node and Elem unique_ids based on values from within the Exodus file itself, rather than generating them automatically in LibMesh.
 
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.
 
std::set< unsigned char > _elem_dims
 We cache the dimension of the elements present in the mesh.
 
std::set< Order_elem_default_orders
 We cache the (default) order of the geometric elements present in the mesh.
 
Order _supported_nodal_order
 We cache the maximum nodal order supported by all the mesh's elements (the minimum supported_nodal_order() of any element)
 
std::set< subdomain_id_type_mesh_subdomains
 We cache the subdomain ids of the elements present in the mesh.
 
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).
 
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.
 
std::vector< std::string > _elem_integer_names
 The array of names for integer data associated with each element in the mesh.
 
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.
 
std::vector< std::string > _node_integer_names
 The array of names for integer data associated with each node in the mesh.
 
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.
 
std::unique_ptr< GhostingFunctor_default_ghosting
 The default geometric GhostingFunctor, used to implement standard libMesh element ghosting behavior.
 
std::vector< GhostingFunctor * > _ghosting_functors
 The list of all GhostingFunctor objects to be used when distributing a DistributedMesh.
 
std::map< GhostingFunctor *, std::shared_ptr< GhostingFunctor > > _shared_functors
 Hang on to references to any GhostingFunctor objects we were passed in shared_ptr form.
 
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.
 
const Parallel::Communicator_communicator
 

Private Types

typedef dofobject_container< Elem >::veclike_iterator elem_iterator_imp
 Typedefs for the container implementation.
 
typedef dofobject_container< Elem >::const_veclike_iterator const_elem_iterator_imp
 
typedef dofobject_container< Node >::veclike_iterator node_iterator_imp
 Typedefs for the container implementation.
 
typedef dofobject_container< Node >::const_veclike_iterator const_node_iterator_imp
 

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

Detailed Description

The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.

Author
Benjamin S. Kirk
Date
2002

Manages a collection of Nodes and Elems.

Definition at line 50 of file 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 2485 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 2505 of file mesh_base.h.

◆ const_elem_iterator_imp

typedef dofobject_container<Elem>::const_veclike_iterator libMesh::DistributedMesh::const_elem_iterator_imp
privateinherited

Definition at line 476 of file distributed_mesh.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 2492 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 2518 of file mesh_base.h.

◆ const_node_iterator_imp

typedef dofobject_container<Node>::const_veclike_iterator libMesh::DistributedMesh::const_node_iterator_imp
privateinherited

Definition at line 482 of file distributed_mesh.h.

◆ ConstElemRange

Definition at line 1895 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 1929 of file mesh_base.h.

◆ constraint_rows_type

Definition at line 1930 of file mesh_base.h.

◆ dofobject_container [1/2]

template<typename Obj >
using libMesh::DistributedMesh::dofobject_container = mapvector<Obj *, dof_id_type>
inherited

Definition at line 63 of file distributed_mesh.h.

◆ dofobject_container [2/2]

using libMesh::DistributedMesh::dofobject_container = chunked_mapvector<Obj *, dof_id_type, LIBMESH_MAPVECTOR_CHUNK_SIZE>
inherited

Definition at line 65 of file distributed_mesh.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 2480 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 2500 of file mesh_base.h.

◆ elem_iterator_imp

typedef dofobject_container<Elem>::veclike_iterator libMesh::DistributedMesh::elem_iterator_imp
privateinherited

Typedefs for the container implementation.

Definition at line 475 of file distributed_mesh.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 466 of file mesh_base.h.

◆ GhostingFunctorIterator

typedef std::vector<GhostingFunctor*>::const_iterator libMesh::MeshBase::GhostingFunctorIterator
inherited

Iterator type for ghosting functor ranges.

This has changed in the past and may change again; code should use auto or the type here.

Definition at line 1467 of file mesh_base.h.

◆ node_filter_iter [1/2]

Definition at line 2487 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 2513 of file mesh_base.h.

◆ node_iterator_imp

typedef dofobject_container<Node>::veclike_iterator libMesh::DistributedMesh::node_iterator_imp
privateinherited

Typedefs for the container implementation.

Definition at line 481 of file distributed_mesh.h.

◆ Predicate

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

Definition at line 1585 of file mesh_base.h.

Constructor & Destructor Documentation

◆ Mesh() [1/4]

libMesh::Mesh::Mesh ( const Parallel::Communicator comm_in,
unsigned char  dim = 1 
)
inlineexplicit

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 60 of file mesh.h.

62 : DefaultMesh(comm_in,dim) {}
unsigned int dim
DistributedMesh DefaultMesh
Definition mesh.h:27

◆ Mesh() [2/4]

libMesh::Mesh::Mesh ( const UnstructuredMesh other_mesh)
inline

Copy-constructor.

This should be able to take a serial or parallel mesh.

Definition at line 68 of file mesh.h.

68: DefaultMesh(other_mesh) {}

◆ Mesh() [3/4]

libMesh::Mesh::Mesh ( const Mesh )
default

Default copy constructors and destructor.

◆ ~Mesh()

libMesh::Mesh::~Mesh ( )
default

◆ Mesh() [4/4]

libMesh::Mesh::Mesh ( Mesh &&  )
delete

Move-constructor deleted in MeshBase.

Member Function Documentation

◆ ABSTRACT_ELEM_ITERATORS() [1/15]

libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( )
inherited

◆ ABSTRACT_ELEM_ITERATORS() [2/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() [3/15]

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

◆ ABSTRACT_ELEM_ITERATORS() [4/15]

libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( active_semilocal_  )
inherited

◆ ABSTRACT_ELEM_ITERATORS() [5/15]

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

◆ ABSTRACT_ELEM_ITERATORS() [6/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() [7/15]

libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( ancestor_  )
inherited

◆ ABSTRACT_ELEM_ITERATORS() [8/15]

libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( facelocal_  )
inherited

◆ ABSTRACT_ELEM_ITERATORS() [9/15]

libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( local_  )
inherited

◆ ABSTRACT_ELEM_ITERATORS() [10/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() [11/15]

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

◆ ABSTRACT_ELEM_ITERATORS() [12/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() [13/15]

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

◆ ABSTRACT_ELEM_ITERATORS() [14/15]

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

◆ ABSTRACT_ELEM_ITERATORS() [15/15]

libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( semilocal_  )
inherited

◆ active_local_element_stored_range()

const ConstElemRange & libMesh::MeshBase::active_local_element_stored_range ( ) const
inherited
Returns
A reference to a cached vector copy of a range of pointers to all active local elements, suitable for threading.

Iterating over only local elements is most useful for computing on the mesh, so we only have a non-const version for now.

Definition at line 1954 of file mesh_base.C.

1955{
1957 {
1958 // Range construction may not be safe within threads
1960
1962 std::make_unique<ConstElemRange>(this->active_local_elements_begin(),
1963 this->active_local_elements_end());
1964 }
1965
1967}
std::unique_ptr< ConstElemRange > _const_active_local_element_stored_range
A cached ConstElemRange for threaded calculation on all local elements of this mesh.
Definition mesh_base.h:2216
bool in_threads
A boolean which is true iff we are in a Threads:: function It may be useful to assert(!...
Definition threads.C:33
libmesh_assert(ctx)

References libMesh::MeshBase::_const_active_local_element_stored_range, libMesh::Threads::in_threads, and libMesh::libmesh_assert().

Referenced by libMesh::FEMSystem::assemble_qoi(), libMesh::FEMSystem::assemble_qoi_derivative(), libMesh::FEMSystem::assembly(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::MeshTetInterface::check_hull_integrity(), libMesh::MeshRefinement::create_parent_error_vector(), libMesh::MeshTools::n_active_local_levels(), libMesh::FEMSystem::postprocess(), and libMesh::MeshBase::subdomain_ids().

◆ active_local_subdomain_elements_ptr_range() [1/2]

virtual SimpleRange< const_element_iterator > libMesh::DistributedMesh::active_local_subdomain_elements_ptr_range ( subdomain_id_type  sid) const
inlinefinaloverridevirtualinherited

Implements libMesh::MeshBase.

Definition at line 363 of file distributed_mesh.h.

363{ return active_local_subdomain_element_ptr_range(sid); }

◆ active_local_subdomain_elements_ptr_range() [2/2]

virtual SimpleRange< element_iterator > libMesh::DistributedMesh::active_local_subdomain_elements_ptr_range ( subdomain_id_type  sid)
inlinefinaloverridevirtualinherited

Implements libMesh::MeshBase.

Definition at line 362 of file distributed_mesh.h.

362{ return active_local_subdomain_element_ptr_range(sid); }

◆ active_subdomain_elements_ptr_range() [1/2]

virtual SimpleRange< const_element_iterator > libMesh::DistributedMesh::active_subdomain_elements_ptr_range ( subdomain_id_type  sid) const
inlinefinaloverridevirtualinherited

Implements libMesh::MeshBase.

Definition at line 361 of file distributed_mesh.h.

361{ return active_subdomain_element_ptr_range(sid); }

◆ active_subdomain_elements_ptr_range() [2/2]

unsigned int level ElemType type std::set< subdomain_id_type > virtual ss SimpleRange< element_iterator > libMesh::DistributedMesh::active_subdomain_elements_ptr_range ( subdomain_id_type  sid)
inlinefinaloverridevirtualinherited

Implements libMesh::MeshBase.

Definition at line 360 of file distributed_mesh.h.

360{ return active_subdomain_element_ptr_range(sid); }

◆ active_subdomain_set_elements_ptr_range() [1/2]

virtual SimpleRange< const_element_iterator > libMesh::DistributedMesh::active_subdomain_set_elements_ptr_range ( std::set< subdomain_id_type ss) const
inlinefinaloverridevirtualinherited

Implements libMesh::MeshBase.

Definition at line 365 of file distributed_mesh.h.

365{ return active_subdomain_set_element_ptr_range(ss); }
unsigned int level ElemType type std::set< subdomain_id_type > ss

References libMesh::DistributedMesh::ss.

◆ active_subdomain_set_elements_ptr_range() [2/2]

virtual SimpleRange< element_iterator > libMesh::DistributedMesh::active_subdomain_set_elements_ptr_range ( std::set< subdomain_id_type ss)
inlinefinaloverridevirtualinherited

Implements libMesh::MeshBase.

Definition at line 364 of file distributed_mesh.h.

364{ return active_subdomain_set_element_ptr_range(ss); }

References libMesh::DistributedMesh::ss.

◆ add_disjoint_neighbor_boundary_pairs()

void libMesh::MeshBase::add_disjoint_neighbor_boundary_pairs ( const boundary_id_type  b1,
const boundary_id_type  b2,
const RealVectorValue translation 
)
inherited

Register a pair of boundaries as disjoint neighbor boundary pairs.

Definition at line 2272 of file mesh_base.C.

2275 {
2276 // Lazily allocate the container the first time it’s needed
2278 _disjoint_neighbor_boundary_pairs = std::make_unique<PeriodicBoundaries>();
2279
2280 PeriodicBoundaries & db = *_disjoint_neighbor_boundary_pairs;
2281
2282 // Create forward and inverse boundary mappings
2283 PeriodicBoundary forward(translation);
2284 PeriodicBoundary inverse(translation * -1.0);
2285
2286 forward.myboundary = b1;
2287 forward.pairedboundary = b2;
2288 inverse.myboundary = b2;
2289 inverse.pairedboundary = b1;
2290
2291 // Add both directions into the container
2292 db.emplace(b1, forward.clone());
2293 db.emplace(b2, inverse.clone());
2294 }
std::unique_ptr< PeriodicBoundaries > _disjoint_neighbor_boundary_pairs
The disjoint neighbor boundary id pairs.
Definition mesh_base.h:2119

References libMesh::MeshBase::_disjoint_neighbor_boundary_pairs, libMesh::PeriodicBoundary::clone(), libMesh::PeriodicBoundaryBase::myboundary, and libMesh::PeriodicBoundaryBase::pairedboundary.

Referenced by DisjointNeighborTest::build_four_disjoint_elems(), DisjointNeighborTest::build_split_mesh_with_interface(), DisjointNeighborTest::build_two_disjoint_elems(), libMesh::UnstructuredMesh::stitching_helper(), DisjointNeighborTest::testDisjointNeighborConflictError(), and DisjointNeighborTest::testStitchCrossMesh().

◆ add_elem() [1/2]

Elem * libMesh::DistributedMesh::add_elem ( Elem e)
finaloverridevirtualinherited

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::complete_preparation() after elements are added to and/or deleted from the mesh.

Implements libMesh::MeshBase.

Definition at line 529 of file distributed_mesh.C.

530{
531 // Don't try to add nullptrs!
533
534 // Trying to add an existing element is a no-op
535 if (e->valid_id() && _elements[e->id()] == e)
536 return e;
537
538 const processor_id_type elem_procid = e->processor_id();
539
540 if (!e->valid_id())
541 {
542 // We should only be creating new ids past the end of the range
543 // of existing ids
544 libmesh_assert_greater_equal(_next_free_unpartitioned_elem_id,
546 libmesh_assert_greater_equal(_next_free_local_elem_id, _max_elem_id);
547
548 // Use the unpartitioned ids for unpartitioned elems, and
549 // temporarily for ghost elems
551 if (elem_procid == this->processor_id())
552 next_id = &_next_free_local_elem_id;
553 e->set_id (*next_id);
554 }
555
556 {
557 // Advance next_ids up high enough that each is pointing to an
558 // unused id and any subsequent increments will still point us
559 // to unused ids
560 _max_elem_id = std::max(_max_elem_id,
561 static_cast<dof_id_type>(e->id()+1));
562
565 ((_max_elem_id-1) / (this->n_processors() + 1) + 1) *
566 (this->n_processors() + 1) + this->n_processors();
569 ((_max_elem_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
570 (this->n_processors() + 1) + this->processor_id();
571
572#ifndef NDEBUG
573 // We need a const dofobject_container so we don't inadvertently create
574 // nullptr entries when testing for non-nullptr ones
575 const dofobject_container<Elem> & const_elements = _elements;
576#endif
579 }
580
581 // Don't try to overwrite existing elems
582 libmesh_assert (!_elements[e->id()]);
583
584 _elements[e->id()] = e;
585
586 // We actually added a new element. Some of our caches might still
587 // be valid, but we should clear the ones which definitely are not.
588 this->clear_point_locator();
589 this->clear_stored_ranges();
590
591 // Try to make the cached elem data more accurate
592 if (elem_procid == this->processor_id() ||
593 elem_procid == DofObject::invalid_processor_id)
594 _n_elem++;
595
596#ifdef LIBMESH_ENABLE_UNIQUE_ID
597 if (!e->valid_unique_id())
598 {
599 if (processor_id() == e->processor_id())
600 {
601 e->set_unique_id(_next_unique_id);
602 _next_unique_id += this->n_processors() + 1;
603 }
604 else
605 {
606 e->set_unique_id(_next_unpartitioned_unique_id);
608 }
609 }
610 else
611 {
612 _next_unique_id = std::max(_next_unique_id, e->unique_id()+1);
614 ((_next_unique_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
615 (this->n_processors() + 1) + this->processor_id();
616 }
617#endif
618
619 // Unpartitioned elems should be added on every processor
620 // And shouldn't be added in the same batch as ghost elems
621 // But we might be just adding on processor 0 to
622 // broadcast later
623 // #ifdef DEBUG
624 // if (elem_procid == DofObject::invalid_processor_id)
625 // {
626 // dof_id_type elem_id = e->id();
627 // this->comm().max(elem_id);
628 // libmesh_assert_equal_to (elem_id, e->id());
629 // }
630 // #endif
631
632 // Make sure any new element is given space for any extra integers
633 // we've requested
634 e->add_extra_integers(_elem_integer_names.size(),
636
637 // And set mapping type and data on any new element
638 e->set_mapping_type(this->default_mapping_type());
639 e->set_mapping_data(this->default_mapping_data());
640
641 return e;
642}
dof_id_type _next_free_unpartitioned_elem_id
dofobject_container< Elem > _elements
The elements in the mesh.
unique_id_type _next_unpartitioned_unique_id
The next available unique id for assigning ids to unpartitioned DOF objects.
static constexpr 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:484
ElemMappingType default_mapping_type() const
Returns the default master space to physical space mapping basis functions to be used on newly added ...
Definition mesh_base.h:941
unique_id_type _next_unique_id
The next available unique id for assigning ids to DOF objects.
Definition mesh_base.h:2245
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:2371
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:2377
unsigned char default_mapping_data() const
Returns any default data value used by the master space to physical space mapping.
Definition mesh_base.h:959
void clear_point_locator()
Releases the current PointLocator object.
Definition mesh_base.C:1866
void clear_stored_ranges()
Clears stored ranges, to indicate that the mesh has changed and they should be regenerated when next ...
Definition mesh_base.C:1969
processor_id_type processor_id() const
processor_id_type n_processors() const
uint8_t dof_id_type
Definition id_types.h:67
uint8_t processor_id_type
Definition id_types.h:104

References libMesh::MeshBase::_elem_integer_default_values, libMesh::MeshBase::_elem_integer_names, libMesh::DistributedMesh::_elements, libMesh::DistributedMesh::_max_elem_id, libMesh::DistributedMesh::_n_elem, libMesh::DistributedMesh::_next_free_local_elem_id, libMesh::DistributedMesh::_next_free_unpartitioned_elem_id, libMesh::MeshBase::_next_unique_id, libMesh::DistributedMesh::_next_unpartitioned_unique_id, libMesh::DofObject::add_extra_integers(), libMesh::MeshBase::clear_point_locator(), libMesh::MeshBase::clear_stored_ranges(), libMesh::MeshBase::default_mapping_data(), libMesh::MeshBase::default_mapping_type(), libMesh::DofObject::id(), libMesh::DofObject::invalid_processor_id, libMesh::libmesh_assert(), libMesh::ParallelObject::n_processors(), libMesh::DofObject::processor_id(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::set_id(), libMesh::Elem::set_mapping_data(), libMesh::Elem::set_mapping_type(), libMesh::DofObject::set_unique_id(), libMesh::DofObject::unique_id(), libMesh::DofObject::valid_id(), and libMesh::DofObject::valid_unique_id().

Referenced by libMesh::DistributedMesh::add_elem(), libMesh::DistributedMesh::add_extra_ghost_elem(), DisjointNeighborTest::testDisjointNeighborConflictError(), and DisjointNeighborTest::testStitchCrossMesh().

◆ add_elem() [2/2]

Elem * libMesh::DistributedMesh::add_elem ( std::unique_ptr< Elem e)
finaloverridevirtualinherited

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.

Implements libMesh::MeshBase.

Definition at line 646 of file distributed_mesh.C.

647{
648 // The mesh now takes ownership of the Elem. Eventually the guts of
649 // add_elem() will get moved to a private helper function, and
650 // calling add_elem() directly will be deprecated.
651 return add_elem(e.release());
652}
virtual Elem * add_elem(Elem *e) override final
Add elem e to the end of the element array.

References libMesh::DistributedMesh::add_elem().

◆ 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 2654 of file mesh_base.h.

2657{
2658 libmesh_assert(!default_values || default_values->size() == names.size());
2659
2660 std::vector<unsigned int> returnval(names.size());
2661
2662 const std::size_t old_size = _elem_integer_names.size();
2663
2664 for (auto i : index_range(names))
2665 returnval[i] =
2666 this->add_elem_datum<T>(names[i], false,
2667 default_values ?
2668 (*default_values)[i] : nullptr);
2669
2670 if (allocate_data && old_size != _elem_integer_names.size())
2672
2673 return returnval;
2674}
void size_elem_extra_integers()
Size extra-integer arrays of all elements in the mesh.
Definition mesh_base.C:2361
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.
Definition mesh_base.h:2630
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:153

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

◆ 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 2630 of file mesh_base.h.

2633{
2634 const std::size_t old_size = _elem_integer_names.size();
2635
2636 unsigned int n_more_integers = (sizeof(T)-1)/sizeof(dof_id_type);
2637 std::vector<dof_id_type> int_data(n_more_integers+1, DofObject::invalid_id);
2638 if (default_value)
2639 std::memcpy(int_data.data(), default_value, sizeof(T));
2640
2641 unsigned int start_idx = this->add_elem_integer(name, false, int_data[0]);
2642 for (unsigned int i=0; i != n_more_integers; ++i)
2643 this->add_elem_integer(name+"__"+std::to_string(i), false, int_data[i+1]);
2644
2645 if (allocate_data && old_size != _elem_integer_names.size())
2647
2648 return start_idx;
2649}
static constexpr dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition dof_object.h:473
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:623

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().

◆ 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 623 of file mesh_base.C.

626{
627 for (auto i : index_range(_elem_integer_names))
629 {
630 libmesh_assert_less(i, _elem_integer_default_values.size());
631 _elem_integer_default_values[i] = default_value;
632 return i;
633 }
634
635 libmesh_assert_equal_to(_elem_integer_names.size(),
637 _elem_integer_names.push_back(std::move(name));
638 _elem_integer_default_values.push_back(default_value);
639 if (allocate_data)
641 return _elem_integer_names.size()-1;
642}
std::string name(const ElemQuality q)
This function returns a string containing some name for q.

References libMesh::MeshBase::_elem_integer_default_values, libMesh::MeshBase::_elem_integer_names, libMesh::index_range(), 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().

◆ 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 646 of file mesh_base.C.

649{
650 libmesh_assert(!default_values || default_values->size() == names.size());
651 libmesh_assert_equal_to(_elem_integer_names.size(), _elem_integer_default_values.size());
652
653 std::unordered_map<std::string, std::size_t> name_indices;
654 for (auto i : index_range(_elem_integer_names))
655 name_indices[_elem_integer_names[i]] = i;
656
657 std::vector<unsigned int> returnval(names.size());
658
659 bool added_an_integer = false;
660 for (auto i : index_range(names))
661 {
662 const std::string & name = names[i];
663 if (const auto it = name_indices.find(name);
664 it != name_indices.end())
665 {
666 returnval[i] = it->second;
667 _elem_integer_default_values[it->second] =
668 default_values ? (*default_values)[i] : DofObject::invalid_id;
669 }
670 else
671 {
672 returnval[i] = _elem_integer_names.size();
673 name_indices[name] = returnval[i];
674 _elem_integer_names.push_back(name);
676 (default_values ? (*default_values)[i] : DofObject::invalid_id);
677 added_an_integer = true;
678 }
679 }
680
681 if (allocate_data && added_an_integer)
683
684 return returnval;
685}

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

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

◆ 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 456 of file mesh_base.C.

457{
458 // Populate inverse map, stealing id_set's resources
459 auto [it1, inserted1] = _elemset_codes_inverse_map.emplace(std::move(id_set), code);
460
461 // Reference to the newly inserted (or previously existing) id_set
462 const auto & inserted_id_set = it1->first;
463
464 // Keep track of all elemset ids ever added for O(1) n_elemsets()
465 // performance. Only need to do this if we didn't know about this
466 // id_set before...
467 if (inserted1)
468 _all_elemset_ids.insert(inserted_id_set.begin(), inserted_id_set.end());
469
470 // Take the address of the newly emplaced set to use in
471 // _elemset_codes, avoid duplicating std::set storage
472 auto [it2, inserted2] = _elemset_codes.emplace(code, &inserted_id_set);
473
474 // Throw an error if this code already exists with a pointer to a
475 // different set of ids.
476 libmesh_error_msg_if(!inserted2 && it2->second != &inserted_id_set,
477 "The elemset code " << code << " already exists with a different id_set.");
478}
MeshBase::elemset_type _all_elemset_ids
Definition mesh_base.h:2359
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:2357
std::map< MeshBase::elemset_type, dof_id_type > _elemset_codes_inverse_map
Definition mesh_base.h:2358

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(), libMesh::UnstructuredMesh::stitching_helper(), MeshStitchTest::testMeshStitchElemsets(), and WriteElemsetData::testWriteImpl().

◆ add_extra_ghost_elem()

void libMesh::DistributedMesh::add_extra_ghost_elem ( Elem e)
virtualinherited

Inserts the element and adds it to a list of elements that should not get deleted or have their descendants deleted by delete_remote_elements.

This is handy for inserting otherwise off-processor elements that you want to keep track of on this processor.

Definition at line 1807 of file distributed_mesh.C.

1808{
1809 // First add the elem like normal
1810 add_elem(e);
1811
1812 // Now add it to the set that won't be deleted when we call
1813 // delete_remote_elements()
1814 _extra_ghost_elems.insert(e);
1815}
std::set< Elem * > _extra_ghost_elems
These are extra ghost elements that we want to make sure not to delete when we call delete_remote_ele...

References libMesh::DistributedMesh::_extra_ghost_elems, and libMesh::DistributedMesh::add_elem().

◆ add_ghosting_functor() [1/2]

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

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 1078 of file mesh_base.C.

1079{
1080 // We used to implicitly support duplicate inserts to std::set
1081#ifdef LIBMESH_ENABLE_DEPRECATED
1082 _ghosting_functors.erase
1083 (std::remove(_ghosting_functors.begin(),
1084 _ghosting_functors.end(),
1085 &ghosting_functor),
1086 _ghosting_functors.end());
1087#endif
1088
1089 // We shouldn't have two copies of the same functor
1090 libmesh_assert(std::find(_ghosting_functors.begin(),
1091 _ghosting_functors.end(),
1092 &ghosting_functor) ==
1093 _ghosting_functors.end());
1094
1095 _ghosting_functors.push_back(&ghosting_functor);
1096}
std::vector< GhostingFunctor * > _ghosting_functors
The list of all GhostingFunctor objects to be used when distributing a DistributedMesh.
Definition mesh_base.h:2424

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

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

◆ 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 1452 of file mesh_base.h.

1453 { _shared_functors[ghosting_functor.get()] = ghosting_functor;
1454 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:2430
void add_ghosting_functor(GhostingFunctor &ghosting_functor)
Adds a functor which can specify ghosting requirements for use on distributed meshes.
Definition mesh_base.C:1078

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

◆ add_node() [1/2]

Node * libMesh::DistributedMesh::add_node ( Node n)
finaloverridevirtualinherited

Add Node n to the end of the vertex array.

Implements libMesh::MeshBase.

Definition at line 819 of file distributed_mesh.C.

820{
821 // Don't try to add nullptrs!
823
824 // Trying to add an existing node is a no-op
825 if (n->valid_id() && _nodes[n->id()] == n)
826 return n;
827
828 const processor_id_type node_procid = n->processor_id();
829
830 if (!n->valid_id())
831 {
832 // We should only be creating new ids past the end of the range
833 // of existing ids
834 libmesh_assert_greater_equal(_next_free_unpartitioned_node_id,
836 libmesh_assert_greater_equal(_next_free_local_node_id, _max_node_id);
837
838 // Use the unpartitioned ids for unpartitioned nodes,
839 // and temporarily for ghost nodes
841 if (node_procid == this->processor_id())
842 next_id = &_next_free_local_node_id;
843 n->set_id (*next_id);
844 }
845
846 {
847 // Advance next_ids up high enough that each is pointing to an
848 // unused id and any subsequent increments will still point us
849 // to unused ids
850 _max_node_id = std::max(_max_node_id,
851 static_cast<dof_id_type>(n->id()+1));
852
855 ((_max_node_id-1) / (this->n_processors() + 1) + 1) *
856 (this->n_processors() + 1) + this->n_processors();
859 ((_max_node_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
860 (this->n_processors() + 1) + this->processor_id();
861
862#ifndef NDEBUG
863 // We need a const dofobject_container so we don't inadvertently create
864 // nullptr entries when testing for non-nullptr ones
865 const dofobject_container<Node> & const_nodes = _nodes;
866#endif
869 }
870
871 // Don't try to overwrite existing nodes
872 libmesh_assert (!_nodes[n->id()]);
873
874 _nodes[n->id()] = n;
875
876 // Try to make the cached node data more accurate
877 if (node_procid == this->processor_id() ||
878 node_procid == DofObject::invalid_processor_id)
879 _n_nodes++;
880
881#ifdef LIBMESH_ENABLE_UNIQUE_ID
882 if (!n->valid_unique_id())
883 {
884 if (processor_id() == n->processor_id())
885 {
886 n->set_unique_id(_next_unique_id);
887 _next_unique_id += this->n_processors() + 1;
888 }
889 else
890 {
891 n->set_unique_id(_next_unpartitioned_unique_id);
893 }
894 }
895 else
896 {
897 _next_unique_id = std::max(_next_unique_id, n->unique_id()+1);
899 ((_next_unique_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
900 (this->n_processors() + 1) + this->processor_id();
901 }
902#endif
903
904 n->add_extra_integers(_node_integer_names.size(),
906
907 // Unpartitioned nodes should be added on every processor
908 // And shouldn't be added in the same batch as ghost nodes
909 // But we might be just adding on processor 0 to
910 // broadcast later
911 // #ifdef DEBUG
912 // if (node_procid == DofObject::invalid_processor_id)
913 // {
914 // dof_id_type node_id = n->id();
915 // this->comm().max(node_id);
916 // libmesh_assert_equal_to (node_id, n->id());
917 // }
918 // #endif
919
920 return n;
921}
dof_id_type _n_nodes
Cached data from the last renumber_nodes_and_elements call.
dof_id_type _next_free_unpartitioned_node_id
processor_id_type pid unsigned int level std::set< subdomain_id_type > ss const DofMap &dof_map LIBMESH_COMMA unsigned int dof_map LIBMESH_COMMA var_num unsigned char rflag processor_id_type pid const DofMap &dof_map LIBMESH_COMMA unsigned int dof_map LIBMESH_COMMA var_num DECLARE_NODE_ITERATORS(multi_evaluable_, std::vector< const DofMap * > dof_maps, dof_maps) protected dofobject_container< Node > _nodes
Move node and elements from a DistributedMesh.
dof_id_type _next_free_local_node_id
Guaranteed globally unused IDs for use when adding new nodes or elements.
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:2389
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:2383

References libMesh::DistributedMesh::_max_node_id, libMesh::DistributedMesh::_n_nodes, libMesh::DistributedMesh::_next_free_local_node_id, libMesh::DistributedMesh::_next_free_unpartitioned_node_id, libMesh::MeshBase::_next_unique_id, libMesh::DistributedMesh::_next_unpartitioned_unique_id, libMesh::MeshBase::_node_integer_default_values, libMesh::MeshBase::_node_integer_names, libMesh::DistributedMesh::_nodes, libMesh::DofObject::add_extra_integers(), libMesh::DofObject::id(), libMesh::DofObject::invalid_processor_id, libMesh::libmesh_assert(), libMesh::ParallelObject::n_processors(), libMesh::DofObject::processor_id(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::set_id(), libMesh::DofObject::set_unique_id(), libMesh::DofObject::unique_id(), libMesh::DofObject::valid_id(), and libMesh::DofObject::valid_unique_id().

Referenced by libMesh::DistributedMesh::add_node(), libMesh::DistributedMesh::add_point(), and libMesh::DistributedMesh::own_node().

◆ add_node() [2/2]

Node * libMesh::DistributedMesh::add_node ( std::unique_ptr< Node n)
finaloverridevirtualinherited

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.

Implements libMesh::MeshBase.

Definition at line 923 of file distributed_mesh.C.

924{
925 // The mesh now takes ownership of the Node. Eventually the guts of
926 // add_node() will get moved to a private helper function, and
927 // calling add_node() directly will be deprecated.
928 return add_node(n.release());
929}
virtual Node * add_node(Node *n) override final
Add Node n to the end of the vertex array.

References libMesh::DistributedMesh::add_node().

◆ 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 2703 of file mesh_base.h.

2706{
2707 libmesh_assert(!default_values || default_values->size() == names.size());
2708
2709 std::vector<unsigned int> returnval(names.size());
2710
2711 const std::size_t old_size = _node_integer_names.size();
2712
2713 for (auto i : index_range(names))
2714 returnval[i] =
2715 this->add_node_datum<T>(names[i], false,
2716 default_values ?
2717 (*default_values)[i] : nullptr);
2718
2719 if (allocate_data && old_size != _node_integer_names.size())
2721
2722 return returnval;
2723}
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.
Definition mesh_base.h:2679
void size_node_extra_integers()
Size extra-integer arrays of all nodes in the mesh.
Definition mesh_base.C:2376

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

◆ 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 2679 of file mesh_base.h.

2682{
2683 const std::size_t old_size = _node_integer_names.size();
2684
2685 unsigned int n_more_integers = (sizeof(T)-1)/sizeof(dof_id_type);
2686 std::vector<dof_id_type> int_data(n_more_integers+1, DofObject::invalid_id);
2687 if (default_value)
2688 std::memcpy(int_data.data(), default_value, sizeof(T));
2689
2690 unsigned int start_idx = this->add_node_integer(name, false, int_data[0]);
2691 for (unsigned int i=0; i != n_more_integers; ++i)
2692 this->add_node_integer(name+"__"+std::to_string(i), false, int_data[i+1]);
2693
2694 if (allocate_data && old_size != _node_integer_names.size())
2696
2697 return start_idx;
2698}
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:712

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

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

◆ 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 712 of file mesh_base.C.

715{
716 for (auto i : index_range(_node_integer_names))
718 {
719 libmesh_assert_less(i, _node_integer_default_values.size());
720 _node_integer_default_values[i] = default_value;
721 return i;
722 }
723
724 libmesh_assert_equal_to(_node_integer_names.size(),
726 _node_integer_names.push_back(std::move(name));
727 _node_integer_default_values.push_back(default_value);
728 if (allocate_data)
730 return _node_integer_names.size()-1;
731}

References libMesh::MeshBase::_node_integer_default_values, libMesh::MeshBase::_node_integer_names, libMesh::index_range(), 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().

◆ 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 735 of file mesh_base.C.

738{
739 libmesh_assert(!default_values || default_values->size() == names.size());
740 libmesh_assert_equal_to(_node_integer_names.size(), _node_integer_default_values.size());
741
742 std::unordered_map<std::string, std::size_t> name_indices;
743 for (auto i : index_range(_node_integer_names))
744 name_indices[_node_integer_names[i]] = i;
745
746 std::vector<unsigned int> returnval(names.size());
747
748 bool added_an_integer = false;
749 for (auto i : index_range(names))
750 {
751 const std::string & name = names[i];
752 if (const auto it = name_indices.find(name);
753 it != name_indices.end())
754 {
755 returnval[i] = it->second;
756 _node_integer_default_values[it->second] =
757 default_values ? (*default_values)[i] : DofObject::invalid_id;
758 }
759 else
760 {
761 returnval[i] = _node_integer_names.size();
762 name_indices[name] = returnval[i];
763 _node_integer_names.push_back(name);
765 (default_values ? (*default_values)[i] : DofObject::invalid_id);
766 added_an_integer = true;
767 }
768 }
769
770 if (allocate_data && added_an_integer)
772
773 return returnval;
774}

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

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

◆ add_point()

Node * libMesh::DistributedMesh::add_point ( const Point p,
const dof_id_type  id = DofObject::invalid_id,
const processor_id_type  proc_id = DofObject::invalid_processor_id 
)
finaloverridevirtualinherited

functions for adding /deleting nodes elements.

Implements libMesh::MeshBase.

Definition at line 783 of file distributed_mesh.C.

786{
787 Node * old_n = this->query_node_ptr(id);
788
789 if (old_n)
790 {
791 *old_n = p;
792 old_n->processor_id() = proc_id;
793
794 return old_n;
795 }
796
797 Node * n = Node::build(p, id).release();
798 n->processor_id() = proc_id;
799
801}
virtual const Node * query_node_ptr(const dof_id_type i) const override final
static std::unique_ptr< Node > build(const Node &n)
Definition node.h:315

References libMesh::DistributedMesh::add_node(), libMesh::Node::build(), libMesh::DofObject::processor_id(), and libMesh::DistributedMesh::query_node_ptr().

Referenced by DisjointNeighborTest::testDisjointNeighborConflictError(), and DisjointNeighborTest::testStitchCrossMesh().

◆ 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 1808 of file mesh_base.C.

1809{
1810 this->all_complete_order_range(this->element_ptr_range());
1811}
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,...

References libMesh::MeshBase::all_complete_order_range().

Referenced by AllSecondOrderTest::allCompleteOrder(), libMesh::MeshTools::Generation::build_cube(), libMesh::MeshTetInterface::increase_tet_order(), libMesh::TriangulatorInterface::increase_triangle_order(), main(), and MeshTetTest::testNetGenTet14Curved().

◆ all_complete_order_range()

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

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 1800 of file unstructured_mesh.C.

1801{
1802 LOG_SCOPE("all_complete_order()", "Mesh");
1803
1804 /*
1805 * The maximum number of new higher-order nodes we might be adding,
1806 * for use when picking unique unique_id values later. This variable
1807 * is not used unless unique ids are enabled.
1808 */
1809 unsigned int max_new_nodes_per_elem;
1810
1811 /*
1812 * for speed-up of the \p add_point() method, we
1813 * can reserve memory. Guess the number of additional
1814 * nodes based on the element spatial dimensions and the
1815 * total number of nodes in the mesh as an upper bound.
1816 */
1817 switch (this->mesh_dimension())
1818 {
1819 case 1:
1820 /*
1821 * in 1D, there can only be order-increase from Edge2
1822 * to Edge3. Something like 1/2 of n_nodes() have
1823 * to be added
1824 */
1825 max_new_nodes_per_elem = 3 - 2;
1826 this->reserve_nodes(static_cast<unsigned int>
1827 (1.5*static_cast<double>(this->n_nodes())));
1828 break;
1829
1830 case 2:
1831 /*
1832 * in 2D, we typically refine from Tri3 or Tri6 to Tri7 (2.3333
1833 * or 1.1667 times the nodes) but might refine from Quad4 to
1834 * Quad9 (2.25 times the nodes)
1835 */
1836 max_new_nodes_per_elem = 9 - 4;
1837 this->reserve_nodes(static_cast<unsigned int>
1838 (2*static_cast<double>(this->n_nodes())));
1839 break;
1840
1841
1842 case 3:
1843 /*
1844 * in 3D, we typically refine from Tet10 to Tet14 (factor = 1.4)
1845 * but may go Hex8 to Hex27 or Tet4 to Tet14 (something > 3).
1846 * Since in 3D there _are_ already quite some nodes, and since
1847 * we do not want to overburden the memory by a too-conservative
1848 * guess, use a moderate bound
1849 */
1850 max_new_nodes_per_elem = 27 - 8;
1851 this->reserve_nodes(static_cast<unsigned int>
1852 (2.5*static_cast<double>(this->n_nodes())));
1853 break;
1854
1855 default:
1856 // Hm?
1857 libmesh_error_msg("Unknown mesh dimension " << this->mesh_dimension());
1858 }
1859
1860 // All the real work is done in the helper function
1861 all_increased_order_range(*this, range, max_new_nodes_per_elem,
1862 [](ElemType t) {
1864 });
1865}
static ElemType complete_order_equivalent_type(const ElemType et)
Definition elem.C:3352
unsigned int mesh_dimension() const
Definition mesh_base.C:430
virtual dof_id_type n_nodes() const =0
virtual void reserve_nodes(const dof_id_type nn)=0
Reserves space for a known number of nodes.
ElemType
Defines an enum for geometric element types.

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

◆ all_first_order()

void libMesh::UnstructuredMesh::all_first_order ( )
overridevirtualinherited

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 1598 of file unstructured_mesh.C.

1599{
1600 LOG_SCOPE("all_first_order()", "Mesh");
1601
1605 std::vector<bool> node_touched_by_me(this->max_node_id(), false);
1606
1607 // Loop over the high-ordered elements.
1608 // First make sure they _are_ indeed high-order, and then replace
1609 // them with an equivalent first-order element.
1610 for (auto & so_elem : element_ptr_range())
1611 {
1612 libmesh_assert(so_elem);
1613
1614 /*
1615 * build the first-order equivalent, add to
1616 * the new_elements list.
1617 */
1618 auto lo_elem = Elem::build
1620 (so_elem->type()), so_elem->parent());
1621
1622 const unsigned short n_sides = so_elem->n_sides();
1623
1624 for (unsigned short s=0; s != n_sides; ++s)
1625 if (so_elem->neighbor_ptr(s) == remote_elem)
1626 lo_elem->set_neighbor(s, const_cast<RemoteElem *>(remote_elem));
1627
1628#ifdef LIBMESH_ENABLE_AMR
1629 /*
1630 * Reset the parent links of any child elements
1631 */
1632 if (so_elem->has_children())
1633 for (unsigned int c = 0, nc = so_elem->n_children(); c != nc; ++c)
1634 {
1635 Elem * child = so_elem->child_ptr(c);
1636 if (child != remote_elem)
1637 child->set_parent(lo_elem.get());
1638 lo_elem->add_child(child, c);
1639 }
1640
1641 /*
1642 * Reset the child link of any parent element
1643 */
1644 if (so_elem->parent())
1645 {
1646 unsigned int c =
1647 so_elem->parent()->which_child_am_i(so_elem);
1648 lo_elem->parent()->replace_child(lo_elem.get(), c);
1649 }
1650
1651 /*
1652 * Copy as much data to the new element as makes sense
1653 */
1654 lo_elem->set_p_level(so_elem->p_level());
1655 lo_elem->set_refinement_flag(so_elem->refinement_flag());
1656 lo_elem->set_p_refinement_flag(so_elem->p_refinement_flag());
1657#endif
1658
1659 libmesh_assert_equal_to (lo_elem->n_vertices(), so_elem->n_vertices());
1660
1661 /*
1662 * By definition the vertices of the linear and
1663 * second order element are identically numbered.
1664 * transfer these.
1665 */
1666 for (unsigned int v=0, snv=so_elem->n_vertices(); v < snv; v++)
1667 {
1668 lo_elem->set_node(v, so_elem->node_ptr(v));
1669 node_touched_by_me[lo_elem->node_id(v)] = true;
1670 }
1671
1672 /*
1673 * find_neighbors relies on remote_elem neighbor links being
1674 * properly maintained.
1675 */
1676 for (unsigned short s=0; s != n_sides; s++)
1677 {
1678 if (so_elem->neighbor_ptr(s) == remote_elem)
1679 lo_elem->set_neighbor(s, const_cast<RemoteElem*>(remote_elem));
1680 }
1681
1689 (this->get_boundary_info(), so_elem, lo_elem.get());
1690
1691 /*
1692 * The new first-order element is ready.
1693 * Inserting it into the mesh will replace and delete
1694 * the second-order element.
1695 */
1696 lo_elem->set_id(so_elem->id());
1697#ifdef LIBMESH_ENABLE_UNIQUE_ID
1698 lo_elem->set_unique_id(so_elem->unique_id());
1699#endif
1700
1701 const unsigned int nei = so_elem->n_extra_integers();
1702 lo_elem->add_extra_integers(nei);
1703 for (unsigned int i=0; i != nei; ++i)
1704 lo_elem->set_extra_integer(i, so_elem->get_extra_integer(i));
1705
1706 lo_elem->inherit_data_from(*so_elem);
1707
1708 this->insert_elem(std::move(lo_elem));
1709 }
1710
1711 // Deleting nodes does not invalidate iterators, so this is safe.
1712 for (const auto & node : this->node_ptr_range())
1713 if (!node_touched_by_me[node->id()])
1714 this->delete_node(node);
1715
1716 // If crazy people applied boundary info to non-vertices and then
1717 // deleted those non-vertices, we should make sure their boundary id
1718 // caches are correct.
1720
1721 // On hanging nodes that used to also be second order nodes, we
1722 // might now have an invalid nodal processor_id()
1724
1725 // delete or renumber nodes if desired
1726 this->prepare_for_use();
1727}
void copy_boundary_ids(const BoundaryInfo &old_boundary_info, const Elem *const old_elem, const Elem *const new_elem)
void regenerate_id_sets()
Clears and regenerates the cached sets of ids.
This is the base class from which all geometric element types are derived.
Definition elem.h:96
const Elem * child_ptr(unsigned int i) const
Definition elem.h:3180
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
Definition elem.C:442
static ElemType first_order_equivalent_type(const ElemType et)
Definition elem.C:3099
void set_parent(Elem *p)
Sets the pointer to the element's parent.
Definition elem.h:3063
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition mesh_base.h:170
virtual Elem * insert_elem(Elem *e)=0
Insert elem e to the element array, preserving its id and replacing/deleting any existing element wit...
virtual void delete_node(Node *n)=0
Removes the Node n from the mesh.
virtual dof_id_type max_node_id() const =0
void prepare_for_use()
Definition mesh_base.C:860
static void set_node_processor_ids(MeshBase &mesh)
This function is called after partitioning to set the processor IDs for the nodes.
In parallel meshes where a ghost element has neighbors which do not exist on the local processor,...
Definition remote_elem.h:61
const RemoteElem * remote_elem
Definition remote_elem.C:57

References 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::Elem::inherit_data_from(), 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::BoundaryInfo::regenerate_id_sets(), libMesh::remote_elem, libMesh::Elem::replace_child(), libMesh::DofObject::set_extra_integer(), libMesh::DofObject::set_id(), 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(), and libMesh::DofObject::set_unique_id().

◆ 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 1803 of file mesh_base.C.

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

References libMesh::MeshBase::all_second_order_range().

Referenced by AllSecondOrderTest::allSecondOrder(), libMesh::MeshTools::Generation::build_cube(), build_domain(), libMesh::MeshTetInterface::increase_tet_order(), libMesh::TriangulatorInterface::increase_triangle_order(), main(), ExtraIntegersTest::test_helper(), MeshTetTest::testNetGenQuadraticCurved(), and InfFERadialTest::testRefinement().

◆ all_second_order_range()

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

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 1732 of file unstructured_mesh.C.

1734{
1735 LOG_SCOPE("all_second_order_range()", "Mesh");
1736
1737 /*
1738 * The maximum number of new second order nodes we might be adding,
1739 * for use when picking unique unique_id values later. This variable
1740 * is not used unless unique ids are enabled.
1741 */
1742 unsigned int max_new_nodes_per_elem;
1743
1744 /*
1745 * For speed-up of the \p add_point() method, we
1746 * can reserve memory. Guess the number of additional
1747 * nodes based on the element spatial dimensions and the
1748 * total number of nodes in the mesh as an upper bound.
1749 */
1750 switch (this->mesh_dimension())
1751 {
1752 case 1:
1753 /*
1754 * in 1D, there can only be order-increase from Edge2
1755 * to Edge3. Something like 1/2 of n_nodes() have
1756 * to be added
1757 */
1758 max_new_nodes_per_elem = 3 - 2;
1759 this->reserve_nodes(static_cast<unsigned int>
1760 (1.5*static_cast<double>(this->n_nodes())));
1761 break;
1762
1763 case 2:
1764 /*
1765 * in 2D, either refine from Tri3 to Tri6 (double the nodes)
1766 * or from Quad4 to Quad8 (again, double) or Quad9 (2.25 that much)
1767 */
1768 max_new_nodes_per_elem = 9 - 4;
1769 this->reserve_nodes(static_cast<unsigned int>
1770 (2*static_cast<double>(this->n_nodes())));
1771 break;
1772
1773
1774 case 3:
1775 /*
1776 * in 3D, either refine from Tet4 to Tet10 (factor = 2.5) up to
1777 * Hex8 to Hex27 (something > 3). Since in 3D there _are_ already
1778 * quite some nodes, and since we do not want to overburden the memory by
1779 * a too conservative guess, use the lower bound
1780 */
1781 max_new_nodes_per_elem = 27 - 8;
1782 this->reserve_nodes(static_cast<unsigned int>
1783 (2.5*static_cast<double>(this->n_nodes())));
1784 break;
1785
1786 default:
1787 // Hm?
1788 libmesh_error_msg("Unknown mesh dimension " << this->mesh_dimension());
1789 }
1790
1791 // All the real work is done in the helper function
1792 all_increased_order_range(*this, range, max_new_nodes_per_elem,
1793 [full_ordered](ElemType t) {
1794 return Elem::second_order_equivalent_type(t, full_ordered);
1795 });
1796}
static ElemType second_order_equivalent_type(const ElemType et, const bool full_ordered=true)
Definition elem.C:3168

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

◆ allgather()

void libMesh::DistributedMesh::allgather ( )
overridevirtualinherited

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

Reimplemented from libMesh::MeshBase.

Definition at line 1827 of file distributed_mesh.C.

1828{
1829 if (_is_serial)
1830 return;
1831 MeshCommunication().allgather(*this);
1832 _is_serial = true;
1833 _is_serial_on_proc_0 = true;
1834
1835 // Make sure our caches are up to date and our
1836 // DofObjects are well packed
1837#ifdef DEBUG
1838 libmesh_assert_equal_to (this->n_nodes(), this->parallel_n_nodes());
1839 libmesh_assert_equal_to (this->n_elem(), this->parallel_n_elem());
1840 const dof_id_type pmax_node_id = this->parallel_max_node_id();
1841 const dof_id_type pmax_elem_id = this->parallel_max_elem_id();
1842 libmesh_assert_equal_to (this->max_node_id(), pmax_node_id);
1843 libmesh_assert_equal_to (this->max_elem_id(), pmax_elem_id);
1844
1845 // If we've disabled renumbering we can't be sure we're contiguous
1846 // libmesh_assert_equal_to (this->n_nodes(), this->max_node_id());
1847 // libmesh_assert_equal_to (this->n_elem(), this->max_elem_id());
1848
1849 // Make sure our neighbor links are all fine
1851
1852 // Make sure our ids and flags are consistent
1855#endif
1856}
dof_id_type parallel_max_node_id() const
virtual dof_id_type n_nodes() const override final
void libmesh_assert_valid_parallel_flags() const
Verify refinement_flag and p_refinement_flag consistency of our elements containers.
virtual dof_id_type parallel_n_elem() const override
virtual dof_id_type max_node_id() const override final
virtual dof_id_type parallel_n_nodes() const override
virtual dof_id_type max_elem_id() const override final
dof_id_type parallel_max_elem_id() const
bool _is_serial
A boolean remembering whether we're serialized or not.
virtual dof_id_type n_elem() const override final
virtual void libmesh_assert_valid_parallel_ids() const override
Verify id and processor_id consistency of our elements and nodes containers.
bool _is_serial_on_proc_0
A boolean remembering whether we're serialized to proc 0 or not.
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...

References libMesh::DistributedMesh::_is_serial, libMesh::DistributedMesh::_is_serial_on_proc_0, libMesh::MeshCommunication::allgather(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_flags(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_ids(), libMesh::DistributedMesh::max_elem_id(), libMesh::DistributedMesh::max_node_id(), libMesh::DistributedMesh::n_elem(), libMesh::DistributedMesh::n_nodes(), libMesh::DistributedMesh::parallel_max_elem_id(), libMesh::DistributedMesh::parallel_max_node_id(), libMesh::DistributedMesh::parallel_n_elem(), and libMesh::DistributedMesh::parallel_n_nodes().

◆ allow_detect_interior_parents() [1/2]

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

◆ allow_detect_interior_parents() [2/2]

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

If false is passed then this mesh will no longer work to detect interior parents when being prepared for use.

Definition at line 1369 of file mesh_base.h.

References libMesh::MeshBase::_skip_detect_interior_parents.

Referenced by libMesh::UnstructuredMesh::copy_nodes_and_elements(), libMesh::DistributedMesh::DistributedMesh(), and libMesh::ReplicatedMesh::ReplicatedMesh().

◆ allow_find_neighbors() [1/2]

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

◆ allow_find_neighbors() [2/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 1362 of file mesh_base.h.

1362{ _skip_find_neighbors = !allow; }

References libMesh::MeshBase::_skip_find_neighbors.

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

◆ allow_node_and_elem_unique_id_overlap() [1/2]

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

Definition at line 1388 of file mesh_base.h.

bool _allow_node_and_elem_unique_id_overlap
The Exodus reader (and potentially other readers in the future?) now supports setting Node and Elem u...
Definition mesh_base.h:2301

References libMesh::MeshBase::_allow_node_and_elem_unique_id_overlap.

◆ allow_node_and_elem_unique_id_overlap() [2/2]

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

If true is passed, then this mesh will no longer require unique_ids to be unique across the set of all DofObjects.

That is, although no two Elems (resp. Nodes) will share the same unique_id, a given Elem and Node might share the same unique_id.

Definition at line 1387 of file mesh_base.h.

References libMesh::MeshBase::_allow_node_and_elem_unique_id_overlap.

Referenced by libMesh::MeshTools::libmesh_assert_valid_unique_ids(), and libMesh::ExodusII_IO::read().

◆ allow_remote_element_removal() [1/2]

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

Definition at line 1379 of file mesh_base.h.

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:2288

References libMesh::MeshBase::_allow_remote_element_removal.

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

◆ allow_remote_element_removal() [2/2]

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

◆ allow_renumbering() [1/2]

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

◆ allow_renumbering() [2/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 1355 of file mesh_base.h.

References libMesh::MeshBase::_skip_renumber_nodes_and_elements.

Referenced by AllSecondOrderTest::allSecondOrderMixedFixing(), DisjointNeighborTest::build_four_disjoint_elems(), DisjointNeighborTest::build_two_disjoint_elems(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::DistributedMesh::DistributedMesh(), main(), AllSecondOrderTest::MixedFixingImpl(), libMesh::ErrorVector::plot_error(), libMesh::GMVIO::read(), libMesh::NameBasedIO::read(), libMesh::ReplicatedMesh::ReplicatedMesh(), libMesh::C0Polyhedron::retriangulate(), WriteVecAndScalar::setupTests(), ConstraintOperatorTest::test1DCoarseningNewNodes(), ConstraintOperatorTest::test1DCoarseningOperator(), MeshGenerationTest::testBuildSphere(), CheckpointIOTest::testC0PolygonCheckpoint(), CheckpointIOTest::testC0PolyhedronCheckpoint(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyElementVectorImpl(), MeshInputTest::testCopyNodalSolutionImpl(), ConstraintOperatorTest::testCoreform(), DisjointNeighborTest::testDisjointNeighborConflictError(), MeshGenerationTest::tester(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), ExtraIntegersTest::testExtraIntegersExodusReading(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), EquationSystemsTest::testRefineThenReinitPreserveFlags(), EquationSystemsTest::testRepartitionThenReinit(), BoundaryInfoTest::testShellFaceConstraints(), MeshInputTest::testSingleElementImpl(), DisjointNeighborTest::testStitchCrossMesh(), MeshSmootherTest::testVariationalPrism21MultipleSubdomains(), MeshInputTest::testVTKPreserveElemIds(), MeshInputTest::testVTKPreserveSubdomainIds(), WriteElemsetData::testWriteImpl(), WriteNodesetData::testWriteImpl(), and WriteSidesetData::testWriteImpl().

◆ assign()

MeshBase & libMesh::DistributedMesh::assign ( MeshBase &&  other_mesh)
overridevirtualinherited

Shim to call the move assignment operator for this class.

Implements libMesh::UnstructuredMesh.

Definition at line 91 of file distributed_mesh.C.

92{
93 *this = std::move(cast_ref<DistributedMesh&>(other_mesh));
94
95 return *this;
96}

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

◆ cache_elem_data()

void libMesh::MeshBase::cache_elem_data ( )
inherited

Definition at line 1985 of file mesh_base.C.

1986{
1987 // This requires an inspection on every processor
1988 parallel_object_only();
1989
1990 // Need to clear containers first in case all elements of a
1991 // particular dimension/order/subdomain have been deleted.
1992 _elem_dims.clear();
1993 _elem_default_orders.clear();
1994 _mesh_subdomains.clear();
1996
1997 for (const auto & elem : this->active_element_ptr_range())
1998 {
1999 _elem_dims.insert(cast_int<unsigned char>(elem->dim()));
2000 _elem_default_orders.insert(elem->default_order());
2001 _mesh_subdomains.insert(elem->subdomain_id());
2003 static_cast<Order>
2004 (std::min(static_cast<int>(_supported_nodal_order),
2005 static_cast<int>(elem->supported_nodal_order())));
2006 }
2007
2008 if (!this->is_serial())
2009 {
2010 // Some different dimension/order/subdomain elements may only live
2011 // on other processors
2012 this->comm().set_union(_elem_dims);
2016 }
2017
2018 // If the largest element dimension found is larger than the current
2019 // _spatial_dimension, increase _spatial_dimension.
2020 unsigned int max_dim = this->mesh_dimension();
2021 if (max_dim > _spatial_dimension)
2022 _spatial_dimension = cast_int<unsigned char>(max_dim);
2023
2024 // _spatial_dimension may need to increase from 1->2 or 2->3 if the
2025 // mesh is full of 1D elements but they are not x-aligned, or the
2026 // mesh is full of 2D elements but they are not in the x-y plane.
2027 // If the mesh is x-aligned or x-y planar, we will end up checking
2028 // every node's coordinates and not breaking out of the loop
2029 // early...
2030 if (_spatial_dimension < LIBMESH_DIM)
2031 {
2032 for (const auto & node : this->node_ptr_range())
2033 {
2034 // Note: the exact floating point comparison is intentional,
2035 // we don't want to get tripped up by tolerances.
2036 if ((*node)(0) != 0. && _spatial_dimension < 1)
2038
2039 if ((*node)(1) != 0. && _spatial_dimension < 2)
2040 {
2042#if LIBMESH_DIM == 2
2043 // If libmesh is compiled in 2D mode, this is the
2044 // largest spatial dimension possible so we can break
2045 // out.
2046 break;
2047#endif
2048 }
2049
2050#if LIBMESH_DIM > 2
2051 if ((*node)(2) != 0.)
2052 {
2053 // Spatial dimension can't get any higher than this, so
2054 // we can break out.
2056 break;
2057 }
2058#endif
2059 }
2060 }
2061
2063}
void min(const T &r, T &o, Request &req) const
void set_union(T &data, const unsigned int root_id) const
virtual bool is_serial() const
Definition mesh_base.h:357
Order _supported_nodal_order
We cache the maximum nodal order supported by all the mesh's elements (the minimum supported_nodal_or...
Definition mesh_base.h:2328
unsigned char _spatial_dimension
The "spatial dimension" of the Mesh.
Definition mesh_base.h:2365
std::set< subdomain_id_type > _mesh_subdomains
We cache the subdomain ids of the elements present in the mesh.
Definition mesh_base.h:2333
std::set< Order > _elem_default_orders
We cache the (default) order of the geometric elements present in the mesh.
Definition mesh_base.h:2322
std::set< unsigned char > _elem_dims
We cache the dimension of the elements present in the mesh.
Definition mesh_base.h:2315
Preparation _preparation
Flags indicating in what ways this mesh has been prepared.
Definition mesh_base.h:2195
const Parallel::Communicator & comm() const

References libMesh::MeshBase::_elem_default_orders, libMesh::MeshBase::_elem_dims, libMesh::MeshBase::_mesh_subdomains, libMesh::MeshBase::_preparation, libMesh::MeshBase::_spatial_dimension, libMesh::MeshBase::_supported_nodal_order, libMesh::ParallelObject::comm(), libMesh::MeshBase::Preparation::has_cached_elem_data, libMesh::MeshBase::is_serial(), libMesh::MAXIMUM, libMesh::MeshBase::mesh_dimension(), libMesh::Parallel::Communicator::min(), and libMesh::Parallel::Communicator::set_union().

Referenced by ExodusC0PolyhedronTest::build_c0polyhedron(), libMesh::MeshBase::cache_elem_dims(), libMesh::MeshBase::complete_preparation(), main(), libMesh::MeshBase::set_elem_dimensions(), ExodusC0PolyhedronTest::test_write_cube_header(), MeshSmootherTest::testVariationalSmoother(), and libMesh::NetGenMeshInterface::triangulate().

◆ cache_elem_dims()

void libMesh::MeshBase::cache_elem_dims ( )
inherited
Deprecated:
This method has ben replaced by cache_elem_data which caches data in addition to elem dimensions (e.g. 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 1977 of file mesh_base.C.

1978{
1979 libmesh_deprecated();
1980
1981 this->cache_elem_data();
1982}

References libMesh::MeshBase::cache_elem_data().

◆ 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 512 of file mesh_base.C.

513{
514 // Look up elemset ids for old_code
515 auto it = _elemset_codes.find(old_code);
516
517 // If we don't have the old_code, then do nothing. Alternatively, we
518 // could throw an error since trying to change an elemset code you
519 // don't have could indicate there's a problem...
520 if (it == _elemset_codes.end())
521 return;
522
523 // Make copy of the set of elemset ids. We are not changing these,
524 // only updating the elemset code it corresponds to.
525 elemset_type id_set_copy = *(it->second);
526
527 // Look up the corresponding entry in the inverse map. Note: we want
528 // the iterator because we are going to remove it.
529 auto inverse_it = _elemset_codes_inverse_map.find(id_set_copy);
530 libmesh_error_msg_if(inverse_it == _elemset_codes_inverse_map.end(),
531 "Expected _elemset_codes_inverse_map entry for elemset code " << old_code);
532
533 // Erase entry from inverse map
534 _elemset_codes_inverse_map.erase(inverse_it);
535
536 // Erase entry from forward map
537 _elemset_codes.erase(it);
538
539 // Add new code with original set of ids.
540 this->add_elemset_code(new_code, id_set_copy);
541
542 // We can't update any actual elemset codes if there is no extra integer defined for it.
543 if (!this->has_elem_integer("elemset_code"))
544 return;
545
546 // Get index of elemset_code extra integer
547 unsigned int elemset_index = this->get_elem_integer_index("elemset_code");
548
549 // Loop over all elems and update code
551 (this->element_stored_range(),
552 [elemset_index, old_code, new_code](const ElemRange & range)
553 {
554 for (Elem * elem : range)
555 {
556 dof_id_type elemset_code =
557 elem->get_extra_integer(elemset_index);
558
559 if (elemset_code == old_code)
560 elem->set_extra_integer(elemset_index, new_code);
561 }
562 });
563}
unsigned int get_elem_integer_index(std::string_view name) const
Definition mesh_base.C:689
const ElemRange & element_stored_range()
Definition mesh_base.C:1939
bool has_elem_integer(std::string_view name) const
Definition mesh_base.C:701
const DofMap &dof_map LIBMESH_COMMA unsigned int Elem * ElemRange
Definition mesh_base.h:1894
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:456
std::set< elemset_id_type > elemset_type
Typedef for the "set" container used to store elemset ids.
Definition mesh_base.h:466
void parallel_for(const Range &range, const Body &body, unsigned int n_threads=libMesh::n_threads())
Execute the provided function object in parallel on the specified range.

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

◆ 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 565 of file mesh_base.C.

566{
567 // Early return if we don't have old_id
568 if (!_all_elemset_ids.count(old_id))
569 return;
570
571 // Throw an error if the new_id is already used
572 libmesh_error_msg_if(_all_elemset_ids.count(new_id),
573 "Cannot change elemset id " << old_id <<
574 " to " << new_id << ", " << new_id << " already exists.");
575
576 // We will build up a new version of the inverse map so we can iterate over
577 // the current one without invalidating anything.
578 std::map<MeshBase::elemset_type, dof_id_type> new_elemset_codes_inverse_map;
579 for (const auto & [id_set, elemset_code] : _elemset_codes_inverse_map)
580 {
581 auto id_set_copy = id_set;
582 if (id_set_copy.count(old_id))
583 {
584 // Remove old_id, insert new_id
585 id_set_copy.erase(old_id);
586 id_set_copy.insert(new_id);
587 }
588
589 // Store in new version of map
590 new_elemset_codes_inverse_map.emplace(id_set_copy, elemset_code);
591 }
592
593 // Swap existing map with newly-built one
594 _elemset_codes_inverse_map.swap(new_elemset_codes_inverse_map);
595
596 // Reconstruct _elemset_codes map
597 _elemset_codes.clear();
598 for (const auto & [id_set, elemset_code] : _elemset_codes_inverse_map)
599 _elemset_codes.emplace(elemset_code, &id_set);
600
601 // Update _all_elemset_ids
602 _all_elemset_ids.erase(old_id);
603 _all_elemset_ids.insert(new_id);
604}

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

◆ clear()

void libMesh::DistributedMesh::clear ( )
overridevirtualinherited

Clear all internal data.

Reimplemented from libMesh::MeshBase.

Definition at line 997 of file distributed_mesh.C.

998{
999 // Call parent clear function
1001
1002 // Clear our elements and nodes
1003 // There is no need to remove them from
1004 // the BoundaryInfo data structure since we
1005 // already cleared it.
1007
1008 for (auto & node : _nodes)
1009 delete node;
1010
1011 _nodes.clear();
1012
1013 // We're no longer distributed if we were before
1014 _is_serial = true;
1015 _is_serial_on_proc_0 = true;
1016
1017 // We deleted a ton of coarse elements, but their nodes got deleted too so
1018 // all is copacetic.
1020
1021 // Correct our caches
1022 _n_nodes = 0;
1023 _max_node_id = 0;
1026}
virtual void clear_elems() override
Clear internal Elem data.
bool _deleted_coarse_elements
A boolean remembering whether we've recently deleted top-level elements or not.
virtual void clear() override
Free all new memory associated with the object, but restore its original state, with the mesh pointer...
Definition dof_map.C:871
virtual void clear()
Deletes all the element and node data that is currently stored.
Definition mesh_base.C:1036

References libMesh::DistributedMesh::_deleted_coarse_elements, libMesh::DistributedMesh::_is_serial, libMesh::DistributedMesh::_is_serial_on_proc_0, libMesh::DistributedMesh::_max_node_id, libMesh::DistributedMesh::_n_nodes, libMesh::DistributedMesh::_next_free_local_node_id, libMesh::DistributedMesh::_next_free_unpartitioned_node_id, libMesh::DistributedMesh::_nodes, libMesh::MeshBase::clear(), libMesh::DofMap::clear(), libMesh::DistributedMesh::clear_elems(), libMesh::ParallelObject::n_processors(), and libMesh::ParallelObject::processor_id().

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

◆ clear_elems()

void libMesh::DistributedMesh::clear_elems ( )
overridevirtualinherited

◆ clear_extra_ghost_elems() [1/2]

virtual void libMesh::DistributedMesh::clear_extra_ghost_elems ( )
inlinevirtualinherited

Clears extra ghost elements.

Definition at line 257 of file distributed_mesh.h.

257{ _extra_ghost_elems.clear(); }

References libMesh::DistributedMesh::_extra_ghost_elems.

◆ clear_extra_ghost_elems() [2/2]

void libMesh::DistributedMesh::clear_extra_ghost_elems ( const std::set< Elem * > &  extra_ghost_elems)
virtualinherited

Clears specified extra ghost elements.

Definition at line 1818 of file distributed_mesh.C.

1819{
1820 std::set<Elem *> tmp;
1821 std::set_difference(_extra_ghost_elems.begin(), _extra_ghost_elems.end(),
1822 extra_ghost_elems.begin(), extra_ghost_elems.end(),
1823 std::inserter(tmp, tmp.begin()));
1824 _extra_ghost_elems = tmp;
1825}
const std::set< Elem * > & extra_ghost_elems() const
Const accessor to the ghosted elements.

References libMesh::DistributedMesh::_extra_ghost_elems, and libMesh::DistributedMesh::extra_ghost_elems().

◆ clear_point_locator()

void libMesh::MeshBase::clear_point_locator ( )
inherited

◆ clear_stored_ranges()

void libMesh::MeshBase::clear_stored_ranges ( )
inherited

◆ clone()

virtual std::unique_ptr< MeshBase > libMesh::DistributedMesh::clone ( ) const
inlineoverridevirtualinherited

Virtual copy-constructor, creates a copy of this mesh.

Implements libMesh::MeshBase.

Reimplemented in libMesh::ParallelMesh.

Definition at line 119 of file distributed_mesh.h.

120 {
121 auto returnval = std::make_unique<DistributedMesh>(*this);
122#ifdef DEBUG
123 libmesh_assert(*returnval == *this);
124#endif
125 return returnval;
126 }

References libMesh::libmesh_assert().

◆ 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.

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

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::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::Partitioner::_find_global_index_by_pid_map(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult_add(), 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::RBEIMEvaluation::add_interpolation_data(), libMesh::CondensedEigenSystem::add_matrices(), libMesh::EigenSystem::add_matrices(), libMesh::System::add_matrix(), libMesh::System::add_matrix(), libMesh::System::add_matrix(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::System::add_vector(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::AdvectionSystem::assemble_claw_rhs(), 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::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::PetscDMWrapper::build_section(), libMesh::PetscDMWrapper::build_sf(), libMesh::MeshBase::cache_elem_data(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::MeshTetInterface::check_hull_integrity(), libMesh::MeshBase::complete_preparation(), 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::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), PetscSolverConfiguration::configure_solver(), 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::CondensedEigenSystem::copy_super_to_sub(), 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< T >::create_submatrix_nosort(), create_wrapped_function(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::MeshBase::detect_interior_parents(), libMesh::RBEIMEvaluation::distribute_bfs(), 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::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::SmoothnessEstimator::estimate_smoothness(), 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::RBEIMEvaluation::get_interior_basis_functions_as_vecs(), 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(), libMesh::RBEIMConstruction::get_random_point(), libMesh::RBEIMConstruction::get_random_point(), libMesh::MeshTetInterface::improve_hull_integrity(), AssembleOptimization::inequality_constraints(), AssembleOptimization::inequality_constraints_jacobian(), libMesh::StaticCondensation::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::LocationMap< T >::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), ElasticitySystem::init_data(), libMesh::AdvectionSystem::init_data(), libMesh::ClawSystem::init_data(), libMesh::PetscDMWrapper::init_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::Modification::interpolate_surface(), 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_constraint_rows(), 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_snes_mffd_interface(), libMesh::libmesh_petsc_snes_postcheck(), 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::MeshCommunication::make_elems_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::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::MeshTools::n_connected_components(), libMesh::DofMap::n_constrained_dofs(), libMesh::MeshBase::n_constraint_rows(), libMesh::DofMap::n_dofs(), libMesh::DofMap::n_dofs_per_processor(), 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::PetscVector< T >::operator=(), libMesh::MeshBase::operator==(), libMesh::DistributedMesh::parallel_max_elem_id(), libMesh::DistributedMesh::parallel_max_node_id(), libMesh::DistributedMesh::parallel_max_unique_id(), libMesh::ReplicatedMesh::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(), LaplaceSystem::postprocess(), PoissonSystem::postprocess(), libMesh::MeshBase::print_constraint_rows(), libMesh::DofMap::print_dof_constraints(), libMesh::DofMap::process_mesh_constraint_rows(), libMesh::Partitioner::processor_pairs_to_interface_nodes(), libMesh::InterMeshProjection::project_system_vectors(), libMesh::XdrIO::read(), libMesh::Nemesis_IO::read(), FEMParameters::read(), libMesh::EquationSystems::read(), libMesh::CheckpointIO::read_header(), libMesh::ExodusII_IO::read_header(), libMesh::System::read_header(), libMesh::XdrIO::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::RBConstruction::read_riesz_representors_from_files(), libMesh::TransientRBConstruction::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(), MeshFunctionTest::read_variable_info_from_output_data(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::SimplexRefiner::refine_via_edges(), libMesh::StaticCondensationDofMap::reinit(), libMesh::BoundaryInfo::remove_edge_id(), libMesh::BoundaryInfo::remove_node_id(), libMesh::BoundaryInfo::remove_shellface_id(), libMesh::BoundaryInfo::remove_side_id(), 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::VariationalMeshSmoother::smooth(), libMesh::NoxNonlinearSolver< Number >::solve(), libMesh::ClawSystem::solve_conservation_law(), libMesh::split_mesh(), libMesh::RBEIMConstruction::store_eim_solutions_for_training_set(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::MeshBase::sync_subdomain_name_map(), ConstraintOperatorTest::test1DCoarseningNewNodes(), ConstraintOperatorTest::test1DCoarseningOperator(), MeshFunctionTest::test_bad_gradient_var_with_out_of_mesh_value(), MeshFunctionTest::test_bad_hessian_var_with_out_of_mesh_value(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), ExodusC0PolyhedronTest::test_write_and_read_hexagonal_prism(), ExodusC0PolygonTest::test_write_and_read_pentagon(), DofMapTest::testBadElemFECombo(), SystemsTest::testBlockRestrictedVarNDofs(), BoundaryInfoTest::testBoundaryOnChildrenErrors(), CheckpointIOTest::testC0PolygonCheckpoint(), VolumeTest::testC0PolygonMethods(), CheckpointIOTest::testC0PolyhedronCheckpoint(), VolumeTest::testC0PolyhedronMethods(), ConstraintOperatorTest::testCoreform(), ConnectedComponentsTest::testEdge(), MeshInputTest::testExodusIGASidesets(), MeshTriangulationTest::testFoundCenters(), PointLocatorTest::testLocator(), BoundaryInfoTest::testMesh(), BoundaryMeshSubdomainTest::testPerBoundarySubdomain(), PointLocatorTest::testPlanar(), MeshTriangulationTest::testPoly2TriEdge3ToTri7CenterFixup(), MeshTriangulationTest::testPoly2TriRefinementBase(), SystemsTest::testProjectCubeWithMeshFunction(), SystemsTest::testProjectScalarCoarsening(), BoundaryInfoTest::testRenumber(), BoundaryInfoTest::testSelectiveRenumber(), BoundaryMeshSubdomainTest::testSingleSubdomain(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), MeshTriangulationTest::testTriangulatorInterp(), MeshTriangulationTest::testTriangulatorMeshedHoles(), MeshTriangulationTest::testTriangulatorRoundHole(), MeshSmootherTest::testVariationalSmoother(), libMesh::MeshTools::total_weight(), libMesh::RBConstruction::train_reduced_basis_with_POD(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::Poly2TriTriangulator::triangulate(), libMesh::RBConstruction::truth_assembly(), libMesh::TransientRBConstruction::truth_assembly(), update_current_local_solution(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::MeshTools::volume(), libMesh::STLIO::write(), libMesh::XdrIO::write(), libMesh::NameBasedIO::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::RBConstruction::write_riesz_representors_to_files(), libMesh::TransientRBConstruction::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().

◆ complete_preparation()

void libMesh::MeshBase::complete_preparation ( )
inherited

Definition at line 874 of file mesh_base.C.

875{
876 LOG_SCOPE("complete_preparation()", "MeshBase");
877
878 parallel_object_only();
879
880 libmesh_assert(this->comm().verify(this->is_serial()));
881
882 // If we don't go into this method with valid constraint rows, we're
883 // only going to be able to make that worse.
884#ifdef DEBUG
886#endif
887
888 // A distributed mesh may have processors with no elements (or
889 // processors with no elements of higher dimension, if we ever
890 // support mixed-dimension meshes), but we want consistent
891 // mesh_dimension anyways.
892 //
893 // cache_elem_data() should get the elem_dimensions() and
894 // mesh_dimension() correct later, and we don't need it earlier.
895
896
897 // Renumber the nodes and elements so that they in contiguous
898 // blocks. By default, _skip_renumber_nodes_and_elements is false.
899 //
900 // Instances where you if prepare_for_use() should not renumber the nodes
901 // and elements include reading in e.g. an xda/r or gmv file. In
902 // this case, the ordering of the nodes may depend on an accompanying
903 // solution, and the node ordering cannot be changed.
904
905
906 // Mesh modification operations might not leave us with consistent
907 // id counts, or might leave us with orphaned nodes we're no longer
908 // using, but our partitioner might need that consistency and/or
909 // might be confused by orphaned nodes.
911 {
915 }
916 else
917 {
919 this->remove_orphaned_nodes();
922 }
923
924 // Let all the elements find their neighbors
926 this->find_neighbors();
927
928 // The user may have set boundary conditions. We require that the
929 // boundary conditions were set consistently. Because we examine
930 // neighbors when evaluating non-raw boundary condition IDs, this
931 // assert is only valid when our neighbor links are in place.
932#ifdef DEBUG
934#endif
935
936 // Search the mesh for all the dimensions of the elements
937 // and cache them.
939 this->cache_elem_data();
940
941 // libMesh expects every processor to know about every subdomain
942 // name, but distributed mesh generators may only have set names for
943 // the part of the mesh they know about, so make sure the map is
944 // consistent everywhere.
947
948 // Search the mesh for elements that have a neighboring element
949 // of dim+1 and set that element as the interior parent
951 {
954 else
955 {
956 // We must set the flag that says "interior parent pointers have been set up"
957 // even though we skip detect_interior_parents().
959 }
960 }
961
962 // Fix up node unique ids in case mesh generation code didn't take
963 // exceptional care to do so.
964 // MeshCommunication().make_node_unique_ids_parallel_consistent(*this);
965
966 // We're going to still require that mesh generation code gets
967 // element unique ids consistent.
968#if defined(DEBUG) && defined(LIBMESH_ENABLE_UNIQUE_ID)
970#endif
971
972 // Allow our GhostingFunctor objects to reinit if necessary.
973 // Do this before partitioning and redistributing, and before
974 // deleting remote elements.
977
978 // Partition the mesh unless *all* partitioning is to be skipped.
979 // If only noncritical partitioning is to be skipped, the
980 // partition() call will still check for orphaned nodes.
982 this->partition();
983 else if (!this->n_unpartitioned_elem() &&
984 !this->n_unpartitioned_nodes())
986
987 // If we're using DistributedMesh, we'll probably want it
988 // parallelized.
992 else
994
995 // Much of our boundary info may have been for now-remote parts of the mesh,
996 // in which case we don't want to keep local copies of data meant to be
997 // local. On the other hand we may have deleted, or the user may have added in
998 // a distributed fashion, boundary data that is meant to be global. So we
999 // handle both of those scenarios here
1002
1005
1006 // The mesh is now prepared for use, with the possible exception of
1007 // partitioning that was supposed to be skipped, and it should know
1008 // it.
1009#ifndef NDEBUG
1010 Preparation completed_preparation = _preparation;
1011 if (skip_partitioning())
1012 completed_preparation.is_partitioned = true;
1013 libmesh_assert(completed_preparation);
1014#endif
1015
1016#ifdef DEBUG
1018#ifdef LIBMESH_ENABLE_UNIQUE_ID
1020#endif
1021#endif
1022}
bool skip_partitioning() const
Definition mesh_base.h:1431
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...
dof_id_type n_unpartitioned_elem() const
Definition mesh_base.h:703
void remove_orphaned_nodes()
Removes any orphaned nodes, nodes not connected to any elements.
Definition mesh_base.C:801
dof_id_type n_unpartitioned_nodes() const
Definition mesh_base.h:597
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:399
void sync_subdomain_name_map()
libMesh often expects all processors to know about names of all subdomain ids, but distributed mesh g...
Definition mesh_base.C:2066
virtual void update_parallel_id_counts()=0
Updates parallel caches so that methods like n_elem() accurately reflect changes on other processors.
void reinit_ghosting_functors()
Loops over ghosting functors and calls mesh_reinit()
Definition mesh_base.C:1025
virtual void find_neighbors(const bool reset_remote_elements=false, const bool reset_current_list=true, const bool assert_valid=true)=0
Locate element face (edge in 2D) neighbors.
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:2077
void libmesh_assert_valid_unique_ids(const MeshBase &mesh)
A function for verifying that unique ids match across processors.
void libmesh_assert_valid_boundary_ids(const MeshBase &mesh)
A function for verifying that boundary condition ids match across processors.
void libmesh_assert_valid_constraint_rows(const MeshBase &mesh)
A function for verifying that all mesh constraint rows express relations between nodes and elements t...

References libMesh::MeshBase::_allow_remote_element_removal, libMesh::MeshBase::_preparation, libMesh::MeshBase::_skip_detect_interior_parents, libMesh::MeshBase::_skip_find_neighbors, libMesh::MeshBase::_skip_renumber_nodes_and_elements, libMesh::MeshBase::cache_elem_data(), libMesh::ParallelObject::comm(), libMesh::MeshBase::delete_remote_elements(), libMesh::MeshBase::detect_interior_parents(), libMesh::MeshBase::find_neighbors(), libMesh::MeshBase::get_boundary_info(), libMesh::MeshBase::Preparation::has_boundary_id_sets, libMesh::MeshBase::Preparation::has_cached_elem_data, libMesh::MeshBase::Preparation::has_interior_parent_ptrs, libMesh::MeshBase::Preparation::has_neighbor_ptrs, libMesh::MeshBase::Preparation::has_reinit_ghosting_functors, libMesh::MeshBase::Preparation::has_removed_orphaned_nodes, libMesh::MeshBase::Preparation::has_removed_remote_elements, libMesh::MeshBase::Preparation::has_synched_id_counts, libMesh::MeshBase::Preparation::has_synched_subdomain_name_map, libMesh::MeshBase::Preparation::is_partitioned, libMesh::MeshBase::is_serial(), libMesh::libmesh_assert(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_constraint_rows(), libMesh::MeshTools::libmesh_assert_valid_unique_ids(), libMesh::MeshBase::n_unpartitioned_elem(), libMesh::MeshBase::n_unpartitioned_nodes(), 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(), libMesh::MeshBase::sync_subdomain_name_map(), and libMesh::MeshBase::update_parallel_id_counts().

Referenced by main(), libMesh::MeshBase::prepare_for_use(), BoundaryMeshSubdomainTest::testDefaultSubdomain(), MeshBaseTest::testMeshBaseVerifyHasCachedElemData(), MeshBaseTest::testMeshBaseVerifyHasNeighborPtrs(), MeshBaseTest::testMeshBaseVerifyRemovalPreparation(), BoundaryMeshSubdomainTest::testPerBoundarySubdomain(), and BoundaryMeshSubdomainTest::testSingleSubdomain().

◆ contract()

bool libMesh::UnstructuredMesh::contract ( )
overridevirtualinherited

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 1535 of file unstructured_mesh.C.

1536{
1537 LOG_SCOPE ("contract()", "Mesh");
1538
1539 // Flag indicating if this call actually changes the mesh
1540 bool mesh_changed = false;
1541
1542#ifdef DEBUG
1543 for (const auto & elem : this->element_ptr_range())
1544 libmesh_assert(elem->active() || elem->subactive() || elem->ancestor());
1545#endif
1546
1547 // Loop over the elements.
1548 for (auto & elem : this->element_ptr_range())
1549 {
1550 // Delete all the subactive ones
1551 if (elem->subactive())
1552 {
1553 // No level-0 element should be subactive.
1554 // Note that we CAN'T test elem->level(), as that
1555 // touches elem->parent()->dim(), and elem->parent()
1556 // might have already been deleted!
1557 libmesh_assert(elem->parent());
1558
1559 // Delete the element
1560 // This just sets a pointer to nullptr, and doesn't
1561 // invalidate any iterators
1562 this->delete_elem(elem);
1563
1564 // the mesh has certainly changed
1565 mesh_changed = true;
1566 }
1567 else
1568 {
1569 // Compress all the active ones
1570 if (elem->active())
1571 elem->contract();
1572 else
1573 libmesh_assert (elem->ancestor());
1574 }
1575 }
1576
1577 // Strip any newly-created nullptr voids out of the element array
1579
1580 // FIXME: Need to understand why deleting subactive children
1581 // invalidates the point locator. For now we will clear it explicitly
1582 this->clear_point_locator();
1583
1584 // Allow our GhostingFunctor objects to reinit if necessary.
1585 for (auto & gf : as_range(this->ghosting_functors_begin(),
1586 this->ghosting_functors_end()))
1587 {
1588 libmesh_assert(gf);
1589 gf->mesh_reinit();
1590 }
1591
1592 return mesh_changed;
1593}
virtual void delete_elem(Elem *e)=0
Removes element e from the mesh.
GhostingFunctorIterator ghosting_functors_begin() const
Beginning of range of ghosting functors.
Definition mesh_base.h:1472
GhostingFunctorIterator ghosting_functors_end() const
End of range of ghosting functors.
Definition mesh_base.h:1478
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
Helper function that allows us to treat a homogenous pair as a range.

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().

◆ copy_cached_data()

void libMesh::MeshBase::copy_cached_data ( const MeshBase other_mesh)
protectedinherited

Helper class to copy cached data, to synchronize with a possibly unprepared other_mesh.

Definition at line 2431 of file mesh_base.C.

2432{
2433 this->_spatial_dimension = other_mesh._spatial_dimension;
2434 this->_elem_dims = other_mesh._elem_dims;
2435 this->_elem_default_orders = other_mesh._elem_default_orders;
2436 this->_supported_nodal_order = other_mesh._supported_nodal_order;
2437 this->_mesh_subdomains = other_mesh._mesh_subdomains;
2438}

References libMesh::MeshBase::_elem_default_orders, libMesh::MeshBase::_elem_dims, libMesh::MeshBase::_mesh_subdomains, libMesh::MeshBase::_spatial_dimension, and libMesh::MeshBase::_supported_nodal_order.

◆ 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 2490 of file mesh_base.C.

2491{
2492 LOG_SCOPE("copy_constraint_rows(mesh)", "MeshBase");
2493
2494 _constraint_rows.clear();
2495
2496 const auto & other_constraint_rows = other_mesh.get_constraint_rows();
2497 for (const auto & [other_node, other_node_constraints] : other_constraint_rows)
2498 {
2499 const Node * const our_node = this->node_ptr(other_node->id());
2500 constraint_rows_mapped_type our_node_constraints;
2501 for (const auto & [other_inner_key_pair, constraint_value] : other_node_constraints)
2502 {
2503 const auto & [other_elem, local_node_id] = other_inner_key_pair;
2504 const Elem * const our_elem = this->elem_ptr(other_elem->id());
2505 our_node_constraints.emplace_back(std::make_pair(our_elem, local_node_id), constraint_value);
2506 }
2507 _constraint_rows[our_node] = std::move(our_node_constraints);
2508 }
2509}
virtual const Node * node_ptr(const dof_id_type i) const =0
std::vector< std::pair< std::pair< const Elem *, unsigned int >, Real > > constraint_rows_mapped_type
Definition mesh_base.h:1929
virtual const Elem * elem_ptr(const dof_id_type i) const =0
constraint_rows_type _constraint_rows
Definition mesh_base.h:2442

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

Referenced by libMesh::DistributedMesh::DistributedMesh(), main(), libMesh::ReplicatedMesh::ReplicatedMesh(), ConstraintOperatorTest::test1DCoarseningNewNodes(), ConstraintOperatorTest::test1DCoarseningOperator(), ConstraintOperatorTest::testCoreform(), and ConnectedComponentsTest::testEdge().

◆ copy_constraint_rows() [2/2]

template<typename T >
void libMesh::MeshBase::copy_constraint_rows ( const SparseMatrix< T > &  constraint_operator,
bool  precondition_constraint_operator = false 
)
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.

If precondition_constraint_operator is true, then the values of those new unconstrained degrees of freedom may be scaled to improve the conditioning of typical PDE matrices integrated on constrained mesh elements.

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 2514 of file mesh_base.C.

2516{
2517 LOG_SCOPE("copy_constraint_rows(mat)", "MeshBase");
2518
2519 this->_constraint_rows.clear();
2520
2521 // We're not going to support doing this distributed yet; it'd be
2522 // pointless unless we temporarily had a linear partitioning to
2523 // better match the constraint operator.
2524 MeshSerializer serialize(*this);
2525
2526 // Our current mesh should already reflect the desired assembly space
2527 libmesh_error_msg_if(this->n_nodes() != constraint_operator.m(),
2528 "Constraint operator matrix with " <<
2529 constraint_operator.m() <<
2530 "rows does not match this mesh with " <<
2531 this->n_nodes() << " nodes");
2532
2533 // First, find what new unconstrained DoFs we need to add. We can't
2534 // iterate over columns in a SparseMatrix, so we'll iterate over
2535 // rows and keep track of columns.
2536
2537 // If we have nodes that will work unconstrained, keep track of
2538 // their node ids and corresponding column indices.
2539 // existing_unconstrained_nodes[column_id] = node_id
2540 std::map<dof_id_type, dof_id_type> existing_unconstrained_columns;
2541 std::set<dof_id_type> existing_unconstrained_nodes;
2542
2543 // In case we need new nodes, keep track of their columns.
2544 // columns[j][k] will be the kth row index and value of column j
2545 typedef
2546 std::unordered_map<dof_id_type,
2547 std::vector<std::pair<dof_id_type, Real>>>
2548 columns_type;
2549 columns_type columns(constraint_operator.n());
2550
2551 // If we need to precondition the constraint operator (e.g. it's an
2552 // unpreconditioned extraction operator for a Flex IGA matrix),
2553 // we'll want to keep track of the sum of each column, because we'll
2554 // be dividing each column by that sum (Jacobi preconditioning on
2555 // the right, which then leads to symmetric preconditioning on a
2556 // physics Jacobian).
2557 std::unordered_map<dof_id_type, Real> column_sums;
2558
2559 // Work in parallel, though we'll have to sync shortly
2560 for (auto i : make_range(constraint_operator.row_start(),
2561 constraint_operator.row_stop()))
2562 {
2563 std::vector<numeric_index_type> indices;
2564 std::vector<T> values;
2565
2566 constraint_operator.get_row(i, indices, values);
2567 libmesh_assert_equal_to(indices.size(), values.size());
2568
2569 if (indices.size() == 1 &&
2570 values[0] == T(1))
2571 {
2572 // If we have multiple simple Ui=Uj constraints, let the
2573 // first one be our "unconstrained" node and let the others
2574 // be constrained to it.
2575 if (existing_unconstrained_columns.find(indices[0]) !=
2576 existing_unconstrained_columns.end())
2577 {
2578 const auto j = indices[0];
2579 columns[j].emplace_back(i, 1);
2580 }
2581 else
2582 {
2583 existing_unconstrained_nodes.insert(i);
2584 existing_unconstrained_columns.emplace(indices[0],i);
2585 }
2586 }
2587 else
2588 for (auto jj : index_range(indices))
2589 {
2590 const auto j = indices[jj];
2591 const Real coef = libmesh_real(values[jj]);
2592 libmesh_assert_equal_to(coef, values[jj]);
2593 columns[j].emplace_back(i, coef);
2594 }
2595 }
2596
2597 // Merge data from different processors' slabs of the matrix
2598 this->comm().set_union(existing_unconstrained_nodes);
2599 this->comm().set_union(existing_unconstrained_columns);
2600
2601 std::vector<columns_type> all_columns;
2602 this->comm().allgather(columns, all_columns);
2603
2604 columns.clear();
2605 for (auto p : index_range(all_columns))
2606 for (auto & [j, subcol] : all_columns[p])
2607 for (auto [i, v] : subcol)
2608 columns[j].emplace_back(i,v);
2609
2610 // Keep track of elements on which unconstrained nodes exist, and
2611 // their local node indices.
2612 // node_to_elem_ptrs[node] = [elem_id, local_node_num]
2613 std::unordered_map<const Node *, std::pair<dof_id_type, unsigned int>> node_to_elem_ptrs;
2614
2615 // Find elements attached to any existing nodes that will stay
2616 // unconstrained. We'll also build a subdomain set here so we don't
2617 // have to assert that the mesh is already prepared before we pick a
2618 // new subdomain for any NodeElems we need to add.
2619 std::set<subdomain_id_type> subdomain_ids;
2620 for (const Elem * elem : this->element_ptr_range())
2621 {
2622 subdomain_ids.insert(elem->subdomain_id());
2623 for (auto n : make_range(elem->n_nodes()))
2624 {
2625 const Node * node = elem->node_ptr(n);
2626 if (existing_unconstrained_nodes.count(node->id()))
2627 node_to_elem_ptrs.emplace(node, std::make_pair(elem->id(), n));
2628 }
2629 }
2630
2631 const subdomain_id_type new_sbd_id = *subdomain_ids.rbegin() + 1;
2632
2633 for (auto j : make_range(constraint_operator.n()))
2634 {
2635 // If we already have a good node for this then we're done
2636 if (existing_unconstrained_columns.count(j))
2637 continue;
2638
2639 // Get a half-decent spot to place a new NodeElem for
2640 // unconstrained DoF(s) here. Getting a *fully*-decent spot
2641 // would require finding a Moore-Penrose pseudoinverse, and I'm
2642 // not going to do that, but scaling a transpose will at least
2643 // get us a little uniqueness to make visualization reasonable.
2644 Point newpt;
2645 Real total_scaling = 0;
2646 unsigned int total_entries = 0;
2647
2648 // We'll get a decent initial pid choice here too, if only to
2649 // aid in later repartitioning.
2650 std::map<processor_id_type, int> pids;
2651
2652 auto & column = columns[j];
2653 for (auto [i, r] : column)
2654 {
2655 Node & constrained_node = this->node_ref(i);
2656 const Point constrained_pt = constrained_node;
2657 newpt += r*constrained_pt;
2658 total_scaling += r;
2659 ++total_entries;
2660 ++pids[constrained_node.processor_id()];
2661 }
2662
2663 if (precondition_constraint_operator)
2664 column_sums[j] = total_scaling;
2665
2666 libmesh_error_msg_if
2667 (!total_entries,
2668 "Empty column " << j <<
2669 " found in constraint operator matrix");
2670
2671 // If we have *cancellation* here then we can end up dividing by
2672 // zero; try just evenly scaling across all constrained node
2673 // points instead.
2674 if (total_scaling > TOLERANCE)
2675 newpt /= total_scaling;
2676 else
2677 newpt /= total_entries;
2678
2679 Node *n = this->add_point(newpt);
2680 std::unique_ptr<Elem> elem = Elem::build(NODEELEM);
2681 elem->set_node(0, n);
2682 elem->subdomain_id() = new_sbd_id;
2683
2684 Elem * added_elem = this->add_elem(std::move(elem));
2685 this->_elem_dims.insert(0);
2686 this->_elem_default_orders.insert(added_elem->default_order());
2688 static_cast<Order>
2689 (std::min(static_cast<int>(this->_supported_nodal_order),
2690 static_cast<int>(added_elem->supported_nodal_order())));
2691 this->_mesh_subdomains.insert(new_sbd_id);
2692 node_to_elem_ptrs.emplace(n, std::make_pair(added_elem->id(), 0));
2693 existing_unconstrained_columns.emplace(j,n->id());
2694
2695 // Repartition the new objects *after* adding them, so a
2696 // DistributedMesh doesn't get confused and think you're not
2697 // adding them on all processors at once.
2698 int n_pids = 0;
2699 for (auto [pid, count] : pids)
2700 if (count >= n_pids)
2701 {
2702 n_pids = count;
2703 added_elem->processor_id() = pid;
2704 n->processor_id() = pid;
2705 }
2706 }
2707
2708 // Calculate constraint rows in an indexed form that's easy for us
2709 // to allgather
2710 std::unordered_map<dof_id_type,
2711 std::vector<std::pair<std::pair<dof_id_type, unsigned int>,Real>>>
2712 indexed_constraint_rows;
2713
2714 for (auto i : make_range(constraint_operator.row_start(),
2715 constraint_operator.row_stop()))
2716 {
2717 if (existing_unconstrained_nodes.count(i))
2718 continue;
2719
2720 std::vector<numeric_index_type> indices;
2721 std::vector<T> values;
2722
2723 constraint_operator.get_row(i, indices, values);
2724
2725 std::vector<std::pair<std::pair<dof_id_type, unsigned int>, Real>> constraint_row;
2726
2727 for (auto jj : index_range(indices))
2728 {
2729 const dof_id_type node_id =
2730 existing_unconstrained_columns[indices[jj]];
2731
2732 Node & constraining_node = this->node_ref(node_id);
2733
2734 libmesh_assert(node_to_elem_ptrs.count(&constraining_node));
2735
2736 auto p = node_to_elem_ptrs[&constraining_node];
2737
2738 Real coef = libmesh_real(values[jj]);
2739 libmesh_assert_equal_to(coef, values[jj]);
2740
2741 // If we're preconditioning and we created a nodeelem then
2742 // we can scale the meaning of that nodeelem's value to give
2743 // us a better-conditioned matrix after the constraints are
2744 // applied.
2745 if (precondition_constraint_operator)
2746 if (auto sum_it = column_sums.find(indices[jj]);
2747 sum_it != column_sums.end())
2748 {
2749 const Real scaling = sum_it->second;
2750
2751 if (scaling > TOLERANCE)
2752 coef /= scaling;
2753 }
2754
2755 constraint_row.emplace_back(std::make_pair(p, coef));
2756 }
2757
2758 indexed_constraint_rows.emplace(i, std::move(constraint_row));
2759 }
2760
2761 this->comm().set_union(indexed_constraint_rows);
2762
2763 // Add constraint rows as mesh constraint rows
2764 for (auto & [node_id, indexed_row] : indexed_constraint_rows)
2765 {
2766 Node * constrained_node = this->node_ptr(node_id);
2767
2768 constraint_rows_mapped_type constraint_row;
2769
2770 for (auto [p, coef] : indexed_row)
2771 {
2772 const Elem * elem = this->elem_ptr(p.first);
2773 constraint_row.emplace_back
2774 (std::make_pair(std::make_pair(elem, p.second), coef));
2775 }
2776
2777 this->_constraint_rows.emplace(constrained_node,
2778 std::move(constraint_row));
2779 }
2780}
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
virtual const Node & node_ref(const dof_id_type i) const
Definition mesh_base.h:745
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,...
Definition mesh_base.C:1126
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.
T libmesh_real(T a)
TestClass subdomain_id_type
Based on the 4-byte comment warning above, this probably doesn't work with exodusII at all....
Definition id_types.h:43
static constexpr Real TOLERANCE
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:176

References libMesh::MeshBase::_constraint_rows, libMesh::MeshBase::_elem_default_orders, libMesh::MeshBase::_elem_dims, libMesh::MeshBase::_mesh_subdomains, libMesh::MeshBase::_supported_nodal_order, libMesh::MeshBase::add_elem(), libMesh::MeshBase::add_point(), libMesh::Parallel::Communicator::allgather(), libMesh::Elem::build(), libMesh::ParallelObject::comm(), libMesh::Elem::default_order(), 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(), libMesh::Parallel::Communicator::set_union(), libMesh::MeshBase::subdomain_ids(), libMesh::Elem::supported_nodal_order(), and libMesh::TOLERANCE.

◆ 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,
const bool  skip_preparation = false 
)
virtualinherited

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.

For backwards compatibility, this does some limited mesh preparation after the copy: everything except for renumbering, remote element removal, and partitioning. To skip just the step of that preparation which finds new neighbor_ptr links between elements, set skip_find_neighbors. To skip all of that preparation, set skip_preparation. If preparation is skipped, it is the users responsibility to set the flags indicating what preparation may still be necessary before using the mesh later.

Definition at line 645 of file unstructured_mesh.C.

657{
658 LOG_SCOPE("copy_nodes_and_elements()", "UnstructuredMesh");
659
660 // If we're asked to skip all preparation, we should be skipping
661 // find_neighbors specifically.
662 libmesh_assert(!skip_preparation || skip_find_neighbors);
663
664 std::pair<std::vector<unsigned int>, std::vector<unsigned int>>
665 extra_int_maps = this->merge_extra_integer_names(other_mesh);
666
667 const unsigned int n_old_node_ints = extra_int_maps.second.size(),
668 n_new_node_ints = _node_integer_names.size(),
669 n_old_elem_ints = extra_int_maps.first.size(),
670 n_new_elem_ints = _elem_integer_names.size();
671
672 // If we are partitioned into fewer parts than the incoming mesh has
673 // processors to handle, then we need to "wrap" the other Mesh's
674 // processor ids to fit within our range. This can happen, for
675 // example, while stitching meshes with small numbers of elements in
676 // parallel...
677 bool wrap_proc_ids = (this->n_processors() <
678 other_mesh.n_partitions());
679
680 // We're assuming the other mesh has proper element number ordering,
681 // so that we add parents before their children, and that the other
682 // mesh is consistently partitioned. We're not assuming that node
683 // proc ids are topologically consistent, so we don't just
684 // libmesh_assert_valid_procids.
685#ifdef DEBUG
688#endif
689
690 //Copy in Nodes
691 {
692 //Preallocate Memory if necessary
693 this->reserve_nodes(other_mesh.n_nodes());
694
695 for (const auto & oldn : other_mesh.node_ptr_range())
696 {
697 processor_id_type added_pid = cast_int<processor_id_type>
698 (wrap_proc_ids ? oldn->processor_id() % this->n_processors() : oldn->processor_id());
699
700 // Add new nodes in old node Point locations
701 Node * newn =
702 this->add_point(*oldn,
703 oldn->id() + node_id_offset,
704 added_pid);
705
706 newn->add_extra_integers(n_new_node_ints);
707 for (unsigned int i = 0; i != n_old_node_ints; ++i)
708 newn->set_extra_integer(extra_int_maps.second[i],
709 oldn->get_extra_integer(i));
710
711#ifdef LIBMESH_ENABLE_UNIQUE_ID
712 newn->set_unique_id(oldn->unique_id() + unique_id_offset);
713#endif
714 }
715 }
716
717 //Copy in Elements
718 {
719 //Preallocate Memory if necessary
720 this->reserve_elem(other_mesh.n_elem());
721
722 // Declare a map linking old and new elements, needed to copy the neighbor lists
723 typedef std::unordered_map<const Elem *, Elem *> map_type;
724 map_type old_elems_to_new_elems, ip_map;
725
726 // Loop over the elements
727 for (const auto & old : other_mesh.element_ptr_range())
728 {
729 // Build a new element
730 Elem * newparent = old->parent() ?
731 this->elem_ptr(old->parent()->id() + element_id_offset) :
732 nullptr;
733 auto el = old->disconnected_clone();
734 el->set_parent(newparent);
735
736 subdomain_id_type sbd_id = old->subdomain_id();
737 if (id_remapping)
738 {
739 auto remapping_it = id_remapping->find(sbd_id);
740 if (remapping_it != id_remapping->end())
741 sbd_id = remapping_it->second;
742 }
743 el->subdomain_id() = sbd_id;
744
745 // Hold off on trying to set the interior parent because we may actually
746 // add lower dimensional elements before their interior parents
747 if (old->interior_parent())
748 ip_map[old] = el.get();
749
750#ifdef LIBMESH_ENABLE_AMR
751 if (old->has_children())
752 for (unsigned int c = 0, nc = old->n_children(); c != nc; ++c)
753 if (old->child_ptr(c) == remote_elem)
754 el->add_child(const_cast<RemoteElem *>(remote_elem), c);
755
756 //Create the parent's child pointers if necessary
757 if (newparent)
758 {
759 unsigned int oldc = old->parent()->which_child_am_i(old);
760 newparent->add_child(el.get(), oldc);
761 }
762
763 // Copy the refinement flags
764 el->set_refinement_flag(old->refinement_flag());
765
766 // Use hack_p_level since we may not have sibling elements
767 // added yet
768 el->hack_p_level(old->p_level());
769
770 el->set_p_refinement_flag(old->p_refinement_flag());
771#endif // #ifdef LIBMESH_ENABLE_AMR
772
773 //Assign all the nodes
774 for (auto i : el->node_index_range())
775 el->set_node(i,
776 this->node_ptr(old->node_id(i) + node_id_offset));
777
778 // And start it off with the same processor id (mod _n_parts).
779 el->processor_id() = cast_int<processor_id_type>
780 (wrap_proc_ids ? old->processor_id() % this->n_processors() : old->processor_id());
781
782 // Give it the same element and unique ids
783 el->set_id(old->id() + element_id_offset);
784
785 el->add_extra_integers(n_new_elem_ints);
786 for (unsigned int i = 0; i != n_old_elem_ints; ++i)
787 el->set_extra_integer(extra_int_maps.first[i],
788 old->get_extra_integer(i));
789
790#ifdef LIBMESH_ENABLE_UNIQUE_ID
791 el->set_unique_id(old->unique_id() + unique_id_offset);
792#endif
793
794 //Hold onto it
795 if (!skip_find_neighbors)
796 {
797 for (auto s : old->side_index_range())
798 if (old->neighbor_ptr(s) == remote_elem)
799 el->set_neighbor(s, const_cast<RemoteElem *>(remote_elem));
800 this->add_elem(std::move(el));
801 }
802 else
803 {
804 Elem * new_el = this->add_elem(std::move(el));
805 old_elems_to_new_elems[old] = new_el;
806 }
807 }
808
809 // If the other_mesh had some interior parents, we may need to
810 // copy those pointers (if they're to elements in a third mesh),
811 // or create new equivalent pointers (if they're to elements we
812 // just copied), or scream and die (if the other mesh had interior
813 // parents from a third mesh but we already have interior parents
814 // that aren't to that same third mesh.
815 if (!ip_map.empty())
816 {
817 std::atomic<bool> existing_interior_parents{false};
818
820 (this->element_stored_range(),
821 [&existing_interior_parents](const ElemRange & range)
822 {
823 for (Elem * elem : range)
824 if (elem->interior_parent())
825 {
826 existing_interior_parents = true;
827 break;
828 }
829 });
830
831 MeshBase * other_interior_mesh =
832 const_cast<MeshBase *>(&other_mesh.interior_mesh());
833
834 // If we don't already have interior parents, then we can just
835 // use whatever interior_mesh we need for the incoming
836 // elements.
837 if (!existing_interior_parents)
838 {
839 if (other_interior_mesh == &other_mesh)
840 this->set_interior_mesh(*this);
841 else
842 this->set_interior_mesh(*other_interior_mesh);
843 }
844
845 if (other_interior_mesh == &other_mesh &&
846 _interior_mesh == this)
847 for (auto & elem_pair : ip_map)
848 elem_pair.second->set_interior_parent(
849 this->elem_ptr(elem_pair.first->interior_parent()->id() + element_id_offset));
850 else if (other_interior_mesh == _interior_mesh)
851 for (auto & elem_pair : ip_map)
852 {
853 Elem * ip = const_cast<Elem *>(elem_pair.first->interior_parent());
855 ip == other_interior_mesh->elem_ptr(ip->id()));
856 elem_pair.second->set_interior_parent(ip);
857 }
858 else
859 libmesh_error_msg("Cannot copy boundary elements between meshes with different interior meshes");
860 }
861
862 // Loop (again) over the elements to fill in the neighbors
863 if (skip_find_neighbors)
864 {
865 old_elems_to_new_elems[remote_elem] = const_cast<RemoteElem*>(remote_elem);
866
867 for (const auto & old_elem : other_mesh.element_ptr_range())
868 {
869 Elem * new_elem = old_elems_to_new_elems[old_elem];
870 for (auto s : old_elem->side_index_range())
871 {
872 const Elem * old_neighbor = old_elem->neighbor_ptr(s);
873 Elem * new_neighbor = old_elems_to_new_elems[old_neighbor];
874 new_elem->set_neighbor(s, new_neighbor);
875 }
876 }
877 }
878 }
879
880#ifdef LIBMESH_ENABLE_UNIQUE_ID
881 // We set the unique ids of nodes after adding them to the mesh such that our value of
882 // _next_unique_id may be wrong. So we amend that here
883 this->set_next_unique_id(other_mesh.parallel_max_unique_id() + unique_id_offset + 1);
884#endif
885
886 // Finally, partially prepare the new Mesh for use, if that isn't
887 // being skipped.
888 // Even the default behavior here is for backwards compatibility,
889 // and we don't want to prepare everything.
890
891 if (!skip_preparation)
892 {
893 // Keep the same numbering and partitioning and distribution
894 // status for now, but save our original policies to restore
895 // later.
896 const bool allowed_renumbering = this->allow_renumbering();
897 const bool allowed_find_neighbors = this->allow_find_neighbors();
898 const bool allowed_elem_removal = this->allow_remote_element_removal();
899 const bool allowed_detect_detect_interior_parents = this->allow_detect_interior_parents();
900 this->allow_renumbering(false);
901 this->allow_remote_element_removal(false);
902 this->allow_find_neighbors(!skip_find_neighbors);
904
905 // We should generally be able to skip *all* partitioning here
906 // because we're only adding one already-consistent mesh to
907 // another.
908 const bool skipped_partitioning = this->skip_partitioning();
909 this->skip_partitioning(true);
910
911 const bool was_prepared = this->is_prepared();
912 this->prepare_for_use();
913
914 //But in the long term, don't change our policies.
915 this->allow_find_neighbors(allowed_find_neighbors);
916 this->allow_renumbering(allowed_renumbering);
917 this->allow_remote_element_removal(allowed_elem_removal);
918 this->skip_partitioning(skipped_partitioning);
919 this->allow_detect_interior_parents(allowed_detect_detect_interior_parents);
920
921 // That prepare_for_use() call marked us as prepared, but we
922 // specifically avoided some important preparation, so we might not
923 // actually be prepared now.
924 if (skip_find_neighbors ||
925 !was_prepared || !other_mesh.is_prepared())
926 this->unset_is_prepared();
927 }
928
929 // In general we've just invalidated just about everything, and we'd
930 // like to unset_is_prepared(), but specific use cases might know a
931 // priori that they're still partitioned well, or that they've
932 // copied in a disjoint mesh component and don't need new neighbor
933 // pointers, or that they're not adding anything that would change
934 // cached subdomain/element/boundary sets, etc., so we'll rely on
935 // users of the "advanced" skip_preparation option to also set what
936 // preparation they still need.
937
938 // else
939 // this->unset_is_prepared();
940}
void add_extra_integers(const unsigned int n_integers)
Assigns a set of extra integers to this DofObject.
Definition dof_object.C:482
dof_id_type id() const
Definition dof_object.h:819
void set_unique_id(unique_id_type new_id)
Sets the unique_id for this DofObject.
Definition dof_object.h:848
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...
const Elem * parent() const
Definition elem.h:3047
void set_neighbor(const unsigned int i, Elem *n)
Assigns n as the neighbor.
Definition elem.h:2635
void add_child(Elem *elem)
Adds a child pointer to the array of children of this element.
Definition elem.C:2053
const Elem * neighbor_ptr(unsigned int i) const
Definition elem.h:2615
This is the MeshBase class.
Definition mesh_base.h:81
bool is_prepared() const
Definition mesh_base.C:1064
bool allow_renumbering() const
Definition mesh_base.h:1356
virtual dof_id_type n_elem() const =0
bool allow_detect_interior_parents() const
Definition mesh_base.h:1370
unsigned int n_partitions() const
Definition mesh_base.h:1526
virtual void set_next_unique_id(unique_id_type id)=0
Sets the next available unique id to be used.
MeshBase * _interior_mesh
Defaulting to this, a pointer to the mesh used to generate boundary elements on this.
Definition mesh_base.h:2252
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:2385
const MeshBase & interior_mesh() const
Definition mesh_base.h:2040
bool allow_remote_element_removal() const
Definition mesh_base.h:1379
bool allow_find_neighbors() const
Definition mesh_base.h:1363
virtual void reserve_elem(const dof_id_type ne)=0
Reserves space for a known number of elements.
void set_interior_mesh(MeshBase &int_mesh)
Sets the interior mesh.
Definition mesh_base.h:2050
void allow_detect_interior_parents(bool allow)
If false is passed then this mesh will no longer work to detect interior parents when being prepared ...
Definition mesh_base.h:1369
void unset_is_prepared()
Tells this we have done some operation where we should no longer consider ourself prepared.
Definition mesh_base.C:1070
virtual unique_id_type parallel_max_unique_id() const =0
A Node is like a Point, but with more information.
Definition node.h:55
The StoredRange class defines a contiguous, divisible set of objects.
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...
void libmesh_assert_parallel_consistent_procids< Node >(const MeshBase &mesh)

References libMesh::MeshBase::_elem_integer_names, libMesh::MeshBase::_interior_mesh, libMesh::MeshBase::_node_integer_names, libMesh::Elem::add_child(), libMesh::MeshBase::add_elem(), libMesh::MeshBase::add_point(), libMesh::MeshBase::allow_detect_interior_parents(), libMesh::MeshBase::allow_detect_interior_parents(), libMesh::MeshBase::allow_find_neighbors(), libMesh::MeshBase::allow_remote_element_removal(), libMesh::MeshBase::allow_renumbering(), libMesh::MeshBase::elem_ptr(), libMesh::MeshBase::element_stored_range(), libMesh::DofObject::id(), libMesh::MeshBase::interior_mesh(), libMesh::MeshBase::is_prepared(), libMesh::libmesh_assert(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_amr_elem_ids(), libMesh::MeshBase::merge_extra_integer_names(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::MeshBase::n_partitions(), libMesh::ParallelObject::n_processors(), libMesh::Elem::neighbor_ptr(), libMesh::Threads::parallel_for(), libMesh::MeshBase::parallel_max_unique_id(), libMesh::Elem::parent(), libMesh::MeshBase::prepare_for_use(), libMesh::remote_elem, libMesh::MeshBase::reserve_elem(), libMesh::MeshBase::reserve_nodes(), libMesh::MeshBase::set_interior_mesh(), libMesh::Elem::set_neighbor(), libMesh::MeshBase::set_next_unique_id(), libMesh::MeshBase::skip_partitioning(), and libMesh::MeshBase::unset_is_prepared().

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

◆ create_pid_mesh()

void libMesh::UnstructuredMesh::create_pid_mesh ( UnstructuredMesh pid_mesh,
const processor_id_type  pid 
) const
inherited

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 1423 of file unstructured_mesh.C.

1425{
1426
1427 // Issue a warning if the number the number of processors
1428 // currently available is less that that requested for
1429 // partitioning. This is not necessarily an error since
1430 // you may run on one processor and still partition the
1431 // mesh into several partitions.
1432#ifdef DEBUG
1433 if (this->n_processors() < pid)
1434 {
1435 libMesh::out << "WARNING: You are creating a "
1436 << "mesh for a processor id (="
1437 << pid
1438 << ") greater than "
1439 << "the number of processors available for "
1440 << "the calculation. (="
1441 << this->n_processors()
1442 << ")."
1443 << std::endl;
1444 }
1445#endif
1446
1447 this->create_submesh (pid_mesh,
1448 this->active_pid_elements_begin(pid),
1449 this->active_pid_elements_end(pid));
1450}
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...
OStreamProxy out

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

◆ create_submesh()

void libMesh::UnstructuredMesh::create_submesh ( UnstructuredMesh new_mesh,
const const_element_iterator it,
const const_element_iterator it_end 
) const
inherited

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 1458 of file unstructured_mesh.C.

1461{
1462 // Just in case the subdomain_mesh already has some information
1463 // in it, get rid of it.
1464 new_mesh.clear();
1465
1466 // If we're not serial, our submesh isn't either.
1467 // There are no remote elements to delete on an empty mesh, but
1468 // calling the method to do so marks the mesh as parallel.
1469 if (!this->is_serial())
1470 new_mesh.delete_remote_elements();
1471
1472 // Fail if (*this == new_mesh), we cannot create a submesh inside ourself!
1473 // This may happen if the user accidentally passes the original mesh into
1474 // this function! We will check this by making sure we did not just
1475 // clear ourself.
1476 libmesh_assert_not_equal_to (this->n_nodes(), 0);
1477 libmesh_assert_not_equal_to (this->n_elem(), 0);
1478
1479 // Container to catch boundary IDs handed back by BoundaryInfo
1480 std::vector<boundary_id_type> bc_ids;
1481
1482 // Put any extra integers on the new mesh too
1483 new_mesh.merge_extra_integer_names(*this);
1484 const unsigned int n_node_ints = _node_integer_names.size();
1485
1486 for (const auto & old_elem : as_range(it, it_end))
1487 {
1488 // Add an equivalent element type to the new_mesh.
1489 // disconnected_clone() copies ids, extra element integers, etc.
1490 auto uelem = old_elem->disconnected_clone();
1491 Elem * new_elem = new_mesh.add_elem(std::move(uelem));
1492 libmesh_assert(new_elem);
1493
1494 // Loop over the nodes on this element.
1495 for (auto n : old_elem->node_index_range())
1496 {
1497 const dof_id_type this_node_id = old_elem->node_id(n);
1498
1499 // Add this node to the new mesh if it's not there already
1500 if (!new_mesh.query_node_ptr(this_node_id))
1501 {
1502 Node * newn =
1503 new_mesh.add_point (old_elem->point(n),
1504 this_node_id,
1505 old_elem->node_ptr(n)->processor_id());
1506
1507 newn->add_extra_integers(n_node_ints);
1508 for (unsigned int i = 0; i != n_node_ints; ++i)
1509 newn->set_extra_integer(i, old_elem->node_ptr(n)->get_extra_integer(i));
1510
1511#ifdef LIBMESH_ENABLE_UNIQUE_ID
1512 newn->set_unique_id(old_elem->node_ptr(n)->unique_id());
1513#endif
1514 }
1515
1516 // Define this element's connectivity on the new mesh
1517 new_elem->set_node(n, new_mesh.node_ptr(this_node_id));
1518 }
1519
1520 // Maybe add boundary conditions for this element
1521 for (auto s : old_elem->side_index_range())
1522 {
1523 this->get_boundary_info().boundary_ids(old_elem, s, bc_ids);
1524 new_mesh.get_boundary_info().add_side (new_elem, s, bc_ids);
1525 }
1526 } // end loop over elements
1527
1528 // Prepare the new_mesh for use
1529 new_mesh.prepare_for_use();
1530}
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.
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.
virtual Node *& set_node(const unsigned int i)
Definition elem.h:2567
void prepare_for_use(const bool skip_renumber_nodes_and_elements, const bool skip_find_neighbors)
Prepare a newly created (or read) mesh for use.
Definition mesh_base.C:824
virtual const Node * query_node_ptr(const dof_id_type i) const =0

References 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::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 libMesh::UnstructuredMesh::create_pid_mesh().

◆ DECLARE_ELEM_ITERATORS() [1/20]

libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( )
inherited

Elem and Node iterator accessor functions.

See MeshBase for documentation.

◆ DECLARE_ELEM_ITERATORS() [2/20]

libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( active_  )
inherited

◆ DECLARE_ELEM_ITERATORS() [3/20]

processor_id_type pid unsigned int level libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( active_local_subdomain_  ,
subdomain_id_type  sid,
sid   
)
inherited

◆ DECLARE_ELEM_ITERATORS() [4/20]

libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( active_not_local_  )
inherited

◆ DECLARE_ELEM_ITERATORS() [5/20]

processor_id_type pid unsigned int level std::set< subdomain_id_type > ss libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( active_semilocal_  )
inherited

◆ DECLARE_ELEM_ITERATORS() [6/20]

unsigned int level ElemType type libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( active_subdomain_  ,
subdomain_id_type  sid,
sid   
)
inherited

◆ DECLARE_ELEM_ITERATORS() [7/20]

libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( active_type_  ,
ElemType  type,
type   
)
inherited

◆ DECLARE_ELEM_ITERATORS() [8/20]

libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( ancestor_  )
inherited

◆ DECLARE_ELEM_ITERATORS() [9/20]

libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( facelocal_  )
inherited

◆ DECLARE_ELEM_ITERATORS() [10/20]

processor_id_type pid unsigned int level std::set< subdomain_id_type > ss const DofMap &dof_map LIBMESH_COMMA unsigned int dof_map LIBMESH_COMMA var_num unsigned char rflag libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( flagged_pid_  ,
unsigned char rflag LIBMESH_COMMA processor_id_type  pid,
rflag LIBMESH_COMMA  pid 
)
inherited

◆ DECLARE_ELEM_ITERATORS() [11/20]

libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( local_  )
inherited

◆ DECLARE_ELEM_ITERATORS() [12/20]

processor_id_type pid libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( local_level_  ,
unsigned int  level,
level   
)
inherited

◆ DECLARE_ELEM_ITERATORS() [13/20]

processor_id_type pid unsigned int level std::set< subdomain_id_type > ss const DofMap &dof_map LIBMESH_COMMA unsigned int dof_map LIBMESH_COMMA var_num libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( multi_evaluable_  ,
std::vector< const DofMap * >  dof_maps,
dof_maps   
)
inherited

◆ DECLARE_ELEM_ITERATORS() [14/20]

libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( not_active_  )
inherited

◆ DECLARE_ELEM_ITERATORS() [15/20]

libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( not_ancestor_  )
inherited

◆ DECLARE_ELEM_ITERATORS() [16/20]

libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( not_level_  ,
unsigned int  level,
level   
)
inherited

◆ DECLARE_ELEM_ITERATORS() [17/20]

libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( not_local_  )
inherited

◆ DECLARE_ELEM_ITERATORS() [18/20]

libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( not_subactive_  )
inherited

◆ DECLARE_ELEM_ITERATORS() [19/20]

unsigned int level libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( pid_  ,
processor_id_type  pid,
pid   
)
inherited

◆ DECLARE_ELEM_ITERATORS() [20/20]

processor_id_type pid unsigned int level std::set< subdomain_id_type > ss libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( semilocal_  )
inherited

◆ DECLARE_NODE_ITERATORS() [1/3]

processor_id_type pid unsigned int level std::set< subdomain_id_type > ss const DofMap &dof_map LIBMESH_COMMA unsigned int dof_map LIBMESH_COMMA var_num unsigned char rflag libMesh::DistributedMesh::DECLARE_NODE_ITERATORS ( active_  )
inherited

◆ DECLARE_NODE_ITERATORS() [2/3]

processor_id_type pid unsigned int level std::set< subdomain_id_type > ss const DofMap &dof_map LIBMESH_COMMA unsigned int dof_map LIBMESH_COMMA var_num unsigned char rflag processor_id_type pid libMesh::DistributedMesh::DECLARE_NODE_ITERATORS ( bid_  ,
boundary_id_type  bid,
bid   
)
inherited

◆ DECLARE_NODE_ITERATORS() [3/3]

processor_id_type pid unsigned int level std::set< subdomain_id_type > ss const DofMap &dof_map LIBMESH_COMMA unsigned int dof_map LIBMESH_COMMA var_num unsigned char rflag libMesh::DistributedMesh::DECLARE_NODE_ITERATORS ( bnd_  )
inherited

◆ default_ghosting()

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

Default ghosting functor.

Definition at line 1484 of file mesh_base.h.

1484{ 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:2415

References libMesh::MeshBase::_default_ghosting.

◆ 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 959 of file mesh_base.h.

960 {
962 }
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:2190

References libMesh::MeshBase::_default_mapping_data.

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

◆ 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 941 of file mesh_base.h.

942 {
944 }
ElemMappingType _default_mapping_type
The default mapping type (typically Lagrange) between master and physical space to assign to newly ad...
Definition mesh_base.h:2183

References libMesh::MeshBase::_default_mapping_type.

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

◆ delete_elem()

void libMesh::DistributedMesh::delete_elem ( Elem e)
finaloverridevirtualinherited

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::complete_preparation() 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.

Implements libMesh::MeshBase.

Definition at line 718 of file distributed_mesh.C.

719{
720 libmesh_assert (e);
721
722 // Try to make the cached elem data more accurate
723 _n_elem--;
724
725 // Was this a coarse element, not just a coarsening where we still
726 // have some ancestor structure? Was it a *local* element, that we
727 // might have been depending on as an owner of local nodes? We'll
728 // have to be more careful with our nodes in contract() later; no
729 // telling if we just locally orphaned a node that should be
730 // globally retained.
731 if (e->processor_id() == this->processor_id() &&
732 !e->parent())
734
735 // Delete the element from the BoundaryInfo object
736 this->get_boundary_info().remove(e);
737
738 // But not yet from the container; we might invalidate
739 // an iterator that way!
740
741 //_elements.erase(e->id());
742
743 // Instead, we set it to nullptr for now
744
745 _elements[e->id()] = nullptr;
746
747 // delete the element
748 delete e;
749
750 // Some of our caches might still be valid, but we should clear the
751 // ones which definitely are not.
752 this->clear_point_locator();
753 this->clear_stored_ranges();
754}
void remove(const Node *node)
Removes the boundary conditions associated with node node, if any exist.

References libMesh::DistributedMesh::_deleted_coarse_elements, libMesh::DistributedMesh::_elements, libMesh::DistributedMesh::_n_elem, libMesh::MeshBase::clear_point_locator(), libMesh::MeshBase::clear_stored_ranges(), libMesh::MeshBase::get_boundary_info(), libMesh::DofObject::id(), libMesh::libmesh_assert(), libMesh::Elem::parent(), libMesh::DofObject::processor_id(), and libMesh::BoundaryInfo::remove().

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

◆ delete_node()

void libMesh::DistributedMesh::delete_node ( Node n)
finaloverridevirtualinherited

Removes the Node n from the mesh.

Implements libMesh::MeshBase.

Definition at line 931 of file distributed_mesh.C.

932{
934 libmesh_assert(_nodes[n->id()]);
935
936 // Try to make the cached elem data more accurate
937 _n_nodes--;
938
939 // Delete the node from the BoundaryInfo object
940 this->get_boundary_info().remove(n);
941 _constraint_rows.erase(n);
942
943 // But not yet from the container; we might invalidate
944 // an iterator that way!
945
946 //_nodes.erase(n->id());
947
948 // Instead, we set it to nullptr for now
949
950 _nodes[n->id()] = nullptr;
951
952 // delete the node
953 delete n;
954}

References libMesh::MeshBase::_constraint_rows, libMesh::DistributedMesh::_n_nodes, libMesh::DistributedMesh::_nodes, libMesh::MeshBase::get_boundary_info(), libMesh::DofObject::id(), libMesh::libmesh_assert(), and libMesh::BoundaryInfo::remove().

◆ delete_remote_elements()

void libMesh::DistributedMesh::delete_remote_elements ( )
overridevirtualinherited

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 from libMesh::MeshBase.

Definition at line 1731 of file distributed_mesh.C.

1732{
1733#ifdef DEBUG
1734 // Make sure our neighbor links are all fine
1736
1737 // And our child/parent links, and our flags
1739
1740 // Make sure our ids and flags are consistent
1743
1744 libmesh_assert_equal_to (this->n_nodes(), this->parallel_n_nodes());
1745 libmesh_assert_equal_to (this->n_elem(), this->parallel_n_elem());
1746 const dof_id_type pmax_node_id = this->parallel_max_node_id();
1747 const dof_id_type pmax_elem_id = this->parallel_max_elem_id();
1748 libmesh_assert_equal_to (this->max_node_id(), pmax_node_id);
1749 libmesh_assert_equal_to (this->max_elem_id(), pmax_elem_id);
1750#endif
1751
1752 _is_serial = false;
1753 _is_serial_on_proc_0 = false;
1754
1755 MeshCommunication().delete_remote_elements(*this, _extra_ghost_elems);
1756
1757 libmesh_assert_equal_to (this->max_elem_id(), this->parallel_max_elem_id());
1758
1759 // Now make sure the containers actually shrink - strip
1760 // any newly-created nullptr voids out of the element array
1761 dofobject_container<Elem>::veclike_iterator e_it = _elements.begin();
1762 const dofobject_container<Elem>::veclike_iterator e_end = _elements.end();
1763 while (e_it != e_end)
1764 if (!*e_it)
1765 e_it = _elements.erase(e_it);
1766 else
1767 ++e_it;
1768
1769 dofobject_container<Node>::veclike_iterator n_it = _nodes.begin();
1770 const dofobject_container<Node>::veclike_iterator n_end = _nodes.end();
1771 while (n_it != n_end)
1772 if (!*n_it)
1773 n_it = _nodes.erase(n_it);
1774 else
1775 ++n_it;
1776
1777 // We may have deleted no-longer-connected nodes or coarsened-away
1778 // elements; let's update our caches.
1780
1781 // We may have deleted nodes or elements that were the only local
1782 // representatives of some particular boundary id(s); let's update
1783 // those caches.
1785
1786#ifdef DEBUG
1787 // We might not have well-packed objects if the user didn't allow us
1788 // to renumber
1789 // libmesh_assert_equal_to (this->n_nodes(), this->max_node_id());
1790 // libmesh_assert_equal_to (this->n_elem(), this->max_elem_id());
1791
1792 // Make sure our neighbor links are all fine
1794
1795 // And our child/parent links, and our flags
1797
1798 // Make sure our ids and flags are consistent
1801#endif
1802
1804}
virtual void update_parallel_id_counts() override
Updates parallel caches so that methods like n_elem() accurately reflect changes on other processors.
void libmesh_assert_valid_refinement_tree(const MeshBase &mesh)
A function for verifying that elements on this processor have valid descendants and consistent active...

References libMesh::DistributedMesh::_elements, libMesh::DistributedMesh::_extra_ghost_elems, libMesh::DistributedMesh::_is_serial, libMesh::DistributedMesh::_is_serial_on_proc_0, libMesh::DistributedMesh::_nodes, libMesh::MeshBase::_preparation, libMesh::MeshCommunication::delete_remote_elements(), libMesh::MeshBase::get_boundary_info(), libMesh::MeshBase::Preparation::has_removed_remote_elements, libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_flags(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_ids(), libMesh::MeshTools::libmesh_assert_valid_refinement_tree(), libMesh::DistributedMesh::max_elem_id(), libMesh::DistributedMesh::max_node_id(), libMesh::DistributedMesh::n_elem(), libMesh::DistributedMesh::n_nodes(), libMesh::DistributedMesh::parallel_max_elem_id(), libMesh::DistributedMesh::parallel_max_node_id(), libMesh::DistributedMesh::parallel_n_elem(), libMesh::DistributedMesh::parallel_n_nodes(), libMesh::BoundaryInfo::regenerate_id_sets(), and libMesh::DistributedMesh::update_parallel_id_counts().

◆ 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 2077 of file mesh_base.C.

2078{
2079 LOG_SCOPE("detect_interior_parents()", "MeshBase");
2080
2081 // This requires an inspection on every processor
2082 parallel_object_only();
2083
2084 // This requires up-to-date mesh dimensions, but if we don't have
2085 // them cached then we can't update them without changing the mesh
2086 // in unexpected ways that interfere with our tests of
2087 // partially-prepared meshes in MeshTools::*valid_is_prepared
2088 std::set<unsigned char> elem_dims_copy;
2090 elem_dims_copy = this->elem_dimensions();
2091 else
2092 {
2093 for (const auto & elem : this->active_element_ptr_range())
2094 elem_dims_copy.insert(cast_int<unsigned char>(elem->dim()));
2095 if (!this->is_serial())
2096 this->comm().set_union(elem_dims_copy);
2097 }
2098
2099 // Early return if the mesh is empty or has elements of a single spatial dimension.
2100 if (elem_dims_copy.size() <= 1)
2101 {
2103 return;
2104 }
2105
2106 // Convenient elem_dimensions iterators
2107 const auto dim_start = elem_dims_copy.begin();
2108 const auto dim_end = elem_dims_copy.end();
2109
2110 // In this function we find only +1 dimensional interior parents,
2111 // (so, for a given element el, the interior parent p must satisfy p.dim() == el.dim() + 1).
2112 // Therefore, we can avoid checking the existence of interior parents
2113 // for all those elements el such there there is no p with p.dim() == el.dim() + 1.
2114 // We store whether to skip any given dimension in the construction of interior parents
2115 // inside the vector in dimensions_to_skip_for_interior_parents.
2116 std::vector<bool> skip_dimension_for_interior_parents(/*count=*/LIBMESH_DIM+1, /*value=*/false);
2117 skip_dimension_for_interior_parents.back() = true;
2118
2119 // Moreover, in the following, we will build a node-to-elem map.
2120 // It is among the elems of this map that we will look for interior parents.
2121 // Therefore, we can skip all elems p such that there is no el with el.dim() == p.dim() - 1.
2122 // We store whether to skip any given dimension in the construction of the node-to-elem map
2123 // in the vector skip_dimensions_for_node_to_el_map.
2124 std::vector<bool> skip_dimensions_for_node_to_el_map(/*count=*/LIBMESH_DIM+1, /*value=*/false);
2125 skip_dimensions_for_node_to_el_map[*dim_start] = true;
2126
2127 // We also create a flag to know if all dimensions should be skipped,
2128 // and if we should therefore return early.
2129 bool skip_all_dimensions = true;
2130
2131 // Fill dimensions_to_skip_for_interior_parents and dimensions_to_skip_for_node_to_el_map.
2132 for (auto [it, next] = std::make_tuple(dim_start, std::next(dim_start));
2133 next != dim_end; ++it, ++next)
2134 {
2135 if (*it + 1 != *next) // if sequential dimensions differ by exactly 1
2136 {
2137 skip_dimension_for_interior_parents[*it] = true;
2138 skip_dimensions_for_node_to_el_map[*next] = true;
2139 }
2140 else if (!skip_dimension_for_interior_parents[*it])
2141 skip_all_dimensions = false;
2142 }
2143
2144 // There is nothing to do if all dimensions should be
2145 // skipped. Before returning, we must also set the flag that says
2146 // "interior parent pointers have been set up" even though we
2147 // determined there was no work to be done.
2148 if (skip_all_dimensions)
2149 {
2151 return;
2152 }
2153
2154 // Do we have interior parent pointers going to a different mesh?
2155 // If so then we'll still check to make sure that's the only place
2156 // they go, so we can libmesh_not_implemented() if not.
2157 const bool separate_interior_mesh = (&(this->interior_mesh()) != this);
2158
2159 // This map will be used to set interior parents
2160 std::unordered_map<dof_id_type, std::vector<dof_id_type>> node_to_elem;
2161
2162 for (const auto & elem : this->element_ptr_range())
2163 {
2164 // Ignore element if it cannot be interior parent of any other elem.
2165 if (skip_dimensions_for_node_to_el_map[elem->dim()])
2166 continue;
2167
2168 // Populating the node_to_elem map, same as MeshTools::build_nodes_to_elem_map
2169 for (auto n : make_range(elem->n_vertices()))
2170 {
2171 libmesh_assert_less (elem->id(), this->max_elem_id());
2172
2173 node_to_elem[elem->node_id(n)].push_back(elem->id());
2174 }
2175 }
2176
2177 // Automatically set interior parents
2178 for (const auto & element : this->element_ptr_range())
2179 {
2180 // Ignore elements with dimensions to skip
2181 // or elements that already have an interior parent.
2182 if (skip_dimension_for_interior_parents[element->dim()] || element->interior_parent())
2183 continue;
2184
2185 // Start by generating sets of dim+1 dimensional elements that
2186 // touch each vertex of the current element. If we encounter a
2187 // vertex not connected to _any_ dim+1 dimensional elements,
2188 // then we can exit the loop without checking the remaining
2189 // vertices since an interior parent (if it exists) will be
2190 // connected to all vertices of the current element.
2191 std::vector<std::set<dof_id_type>> neighbors( element->n_vertices() );
2192
2193 bool found_interior_parents = true;
2194
2195 for (auto n : make_range(element->n_vertices()))
2196 {
2197 auto it = node_to_elem.find(element->node_id(n));
2198
2199 // Check at first that this node is not isolated.
2200 if (it == node_to_elem.end())
2201 {
2202 found_interior_parents = false;
2203 break; // out of n-loop
2204 }
2205
2206 for (const auto & vertex_neighbor_id : it->second)
2207 if (this->elem_ref(vertex_neighbor_id).dim() == element->dim()+1)
2208 neighbors[n].insert(vertex_neighbor_id);
2209
2210 if (neighbors[n].empty())
2211 {
2212 // We have found an empty set for one vertex, no reason
2213 // to continue.
2214 found_interior_parents = false;
2215 break; // out of n-loop
2216 }
2217 }
2218
2219 // If we have generated a non-empty set of elements for each
2220 // vertex, we will now look for a vertex_neighbor_id that
2221 // appears in _all_ of those sets. If found, this is our interior
2222 // parent id. If multiple such common ids are found, we will
2223 // take the lowest such id to be the interior parent id.
2224 if (found_interior_parents)
2225 {
2226 std::set<dof_id_type> & neighbors_0 = neighbors[0];
2227 for (const auto & interior_parent_id : neighbors_0)
2228 {
2229 found_interior_parents = false;
2230 for (auto n : make_range(1u, element->n_vertices()))
2231 {
2232 if (neighbors[n].count(interior_parent_id))
2233 {
2234 found_interior_parents = true;
2235 }
2236 else
2237 {
2238 found_interior_parents = false;
2239 break;
2240 }
2241 }
2242
2243 if (found_interior_parents)
2244 {
2245 element->set_interior_parent(this->elem_ptr(interior_parent_id));
2246 break;
2247 }
2248 }
2249
2250 // Do we have a mixed dimensional mesh that contains some of
2251 // its own interior parents, but we already expect to have
2252 // interior parents on a different mesh? That's going to
2253 // take some work to support if anyone needs it.
2254 if (separate_interior_mesh)
2255 libmesh_not_implemented_msg
2256 ("interior_parent() values in multiple meshes are unsupported.");
2257 }
2258 }
2259
2260 // This flag doesn't necessarily mean any Elems actually have
2261 // interior parent pointers, just that we did all the work to
2262 // determine whether or not they do.
2264}
const std::set< unsigned char > & elem_dimensions() const
Definition mesh_base.h:430
virtual const Elem & elem_ref(const dof_id_type i) const
Definition mesh_base.h:788
Tnew cast_int(Told oldvar)

References libMesh::MeshBase::_preparation, libMesh::ParallelObject::comm(), libMesh::Elem::dim(), libMesh::MeshBase::elem_dimensions(), libMesh::MeshBase::elem_ptr(), libMesh::MeshBase::elem_ref(), libMesh::MeshBase::Preparation::has_cached_elem_data, libMesh::MeshBase::Preparation::has_interior_parent_ptrs, libMesh::MeshBase::interior_mesh(), libMesh::MeshBase::is_serial(), libMesh::make_range(), and libMesh::Parallel::Communicator::set_union().

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

◆ elem_default_orders()

const std::set< Order > & libMesh::MeshBase::elem_default_orders ( ) const
inlineinherited
Returns
A const reference to a std::set of element default orders present in the mesh.

Definition at line 437 of file mesh_base.h.

438 { return _elem_default_orders; }

References libMesh::MeshBase::_elem_default_orders.

Referenced by MeshSmootherTest::testVariationalSmoother().

◆ 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 430 of file mesh_base.h.

431 { return _elem_dims; }

References libMesh::MeshBase::_elem_dims.

Referenced by libMesh::MeshBase::detect_interior_parents(), libMesh::TreeNode< N >::insert(), and libMesh::VariationalMeshSmoother::setup().

◆ elem_ptr() [1/2]

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

Implements libMesh::MeshBase.

Definition at line 475 of file distributed_mesh.C.

476{
478 libmesh_assert_equal_to (_elements[i]->id(), i);
479
480 return _elements[i];
481}

References libMesh::DistributedMesh::_elements, and libMesh::libmesh_assert().

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

◆ elem_ptr() [2/2]

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

Implements libMesh::MeshBase.

Definition at line 486 of file distributed_mesh.C.

487{
489 libmesh_assert_equal_to (_elements[i]->id(), i);
490
491 return _elements[i];
492}

References libMesh::DistributedMesh::_elements, and libMesh::libmesh_assert().

◆ elem_ref() [1/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 798 of file mesh_base.h.

799 {
800 return *this->elem_ptr(i);
801 }

References libMesh::MeshBase::elem_ptr().

◆ elem_ref() [2/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 788 of file mesh_base.h.

789 {
790 return *this->elem_ptr(i);
791 }

References libMesh::MeshBase::elem_ptr().

Referenced by libMesh::SyncSubdomainIds::act_on_data(), libMesh::SyncElementIntegers::act_on_data(), libMesh::SyncRefinementFlags::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::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::SyncSubdomainIds::gather_data(), libMesh::SyncElementIntegers::gather_data(), libMesh::SyncRefinementFlags::gather_data(), libMesh::MeshTetInterface::improve_hull_integrity(), main(), MeshPerElemTest< 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(), SystemsTest::testSetSystemParameterOverEquationSystem(), libMesh::FroIO::write(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::Nemesis_IO_Helper::write_elements(), libMesh::GmshIO::write_mesh(), and libMesh::ExodusII_IO_Helper::write_sidesets().

◆ element_stored_range()

const ElemRange & libMesh::MeshBase::element_stored_range ( )
inherited
Returns
A reference to a cached vector copy of a range of pointers to all semilocal elements, suitable for threading.

Iterating over all semilocal elements is most useful for modifying the mesh, so we only have a non-const version for now.

Definition at line 1939 of file mesh_base.C.

1940{
1942 {
1943 // Range construction may not be safe within threads
1945
1947 std::make_unique<ElemRange>(this->elements_begin(),
1948 this->elements_end());
1949 }
1950
1951 return *_element_stored_range;
1952}

References libMesh::MeshBase::_element_stored_range, libMesh::Threads::in_threads, and libMesh::libmesh_assert().

Referenced by libMesh::EquationSystems::allgather(), libMesh::MeshBase::change_elemset_code(), libMesh::MeshTools::Modification::change_subdomain_id(), libMesh::UnstructuredMesh::copy_nodes_and_elements(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::EquationSystems::reinit_mesh(), libMesh::EquationSystems::reinit_solutions(), and libMesh::MeshBase::size_elem_extra_integers().

◆ extra_ghost_elems()

const std::set< Elem * > & libMesh::DistributedMesh::extra_ghost_elems ( ) const
inlineinherited

Const accessor to the ghosted elements.

Definition at line 267 of file distributed_mesh.h.

267{ return _extra_ghost_elems; }

References libMesh::DistributedMesh::_extra_ghost_elems.

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

◆ find_neighbors()

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

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 955 of file unstructured_mesh.C.

958{
959 // We might actually want to run this on an empty mesh
960 // (e.g. the boundary mesh for a nonexistent bcid!)
961 // libmesh_assert_not_equal_to (this->n_nodes(), 0);
962 // libmesh_assert_not_equal_to (this->n_elem(), 0);
963
964 // This function must be run on all processors at once
965 parallel_object_only();
966
967 LOG_SCOPE("find_neighbors()", "Mesh");
968
969 //TODO:[BSK] This should be removed later?!
970 if (reset_current_list)
972 (this->element_stored_range(),
973 [reset_remote_elements](const ElemRange & range)
974 {
975 for (Elem * e : range)
976 for (auto s : e->side_index_range())
977 if (e->neighbor_ptr(s) != remote_elem || reset_remote_elements)
978 e->set_neighbor(s, nullptr);
979 });
980
981 // Find neighboring elements by first finding elements
982 // with identical side keys and then check to see if they
983 // are neighbors
984 {
985 // data structures -- Use the hash_multimap if available
986 typedef dof_id_type key_type;
987 typedef std::pair<Elem *, unsigned char> val_type;
988 typedef std::unordered_multimap<key_type, val_type> map_type;
989
990 // A map from side keys to corresponding elements & side numbers
991 map_type side_to_elem_map;
992
993 // Pull objects out of the loop to reduce heap operations
994 std::unique_ptr<Elem> my_side, their_side;
995
996 for (const auto & element : this->element_ptr_range())
997 {
998 for (auto ms : element->side_index_range())
999 {
1000 next_side:
1001 // If we haven't yet found a neighbor on this side, try.
1002 // Even if we think our neighbor is remote, that
1003 // information may be out of date.
1004 if (element->neighbor_ptr(ms) == nullptr ||
1005 element->neighbor_ptr(ms) == remote_elem)
1006 {
1007 // Get the key for the side of this element. Use the
1008 // low_order_key so we can find neighbors in
1009 // mixed-order meshes if necessary.
1010 const dof_id_type key = element->low_order_key(ms);
1011
1012 // Look for elements that have an identical side key
1013 auto bounds = side_to_elem_map.equal_range(key);
1014
1015 // May be multiple keys, check all the possible
1016 // elements which _might_ be neighbors.
1017 if (bounds.first != bounds.second)
1018 {
1019 // Get the side for this element
1020 element->side_ptr(my_side, ms);
1021
1022 // Look at all the entries with an equivalent key
1023 while (bounds.first != bounds.second)
1024 {
1025 // Get the potential element
1026 Elem * neighbor = bounds.first->second.first;
1027
1028 // Get the side for the neighboring element
1029 const unsigned int ns = bounds.first->second.second;
1030 neighbor->side_ptr(their_side, ns);
1031 //libmesh_assert(my_side.get());
1032 //libmesh_assert(their_side.get());
1033
1034 // If found a match with my side
1035 //
1036 // In 1D, since parents and children have an
1037 // equal side (i.e. a node) we need to check
1038 // for matching level() to avoid setting our
1039 // neighbor pointer to any of our neighbor's
1040 // descendants.
1041 if ((*my_side == *their_side) &&
1042 (element->level() == neighbor->level()))
1043 {
1044 // So share a side. Is this a mixed pair
1045 // of subactive and active/ancestor
1046 // elements?
1047 // If not, then we're neighbors.
1048 // If so, then the subactive's neighbor is
1049
1050 if (element->subactive() ==
1051 neighbor->subactive())
1052 {
1053 // an element is only subactive if it has
1054 // been coarsened but not deleted
1055 element->set_neighbor (ms,neighbor);
1056 neighbor->set_neighbor(ns,element);
1057 }
1058 else if (element->subactive())
1059 {
1060 element->set_neighbor(ms,neighbor);
1061 }
1062 else if (neighbor->subactive())
1063 {
1064 neighbor->set_neighbor(ns,element);
1065 }
1066 side_to_elem_map.erase (bounds.first);
1067
1068 // get out of this nested crap
1069 goto next_side;
1070 }
1071
1072 ++bounds.first;
1073 }
1074 }
1075
1076 // didn't find a match...
1077 // Build the map entry for this element
1078 side_to_elem_map.emplace
1079 (key, std::make_pair(element, cast_int<unsigned char>(ms)));
1080 }
1081 }
1082 }
1083 }
1084
1085#ifdef LIBMESH_ENABLE_PERIODIC
1086 // Get the disjoint neighbor boundary pairs object (from periodic BCs)
1087 auto * db = this->get_disjoint_neighbor_boundary_pairs();
1088
1089 if (db)
1090 {
1091 // Obtain a point locator
1092 std::unique_ptr<PointLocatorBase> point_locator = this->sub_point_locator();
1093
1094 for (const auto & element : this->element_ptr_range())
1095 {
1096 for (auto ms : element->side_index_range())
1097 {
1098 // Skip if this side already has a valid neighbor (including remote neighbors)
1099 if (element->neighbor_ptr(ms) != nullptr &&
1100 element->neighbor_ptr(ms) != remote_elem)
1101 continue;
1102
1103 for (const auto & [id, boundary_ptr] : *db)
1104 {
1105 if (!this->get_boundary_info().has_boundary_id(element, ms, id))
1106 continue;
1107
1108 unsigned int neigh_side;
1109 const Elem * neigh =
1110 db->neighbor(id, *point_locator, element, ms, &neigh_side);
1111
1112 if (neigh && neigh != remote_elem && neigh != element)
1113 {
1114 auto neigh_changeable = this->elem_ptr(neigh->id());
1115 element->set_neighbor(ms, neigh_changeable);
1116 neigh_changeable->set_neighbor(neigh_side, element);
1117 }
1118 }
1119 }
1120 }
1121 }
1122#endif // LIBMESH_ENABLE_PERIODIC
1123
1124#ifdef LIBMESH_ENABLE_AMR
1125
1153 const unsigned int n_levels = MeshTools::n_levels(*this);
1154 for (unsigned int level = 1; level < n_levels; ++level)
1155 {
1156 for (auto & current_elem : as_range(level_elements_begin(level),
1157 level_elements_end(level)))
1158 {
1159 libmesh_assert(current_elem);
1160 Elem * parent = current_elem->parent();
1161 libmesh_assert(parent);
1162 const unsigned int my_child_num = parent->which_child_am_i(current_elem);
1163
1164 for (auto s : current_elem->side_index_range())
1165 {
1166 if (current_elem->neighbor_ptr(s) == nullptr ||
1167 (current_elem->neighbor_ptr(s) == remote_elem &&
1168 parent->is_child_on_side(my_child_num, s)))
1169 {
1170 Elem * neigh = parent->neighbor_ptr(s);
1171
1172 // If neigh was refined and had non-subactive children
1173 // made remote earlier, then our current elem should
1174 // actually have one of those remote children as a
1175 // neighbor
1176 if (neigh &&
1177 (neigh->ancestor() ||
1178 // If neigh has subactive children which should have
1179 // matched as neighbors of the current element but
1180 // did not, then those likewise must be remote
1181 // children.
1182 (current_elem->subactive() && neigh->has_children() &&
1183 (neigh->level()+1) == current_elem->level())))
1184 {
1185#ifdef DEBUG
1186 // Let's make sure that "had children made remote"
1187 // situation is actually the case
1188 libmesh_assert(neigh->has_children());
1189 bool neigh_has_remote_children = false;
1190 for (auto & child : neigh->child_ref_range())
1191 if (&child == remote_elem)
1192 neigh_has_remote_children = true;
1193 libmesh_assert(neigh_has_remote_children);
1194
1195 // And let's double-check that we don't have
1196 // a remote_elem neighboring an active local element
1197 if (current_elem->active())
1198 libmesh_assert_not_equal_to (current_elem->processor_id(),
1199 this->processor_id());
1200#endif // DEBUG
1201 neigh = const_cast<RemoteElem *>(remote_elem);
1202 }
1203 // If neigh and current_elem are more than one level
1204 // apart, figuring out whether we have a remote
1205 // neighbor here becomes much harder.
1206 else if (neigh && (current_elem->subactive() &&
1207 neigh->has_children()))
1208 {
1209 // Find the deepest descendant of neigh which
1210 // we could consider for a neighbor. If we run
1211 // out of neigh children, then that's our
1212 // neighbor. If we find a potential neighbor
1213 // with remote_children and we don't find any
1214 // potential neighbors among its non-remote
1215 // children, then our neighbor must be remote.
1216 while (neigh != remote_elem &&
1217 neigh->has_children())
1218 {
1219 bool found_neigh = false;
1220 for (unsigned int c = 0, nc = neigh->n_children();
1221 !found_neigh && c != nc; ++c)
1222 {
1223 Elem * child = neigh->child_ptr(c);
1224 if (child == remote_elem)
1225 continue;
1226 for (auto ncn : child->neighbor_ptr_range())
1227 {
1228 if (ncn != remote_elem &&
1229 ncn->is_ancestor_of(current_elem))
1230 {
1231 neigh = ncn;
1232 found_neigh = true;
1233 break;
1234 }
1235 }
1236 }
1237 if (!found_neigh)
1238 neigh = const_cast<RemoteElem *>(remote_elem);
1239 }
1240 }
1241 current_elem->set_neighbor(s, neigh);
1242#ifdef DEBUG
1243 if (neigh != nullptr && neigh != remote_elem)
1244 // We ignore subactive elements here because
1245 // we don't care about neighbors of subactive element.
1246 if ((!neigh->active()) && (!current_elem->subactive()))
1247 {
1248 libMesh::err << "On processor " << this->processor_id()
1249 << std::endl;
1250 libMesh::err << "Bad element ID = " << current_elem->id()
1251 << ", Side " << s << ", Bad neighbor ID = " << neigh->id() << std::endl;
1252 libMesh::err << "Bad element proc_ID = " << current_elem->processor_id()
1253 << ", Bad neighbor proc_ID = " << neigh->processor_id() << std::endl;
1254 libMesh::err << "Bad element size = " << current_elem->hmin()
1255 << ", Bad neighbor size = " << neigh->hmin() << std::endl;
1256 libMesh::err << "Bad element center = " << current_elem->vertex_average()
1257 << ", Bad neighbor center = " << neigh->vertex_average() << std::endl;
1258 libMesh::err << "ERROR: "
1259 << (current_elem->active()?"Active":"Ancestor")
1260 << " Element at level "
1261 << current_elem->level() << std::endl;
1262 libMesh::err << "with "
1263 << (parent->active()?"active":
1264 (parent->subactive()?"subactive":"ancestor"))
1265 << " parent share "
1266 << (neigh->subactive()?"subactive":"ancestor")
1267 << " neighbor at level " << neigh->level()
1268 << std::endl;
1269 NameBasedIO(*this).write ("bad_mesh.gmv");
1270 libmesh_error_msg("Problematic mesh written to bad_mesh.gmv.");
1271 }
1272#endif // DEBUG
1273 }
1274 }
1275
1276 // We can skip to the next element if we're full-dimension
1277 // and therefore don't have any interior parents
1278 if (current_elem->dim() >= LIBMESH_DIM)
1279 continue;
1280
1281 // We have no interior parents unless we can find one later
1282 current_elem->set_interior_parent(nullptr);
1283
1284 Elem * pip = parent->interior_parent();
1285
1286 if (!pip)
1287 continue;
1288
1289 // If there's no interior_parent children, whether due to a
1290 // remote element or a non-conformity, then there's no
1291 // children to search.
1292 if (pip == remote_elem || pip->active())
1293 {
1294 current_elem->set_interior_parent(pip);
1295 continue;
1296 }
1297
1298 // For node comparisons we'll need a sensible tolerance
1299 Real node_tolerance = current_elem->hmin() * TOLERANCE;
1300
1301 // Otherwise our interior_parent should be a child of our
1302 // parent's interior_parent.
1303 for (auto & child : pip->child_ref_range())
1304 {
1305 // If we have a remote_elem, that might be our
1306 // interior_parent. We'll set it provisionally now and
1307 // keep trying to find something better.
1308 if (&child == remote_elem)
1309 {
1310 current_elem->set_interior_parent
1311 (const_cast<RemoteElem *>(remote_elem));
1312 continue;
1313 }
1314
1315 bool child_contains_our_nodes = true;
1316 for (auto & n : current_elem->node_ref_range())
1317 {
1318 bool child_contains_this_node = false;
1319 for (auto & cn : child.node_ref_range())
1321 (n, node_tolerance))
1322 {
1323 child_contains_this_node = true;
1324 break;
1325 }
1326 if (!child_contains_this_node)
1327 {
1328 child_contains_our_nodes = false;
1329 break;
1330 }
1331 }
1332 if (child_contains_our_nodes)
1333 {
1334 current_elem->set_interior_parent(&child);
1335 break;
1336 }
1337 }
1338
1339 // We should have found *some* interior_parent at this
1340 // point, whether semilocal or remote.
1341 libmesh_assert(current_elem->interior_parent());
1342 }
1343 }
1344#endif // AMR
1345
1346#ifdef DEBUG
1347 if (assert_valid)
1348 {
1350 !reset_remote_elements);
1352 }
1353#else
1354 libmesh_ignore(assert_valid);
1355#endif
1356
1357 this->_preparation.has_neighbor_ptrs = true;
1358}
processor_id_type processor_id() const
Definition dof_object.h:881
virtual bool is_child_on_side(const unsigned int c, const unsigned int s) const =0
bool active() const
Definition elem.h:2958
bool is_ancestor_of(const Elem *descendant) const
Definition elem.h:3026
bool has_children() const
Definition elem.h:2996
virtual std::unique_ptr< Elem > side_ptr(unsigned int i)=0
bool ancestor() const
Definition elem.C:2019
void set_interior_parent(Elem *p)
Sets the pointer to the element's interior_parent.
Definition elem.C:1222
unsigned int which_child_am_i(const Elem *e) const
Definition elem.h:3209
virtual Real hmin() const
Definition elem.C:683
unsigned int level() const
Definition elem.h:3091
virtual unsigned int n_children() const =0
const Elem * interior_parent() const
Definition elem.C:1160
bool subactive() const
Definition elem.h:2976
Point vertex_average() const
Definition elem.C:669
PeriodicBoundaries * get_disjoint_neighbor_boundary_pairs()
Definition mesh_base.C:2296
std::unique_ptr< PointLocatorBase > sub_point_locator() const
Definition mesh_base.C:1833
This class supports simple reads and writes in any libMesh-supported format, by dispatching to one of...
virtual void write(const std::string &mesh_file) override
This method implements writing a mesh to a specified file.
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...
unsigned int n_levels(const MeshBase &mesh)
Definition mesh_tools.C:826
OStreamProxy err
bool absolute_fuzzy_equals(const T &var1, const T2 &var2, const Real tol=TOLERANCE *TOLERANCE)
Function to check whether two variables are equal within an absolute tolerance.
void libmesh_ignore(const Args &...)

References libMesh::MeshBase::_preparation, libMesh::Elem::active(), libMesh::Elem::ancestor(), libMesh::as_range(), libMesh::Elem::child_ptr(), libMesh::Elem::child_ref_range(), libMesh::MeshBase::elem_ptr(), libMesh::MeshBase::element_stored_range(), libMesh::err, libMesh::MeshBase::get_boundary_info(), libMesh::MeshBase::get_disjoint_neighbor_boundary_pairs(), libMesh::BoundaryInfo::has_boundary_id(), libMesh::Elem::has_children(), libMesh::MeshBase::Preparation::has_neighbor_ptrs, 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::libmesh_ignore(), libMesh::Elem::n_children(), libMesh::MeshTools::n_levels(), libMesh::Elem::neighbor_ptr(), libMesh::Elem::neighbor_ptr_range(), libMesh::Threads::parallel_for(), libMesh::Elem::parent(), libMesh::DofObject::processor_id(), libMesh::ParallelObject::processor_id(), libMesh::Real, libMesh::remote_elem, libMesh::Elem::set_interior_parent(), libMesh::Elem::set_neighbor(), libMesh::Elem::side_ptr(), libMesh::MeshBase::sub_point_locator(), 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(), libMesh::MeshTetInterface::improve_hull_integrity(), libMesh::Poly2TriTriangulator::insert_refinement_points(), libMesh::UnstructuredMesh::stitching_helper(), libMesh::NetGenMeshInterface::triangulate(), and libMesh::TriangleInterface::triangulate().

◆ fix_broken_node_and_element_numbering()

void libMesh::DistributedMesh::fix_broken_node_and_element_numbering ( )
overridevirtualinherited

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.

Implements libMesh::MeshBase.

Definition at line 1676 of file distributed_mesh.C.

1677{
1678 // We can't use range-for here because we need access to the special
1679 // iterators' methods, not just to their dereferenced values.
1680
1681 // Nodes first
1682 for (auto pr = this->_nodes.begin(),
1683 end = this->_nodes.end(); pr != end; ++pr)
1684 {
1685 Node * n = *pr;
1686 if (n != nullptr)
1687 {
1688 const dof_id_type id = pr.index();
1689 n->set_id() = id;
1690 libmesh_assert_equal_to(this->node_ptr(id), n);
1691 }
1692 }
1693
1694 // Elements next
1695 for (auto pr = this->_elements.begin(),
1696 end = this->_elements.end(); pr != end; ++pr)
1697 {
1698 Elem * e = *pr;
1699 if (e != nullptr)
1700 {
1701 const dof_id_type id = pr.index();
1702 e->set_id() = id;
1703 libmesh_assert_equal_to(this->elem_ptr(id), e);
1704 }
1705 }
1706}
virtual const Elem * elem_ptr(const dof_id_type i) const override final
virtual const Node * node_ptr(const dof_id_type i) const override final

References libMesh::DistributedMesh::_elements, libMesh::DistributedMesh::_nodes, libMesh::DistributedMesh::elem_ptr(), libMesh::DistributedMesh::node_ptr(), and libMesh::DofObject::set_id().

◆ gather_to_zero()

void libMesh::DistributedMesh::gather_to_zero ( )
overridevirtualinherited

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

Reimplemented from libMesh::MeshBase.

Definition at line 1858 of file distributed_mesh.C.

1859{
1861 return;
1862
1863 _is_serial_on_proc_0 = true;
1864 MeshCommunication().gather(0, *this);
1865}

References libMesh::DistributedMesh::_is_serial_on_proc_0, and libMesh::MeshCommunication::gather().

◆ get_boundary_info() [1/2]

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

Writable information about boundary ids on the mesh.

Definition at line 175 of file mesh_base.h.

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

References libMesh::MeshBase::boundary_info.

◆ get_boundary_info() [2/2]

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

The information about boundary ids on the mesh.

Definition at line 170 of file mesh_base.h.

170{ return *boundary_info; }

References libMesh::MeshBase::boundary_info.

Referenced by libMesh::MeshTools::Subdivision::add_boundary_ghosts(), libMesh::UnstructuredMesh::all_first_order(), libMesh::MeshTools::Subdivision::all_subdivision(), libMesh::MeshTools::Modification::all_tri(), LinearElasticity::assemble(), assemble_elasticity(), assemble_poisson(), assemble_shell(), assemble_temperature_jump(), libMesh::AbaqusIO::assign_boundary_node_ids(), libMesh::AbaqusIO::assign_sideset_ids(), AssemblyF0::boundary_assembly(), AssemblyF1::boundary_assembly(), AssemblyF2::boundary_assembly(), AssemblyA0::boundary_assembly(), AssemblyA1::boundary_assembly(), AssemblyA2::boundary_assembly(), libMesh::MeshTools::Generation::build_cube(), libMesh::MeshTools::Generation::build_delaunay_square(), libMesh::MeshTools::Generation::build_extrusion(), DisjointNeighborTest::build_four_disjoint_elems(), DisjointNeighborTest::build_split_mesh_with_interface(), DisjointNeighborTest::build_two_disjoint_elems(), libMesh::MeshTools::Modification::change_boundary_id(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::MeshBase::complete_preparation(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::FEGenericBase< OutputType >::compute_periodic_constraints(), libMesh::TriangleWrapper::copy_tri_to_mesh(), libMesh::UnstructuredMesh::create_submesh(), libMesh::MeshTetInterface::delete_2D_hull_elements(), libMesh::DistributedMesh::delete_elem(), libMesh::ReplicatedMesh::delete_elem(), libMesh::DistributedMesh::delete_node(), libMesh::ReplicatedMesh::delete_node(), libMesh::DistributedMesh::delete_remote_elements(), libMesh::DistributedMesh::DistributedMesh(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::MeshTools::Modification::flatten(), libMesh::MeshBase::get_info(), AssemblyPointLoadX::get_nodal_rhs_values(), AssemblyPointLoadY::get_nodal_rhs_values(), AssemblyPointLoadZ::get_nodal_rhs_values(), libMesh::UNVIO::groups_in(), libMesh::MeshTetInterface::improve_hull_integrity(), libMesh::HDGProblem::init(), ElasticitySystem::init_data(), libMesh::ExodusII_IO_Helper::initialize(), LinearElasticityWithContact::initialize_contact_load_paths(), libMesh::Poly2TriTriangulator::insert_refinement_points(), libMesh::MeshTools::Modification::interpolate_surface(), libMesh::HDGProblem::jacobian(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), main(), AugmentSparsityOnInterface::mesh_reinit(), libMesh::TriangulatorInterface::MeshedHole::MeshedHole(), libMesh::PeriodicBoundaries::neighbor(), libMesh::MeshTools::Modification::orient_elements(), libMesh::TetGenMeshInterface::pointset_convexhull(), libMesh::Nemesis_IO::prepare_to_write_nodal_data(), libMesh::Nemesis_IO::read(), libMesh::AbaqusIO::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(), libMesh::SimplexRefiner::refine_via_edges(), MeshStitchTest::renameAndShift(), libMesh::DistributedMesh::renumber_nodes_and_elements(), libMesh::ReplicatedMesh::renumber_nodes_and_elements(), libMesh::ReplicatedMesh::ReplicatedMesh(), libMesh::HDGProblem::residual(), libMesh::RBEIMEvaluation::side_distribute_bfs(), libMesh::PetscDiffSolver::solve(), libMesh::UnstructuredMesh::stitching_helper(), libMesh::MeshTools::Generation::surface_octahedron(), libMesh::BoundaryInfo::sync(), AllTriTest::test_helper(), AllTriTest::test_helper_c0polyhedron(), ExodusC0PolyhedronTest::test_write_cube_header(), AllTriTest::testAllTriC0Polygon(), AllTriTest::testAllTriC0PolygonOctagon(), MeshTetTest::testBcids(), BoundaryInfoTest::testBoundaryIDs(), BoundaryInfoTest::testBoundaryOnChildrenBoundaryIDs(), BoundaryInfoTest::testBoundaryOnChildrenBoundarySides(), BoundaryInfoTest::testBoundaryOnChildrenElementsRefineCoarsen(), BoundaryInfoTest::testBoundaryOnChildrenErrors(), SystemsTest::testBoundaryProjectCube(), BoundaryInfoTest::testBuildNodeListFromSideList(), BoundaryInfoTest::testBuildSideListFromNodeList(), VolumeTest::testC0PolygonMethods(), BoundaryMeshSubdomainTest::testDefaultSubdomain(), DisjointNeighborTest::testDisjointNeighborConflictError(), BoundaryInfoTest::testEdgeBoundaryConditions(), MeshInputTest::testExodusIGASidesets(), MeshInputTest::testGmshBCIDOverlap(), BoundaryInfoTest::testInternalBoundary(), MeshInputTest::testLowOrderEdgeBlocks(), BoundaryInfoTest::testMesh(), BoundaryInfoTest::testNameCopying(), BoundaryMeshSubdomainTest::testPerBoundarySubdomain(), PeriodicBCTest::testPeriodicBC(), MeshTriangulationTest::testPoly2TriHolesInteriorRefinedBase(), BoundaryInfoTest::testRenumber(), BoundaryInfoTest::testSelectiveRenumber(), BoundaryInfoTest::testShellFaceConstraints(), BoundaryMeshSubdomainTest::testSingleSubdomain(), DisjointNeighborTest::testStitchCrossMesh(), MeshTetTest::testTrisToTets(), MeshSmootherTest::testVariationalSmoother(), WriteEdgesetData::testWriteImpl(), WriteNodesetData::testWriteImpl(), WriteSidesetData::testWriteImpl(), libMesh::NetGenMeshInterface::triangulate(), libMesh::Poly2TriTriangulator::triangulate_current_points(), libMesh::Parallel::Packing< Elem * >::unpack(), libMesh::Parallel::Packing< Node * >::unpack(), libMesh::MeshTetInterface::volume_to_surface_mesh(), libMesh::FroIO::write(), libMesh::XdrIO::write(), libMesh::Nemesis_IO::write(), libMesh::ExodusII_IO::write(), libMesh::CheckpointIO::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().

◆ 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 1938 of file mesh_base.h.

1939 { return _constraint_rows; }

References libMesh::MeshBase::_constraint_rows.

◆ 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 1880 of file mesh_base.C.

1881{
1883}
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:2231

References libMesh::MeshBase::_count_lower_dim_elems_in_point_locator.

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

◆ get_disjoint_neighbor_boundary_pairs() [1/2]

PeriodicBoundaries * libMesh::MeshBase::get_disjoint_neighbor_boundary_pairs ( )
inherited

◆ get_disjoint_neighbor_boundary_pairs() [2/2]

const PeriodicBoundaries * libMesh::MeshBase::get_disjoint_neighbor_boundary_pairs ( ) const
inherited

Definition at line 2301 of file mesh_base.C.

2302 {
2304 }

References libMesh::MeshBase::_disjoint_neighbor_boundary_pairs.

◆ get_elem_integer_index()

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

Definition at line 689 of file mesh_base.C.

690{
691 for (auto i : index_range(_elem_integer_names))
693 return i;
694
695 libmesh_error_msg("Unknown elem integer " << name);
697}
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:303

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

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

◆ get_elem_integer_name()

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

Definition at line 1079 of file mesh_base.h.

1080 { return _elem_integer_names[i]; }

References libMesh::MeshBase::_elem_integer_names.

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

◆ get_elemset_code()

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

Definition at line 497 of file mesh_base.C.

498{
499 auto it = _elemset_codes_inverse_map.find(id_set);
500 return (it == _elemset_codes_inverse_map.end()) ? DofObject::invalid_id : it->second;
501}

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

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

◆ 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 503 of file mesh_base.C.

504{
505 std::vector<dof_id_type> ret;
506 ret.reserve(_elemset_codes.size());
507 for (const auto & pr : _elemset_codes)
508 ret.push_back(pr.first);
509 return ret;
510}

References libMesh::MeshBase::_elemset_codes.

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

◆ 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 487 of file mesh_base.C.

488{
489 // If we don't recognize this elemset_code, hand back an empty set
490 id_set_to_fill.clear();
491
492 if (const auto it = _elemset_codes.find(elemset_code);
493 it != _elemset_codes.end())
494 id_set_to_fill.insert(it->second->begin(), it->second->end());
495}

References libMesh::MeshBase::_elemset_codes.

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

◆ 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 1926 of file mesh_base.C.

1927{
1928 // Linear search over the map values.
1929 for (const auto & [sbd_id, sbd_name] : _block_id_to_name)
1930 if (sbd_name == name)
1931 return sbd_id;
1932
1933 // If we made it here without returning, we don't have a subdomain
1934 // with the requested name, so return Elem::invalid_subdomain_id.
1936}
static constexpr subdomain_id_type invalid_subdomain_id
A static integral constant representing an invalid subdomain id.
Definition elem.h:246
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:2308

References libMesh::MeshBase::_block_id_to_name, and libMesh::Elem::invalid_subdomain_id.

◆ 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 1275 of file mesh_base.C.

1276{
1277 std::ostringstream oss;
1278
1279 oss << " Mesh Information:" << '\n';
1280
1281 if (!_elem_dims.empty())
1282 {
1283 oss << " elem_dimensions()={";
1284 std::copy(_elem_dims.begin(),
1285 --_elem_dims.end(), // --end() is valid if the set is non-empty
1286 std::ostream_iterator<unsigned int>(oss, ", "));
1287 oss << cast_int<unsigned int>(*_elem_dims.rbegin());
1288 oss << "}\n";
1289 }
1290
1291 if (!_elem_default_orders.empty())
1292 {
1293 oss << " elem_default_orders()={";
1294 std::transform(_elem_default_orders.begin(),
1295 --_elem_default_orders.end(),
1296 std::ostream_iterator<std::string>(oss, ", "),
1297 [](Order o)
1298 { return Utility::enum_to_string<Order>(o); });
1299 oss << Utility::enum_to_string<Order>(*_elem_default_orders.rbegin());
1300 oss << "}\n";
1301 }
1302
1303 oss << " supported_nodal_order()=" << this->supported_nodal_order() << '\n'
1304 << " spatial_dimension()=" << this->spatial_dimension() << '\n'
1305 << " n_nodes()=" << this->n_nodes() << '\n'
1306 << " n_local_nodes()=" << this->n_local_nodes() << '\n'
1307 << " n_elem()=" << this->n_elem() << '\n'
1308 << " n_local_elem()=" << this->n_local_elem() << '\n';
1309#ifdef LIBMESH_ENABLE_AMR
1310 oss << " n_active_elem()=" << this->n_active_elem() << '\n';
1311#endif
1312 if (global)
1313 oss << " n_subdomains()=" << static_cast<std::size_t>(this->n_subdomains()) << '\n';
1314 else
1315 oss << " n_local_subdomains()= " << static_cast<std::size_t>(this->n_local_subdomains()) << '\n';
1316 oss << " n_elemsets()=" << static_cast<std::size_t>(this->n_elemsets()) << '\n';
1317 if (!_elemset_codes.empty())
1318 oss << " n_elemset_codes=" << _elemset_codes.size() << '\n';
1319 oss << " n_partitions()=" << static_cast<std::size_t>(this->n_partitions()) << '\n'
1320 << " n_processors()=" << static_cast<std::size_t>(this->n_processors()) << '\n'
1321 << " n_threads()=" << static_cast<std::size_t>(libMesh::n_threads()) << '\n'
1322 << " processor_id()=" << static_cast<std::size_t>(this->processor_id()) << '\n'
1323 << " is_prepared()=" << (this->is_prepared() ? "true" : "false") << '\n'
1324 << " is_replicated()=" << (this->is_replicated() ? "true" : "false") << '\n';
1325
1326 if (verbosity > 0)
1327 {
1328 if (global)
1329 {
1330 libmesh_parallel_only(this->comm());
1331 if (this->processor_id() != 0)
1332 oss << "\n Detailed global get_info() (verbosity > 0) is reduced and output to only rank 0.";
1333 }
1334
1335 // Helper for printing element types
1336 const auto elem_type_helper = [](const std::set<int> & elem_types) {
1337 std::stringstream ss;
1338 for (auto it = elem_types.begin(); it != elem_types.end();)
1339 {
1341 if (++it != elem_types.end())
1342 ss << ", ";
1343 }
1344 return ss.str();
1345 };
1346
1347 // Helper for whether or not the given DofObject is to be included. If we're doing
1348 // a global reduction, we also count unpartitioned objects on rank 0.
1349 const auto include_object = [this, &global](const DofObject & dof_object) {
1350 return this->processor_id() == dof_object.processor_id() ||
1351 (global &&
1352 this->processor_id() == 0 &&
1353 dof_object.processor_id() == DofObject::invalid_processor_id);
1354 };
1355
1356 Real volume = 0;
1357
1358 // Add bounding box information
1359 const auto bbox = global ? MeshTools::create_bounding_box(*this) : MeshTools::create_local_bounding_box(*this);
1360 if (!global || this->processor_id() == 0)
1361 oss << "\n " << (global ? "" : "Local ") << "Mesh Bounding Box:\n"
1362 << " Minimum: " << bbox.min() << "\n"
1363 << " Maximum: " << bbox.max() << "\n"
1364 << " Delta: " << (bbox.max() - bbox.min()) << "\n";
1365
1366 // Obtain the global or local element types
1367 std::set<int> elem_types;
1368 for (const Elem * elem : this->active_local_element_ptr_range())
1369 elem_types.insert(elem->type());
1370 if (global)
1371 {
1372 // Pick up unpartitioned elems on rank 0
1373 if (this->processor_id() == 0)
1374 for (const Elem * elem : this->active_unpartitioned_element_ptr_range())
1375 elem_types.insert(elem->type());
1376
1377 this->comm().set_union(elem_types);
1378 }
1379
1380 // Add element types
1381 if (!global || this->processor_id() == 0)
1382 oss << "\n " << (global ? "" : "Local ") << "Mesh Element Type(s):\n "
1383 << elem_type_helper(elem_types) << "\n";
1384
1385 // Reduce the nodeset ids
1386 auto nodeset_ids = this->get_boundary_info().get_node_boundary_ids();
1387 if (global)
1388 this->comm().set_union(nodeset_ids);
1389
1390 // Accumulate local information for each nodeset
1391 struct NodesetInfo
1392 {
1393 std::size_t num_nodes = 0;
1394 BoundingBox bbox;
1395 };
1396 std::map<boundary_id_type, NodesetInfo> nodeset_info_map;
1397 for (const auto & [node, id] : this->get_boundary_info().get_nodeset_map())
1398 {
1399 if (!include_object(*node))
1400 continue;
1401
1402 NodesetInfo & info = nodeset_info_map[id];
1403
1404 ++info.num_nodes;
1405
1406 if (verbosity > 1)
1407 info.bbox.union_with(*node);
1408 }
1409
1410 // Add nodeset info
1411 if (!global || this->processor_id() == 0)
1412 {
1413 oss << "\n " << (global ? "" : "Local ") << "Mesh Nodesets:\n";
1414 if (nodeset_ids.empty())
1415 oss << " None\n";
1416 }
1417
1418 const auto & nodeset_name_map = this->get_boundary_info().get_nodeset_name_map();
1419 for (const auto id : nodeset_ids)
1420 {
1421 NodesetInfo & info = nodeset_info_map[id];
1422
1423 // Reduce the local information for this nodeset if required
1424 if (global)
1425 {
1426 this->comm().sum(info.num_nodes);
1427 if (verbosity > 1)
1428 {
1429 this->comm().min(info.bbox.min());
1430 this->comm().max(info.bbox.max());
1431 }
1432 }
1433
1434 const bool has_name = nodeset_name_map.count(id) && nodeset_name_map.at(id).size();
1435 const std::string name = has_name ? nodeset_name_map.at(id) : "";
1436 if (global)
1437 libmesh_assert(this->comm().verify(name));
1438
1439 if (global ? this->processor_id() == 0 : info.num_nodes > 0)
1440 {
1441 oss << " Nodeset " << id;
1442 if (has_name)
1443 oss << " (" << name << ")";
1444 oss << ", " << info.num_nodes << " " << (global ? "" : "local ") << "nodes\n";
1445
1446 if (verbosity > 1)
1447 {
1448 oss << " " << (global ? "Bounding" : "Local bounding") << " box minimum: "
1449 << info.bbox.min() << "\n"
1450 << " " << (global ? "Bounding" : "Local bounding") << " box maximum: "
1451 << info.bbox.max() << "\n"
1452 << " " << (global ? "Bounding" : "Local bounding") << " box delta: "
1453 << (info.bbox.max() - info.bbox.min()) << "\n";
1454 }
1455 }
1456 }
1457
1458 // Reduce the sideset ids
1459 auto sideset_ids = this->get_boundary_info().get_side_boundary_ids();
1460 if (global)
1461 this->comm().set_union(sideset_ids);
1462
1463 // Accumulate local information for each sideset
1464 struct SidesetInfo
1465 {
1466 std::size_t num_sides = 0;
1467 Real volume = 0;
1468 std::set<int> side_elem_types;
1469 std::set<int> elem_types;
1470 std::set<dof_id_type> elem_ids;
1471 std::set<dof_id_type> node_ids;
1472 BoundingBox bbox;
1473 };
1474 ElemSideBuilder side_builder;
1475 std::map<boundary_id_type, SidesetInfo> sideset_info_map;
1476 for (const auto & pair : this->get_boundary_info().get_sideset_map())
1477 {
1478 const Elem * elem = pair.first;
1479 if (!include_object(*elem))
1480 continue;
1481
1482 const auto id = pair.second.second;
1483 SidesetInfo & info = sideset_info_map[id];
1484
1485 const auto s = pair.second.first;
1486 const Elem & side = side_builder(*elem, s);
1487
1488 ++info.num_sides;
1489 info.side_elem_types.insert(side.type());
1490 info.elem_types.insert(elem->type());
1491 info.elem_ids.insert(elem->id());
1492
1493 for (const Node & node : side.node_ref_range())
1494 if (include_object(node))
1495 info.node_ids.insert(node.id());
1496
1497 if (verbosity > 1)
1498 {
1499 info.volume += side.volume();
1500 info.bbox.union_with(side.loose_bounding_box());
1501 }
1502 }
1503
1504 // Add sideset info
1505 if (!global || this->processor_id() == 0)
1506 {
1507 oss << "\n " << (global ? "" : "Local ") << "Mesh Sidesets:\n";
1508 if (sideset_ids.empty())
1509 oss << " None\n";
1510 }
1511 const auto & sideset_name_map = this->get_boundary_info().get_sideset_name_map();
1512 for (const auto id : sideset_ids)
1513 {
1514 SidesetInfo & info = sideset_info_map[id];
1515
1516 auto num_elems = info.elem_ids.size();
1517 auto num_nodes = info.node_ids.size();
1518
1519 // Reduce the local information for this sideset if required
1520 if (global)
1521 {
1522 this->comm().sum(info.num_sides);
1523 this->comm().set_union(info.side_elem_types, 0);
1524 this->comm().sum(num_elems);
1525 this->comm().set_union(info.elem_types, 0);
1526 this->comm().sum(num_nodes);
1527 if (verbosity > 1)
1528 {
1529 this->comm().sum(info.volume);
1530 this->comm().min(info.bbox.min());
1531 this->comm().max(info.bbox.max());
1532 }
1533 }
1534
1535 const bool has_name = sideset_name_map.count(id) && sideset_name_map.at(id).size();
1536 const std::string name = has_name ? sideset_name_map.at(id) : "";
1537 if (global)
1538 libmesh_assert(this->comm().verify(name));
1539
1540 if (global ? this->processor_id() == 0 : info.num_sides > 0)
1541 {
1542 oss << " Sideset " << id;
1543 if (has_name)
1544 oss << " (" << name << ")";
1545 oss << ", " << info.num_sides << " sides (" << elem_type_helper(info.side_elem_types) << ")"
1546 << ", " << num_elems << " " << (global ? "" : "local ") << "elems (" << elem_type_helper(info.elem_types) << ")"
1547 << ", " << num_nodes << " " << (global ? "" : "local ") << "nodes\n";
1548
1549 if (verbosity > 1)
1550 {
1551 oss << " " << (global ? "Side" : "Local side") << " volume: " << info.volume << "\n"
1552 << " " << (global ? "Bounding" : "Local bounding") << " box minimum: "
1553 << info.bbox.min() << "\n"
1554 << " " << (global ? "Bounding" : "Local bounding") << " box maximum: "
1555 << info.bbox.max() << "\n"
1556 << " " << (global ? "Bounding" : "Local bounding") << " box delta: "
1557 << (info.bbox.max() - info.bbox.min()) << "\n";
1558 }
1559 }
1560 }
1561
1562 // Reduce the edgeset ids
1563 auto edgeset_ids = this->get_boundary_info().get_edge_boundary_ids();
1564 if (global)
1565 this->comm().set_union(edgeset_ids);
1566
1567 // Accumulate local information for each edgeset
1568 struct EdgesetInfo
1569 {
1570 std::size_t num_edges = 0;
1571 std::set<int> edge_elem_types;
1572 BoundingBox bbox;
1573 };
1574 std::map<boundary_id_type, EdgesetInfo> edgeset_info_map;
1575 std::unique_ptr<const Elem> edge;
1576
1577 for (const auto & pair : this->get_boundary_info().get_edgeset_map())
1578 {
1579 const Elem * elem = pair.first;
1580 if (!include_object(*elem))
1581 continue;
1582
1583 const auto id = pair.second.second;
1584 EdgesetInfo & info = edgeset_info_map[id];
1585
1586 elem->build_edge_ptr(edge, pair.second.first);
1587
1588 ++info.num_edges;
1589 info.edge_elem_types.insert(edge->type());
1590
1591 if (verbosity > 1)
1592 info.bbox.union_with(edge->loose_bounding_box());
1593 }
1594
1595 // Add edgeset info
1596 if (!global || this->processor_id() == 0)
1597 {
1598 oss << "\n " << (global ? "" : "Local ") << "Mesh Edgesets:\n";
1599 if (edgeset_ids.empty())
1600 oss << " None\n";
1601 }
1602
1603 const auto & edgeset_name_map = this->get_boundary_info().get_edgeset_name_map();
1604 for (const auto id : edgeset_ids)
1605 {
1606 EdgesetInfo & info = edgeset_info_map[id];
1607
1608 // Reduce the local information for this edgeset if required
1609 if (global)
1610 {
1611 this->comm().sum(info.num_edges);
1612 this->comm().set_union(info.edge_elem_types, 0);
1613 if (verbosity > 1)
1614 {
1615 this->comm().min(info.bbox.min());
1616 this->comm().min(info.bbox.max());
1617 }
1618 }
1619
1620 const bool has_name = edgeset_name_map.count(id) && edgeset_name_map.at(id).size();
1621 const std::string name = has_name ? edgeset_name_map.at(id) : "";
1622 if (global)
1623 libmesh_assert(this->comm().verify(name));
1624
1625 if (global ? this->processor_id() == 0 : info.num_edges > 0)
1626 {
1627 oss << " Edgeset " << id;
1628 if (has_name)
1629 oss << " (" << name << ")";
1630 oss << ", " << info.num_edges << " " << (global ? "" : "local ") << "edges ("
1631 << elem_type_helper(info.edge_elem_types) << ")\n";
1632
1633 if (verbosity > 1)
1634 {
1635 oss << " " << (global ? "Bounding" : "Local bounding") << " box minimum: "
1636 << info.bbox.min() << "\n"
1637 << " " << (global ? "Bounding" : "Local bounding") << " box maximum: "
1638 << info.bbox.max() << "\n"
1639 << " " << (global ? "Bounding" : "Local bounding") << " box delta: "
1640 << (info.bbox.max() - info.bbox.min()) << "\n";
1641 }
1642 }
1643 }
1644
1645 // Reduce the block IDs and block names
1646 std::set<subdomain_id_type> subdomains;
1647 for (const Elem * elem : this->active_element_ptr_range())
1648 if (include_object(*elem))
1649 subdomains.insert(elem->subdomain_id());
1650 if (global)
1651 this->comm().set_union(subdomains);
1652
1653 // Accumulate local information for each subdomain
1654 struct SubdomainInfo
1655 {
1656 std::size_t num_elems = 0;
1657 Real volume = 0;
1658 std::set<int> elem_types;
1659 std::set<dof_id_type> active_node_ids;
1660#ifdef LIBMESH_ENABLE_AMR
1661 std::size_t num_active_elems = 0;
1662#endif
1663 BoundingBox bbox;
1664 };
1665 std::map<subdomain_id_type, SubdomainInfo> subdomain_info_map;
1666 for (const Elem * elem : this->element_ptr_range())
1667 if (include_object(*elem))
1668 {
1669 SubdomainInfo & info = subdomain_info_map[elem->subdomain_id()];
1670
1671 ++info.num_elems;
1672 info.elem_types.insert(elem->type());
1673
1674#ifdef LIBMESH_ENABLE_AMR
1675 if (elem->active())
1676 ++info.num_active_elems;
1677#endif
1678
1679 for (const Node & node : elem->node_ref_range())
1680 if (include_object(node) && node.active())
1681 info.active_node_ids.insert(node.id());
1682
1683 if (verbosity > 1 && elem->active())
1684 {
1685 info.volume += elem->volume();
1686 info.bbox.union_with(elem->loose_bounding_box());
1687 }
1688 }
1689
1690 // Add subdomain info
1691 oss << "\n " << (global ? "" : "Local ") << "Mesh Subdomains:\n";
1692 const auto & subdomain_name_map = this->get_subdomain_name_map();
1693 for (const auto id : subdomains)
1694 {
1695 SubdomainInfo & info = subdomain_info_map[id];
1696
1697 auto num_active_nodes = info.active_node_ids.size();
1698
1699 // Reduce the information for this subdomain if needed
1700 if (global)
1701 {
1702 this->comm().sum(info.num_elems);
1703#ifdef LIBMESH_ENABLE_AMR
1704 this->comm().sum(info.num_active_elems);
1705#endif
1706 this->comm().sum(num_active_nodes);
1707 this->comm().set_union(info.elem_types, 0);
1708 if (verbosity > 1)
1709 {
1710 this->comm().min(info.bbox.min());
1711 this->comm().max(info.bbox.max());
1712 this->comm().sum(info.volume);
1713 }
1714 }
1715 if (verbosity > 1)
1716 volume += info.volume;
1717
1718 const bool has_name = subdomain_name_map.count(id);
1719 const std::string name = has_name ? subdomain_name_map.at(id) : "";
1720 if (global)
1721 libmesh_assert(this->comm().verify(name));
1722
1723 if (!global || this->processor_id() == 0)
1724 {
1725 oss << " Subdomain " << id;
1726 if (has_name)
1727 oss << " (" << name << ")";
1728 oss << ": " << info.num_elems << " " << (global ? "" : "local ") << "elems "
1729 << "(" << elem_type_helper(info.elem_types);
1730#ifdef LIBMESH_ENABLE_AMR
1731 oss << ", " << info.num_active_elems << " active";
1732#endif
1733 oss << "), " << num_active_nodes << " " << (global ? "" : "local ") << "active nodes\n";
1734 if (verbosity > 1)
1735 {
1736 oss << " " << (global ? "Volume" : "Local volume") << ": " << info.volume << "\n";
1737 oss << " " << (global ? "Bounding" : "Local bounding") << " box minimum: "
1738 << info.bbox.min() << "\n"
1739 << " " << (global ? "Bounding" : "Local bounding") << " box maximum: "
1740 << info.bbox.max() << "\n"
1741 << " " << (global ? "Bounding" : "Local bounding") << " box delta: "
1742 << (info.bbox.max() - info.bbox.min()) << "\n";
1743 }
1744 }
1745 }
1746
1747 oss << " " << (global ? "Global" : "Local") << " mesh volume = " << volume << "\n";
1748
1749 }
1750
1751 return oss.str();
1752}
void max(const T &r, T &o, Request &req) const
const std::set< boundary_id_type > & get_edge_boundary_ids() const
const std::set< boundary_id_type > & get_node_boundary_ids() const
const std::set< boundary_id_type > & get_side_boundary_ids() const
const std::map< boundary_id_type, std::string > & get_edgeset_name_map() const
const std::map< boundary_id_type, std::string > & get_nodeset_name_map() const
const std::map< boundary_id_type, std::string > & get_sideset_name_map() const
const Point & min() const
virtual bool is_replicated() const
Definition mesh_base.h:379
Order supported_nodal_order() const
Definition mesh_base.h:445
unsigned int spatial_dimension() const
Definition mesh_base.C:606
const std::map< subdomain_id_type, std::string > & get_subdomain_name_map() const
Definition mesh_base.h:1926
subdomain_id_type n_local_subdomains() const
Definition mesh_base.C:1204
dof_id_type n_local_elem() const
Definition mesh_base.h:697
dof_id_type n_local_nodes() const
Definition mesh_base.h:591
unsigned int n_elemsets() const
Returns the number of unique elemset ids which have been added via add_elemset_code(),...
Definition mesh_base.C:482
virtual dof_id_type n_active_elem() const =0
subdomain_id_type n_subdomains() const
Definition mesh_base.C:1190
MPI_Info info
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:723
Real volume(const MeshBase &mesh, unsigned int dim=libMesh::invalid_uint)
Find the total volume of a mesh (interpreting that as area for dim = 2, or total arc length for dim =...
libMesh::BoundingBox create_bounding_box(const MeshBase &mesh)
Definition mesh_tools.C:566
libMesh::BoundingBox create_local_bounding_box(const MeshBase &mesh)
Definition mesh_tools.C:631
std::string enum_to_string(const T e)
unsigned int n_threads()

References libMesh::MeshBase::_elem_default_orders, 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::Utility::enum_to_string(), libMesh::MeshBase::get_boundary_info(), libMesh::BoundaryInfo::get_edge_boundary_ids(), libMesh::BoundaryInfo::get_edgeset_map(), libMesh::BoundaryInfo::get_edgeset_name_map(), libMesh::BoundaryInfo::get_node_boundary_ids(), libMesh::BoundaryInfo::get_nodeset_map(), libMesh::BoundaryInfo::get_nodeset_name_map(), libMesh::BoundaryInfo::get_side_boundary_ids(), libMesh::BoundaryInfo::get_sideset_map(), 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(), libMesh::Parallel::Communicator::max(), libMesh::Parallel::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::Elem::node_ref_range(), libMesh::ParallelObject::processor_id(), libMesh::Real, libMesh::Parallel::Communicator::set_union(), libMesh::MeshBase::spatial_dimension(), libMesh::Parallel::Communicator::sum(), libMesh::MeshBase::supported_nodal_order(), libMesh::Elem::type(), and libMesh::Elem::volume().

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

◆ get_local_constraints()

std::string libMesh::MeshBase::get_local_constraints ( bool  print_nonlocal = false) const
inherited

Gets a string reporting all mesh constraint rows local to this processor.

If print_nonlocal is true, then nonlocal constraints which are locally known are included.

Definition at line 2811 of file mesh_base.C.

2812{
2813 std::ostringstream os;
2814
2815 if (print_nonlocal)
2816 os << "All ";
2817 else
2818 os << "Local ";
2819
2820 os << "Mesh Constraint Rows:"
2821 << std::endl;
2822
2823 for (const auto & [node, row] : _constraint_rows)
2824 {
2825 const bool local = (node->processor_id() == this->processor_id());
2826
2827 // Skip non-local dofs if requested
2828 if (!print_nonlocal && !local)
2829 continue;
2830
2831 os << "Constraints for " << (local ? "Local" : "Ghost") << " Node " << node->id()
2832 << ": \t";
2833
2834 for (const auto & [elem_and_node, coef] : row)
2835 os << " ((" << elem_and_node.first->id() << ',' << elem_and_node.second << "), " << coef << ")\t";
2836
2837 os << std::endl;
2838 }
2839
2840 return os.str();
2841}

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

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

◆ 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 2057 of file mesh_base.h.

2058 { libmesh_assert(this->is_prepared()); return _mesh_subdomains; }

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

◆ get_node_integer_index()

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

Definition at line 778 of file mesh_base.C.

779{
780 for (auto i : index_range(_node_integer_names))
782 return i;
783
784 libmesh_error_msg("Unknown node integer " << name);
786}

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

◆ get_node_integer_name()

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

Definition at line 1201 of file mesh_base.h.

1202 { return _node_integer_names[i]; }

References libMesh::MeshBase::_node_integer_names.

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

◆ get_point_locator_close_to_point_tol()

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

Definition at line 2354 of file mesh_base.C.

2355{
2357}
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:2448

References libMesh::MeshBase::_point_locator_close_to_point_tol.

◆ get_subdomain_name_map()

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

◆ ghosting_functors_begin()

GhostingFunctorIterator libMesh::MeshBase::ghosting_functors_begin ( ) const
inlineinherited

◆ ghosting_functors_end()

GhostingFunctorIterator libMesh::MeshBase::ghosting_functors_end ( ) const
inlineinherited

◆ has_elem_integer()

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

◆ has_node_integer()

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

Definition at line 790 of file mesh_base.C.

791{
792 for (auto & entry : _node_integer_names)
793 if (entry == name)
794 return true;
795
796 return false;
797}

References libMesh::MeshBase::_node_integer_names.

Referenced by ExtraIntegersTest::checkpoint_helper().

◆ insert_elem() [1/2]

Elem * libMesh::DistributedMesh::insert_elem ( Elem e)
finaloverridevirtualinherited

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

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

Implements libMesh::MeshBase.

Definition at line 656 of file distributed_mesh.C.

657{
658 if (_elements[e->id()])
659 this->delete_elem(_elements[e->id()]);
660
661#ifdef LIBMESH_ENABLE_UNIQUE_ID
662 if (!e->valid_unique_id())
663 {
664 if (processor_id() == e->processor_id())
665 {
666 e->set_unique_id(_next_unique_id);
667 _next_unique_id += this->n_processors() + 1;
668 }
669 else
670 {
671 e->set_unique_id(_next_unpartitioned_unique_id);
673 }
674 }
675 else
676 {
677 _next_unique_id = std::max(_next_unique_id, e->unique_id()+1);
679 ((_next_unique_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
680 (this->n_processors() + 1) + this->processor_id();
681 }
682#endif
683
684 // Try to make the cached elem data more accurate
685 processor_id_type elem_procid = e->processor_id();
686 if (elem_procid == this->processor_id() ||
687 elem_procid == DofObject::invalid_processor_id)
688 _n_elem++;
689
690 _elements[e->id()] = e;
691
692 // We actually added a new element. Some of our caches might still
693 // be valid, but we should clear the ones which definitely are not.
694 this->clear_point_locator();
695 this->clear_stored_ranges();
696
697 // Make sure any new element is given space for any extra integers
698 // we've requested
699 e->add_extra_integers(_elem_integer_names.size(),
701
702 // And set mapping type and data on any new element
703 e->set_mapping_type(this->default_mapping_type());
704 e->set_mapping_data(this->default_mapping_data());
705
706 return e;
707}
virtual void delete_elem(Elem *e) override final
Removes element e from the mesh.

References libMesh::MeshBase::_elem_integer_default_values, libMesh::MeshBase::_elem_integer_names, libMesh::DistributedMesh::_elements, libMesh::DistributedMesh::_n_elem, libMesh::MeshBase::_next_unique_id, libMesh::DistributedMesh::_next_unpartitioned_unique_id, libMesh::DofObject::add_extra_integers(), libMesh::MeshBase::clear_point_locator(), libMesh::MeshBase::clear_stored_ranges(), libMesh::MeshBase::default_mapping_data(), libMesh::MeshBase::default_mapping_type(), libMesh::DistributedMesh::delete_elem(), libMesh::DofObject::id(), libMesh::DofObject::invalid_processor_id, libMesh::ParallelObject::n_processors(), libMesh::DofObject::processor_id(), libMesh::ParallelObject::processor_id(), libMesh::Elem::set_mapping_data(), libMesh::Elem::set_mapping_type(), libMesh::DofObject::set_unique_id(), libMesh::DofObject::unique_id(), and libMesh::DofObject::valid_unique_id().

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

◆ insert_elem() [2/2]

Elem * libMesh::DistributedMesh::insert_elem ( std::unique_ptr< Elem e)
finaloverridevirtualinherited

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.

Implements libMesh::MeshBase.

Definition at line 709 of file distributed_mesh.C.

710{
711 // The mesh now takes ownership of the Elem. Eventually the guts of
712 // insert_elem(Elem*) will get moved to a private helper function, and
713 // calling insert_elem(Elem*) directly will be deprecated.
714 return insert_elem(e.release());
715}
virtual Elem * insert_elem(Elem *e) override final
Insert elem e to the element array, preserving its id and replacing/deleting any existing element wit...

References libMesh::DistributedMesh::insert_elem().

◆ interior_mesh() [1/2]

MeshBase & libMesh::MeshBase::interior_mesh ( )
inlineinherited
Returns
A writeable reference to the interior mesh.

Definition at line 2045 of file mesh_base.h.

2045{ return *_interior_mesh; }

References libMesh::MeshBase::_interior_mesh.

◆ interior_mesh() [2/2]

const MeshBase & libMesh::MeshBase::interior_mesh ( ) const
inlineinherited
Returns
A mesh that may own interior parents of elements in this mesh. In most cases this mesh includes its own interior parents, but in cases where a separate "interior" mesh was used to create this mesh as a distinct lower-dimensional boundary (or boundary subset) mesh, the original mesh will be returned here.

Definition at line 2040 of file mesh_base.h.

2040{ return *_interior_mesh; }

References libMesh::MeshBase::_interior_mesh.

Referenced by libMesh::BoundaryInfo::add_elements(), libMesh::UnstructuredMesh::copy_nodes_and_elements(), libMesh::MeshBase::detect_interior_parents(), and libMesh::Parallel::Packing< Elem * >::unpack().

◆ is_prepared()

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

◆ is_replicated()

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

Reimplemented from libMesh::MeshBase.

Definition at line 182 of file distributed_mesh.h.

183 { return false; }

◆ is_serial()

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

Reimplemented from libMesh::MeshBase.

Definition at line 160 of file distributed_mesh.h.

161 { return _is_serial; }

References libMesh::DistributedMesh::_is_serial.

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

◆ is_serial_on_zero()

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

Reimplemented from libMesh::MeshBase.

Definition at line 167 of file distributed_mesh.h.

168 { return _is_serial || _is_serial_on_proc_0; }

References libMesh::DistributedMesh::_is_serial, and libMesh::DistributedMesh::_is_serial_on_proc_0.

Referenced by main().

◆ libmesh_assert_valid_parallel_flags()

void libMesh::DistributedMesh::libmesh_assert_valid_parallel_flags ( ) const
inherited

Verify refinement_flag and p_refinement_flag consistency of our elements containers.

Calls libmesh_assert() on each possible failure.

Definition at line 1182 of file distributed_mesh.C.

1183{
1184#if defined(LIBMESH_ENABLE_AMR) && !defined(NDEBUG)
1185 // This function must be run on all processors at once
1186 parallel_object_only();
1187
1188 dof_id_type pmax_elem_id = this->parallel_max_elem_id();
1189
1190 for (dof_id_type i=0; i != pmax_elem_id; ++i)
1191 {
1192 Elem * el = _elements[i]; // Returns nullptr if there's no map entry
1193
1194 unsigned int refinement_flag = el ?
1195 static_cast<unsigned int> (el->refinement_flag()) : libMesh::invalid_uint;
1196 unsigned int p_refinement_flag = el ?
1197 static_cast<unsigned int> (el->p_refinement_flag()) : libMesh::invalid_uint;
1198
1199 libmesh_assert(this->comm().semiverify(el ? &refinement_flag : nullptr));
1200
1201 // p refinement flags aren't always kept correct on inactive
1202 // ghost elements
1203 libmesh_assert(this->comm().semiverify((el && el->active()) ? &p_refinement_flag : nullptr));
1204 }
1205#endif // LIBMESH_ENABLE_AMR
1206}
The libMesh namespace provides an interface to certain functionality in the library.

References libMesh::DistributedMesh::_elements, libMesh::Elem::active(), libMesh::ParallelObject::comm(), libMesh::invalid_uint, libMesh::libmesh_assert(), libMesh::Elem::p_refinement_flag(), libMesh::DistributedMesh::parallel_max_elem_id(), and libMesh::Elem::refinement_flag().

Referenced by libMesh::DistributedMesh::allgather(), libMesh::DistributedMesh::delete_remote_elements(), and libMesh::DistributedMesh::renumber_nodes_and_elements().

◆ libmesh_assert_valid_parallel_ids()

void libMesh::DistributedMesh::libmesh_assert_valid_parallel_ids ( ) const
overridevirtualinherited

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

Calls libmesh_assert() on each possible failure.

Reimplemented from libMesh::MeshBase.

Definition at line 1151 of file distributed_mesh.C.

1152{
1155}
void libmesh_assert_valid_parallel_object_ids(const dofobject_container< T > &) const
Verify id, processor_id, and if applicable unique_id consistency of a parallel objects container.

References libMesh::DistributedMesh::_elements, libMesh::DistributedMesh::_nodes, and libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids().

Referenced by libMesh::BoundaryInfo::add_elements(), libMesh::DistributedMesh::allgather(), libMesh::DistributedMesh::delete_remote_elements(), and libMesh::DistributedMesh::renumber_nodes_and_elements().

◆ libmesh_assert_valid_parallel_object_ids()

template<typename T >
void libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids ( const dofobject_container< T > &  objects) const
inherited

Verify id, processor_id, and if applicable unique_id consistency of a parallel objects container.

Calls libmesh_assert() on each possible failure in that container.

Definition at line 1095 of file distributed_mesh.C.

1096{
1097 // This function must be run on all processors at once
1098 parallel_object_only();
1099
1100 const dof_id_type pmax_node_id = this->parallel_max_node_id();
1101 const dof_id_type pmax_elem_id = this->parallel_max_elem_id();
1102 const dof_id_type pmax_id = std::max(pmax_node_id, pmax_elem_id);
1103
1104 for (dof_id_type i=0; i != pmax_id; ++i)
1105 {
1106 T * obj = objects[i]; // Returns nullptr if there's no map entry
1107
1108 // Local lookups by id should return the requested object
1109 libmesh_assert(!obj || obj->id() == i);
1110
1111 // All processors with an object should agree on id
1112#ifndef NDEBUG
1113 const dof_id_type dofid = obj && obj->valid_id() ?
1114 obj->id() : DofObject::invalid_id;
1115 libmesh_assert(this->comm().semiverify(obj ? &dofid : nullptr));
1116#endif
1117
1118 // All processors with an object should agree on processor id
1119 const dof_id_type procid = obj && obj->valid_processor_id() ?
1120 obj->processor_id() : DofObject::invalid_processor_id;
1121 libmesh_assert(this->comm().semiverify(obj ? &procid : nullptr));
1122
1123 dof_id_type min_procid = procid;
1124 this->comm().min(min_procid);
1125
1126 // Either:
1127 // 1.) I own this elem (min_procid == this->processor_id()) *and* I have a valid pointer to it (obj != nullptr)
1128 // or
1129 // 2.) I don't own this elem (min_procid != this->processor_id()). (In this case I may or may not have a valid pointer to it.)
1130
1131 // Original assert logic
1132 // libmesh_assert (min_procid != this->processor_id() || obj);
1133
1134 // More human-understandable logic...
1136 ((min_procid == this->processor_id()) && obj)
1137 ||
1138 (min_procid != this->processor_id())
1139 );
1140
1141#if defined(LIBMESH_ENABLE_UNIQUE_ID) && !defined(NDEBUG)
1142 // All processors with an object should agree on unique id
1143 const unique_id_type uniqueid = obj ? obj->unique_id() : 0;
1144 libmesh_assert(this->comm().semiverify(obj ? &uniqueid : nullptr));
1145#endif
1146 }
1147}
uint8_t unique_id_type
Definition id_types.h:86

References libMesh::ParallelObject::comm(), libMesh::DofObject::invalid_id, libMesh::DofObject::invalid_processor_id, libMesh::libmesh_assert(), libMesh::Parallel::Communicator::min(), libMesh::DistributedMesh::parallel_max_elem_id(), libMesh::DistributedMesh::parallel_max_node_id(), and libMesh::ParallelObject::processor_id().

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

◆ libmesh_assert_valid_parallel_p_levels()

void libMesh::DistributedMesh::libmesh_assert_valid_parallel_p_levels ( ) const
inherited

Verify p_level consistency of our elements containers.

Calls libmesh_assert() on each possible failure.

Definition at line 1159 of file distributed_mesh.C.

1160{
1161#ifndef NDEBUG
1162 // This function must be run on all processors at once
1163 parallel_object_only();
1164
1165 dof_id_type pmax_elem_id = this->parallel_max_elem_id();
1166
1167 for (dof_id_type i=0; i != pmax_elem_id; ++i)
1168 {
1169 Elem * el = _elements[i]; // Returns nullptr if there's no map entry
1170
1171 unsigned int p_level = el ? (el->p_level()) : libMesh::invalid_uint;
1172
1173 // All processors with an active element should agree on p level
1174 libmesh_assert(this->comm().semiverify((el && el->active()) ? &p_level : nullptr));
1175 }
1176#endif
1177}

References libMesh::DistributedMesh::_elements, libMesh::Elem::active(), libMesh::ParallelObject::comm(), libMesh::invalid_uint, libMesh::libmesh_assert(), libMesh::Elem::p_level(), and libMesh::DistributedMesh::parallel_max_elem_id().

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

◆ 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 281 of file mesh_base.C.

282{
283 // Check whether (almost) everything in the base is equal
284 //
285 // We don't check _next_unique_id here, because it's expected to
286 // change in a DistributedMesh prepare_for_use(); it's conceptually
287 // "mutable".
288 //
289 // We use separate if statements instead of logical operators here,
290 // to make it easy to see the failing condition when using a
291 // debugger to figure out why a MeshTools::valid_is_prepared(mesh)
292 // is failing.
293 if (_n_parts != other_mesh._n_parts)
294 return false;
295 if (_default_mapping_type != other_mesh._default_mapping_type)
296 return false;
297 if (_default_mapping_data != other_mesh._default_mapping_data)
298 return false;
299 if (_preparation != other_mesh._preparation)
300 return false;
302 other_mesh._count_lower_dim_elems_in_point_locator)
303 return false;
304
305 // We should either both have our own interior parents or both not;
306 // but if we both don't then we can't really assert anything else
307 // because pointing at the same interior mesh is fair but so is
308 // pointing at two different copies of "the same" interior mesh.
309 if ((_interior_mesh == this) !=
310 (other_mesh._interior_mesh == &other_mesh))
311 return false;
312
313 if (_skip_noncritical_partitioning != other_mesh._skip_noncritical_partitioning)
314 return false;
315 if (_skip_all_partitioning != other_mesh._skip_all_partitioning)
316 return false;
317 if (_skip_renumber_nodes_and_elements != other_mesh._skip_renumber_nodes_and_elements)
318 return false;
319 if (_skip_find_neighbors != other_mesh._skip_find_neighbors)
320 return false;
321 if (_skip_detect_interior_parents != other_mesh._skip_detect_interior_parents)
322 return false;
323 if (_allow_remote_element_removal != other_mesh._allow_remote_element_removal)
324 return false;
325 if (_allow_node_and_elem_unique_id_overlap != other_mesh._allow_node_and_elem_unique_id_overlap)
326 return false;
327 if (_spatial_dimension != other_mesh._spatial_dimension)
328 return false;
329 if (_point_locator_close_to_point_tol != other_mesh._point_locator_close_to_point_tol)
330 return false;
331 if (_block_id_to_name != other_mesh._block_id_to_name)
332 return false;
333 if (_elem_dims != other_mesh._elem_dims)
334 return false;
335 if (_elem_default_orders != other_mesh._elem_default_orders)
336 return false;
337 if (_supported_nodal_order != other_mesh._supported_nodal_order)
338 return false;
339 if (_mesh_subdomains != other_mesh._mesh_subdomains)
340 return false;
341 if (_all_elemset_ids != other_mesh._all_elemset_ids)
342 return false;
343 if (_elem_integer_names != other_mesh._elem_integer_names)
344 return false;
345 if (_elem_integer_default_values != other_mesh._elem_integer_default_values)
346 return false;
347 if (_node_integer_names != other_mesh._node_integer_names)
348 return false;
349 if (_node_integer_default_values != other_mesh._node_integer_default_values)
350 return false;
351 if (static_cast<bool>(_default_ghosting) != static_cast<bool>(other_mesh._default_ghosting))
352 return false;
353 if (static_cast<bool>(_partitioner) != static_cast<bool>(other_mesh._partitioner))
354 return false;
355 if (*boundary_info != *other_mesh.boundary_info)
356 return false;
357
358 // First check whether the "existence" of the two pointers differs (one present, one absent)
359 if (static_cast<bool>(_disjoint_neighbor_boundary_pairs) !=
360 static_cast<bool>(other_mesh._disjoint_neighbor_boundary_pairs))
361 return false;
362 // If both exist, compare the contents (Weak Test: just compare sizes like `_ghosting_functors`)
364 (_disjoint_neighbor_boundary_pairs->size() != other_mesh._disjoint_neighbor_boundary_pairs->size()))
365 return false;
366
367 const constraint_rows_type & other_rows =
368 other_mesh.get_constraint_rows();
369 for (const auto & [node, row] : this->_constraint_rows)
370 {
371 const dof_id_type node_id = node->id();
372 const Node * other_node = other_mesh.query_node_ptr(node_id);
373 if (!other_node)
374 return false;
375
376 auto it = other_rows.find(other_node);
377 if (it == other_rows.end())
378 return false;
379
380 const auto & other_row = it->second;
381 if (row.size() != other_row.size())
382 return false;
383
384 for (auto i : index_range(row))
385 {
386 const auto & [elem_pair, coef] = row[i];
387 const auto & [other_elem_pair, other_coef] = other_row[i];
388 libmesh_assert(elem_pair.first);
389 libmesh_assert(other_elem_pair.first);
390 if (elem_pair.first->id() !=
391 other_elem_pair.first->id() ||
392 elem_pair.second !=
393 other_elem_pair.second ||
394 coef != other_coef)
395 return false;
396 }
397 }
398
399 for (const auto & [elemset_code, elemset_ptr] : this->_elemset_codes)
400 if (const auto it = other_mesh._elemset_codes.find(elemset_code);
401 it == other_mesh._elemset_codes.end() || *elemset_ptr != *it->second)
402 return false;
403
404 // FIXME: we have no good way to compare ghosting functors, since
405 // they're in a vector of pointers, and we have no way *at all*
406 // to compare ghosting functors, since they don't have operator==
407 // defined and we encourage users to subclass them. We can check if
408 // we have the same number, is all.
409 if (_ghosting_functors.size() !=
410 other_mesh._ghosting_functors.size())
411 return false;
412
413 // Same deal for partitioners. We tested that we both have one or
414 // both don't, but are they equivalent? Let's guess "yes".
415
416 // Now let the subclasses decide whether everything else is equal
417 return this->subclass_locally_equals(other_mesh);
418}
bool _skip_all_partitioning
If this is true then no partitioning should be done.
Definition mesh_base.h:2263
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:2258
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.
std::unique_ptr< Partitioner > _partitioner
A partitioner to use at each prepare_for_use().
Definition mesh_base.h:2239
unsigned int _n_parts
The number of partitions the mesh has.
Definition mesh_base.h:2177
std::map< const Node *, constraint_rows_mapped_type > constraint_rows_type
Definition mesh_base.h:1930

References libMesh::MeshBase::_all_elemset_ids, libMesh::MeshBase::_allow_node_and_elem_unique_id_overlap, 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::_disjoint_neighbor_boundary_pairs, libMesh::MeshBase::_elem_default_orders, 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::_interior_mesh, 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::_preparation, libMesh::MeshBase::_skip_all_partitioning, libMesh::MeshBase::_skip_detect_interior_parents, libMesh::MeshBase::_skip_find_neighbors, libMesh::MeshBase::_skip_noncritical_partitioning, libMesh::MeshBase::_skip_renumber_nodes_and_elements, libMesh::MeshBase::_spatial_dimension, libMesh::MeshBase::_supported_nodal_order, 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==().

◆ max_elem_id()

virtual dof_id_type libMesh::DistributedMesh::max_elem_id ( ) const
inlinefinaloverridevirtualinherited
Returns
A number one greater than the maximum element id in the mesh. A more apt name for this method would be end_elem_id

Implements libMesh::MeshBase.

Definition at line 275 of file distributed_mesh.h.

275{ return _max_elem_id; }

References libMesh::DistributedMesh::_max_elem_id.

Referenced by libMesh::DistributedMesh::allgather(), libMesh::DistributedMesh::delete_remote_elements(), libMesh::DistributedMesh::DistributedMesh(), MeshPerElemTest< elem_type >::meshes_equal_enough(), and libMesh::DistributedMesh::renumber_nodes_and_elements().

◆ max_node_id()

virtual dof_id_type libMesh::DistributedMesh::max_node_id ( ) const
inlinefinaloverridevirtualinherited
Returns
A number one greater than the maximum node id in the mesh. A more apt name for this method would be end_node_id

Implements libMesh::MeshBase.

Definition at line 271 of file distributed_mesh.h.

271{ return _max_node_id; }

References libMesh::DistributedMesh::_max_node_id.

Referenced by libMesh::DistributedMesh::allgather(), libMesh::DistributedMesh::delete_remote_elements(), libMesh::DistributedMesh::DistributedMesh(), MeshPerElemTest< elem_type >::meshes_equal_enough(), and libMesh::DistributedMesh::renumber_nodes_and_elements().

◆ 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 2385 of file mesh_base.C.

2386{
2387 std::pair<std::vector<unsigned int>, std::vector<unsigned int>> returnval;
2388 returnval.first = this->add_elem_integers(other._elem_integer_names, true, &other._elem_integer_default_values);
2389 returnval.second = this->add_node_integers(other._node_integer_names, true, &other._node_integer_default_values);
2390 return returnval;
2391}
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:735
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,...
Definition mesh_base.C:646

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 libMesh::UnstructuredMesh::copy_nodes_and_elements(), and libMesh::UnstructuredMesh::create_submesh().

◆ 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. When we have multi-dimensional meshes (e.g. hexes and quads in the same mesh) then this will return the largest such dimension.

Definition at line 430 of file mesh_base.C.

431{
432 if (!_elem_dims.empty())
433 return cast_int<unsigned int>(*_elem_dims.rbegin());
434 return 0;
435}

References libMesh::MeshBase::_elem_dims.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::HPCoarsenTest::add_projection(), libMesh::UnstructuredMesh::all_complete_order_range(), libMesh::UnstructuredMesh::all_second_order_range(), libMesh::MeshTools::Modification::all_tri(), alternative_fe_assembly(), LinearElasticity::assemble(), assemble(), assemble(), assemble_1D(), AssembleOptimization::assemble_A_and_F(), assemble_biharmonic(), assemble_cd(), assemble_cd(), assemble_divgrad(), assemble_elasticity(), assemble_ellipticdg(), assemble_func(), assemble_graddiv(), assemble_helmholtz(), assemble_laplace(), assemble_mass(), assemble_matrices(), assemble_poisson(), assemble_poisson(), assemble_poisson(), assemble_SchroedingerEquation(), assemble_shell(), assemble_stokes(), assemble_temperature_jump(), assemble_wave(), assemble_wave(), libMesh::MeshTools::Generation::build_cube(), libMesh::MeshBase::cache_elem_data(), compute_enriched_soln(), compute_jacobian(), compute_residual(), LinearElasticity::compute_stresses(), LargeDeformationElasticity::compute_stresses(), LinearElasticityWithContact::compute_stresses(), compute_stresses(), libMesh::VariationalSmootherConstraint::constrain(), libMesh::VariationalSmootherConstraint::constrain_node_to_line(), libMesh::VariationalSmootherConstraint::constrain_node_to_plane(), libMesh::DofMap::create_dof_constraints(), libMesh::MeshTools::Modification::distort(), NavierSystem::element_constraint(), HeatSystem::element_time_derivative(), NavierSystem::element_time_derivative(), SolidSystem::element_time_derivative(), libMesh::ExactErrorEstimator::estimate_error(), fe_assembly(), libMesh::VariationalSmootherConstraint::fix_node(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), NavierSystem::forcing(), form_functionA(), form_functionB(), form_matrixA(), libMesh::ReplicatedMesh::get_boundary_points(), libMesh::LaplaceMeshSmoother::init(), libMesh::PointLocatorTree::init(), NavierSystem::init_data(), SolidSystem::init_data(), ElasticityRBConstruction::init_data(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::Nemesis_IO_Helper::initialize(), integrate_function(), LargeDeformationElasticity::jacobian(), LaplaceYoung::jacobian(), main(), NavierSystem::mass_residual(), Integrate::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SmoothnessEstimator::EstimateSmoothness::operator()(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), NavierSystem::postprocess(), libMesh::VTKIO::read(), libMesh::Nemesis_IO::read(), libMesh::GMVIO::read(), libMesh::ExodusII_IO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::System::read_header(), libMesh::UCDIO::read_implementation(), libMesh::XdrIO::read_serialized_connectivity(), LargeDeformationElasticity::residual(), LaplaceYoung::residual(), LinearElasticityWithContact::residual_and_jacobian(), SolidSystem::save_initial_mesh(), libMesh::HPCoarsenTest::select_refinement(), libMesh::PetscPreconditioner< T >::set_hypre_ads_data(), libMesh::PetscPreconditioner< T >::set_hypre_ams_data(), libMesh::PetscPreconditioner< T >::set_petsc_aux_data(), setup(), NavierSystem::side_constraint(), libMesh::MeshTools::Modification::smooth(), MeshSpatialDimensionTest::test1D(), MeshSpatialDimensionTest::test2D(), CheckpointIOTest::testC0PolygonCheckpoint(), CheckpointIOTest::testC0PolyhedronCheckpoint(), BoundaryMeshSubdomainTest::testDefaultSubdomain(), InfFERadialTest::testInfQuants(), InfFERadialTest::testInfQuants_numericDeriv(), BoundaryMeshSubdomainTest::testPerBoundarySubdomain(), InfFERadialTest::testSides(), InfFERadialTest::testSingleOrder(), BoundaryMeshSubdomainTest::testSingleSubdomain(), MeshSmootherTest::testVariationalSmootherRegression(), libMesh::BoundaryVolumeSolutionTransfer::transfer(), libMesh::DTKSolutionTransfer::transfer(), libMesh::MeshTools::volume(), libMesh::PostscriptIO::write(), libMesh::CheckpointIO::write(), libMesh::GMVIO::write_binary(), libMesh::TecplotIO::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().

◆ move_nodes_and_elements()

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

Move node and elements from other_mesh to this mesh.

Implemented in libMesh::ReplicatedMesh.

◆ n_active_elem()

dof_id_type libMesh::DistributedMesh::n_active_elem ( ) const
finaloverridevirtualinherited
Returns
The number of active elements in the mesh.

Implemented in terms of active_element_iterators.

Implements libMesh::MeshBase.

Definition at line 1710 of file distributed_mesh.C.

1711{
1712 parallel_object_only();
1713
1714 // Get local active elements first
1715 dof_id_type active_elements =
1716 static_cast<dof_id_type>(std::distance (this->active_local_elements_begin(),
1717 this->active_local_elements_end()));
1718 this->comm().sum(active_elements);
1719
1720 // Then add unpartitioned active elements, which should exist on
1721 // every processor
1722 active_elements +=
1723 static_cast<dof_id_type>(std::distance
1724 (this->active_pid_elements_begin(DofObject::invalid_processor_id),
1725 this->active_pid_elements_end(DofObject::invalid_processor_id)));
1726 return active_elements;
1727}

References libMesh::ParallelObject::comm(), libMesh::DofObject::invalid_processor_id, and libMesh::Parallel::Communicator::sum().

◆ 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 1242 of file mesh_base.C.

1243{
1244 libmesh_assert_less (proc_id, this->n_processors());
1245 return static_cast<dof_id_type>(std::distance (this->active_pid_elements_begin(proc_id),
1246 this->active_pid_elements_end (proc_id)));
1247}

References libMesh::ParallelObject::n_processors().

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

◆ 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 1263 of file mesh_base.C.

1264{
1265 dof_id_type ne=0;
1266
1267 for (const auto & elem : this->active_element_ptr_range())
1268 ne += elem->n_sub_elem();
1269
1270 return ne;
1271}
dof_id_type n_sub_elem() const
Definition mesh_base.C:1251

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

◆ n_constraint_rows()

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

Definition at line 2471 of file mesh_base.C.

2472{
2473 dof_id_type n_local_rows=0, n_unpartitioned_rows=0;
2474 for (const auto & [node, node_constraints] : _constraint_rows)
2475 {
2476 // Unpartitioned nodes
2477 if (node->processor_id() == DofObject::invalid_processor_id)
2478 n_unpartitioned_rows++;
2479 else if (node->processor_id() == this->processor_id())
2480 n_local_rows++;
2481 }
2482
2483 this->comm().sum(n_local_rows);
2484
2485 return n_unpartitioned_rows + n_local_rows;
2486}

References libMesh::MeshBase::_constraint_rows, libMesh::ParallelObject::comm(), libMesh::DofObject::invalid_processor_id, libMesh::ParallelObject::processor_id(), and libMesh::Parallel::Communicator::sum().

Referenced by libMesh::MeshCommunication::delete_remote_elements().

◆ n_elem()

virtual dof_id_type libMesh::DistributedMesh::n_elem ( ) const
inlinefinaloverridevirtualinherited

◆ n_elem_integers()

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

◆ 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 1229 of file mesh_base.C.

1230{
1231 // We're either counting a processor's elements or unpartitioned
1232 // elements
1233 libmesh_assert (proc_id < this->n_processors() ||
1235
1236 return static_cast<dof_id_type>(std::distance (this->pid_elements_begin(proc_id),
1237 this->pid_elements_end (proc_id)));
1238}

References 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().

◆ 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 482 of file mesh_base.C.

483{
484 return _all_elemset_ids.size();
485}

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().

◆ 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 697 of file mesh_base.h.

698 { 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:1229

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().

◆ 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 591 of file mesh_base.h.

592 { 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:1216

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().

◆ 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 1204 of file mesh_base.C.

1205{
1206 std::set<subdomain_id_type> ids;
1207
1208 this->subdomain_ids (ids, /* global = */ false);
1209
1210 return cast_int<subdomain_id_type>(ids.size());
1211}

References libMesh::MeshBase::subdomain_ids().

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

◆ n_node_integers()

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

◆ n_nodes()

virtual dof_id_type libMesh::DistributedMesh::n_nodes ( ) const
inlinefinaloverridevirtualinherited
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.

Implements libMesh::MeshBase.

Definition at line 270 of file distributed_mesh.h.

270{ return _n_nodes; }

References libMesh::DistributedMesh::_n_nodes.

Referenced by libMesh::DistributedMesh::allgather(), libMesh::DistributedMesh::delete_remote_elements(), libMesh::DistributedMesh::DistributedMesh(), libMesh::DistributedMesh::renumber_nodes_and_elements(), AllRBBTest::test_circle(), and MixedOrderTest::testStitch().

◆ 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 1216 of file mesh_base.C.

1217{
1218 // We're either counting a processor's nodes or unpartitioned
1219 // nodes
1220 libmesh_assert (proc_id < this->n_processors() ||
1222
1223 return static_cast<dof_id_type>(std::distance (this->pid_nodes_begin(proc_id),
1224 this->pid_nodes_end (proc_id)));
1225}

References 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().

◆ 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 1526 of file mesh_base.h.

1527 { return _n_parts; }

References libMesh::MeshBase::_n_parts.

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

◆ 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.

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 }
processor_id_type size() const

References libMesh::ParallelObject::_communicator, libMesh::libmesh_assert(), and libMesh::Parallel::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::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::Partitioner::build_graph(), 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::UnstructuredMesh::copy_nodes_and_elements(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::DistributedMesh::DistributedMesh(), libMesh::EnsightIO::EnsightIO(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::MeshBase::get_info(), libMesh::StaticCondensation::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_petscdm(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::DistributedMesh::insert_elem(), libMesh::NumericVector< T >::is_effectively_ghosted(), libMesh::NumericVector< T >::is_effectively_serial(), 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::MeshBase::n_active_elem_on_proc(), libMesh::DofMap::n_dofs_per_processor(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::MeshBase::partition(), libMesh::Partitioner::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::MeshBase::print_constraint_rows(), libMesh::DofMap::print_dof_constraints(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::NameBasedIO::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::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::VTKIO::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().

◆ 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 1251 of file mesh_base.C.

1252{
1253 dof_id_type ne=0;
1254
1255 for (const auto & elem : this->element_ptr_range())
1256 ne += elem->n_sub_elem();
1257
1258 return ne;
1259}

◆ 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 1190 of file mesh_base.C.

1191{
1192 // This requires an inspection on every processor
1193 parallel_object_only();
1194
1195 std::set<subdomain_id_type> ids;
1196
1197 this->subdomain_ids (ids);
1198
1199 return cast_int<subdomain_id_type>(ids.size());
1200}

References libMesh::MeshBase::subdomain_ids().

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

◆ n_unpartitioned_elem()

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

◆ 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 597 of file mesh_base.h.

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

Referenced by libMesh::MeshBase::complete_preparation(), and libMesh::DistributedMesh::parallel_n_nodes().

◆ next_unique_id()

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

Definition at line 610 of file mesh_base.h.

610{ return _next_unique_id; }

References libMesh::MeshBase::_next_unique_id.

Referenced by libMesh::ExodusII_IO_Helper::set_dof_object_unique_id(), and libMesh::ExodusII_IO_Helper::write_elements().

◆ node_ptr() [1/2]

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

Implements libMesh::MeshBase.

Definition at line 421 of file distributed_mesh.C.

422{
424 libmesh_assert_equal_to (_nodes[i]->id(), i);
425
426 return _nodes[i];
427}

References libMesh::DistributedMesh::_nodes, and libMesh::libmesh_assert().

Referenced by libMesh::DistributedMesh::fix_broken_node_and_element_numbering(), MeshPerElemTest< elem_type >::meshes_equal_enough(), DisjointNeighborTest::testDisjointNeighborConflictError(), and DisjointNeighborTest::testStitchCrossMesh().

◆ node_ptr() [2/2]

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

Implements libMesh::MeshBase.

Definition at line 432 of file distributed_mesh.C.

433{
435 libmesh_assert_equal_to (_nodes[i]->id(), i);
436
437 return _nodes[i];
438}

References libMesh::DistributedMesh::_nodes, and libMesh::libmesh_assert().

◆ node_ref() [1/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 754 of file mesh_base.h.

755 {
756 return *this->node_ptr(i);
757 }

References libMesh::MeshBase::node_ptr().

◆ node_ref() [2/2]

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

Definition at line 745 of file mesh_base.h.

746 {
747 return *this->node_ptr(i);
748 }

References libMesh::MeshBase::node_ptr().

Referenced by libMesh::SyncNodalPositions::act_on_data(), LinearElasticityWithContact::add_contact_edge_elements(), add_cube_convex_hull_to_mesh(), assemble_matrix_and_rhs(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::MeshBase::copy_constraint_rows(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::DTKAdapter::DTKAdapter(), fill_dirichlet_bc(), libMesh::MeshTools::Modification::interpolate_surface(), main(), libMesh::DistributedMesh::point(), libMesh::ReplicatedMesh::point(), libMesh::ExodusII_IO::read(), libMesh::XdrIO::read_serialized_nodes(), libMesh::DistributedMesh::renumber_nodes_and_elements(), LinearElasticityWithContact::residual_and_jacobian(), 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::LaplaceMeshSmoother::smooth(), libMesh::VariationalMeshSmoother::smooth(), libMesh::MeshTools::Modification::smooth(), libMesh::UnstructuredMesh::stitching_helper(), MeshTriangulationTest::testPoly2TriHolesInterpRefined(), MeshSmootherTest::testVariationalSmoother(), MeshSmootherTest::testVariationalSmootherRegression(), libMesh::DTKAdapter::update_variable_values(), and libMesh::GmshIO::write_mesh().

◆ 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 2441 of file mesh_base.C.

2442{
2443 for (const auto & other_node : other_mesh.node_ptr_range())
2444 {
2445 const Node * node = this->query_node_ptr(other_node->id());
2446 if (!node)
2447 return false;
2448 if (*other_node != *node)
2449 return false;
2450 }
2451 for (const auto & node : this->node_ptr_range())
2452 if (!other_mesh.query_node_ptr(node->id()))
2453 return false;
2454
2455 for (const auto & other_elem : other_mesh.element_ptr_range())
2456 {
2457 const Elem * elem = this->query_elem_ptr(other_elem->id());
2458 if (!elem)
2459 return false;
2460 if (!other_elem->topologically_equal(*elem))
2461 return false;
2462 }
2463 for (const auto & elem : this->element_ptr_range())
2464 if (!other_mesh.query_elem_ptr(elem->id()))
2465 return false;
2466
2467 return true;
2468}
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0

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

◆ operator!=()

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

Definition at line 138 of file mesh_base.h.

139 {
140 return !(*this == other_mesh);
141 }

◆ operator=() [1/2]

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

Copy assignment is not allowed.

◆ operator=() [2/2]

Mesh & libMesh::Mesh::operator= ( Mesh &&  )
default

Move assignment is allowed.

◆ 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).

Though this method is non-virtual, its implementation calls the virtual function subclass_locally_equals() to test for equality of subclass-specific data as well.

Definition at line 271 of file mesh_base.C.

272{
273 LOG_SCOPE("operator==()", "MeshBase");
274
275 bool is_equal = this->locally_equals(other_mesh);
276 this->comm().min(is_equal);
277 return is_equal;
278}
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:281

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

◆ own_node()

void libMesh::DistributedMesh::own_node ( Node n)
finaloverridevirtualinherited

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 from libMesh::MeshBase.

Definition at line 804 of file distributed_mesh.C.

805{
806 // This had better be a node in our mesh
807 libmesh_assert(_nodes[n.id()] == &n);
808
809 _nodes[n.id()] = nullptr;
810 _n_nodes--;
811
812 n.set_id(DofObject::invalid_id);
813 n.processor_id() = this->processor_id();
814
815 this->add_node(&n);
816}

References libMesh::DistributedMesh::_n_nodes, libMesh::DistributedMesh::_nodes, libMesh::DistributedMesh::add_node(), libMesh::DofObject::id(), libMesh::DofObject::invalid_id, libMesh::libmesh_assert(), libMesh::DofObject::processor_id(), libMesh::ParallelObject::processor_id(), and libMesh::DofObject::set_id().

◆ parallel_max_elem_id()

dof_id_type libMesh::DistributedMesh::parallel_max_elem_id ( ) const
inherited

Definition at line 307 of file distributed_mesh.C.

308{
309 // This function must be run on all processors at once
310 parallel_object_only();
311
312 dof_id_type max_local = 0;
313
314 dofobject_container<Elem>::const_reverse_veclike_iterator
315 rit = _elements.rbegin();
316
317 const dofobject_container<Elem>::const_reverse_veclike_iterator
318 rend = _elements.rend();
319
320 // Look for the maximum element id. Search backwards through
321 // elements so we can break out early. Beware of nullptr entries that
322 // haven't yet been cleared from _elements.
323 for (; rit != rend; ++rit)
324 {
325 const DofObject *d = *rit;
326 if (d)
327 {
328 libmesh_assert(_elements[d->id()] == d);
329 max_local = d->id() + 1;
330 break;
331 }
332 }
333
334 this->comm().max(max_local);
335 return max_local;
336}

References libMesh::DistributedMesh::_elements, libMesh::ParallelObject::comm(), libMesh::DofObject::id(), libMesh::libmesh_assert(), and libMesh::Parallel::Communicator::max().

Referenced by libMesh::DistributedMesh::allgather(), libMesh::DistributedMesh::delete_remote_elements(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_flags(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_p_levels(), libMesh::DistributedMesh::renumber_nodes_and_elements(), and libMesh::DistributedMesh::update_parallel_id_counts().

◆ parallel_max_node_id()

dof_id_type libMesh::DistributedMesh::parallel_max_node_id ( ) const
inherited

Definition at line 381 of file distributed_mesh.C.

382{
383 // This function must be run on all processors at once
384 parallel_object_only();
385
386 dof_id_type max_local = 0;
387
388 dofobject_container<Node>::const_reverse_veclike_iterator
389 rit = _nodes.rbegin();
390
391 const dofobject_container<Node>::const_reverse_veclike_iterator
392 rend = _nodes.rend();
393
394 // Look for the maximum node id. Search backwards through
395 // nodes so we can break out early. Beware of nullptr entries that
396 // haven't yet been cleared from _nodes
397 for (; rit != rend; ++rit)
398 {
399 const DofObject *d = *rit;
400 if (d)
401 {
402 libmesh_assert(_nodes[d->id()] == d);
403 max_local = d->id() + 1;
404 break;
405 }
406 }
407
408 this->comm().max(max_local);
409 return max_local;
410}

References libMesh::DistributedMesh::_nodes, libMesh::ParallelObject::comm(), libMesh::DofObject::id(), libMesh::libmesh_assert(), and libMesh::Parallel::Communicator::max().

Referenced by libMesh::DistributedMesh::allgather(), libMesh::DistributedMesh::delete_remote_elements(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DistributedMesh::renumber_nodes_and_elements(), and libMesh::DistributedMesh::update_parallel_id_counts().

◆ parallel_max_unique_id()

unique_id_type libMesh::DistributedMesh::parallel_max_unique_id ( ) const
overridevirtualinherited
Returns
A number greater than or equal to the maximum unique_id in the mesh.

Implements libMesh::MeshBase.

Definition at line 341 of file distributed_mesh.C.

342{
343 // This function must be run on all processors at once
344 parallel_object_only();
345
346 unique_id_type max_local = std::max(_next_unique_id,
348 this->comm().max(max_local);
349 return max_local;
350}

References libMesh::MeshBase::_next_unique_id, libMesh::DistributedMesh::_next_unpartitioned_unique_id, libMesh::ParallelObject::comm(), and libMesh::Parallel::Communicator::max().

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

◆ parallel_n_elem()

dof_id_type libMesh::DistributedMesh::parallel_n_elem ( ) const
overridevirtualinherited
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.

Implements libMesh::MeshBase.

Definition at line 294 of file distributed_mesh.C.

295{
296 // This function must be run on all processors at once
297 parallel_object_only();
298
299 dof_id_type n_local = this->n_local_elem();
300 this->comm().sum(n_local);
301 n_local += this->n_unpartitioned_elem();
302 return n_local;
303}

References libMesh::ParallelObject::comm(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_unpartitioned_elem(), and libMesh::Parallel::Communicator::sum().

Referenced by libMesh::DistributedMesh::allgather(), libMesh::DistributedMesh::delete_remote_elements(), libMesh::DistributedMesh::renumber_nodes_and_elements(), and libMesh::DistributedMesh::update_parallel_id_counts().

◆ parallel_n_nodes()

dof_id_type libMesh::DistributedMesh::parallel_n_nodes ( ) const
overridevirtualinherited
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.

Implements libMesh::MeshBase.

Definition at line 368 of file distributed_mesh.C.

369{
370 // This function must be run on all processors at once
371 parallel_object_only();
372
373 dof_id_type n_local = this->n_local_nodes();
374 this->comm().sum(n_local);
375 n_local += this->n_unpartitioned_nodes();
376 return n_local;
377}

References libMesh::ParallelObject::comm(), libMesh::MeshBase::n_local_nodes(), libMesh::MeshBase::n_unpartitioned_nodes(), and libMesh::Parallel::Communicator::sum().

Referenced by libMesh::DistributedMesh::allgather(), libMesh::DistributedMesh::delete_remote_elements(), libMesh::DistributedMesh::renumber_nodes_and_elements(), DisjointNeighborTest::testStitchCrossMesh(), DisjointNeighborTest::testStitchingDiscontinuousBoundaries(), and libMesh::DistributedMesh::update_parallel_id_counts().

◆ partition() [1/2]

void libMesh::MeshBase::partition ( )
inlineinherited

◆ partition() [2/2]

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

Call the default partitioner (currently metis_partition()).

Definition at line 1769 of file mesh_base.C.

1770{
1771 // If we get here and we have unpartitioned elements, we need that
1772 // fixed.
1773 if (this->n_unpartitioned_elem() > 0)
1774 {
1776 libmesh_assert (this->is_serial());
1777 partitioner()->partition (*this, n_parts);
1778 }
1779 // A nullptr partitioner or a skip_partitioning(true) call or a
1780 // skip_noncritical_partitioning(true) call means don't repartition;
1781 // skip_noncritical_partitioning() checks all these.
1783 {
1784 partitioner()->partition (*this, n_parts);
1785 }
1786 else
1787 {
1788 // Adaptive coarsening may have "orphaned" nodes on processors
1789 // whose elements no longer share them. We need to check for
1790 // and possibly fix that.
1792
1793 // Make sure locally cached partition count is correct
1795
1796 // Make sure any other locally cached data is correct
1798 }
1799
1801}
virtual std::unique_ptr< Partitioner > & partitioner()
A partitioner to use at each partitioning.
Definition mesh_base.h:165
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:1813
virtual void update_post_partitioning()
Recalculate any cached data (or invalidate any caches that are computed on the fly) after elements an...
Definition mesh_base.C:1180
bool skip_noncritical_partitioning() const
Definition mesh_base.h:1414
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...
const Elem & get(const ElemType type_in)

References libMesh::MeshBase::_preparation, libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshBase::Preparation::is_partitioned, 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().

◆ partitioner()

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

◆ point()

const Point & libMesh::DistributedMesh::point ( const dof_id_type  i) const
finaloverridevirtualinherited
Returns
A constant reference (for reading only) to the \( i^{th} \) point, which should be present in this processor's subset of the mesh data structure.

Implements libMesh::MeshBase.

Definition at line 414 of file distributed_mesh.C.

415{
416 return this->node_ref(i);
417}

References libMesh::MeshBase::node_ref().

◆ 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 2396 of file mesh_base.C.

2397{
2398 // Now that all the DofObject moving is done, we can move the GhostingFunctor objects
2399 // which include the _default_ghosting,_ghosting_functors and _shared_functors. We also need
2400 // to set the mesh object associated with these functors to the assignee mesh.
2401
2402 // _default_ghosting
2403 _default_ghosting = std::move(other_mesh._default_ghosting);
2404 _default_ghosting->set_mesh(this);
2405
2406 // _ghosting_functors
2407 _ghosting_functors = std::move(other_mesh._ghosting_functors);
2408
2409 for (const auto gf : _ghosting_functors )
2410 {
2411 gf->set_mesh(this);
2412 }
2413
2414 // _shared_functors
2415 _shared_functors = std::move(other_mesh._shared_functors);
2416
2417 for (const auto & sf : _shared_functors )
2418 {
2419 (sf.second)->set_mesh(this);
2420 }
2421
2422 // _constraint_rows
2423 _constraint_rows = std::move(other_mesh._constraint_rows);
2424
2425 if (other_mesh.partitioner())
2426 _partitioner = std::move(other_mesh.partitioner());
2427}

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=().

◆ preparation()

Preparation libMesh::MeshBase::preparation ( ) const
inlineinherited

◆ prepare_for_use() [1/3]

void libMesh::MeshBase::prepare_for_use ( )
inherited

◆ prepare_for_use() [2/3]

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

Definition at line 843 of file mesh_base.C.

844{
845 libmesh_deprecated();
846
847 // We only respect the users wish if they tell us to skip renumbering. If they tell us not to
848 // skip renumbering but someone previously called allow_renumbering(false), then the latter takes
849 // precedence
850 if (skip_renumber_nodes_and_elements)
851 this->allow_renumbering(false);
852
853 this->prepare_for_use();
854}

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

◆ prepare_for_use() [3/3]

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

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

This involves several steps: 1.) renumbering (if enabled) 2.) removing any orphaned nodes 3.) updating parallel id counts 4.) finding neighbor links 5.) caching summarized element data 6.) finding interior parent links 7.) clearing any old point locator 8.) calling reinit() on ghosting functors 9.) repartitioning (if enabled) 10.) removing any remote elements (if enabled) 11.) regenerating summarized boundary id sets

For backwards compatibility, prepare_for_use() performs all those steps, regardless of the official preparation() state of the mesh. In codes which have maintained a valid preparation() state via methods such as unset_has_synched_id_counts(), calling complete_preparation() will result in a fully-prepared mesh at less cost.

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 824 of file mesh_base.C.

825{
826 libmesh_deprecated();
827
828 // We only respect the users wish if they tell us to skip renumbering. If they tell us not to
829 // skip renumbering but someone previously called allow_renumbering(false), then the latter takes
830 // precedence
831 if (skip_renumber_nodes_and_elements)
832 this->allow_renumbering(false);
833
834 // We always accept the user's value for skip_find_neighbors, in contrast to skip_renumber
835 const bool old_allow_find_neighbors = this->allow_find_neighbors();
836 this->allow_find_neighbors(!skip_find_neighbors);
837
838 this->prepare_for_use();
839
840 this->allow_find_neighbors(old_allow_find_neighbors);
841}

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(), ExodusC0PolyhedronTest::build_c0polyhedron(), libMesh::MeshTools::Generation::build_cube(), libMesh::MeshTools::Generation::build_extrusion(), DisjointNeighborTest::build_four_disjoint_elems(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::InfElemBuilder::build_inf_elem(), ExodusC0PolygonTest::build_pentagon(), DisjointNeighborTest::build_split_mesh_with_interface(), DisjointNeighborTest::build_two_disjoint_elems(), VolumeTest::buildC0Polyhedron(), libMesh::UnstructuredMesh::create_submesh(), libMesh::MeshTools::Modification::flatten(), main(), libMesh::MeshTools::Subdivision::prepare_subdivision_mesh(), libMesh::GMVIO::read(), libMesh::SimplexRefiner::refine_elements(), libMesh::C0Polyhedron::retriangulate(), libMesh::MeshTools::Generation::surface_octahedron(), libMesh::BoundaryInfo::sync(), MeshSpatialDimensionTest::test1D(), ConstraintOperatorTest::test1DCoarseningNewNodes(), ConstraintOperatorTest::test1DCoarseningOperator(), MeshSpatialDimensionTest::test2D(), AllTriTest::test_helper_c0polyhedron(), ExodusTest< elem_type >::test_read_gold(), XdrIOTest< elem_type >::test_read_gold(), ExodusTest< elem_type >::test_write(), XdrIOTest< elem_type >::test_write(), ExodusC0PolyhedronTest::test_write_and_read_hexagonal_prism(), ExodusC0PolygonTest::test_write_and_read_pentagon(), MeshInputTest::testAbaqusRead(), AllTriTest::testAllTriC0PolygonOctagon(), SystemsTest::testBlockRestrictedVarNDofs(), BoundaryInfoTest::testBoundaryIDs(), BoundaryInfoTest::testBoundaryOnChildrenBoundaryIDs(), BoundaryInfoTest::testBoundaryOnChildrenBoundarySides(), BoundaryInfoTest::testBoundaryOnChildrenElementsRefineCoarsen(), BoundaryInfoTest::testBoundaryOnChildrenErrors(), CheckpointIOTest::testC0PolygonCheckpoint(), CheckpointIOTest::testC0PolyhedronCheckpoint(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyElementVectorImpl(), MeshInputTest::testCopyNodalSolutionImpl(), ConstraintOperatorTest::testCoreform(), MeshDeletionsTest::testDeleteElem(), DisjointNeighborTest::testDisjointNeighborConflictError(), SystemsTest::testDofCouplingWithVarGroups(), MeshInputTest::testDynaFileMappings(), MeshInputTest::testDynaNoSplines(), MeshInputTest::testDynaReadElem(), MeshInputTest::testDynaReadPatch(), ConnectedComponentsTest::testEdge(), MeshTriangulationTest::testEdge3Mesh(), MeshTriangulationTest::testEdgesMesh(), MeshInputTest::testExodusFileMappings(), MeshInputTest::testExodusIGASidesets(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), BoundaryInfoTest::testInternalBoundary(), MeshInputTest::testLowOrderEdgeBlocks(), MeshInputTest::testNemesisReadImpl(), MeshTetTest::testNetGenQuadraticCurved(), MeshTetTest::testNetGenTet14Curved(), NodalNeighborsTest::testOrientation(), PeriodicBCTest::testPeriodicBC(), MeshTriangulationTest::testPoly2TriBad1DMultiBoundary(), MeshTriangulationTest::testPoly2TriBad2DMultiBoundary(), MeshTriangulationTest::testPoly2TriBadEdges(), MeshTriangulationTest::testPoly2TriEdge3ToTri6FlipThrows(), EquationSystemsTest::testPostInitAddElem(), SystemsTest::testProjectMatrix3D(), SystemsTest::testProjectScalarCoarsening(), InfFERadialTest::testRefinement(), EquationSystemsTest::testReinitWithNodeElem(), SystemsTest::testSetSystemParameterOverEquationSystem(), BoundaryInfoTest::testShellFaceConstraints(), MeshInputTest::testSingleElementImpl(), DisjointNeighborTest::testStitchCrossMesh(), MeshInputTest::testTetgenIO(), MeshTetTest::testTetsToTets(), MeshTetTest::testTrisToTetsError(), MeshInputTest::testVTKPreserveElemIds(), MeshInputTest::testVTKPreserveSubdomainIds(), tetrahedralize_domain(), libMesh::NetGenMeshInterface::triangulate(), libMesh::TriangleInterface::triangulate(), libMesh::Poly2TriTriangulator::triangulate(), and libMesh::MeshTetInterface::volume_to_surface_mesh().

◆ print_constraint_rows()

void libMesh::MeshBase::print_constraint_rows ( std::ostream &  os = libMesh::out,
bool  print_nonlocal = false 
) const
inherited

Prints (from processor 0) all mesh constraint rows.

If print_nonlocal is true, then each constraint is printed once for each processor that knows about it, which may be useful for DistributedMesh debugging.

Definition at line 2783 of file mesh_base.C.

2785{
2786 parallel_object_only();
2787
2788 std::string local_constraints =
2789 this->get_local_constraints(print_nonlocal);
2790
2791 if (this->processor_id())
2792 {
2793 this->comm().send(0, local_constraints);
2794 }
2795 else
2796 {
2797 os << "Processor 0:\n";
2798 os << local_constraints;
2799
2800 for (auto p : IntRange<processor_id_type>(1, this->n_processors()))
2801 {
2802 this->comm().receive(p, local_constraints);
2803 os << "Processor " << p << ":\n";
2804 os << local_constraints;
2805 }
2806 }
2807}
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const
std::string get_local_constraints(bool print_nonlocal=false) const
Gets a string reporting all mesh constraint rows local to this processor.
Definition mesh_base.C:2811

References libMesh::ParallelObject::comm(), libMesh::MeshBase::get_local_constraints(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::Parallel::Communicator::receive(), and libMesh::Parallel::Communicator::send().

◆ 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 1755 of file mesh_base.C.

1756{
1757 os << this->get_info(verbosity, global)
1758 << std::endl;
1759}
std::string get_info(const unsigned int verbosity=0, const bool global=true) const
Definition mesh_base.C:1275

References libMesh::MeshBase::get_info().

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

◆ 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.

115 { return cast_int<processor_id_type>(_communicator.rank()); }
processor_id_type rank() const

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

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DistributedMesh::add_node(), libMesh::MeshTools::Modification::all_tri(), 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::MeshFunction::check_found_elem(), 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::MeshCommunication::delete_remote_elements(), libMesh::DistributedMesh::DistributedMesh(), libMesh::DistributedMesh::DistributedMesh(), libMesh::DofMapBase::end_dof(), libMesh::DofMapBase::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::find_dofs_to_send(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMapBase::first_dof(), libMesh::DofMapBase::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::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::RBEIMEvaluation::get_interior_basis_functions_as_vecs(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::DofMap::get_local_constraints(), libMesh::MeshBase::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(), 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::MeshTools::Modification::interpolate_surface(), libMesh::SparsityPattern::Build::join(), libMesh::RBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files(), libMesh::TransientRBEvaluation::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(), main(), AugmentSparsityOnInterface::mesh_reinit(), libMesh::TriangulatorInterface::MeshedHole::MeshedHole(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::MeshTools::n_connected_components(), libMesh::MeshBase::n_constraint_rows(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::DofMapBase::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::DistributedMesh::own_node(), libMesh::BoundaryInfo::parallel_sync_node_ids(), libMesh::BoundaryInfo::parallel_sync_side_ids(), libMesh::MeshBase::print_constraint_rows(), 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::XdrIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::NameBasedIO::read(), libMesh::EquationSystems::read(), libMesh::EquationSystems::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_global_values(), libMesh::CheckpointIO::read_header(), libMesh::ExodusII_IO::read_header(), libMesh::System::read_header(), libMesh::XdrIO::read_header(), libMesh::DynaIO::read_mesh(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::System::read_parallel_data(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::TransientRBConstruction::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::SimplexRefiner::refine_via_edges(), libMesh::SimplexRefiner::refine_via_edges(), libMesh::StaticCondensationDofMap::reinit(), 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(), MeshFunctionTest::test_bad_gradient_var_with_out_of_mesh_value(), MeshFunctionTest::test_bad_hessian_var_with_out_of_mesh_value(), ExodusTest< elem_type >::test_read_gold(), ExodusTest< elem_type >::test_write(), ExodusC0PolyhedronTest::test_write_and_read_hexagonal_prism(), ExodusC0PolygonTest::test_write_and_read_pentagon(), MeshInputTest::testAbaqusRead(), MeshInputTest::testBadGmsh(), BoundaryInfoTest::testBoundaryIDs(), 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::testGmshBCIDOverlap(), MeshInputTest::testGoodGmsh(), MeshInputTest::testGoodSTL(), MeshInputTest::testGoodSTLBinary(), BoundaryInfoTest::testInternalBoundary(), MeshInputTest::testLowOrderEdgeBlocks(), BoundaryMeshSubdomainTest::testPerBoundarySubdomain(), SystemsTest::testProjectMatrix3D(), BoundaryInfoTest::testShellFaceConstraints(), MeshInputTest::testSingleElementImpl(), BoundaryMeshSubdomainTest::testSingleSubdomain(), WriteVecAndScalar::testSolution(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), MeshSmootherTest::testVariationalSmoother(), libMesh::MeshTools::total_weight(), libMesh::NetGenMeshInterface::triangulate(), libMesh::Parallel::Packing< Elem * >::unpack(), libMesh::Parallel::Packing< Node * >::unpack(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::DTKAdapter::update_variable_values(), libMesh::MeshTools::volume(), libMesh::STLIO::write(), libMesh::XdrIO::write(), libMesh::NameBasedIO::write(), libMesh::CheckpointIO::write(), libMesh::EquationSystems::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO::write_element_data_from_discontinuous_nodal_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::ExodusII_IO::write_nodal_data(), libMesh::VTKIO::write_nodal_data(), libMesh::UCDIO::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::ExodusII_IO_Helper::write_nodesets(), libMesh::Nemesis_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::ExodusII_IO_Helper::write_sidesets(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), libMesh::ExodusII_IO_Helper::write_timestep(), and libMesh::ExodusII_IO::write_timestep_discontinuous().

◆ query_elem_ptr() [1/2]

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

Implements libMesh::MeshBase.

Definition at line 497 of file distributed_mesh.C.

498{
499 if (const auto it = _elements.find(i);
500 it != _elements.end())
501 {
502 const Elem * e = *it;
503 libmesh_assert (!e || e->id() == i);
504 return e;
505 }
506
507 return nullptr;
508}

References libMesh::DistributedMesh::_elements, libMesh::DofObject::id(), and libMesh::libmesh_assert().

Referenced by libMesh::DistributedMesh::subclass_locally_equals(), ExodusC0PolyhedronTest::test_write_and_read_hexagonal_prism(), and ExodusC0PolygonTest::test_write_and_read_pentagon().

◆ query_elem_ptr() [2/2]

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

Implements libMesh::MeshBase.

Definition at line 513 of file distributed_mesh.C.

514{
515 if (auto it = _elements.find(i);
516 it != _elements.end())
517 {
518 Elem * e = *it;
519 libmesh_assert (!e || e->id() == i);
520 return e;
521 }
522
523 return nullptr;
524}

References libMesh::DistributedMesh::_elements, libMesh::DofObject::id(), and libMesh::libmesh_assert().

◆ query_node_ptr() [1/2]

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

Implements libMesh::MeshBase.

Definition at line 443 of file distributed_mesh.C.

444{
445 if (const auto it = _nodes.find(i);
446 it != _nodes.end())
447 {
448 const Node * n = *it;
449 libmesh_assert (!n || n->id() == i);
450 return n;
451 }
452
453 return nullptr;
454}

References libMesh::DistributedMesh::_nodes, libMesh::DofObject::id(), and libMesh::libmesh_assert().

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

◆ query_node_ptr() [2/2]

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

Implements libMesh::MeshBase.

Definition at line 459 of file distributed_mesh.C.

460{
461 if (auto it = _nodes.find(i);
462 it != _nodes.end())
463 {
464 Node * n = *it;
465 libmesh_assert (!n || n->id() == i);
466 return n;
467 }
468
469 return nullptr;
470}

References libMesh::DistributedMesh::_nodes, libMesh::DofObject::id(), and libMesh::libmesh_assert().

◆ 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,
bool  skip_detect_interior_parents = false 
)
overridevirtualinherited

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 1362 of file unstructured_mesh.C.

1367{
1368 // Set the skip_renumber_nodes_and_elements flag on all processors
1369 // if necessary.
1370 // This ensures that renumber_nodes_and_elements is *not* called
1371 // during prepare_for_use() for certain types of mesh files.
1372 // This is required in cases where there is an associated solution
1373 // file which expects a certain ordering of the nodes.
1374 if (Utility::ends_with(name, ".gmv"))
1375 this->allow_renumbering(false);
1376
1377 NameBasedIO(*this).read(name);
1378
1379 if (skip_renumber_nodes_and_elements)
1380 {
1381 // Use MeshBase::allow_renumbering() yourself instead.
1382 libmesh_deprecated();
1383 this->allow_renumbering(false);
1384 }
1385
1386 // Done reading the mesh. Now prepare it for use.
1387 const bool old_allow_find_neighbors = this->allow_find_neighbors();
1388 const bool old_allow_detect_interior_parents = this->allow_detect_interior_parents();
1389
1390 this->allow_find_neighbors(!skip_find_neighbors);
1391 this->allow_detect_interior_parents(!skip_detect_interior_parents);
1392
1393 this->prepare_for_use();
1394
1395 this->allow_find_neighbors(old_allow_find_neighbors);
1396 this->allow_detect_interior_parents(old_allow_detect_interior_parents);
1397}
virtual void read(const std::string &mesh_file) override
This method implements reading a mesh from a specified file.
bool ends_with(std::string_view superstring, std::string_view suffix)
Look for a substring at the very end of a string.
Definition utility.C:213

References libMesh::MeshBase::allow_detect_interior_parents(), libMesh::MeshBase::allow_find_neighbors(), libMesh::MeshBase::allow_renumbering(), libMesh::Utility::ends_with(), libMesh::MeshBase::prepare_for_use(), and libMesh::NameBasedIO::read().

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

◆ 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 1813 of file mesh_base.C.

1814{
1815 // This requires an inspection on every processor
1816 parallel_object_only();
1817
1818 unsigned int max_proc_id=0;
1819
1820 for (const auto & elem : this->active_local_element_ptr_range())
1821 max_proc_id = std::max(max_proc_id, static_cast<unsigned int>(elem->processor_id()));
1822
1823 // The number of partitions is one more than the max processor ID.
1824 _n_parts = max_proc_id+1;
1825
1826 this->comm().max(_n_parts);
1827
1828 return _n_parts;
1829}
void ErrorVector unsigned int

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

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

◆ redistribute()

void libMesh::DistributedMesh::redistribute ( )
overridevirtualinherited

Redistribute elements between processors.

This gets called automatically by the Partitioner, and is a no-op in the case of a serialized mesh.

Reimplemented from libMesh::MeshBase.

Definition at line 1046 of file distributed_mesh.C.

1047{
1048 // If this is a truly parallel mesh, go through the redistribution/gather/delete remote steps
1049 if (!this->is_serial())
1050 {
1051 // Construct a MeshCommunication object to actually redistribute the nodes
1052 // and elements according to the partitioner, and then to re-gather the neighbors.
1053 MeshCommunication mc;
1054 mc.redistribute(*this);
1055
1057
1058 // We ought to still have valid neighbor links; we communicate
1059 // them for newly-redistributed elements
1060 // this->find_neighbors();
1061
1062 // Is this necessary? If we are called from prepare_for_use(), this will be called
1063 // anyway... but users can always call partition directly, in which case we do need
1064 // to call delete_remote_elements()...
1065 //
1066 // Regardless of whether it's necessary, it isn't safe. We
1067 // haven't communicated new node processor_ids yet, and we can't
1068 // delete nodes until we do.
1069 // this->delete_remote_elements();
1070 }
1071 else
1072 // The base class can handle non-distributed things, like
1073 // notifying any GhostingFunctors of changes
1075}
virtual bool is_serial() const override final
virtual void redistribute()
Redistribute elements between processors.
Definition mesh_base.C:1168

References libMesh::DistributedMesh::is_serial(), libMesh::MeshBase::redistribute(), libMesh::MeshCommunication::redistribute(), and libMesh::DistributedMesh::update_parallel_id_counts().

◆ reinit_ghosting_functors()

void libMesh::MeshBase::reinit_ghosting_functors ( )
inherited

Loops over ghosting functors and calls mesh_reinit()

Definition at line 1025 of file mesh_base.C.

1026{
1027 for (auto & gf : _ghosting_functors)
1028 {
1029 libmesh_assert(gf);
1030 gf->mesh_reinit();
1031 }
1032
1034}

References libMesh::MeshBase::_ghosting_functors, libMesh::MeshBase::_preparation, libMesh::MeshBase::Preparation::has_reinit_ghosting_functors, and libMesh::libmesh_assert().

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

◆ remove_disjoint_boundary_pair()

void libMesh::MeshBase::remove_disjoint_boundary_pair ( const boundary_id_type  b1,
const boundary_id_type  b2 
)
inherited

Definition at line 2306 of file mesh_base.C.

2308 {
2309 // Nothing to remove if not allocated or empty
2311 return;
2312
2313 auto & pairs = *_disjoint_neighbor_boundary_pairs;
2314
2315 // Helper to check and erase both directions
2316 auto erase_if_match = [](boundary_id_type key,
2317 boundary_id_type pair,
2318 PeriodicBoundaries & pb_map)
2319 {
2320 auto it = pb_map.find(key);
2321 if (it != pb_map.end())
2322 {
2323 const auto & pb = *(it->second);
2324 // Check both directions
2325 if ((pb.myboundary == key && pb.pairedboundary == pair) ||
2326 (pb.pairedboundary == key && pb.myboundary == pair))
2327 pb_map.erase(it);
2328 }
2329 };
2330
2331 erase_if_match(b1, b2, pairs);
2332 erase_if_match(b2, b1, pairs);
2333 }
int8_t boundary_id_type
Definition id_types.h:51

References libMesh::MeshBase::_disjoint_neighbor_boundary_pairs.

Referenced by libMesh::UnstructuredMesh::stitching_helper().

◆ 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 1100 of file mesh_base.C.

1101{
1102 auto raw_it = std::find(_ghosting_functors.begin(),
1103 _ghosting_functors.end(), &ghosting_functor);
1104
1105 // The DofMap has a "to_mesh" parameter that tells it to avoid
1106 // registering a new functor with the mesh, but it doesn't keep
1107 // track of which functors weren't added, so we'll support "remove a
1108 // functor that isn't there" just like we did with set::erase
1109 // before.
1110 if (raw_it != _ghosting_functors.end())
1111 _ghosting_functors.erase(raw_it);
1112
1113 // We shouldn't have had two copies of the same functor
1114 libmesh_assert(std::find(_ghosting_functors.begin(),
1115 _ghosting_functors.end(),
1116 &ghosting_functor) ==
1117 _ghosting_functors.end());
1118
1119 if (const auto it = _shared_functors.find(&ghosting_functor);
1120 it != _shared_functors.end())
1121 _shared_functors.erase(it);
1122}

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

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

◆ remove_orphaned_nodes()

void libMesh::MeshBase::remove_orphaned_nodes ( )
inherited

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

Typically done automatically in a preparation step

Definition at line 801 of file mesh_base.C.

802{
803 LOG_SCOPE("remove_orphaned_nodes()", "MeshBase");
804
805 // Will hold the set of nodes that are currently connected to elements
806 std::unordered_set<Node *> connected_nodes;
807
808 // Loop over the elements. Find which nodes are connected to at
809 // least one of them.
810 for (const auto & element : this->element_ptr_range())
811 for (auto & n : element->node_ref_range())
812 connected_nodes.insert(&n);
813
814 for (const auto & node : this->node_ptr_range())
815 if (!connected_nodes.count(node))
816 this->delete_node(node);
817
819}

References libMesh::MeshBase::_preparation, libMesh::MeshBase::delete_node(), and libMesh::MeshBase::Preparation::has_removed_orphaned_nodes.

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

◆ renumber_dof_objects()

template<typename T >
dof_id_type libMesh::DistributedMesh::renumber_dof_objects ( dofobject_container< T > &  objects)
inherited

Renumber a parallel objects container.

Returns
The smallest globally unused id for that container.

Definition at line 1212 of file distributed_mesh.C.

1213{
1214 // This function must be run on all processors at once
1215 parallel_object_only();
1216
1217 typedef typename dofobject_container<T>::veclike_iterator object_iterator;
1218
1219 // In parallel we may not know what objects other processors have.
1220 // Start by figuring out how many
1221 dof_id_type unpartitioned_objects = 0;
1222
1223 std::unordered_map<processor_id_type, dof_id_type>
1224 ghost_objects_from_proc;
1225
1226 object_iterator it = objects.begin();
1227 object_iterator end = objects.end();
1228
1229 while (it != end)
1230 {
1231 T * obj = *it;
1232
1233 // Remove any nullptr container entries while we're here.
1234 if (!obj)
1235 it = objects.erase(it);
1236 else
1237 {
1238 processor_id_type obj_procid = obj->processor_id();
1239 if (obj_procid == DofObject::invalid_processor_id)
1240 unpartitioned_objects++;
1241 else
1242 ghost_objects_from_proc[obj_procid]++;
1243
1244 // Finally, increment the iterator
1245 ++it;
1246 }
1247 }
1248
1249 std::vector<dof_id_type> objects_on_proc(this->n_processors(), 0);
1250 auto this_it = ghost_objects_from_proc.find(this->processor_id());
1251 this->comm().allgather
1252 ((this_it == ghost_objects_from_proc.end()) ?
1253 dof_id_type(0) : this_it->second, objects_on_proc);
1254
1255#ifndef NDEBUG
1256 libmesh_assert(this->comm().verify(unpartitioned_objects));
1257 for (processor_id_type p=0, np=this->n_processors(); p != np; ++p)
1258 if (ghost_objects_from_proc.count(p))
1259 libmesh_assert_less_equal (ghost_objects_from_proc[p], objects_on_proc[p]);
1260 else
1261 libmesh_assert_less_equal (0, objects_on_proc[p]);
1262#endif
1263
1264 // We'll renumber objects in blocks by processor id
1265 std::vector<dof_id_type> first_object_on_proc(this->n_processors());
1266 for (processor_id_type i=1, np=this->n_processors(); i != np; ++i)
1267 first_object_on_proc[i] = first_object_on_proc[i-1] +
1268 objects_on_proc[i-1];
1269 dof_id_type next_id = first_object_on_proc[this->processor_id()];
1270 dof_id_type first_free_id =
1271 first_object_on_proc[this->n_processors()-1] +
1272 objects_on_proc[this->n_processors()-1] +
1273 unpartitioned_objects;
1274
1275 // First set new local object ids and build request sets
1276 // for non-local object ids
1277
1278 // Request sets to send to each processor
1279 std::map<processor_id_type, std::vector<dof_id_type>>
1280 requested_ids;
1281
1282 // We know how many objects live on each processor, so reserve() space for
1283 // each.
1284 auto ghost_end = ghost_objects_from_proc.end();
1285 for (auto p : make_range(this->n_processors()))
1286 if (p != this->processor_id())
1287 {
1288 if (const auto p_it = ghost_objects_from_proc.find(p);
1289 p_it != ghost_end)
1290 requested_ids[p].reserve(p_it->second);
1291 }
1292
1293 end = objects.end();
1294 for (it = objects.begin(); it != end; ++it)
1295 {
1296 T * obj = *it;
1297 if (!obj)
1298 continue;
1299 if (obj->processor_id() == this->processor_id())
1300 obj->set_id(next_id++);
1301 else if (obj->processor_id() != DofObject::invalid_processor_id)
1302 requested_ids[obj->processor_id()].push_back(obj->id());
1303 }
1304
1305 // Next set ghost object ids from other processors
1306
1307 auto gather_functor =
1308 [
1309#ifndef NDEBUG
1310 this,
1311 &first_object_on_proc,
1312 &objects_on_proc,
1313#endif
1314 &objects]
1315 (processor_id_type, const std::vector<dof_id_type> & ids,
1316 std::vector<dof_id_type> & new_ids)
1317 {
1318 std::size_t ids_size = ids.size();
1319 new_ids.resize(ids_size);
1320
1321 for (std::size_t i=0; i != ids_size; ++i)
1322 {
1323 T * obj = objects[ids[i]];
1324 libmesh_assert(obj);
1325 libmesh_assert_equal_to (obj->processor_id(), this->processor_id());
1326 new_ids[i] = obj->id();
1327
1328 libmesh_assert_greater_equal (new_ids[i],
1329 first_object_on_proc[this->processor_id()]);
1330 libmesh_assert_less (new_ids[i],
1331 first_object_on_proc[this->processor_id()] +
1332 objects_on_proc[this->processor_id()]);
1333 }
1334 };
1335
1336 auto action_functor =
1337 [
1338#ifndef NDEBUG
1339 &first_object_on_proc,
1340 &objects_on_proc,
1341#endif
1342 &objects]
1343 (processor_id_type libmesh_dbg_var(pid),
1344 const std::vector<dof_id_type> & ids,
1345 const std::vector<dof_id_type> & data)
1346 {
1347 // Copy the id changes we've now been informed of
1348 for (auto i : index_range(ids))
1349 {
1350 T * obj = objects[ids[i]];
1351 libmesh_assert (obj);
1352 libmesh_assert_equal_to (obj->processor_id(), pid);
1353 libmesh_assert_greater_equal (data[i],
1354 first_object_on_proc[pid]);
1355 libmesh_assert_less (data[i],
1356 first_object_on_proc[pid] +
1357 objects_on_proc[pid]);
1358 obj->set_id(data[i]);
1359 }
1360 };
1361
1362 const dof_id_type * ex = nullptr;
1364 (this->comm(), requested_ids, gather_functor, action_functor, ex);
1365
1366#ifdef LIBMESH_ENABLE_UNIQUE_ID
1367 auto unique_gather_functor =
1368 [
1369#ifndef NDEBUG
1370 this,
1371#endif
1372 &objects]
1373 (processor_id_type, const std::vector<dof_id_type> & ids,
1374 std::vector<unique_id_type> & data)
1375 {
1376 std::size_t ids_size = ids.size();
1377 data.resize(ids_size);
1378
1379 for (std::size_t i=0; i != ids_size; ++i)
1380 {
1381 T * obj = objects[ids[i]];
1382 libmesh_assert(obj);
1383 libmesh_assert_equal_to (obj->processor_id(), this->processor_id());
1384 data[i] = obj->valid_unique_id() ? obj->unique_id() : DofObject::invalid_unique_id;
1385 }
1386 };
1387
1388 auto unique_action_functor =
1389 [&objects]
1390 (processor_id_type libmesh_dbg_var(pid),
1391 const std::vector<dof_id_type> & ids,
1392 const std::vector<unique_id_type> & data)
1393 {
1394 for (auto i : index_range(ids))
1395 {
1396 T * obj = objects[ids[i]];
1397 libmesh_assert (obj);
1398 libmesh_assert_equal_to (obj->processor_id(), pid);
1399 if (!obj->valid_unique_id() && data[i] != DofObject::invalid_unique_id)
1400 obj->set_unique_id(data[i]);
1401 }
1402 };
1403
1404 const unique_id_type * unique_ex = nullptr;
1406 (this->comm(), requested_ids, unique_gather_functor,
1407 unique_action_functor, unique_ex);
1408#endif
1409
1410 // Next set unpartitioned object ids
1411 next_id = 0;
1412 for (auto i : make_range(this->n_processors()))
1413 next_id += objects_on_proc[i];
1414 for (it = objects.begin(); it != end; ++it)
1415 {
1416 T * obj = *it;
1417 if (!obj)
1418 continue;
1419 if (obj->processor_id() == DofObject::invalid_processor_id)
1420 obj->set_id(next_id++);
1421 }
1422
1423 // Finally shuffle around objects so that container indices
1424 // match ids
1425 it = objects.begin();
1426 end = objects.end();
1427 while (it != end)
1428 {
1429 T * obj = *it;
1430 if (obj) // don't try shuffling already-nullptr entries
1431 {
1432 T * next = objects[obj->id()];
1433 // If we have to move this object
1434 if (next != obj)
1435 {
1436 // nullptr out its original position for now
1437 // (our shuffling may put another object there shortly)
1438 *it = nullptr;
1439
1440 // There may already be another object with this id that
1441 // needs to be moved itself
1442 while (next)
1443 {
1444 // We shouldn't be trying to give two objects the
1445 // same id
1446 libmesh_assert_not_equal_to (next->id(), obj->id());
1447 objects[obj->id()] = obj;
1448 obj = next;
1449 next = objects[obj->id()];
1450 }
1451 objects[obj->id()] = obj;
1452 }
1453 }
1454
1455 // Remove any container entries that were left as nullptr.
1456 if (!obj)
1457 it = objects.erase(it);
1458 else
1459 ++it;
1460 }
1461
1462 return first_free_id;
1463}
static constexpr unique_id_type invalid_unique_id
An invalid unique_id to distinguish an uninitialized DofObject.
Definition dof_object.h:478
void pull_parallel_vector_data(const Communicator &comm, const MapToVectors &queries, GatherFunctor &gather_data, const ActionFunctor &act_on_data, const datum *example)

References libMesh::Parallel::Communicator::allgather(), libMesh::mapvector< Val, index_t >::begin(), libMesh::ParallelObject::comm(), libMesh::mapvector< Val, index_t >::end(), libMesh::mapvector< Val, index_t >::erase(), libMesh::index_range(), libMesh::DofObject::invalid_processor_id, libMesh::DofObject::invalid_unique_id, libMesh::libmesh_assert(), libMesh::make_range(), libMesh::ParallelObject::n_processors(), libMesh::DistributedMesh::pid, libMesh::ParallelObject::processor_id(), and TIMPI::pull_parallel_vector_data().

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

◆ renumber_elem()

void libMesh::DistributedMesh::renumber_elem ( dof_id_type  old_id,
dof_id_type  new_id 
)
finaloverridevirtualinherited

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.

Implements libMesh::MeshBase.

Definition at line 758 of file distributed_mesh.C.

760{
761 // This could be a no-op
762 if (old_id == new_id)
763 return;
764
765 Elem * el = _elements[old_id];
766 libmesh_assert (el);
767 libmesh_assert_equal_to (el->id(), old_id);
768
769 el->set_id(new_id);
770 libmesh_assert (!_elements[new_id]);
771 _elements[new_id] = el;
772 _elements.erase(old_id);
773
774 // Should we delete any caches here? Our point locator indexes by
775 // element pointer and should be fine with an id change. Our stored
776 // ranges are no longer sorted, which is *probably* fine, but let's
777 // just be safe.
778 this->clear_stored_ranges();
779}

References libMesh::DistributedMesh::_elements, libMesh::MeshBase::clear_stored_ranges(), libMesh::DofObject::id(), libMesh::libmesh_assert(), and libMesh::DofObject::set_id().

Referenced by MeshPerElemTest< elem_type >::meshes_equal_enough().

◆ renumber_node()

void libMesh::DistributedMesh::renumber_node ( dof_id_type  old_id,
dof_id_type  new_id 
)
finaloverridevirtualinherited

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.

Implements libMesh::MeshBase.

Definition at line 958 of file distributed_mesh.C.

960{
961 // This could be a no-op
962 if (old_id == new_id)
963 return;
964
965 Node * nd = _nodes[old_id];
966 libmesh_assert (nd);
967 libmesh_assert_equal_to (nd->id(), old_id);
968
969 // If we have nodes shipped to this processor for NodeConstraints
970 // use, then those nodes will exist in _nodes, but may not be
971 // locatable via a TopologyMap due to the insufficiency of elements
972 // connecting to them. If local refinement then wants to create a
973 // *new* node in the same location, it will initially get a temporary
974 // id, and then make_node_ids_parallel_consistent() will try to move
975 // it to the canonical id. We need to account for this case to
976 // avoid false positives and memory leaks.
977#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
978 if (_nodes[new_id])
979 {
980 libmesh_assert_equal_to (*(Point *)_nodes[new_id],
981 *(Point *)_nodes[old_id]);
982 _nodes.erase(new_id);
983 }
984#else
985 // If we aren't shipping nodes for NodeConstraints, there should be
986 // no reason for renumbering one node onto another.
987 libmesh_assert (!_nodes[new_id]);
988#endif
989 _nodes[new_id] = nd;
990 nd->set_id(new_id);
991
992 _nodes.erase(old_id);
993}

References libMesh::DistributedMesh::_nodes, libMesh::DofObject::id(), libMesh::libmesh_assert(), and libMesh::DofObject::set_id().

Referenced by MeshPerElemTest< elem_type >::meshes_equal_enough().

◆ renumber_nodes_and_elements()

void libMesh::DistributedMesh::renumber_nodes_and_elements ( )
overridevirtualinherited

Remove nullptr elements from arrays.

Implements libMesh::MeshBase.

Definition at line 1466 of file distributed_mesh.C.

1467{
1468 parallel_object_only();
1469
1470#ifdef DEBUG
1471 // Make sure our ids and flags are consistent
1475#endif
1476
1477 LOG_SCOPE("renumber_nodes_and_elements()", "DistributedMesh");
1478
1479 // Nodes not connected to any elements, and nullptr node entries
1480 // in our container, should be deleted. But wait! If we've deleted coarse
1481 // local elements on some processor, other processors might have ghosted
1482 // nodes from it that are now no longer connected to any elements on it, but
1483 // that are connected to their own semilocal elements. We'll have to
1484 // communicate to ascertain if that's the case.
1486
1487 // What used nodes do we see on our proc?
1488 std::set<dof_id_type> used_nodes;
1489
1490 // What used node info should we send from our proc? Could we take ownership
1491 // of each node if we needed to?
1492 std::map<processor_id_type, std::map<dof_id_type, bool>>
1493 used_nodes_on_proc;
1494
1495 // flag the nodes we need
1496 for (auto & elem : this->element_ptr_range())
1497 for (const Node & node : elem->node_ref_range())
1498 {
1499 const dof_id_type n = node.id();
1500 used_nodes.insert(n);
1502 {
1503 const processor_id_type p = node.processor_id();
1504 if (p != this->processor_id())
1505 {
1506 auto & used_nodes_on_p = used_nodes_on_proc[p];
1507 if (elem->processor_id() == this->processor_id())
1508 used_nodes_on_p[n] = true;
1509 else
1510 if (!used_nodes_on_p.count(n))
1511 used_nodes_on_p[n] = false;
1512 }
1513 }
1514 }
1515
1517 {
1518 // "unsigned char" == "bool, but MPI::BOOL is iffy to use"
1519 typedef unsigned char boolish;
1520 std::map<processor_id_type, std::vector<std::pair<dof_id_type, boolish>>>
1521 used_nodes_on_proc_vecs;
1522 for (auto & [pid, nodemap] : used_nodes_on_proc)
1523 used_nodes_on_proc_vecs[pid].assign(nodemap.begin(), nodemap.end());
1524
1525 std::map<dof_id_type,processor_id_type> repartitioned_node_pids;
1526 std::map<processor_id_type, std::set<dof_id_type>>
1527 repartitioned_node_sets_to_push;
1528
1529 auto ids_action_functor =
1530 [&used_nodes, &repartitioned_node_pids,
1531 &repartitioned_node_sets_to_push]
1533 const std::vector<std::pair<dof_id_type, boolish>> & ids_and_bools)
1534 {
1535 for (auto [n, sender_could_become_owner] : ids_and_bools)
1536 {
1537 // If we don't see a use for our own node, but someone
1538 // else does, better figure out who should own it next.
1539 if (!used_nodes.count(n))
1540 {
1541 if (auto it = repartitioned_node_pids.find(n);
1542 sender_could_become_owner)
1543 {
1544 if (it != repartitioned_node_pids.end() &&
1545 pid < it->second)
1546 it->second = pid;
1547 else
1548 repartitioned_node_pids[n] = pid;
1549 }
1550 else
1551 if (it == repartitioned_node_pids.end())
1552 repartitioned_node_pids[n] =
1554
1555 repartitioned_node_sets_to_push[pid].insert(n);
1556 }
1557 }
1558 };
1559
1560 // We need two pushes instead of a pull here because we need to
1561 // know *all* the queries for a particular node before we can
1562 // respond to *any* of them.
1564 (this->comm(), used_nodes_on_proc_vecs, ids_action_functor);
1565
1566 // Repartition (what used to be) our own nodes first
1567 for (auto & [n, p] : repartitioned_node_pids)
1568 {
1569 Node & node = this->node_ref(n);
1570 libmesh_assert_equal_to(node.processor_id(), this->processor_id());
1571 libmesh_assert_not_equal_to_msg(p, DofObject::invalid_processor_id, "Node " << n << " is lost?");
1572 node.processor_id() = p;
1573 }
1574
1575 // Then push to repartition others' ghosted copies.
1576
1577 std::map<processor_id_type, std::vector<std::pair<dof_id_type,processor_id_type>>>
1578 repartitioned_node_vecs;
1579
1580 for (auto & [p, nodeset] : repartitioned_node_sets_to_push)
1581 {
1582 auto & rn_vec = repartitioned_node_vecs[p];
1583 for (auto n : nodeset)
1584 rn_vec.emplace_back(n, repartitioned_node_pids[n]);
1585 }
1586
1587 auto repartition_node_functor =
1588 [this]
1589 (processor_id_type libmesh_dbg_var(pid),
1590 const std::vector<std::pair<dof_id_type, processor_id_type>> & ids_and_pids)
1591 {
1592 for (auto [n, p] : ids_and_pids)
1593 {
1594 libmesh_assert_not_equal_to(p, DofObject::invalid_processor_id);
1595 Node & node = this->node_ref(n);
1596 libmesh_assert_equal_to(node.processor_id(), pid);
1597 node.processor_id() = p;
1598 }
1599 };
1600
1602 (this->comm(), repartitioned_node_vecs, repartition_node_functor);
1603 }
1604
1606
1607 // Nodes not connected to any local elements, and nullptr node entries
1608 // in our container, are deleted
1609 {
1610 node_iterator_imp it = _nodes.begin();
1611 node_iterator_imp end = _nodes.end();
1612
1613 while (it != end)
1614 {
1615 Node * nd = *it;
1616 if (!nd)
1617 it = _nodes.erase(it);
1618 else if (!used_nodes.count(nd->id()))
1619 {
1620 // remove any boundary information associated with
1621 // this node
1622 this->get_boundary_info().remove (nd);
1623 _constraint_rows.erase(nd);
1624
1625 // delete the node
1626 delete nd;
1627
1628 it = _nodes.erase(it);
1629 }
1630 else
1631 ++it;
1632 }
1633 }
1634
1636
1638 {
1640 return;
1641 }
1642
1643 // Finally renumber all the elements
1644 _n_elem = this->renumber_dof_objects (this->_elements);
1645
1646 // and all the remaining nodes
1647 _n_nodes = this->renumber_dof_objects (this->_nodes);
1648
1649 // And figure out what IDs we should use when adding new nodes and
1650 // new elements
1652
1653 // Make sure our caches are up to date and our
1654 // DofObjects are well packed
1655#ifdef DEBUG
1656 libmesh_assert_equal_to (this->n_nodes(), this->parallel_n_nodes());
1657 libmesh_assert_equal_to (this->n_elem(), this->parallel_n_elem());
1658 const dof_id_type pmax_node_id = this->parallel_max_node_id();
1659 const dof_id_type pmax_elem_id = this->parallel_max_elem_id();
1660 libmesh_assert_equal_to (this->max_node_id(), pmax_node_id);
1661 libmesh_assert_equal_to (this->max_elem_id(), pmax_elem_id);
1662 libmesh_assert_equal_to (this->n_nodes(), this->max_node_id());
1663 libmesh_assert_equal_to (this->n_elem(), this->max_elem_id());
1664
1665 // Make sure our ids and flags are consistent
1668
1669 // And make sure we've made our numbering monotonic
1671#endif
1672}
dof_id_type renumber_dof_objects(dofobject_container< T > &)
Renumber a parallel objects container.
void libmesh_assert_valid_parallel_p_levels() const
Verify p_level consistency of our elements containers.
dofobject_container< Node >::veclike_iterator node_iterator_imp
Typedefs for the container implementation.
virtual MeshBase & assign(MeshBase &&other_mesh) override
Shim to call the move assignment operator for this class.
void push_parallel_vector_data(const Communicator &comm, MapToVectors &&data, const ActionFunctor &act_on_data)
void libmesh_assert_valid_elem_ids(const MeshBase &mesh)
A function for verifying that ids and processor assignment of elements are correctly sorted (monotone...

References libMesh::MeshBase::_constraint_rows, libMesh::DistributedMesh::_deleted_coarse_elements, libMesh::DistributedMesh::_elements, libMesh::DistributedMesh::_n_elem, libMesh::DistributedMesh::_n_nodes, libMesh::DistributedMesh::_nodes, libMesh::MeshBase::_preparation, libMesh::MeshBase::_skip_renumber_nodes_and_elements, libMesh::DistributedMesh::assign(), libMesh::ParallelObject::comm(), libMesh::MeshBase::get_boundary_info(), libMesh::MeshBase::Preparation::has_removed_orphaned_nodes, libMesh::DofObject::id(), libMesh::DofObject::invalid_processor_id, libMesh::MeshTools::libmesh_assert_valid_elem_ids(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_flags(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_ids(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_p_levels(), libMesh::Parallel::Communicator::max(), libMesh::DistributedMesh::max_elem_id(), libMesh::DistributedMesh::max_node_id(), libMesh::DistributedMesh::n_elem(), libMesh::DistributedMesh::n_nodes(), libMesh::MeshBase::node_ref(), libMesh::DistributedMesh::parallel_max_elem_id(), libMesh::DistributedMesh::parallel_max_node_id(), libMesh::DistributedMesh::parallel_n_elem(), libMesh::DistributedMesh::parallel_n_nodes(), libMesh::DistributedMesh::pid, libMesh::DofObject::processor_id(), libMesh::ParallelObject::processor_id(), TIMPI::push_parallel_vector_data(), libMesh::BoundaryInfo::remove(), libMesh::DistributedMesh::renumber_dof_objects(), and libMesh::DistributedMesh::update_parallel_id_counts().

◆ reserve_elem()

virtual void libMesh::DistributedMesh::reserve_elem ( const dof_id_type  ne)
inlinefinaloverridevirtualinherited

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.

Implements libMesh::MeshBase.

Definition at line 276 of file distributed_mesh.h.

276{}

◆ reserve_nodes()

virtual void libMesh::DistributedMesh::reserve_nodes ( const dof_id_type  nn)
inlinefinaloverridevirtualinherited

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.

Implements libMesh::MeshBase.

Definition at line 272 of file distributed_mesh.h.

272{}

◆ 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 1873 of file mesh_base.C.

1874{
1875 _count_lower_dim_elems_in_point_locator = count_lower_dim_elems;
1876}

References libMesh::MeshBase::_count_lower_dim_elems_in_point_locator.

◆ 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 968 of file mesh_base.h.

969 {
971 }

References libMesh::MeshBase::_default_mapping_data.

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

◆ 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 950 of file mesh_base.h.

951 {
953 }

References libMesh::MeshBase::_default_mapping_type.

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

◆ set_distributed()

virtual void libMesh::DistributedMesh::set_distributed ( )
inlinefinaloverridevirtualinherited

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

Reimplemented from libMesh::MeshBase.

Definition at line 174 of file distributed_mesh.h.

175 { _is_serial = false;
176 _is_serial_on_proc_0 = false; }

References libMesh::DistributedMesh::_is_serial, and libMesh::DistributedMesh::_is_serial_on_proc_0.

◆ 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 439 of file mesh_base.C.

440{
441#ifdef DEBUG
442 // In debug mode, we call cache_elem_data() and then make sure
443 // the result actually agrees with what the user specified.
444 parallel_object_only();
445
446 this->cache_elem_data();
447 libmesh_assert_msg(_elem_dims == elem_dims, \
448 "Specified element dimensions does not match true element dimensions!");
449#endif
450
451 _elem_dims = std::move(elem_dims);
452}

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

◆ set_interior_mesh()

void libMesh::MeshBase::set_interior_mesh ( MeshBase int_mesh)
inlineinherited

Sets the interior mesh.

For advanced use only.

Definition at line 2050 of file mesh_base.h.

2050{ _interior_mesh = &int_mesh; }

References libMesh::MeshBase::_interior_mesh.

Referenced by libMesh::BoundaryInfo::add_elements(), and libMesh::UnstructuredMesh::copy_nodes_and_elements().

◆ 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.

This is a very coarse setting; it is generally more efficient to mark finer-grained settings instead.

This method name is now deprecated, in part to match the less awkward unset_has_ names of the more fine-grained methods, in part as a way to prompt older user codes to use the more fine-grained methods where they can, to speed up the complete_preparation() calls afterward.

Definition at line 228 of file mesh_base.h.

229 { libmesh_deprecated(); _preparation = false; }

References libMesh::MeshBase::_preparation.

◆ set_mesh_dimension()

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

◆ set_n_partitions()

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

Definition at line 2164 of file mesh_base.h.

2165 { return _n_parts; }

References libMesh::MeshBase::_n_parts.

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

◆ set_next_unique_id()

void libMesh::DistributedMesh::set_next_unique_id ( unique_id_type  id)
overridevirtualinherited

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.

Implements libMesh::MeshBase.

Definition at line 354 of file distributed_mesh.C.

355{
356 _next_unique_id = id;
358 ((_next_unique_id-1) / (this->n_processors() + 1) + 1) *
359 (this->n_processors() + 1) + this->n_processors();
361 ((_next_unique_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
362 (this->n_processors() + 1) + this->processor_id();
363}

References libMesh::MeshBase::_next_unique_id, libMesh::DistributedMesh::_next_unpartitioned_unique_id, libMesh::ParallelObject::n_processors(), and libMesh::ParallelObject::processor_id().

Referenced by MeshPerElemTest< elem_type >::meshes_equal_enough().

◆ 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 2340 of file mesh_base.C.

2341{
2343 if (_point_locator)
2344 {
2345 if (val > 0.)
2346 _point_locator->set_close_to_point_tol(val);
2347 else
2348 _point_locator->unset_close_to_point_tol();
2349 }
2350}

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

◆ 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 613 of file mesh_base.C.

614{
615 // The user can set the _spatial_dimension however they wish,
616 // libMesh will only *increase* the spatial dimension, however,
617 // never decrease it.
619}

References libMesh::MeshBase::_spatial_dimension.

Referenced by libMesh::MeshTools::Generation::build_cube(), MeshSpatialDimensionTest::test2D(), and InfFERadialTest::testRefinement().

◆ set_subdomain_name()

void libMesh::MeshBase::set_subdomain_name ( subdomain_id_type  id,
const std::string &  name,
bool  synchronous = false 
)
inherited

Sets the name for the provided id.

Parameters
idThe subdomain id to set the name for
nameThe subdomain name
synchronousWhether this method is being called across all mesh ranks. If this is true, then we don't have to register this collective container as being out of sync

Definition at line 1914 of file mesh_base.C.

1917{
1918 if (synchronous)
1919 parallel_object_only();
1920 else
1922 _block_id_to_name[id] = name;
1923}
void unset_has_synched_subdomain_name_map()
Tells this we have done some operation which may have left the subdomain id to name map inconsistent ...
Definition mesh_base.h:350

References libMesh::MeshBase::_block_id_to_name, and libMesh::MeshBase::unset_has_synched_subdomain_name_map().

Referenced by libMesh::AbaqusIO::assign_subdomain_ids(), libMesh::UNVIO::groups_in(), libMesh::Nemesis_IO::read(), libMesh::ExodusII_IO::read(), libMesh::GmshIO::read_mesh(), libMesh::UnstructuredMesh::stitching_helper(), MeshStitchTest::testAmbiguousRemappingStitch(), and MeshStitchTest::testRemappingStitch().

◆ set_subdomain_name_map()

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

◆ 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 2361 of file mesh_base.C.

2362{
2363 const std::size_t new_size = _elem_integer_names.size();
2364
2366 (this->element_stored_range(),
2367 [new_size, this](const ElemRange & range)
2368 {
2369 for (Elem * elem : range)
2370 elem->add_extra_integers(new_size, this->_elem_integer_default_values);
2371 });
2372}

References libMesh::MeshBase::_elem_integer_names, libMesh::MeshBase::element_stored_range(), and libMesh::Threads::parallel_for().

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

◆ 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 2376 of file mesh_base.C.

2377{
2378 const std::size_t new_size = _node_integer_names.size();
2379 for (auto node : this->node_ptr_range())
2380 node->add_extra_integers(new_size, _node_integer_default_values);
2381}

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().

◆ skip_noncritical_partitioning() [1/2]

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

◆ skip_noncritical_partitioning() [2/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 1411 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().

◆ skip_partitioning() [1/2]

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

◆ skip_partitioning() [2/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 1429 of file mesh_base.h.

1429{ _skip_all_partitioning = skip; }

References libMesh::MeshBase::_skip_all_partitioning.

Referenced by libMesh::DistributedMesh::DistributedMesh(), libMesh::CheckpointIO::read(), libMesh::ReplicatedMesh::ReplicatedMesh(), and CheckpointIOTest::testSplitter().

◆ 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 mesh preparation based on the dimensions of the various elements present in the Mesh, but is never automatically decreased.

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() or complete_preparation(). 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 606 of file mesh_base.C.

607{
608 return cast_int<unsigned int>(_spatial_dimension);
609}

References libMesh::MeshBase::_spatial_dimension.

Referenced by libMesh::EquationSystems::build_elemental_data_variable_names(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::EquationSystems::build_variable_names(), libMesh::EquationSystems::find_variable_numbers_by_predicate(), libMesh::MeshBase::get_info(), libMesh::ExodusII_IO_Helper::initialize(), MeshSpatialDimensionTest::test1D(), and MeshSpatialDimensionTest::test2D().

◆ 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,
bool  prepare_after_stitching = true 
)
inherited

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.

If prepare_after_stitching is true then we prepare the newly stitched mesh for use immediately after stitching. If the mesh does not need to be completely prepared for use yet (e.g. because it will undergo further stitching etc. before repartitioning for load balancing is desired), this can be set to false to potentially improve performance.

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 1869 of file unstructured_mesh.C.

1880{
1881 LOG_SCOPE("stitch_meshes()", "UnstructuredMesh");
1882 return stitching_helper(&other_mesh,
1883 this_mesh_boundary_id,
1884 other_mesh_boundary_id,
1885 tol,
1886 clear_stitched_boundary_ids,
1887 verbose,
1888 use_binary_search,
1889 enforce_all_nodes_match_on_boundaries,
1890 true,
1891 merge_boundary_nodes_all_or_nothing,
1892 remap_subdomain_ids,
1893 prepare_after_stitching);
1894}
std::size_t stitching_helper(const MeshBase *other_mesh, boundary_id_type boundary_id_1, boundary_id_type boundary_id_2, Real tol, bool clear_stitched_boundary_ids, bool verbose, bool use_binary_search, bool enforce_all_nodes_match_on_boundaries, bool skip_find_neighbors, bool merge_boundary_nodes_all_or_nothing, bool remap_subdomain_ids, bool prepare_after_stitching)
Helper function for stitch_meshes and stitch_surfaces that does the mesh stitching.

References libMesh::UnstructuredMesh::stitching_helper().

Referenced by main(), DisjointNeighborTest::testDisjointNeighborConflictError(), MeshStitchTest::testNodeElemStitch(), and DisjointNeighborTest::testStitchCrossMesh().

◆ 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,
bool  prepare_after_stitching = true 
)
inherited

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

Definition at line 1898 of file unstructured_mesh.C.

1908{
1909 return stitching_helper(nullptr,
1910 boundary_id_1,
1911 boundary_id_2,
1912 tol,
1913 clear_stitched_boundary_ids,
1914 verbose,
1915 use_binary_search,
1916 enforce_all_nodes_match_on_boundaries,
1917 /* skip_find_neighbors = */ true,
1918 merge_boundary_nodes_all_or_nothing,
1919 /* remap_subdomain_ids = */ false,
1920 prepare_after_stitching);
1921}

References libMesh::UnstructuredMesh::stitching_helper().

Referenced by DisjointNeighborTest::testStitchingDiscontinuousBoundaries().

◆ 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,
bool  prepare_after_stitching 
)
privateinherited

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

Definition at line 1925 of file unstructured_mesh.C.

1937{
1938#ifdef DEBUG
1939 // We rely on neighbor links here
1941#endif
1942
1943 bool is_valid_disjoint_pair_to_stitch = false;
1944
1945#ifdef LIBMESH_ENABLE_PERIODIC
1946 auto * this_db = this->get_disjoint_neighbor_boundary_pairs();
1947 auto * other_db = (other_mesh ? other_mesh->get_disjoint_neighbor_boundary_pairs() : nullptr);
1948 const bool have_disc_bdys =
1949 (this_db && !this_db->empty()) || (other_db && !other_db->empty());
1950
1951 if (have_disc_bdys)
1952 {
1953 const boundary_id_type a = this_mesh_boundary_id;
1954 const boundary_id_type b = other_mesh_boundary_id;
1955
1956 auto get_pb = [](const PeriodicBoundaries * db, boundary_id_type id)
1957 {
1958 return db ? db->boundary(id) : nullptr;
1959 };
1960
1961 // this mesh
1962 const auto * pb_this_a = get_pb(this_db, a);
1963 const auto * pb_this_b = get_pb(this_db, b);
1964 const bool in_this =
1965 (pb_this_a && pb_this_a->pairedboundary == b) ||
1966 (pb_this_b && pb_this_b->pairedboundary == a);
1967
1968 // other mesh
1969 const auto * pb_other_b = get_pb(other_db, b);
1970 const auto * pb_other_a = get_pb(other_db, a);
1971 const bool in_other =
1972 (pb_other_b && pb_other_b->pairedboundary == a) ||
1973 (pb_other_a && pb_other_a->pairedboundary == b);
1974
1975 // Conflict conditions:
1976 // Case 1: On "this" mesh, a or b exist but are not paired,
1977 // while the other mesh pairs them.
1978 if (!in_this && (pb_this_a || pb_this_b) && in_other)
1979 libmesh_error_msg("Disjoint neighbor boundary pairing mismatch: on 'this' mesh, "
1980 "boundary (" << a << " or " << b
1981 << ") exists but is not paired; on 'other' mesh the pair is present.");
1982
1983 // Case 2: On "other" mesh, a or b exist but are not paired,
1984 // while this mesh pairs them.
1985 if (!in_other && (pb_other_a || pb_other_b) && in_this)
1986 libmesh_error_msg("Disjoint neighbor boundary pairing mismatch: on 'other' mesh, "
1987 "boundary (" << a << " or " << b
1988 << ") exists but is not paired; on 'this' mesh the pair is present.");
1989
1990 // Legal conditions: either side has a correct pairing
1991 if (in_this || in_other)
1992 is_valid_disjoint_pair_to_stitch = true;
1993 }
1994#endif // LIBMESH_ENABLE_PERIODIC
1995
1996 // We can't even afford any unset neighbor links here.
1997 if (!this->is_prepared())
1998 this->find_neighbors();
1999
2000 // FIXME: make distributed mesh support efficient.
2001 // Yes, we currently suck.
2002 MeshSerializer serialize(*this);
2003
2004 // *Badly*.
2005 std::unique_ptr<MeshSerializer> serialize_other;
2006 if (other_mesh)
2007 serialize_other = std::make_unique<MeshSerializer>
2008 (*const_cast<MeshBase *>(other_mesh));
2009
2010 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
2011 std::map<dof_id_type, std::vector<dof_id_type>> node_to_elems_map;
2012
2013 typedef dof_id_type key_type;
2014 typedef std::pair<const Elem *, unsigned char> val_type;
2015 typedef std::pair<key_type, val_type> key_val_pair;
2016 typedef std::unordered_multimap<key_type, val_type> map_type;
2017 // Mapping between all side keys in this mesh and elements+side numbers relevant to the boundary in this mesh as well.
2018 map_type side_to_elem_map;
2019
2020 // If there is only one mesh (i.e. other_mesh == nullptr), then loop over this mesh twice
2021 if (!other_mesh)
2022 {
2023 other_mesh = this;
2024 }
2025
2026 if ((this_mesh_boundary_id != BoundaryInfo::invalid_id) &&
2027 (other_mesh_boundary_id != BoundaryInfo::invalid_id))
2028 {
2029 LOG_SCOPE("stitch_meshes node merging", "UnstructuredMesh");
2030
2031 // While finding nodes on the boundary, also find the minimum edge length
2032 // of all faces on both boundaries. This will later be used in relative
2033 // distance checks when stitching nodes.
2034 Real h_min = std::numeric_limits<Real>::max();
2035 bool h_min_updated = false;
2036
2037 // Loop below fills in these sets for the two meshes.
2038 std::set<dof_id_type> this_boundary_node_ids, other_boundary_node_ids;
2039
2040 // Pull objects out of the loop to reduce heap operations
2041 std::unique_ptr<const Elem> side;
2042
2043 {
2044 // Make temporary fixed-size arrays for loop
2045 boundary_id_type id_array[2] = {this_mesh_boundary_id, other_mesh_boundary_id};
2046 std::set<dof_id_type> * set_array[2] = {&this_boundary_node_ids, &other_boundary_node_ids};
2047 const MeshBase * mesh_array[2] = {this, other_mesh};
2048
2049 for (unsigned i=0; i<2; ++i)
2050 {
2051 // First we deal with node boundary IDs. We only enter
2052 // this loop if we have at least one nodeset. Note that we
2053 // do not attempt to make an h_min determination here.
2054 // The h_min determination is done while looping over the
2055 // Elems and checking their sides and edges for boundary
2056 // information, below.
2057 if (mesh_array[i]->get_boundary_info().n_nodeset_conds() > 0)
2058 {
2059 // build_node_list() returns a vector of (node-id, bc-id) tuples
2060 for (const auto & t : mesh_array[i]->get_boundary_info().build_node_list())
2061 {
2062 boundary_id_type node_bc_id = std::get<1>(t);
2063 if (node_bc_id == id_array[i])
2064 {
2065 dof_id_type this_node_id = std::get<0>(t);
2066 set_array[i]->insert( this_node_id );
2067 }
2068 }
2069 }
2070
2071 // Container to catch boundary IDs passed back from BoundaryInfo.
2072 std::vector<boundary_id_type> bc_ids;
2073
2074 // Pointers to boundary NodeElems encountered while looping over the entire Mesh
2075 // and checking side and edge boundary ids. The Nodes associated with NodeElems
2076 // may be in a boundary nodeset, but not connected to any other Elems. In this
2077 // case, we also consider the "minimum node separation distance" amongst all
2078 // NodeElems when determining the relevant h_min value for this mesh.
2079 std::vector<const Elem *> boundary_node_elems;
2080
2081 for (auto & el : mesh_array[i]->element_ptr_range())
2082 {
2083 // Now check whether elem has a face on the specified boundary
2084 for (auto side_id : el->side_index_range())
2085 {
2086 bool should_stitch_this_side =
2087 (el->neighbor_ptr(side_id) == nullptr) ||
2088 (is_valid_disjoint_pair_to_stitch &&
2089 mesh_array[i]->get_boundary_info().has_boundary_id(el, side_id, id_array[i]));
2090
2091 if (should_stitch_this_side)
2092 {
2093 // Get *all* boundary IDs on this side, not just the first one!
2094 mesh_array[i]->get_boundary_info().boundary_ids (el, side_id, bc_ids);
2095
2096 if (std::find(bc_ids.begin(), bc_ids.end(), id_array[i]) != bc_ids.end())
2097 {
2098 el->build_side_ptr(side, side_id);
2099 for (auto & n : side->node_ref_range())
2100 set_array[i]->insert(n.id());
2101
2102 h_min = std::min(h_min, side->hmin());
2103 h_min_updated = true;
2104
2105 // This side is on the boundary, add its information to side_to_elem
2106 if (skip_find_neighbors && (i==0))
2107 {
2108 key_type key = el->low_order_key(side_id);
2109 val_type val;
2110 val.first = el;
2111 val.second = cast_int<unsigned char>(side_id);
2112
2113 key_val_pair kvp;
2114 kvp.first = key;
2115 kvp.second = val;
2116 side_to_elem_map.insert (kvp);
2117 }
2118 }
2119
2120 // Also, check the edges on this side. We don't have to worry about
2121 // updating neighbor info in this case since elements don't store
2122 // neighbor info on edges.
2123 for (auto edge_id : el->edge_index_range())
2124 {
2125 if (el->is_edge_on_side(edge_id, side_id))
2126 {
2127 // Get *all* boundary IDs on this edge, not just the first one!
2128 mesh_array[i]->get_boundary_info().edge_boundary_ids (el, edge_id, bc_ids);
2129
2130 if (std::find(bc_ids.begin(), bc_ids.end(), id_array[i]) != bc_ids.end())
2131 {
2132 std::unique_ptr<const Elem> edge (el->build_edge_ptr(edge_id));
2133 for (auto & n : edge->node_ref_range())
2134 set_array[i]->insert( n.id() );
2135
2136 h_min = std::min(h_min, edge->hmin());
2137 h_min_updated = true;
2138 }
2139 }
2140 } // end for (edge_id)
2141 } // end if (should_stitch_this_side)
2142 } // end for (side_id)
2143
2144 // Alternatively, is this a boundary NodeElem? If so,
2145 // add it to a list of NodeElems that will later be
2146 // used to set h_min based on the minimum node
2147 // separation distance between all pairs of boundary
2148 // NodeElems.
2149 if (el->type() == NODEELEM)
2150 {
2151 mesh_array[i]->get_boundary_info().boundary_ids(el->node_ptr(0), bc_ids);
2152 if (std::find(bc_ids.begin(), bc_ids.end(), id_array[i]) != bc_ids.end())
2153 {
2154 boundary_node_elems.push_back(el);
2155
2156 // Debugging:
2157 // libMesh::out << "Elem " << el->id() << " is a NodeElem on boundary " << id_array[i] << std::endl;
2158 }
2159 } // end if (el->type() == NODEELEM)
2160 } // end for (el)
2161
2162 // Compute the minimum node separation distance amongst
2163 // all boundary NodeElem pairs.
2164 {
2165 const auto N = boundary_node_elems.size();
2166 for (auto node_elem_i : make_range(N))
2167 for (auto node_elem_j : make_range(node_elem_i+1, N))
2168 {
2169 Real node_sep =
2170 (boundary_node_elems[node_elem_i]->point(0) - boundary_node_elems[node_elem_j]->point(0)).norm();
2171
2172 // We only want to consider non-coincident
2173 // boundary NodeElem pairs when determining the
2174 // minimum node separation distance.
2175 if (node_sep > 0.)
2176 {
2177 h_min = std::min(h_min, node_sep);
2178 h_min_updated = true;
2179 }
2180 } // end for (node_elem_j)
2181 } // end minimum NodeElem separation scope
2182 } // end for (i)
2183 } // end scope
2184
2185 if (verbose)
2186 {
2187 libMesh::out << "In UnstructuredMesh::stitch_meshes:\n"
2188 << "This mesh has " << this_boundary_node_ids.size()
2189 << " nodes on boundary `"
2190 << this->get_boundary_info().get_sideset_name(this_mesh_boundary_id)
2191 << "' (" << this_mesh_boundary_id << ").\n"
2192 << "Other mesh has " << other_boundary_node_ids.size()
2193 << " nodes on boundary `"
2194 << other_mesh->get_boundary_info().get_sideset_name(other_mesh_boundary_id)
2195 << "' (" << other_mesh_boundary_id << ").\n";
2196
2197 if (h_min_updated)
2198 {
2199 libMesh::out << "Minimum edge length on both surfaces is " << h_min << ".\n";
2200 }
2201 else
2202 {
2203 libMesh::out << "No minimum edge length determined on specified surfaces." << std::endl;
2204 }
2205 }
2206
2207 // At this point, if h_min==0 it means that there were at least two coincident
2208 // nodes on the surfaces being stitched, and we don't currently support that case.
2209 // (It might be possible to support, but getting it exactly right would be tricky
2210 // and probably not worth the extra complications to the "normal" case.)
2211 libmesh_error_msg_if(h_min < std::numeric_limits<Real>::epsilon(),
2212 "Coincident nodes detected on source and/or target "
2213 "surface, stitching meshes is not possible.");
2214
2215 // We require nanoflann for the "binary search" (really kd-tree)
2216 // option to work. If it's not available, turn that option off,
2217 // warn the user, and fall back on the N^2 search algorithm.
2218 if (use_binary_search)
2219 {
2220#ifndef LIBMESH_HAVE_NANOFLANN
2221 use_binary_search = false;
2222 libmesh_warning("The use_binary_search option in the "
2223 "UnstructuredMesh stitching algorithms requires nanoflann "
2224 "support. Falling back on N^2 search algorithm.");
2225#endif
2226 }
2227
2228 if (!this_boundary_node_ids.empty())
2229 {
2230 if (use_binary_search)
2231 {
2232#ifdef LIBMESH_HAVE_NANOFLANN
2233 typedef nanoflann::KDTreeSingleIndexAdaptor<nanoflann::L2_Simple_Adaptor<Real, VectorOfNodesAdaptor>,
2234 VectorOfNodesAdaptor, 3, std::size_t> kd_tree_t;
2235
2236 // Create the dataset needed to build the kd tree with nanoflann
2237 std::vector<std::pair<Point, dof_id_type>> this_mesh_nodes(this_boundary_node_ids.size());
2238
2239 for (auto [it, ctr] = std::make_tuple(this_boundary_node_ids.begin(), 0u);
2240 it != this_boundary_node_ids.end(); ++it, ++ctr)
2241 {
2242 this_mesh_nodes[ctr].first = this->point(*it);
2243 this_mesh_nodes[ctr].second = *it;
2244 }
2245
2246 VectorOfNodesAdaptor vec_nodes_adaptor(this_mesh_nodes);
2247
2248 kd_tree_t this_kd_tree(3, vec_nodes_adaptor, 10);
2249 this_kd_tree.buildIndex();
2250
2251 // Storage for nearest neighbor in the loop below
2252 std::size_t ret_index;
2253 Real ret_dist_sqr;
2254
2255 // Loop over other mesh. For each node, find its nearest neighbor in this mesh, and fill in the maps.
2256 for (const auto & node_id : other_boundary_node_ids)
2257 {
2258 const auto & p = other_mesh->point(node_id);
2259 const Real query_pt[] = {p(0), p(1), p(2)};
2260 this_kd_tree.knnSearch(&query_pt[0], 1, &ret_index, &ret_dist_sqr);
2261
2262 // TODO: here we should use the user's specified tolerance
2263 // and the previously determined value of h_min in the
2264 // distance comparison, not just TOLERANCE^2.
2265 if (ret_dist_sqr < TOLERANCE*TOLERANCE)
2266 {
2267 node_to_node_map[this_mesh_nodes[ret_index].second] = node_id;
2268 other_to_this_node_map[node_id] = this_mesh_nodes[ret_index].second;
2269 }
2270 }
2271
2272 // If the two maps don't have the same size, it means one
2273 // node in this mesh is the nearest neighbor of several
2274 // nodes in other mesh. Since the stitching is ambiguous in
2275 // this case, we throw an error.
2276 libmesh_error_msg_if(node_to_node_map.size() != other_to_this_node_map.size(),
2277 "Error: Found multiple matching nodes in stitch_meshes");
2278#endif
2279 }
2280 else // !use_binary_search
2281 {
2282 // In the unlikely event that two meshes composed entirely of
2283 // NodeElems are being stitched together, we will not have
2284 // selected a valid h_min value yet, and the distance
2285 // comparison below will be true for essentially any two
2286 // nodes. In this case we simply fall back on an absolute
2287 // distance check.
2288 if (!h_min_updated)
2289 {
2290 libmesh_warning("No valid h_min value was found, falling back on "
2291 "absolute distance check in the N^2 search algorithm.");
2292 h_min = 1.;
2293 }
2294
2295 // Otherwise, use a simple N^2 search to find the closest matching points. This can be helpful
2296 // in the case that we have tolerance issues which cause mismatch between the two surfaces
2297 // that are being stitched.
2298 for (const auto & this_node_id : this_boundary_node_ids)
2299 {
2300 Node & this_node = this->node_ref(this_node_id);
2301
2302 bool found_matching_nodes = false;
2303
2304 for (const auto & other_node_id : other_boundary_node_ids)
2305 {
2306 const Node & other_node = other_mesh->node_ref(other_node_id);
2307
2308 Real node_distance = (this_node - other_node).norm();
2309
2310 if (node_distance < tol*h_min)
2311 {
2312 // Make sure we didn't already find a matching node!
2313 libmesh_error_msg_if(found_matching_nodes,
2314 "Error: Found multiple matching nodes in stitch_meshes");
2315
2316 node_to_node_map[this_node_id] = other_node_id;
2317 other_to_this_node_map[other_node_id] = this_node_id;
2318
2319 found_matching_nodes = true;
2320 }
2321 }
2322 }
2323 }
2324 }
2325
2326 // Build up the node_to_elems_map, using only one loop over other_mesh
2327 for (auto & el : other_mesh->element_ptr_range())
2328 {
2329 // For each node on the element, find the corresponding node
2330 // on "this" Mesh, 'this_node_id', if it exists, and push
2331 // the current element ID back onto node_to_elems_map[this_node_id].
2332 // For that we will use the reverse mapping we created at
2333 // the same time as the forward mapping.
2334 for (auto & n : el->node_ref_range())
2335 if (const auto it = other_to_this_node_map.find(/*other_node_id=*/n.id());
2336 it != other_to_this_node_map.end())
2337 node_to_elems_map[/*this_node_id=*/it->second].push_back( el->id() );
2338 }
2339
2340 if (verbose)
2341 {
2342 libMesh::out << "In UnstructuredMesh::stitch_meshes:\n"
2343 << "Found " << node_to_node_map.size()
2344 << " matching nodes.\n"
2345 << std::endl;
2346 }
2347
2348 if (enforce_all_nodes_match_on_boundaries)
2349 {
2350 std::size_t n_matching_nodes = node_to_node_map.size();
2351 std::size_t this_mesh_n_nodes = this_boundary_node_ids.size();
2352 std::size_t other_mesh_n_nodes = other_boundary_node_ids.size();
2353 libmesh_error_msg_if((n_matching_nodes != this_mesh_n_nodes) || (n_matching_nodes != other_mesh_n_nodes),
2354 "Error: We expected the number of nodes to match.");
2355 }
2356
2357 if (merge_boundary_nodes_all_or_nothing)
2358 {
2359 std::size_t n_matching_nodes = node_to_node_map.size();
2360 std::size_t this_mesh_n_nodes = this_boundary_node_ids.size();
2361 std::size_t other_mesh_n_nodes = other_boundary_node_ids.size();
2362 if ((n_matching_nodes != this_mesh_n_nodes) || (n_matching_nodes != other_mesh_n_nodes))
2363 {
2364 if (verbose)
2365 {
2366 libMesh::out << "Skipping node merging in "
2367 "UnstructuredMesh::stitch_meshes because not "
2368 "all boundary nodes were matched."
2369 << std::endl;
2370 }
2371 node_to_node_map.clear();
2372 other_to_this_node_map.clear();
2373 node_to_elems_map.clear();
2374 }
2375 }
2376 }
2377 else
2378 {
2379 if (verbose)
2380 {
2381 libMesh::out << "Skip node merging in UnstructuredMesh::stitch_meshes:" << std::endl;
2382 }
2383 }
2384
2385 dof_id_type node_delta = this->max_node_id();
2386 dof_id_type elem_delta = this->max_elem_id();
2387
2388 unique_id_type unique_delta =
2389#ifdef LIBMESH_ENABLE_UNIQUE_ID
2390 this->parallel_max_unique_id();
2391#else
2392 0;
2393#endif
2394
2395 // If other_mesh != nullptr, then we have to do a bunch of work
2396 // in order to copy it to this mesh
2397 if (this!=other_mesh)
2398 {
2399 LOG_SCOPE("stitch_meshes copying", "UnstructuredMesh");
2400
2401#ifdef LIBMESH_ENABLE_PERIODIC
2402 // Copy disjoint neighbor boundary pairs (PeriodicBoundary objects)
2403 // from `other_mesh` to `this` mesh
2404 if (other_db && !other_db->empty())
2405 {
2406 for (const auto & [bdy_id, pb_ptr] : *other_db)
2407 {
2408 const auto & pb = *pb_ptr;
2409 const boundary_id_type a = pb.myboundary;
2410 const boundary_id_type b = pb.pairedboundary;
2411
2412 if (this_db)
2413 {
2414 // Skip if identical pair already exists
2415 if (const auto * existing_pb = this_db->boundary(a))
2416 if ((existing_pb->myboundary == a && existing_pb->pairedboundary == b) ||
2417 (existing_pb->myboundary == b && existing_pb->pairedboundary == a))
2418 continue;
2419
2420 // If both boundary ids exist on this mesh but aren't paired here, refuse to create a new pair
2421 const auto & bdy_ids = this->get_boundary_info().get_boundary_ids();
2422 const bool a_exists = bdy_ids.count(a);
2423 const bool b_exists = bdy_ids.count(b);
2424 // If a and b already exist on `this`, we should be screaming and dying
2425 // unless they already have PeriodicBoundary objects connecting them too
2426 if (a_exists && b_exists && !this_db->boundary(a))
2427 libmesh_error_msg("Conflict: boundaries " << a << " and " << b
2428 << " already exist on this mesh but are not paired.");
2429 }
2430
2431 this->add_disjoint_neighbor_boundary_pairs(a, b, pb.get_corresponding_pos(Point(0.0,0.0,0.0)));
2432 }
2433 }
2434#endif // LIBMESH_ENABLE_PERIODIC
2435
2436
2437 // Increment the node_to_node_map and node_to_elems_map
2438 // to account for id offsets
2439 for (auto & pr : node_to_node_map)
2440 pr.second += node_delta;
2441
2442 for (auto & pr : node_to_elems_map)
2443 for (auto & entry : pr.second)
2444 entry += elem_delta;
2445
2446 // We run into problems when the libMesh subdomain standard (the
2447 // id defines the subdomain; the name was an afterthought) and
2448 // the MOOSE standard (the name defines the subdomain; the id
2449 // might be autogenerated) clash.
2450 //
2451 // Subdomain ids with the same name in both meshes are surely
2452 // meant to represent the same subdomain. We can just merge
2453 // them.
2454 //
2455 // Subdomain ids which don't have a name in either mesh are
2456 // almost surely meant to represent the same subdomain. We'll
2457 // just merge them.
2458 //
2459 // Subdomain ids with different names in different meshes, or
2460 // names with different ids in different meshes, are trickier.
2461 // For backwards compatibility we default to the old "just copy
2462 // all the subdomain ids over" behavior, but if requested we'll
2463 // remap any ids that appear to be clear conflicts, and we'll
2464 // scream and die if we see any ids that are ambiguous due to
2465 // being named in one mesh but not the other.
2466 std::unordered_map<subdomain_id_type, subdomain_id_type> id_remapping;
2467 if (remap_subdomain_ids)
2468 {
2469 const auto & this_map = this->get_subdomain_name_map();
2470 const auto & other_map = other_mesh->get_subdomain_name_map();
2471 std::unordered_map<std::string, subdomain_id_type> other_map_reversed;
2472 for (auto & [sid, sname] : other_map)
2473 other_map_reversed.emplace(sname, sid);
2474
2475 std::unordered_map<std::string, subdomain_id_type> this_map_reversed;
2476 for (auto & [sid, sname] : this_map)
2477 this_map_reversed.emplace(sname, sid);
2478
2479 // We don't require either mesh to be prepared, but that
2480 // means we need to check for subdomains manually.
2481 auto get_subdomains = [](const MeshBase & mesh) {
2482 std::set<subdomain_id_type> all_subdomains;
2483 for (auto & el : mesh.element_ptr_range())
2484 all_subdomains.insert(el->subdomain_id());
2485 return all_subdomains;
2486 };
2487
2488 const auto this_subdomains = get_subdomains(*this);
2489 const auto other_subdomains = get_subdomains(*other_mesh);
2490
2491 for (auto & [sid, sname] : this_map)
2492 {
2493 // The same name with the same id means we're fine. The
2494 // same name with another id means we remap their id to
2495 // ours
2496 if (const auto other_reverse_it = other_map_reversed.find(sname);
2497 other_reverse_it != other_map_reversed.end() && other_reverse_it->second != sid)
2498 id_remapping[other_reverse_it->second] = sid;
2499
2500 // The same id with a different name, we'll get to
2501 // later. The same id without any name means we don't
2502 // know what the user wants.
2503 if (other_subdomains.count(sid) && !other_map.count(sid))
2504 libmesh_error_msg("Can't safely stitch with a mesh sharing subdomain id "
2505 << sid << " but not subdomain name " << sname);
2506 }
2507
2508 subdomain_id_type next_free_id = 0;
2509 // We might try to stitch empty meshes ...
2510 if (!this_subdomains.empty())
2511 next_free_id = *this_subdomains.rbegin() + 1;
2512 if (!other_subdomains.empty())
2513 next_free_id =
2514 std::max(next_free_id,
2515 cast_int<subdomain_id_type>
2516 (*other_subdomains.rbegin() + 1));
2517
2518 for (auto & [sid, sname] : other_map)
2519 {
2520 // At this point we've figured out any remapping
2521 // necessary for an sname that we share. And we don't
2522 // need to remap any sid we don't share.
2523 if (!this_map_reversed.count(sname))
2524 {
2525 // But if we don't have this sname and we do have this
2526 // sid then we can't just merge into that.
2527 if (this_subdomains.count(sid))
2528 {
2529 // If we have this sid with no name, we don't
2530 // know what the user wants.
2531 if (!this_map.count(sid))
2532 libmesh_error_msg("Can't safely stitch with a mesh sharing subdomain id "
2533 << sid << " but under subdomain name " << sname);
2534
2535 // We have this sid under a different name, so
2536 // we just need to give the other elements a new
2537 // id.
2538
2539 // Users might have done crazy things with id
2540 // choice so let's make sure they didn't get too
2541 // crazy.
2542 libmesh_error_msg_if ((!this_subdomains.empty() &&
2543 next_free_id < *this_subdomains.rbegin()) ||
2544 (!other_subdomains.empty() &&
2545 next_free_id < *other_subdomains.rbegin()),
2546 "Subdomain id overflow");
2547
2548 id_remapping[sid] = next_free_id++;
2549 this->set_subdomain_name(next_free_id, sname);
2550 }
2551 // If we don't have this subdomain id, well, we're
2552 // about to, so we should have its name too.
2553 else
2554 this->set_subdomain_name(sid, sname);
2555 }
2556 }
2557 }
2558
2559 // Copy mesh data. If we skip the call to find_neighbors(), the lists
2560 // of neighbors will be copied verbatim from the other mesh
2561 this->copy_nodes_and_elements(*other_mesh, skip_find_neighbors,
2562 elem_delta, node_delta,
2563 unique_delta, &id_remapping);
2564
2565 // Copy BoundaryInfo from other_mesh too. We do this via the
2566 // list APIs rather than element-by-element for speed.
2567 BoundaryInfo & boundary = this->get_boundary_info();
2568 const BoundaryInfo & other_boundary = other_mesh->get_boundary_info();
2569
2570 for (const auto & t : other_boundary.build_node_list())
2571 boundary.add_node(std::get<0>(t) + node_delta,
2572 std::get<1>(t));
2573
2574 for (const auto & t : other_boundary.build_side_list())
2575 boundary.add_side(std::get<0>(t) + elem_delta,
2576 std::get<1>(t),
2577 std::get<2>(t));
2578
2579 for (const auto & t : other_boundary.build_edge_list())
2580 boundary.add_edge(std::get<0>(t) + elem_delta,
2581 std::get<1>(t),
2582 std::get<2>(t));
2583
2584 for (const auto & t : other_boundary.build_shellface_list())
2585 boundary.add_shellface(std::get<0>(t) + elem_delta,
2586 std::get<1>(t),
2587 std::get<2>(t));
2588
2589 const auto & other_ns_id_to_name = other_boundary.get_nodeset_name_map();
2590 auto & ns_id_to_name = boundary.set_nodeset_name_map();
2591 ns_id_to_name.insert(other_ns_id_to_name.begin(), other_ns_id_to_name.end());
2592
2593 const auto & other_ss_id_to_name = other_boundary.get_sideset_name_map();
2594 auto & ss_id_to_name = boundary.set_sideset_name_map();
2595 ss_id_to_name.insert(other_ss_id_to_name.begin(), other_ss_id_to_name.end());
2596
2597 const auto & other_es_id_to_name = other_boundary.get_edgeset_name_map();
2598 auto & es_id_to_name = boundary.set_edgeset_name_map();
2599 es_id_to_name.insert(other_es_id_to_name.begin(), other_es_id_to_name.end());
2600
2601 // Merge other_mesh's elemset information with ours. Throw an
2602 // error if this and other_mesh have overlapping elemset codes
2603 // that refer to different elemset ids.
2604 std::vector<dof_id_type> this_elemset_codes = this->get_elemset_codes();
2605 MeshBase::elemset_type this_id_set_to_fill, other_id_set_to_fill;
2606 for (const auto & elemset_code : other_mesh->get_elemset_codes())
2607 {
2608 // Get the elemset ids for this elemset_code on other_mesh
2609 other_mesh->get_elemsets(elemset_code, other_id_set_to_fill);
2610
2611 // Check that this elemset code does not already exist
2612 // in this mesh, or if it does, that it has the same elemset
2613 // ids associated with it.
2614 //
2615 // Note: get_elemset_codes() is guaranteed to return a
2616 // sorted vector, so we can binary search in it.
2617 auto it = Utility::binary_find(this_elemset_codes.begin(),
2618 this_elemset_codes.end(),
2619 elemset_code);
2620
2621 if (it != this_elemset_codes.end())
2622 {
2623 // This mesh has the same elemset code. Does it refer to
2624 // the same elemset ids?
2625 this->get_elemsets(elemset_code, this_id_set_to_fill);
2626
2627 // Throw an error if they don't match, otherwise we
2628 // don't need to do anything
2629 libmesh_error_msg_if(other_id_set_to_fill != this_id_set_to_fill,
2630 "Attempted to stitch together meshes with conflicting elemset codes.");
2631 }
2632 else
2633 {
2634 // Add other_mesh's elemset code to this mesh
2635 this->add_elemset_code(elemset_code, other_id_set_to_fill);
2636 }
2637 }
2638
2639 } // end if (other_mesh)
2640
2641 // Finally, we need to "merge" the overlapping nodes
2642 // We do this by iterating over node_to_elems_map and updating
2643 // the elements so that they "point" to the nodes that came
2644 // from this mesh, rather than from other_mesh.
2645 // Then we iterate over node_to_node_map and delete the
2646 // duplicate nodes that came from other_mesh.
2647
2648 {
2649 LOG_SCOPE("stitch_meshes node updates", "UnstructuredMesh");
2650
2651 // Container to catch boundary IDs passed back from BoundaryInfo.
2652 std::vector<boundary_id_type> bc_ids;
2653
2654 for (const auto & [target_node_id, elem_vec] : node_to_elems_map)
2655 {
2656 dof_id_type other_node_id = node_to_node_map[target_node_id];
2657 Node & target_node = this->node_ref(target_node_id);
2658
2659 std::size_t n_elems = elem_vec.size();
2660 for (std::size_t i=0; i<n_elems; i++)
2661 {
2662 dof_id_type elem_id = elem_vec[i];
2663 Elem * el = this->elem_ptr(elem_id);
2664
2665 // find the local node index that we want to update
2666 unsigned int local_node_index = el->local_node(other_node_id);
2667 libmesh_assert_not_equal_to(local_node_index, libMesh::invalid_uint);
2668
2669 // We also need to copy over the nodeset info here,
2670 // because the node will get deleted below
2671 this->get_boundary_info().boundary_ids(el->node_ptr(local_node_index), bc_ids);
2672 el->set_node(local_node_index, &target_node);
2673 this->get_boundary_info().add_node(&target_node, bc_ids);
2674 }
2675 }
2676 }
2677
2678 {
2679 LOG_SCOPE("stitch_meshes node deletion", "UnstructuredMesh");
2680 for (const auto & [other_node_id, this_node_id] : node_to_node_map)
2681 {
2682 // In the case that this==other_mesh, the two nodes might be the same (e.g. if
2683 // we're stitching a "sliver"), hence we need to skip node deletion in that case.
2684 if ((this == other_mesh) && (this_node_id == other_node_id))
2685 continue;
2686
2687 this->delete_node( this->node_ptr(this_node_id) );
2688 }
2689 }
2690
2691 // If find_neighbors() wasn't called in prepare_for_use(), we need to
2692 // manually loop once more over all elements adjacent to the stitched boundary
2693 // and fix their lists of neighbors.
2694 // This is done according to the following steps:
2695 // 1. Loop over all copied elements adjacent to the boundary using node_to_elems_map (trying to avoid duplicates)
2696 // 2. Look at all their sides with a nullptr neighbor and update them using side_to_elem_map if necessary
2697 // 3. Update the corresponding side in side_to_elem_map as well
2698 if (skip_find_neighbors)
2699 {
2700 LOG_SCOPE("stitch_meshes neighbor fixes", "UnstructuredMesh");
2701
2702 // Pull objects out of the loop to reduce heap operations
2703 std::unique_ptr<const Elem> my_side, their_side;
2704
2705 std::set<dof_id_type> fixed_elems;
2706 for (const auto & pr : node_to_elems_map)
2707 {
2708 std::size_t n_elems = pr.second.size();
2709 for (std::size_t i=0; i<n_elems; i++)
2710 {
2711 dof_id_type elem_id = pr.second[i];
2712 if (!fixed_elems.count(elem_id))
2713 {
2714 Elem * el = this->elem_ptr(elem_id);
2715 fixed_elems.insert(elem_id);
2716 for (auto s : el->side_index_range())
2717 {
2718 bool has_real_neighbor = (el->neighbor_ptr(s) != nullptr);
2719 bool has_disdjoint_neighbor = is_valid_disjoint_pair_to_stitch &&
2720 (this->get_boundary_info().has_boundary_id(el, s, this_mesh_boundary_id)
2721 || this->get_boundary_info().has_boundary_id(el, s, other_mesh_boundary_id));
2722
2723 if (!has_real_neighbor || has_disdjoint_neighbor)
2724 {
2725 key_type key = el->low_order_key(s);
2726 auto bounds = side_to_elem_map.equal_range(key);
2727
2728 if (bounds.first != bounds.second)
2729 {
2730 // Get the side for this element
2731 el->side_ptr(my_side, s);
2732
2733 // Look at all the entries with an equivalent key
2734 while (bounds.first != bounds.second)
2735 {
2736 // Get the potential element
2737 Elem * neighbor = const_cast<Elem *>(bounds.first->second.first);
2738
2739 // Get the side for the neighboring element
2740 const unsigned int ns = bounds.first->second.second;
2741 neighbor->side_ptr(their_side, ns);
2742 //libmesh_assert(my_side.get());
2743 //libmesh_assert(their_side.get());
2744
2745 // If found a match with my side
2746 //
2747 // We need special tests here for 1D:
2748 // since parents and children have an equal
2749 // side (i.e. a node), we need to check
2750 // ns != ms, and we also check level() to
2751 // avoid setting our neighbor pointer to
2752 // any of our neighbor's descendants
2753 if ((*my_side == *their_side) &&
2754 (el->level() == neighbor->level()) &&
2755 ((el->dim() != 1) || (ns != s)))
2756 {
2757 // So share a side. Is this a mixed pair
2758 // of subactive and active/ancestor
2759 // elements?
2760 // If not, then we're neighbors.
2761 // If so, then the subactive's neighbor is
2762
2763 if (el->subactive() ==
2764 neighbor->subactive())
2765 {
2766 // an element is only subactive if it has
2767 // been coarsened but not deleted
2768 el->set_neighbor (s,neighbor);
2769 neighbor->set_neighbor(ns,el);
2770 }
2771 else if (el->subactive())
2772 {
2773 el->set_neighbor(s,neighbor);
2774 }
2775 else if (neighbor->subactive())
2776 {
2777 neighbor->set_neighbor(ns,el);
2778 }
2779 // It's OK to invalidate the
2780 // bounds.first iterator here,
2781 // as we are immediately going
2782 // to break out of this while
2783 // loop. bounds.first will
2784 // therefore not be used for
2785 // anything else.
2786 side_to_elem_map.erase (bounds.first);
2787 break;
2788 }
2789
2790 ++bounds.first;
2791 }
2792 }
2793 }
2794 }
2795 }
2796 }
2797 }
2798 }
2799
2800#ifdef LIBMESH_ENABLE_PERIODIC
2801 // Remove only the disjoint pair that was actually stitched.
2802 // Safe because `is_valid_disjoint_pair_to_stitch` is true
2803 // only if this exact (a,b) pair exists in the registry.
2804 // Other disjoint pairs remain untouched.
2805 if (is_valid_disjoint_pair_to_stitch)
2806 this->remove_disjoint_boundary_pair(this_mesh_boundary_id, other_mesh_boundary_id);
2807#endif
2808
2809 if (prepare_after_stitching)
2810 {
2811 // We set our new neighbor pointers already
2812 const bool old_allow_find_neighbors = this->allow_find_neighbors();
2813 this->allow_find_neighbors(!skip_find_neighbors);
2814
2815 // We haven't newly remoted any elements
2816 const bool old_allow_remote_element_removal = this->allow_remote_element_removal();
2817 this->allow_remote_element_removal(false);
2818
2819 this->prepare_for_use();
2820
2821 this->allow_find_neighbors(old_allow_find_neighbors);
2822 this->allow_remote_element_removal(old_allow_remote_element_removal);
2823 }
2824
2825 // After the stitching, we may want to clear boundary IDs from element
2826 // faces that are now internal to the mesh
2827 if (clear_stitched_boundary_ids)
2828 {
2829 LOG_SCOPE("stitch_meshes clear bcids", "UnstructuredMesh");
2830
2832 this_mesh_boundary_id, other_mesh_boundary_id, /*clear_nodeset_data=*/true);
2833 }
2834
2835 // Return the number of nodes which were merged.
2836 return node_to_node_map.size();
2837}
The BoundaryInfo class contains information relevant to boundary conditions including storing faces,...
bool has_boundary_id(const Node *const node, const boundary_id_type id) const
void edge_boundary_ids(const Elem *const elem, const unsigned short int edge, std::vector< boundary_id_type > &vec_to_fill) const
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.
std::map< boundary_id_type, std::string > & set_sideset_name_map()
const std::set< boundary_id_type > & get_boundary_ids() const
const std::string & get_sideset_name(boundary_id_type id) const
void add_node(const Node *node, const boundary_id_type id)
Add Node node with boundary id id to the boundary information data structures.
static const boundary_id_type invalid_id
Number used for internal use.
std::map< boundary_id_type, std::string > & set_edgeset_name_map()
std::map< boundary_id_type, std::string > & set_nodeset_name_map()
virtual dof_id_type low_order_key(const unsigned int s) const =0
unsigned int local_node(const dof_id_type i) const
Definition elem.h:2496
virtual unsigned short dim() const =0
const Node * node_ptr(const unsigned int i) const
Definition elem.h:2516
void set_subdomain_name(subdomain_id_type id, const std::string &name, bool synchronous=false)
Sets the name for the provided id.
Definition mesh_base.C:1914
virtual const Point & point(const dof_id_type i) const =0
std::vector< dof_id_type > get_elemset_codes() const
Return a vector of all elemset codes defined on the mesh.
Definition mesh_base.C:503
virtual Node * add_node(Node *n)=0
Add Node n to the end of the vertex array.
virtual dof_id_type max_elem_id() const =0
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:487
void remove_disjoint_boundary_pair(const boundary_id_type b1, const boundary_id_type b2)
Definition mesh_base.C:2306
void add_disjoint_neighbor_boundary_pairs(const boundary_id_type b1, const boundary_id_type b2, const RealVectorValue &translation)
Register a pair of boundaries as disjoint neighbor boundary pairs.
Definition mesh_base.C:2272
Temporarily serialize a DistributedMesh for non-distributed-mesh capable code paths.
We're using a class instead of a typedef to allow forward declarations and future flexibility.
PeriodicBoundaryBase * boundary(boundary_id_type id)
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:40
virtual void copy_nodes_and_elements(const MeshBase &other_mesh, const bool skip_find_neighbors=false, dof_id_type element_id_offset=0, dof_id_type node_id_offset=0, unique_id_type unique_id_offset=0, std::unordered_map< subdomain_id_type, subdomain_id_type > *id_remapping=nullptr, const bool skip_preparation=false)
Deep copy of nodes and elements from another mesh object (used by subclass copy constructors and by m...
virtual void find_neighbors(const bool reset_remote_elements=false, const bool reset_current_list=true, const bool assert_valid=true) override
Other functions from MeshBase requiring re-definition.
static const Real b
MeshBase & mesh
auto norm(const T &a)
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:233
const boundary_id_type side_id

References libMesh::MeshBase::add_disjoint_neighbor_boundary_pairs(), 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(), b, libMesh::Utility::binary_find(), libMesh::PeriodicBoundaries::boundary(), 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(), libMesh::UnstructuredMesh::copy_nodes_and_elements(), libMesh::MeshBase::delete_node(), libMesh::Elem::dim(), libMesh::BoundaryInfo::edge_boundary_ids(), libMesh::MeshBase::elem_ptr(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::BoundaryInfo::get_boundary_ids(), libMesh::MeshBase::get_boundary_info(), libMesh::MeshBase::get_disjoint_neighbor_boundary_pairs(), 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::has_boundary_id(), libMesh::BoundaryInfo::invalid_id, libMesh::invalid_uint, libMesh::MeshBase::is_prepared(), libMesh::Elem::level(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::Elem::local_node(), libMesh::Elem::low_order_key(), libMesh::make_range(), libMesh::MeshBase::max_elem_id(), libMesh::MeshBase::max_node_id(), mesh, libMesh::Elem::neighbor_ptr(), libMesh::MeshBase::node_ptr(), libMesh::Elem::node_ptr(), libMesh::MeshBase::node_ref(), libMesh::NODEELEM, libMesh::out, libMesh::MeshBase::parallel_max_unique_id(), libMesh::MeshBase::point(), libMesh::MeshBase::prepare_for_use(), libMesh::Real, libMesh::MeshBase::remove_disjoint_boundary_pair(), 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(), libMesh::MeshBase::set_subdomain_name(), side_id, libMesh::Elem::side_index_range(), libMesh::Elem::side_ptr(), libMesh::Elem::subactive(), and libMesh::TOLERANCE.

Referenced by libMesh::UnstructuredMesh::stitch_meshes(), and libMesh::UnstructuredMesh::stitch_surfaces().

◆ 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 1833 of file mesh_base.C.

1834{
1835 // If there's no master point locator, then we need one.
1836 if (_point_locator.get() == nullptr)
1837 {
1838 // PointLocator construction may not be safe within threads
1840
1841 // And it may require parallel communication
1842 parallel_object_only();
1843
1844#ifdef LIBMESH_ENABLE_NANOFLANN_POINTLOCATOR
1846#else
1848#endif
1849
1851 _point_locator->set_close_to_point_tol(_point_locator_close_to_point_tol);
1852 }
1853
1854 // Otherwise there was a master point locator, and we can grab a
1855 // sub-locator easily.
1856 return
1857#ifdef LIBMESH_ENABLE_NANOFLANN_POINTLOCATOR
1859#else
1861#endif
1862}
static std::unique_ptr< PointLocatorBase > build(PointLocatorType t, const MeshBase &mesh, const PointLocatorBase *master=nullptr)
Builds an PointLocator for the mesh mesh.

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::UnstructuredMesh::find_neighbors(), libMesh::MeshFunction::init(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), main(), libMesh::DefaultCoupling::mesh_reinit(), libMesh::OverlapCoupling::mesh_reinit(), libMesh::PointNeighborCoupling::mesh_reinit(), MeshPerElemTest< elem_type >::meshes_equal_enough(), OverlappingCouplingFunctor::operator()(), MeshFunctionTest::test_bad_gradient_var_with_out_of_mesh_value(), MeshFunctionTest::test_bad_hessian_var_with_out_of_mesh_value(), PointLocatorTest::testLocator(), MeshInputTest::testMasterCenters(), PointLocatorTest::testPlanar(), SystemsTest::testProjectCube(), SystemsTest::testProjectLine(), and SystemsTest::testProjectSquare().

◆ subclass_locally_equals()

bool libMesh::DistributedMesh::subclass_locally_equals ( const MeshBase other_mesh) const
overridevirtualinherited

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

Implements libMesh::MeshBase.

Definition at line 98 of file distributed_mesh.C.

99{
100 const DistributedMesh * dist_mesh_ptr =
101 dynamic_cast<const DistributedMesh *>(&other_mesh_base);
102 if (!dist_mesh_ptr)
103 return false;
104 const DistributedMesh & other_mesh = *dist_mesh_ptr;
105
106 if (_is_serial != other_mesh._is_serial ||
107 _is_serial_on_proc_0 != other_mesh._is_serial_on_proc_0 ||
108 _deleted_coarse_elements != other_mesh._deleted_coarse_elements ||
109 _n_nodes != other_mesh._n_nodes ||
110 _n_elem != other_mesh._n_elem ||
111 _max_node_id != other_mesh._max_node_id ||
112 _max_elem_id != other_mesh._max_elem_id ||
113 // We expect these things to change in a prepare_for_use();
114 // they're conceptually "mutable"...
115/*
116 _next_free_local_node_id != other_mesh._next_free_local_node_id ||
117 _next_free_local_elem_id != other_mesh._next_free_local_elem_id ||
118 _next_free_unpartitioned_node_id != other_mesh._next_free_unpartitioned_node_id ||
119 _next_free_unpartitioned_elem_id != other_mesh._next_free_unpartitioned_elem_id ||
120#ifdef LIBMESH_ENABLE_UNIQUE_ID
121 _next_unpartitioned_unique_id != other_mesh._next_unpartitioned_unique_id ||
122#endif
123*/
124 !this->nodes_and_elements_equal(other_mesh))
125 return false;
126
127 if (_extra_ghost_elems.size() !=
128 other_mesh._extra_ghost_elems.size())
129 return false;
130 for (auto & elem : _extra_ghost_elems)
131 {
132 libmesh_assert(this->query_elem_ptr(elem->id()) == elem);
133 const Elem * other_elem = other_mesh.query_elem_ptr(elem->id());
134 if (!other_elem ||
135 !other_mesh._extra_ghost_elems.count(const_cast<Elem *>(other_elem)))
136 return false;
137 }
138
139 return true;
140}
DistributedMesh(const Parallel::Communicator &comm_in, unsigned char dim=1)
Constructor.
virtual const Elem * query_elem_ptr(const dof_id_type i) const override final

References libMesh::DistributedMesh::_deleted_coarse_elements, libMesh::DistributedMesh::_extra_ghost_elems, libMesh::DistributedMesh::_is_serial, libMesh::DistributedMesh::_is_serial_on_proc_0, libMesh::DistributedMesh::_max_elem_id, libMesh::DistributedMesh::_max_node_id, libMesh::DistributedMesh::_n_elem, libMesh::DistributedMesh::_n_nodes, libMesh::libmesh_assert(), and libMesh::DistributedMesh::query_elem_ptr().

◆ 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 1126 of file mesh_base.C.

1127{
1128 // This requires an inspection on every processor
1129 if (global)
1130 parallel_object_only();
1131
1132 struct SBDInserter {
1133 std::set<subdomain_id_type> my_ids;
1134
1135 SBDInserter () {}
1136 SBDInserter (SBDInserter &, Threads::split) {}
1137
1138 void operator()(const ConstElemRange & range) {
1139 for (const Elem * elem : range)
1140 my_ids.insert(elem->subdomain_id());
1141 }
1142
1143 void join(SBDInserter & other) {
1144 my_ids.merge(other.my_ids);
1145 }
1146 };
1147
1148 SBDInserter inserter;
1150
1151 ids.swap(inserter.my_ids);
1152
1153 if (global)
1154 {
1155 // Only include the unpartitioned elements if the user requests the global IDs.
1156 // In the case of the local subdomain IDs, it doesn't make sense to include the
1157 // unpartitioned elements because said elements do not have a sense of locality.
1158 for (const auto & elem : this->active_unpartitioned_element_ptr_range())
1159 ids.insert(elem->subdomain_id());
1160
1161 // Some subdomains may only live on other processors
1162 this->comm().set_union(ids);
1163 }
1164}
const ConstElemRange & active_local_element_stored_range() const
Definition mesh_base.C:1954
void parallel_reduce(const Range &range, Body &body, unsigned int n_threads=libMesh::n_threads())
Execute the provided reduction operation in parallel on the specified range.

References libMesh::MeshBase::active_local_element_stored_range(), libMesh::ParallelObject::comm(), libMesh::Threads::parallel_reduce(), and libMesh::Parallel::Communicator::set_union().

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

◆ subdomain_name() [1/2]

std::string & libMesh::MeshBase::subdomain_name ( subdomain_id_type  id)
inherited
Deprecated:
Returns
A writable reference for setting an optional name for a subdomain. This method is deprecated; use set_subdomain_name() instead.

Definition at line 1887 of file mesh_base.C.

1888{
1889 // Use set_subdomain_name() instead
1890 libmesh_deprecated();
1891
1892 // We'd like to do this so our preparation isn't invalidated by a
1893 // write, but for all we know the user is just reading from a
1894 // non-const mesh!
1895 // this->unset_has_synched_subdomain_name_map();
1896
1897 return _block_id_to_name[id];
1898}

References libMesh::MeshBase::_block_id_to_name.

Referenced by DMlibMeshSetSystem_libMesh(), MeshInputTest::testGmshBCIDOverlap(), libMesh::TecplotIO::write_binary(), and libMesh::ExodusII_IO_Helper::write_elements().

◆ subdomain_name() [2/2]

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

Definition at line 1902 of file mesh_base.C.

1903{
1904 // An empty string to return when no matching subdomain name is found
1905 static const std::string empty;
1906
1907 if (const auto iter = _block_id_to_name.find(id);
1908 iter == _block_id_to_name.end())
1909 return empty;
1910 else
1911 return iter->second;
1912}

References libMesh::MeshBase::_block_id_to_name.

◆ supported_nodal_order()

Order libMesh::MeshBase::supported_nodal_order ( ) const
inlineinherited
Returns
The smallest supported_nodal_order() of any element present in the mesh, which is thus the maximum supported nodal order on the mesh as a whole.

Definition at line 445 of file mesh_base.h.

446 { return _supported_nodal_order; }

References libMesh::MeshBase::_supported_nodal_order.

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

◆ sync_subdomain_name_map()

void libMesh::MeshBase::sync_subdomain_name_map ( )
inherited

libMesh often expects all processors to know about names of all subdomain ids, but distributed mesh generators may only know about part of a mesh when creating names.

This method can synchronize the subdomain id to name map across processors, assuming no conflicts exist. It is called automatically during complete_preparation() unless the map is already known to be synchronized.

Definition at line 2066 of file mesh_base.C.

2067{
2068 // This requires every processor
2069 parallel_object_only();
2070
2072
2074}

References libMesh::MeshBase::_block_id_to_name, libMesh::MeshBase::_preparation, libMesh::ParallelObject::comm(), libMesh::MeshBase::Preparation::has_synched_subdomain_name_map, and libMesh::Parallel::Communicator::set_union().

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

◆ unset_has_boundary_id_sets()

void libMesh::MeshBase::unset_has_boundary_id_sets ( )
inlineinherited

Tells this we have done some operation which may have invalidated our cached boundary id sets.

User code which removes elements, or which adds or removes boundary entries, should call this method.

Definition at line 340 of file mesh_base.h.

References libMesh::MeshBase::_preparation, and libMesh::MeshBase::Preparation::has_boundary_id_sets.

Referenced by libMesh::BoundaryInfo::add_elements(), and MeshBaseTest::testMeshBaseVerifyRemovalPreparation().

◆ unset_has_cached_elem_data()

void libMesh::MeshBase::unset_has_cached_elem_data ( )
inlineinherited

Tells this we have done some operation (e.g.

adding elements with a new dimension or subdomain value) which may invalidate cached summaries of element data.

User code which adds new elements to this mesh must call this function.

Definition at line 281 of file mesh_base.h.

References libMesh::MeshBase::_preparation, and libMesh::MeshBase::Preparation::has_cached_elem_data.

Referenced by libMesh::BoundaryInfo::add_elements(), libMesh::MeshTools::Modification::change_subdomain_id(), libMesh::MeshTools::Modification::redistribute(), libMesh::MeshTools::Modification::rotate(), libMesh::MeshTools::Modification::scale(), MeshBaseTest::testMeshBaseVerifyHasCachedElemData(), and libMesh::MeshTools::Modification::translate().

◆ unset_has_interior_parent_ptrs()

void libMesh::MeshBase::unset_has_interior_parent_ptrs ( )
inlineinherited

Tells this we have done some operation (e.g.

refining elements with interior parents) which requires interior parent pointers to be found later.

Most user code will not need to call this method; any user code that manipulates interior parents or their boundary elements may be an exception.

Definition at line 293 of file mesh_base.h.

References libMesh::MeshBase::_preparation, and libMesh::MeshBase::Preparation::has_interior_parent_ptrs.

◆ unset_has_neighbor_ptrs()

void libMesh::MeshBase::unset_has_neighbor_ptrs ( )
inlineinherited

Tells this we have done some operation (e.g.

adding elements without setting their neighbor pointers, or adding disjoint neighbor boundary pairs) which requires neighbor pointers to be determined later.

User code which adds new elements to this mesh must call this function or manually set neighbor pointer from and to those elements.

Definition at line 270 of file mesh_base.h.

References libMesh::MeshBase::_preparation, and libMesh::MeshBase::Preparation::has_neighbor_ptrs.

Referenced by libMesh::BoundaryInfo::add_elements(), and MeshBaseTest::testMeshBaseVerifyHasNeighborPtrs().

◆ unset_has_reinit_ghosting_functors()

void libMesh::MeshBase::unset_has_reinit_ghosting_functors ( )
inlineinherited

Tells this we have done some operation (e.g.

adding or removing elements) which may require a reinit() of custom ghosting functors.

User code which adds or removes elements should call this method. User code which moves nodes ... should probably call this method, in case ghosting functors depending on position exist?

Definition at line 330 of file mesh_base.h.

References libMesh::MeshBase::_preparation, and libMesh::MeshBase::Preparation::has_reinit_ghosting_functors.

Referenced by libMesh::BoundaryInfo::add_elements().

◆ unset_has_removed_orphaned_nodes()

void libMesh::MeshBase::unset_has_removed_orphaned_nodes ( )
inlineinherited

Tells this we have done some operation (e.g.

coarsening) which may have left orphaned nodes in need of removal.

Most user code should probably never need to use this; we can set it in MeshRefinement. User code which deletes elements without carefully deleting orphaned nodes should call this manually.

Definition at line 318 of file mesh_base.h.

References libMesh::MeshBase::_preparation, and libMesh::MeshBase::Preparation::has_removed_orphaned_nodes.

Referenced by MeshBaseTest::testMeshBaseVerifyRemovalPreparation().

◆ unset_has_removed_remote_elements()

void libMesh::MeshBase::unset_has_removed_remote_elements ( )
inlineinherited

Tells this we have done some operation (e.g.

repartitioning) which may have left elements as ghosted which on a distributed mesh should be remote.

User code should probably never need to use this; we can set it in Partitioner. Any user code which manually repartitions elements on distributed meshes may need to call this manually, in addition to manually communicating elements with newly-created ghosting requirements.

Definition at line 307 of file mesh_base.h.

References libMesh::MeshBase::_preparation, and libMesh::MeshBase::Preparation::has_removed_remote_elements.

◆ unset_has_synched_id_counts()

void libMesh::MeshBase::unset_has_synched_id_counts ( )
inlineinherited

Tells this we have done some operation (e.g.

adding objects to a distributed mesh on one processor only) which can lose synchronization of id counts.

User code which does distributed additions of nodes or elements must call either this method or update_parallel_id_counts().

Definition at line 257 of file mesh_base.h.

References libMesh::MeshBase::_preparation, and libMesh::MeshBase::Preparation::has_synched_id_counts.

◆ unset_has_synched_subdomain_name_map()

void libMesh::MeshBase::unset_has_synched_subdomain_name_map ( )
inlineinherited

Tells this we have done some operation which may have left the subdomain id to name map inconsistent across processors.

User code which adds or changes subdomain names should call this method.

Definition at line 350 of file mesh_base.h.

References libMesh::MeshBase::_preparation, and libMesh::MeshBase::Preparation::has_synched_subdomain_name_map.

Referenced by libMesh::MeshBase::set_subdomain_name(), and libMesh::MeshBase::set_subdomain_name_map().

◆ unset_is_partitioned()

void libMesh::MeshBase::unset_is_partitioned ( )
inlineinherited

Tells this we have done some operation creating unpartitioned elements.

User code which adds elements to this mesh must either partition them too or call this method.

Definition at line 246 of file mesh_base.h.

247 { _preparation.is_partitioned = false; }

References libMesh::MeshBase::_preparation, and libMesh::MeshBase::Preparation::is_partitioned.

Referenced by MeshBaseTest::testMeshBaseVerifyRemovalPreparation().

◆ unset_is_prepared()

void libMesh::MeshBase::unset_is_prepared ( )
inherited

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

This is a very coarse setting; it is generally more efficient to mark finer-grained settings instead.

Definition at line 1070 of file mesh_base.C.

1071{
1072 _preparation = false;
1073 this->clear_point_locator();
1074 this->clear_stored_ranges();
1075}

References libMesh::MeshBase::_preparation, libMesh::MeshBase::clear_point_locator(), and libMesh::MeshBase::clear_stored_ranges().

Referenced by libMesh::UnstructuredMesh::copy_nodes_and_elements(), and MeshTetTest::testTrisToTets().

◆ update_parallel_id_counts()

void libMesh::DistributedMesh::update_parallel_id_counts ( )
overridevirtualinherited

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

Implements libMesh::MeshBase.

Definition at line 254 of file distributed_mesh.C.

255{
256 // This function must be run on all processors at once
257 parallel_object_only();
258
259 _n_elem = this->parallel_n_elem();
260 _n_nodes = this->parallel_n_nodes();
263
265 ((_max_elem_id-1) / (this->n_processors() + 1) + 1) *
266 (this->n_processors() + 1) + this->n_processors();
268 ((_max_elem_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
269 (this->n_processors() + 1) + this->processor_id();
270
272 ((_max_node_id-1) / (this->n_processors() + 1) + 1) *
273 (this->n_processors() + 1) + this->n_processors();
275 ((_max_node_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
276 (this->n_processors() + 1) + this->processor_id();
277
278#ifdef LIBMESH_ENABLE_UNIQUE_ID
281 ((_next_unique_id-1) / (this->n_processors() + 1) + 1) *
282 (this->n_processors() + 1) + this->n_processors();
284 ((_next_unique_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
285 (this->n_processors() + 1) + this->processor_id();
286#endif
287
289}
virtual unique_id_type parallel_max_unique_id() const override

References libMesh::DistributedMesh::_max_elem_id, libMesh::DistributedMesh::_max_node_id, libMesh::DistributedMesh::_n_elem, libMesh::DistributedMesh::_n_nodes, libMesh::DistributedMesh::_next_free_local_elem_id, libMesh::DistributedMesh::_next_free_local_node_id, libMesh::DistributedMesh::_next_free_unpartitioned_elem_id, libMesh::DistributedMesh::_next_free_unpartitioned_node_id, libMesh::MeshBase::_next_unique_id, libMesh::DistributedMesh::_next_unpartitioned_unique_id, libMesh::MeshBase::_preparation, libMesh::MeshBase::Preparation::has_synched_id_counts, libMesh::ParallelObject::n_processors(), libMesh::DistributedMesh::parallel_max_elem_id(), libMesh::DistributedMesh::parallel_max_node_id(), libMesh::DistributedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_n_elem(), libMesh::DistributedMesh::parallel_n_nodes(), and libMesh::ParallelObject::processor_id().

Referenced by libMesh::DistributedMesh::delete_remote_elements(), libMesh::DistributedMesh::DistributedMesh(), libMesh::DistributedMesh::redistribute(), libMesh::DistributedMesh::renumber_nodes_and_elements(), and libMesh::DistributedMesh::update_post_partitioning().

◆ update_post_partitioning()

void libMesh::DistributedMesh::update_post_partitioning ( )
overridevirtualinherited

Recalculate cached data after elements and nodes have been repartitioned.

Reimplemented from libMesh::MeshBase.

Definition at line 1079 of file distributed_mesh.C.

1080{
1081 // this->recalculate_n_partitions();
1082
1083 // Let's do the base class cache clearing first, just in case our
1084 // later computations are ever changed to make use of a local
1085 // elements range cache
1087
1088 // Partitioning changes our numbers of unpartitioned objects
1090}

References libMesh::DistributedMesh::update_parallel_id_counts(), and libMesh::MeshBase::update_post_partitioning().

◆ write() [1/2]

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

Write the file specified by name.

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

Implements libMesh::MeshBase.

Definition at line 1401 of file unstructured_mesh.C.

1402{
1403 LOG_SCOPE("write()", "Mesh");
1404
1405 NameBasedIO(*this).write(name);
1406}

References libMesh::NameBasedIO::write().

Referenced by main().

◆ write() [2/2]

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

Write to the file specified by name.

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

Definition at line 1410 of file unstructured_mesh.C.

1413{
1414 LOG_SCOPE("write()", "Mesh");
1415
1416 NameBasedIO(*this).write_nodal_data(name, v, vn);
1417}
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...

References libMesh::NameBasedIO::write_nodal_data().

Member Data Documentation

◆ _all_elemset_ids

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

◆ _allow_node_and_elem_unique_id_overlap

bool libMesh::MeshBase::_allow_node_and_elem_unique_id_overlap
protectedinherited

The Exodus reader (and potentially other readers in the future?) now supports setting Node and Elem unique_ids based on values from within the Exodus file itself, rather than generating them automatically in LibMesh.

In this case, the unique_ids will not necessarily be unique across the set of all DofObjects, although they should still be unique within the individual sets of Elems and Nodes. The reader can therefore set this Mesh flag (which defaults to false) to indicate we should be less strict when checking the "uniqueness" of unique_ids.

Definition at line 2301 of file mesh_base.h.

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

◆ _allow_remote_element_removal

bool libMesh::MeshBase::_allow_remote_element_removal
protectedinherited

◆ _block_id_to_name

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

◆ _communicator

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

◆ _const_active_local_element_stored_range

std::unique_ptr<ConstElemRange> libMesh::MeshBase::_const_active_local_element_stored_range
mutableprotectedinherited

A cached ConstElemRange for threaded calculation on all local elements of this mesh.

This will not actually be built unless needed. Further, since we want our elem_stored_range() method to be const (yet do the dynamic allocating) this needs to be mutable.

Definition at line 2216 of file mesh_base.h.

Referenced by libMesh::MeshBase::active_local_element_stored_range(), libMesh::MeshBase::clear_stored_ranges(), libMesh::MeshBase::operator=(), and libMesh::MeshBase::update_post_partitioning().

◆ _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 2231 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 2415 of file mesh_base.h.

Referenced by libMesh::MeshBase::default_ghosting(), libMesh::MeshBase::locally_equals(), libMesh::MeshBase::MeshBase(), 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 2190 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 2183 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().

◆ _deleted_coarse_elements

bool libMesh::DistributedMesh::_deleted_coarse_elements
inherited

A boolean remembering whether we've recently deleted top-level elements or not.

If so, we'll need to be extra careful when deleting "unused" nodes they used to have, because those nodes might still be used by ghost elements.

Definition at line 441 of file distributed_mesh.h.

Referenced by libMesh::DistributedMesh::clear(), libMesh::DistributedMesh::delete_elem(), libMesh::DistributedMesh::DistributedMesh(), libMesh::DistributedMesh::renumber_nodes_and_elements(), and libMesh::DistributedMesh::subclass_locally_equals().

◆ _disjoint_neighbor_boundary_pairs

std::unique_ptr<PeriodicBoundaries> libMesh::MeshBase::_disjoint_neighbor_boundary_pairs
protectedinherited

◆ _elem_default_orders

std::set<Order> libMesh::MeshBase::_elem_default_orders
protectedinherited

We cache the (default) order of the geometric elements present in the mesh.

E.g. if we have a mesh with TRI3 and TRI6 elements, this structure will contain FIRST and SECOND.

Definition at line 2322 of file mesh_base.h.

Referenced by libMesh::MeshBase::cache_elem_data(), libMesh::MeshBase::clear(), libMesh::MeshBase::copy_cached_data(), libMesh::MeshBase::copy_constraint_rows(), libMesh::MeshBase::elem_default_orders(), libMesh::MeshBase::get_info(), libMesh::MeshBase::locally_equals(), and libMesh::MeshBase::operator=().

◆ _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

◆ _element_stored_range

std::unique_ptr<ElemRange> libMesh::MeshBase::_element_stored_range
mutableprotectedinherited

A cached ElemRange for threaded mutation of all semilocal elements of this mesh.

This will not actually be built unless needed. Further, since we want our elem_stored_range() method to be const (yet do the dynamic allocating) this needs to be mutable.

Definition at line 2205 of file mesh_base.h.

Referenced by libMesh::MeshBase::clear_stored_ranges(), libMesh::MeshBase::element_stored_range(), and libMesh::MeshBase::operator=().

◆ _elements

dofobject_container<Elem> libMesh::DistributedMesh::_elements
inherited

◆ _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 2357 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

◆ _extra_ghost_elems

std::set<Elem *> libMesh::DistributedMesh::_extra_ghost_elems
inherited

◆ _ghosting_functors

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

◆ _interior_mesh

MeshBase* libMesh::MeshBase::_interior_mesh
protectedinherited

◆ _is_serial

bool libMesh::DistributedMesh::_is_serial
inherited

◆ _is_serial_on_proc_0

bool libMesh::DistributedMesh::_is_serial_on_proc_0
inherited

◆ _max_elem_id

dof_id_type libMesh::DistributedMesh::_max_elem_id
inherited

◆ _max_node_id

dof_id_type libMesh::DistributedMesh::_max_node_id
inherited

◆ _mesh_subdomains

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

◆ _n_elem

dof_id_type libMesh::DistributedMesh::_n_elem
inherited

◆ _n_nodes

dof_id_type libMesh::DistributedMesh::_n_nodes
inherited

◆ _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 2177 of file mesh_base.h.

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

◆ _next_free_local_elem_id

dof_id_type libMesh::DistributedMesh::_next_free_local_elem_id
inherited

◆ _next_free_local_node_id

dof_id_type libMesh::DistributedMesh::_next_free_local_node_id
inherited

Guaranteed globally unused IDs for use when adding new nodes or elements.

Definition at line 452 of file distributed_mesh.h.

Referenced by libMesh::DistributedMesh::add_node(), libMesh::DistributedMesh::clear(), libMesh::DistributedMesh::DistributedMesh(), and libMesh::DistributedMesh::update_parallel_id_counts().

◆ _next_free_unpartitioned_elem_id

dof_id_type libMesh::DistributedMesh::_next_free_unpartitioned_elem_id
inherited

◆ _next_free_unpartitioned_node_id

dof_id_type libMesh::DistributedMesh::_next_free_unpartitioned_node_id
inherited

◆ _next_unique_id

unique_id_type libMesh::MeshBase::_next_unique_id
protectedinherited

◆ _next_unpartitioned_unique_id

unique_id_type libMesh::DistributedMesh::_next_unpartitioned_unique_id
inherited

◆ _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

◆ _nodes

processor_id_type pid unsigned int level std::set< subdomain_id_type > ss const DofMap &dof_map LIBMESH_COMMA unsigned int dof_map LIBMESH_COMMA var_num unsigned char rflag processor_id_type pid const DofMap& dof_map LIBMESH_COMMA unsigned int dof_map LIBMESH_COMMA var_num DECLARE_NODE_ITERATORS (multi_evaluable_, std::vector<const DofMap *> dof_maps, dof_maps) protected dofobject_container<Node> libMesh::DistributedMesh::_nodes
inherited

◆ _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 2225 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

◆ _preparation

Preparation libMesh::MeshBase::_preparation
protectedinherited

Flags indicating in what ways this mesh has been prepared.

Definition at line 2195 of file mesh_base.h.

Referenced by libMesh::MeshBase::cache_elem_data(), libMesh::MeshBase::clear(), libMesh::MeshBase::complete_preparation(), libMesh::MeshBase::delete_remote_elements(), libMesh::DistributedMesh::delete_remote_elements(), libMesh::MeshBase::detect_interior_parents(), libMesh::DistributedMesh::DistributedMesh(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::BoundaryInfo::get_global_boundary_ids(), libMesh::MeshBase::is_prepared(), libMesh::MeshBase::locally_equals(), libMesh::MeshBase::operator=(), libMesh::MeshBase::partition(), libMesh::MeshBase::preparation(), libMesh::MeshBase::prepare_for_use(), libMesh::MeshBase::reinit_ghosting_functors(), libMesh::MeshBase::remove_orphaned_nodes(), libMesh::DistributedMesh::renumber_nodes_and_elements(), libMesh::ReplicatedMesh::renumber_nodes_and_elements(), libMesh::ReplicatedMesh::ReplicatedMesh(), libMesh::MeshBase::set_isnt_prepared(), libMesh::MeshBase::sync_subdomain_name_map(), libMesh::BoundaryInfo::synchronize_global_id_set(), libMesh::MeshBase::unset_has_boundary_id_sets(), libMesh::MeshBase::unset_has_cached_elem_data(), libMesh::MeshBase::unset_has_interior_parent_ptrs(), libMesh::MeshBase::unset_has_neighbor_ptrs(), libMesh::MeshBase::unset_has_reinit_ghosting_functors(), libMesh::MeshBase::unset_has_removed_orphaned_nodes(), libMesh::MeshBase::unset_has_removed_remote_elements(), libMesh::MeshBase::unset_has_synched_id_counts(), libMesh::MeshBase::unset_has_synched_subdomain_name_map(), libMesh::MeshBase::unset_is_partitioned(), libMesh::MeshBase::unset_is_prepared(), libMesh::DistributedMesh::update_parallel_id_counts(), and libMesh::ReplicatedMesh::update_parallel_id_counts().

◆ _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 2430 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_detect_interior_parents

bool libMesh::MeshBase::_skip_detect_interior_parents
protectedinherited

◆ _skip_find_neighbors

bool libMesh::MeshBase::_skip_find_neighbors
protectedinherited

◆ _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 2258 of file mesh_base.h.

Referenced by libMesh::MeshBase::locally_equals(), libMesh::MeshBase::operator=(), libMesh::MeshBase::skip_noncritical_partitioning(), 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

◆ _supported_nodal_order

Order libMesh::MeshBase::_supported_nodal_order
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 2131 of file mesh_base.h.

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

◆ ElemRange

const DofMap& dof_map LIBMESH_COMMA unsigned int Elem* libMesh::MeshBase::ElemRange
inherited

Definition at line 1894 of file mesh_base.h.

◆ level [1/2]

unsigned int libMesh::DistributedMesh::level
inherited

Definition at line 352 of file distributed_mesh.h.

◆ level [2/2]

processor_id_type pid unsigned int libMesh::DistributedMesh::level
inherited

Definition at line 379 of file distributed_mesh.h.

◆ pid [1/2]

processor_id_type libMesh::DistributedMesh::pid
inherited

◆ pid [2/2]

processor_id_type pid unsigned int level std::set< subdomain_id_type > ss const DofMap &dof_map LIBMESH_COMMA unsigned int dof_map LIBMESH_COMMA var_num unsigned char rflag processor_id_type libMesh::DistributedMesh::pid
inherited

Definition at line 401 of file distributed_mesh.h.

◆ rflag

processor_id_type pid unsigned int level std::set< subdomain_id_type > ss const DofMap &dof_map LIBMESH_COMMA unsigned int dof_map LIBMESH_COMMA var_num unsigned char libMesh::DistributedMesh::rflag
inherited

Definition at line 391 of file distributed_mesh.h.

◆ ss [1/2]

unsigned int level ElemType type std::set<subdomain_id_type> libMesh::DistributedMesh::ss
inherited

◆ ss [2/2]

processor_id_type pid unsigned int level std::set<subdomain_id_type> libMesh::DistributedMesh::ss
inherited

Definition at line 381 of file distributed_mesh.h.

◆ type

unsigned int level ElemType libMesh::DistributedMesh::type
inherited

Definition at line 354 of file distributed_mesh.h.

◆ var_num [1/2]

processor_id_type pid unsigned int level std::set< subdomain_id_type > ss const DofMap& dof_map LIBMESH_COMMA unsigned int libMesh::DistributedMesh::var_num = libMesh::invalid_uint
inherited

Definition at line 387 of file distributed_mesh.h.

◆ var_num [2/2]

processor_id_type pid unsigned int level std::set< subdomain_id_type > ss const DofMap &dof_map LIBMESH_COMMA unsigned int dof_map LIBMESH_COMMA var_num unsigned char rflag processor_id_type pid const DofMap& dof_map LIBMESH_COMMA unsigned int libMesh::DistributedMesh::var_num = libMesh::invalid_uint
inherited

Definition at line 404 of file distributed_mesh.h.


The documentation for this class was generated from the following file: