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

The DistributedMesh class is derived from the MeshBase class, and is intended to provide identical functionality to the user but be distributed rather than replicated across distributed-memory systems. More...

#include <distributed_mesh.h>

Inheritance diagram for libMesh::DistributedMesh:
[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. More...
 
typedef Predicates::multi_predicate Predicate
 We need an empty, generic class to act as a predicate for this and derived mesh classes. More...
 
typedef std::vector< std::pair< std::pair< const Elem *, unsigned int >, Real > > constraint_rows_mapped_type
 
typedef std::map< const Node *, constraint_rows_mapped_typeconstraint_rows_type
 

Public Member Functions

 DistributedMesh (const Parallel::Communicator &comm_in, unsigned char dim=1)
 Constructor. More...
 
 DistributedMesh (const MeshBase &other_mesh)
 Copy-constructor. More...
 
 DistributedMesh (const DistributedMesh &other_mesh)
 Copy-constructor, possibly specialized for a distributed mesh. More...
 
 DistributedMesh (DistributedMesh &&)=delete
 Move-constructor deleted in MeshBase. More...
 
DistributedMeshoperator= (const DistributedMesh &)=delete
 Copy assignment is not allowed. More...
 
DistributedMeshoperator= (DistributedMesh &&other_mesh)
 Overloaded operator= will move contents of other_mesh to calling DistributedMesh object. More...
 
virtual MeshBaseassign (MeshBase &&other_mesh) override
 Shim to call the move assignment operator for this class. More...
 
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. More...
 
virtual std::unique_ptr< MeshBaseclone () const override
 Virtual copy-constructor, creates a copy of this mesh. More...
 
virtual ~DistributedMesh ()
 Destructor. More...
 
virtual void clear () override
 Clear all internal data. More...
 
virtual void clear_elems () override
 Clear internal Elem data. More...
 
virtual void redistribute () override
 Redistribute elements between processors. More...
 
virtual void update_post_partitioning () override
 Recalculate cached data after elements and nodes have been repartitioned. More...
 
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. More...
 
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. More...
 
virtual void libmesh_assert_valid_parallel_ids () const override
 Verify id and processor_id consistency of our elements and nodes containers. More...
 
void libmesh_assert_valid_parallel_p_levels () const
 Verify p_level consistency of our elements containers. More...
 
void libmesh_assert_valid_parallel_flags () const
 Verify refinement_flag and p_refinement_flag consistency of our elements containers. More...
 
template<typename T >
dof_id_type renumber_dof_objects (dofobject_container< T > &)
 Renumber a parallel objects container. More...
 
virtual void renumber_nodes_and_elements () override
 Remove nullptr elements from arrays. More...
 
virtual void allgather () override
 Gathers all elements and nodes of the mesh onto every processor. More...
 
virtual void gather_to_zero () override
 Gathers all elements and nodes of the mesh onto processor zero. More...
 
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. More...
 
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. More...
 
virtual void clear_extra_ghost_elems ()
 Clears extra ghost elements. More...
 
virtual void clear_extra_ghost_elems (const std::set< Elem *> &extra_ghost_elems)
 Clears specified extra ghost elements. More...
 
const std::set< Elem * > & extra_ghost_elems () const
 Const accessor to the ghosted elements. More...
 
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. More...
 
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. More...
 
virtual void update_parallel_id_counts () override
 Updates parallel caches so that methods like n_elem() accurately reflect changes on other processors. More...
 
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. More...
 
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. More...
 
virtual Nodeadd_node (Node *n) override final
 Add Node n to the end of the vertex array. More...
 
virtual Nodeadd_node (std::unique_ptr< Node > n) override final
 Version of add_node() taking a std::unique_ptr by value. More...
 
virtual Nodeinsert_node (Node *n) override final
 These methods are deprecated. More...
 
virtual Nodeinsert_node (std::unique_ptr< Node > n) override final
 This method is deprecated. More...
 
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. More...
 
virtual void delete_node (Node *n) override final
 Removes the Node n from the mesh. More...
 
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. More...
 
virtual Elemadd_elem (Elem *e) override final
 Add elem e to the end of the element array. More...
 
virtual Elemadd_elem (std::unique_ptr< Elem > e) override final
 Version of add_elem() taking a std::unique_ptr by value. More...
 
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. More...
 
virtual Eleminsert_elem (std::unique_ptr< Elem > e) override final
 Version of insert_elem() taking a std::unique_ptr by value. More...
 
virtual void delete_elem (Elem *e) override final
 Removes element e from the mesh. More...
 
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. More...
 
virtual void fix_broken_node_and_element_numbering () override
 There is no reason for a user to ever call this function. More...
 
 DECLARE_ELEM_ITERATORS (,,)
 Elem and Node iterator accessor functions. More...
 
 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_
 
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
 
 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(
 
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) override
 Reads the file specified by name. More...
 
virtual void write (const std::string &name) const override
 Write the file specified by name. More...
 
void write (const std::string &name, const std::vector< Number > &values, const std::vector< std::string > &variable_names) const
 Write to the file specified by name. More...
 
virtual void all_first_order () override
 Converts a mesh with higher-order elements into a mesh with linear elements. More...
 
virtual void all_second_order_range (const SimpleRange< element_iterator > &range, const bool full_ordered=true) override
 Converts a (conforming, non-refined) mesh with linear elements into a mesh with second-order elements. More...
 
virtual void all_complete_order_range (const SimpleRange< element_iterator > &range) override
 Converts a (conforming, non-refined) mesh with linear elements into a mesh with "complete" order elements, i.e. More...
 
void create_pid_mesh (UnstructuredMesh &pid_mesh, const processor_id_type pid) const
 Generates a new mesh containing all the elements which are assigned to processor pid. More...
 
void create_submesh (UnstructuredMesh &new_mesh, const const_element_iterator &it, const const_element_iterator &it_end) const
 Constructs a mesh called "new_mesh" from the current mesh by iterating over the elements between it and it_end and adding them to the new mesh. More...
 
std::size_t stitch_meshes (const MeshBase &other_mesh, boundary_id_type this_mesh_boundary, boundary_id_type other_mesh_boundary, Real tol=TOLERANCE, bool clear_stitched_boundary_ids=false, bool verbose=true, bool use_binary_search=true, bool enforce_all_nodes_match_on_boundaries=false, bool merge_boundary_nodes_all_or_nothing=false, bool remap_subdomain_ids=false)
 Stitch other_mesh to this mesh so that this mesh is the union of the two meshes. More...
 
std::size_t stitch_surfaces (boundary_id_type boundary_id_1, boundary_id_type boundary_id_2, Real tol=TOLERANCE, bool clear_stitched_boundary_ids=false, bool verbose=true, bool use_binary_search=true, bool enforce_all_nodes_match_on_boundaries=false, bool merge_boundary_nodes_all_or_nothing=false)
 Similar to stitch_meshes, except that we stitch two adjacent surfaces within this mesh. More...
 
virtual void copy_nodes_and_elements (const MeshBase &other_mesh, const bool skip_find_neighbors=false, dof_id_type element_id_offset=0, dof_id_type node_id_offset=0, unique_id_type unique_id_offset=0, std::unordered_map< subdomain_id_type, subdomain_id_type > *id_remapping=nullptr)
 Deep copy of nodes and elements from another mesh object (used by subclass copy constructors and by mesh merging operations) More...
 
virtual void move_nodes_and_elements (MeshBase &&other_mesh)=0
 Move node and elements from other_mesh to this mesh. More...
 
virtual void find_neighbors (const bool reset_remote_elements=false, const bool reset_current_list=true) override
 Other functions from MeshBase requiring re-definition. More...
 
virtual bool contract () override
 Delete subactive (i.e. More...
 
bool operator== (const MeshBase &other_mesh) const
 This tests for exactly-equal data in all the senses that a mathematician would care about (element connectivity, nodal coordinates), but in the senses a programmer would care about it allows for non-equal equivalence in some ways (we accept different Elem/Node addresses in memory) but not others (we do not accept different subclass types, nor even different Elem/Node ids). More...
 
bool operator!= (const MeshBase &other_mesh) const
 
bool locally_equals (const MeshBase &other_mesh) const
 This behaves the same as operator==, but only for the local and ghosted aspects of the mesh; i.e. More...
 
virtual std::unique_ptr< Partitioner > & partitioner ()
 A partitioner to use at each prepare_for_use() More...
 
const BoundaryInfoget_boundary_info () const
 The information about boundary ids on the mesh. More...
 
BoundaryInfoget_boundary_info ()
 Writable information about boundary ids on the mesh. More...
 
bool is_prepared () const
 
void set_isnt_prepared ()
 Tells this we have done some operation where we should no longer consider ourself prepared. More...
 
void reinit_ghosting_functors ()
 Loops over ghosting functors and calls mesh_reinit() More...
 
unsigned int mesh_dimension () const
 
void set_mesh_dimension (unsigned char d)
 Resets the logical dimension of the mesh. More...
 
const std::set< unsigned char > & elem_dimensions () const
 
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. More...
 
void add_elemset_code (dof_id_type code, MeshBase::elemset_type id_set)
 Tabulate a user-defined "code" for elements which belong to the element sets specified in id_set. More...
 
unsigned int n_elemsets () const
 Returns the number of unique elemset ids which have been added via add_elemset_code(), which is the size of the _all_elemset_ids set. More...
 
void get_elemsets (dof_id_type elemset_code, MeshBase::elemset_type &id_set_to_fill) const
 Look up the element sets for a given elemset code and vice-versa. More...
 
dof_id_type get_elemset_code (const MeshBase::elemset_type &id_set) const
 
std::vector< dof_id_typeget_elemset_codes () const
 Return a vector of all elemset codes defined on the mesh. More...
 
void change_elemset_code (dof_id_type old_code, dof_id_type new_code)
 Replace elemset code "old_code" with "new_code". More...
 
void change_elemset_id (elemset_id_type old_id, elemset_id_type new_id)
 Replace elemset id "old_id" with "new_id". More...
 
unsigned int spatial_dimension () const
 
void set_spatial_dimension (unsigned char d)
 Sets the "spatial dimension" of the Mesh. More...
 
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 ()
 
dof_id_type n_elem_on_proc (const processor_id_type proc) const
 
dof_id_type n_local_elem () const
 
dof_id_type n_unpartitioned_elem () const
 
dof_id_type n_active_elem_on_proc (const processor_id_type proc) const
 
dof_id_type n_active_local_elem () const
 
dof_id_type n_sub_elem () const
 
dof_id_type n_active_sub_elem () const
 Same as n_sub_elem(), but only counts active elements. More...
 
virtual const 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. More...
 
void set_default_mapping_type (const ElemMappingType type)
 Set the default master space to physical space mapping basis functions to be used on newly added elements. More...
 
unsigned char default_mapping_data () const
 Returns any default data value used by the master space to physical space mapping. More...
 
void set_default_mapping_data (const unsigned char data)
 Set the default master space to physical space mapping basis functions to be used on newly added elements. More...
 
void remove_orphaned_nodes ()
 Removes any orphaned nodes, nodes not connected to any elements. More...
 
unsigned int add_elem_integer (std::string name, bool allocate_data=true, dof_id_type default_value=DofObject::invalid_id)
 Register an integer datum (of type dof_id_type) to be added to each element in the mesh. More...
 
std::vector< unsigned intadd_elem_integers (const std::vector< std::string > &names, bool allocate_data=true, const std::vector< dof_id_type > *default_values=nullptr)
 Register integer data (of type dof_id_type) to be added to each element in the mesh, one string name for each new integer. More...
 
unsigned int get_elem_integer_index (std::string_view name) const
 
bool has_elem_integer (std::string_view name) const
 
const std::string & get_elem_integer_name (unsigned int i) const
 
unsigned int n_elem_integers () const
 
template<typename T >
unsigned int add_elem_datum (const std::string &name, bool allocate_data=true, const T *default_value=nullptr)
 Register a datum (of type T) to be added to each element in the mesh. More...
 
template<typename T >
std::vector< unsigned intadd_elem_data (const std::vector< std::string > &names, bool allocate_data=true, const std::vector< T > *default_values=nullptr)
 Register data (of type T) to be added to each element in the mesh. More...
 
unsigned int add_node_integer (std::string name, bool allocate_data=true, dof_id_type default_value=DofObject::invalid_id)
 Register an integer datum (of type dof_id_type) to be added to each node in the mesh. More...
 
std::vector< unsigned intadd_node_integers (const std::vector< std::string > &names, bool allocate_data=true, const std::vector< dof_id_type > *default_values=nullptr)
 Register integer data (of type dof_id_type) to be added to each node in the mesh. More...
 
unsigned int get_node_integer_index (std::string_view name) const
 
bool has_node_integer (std::string_view name) const
 
const std::string & get_node_integer_name (unsigned int i) const
 
unsigned int n_node_integers () const
 
template<typename T >
unsigned int add_node_datum (const std::string &name, bool allocate_data=true, const T *default_value=nullptr)
 Register a datum (of type T) to be added to each node in the mesh. More...
 
template<typename T >
std::vector< unsigned intadd_node_data (const std::vector< std::string > &name, bool allocate_data=true, const std::vector< T > *default_values=nullptr)
 Register data (of type T) to be added to each node in the mesh. More...
 
void prepare_for_use (const bool skip_renumber_nodes_and_elements, const bool skip_find_neighbors)
 Prepare a newly ecreated (or read) mesh for use. More...
 
void prepare_for_use (const bool skip_renumber_nodes_and_elements)
 
void prepare_for_use ()
 
virtual void partition (const unsigned int n_parts)
 Call the default partitioner (currently metis_partition()). More...
 
void partition ()
 
void allow_renumbering (bool allow)
 If false is passed in then this mesh will no longer be renumbered when being prepared for use. More...
 
bool allow_renumbering () const
 
void allow_find_neighbors (bool allow)
 If false is passed then this mesh will no longer work to find element neighbors when being prepared for use. More...
 
bool allow_find_neighbors () const
 
void allow_remote_element_removal (bool allow)
 If false is passed in then this mesh will no longer have remote elements deleted when being prepared for use; i.e. More...
 
bool allow_remote_element_removal () const
 
void skip_noncritical_partitioning (bool skip)
 If true is passed in then the elements on this mesh will no longer be (re)partitioned, and the nodes on this mesh will only be repartitioned if they are found "orphaned" via coarsening or other removal of the last element responsible for their node/element processor id consistency. More...
 
bool skip_noncritical_partitioning () const
 
void skip_partitioning (bool skip)
 If true is passed in then nothing on this mesh will be (re)partitioned. More...
 
bool skip_partitioning () const
 
void add_ghosting_functor (GhostingFunctor &ghosting_functor)
 Adds a functor which can specify ghosting requirements for use on distributed meshes. More...
 
void add_ghosting_functor (std::shared_ptr< GhostingFunctor > ghosting_functor)
 Adds a functor which can specify ghosting requirements for use on distributed meshes. More...
 
void remove_ghosting_functor (GhostingFunctor &ghosting_functor)
 Removes a functor which was previously added to the set of ghosting functors. More...
 
std::set< GhostingFunctor * >::const_iterator ghosting_functors_begin () const
 Beginning of range of ghosting functors. More...
 
std::set< GhostingFunctor * >::const_iterator ghosting_functors_end () const
 End of range of ghosting functors. More...
 
GhostingFunctordefault_ghosting ()
 Default ghosting functor. More...
 
void subdomain_ids (std::set< subdomain_id_type > &ids, const bool global=true) const
 Constructs a list of all subdomain identifiers in the local mesh if global == false, and in the global mesh if global == true (default). More...
 
subdomain_id_type n_subdomains () const
 
subdomain_id_type n_local_subdomains () const
 
unsigned int n_partitions () const
 
std::string get_info (const unsigned int verbosity=0, const bool global=true) const
 
void print_info (std::ostream &os=libMesh::out, const unsigned int verbosity=0, const bool global=true) const
 Prints relevant information about the mesh. More...
 
void all_second_order (const bool full_ordered=true)
 Calls the range-based version of this function with a range consisting of all elements in the mesh. More...
 
virtual void all_complete_order ()
 Calls the range-based version of this function with a range consisting of all elements in the mesh. More...
 
unsigned int recalculate_n_partitions ()
 In a few (very rare) cases, the user may have manually tagged the elements with specific processor IDs by hand, without using a partitioner. More...
 
std::unique_ptr< PointLocatorBasesub_point_locator () const
 
void set_point_locator_close_to_point_tol (Real val)
 Set value used by PointLocatorBase::close_to_point_tol(). More...
 
Real get_point_locator_close_to_point_tol () const
 
void clear_point_locator ()
 Releases the current PointLocator object. More...
 
void set_count_lower_dim_elems_in_point_locator (bool count_lower_dim_elems)
 In the point locator, do we count lower dimensional elements when we refine point locator regions? This is relevant in tree-based point locators, for example. More...
 
bool get_count_lower_dim_elems_in_point_locator () const
 Get the current value of _count_lower_dim_elems_in_point_locator. More...
 
std::string & subdomain_name (subdomain_id_type id)
 
const std::string & subdomain_name (subdomain_id_type id) const
 
subdomain_id_type get_id_by_name (std::string_view name) const
 
 ABSTRACT_ELEM_ITERATORS (,) ABSTRACT_ELEM_ITERATORS(active_
 
 ABSTRACT_ELEM_ITERATORS (ancestor_,) ABSTRACT_ELEM_ITERATORS(subactive_
 
 ABSTRACT_ELEM_ITERATORS (local_,) ABSTRACT_ELEM_ITERATORS(unpartitioned_
 
 ABSTRACT_ELEM_ITERATORS (facelocal_,) ABSTRACT_ELEM_ITERATORS(level_
 
unsigned int level ABSTRACT_ELEM_ITERATORS (pid_, processor_id_type pid) ABSTRACT_ELEM_ITERATORS(type_
 
unsigned int level ElemType type ABSTRACT_ELEM_ITERATORS (active_subdomain_, subdomain_id_type sid) ABSTRACT_ELEM_ITERATORS(active_subdomain_set_
 
unsigned int level ElemType type std::set< subdomain_id_type > ss ABSTRACT_ELEM_ITERATORS (not_active_,) ABSTRACT_ELEM_ITERATORS(not_ancestor_
 
unsigned int level ElemType type std::set< subdomain_id_type > ss ABSTRACT_ELEM_ITERATORS (not_subactive_,) ABSTRACT_ELEM_ITERATORS(not_local_
 
unsigned int level ElemType type std::set< subdomain_id_type > ss ABSTRACT_ELEM_ITERATORS (not_level_, unsigned int level) ABSTRACT_ELEM_ITERATORS(active_local_
 
unsigned int level ElemType type std::set< subdomain_id_type > ss ABSTRACT_ELEM_ITERATORS (active_not_local_,) ABSTRACT_ELEM_ITERATORS(active_unpartitioned_
 
unsigned int level ElemType type std::set< subdomain_id_type > ss ABSTRACT_ELEM_ITERATORS (active_type_, ElemType type) ABSTRACT_ELEM_ITERATORS(active_pid_
 
unsigned int level ElemType type std::set< subdomain_id_type > ss processor_id_type pid ABSTRACT_ELEM_ITERATORS (local_level_, unsigned int level) ABSTRACT_ELEM_ITERATORS(local_not_level_
 
unsigned int level ElemType type std::set< subdomain_id_type > ss processor_id_type pid unsigned int level ABSTRACT_ELEM_ITERATORS (active_local_subdomain_, subdomain_id_type sid) ABSTRACT_ELEM_ITERATORS(active_local_subdomain_set_
 
 ABSTRACT_ELEM_ITERATORS (semilocal_,) ABSTRACT_ELEM_ITERATORS(ghost_
 
 ABSTRACT_ELEM_ITERATORS (active_semilocal_,) ABSTRACT_ELEM_ITERATORS(evaluable_
 
const DofMap &dof_map LIBMESH_COMMA unsigned int std::string & set_subdomain_name_map ()
 
const std::map< subdomain_id_type, std::string > & get_subdomain_name_map () const
 
constraint_rows_typeget_constraint_rows ()
 Constraint rows accessors. More...
 
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. More...
 
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. More...
 
void print_constraint_rows (std::ostream &os=libMesh::out, bool print_nonlocal=false) const
 Prints (from processor 0) all mesh constraint rows. More...
 
std::string get_local_constraints (bool print_nonlocal=false) const
 Gets a string reporting all mesh constraint rows local to this processor. More...
 
void cache_elem_dims ()
 
void cache_elem_data ()
 
void detect_interior_parents ()
 Search the mesh for elements that have a neighboring element of dim+1 and set that element as the interior parent. More...
 
const MeshBaseinterior_mesh () const
 
MeshBaseinterior_mesh ()
 
void set_interior_mesh (MeshBase &int_mesh)
 Sets the interior mesh. More...
 
const std::set< subdomain_id_type > & get_mesh_subdomains () const
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Public Attributes

unsigned int level
 
unsigned int level ElemType type
 
unsigned int level ElemType type std::set< subdomain_id_typess
 
processor_id_type pid
 
processor_id_type pid unsigned int level
 
processor_id_type pid unsigned int level std::set< subdomain_id_typess
 
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 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 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 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. More...
 
dofobject_container< Elem_elements
 The elements in the mesh. More...
 
bool _is_serial
 A boolean remembering whether we're serialized or not. More...
 
bool _is_serial_on_proc_0
 A boolean remembering whether we're serialized to proc 0 or not. More...
 
bool _deleted_coarse_elements
 A boolean remembering whether we've recently deleted top-level elements or not. More...
 
dof_id_type _n_nodes
 Cached data from the last renumber_nodes_and_elements call. More...
 
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. More...
 
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. More...
 
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() More...
 

Protected Types

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

Protected Member Functions

void post_dofobject_moves (MeshBase &&other_mesh)
 Moves any superclass data (e.g. More...
 
void copy_cached_data (const MeshBase &other_mesh)
 Helper class to copy cached data, to synchronize with a possibly unprepared other_mesh. More...
 
bool nodes_and_elements_equal (const MeshBase &other_mesh) const
 Tests for equality of all elements and nodes in the mesh. More...
 
unsigned intset_n_partitions ()
 
void size_elem_extra_integers ()
 Size extra-integer arrays of all elements in the mesh. More...
 
void size_node_extra_integers ()
 Size extra-integer arrays of all nodes in the mesh. More...
 
std::pair< std::vector< unsigned int >, std::vector< unsigned int > > merge_extra_integer_names (const MeshBase &other)
 Merge extra-integer arrays from an other mesh. More...
 

Protected Attributes

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

Private Types

typedef dofobject_container< Elem >::veclike_iterator elem_iterator_imp
 Typedefs for the container implementation. More...
 
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. More...
 
typedef dofobject_container< Node >::const_veclike_iterator const_node_iterator_imp
 

Detailed Description

The DistributedMesh class is derived from the MeshBase class, and is intended to provide identical functionality to the user but be distributed rather than replicated across distributed-memory systems.

Author
Roy Stogner
Date
2007 Mesh data structure which is distributed across all processors.

Definition at line 57 of file distributed_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 2147 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 2167 of file mesh_base.h.

◆ const_elem_iterator_imp

Definition at line 485 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 2154 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 2180 of file mesh_base.h.

◆ const_node_iterator_imp

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

◆ constraint_rows_type

Definition at line 1698 of file mesh_base.h.

◆ dofobject_container [1/2]

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

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>

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 2142 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 2162 of file mesh_base.h.

◆ elem_iterator_imp

Typedefs for the container implementation.

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

◆ node_filter_iter [1/2]

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

◆ node_iterator_imp

Typedefs for the container implementation.

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

Constructor & Destructor Documentation

◆ DistributedMesh() [1/4]

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

Constructor.

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

Definition at line 42 of file distributed_mesh.C.

References libMesh::MeshBase::_next_unique_id, libMesh::MeshBase::_partitioner, libMesh::Partitioner::build(), libMesh::command_line_value(), and libMesh::ParallelObject::processor_id().

43  :
44  UnstructuredMesh (comm_in,d), _is_serial(true),
52 #ifdef LIBMESH_ENABLE_UNIQUE_ID
54 #endif
55 {
56 #ifdef LIBMESH_ENABLE_UNIQUE_ID
57  _next_unique_id = this->processor_id();
58 #endif
59 
60  const std::string default_partitioner = "parmetis";
61  const std::string my_partitioner =
62  libMesh::command_line_value("--default-partitioner",
63  default_partitioner);
65  (Utility::string_to_enum<PartitionerType>(my_partitioner));
66 }
67 
69 {
70  LOG_SCOPE("operator=(&&)", "DistributedMesh");
71 
72  // Move assign as an UnstructuredMesh.
73  this->UnstructuredMesh::operator=(std::move(other_mesh));
74 
75  // Nodes and elements belong to DistributedMesh and have to be
76  // moved before we can move arbitrary GhostingFunctor, Partitioner,
77  // etc. subclasses.
78  this->move_nodes_and_elements(std::move(other_mesh));
79 
80  // But move_nodes_and_elems misses (or guesses about) some of our
81  // subclass values, and we want more precision than a guess.
82  _deleted_coarse_elements = other_mesh._deleted_coarse_elements;
83  _extra_ghost_elems = std::move(other_mesh._extra_ghost_elems);
84 
85  // Handle remaining MeshBase moves.
86  this->post_dofobject_moves(std::move(other_mesh));
87 
88  return *this;
89 }
UnstructuredMesh & operator=(const UnstructuredMesh &)=delete
Copy assignment is not allowed.
bool _is_serial_on_proc_0
A boolean remembering whether we&#39;re serialized to proc 0 or not.
dof_id_type _n_nodes
Cached data from the last renumber_nodes_and_elements call.
dof_id_type _next_free_local_node_id
Guaranteed globally unused IDs for use when adding new nodes or elements.
bool _is_serial
A boolean remembering whether we&#39;re serialized or not.
unique_id_type _next_unique_id
The next available unique id for assigning ids to DOF objects.
Definition: mesh_base.h:1925
processor_id_type n_processors() const
T command_line_value(const std::string &, T)
Definition: libmesh.C:1024
static std::unique_ptr< Partitioner > build(const PartitionerType solver_package)
Builds a Partitioner of the type specified by partitioner_type.
Definition: partitioner.C:159
virtual void move_nodes_and_elements(MeshBase &&other_mesh)=0
Move node and elements from other_mesh to this mesh.
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...
std::unique_ptr< Partitioner > _partitioner
A partitioner to use at each prepare_for_use().
Definition: mesh_base.h:1919
dof_id_type _next_free_unpartitioned_node_id
UnstructuredMesh(const Parallel::Communicator &comm_in, unsigned char dim=1)
Constructor.
DistributedMesh & operator=(const DistributedMesh &)=delete
Copy assignment is not allowed.
dof_id_type _next_free_unpartitioned_elem_id
DistributedMesh(const Parallel::Communicator &comm_in, unsigned char dim=1)
Constructor.
void post_dofobject_moves(MeshBase &&other_mesh)
Moves any superclass data (e.g.
Definition: mesh_base.C:1969
unique_id_type _next_unpartitioned_unique_id
The next available unique id for assigning ids to unpartitioned DOF objects.
processor_id_type processor_id() const
dof_id_type _next_free_local_elem_id
bool _deleted_coarse_elements
A boolean remembering whether we&#39;ve recently deleted top-level elements or not.

◆ DistributedMesh() [2/4]

libMesh::DistributedMesh::DistributedMesh ( const MeshBase other_mesh)

Copy-constructor.

This should be able to take a replicated or distributed mesh.

Definition at line 184 of file distributed_mesh.C.

References libMesh::MeshBase::_is_prepared, libMesh::MeshBase::_next_unique_id, _next_unpartitioned_unique_id, libMesh::MeshBase::allow_find_neighbors(), libMesh::MeshBase::allow_remote_element_removal(), libMesh::MeshBase::allow_renumbering(), libMesh::MeshBase::copy_cached_data(), libMesh::MeshBase::copy_constraint_rows(), libMesh::UnstructuredMesh::copy_nodes_and_elements(), libMesh::MeshBase::get_boundary_info(), libMesh::MeshBase::get_subdomain_name_map(), libMesh::MeshBase::is_prepared(), libMesh::ParallelObject::n_processors(), libMesh::MeshBase::parallel_max_unique_id(), libMesh::ParallelObject::processor_id(), libMesh::MeshBase::set_subdomain_name_map(), libMesh::MeshBase::skip_partitioning(), and update_parallel_id_counts().

184  :
185  UnstructuredMesh (other_mesh), _is_serial(other_mesh.is_serial()),
186  _is_serial_on_proc_0(other_mesh.is_serial()),
187  _deleted_coarse_elements(true), // better safe than sorry...
188  _n_nodes(0), _n_elem(0), _max_node_id(0), _max_elem_id(0),
193 {
194  this->copy_nodes_and_elements(other_mesh, true);
195 
196  this->allow_find_neighbors(other_mesh.allow_find_neighbors());
197  this->allow_renumbering(other_mesh.allow_renumbering());
198  this->allow_remote_element_removal(other_mesh.allow_remote_element_removal());
199  this->skip_partitioning(other_mesh.skip_partitioning());
200 
201  // The prepare_for_use() in copy_nodes_and_elements() is going to be
202  // tricky to remove without breaking backwards compatibility, but it
203  // updates some things we want to just copy.
204  this->copy_cached_data(other_mesh);
205 
206  this->copy_constraint_rows(other_mesh);
207 
208  this->_is_prepared = other_mesh.is_prepared();
209 
210  auto & this_boundary_info = this->get_boundary_info();
211  const auto & other_boundary_info = other_mesh.get_boundary_info();
212 
213  this_boundary_info = other_boundary_info;
214 
215  this->set_subdomain_name_map() = other_mesh.get_subdomain_name_map();
216 
217 #ifdef LIBMESH_ENABLE_UNIQUE_ID
218  _next_unique_id = other_mesh.parallel_max_unique_id() +
219  this->processor_id();
221  (this->n_processors() - this->processor_id());
222 #endif
224 }
virtual void update_parallel_id_counts() override
Updates parallel caches so that methods like n_elem() accurately reflect changes on other processors...
virtual void copy_nodes_and_elements(const MeshBase &other_mesh, const bool skip_find_neighbors=false, dof_id_type element_id_offset=0, dof_id_type node_id_offset=0, unique_id_type unique_id_offset=0, std::unordered_map< subdomain_id_type, subdomain_id_type > *id_remapping=nullptr)
Deep copy of nodes and elements from another mesh object (used by subclass copy constructors and by m...
bool _is_serial_on_proc_0
A boolean remembering whether we&#39;re serialized to proc 0 or not.
void copy_cached_data(const MeshBase &other_mesh)
Helper class to copy cached data, to synchronize with a possibly unprepared other_mesh.
Definition: mesh_base.C:2004
dof_id_type _n_nodes
Cached data from the last renumber_nodes_and_elements call.
dof_id_type _next_free_local_node_id
Guaranteed globally unused IDs for use when adding new nodes or elements.
void copy_constraint_rows(const MeshBase &other_mesh)
Copy the constraints from the other mesh to this mesh.
Definition: mesh_base.C:2063
bool _is_serial
A boolean remembering whether we&#39;re serialized or not.
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:165
unique_id_type _next_unique_id
The next available unique id for assigning ids to DOF objects.
Definition: mesh_base.h:1925
processor_id_type n_processors() const
bool allow_find_neighbors() const
Definition: mesh_base.h:1204
bool allow_remote_element_removal() const
Definition: mesh_base.h:1213
dof_id_type _next_free_unpartitioned_node_id
bool skip_partitioning() const
Definition: mesh_base.h:1256
UnstructuredMesh(const Parallel::Communicator &comm_in, unsigned char dim=1)
Constructor.
dof_id_type _next_free_unpartitioned_elem_id
bool _is_prepared
Flag indicating if the mesh has been prepared for use.
Definition: mesh_base.h:1896
bool allow_renumbering() const
Definition: mesh_base.h:1197
unique_id_type _next_unpartitioned_unique_id
The next available unique id for assigning ids to unpartitioned DOF objects.
processor_id_type processor_id() const
const DofMap &dof_map LIBMESH_COMMA unsigned int std::string & set_subdomain_name_map()
Definition: mesh_base.h:1692
dof_id_type _next_free_local_elem_id
bool _deleted_coarse_elements
A boolean remembering whether we&#39;ve recently deleted top-level elements or not.

◆ DistributedMesh() [3/4]

libMesh::DistributedMesh::DistributedMesh ( const DistributedMesh other_mesh)

Copy-constructor, possibly specialized for a distributed mesh.

Definition at line 151 of file distributed_mesh.C.

References _deleted_coarse_elements, _extra_ghost_elems, _is_serial, _is_serial_on_proc_0, _max_elem_id, _max_node_id, _n_elem, _n_nodes, _next_free_local_elem_id, _next_free_local_node_id, _next_free_unpartitioned_elem_id, _next_free_unpartitioned_node_id, libMesh::MeshBase::_next_unique_id, _next_unpartitioned_unique_id, elem_ptr(), max_elem_id(), max_node_id(), n_elem(), and n_nodes().

151  :
152  DistributedMesh(static_cast<const MeshBase &>(other_mesh))
153 {
154  _is_serial = other_mesh._is_serial;
155  _is_serial_on_proc_0 = other_mesh._is_serial_on_proc_0;
156  _deleted_coarse_elements = other_mesh._deleted_coarse_elements;
157 
158  _n_nodes = other_mesh.n_nodes();
159  _n_elem = other_mesh.n_elem();
160  _max_node_id = other_mesh.max_node_id();
161  _max_elem_id = other_mesh.max_elem_id();
163  other_mesh._next_free_local_node_id;
165  other_mesh._next_free_local_elem_id;
167  other_mesh._next_free_unpartitioned_node_id;
169  other_mesh._next_free_unpartitioned_elem_id;
170 #ifdef LIBMESH_ENABLE_UNIQUE_ID
172  other_mesh._next_unique_id;
174  other_mesh._next_unpartitioned_unique_id;
175 #endif
176 
177  // Need to copy extra_ghost_elems
178  for (auto & elem : other_mesh._extra_ghost_elems)
179  _extra_ghost_elems.insert(this->elem_ptr(elem->id()));
180 }
bool _is_serial_on_proc_0
A boolean remembering whether we&#39;re serialized to proc 0 or not.
dof_id_type _n_nodes
Cached data from the last renumber_nodes_and_elements call.
dof_id_type _next_free_local_node_id
Guaranteed globally unused IDs for use when adding new nodes or elements.
bool _is_serial
A boolean remembering whether we&#39;re serialized or not.
unique_id_type _next_unique_id
The next available unique id for assigning ids to DOF objects.
Definition: mesh_base.h:1925
virtual const Elem * elem_ptr(const dof_id_type i) const override final
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...
dof_id_type _next_free_unpartitioned_node_id
dof_id_type _next_free_unpartitioned_elem_id
DistributedMesh(const Parallel::Communicator &comm_in, unsigned char dim=1)
Constructor.
unique_id_type _next_unpartitioned_unique_id
The next available unique id for assigning ids to unpartitioned DOF objects.
dof_id_type _next_free_local_elem_id
bool _deleted_coarse_elements
A boolean remembering whether we&#39;ve recently deleted top-level elements or not.

◆ DistributedMesh() [4/4]

libMesh::DistributedMesh::DistributedMesh ( DistributedMesh &&  )
delete

Move-constructor deleted in MeshBase.

◆ ~DistributedMesh()

libMesh::DistributedMesh::~DistributedMesh ( )
virtual

Destructor.

Definition at line 142 of file distributed_mesh.C.

References clear().

143 {
144  this->DistributedMesh::clear(); // Free nodes and elements
145 }
virtual void clear() override
Clear all internal data.

Member Function Documentation

◆ ABSTRACT_ELEM_ITERATORS() [1/15]

libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( )
inherited

◆ ABSTRACT_ELEM_ITERATORS() [2/15]

libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( ancestor_  )
inherited

◆ ABSTRACT_ELEM_ITERATORS() [3/15]

libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( local_  )
inherited

◆ ABSTRACT_ELEM_ITERATORS() [4/15]

libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( facelocal_  )
inherited

◆ ABSTRACT_ELEM_ITERATORS() [5/15]

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

◆ ABSTRACT_ELEM_ITERATORS() [6/15]

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

◆ ABSTRACT_ELEM_ITERATORS() [7/15]

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

◆ ABSTRACT_ELEM_ITERATORS() [8/15]

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

◆ ABSTRACT_ELEM_ITERATORS() [9/15]

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

◆ ABSTRACT_ELEM_ITERATORS() [10/15]

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

◆ ABSTRACT_ELEM_ITERATORS() [11/15]

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

◆ ABSTRACT_ELEM_ITERATORS() [12/15]

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

◆ ABSTRACT_ELEM_ITERATORS() [13/15]

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

◆ ABSTRACT_ELEM_ITERATORS() [14/15]

libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( semilocal_  )
inherited

◆ ABSTRACT_ELEM_ITERATORS() [15/15]

libMesh::MeshBase::ABSTRACT_ELEM_ITERATORS ( active_semilocal_  )
inherited

◆ active_local_subdomain_elements_ptr_range() [1/2]

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

Implements libMesh::MeshBase.

Definition at line 371 of file distributed_mesh.h.

371 { return active_local_subdomain_element_ptr_range(sid); }

◆ active_local_subdomain_elements_ptr_range() [2/2]

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

Implements libMesh::MeshBase.

Definition at line 372 of file distributed_mesh.h.

372 { return active_local_subdomain_element_ptr_range(sid); }

◆ active_subdomain_elements_ptr_range() [1/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)
inlinefinaloverridevirtual

Implements libMesh::MeshBase.

Definition at line 369 of file distributed_mesh.h.

369 { return active_subdomain_element_ptr_range(sid); }

◆ active_subdomain_elements_ptr_range() [2/2]

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

Implements libMesh::MeshBase.

Definition at line 370 of file distributed_mesh.h.

370 { return active_subdomain_element_ptr_range(sid); }

◆ active_subdomain_set_elements_ptr_range() [1/2]

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

Implements libMesh::MeshBase.

Definition at line 373 of file distributed_mesh.h.

References ss.

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

◆ active_subdomain_set_elements_ptr_range() [2/2]

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

Implements libMesh::MeshBase.

Definition at line 374 of file distributed_mesh.h.

References ss.

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

◆ add_elem() [1/2]

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

Add elem e to the end of the element array.

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

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

Implements libMesh::MeshBase.

Definition at line 534 of file distributed_mesh.C.

References libMesh::MeshBase::_elem_integer_default_values, libMesh::MeshBase::_elem_integer_names, _elements, _max_elem_id, _n_elem, _next_free_local_elem_id, _next_free_unpartitioned_elem_id, libMesh::MeshBase::_next_unique_id, _next_unpartitioned_unique_id, libMesh::DofObject::add_extra_integers(), 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::ParallelObject::processor_id(), libMesh::DofObject::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 add_elem(), and add_extra_ghost_elem().

535 {
536  // Don't try to add nullptrs!
537  libmesh_assert(e);
538 
539  // Trying to add an existing element is a no-op
540  if (e->valid_id() && _elements[e->id()] == e)
541  return e;
542 
543  const processor_id_type elem_procid = e->processor_id();
544 
545  if (!e->valid_id())
546  {
547  // We should only be creating new ids past the end of the range
548  // of existing ids
549  libmesh_assert_greater_equal(_next_free_unpartitioned_elem_id,
550  _max_elem_id);
551  libmesh_assert_greater_equal(_next_free_local_elem_id, _max_elem_id);
552 
553  // Use the unpartitioned ids for unpartitioned elems, and
554  // temporarily for ghost elems
556  if (elem_procid == this->processor_id())
557  next_id = &_next_free_local_elem_id;
558  e->set_id (*next_id);
559  }
560 
561  {
562  // Advance next_ids up high enough that each is pointing to an
563  // unused id and any subsequent increments will still point us
564  // to unused ids
565  _max_elem_id = std::max(_max_elem_id,
566  static_cast<dof_id_type>(e->id()+1));
567 
570  ((_max_elem_id-1) / (this->n_processors() + 1) + 1) *
571  (this->n_processors() + 1) + this->n_processors();
574  ((_max_elem_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
575  (this->n_processors() + 1) + this->processor_id();
576 
577 #ifndef NDEBUG
578  // We need a const dofobject_container so we don't inadvertently create
579  // nullptr entries when testing for non-nullptr ones
580  const dofobject_container<Elem> & const_elements = _elements;
581 #endif
583  libmesh_assert(!const_elements[_next_free_local_elem_id]);
584  }
585 
586  // Don't try to overwrite existing elems
587  libmesh_assert (!_elements[e->id()]);
588 
589  _elements[e->id()] = e;
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 }
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:2033
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:812
unique_id_type _next_unique_id
The next available unique id for assigning ids to DOF objects.
Definition: mesh_base.h:1925
uint8_t processor_id_type
processor_id_type n_processors() const
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:493
unsigned char default_mapping_data() const
Returns any default data value used by the master space to physical space mapping.
Definition: mesh_base.h:830
libmesh_assert(ctx)
dofobject_container< Elem > _elements
The elements 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...
Definition: mesh_base.h:2039
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.
processor_id_type processor_id() const
dof_id_type _next_free_local_elem_id
uint8_t dof_id_type
Definition: id_types.h:67

◆ add_elem() [2/2]

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

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.

References add_elem().

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.

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

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

2319 {
2320  libmesh_assert(!default_values || default_values->size() == names.size());
2321 
2322  std::vector<unsigned int> returnval(names.size());
2323 
2324  const std::size_t old_size = _elem_integer_names.size();
2325 
2326  for (auto i : index_range(names))
2327  returnval[i] =
2328  this->add_elem_datum<T>(names[i], false,
2329  default_values ?
2330  (*default_values)[i] : nullptr);
2331 
2332  if (allocate_data && old_size != _elem_integer_names.size())
2333  this->size_elem_extra_integers();
2334 
2335  return returnval;
2336 }
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:2033
libmesh_assert(ctx)
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:117
void size_elem_extra_integers()
Size extra-integer arrays of all elements in the mesh.
Definition: mesh_base.C:1940

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

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

Referenced by ExtraIntegersTest::build_mesh().

2295 {
2296  const std::size_t old_size = _elem_integer_names.size();
2297 
2298  unsigned int n_more_integers = (sizeof(T)-1)/sizeof(dof_id_type);
2299  std::vector<dof_id_type> int_data(n_more_integers+1, DofObject::invalid_id);
2300  if (default_value)
2301  std::memcpy(int_data.data(), default_value, sizeof(T));
2302 
2303  unsigned int start_idx = this->add_elem_integer(name, false, int_data[0]);
2304  for (unsigned int i=0; i != n_more_integers; ++i)
2305  this->add_elem_integer(name+"__"+std::to_string(i), false, int_data[i+1]);
2306 
2307  if (allocate_data && old_size != _elem_integer_names.size())
2308  this->size_elem_extra_integers();
2309 
2310  return start_idx;
2311 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
std::vector< std::string > _elem_integer_names
The array of names for integer data associated with each element in the mesh.
Definition: mesh_base.h:2033
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:560
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:482
void size_elem_extra_integers()
Size extra-integer arrays of all elements in the mesh.
Definition: mesh_base.C:1940
uint8_t dof_id_type
Definition: id_types.h:67

◆ add_elem_integer()

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

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

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

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

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

Definition at line 560 of file mesh_base.C.

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

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

563 {
564  for (auto i : index_range(_elem_integer_names))
565  if (_elem_integer_names[i] == name)
566  {
567  libmesh_assert_less(i, _elem_integer_default_values.size());
568  _elem_integer_default_values[i] = default_value;
569  return i;
570  }
571 
572  libmesh_assert_equal_to(_elem_integer_names.size(),
574  _elem_integer_names.push_back(std::move(name));
575  _elem_integer_default_values.push_back(default_value);
576  if (allocate_data)
577  this->size_elem_extra_integers();
578  return _elem_integer_names.size()-1;
579 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
std::vector< std::string > _elem_integer_names
The array of names for integer data associated with each element in the mesh.
Definition: mesh_base.h:2033
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:2039
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:117
void size_elem_extra_integers()
Size extra-integer arrays of all elements in the mesh.
Definition: mesh_base.C:1940

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

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

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

586 {
587  libmesh_assert(!default_values || default_values->size() == names.size());
588  libmesh_assert_equal_to(_elem_integer_names.size(), _elem_integer_default_values.size());
589 
590  std::unordered_map<std::string, std::size_t> name_indices;
591  for (auto i : index_range(_elem_integer_names))
592  name_indices[_elem_integer_names[i]] = i;
593 
594  std::vector<unsigned int> returnval(names.size());
595 
596  bool added_an_integer = false;
597  for (auto i : index_range(names))
598  {
599  const std::string & name = names[i];
600  if (const auto it = name_indices.find(name);
601  it != name_indices.end())
602  {
603  returnval[i] = it->second;
604  _elem_integer_default_values[it->second] =
605  default_values ? (*default_values)[i] : DofObject::invalid_id;
606  }
607  else
608  {
609  returnval[i] = _elem_integer_names.size();
610  name_indices[name] = returnval[i];
611  _elem_integer_names.push_back(name);
613  (default_values ? (*default_values)[i] : DofObject::invalid_id);
614  added_an_integer = true;
615  }
616  }
617 
618  if (allocate_data && added_an_integer)
619  this->size_elem_extra_integers();
620 
621  return returnval;
622 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
std::vector< std::string > _elem_integer_names
The array of names for integer data associated with each element in the mesh.
Definition: mesh_base.h:2033
libmesh_assert(ctx)
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:482
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:2039
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:117
void size_elem_extra_integers()
Size extra-integer arrays of all elements in the mesh.
Definition: mesh_base.C:1940

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

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

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

399 {
400  // Populate inverse map, stealing id_set's resources
401  auto [it1, inserted1] = _elemset_codes_inverse_map.emplace(std::move(id_set), code);
402 
403  // Reference to the newly inserted (or previously existing) id_set
404  const auto & inserted_id_set = it1->first;
405 
406  // Keep track of all elemset ids ever added for O(1) n_elemsets()
407  // performance. Only need to do this if we didn't know about this
408  // id_set before...
409  if (inserted1)
410  _all_elemset_ids.insert(inserted_id_set.begin(), inserted_id_set.end());
411 
412  // Take the address of the newly emplaced set to use in
413  // _elemset_codes, avoid duplicating std::set storage
414  auto [it2, inserted2] = _elemset_codes.emplace(code, &inserted_id_set);
415 
416  // Throw an error if this code already exists with a pointer to a
417  // different set of ids.
418  libmesh_error_msg_if(!inserted2 && it2->second != &inserted_id_set,
419  "The elemset code " << code << " already exists with a different id_set.");
420 }
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:2019
std::map< MeshBase::elemset_type, dof_id_type > _elemset_codes_inverse_map
Definition: mesh_base.h:2020
MeshBase::elemset_type _all_elemset_ids
Definition: mesh_base.h:2021

◆ add_extra_ghost_elem()

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

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 1798 of file distributed_mesh.C.

References _extra_ghost_elems, and add_elem().

1799 {
1800  // First add the elem like normal
1801  add_elem(e);
1802 
1803  // Now add it to the set that won't be deleted when we call
1804  // delete_remote_elements()
1805  _extra_ghost_elems.insert(e);
1806 }
virtual Elem * add_elem(Elem *e) override final
Add elem e to the end of the element array.
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...

◆ add_ghosting_functor() [1/2]

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

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

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

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

Definition at line 1267 of file mesh_base.h.

References libMesh::MeshBase::_ghosting_functors.

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

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

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

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

1279  { _shared_functors[ghosting_functor.get()] = ghosting_functor;
1280  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:2092
void add_ghosting_functor(GhostingFunctor &ghosting_functor)
Adds a functor which can specify ghosting requirements for use on distributed meshes.
Definition: mesh_base.h:1267

◆ add_node() [1/2]

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

Add Node n to the end of the vertex array.

Implements libMesh::MeshBase.

Definition at line 803 of file distributed_mesh.C.

References _max_node_id, _n_nodes, _next_free_local_node_id, _next_free_unpartitioned_node_id, libMesh::MeshBase::_next_unique_id, _next_unpartitioned_unique_id, libMesh::MeshBase::_node_integer_default_values, libMesh::MeshBase::_node_integer_names, _nodes, libMesh::DofObject::add_extra_integers(), libMesh::DofObject::id(), libMesh::DofObject::invalid_processor_id, libMesh::libmesh_assert(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::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 add_node(), add_point(), insert_node(), and own_node().

804 {
805  // Don't try to add nullptrs!
806  libmesh_assert(n);
807 
808  // Trying to add an existing node is a no-op
809  if (n->valid_id() && _nodes[n->id()] == n)
810  return n;
811 
812  const processor_id_type node_procid = n->processor_id();
813 
814  if (!n->valid_id())
815  {
816  // We should only be creating new ids past the end of the range
817  // of existing ids
818  libmesh_assert_greater_equal(_next_free_unpartitioned_node_id,
819  _max_node_id);
820  libmesh_assert_greater_equal(_next_free_local_node_id, _max_node_id);
821 
822  // Use the unpartitioned ids for unpartitioned nodes,
823  // and temporarily for ghost nodes
825  if (node_procid == this->processor_id())
826  next_id = &_next_free_local_node_id;
827  n->set_id (*next_id);
828  }
829 
830  {
831  // Advance next_ids up high enough that each is pointing to an
832  // unused id and any subsequent increments will still point us
833  // to unused ids
834  _max_node_id = std::max(_max_node_id,
835  static_cast<dof_id_type>(n->id()+1));
836 
839  ((_max_node_id-1) / (this->n_processors() + 1) + 1) *
840  (this->n_processors() + 1) + this->n_processors();
843  ((_max_node_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
844  (this->n_processors() + 1) + this->processor_id();
845 
846 #ifndef NDEBUG
847  // We need a const dofobject_container so we don't inadvertently create
848  // nullptr entries when testing for non-nullptr ones
849  const dofobject_container<Node> & const_nodes = _nodes;
850 #endif
853  }
854 
855  // Don't try to overwrite existing nodes
856  libmesh_assert (!_nodes[n->id()]);
857 
858  _nodes[n->id()] = n;
859 
860  // Try to make the cached node data more accurate
861  if (node_procid == this->processor_id() ||
862  node_procid == DofObject::invalid_processor_id)
863  _n_nodes++;
864 
865 #ifdef LIBMESH_ENABLE_UNIQUE_ID
866  if (!n->valid_unique_id())
867  {
868  if (processor_id() == n->processor_id())
869  {
870  n->set_unique_id(_next_unique_id);
871  _next_unique_id += this->n_processors() + 1;
872  }
873  else
874  {
875  n->set_unique_id(_next_unpartitioned_unique_id);
877  }
878  }
879  else
880  {
881  _next_unique_id = std::max(_next_unique_id, n->unique_id()+1);
883  ((_next_unique_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
884  (this->n_processors() + 1) + this->processor_id();
885  }
886 #endif
887 
888  n->add_extra_integers(_node_integer_names.size(),
890 
891  // Unpartitioned nodes should be added on every processor
892  // And shouldn't be added in the same batch as ghost nodes
893  // But we might be just adding on processor 0 to
894  // broadcast later
895  // #ifdef DEBUG
896  // if (node_procid == DofObject::invalid_processor_id)
897  // {
898  // dof_id_type node_id = n->id();
899  // this->comm().max(node_id);
900  // libmesh_assert_equal_to (node_id, n->id());
901  // }
902  // #endif
903 
904  return n;
905 }
dof_id_type _n_nodes
Cached data from the last renumber_nodes_and_elements call.
dof_id_type _next_free_local_node_id
Guaranteed globally unused IDs for use when adding new nodes or elements.
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:2045
unique_id_type _next_unique_id
The next available unique id for assigning ids to DOF objects.
Definition: mesh_base.h:1925
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.
uint8_t processor_id_type
processor_id_type n_processors() const
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:493
libmesh_assert(ctx)
dof_id_type _next_free_unpartitioned_node_id
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:2051
unique_id_type _next_unpartitioned_unique_id
The next available unique id for assigning ids to unpartitioned DOF objects.
processor_id_type processor_id() const
uint8_t dof_id_type
Definition: id_types.h:67

◆ add_node() [2/2]

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

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 907 of file distributed_mesh.C.

References add_node().

908 {
909  // The mesh now takes ownership of the Node. Eventually the guts of
910  // add_node() will get moved to a private helper function, and
911  // calling add_node() directly will be deprecated.
912  return add_node(n.release());
913 }
virtual Node * add_node(Node *n) override final
Add Node n to the end of the vertex array.

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

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

2368 {
2369  libmesh_assert(!default_values || default_values->size() == names.size());
2370 
2371  std::vector<unsigned int> returnval(names.size());
2372 
2373  const std::size_t old_size = _node_integer_names.size();
2374 
2375  for (auto i : index_range(names))
2376  returnval[i] =
2377  this->add_node_datum<T>(names[i], false,
2378  default_values ?
2379  (*default_values)[i] : nullptr);
2380 
2381  if (allocate_data && old_size != _node_integer_names.size())
2382  this->size_node_extra_integers();
2383 
2384  return returnval;
2385 }
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:2045
libmesh_assert(ctx)
void size_node_extra_integers()
Size extra-integer arrays of all nodes in the mesh.
Definition: mesh_base.C:1949
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:117

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

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

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

2344 {
2345  const std::size_t old_size = _node_integer_names.size();
2346 
2347  unsigned int n_more_integers = (sizeof(T)-1)/sizeof(dof_id_type);
2348  std::vector<dof_id_type> int_data(n_more_integers+1, DofObject::invalid_id);
2349  if (default_value)
2350  std::memcpy(int_data.data(), default_value, sizeof(T));
2351 
2352  unsigned int start_idx = this->add_node_integer(name, false, int_data[0]);
2353  for (unsigned int i=0; i != n_more_integers; ++i)
2354  this->add_node_integer(name+"__"+std::to_string(i), false, int_data[i+1]);
2355 
2356  if (allocate_data && old_size != _node_integer_names.size())
2357  this->size_node_extra_integers();
2358 
2359  return start_idx;
2360 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
std::vector< std::string > _node_integer_names
The array of names for integer data associated with each node in the mesh.
Definition: mesh_base.h:2045
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:482
void size_node_extra_integers()
Size extra-integer arrays of all nodes in the mesh.
Definition: mesh_base.C:1949
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:649
uint8_t dof_id_type
Definition: id_types.h:67

◆ add_node_integer()

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

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

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

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

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

Definition at line 649 of file mesh_base.C.

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

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

652 {
653  for (auto i : index_range(_node_integer_names))
654  if (_node_integer_names[i] == name)
655  {
656  libmesh_assert_less(i, _node_integer_default_values.size());
657  _node_integer_default_values[i] = default_value;
658  return i;
659  }
660 
661  libmesh_assert_equal_to(_node_integer_names.size(),
663  _node_integer_names.push_back(std::move(name));
664  _node_integer_default_values.push_back(default_value);
665  if (allocate_data)
666  this->size_node_extra_integers();
667  return _node_integer_names.size()-1;
668 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
std::vector< std::string > _node_integer_names
The array of names for integer data associated with each node in the mesh.
Definition: mesh_base.h:2045
void size_node_extra_integers()
Size extra-integer arrays of all nodes in the mesh.
Definition: mesh_base.C:1949
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:2051
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:117

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

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

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

675 {
676  libmesh_assert(!default_values || default_values->size() == names.size());
677  libmesh_assert_equal_to(_node_integer_names.size(), _node_integer_default_values.size());
678 
679  std::unordered_map<std::string, std::size_t> name_indices;
680  for (auto i : index_range(_node_integer_names))
681  name_indices[_node_integer_names[i]] = i;
682 
683  std::vector<unsigned int> returnval(names.size());
684 
685  bool added_an_integer = false;
686  for (auto i : index_range(names))
687  {
688  const std::string & name = names[i];
689  if (const auto it = name_indices.find(name);
690  it != name_indices.end())
691  {
692  returnval[i] = it->second;
693  _node_integer_default_values[it->second] =
694  default_values ? (*default_values)[i] : DofObject::invalid_id;
695  }
696  else
697  {
698  returnval[i] = _node_integer_names.size();
699  name_indices[name] = returnval[i];
700  _node_integer_names.push_back(name);
702  (default_values ? (*default_values)[i] : DofObject::invalid_id);
703  added_an_integer = true;
704  }
705  }
706 
707  if (allocate_data && added_an_integer)
708  this->size_node_extra_integers();
709 
710  return returnval;
711 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
std::vector< std::string > _node_integer_names
The array of names for integer data associated with each node in the mesh.
Definition: mesh_base.h:2045
libmesh_assert(ctx)
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:482
void size_node_extra_integers()
Size extra-integer arrays of all nodes in the mesh.
Definition: mesh_base.C:1949
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:2051
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:117

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

functions for adding /deleting nodes elements.

Implements libMesh::MeshBase.

Definition at line 767 of file distributed_mesh.C.

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

770 {
771  Node * old_n = this->query_node_ptr(id);
772 
773  if (old_n)
774  {
775  *old_n = p;
776  old_n->processor_id() = proc_id;
777 
778  return old_n;
779  }
780 
781  Node * n = Node::build(p, id).release();
782  n->processor_id() = proc_id;
783 
784  return DistributedMesh::add_node(n);
785 }
virtual Node * add_node(Node *n) override final
Add Node n to the end of the vertex array.
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

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

References libMesh::MeshBase::all_complete_order_range().

Referenced by AllSecondOrderTest::allCompleteOrder(), libMesh::TriangulatorInterface::increase_triangle_order(), and main().

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

◆ all_complete_order_range()

void libMesh::UnstructuredMesh::all_complete_order_range ( const SimpleRange< element_iterator > &  range)
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 1660 of file unstructured_mesh.C.

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

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

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

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

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

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

References libMesh::MeshBase::all_second_order_range().

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

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

◆ all_second_order_range()

void libMesh::UnstructuredMesh::all_second_order_range ( const SimpleRange< element_iterator > &  range,
const bool  full_ordered = true 
)
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 1592 of file unstructured_mesh.C.

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

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

◆ allgather()

void libMesh::DistributedMesh::allgather ( )
overridevirtual

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

Reimplemented from libMesh::MeshBase.

Definition at line 1818 of file distributed_mesh.C.

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

1819 {
1820  if (_is_serial)
1821  return;
1822  MeshCommunication().allgather(*this);
1823  _is_serial = true;
1824  _is_serial_on_proc_0 = true;
1825 
1826  // Make sure our caches are up to date and our
1827  // DofObjects are well packed
1828 #ifdef DEBUG
1829  libmesh_assert_equal_to (this->n_nodes(), this->parallel_n_nodes());
1830  libmesh_assert_equal_to (this->n_elem(), this->parallel_n_elem());
1831  const dof_id_type pmax_node_id = this->parallel_max_node_id();
1832  const dof_id_type pmax_elem_id = this->parallel_max_elem_id();
1833  libmesh_assert_equal_to (this->max_node_id(), pmax_node_id);
1834  libmesh_assert_equal_to (this->max_elem_id(), pmax_elem_id);
1835 
1836  // If we've disabled renumbering we can't be sure we're contiguous
1837  // libmesh_assert_equal_to (this->n_nodes(), this->max_node_id());
1838  // libmesh_assert_equal_to (this->n_elem(), this->max_elem_id());
1839 
1840  // Make sure our neighbor links are all fine
1842 
1843  // Make sure our ids and flags are consistent
1846 #endif
1847 }
virtual dof_id_type parallel_n_nodes() const override
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&#39;re serialized to proc 0 or not.
virtual dof_id_type n_nodes() const override final
bool _is_serial
A boolean remembering whether we&#39;re serialized or not.
void libmesh_assert_valid_parallel_flags() const
Verify refinement_flag and p_refinement_flag consistency of our elements containers.
friend class MeshCommunication
Make the MeshCommunication class a friend so that it can directly broadcast *_integer_names.
Definition: mesh_base.h:2134
virtual dof_id_type parallel_n_elem() const override
dof_id_type parallel_max_node_id() const
virtual dof_id_type max_node_id() const override final
virtual dof_id_type n_elem() const override final
void libmesh_assert_valid_neighbors(const MeshBase &mesh, bool assert_valid_remote_elems=true)
A function for verifying that neighbor connectivity is correct (each element is a neighbor of or desc...
Definition: mesh_tools.C:2205
virtual dof_id_type max_elem_id() const override final
dof_id_type parallel_max_elem_id() const
uint8_t dof_id_type
Definition: id_types.h:67

◆ allow_find_neighbors() [1/2]

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

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

Definition at line 1203 of file mesh_base.h.

References libMesh::MeshBase::_skip_find_neighbors.

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

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

◆ allow_find_neighbors() [2/2]

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

◆ allow_remote_element_removal() [1/2]

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

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

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

Definition at line 1212 of file mesh_base.h.

References libMesh::MeshBase::_allow_remote_element_removal.

Referenced by AllSecondOrderTest::allCompleteOrder(), AllSecondOrderTest::allCompleteOrderDoNothing(), AllSecondOrderTest::allSecondOrder(), AllSecondOrderTest::allSecondOrderDoNothing(), DistributedMesh(), libMesh::MeshSerializer::MeshSerializer(), libMesh::ReplicatedMesh::ReplicatedMesh(), ConnectedComponentsTest::testEdge(), PeriodicBCTest::testPeriodicBC(), and libMesh::MeshSerializer::~MeshSerializer().

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

◆ allow_remote_element_removal() [2/2]

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

Definition at line 1213 of file mesh_base.h.

References libMesh::MeshBase::_allow_remote_element_removal.

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

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

◆ allow_renumbering() [1/2]

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

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

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

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

Definition at line 1196 of file mesh_base.h.

References libMesh::MeshBase::_skip_renumber_nodes_and_elements.

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

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

◆ allow_renumbering() [2/2]

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

◆ assign()

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

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 }

◆ cache_elem_data()

void libMesh::MeshBase::cache_elem_data ( )
inherited

Definition at line 1733 of file mesh_base.C.

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

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

1734 {
1735  // This requires an inspection on every processor
1736  parallel_object_only();
1737 
1738  // Need to clear containers first in case all elements of a
1739  // particular dimension/order/subdomain have been deleted.
1740  _elem_dims.clear();
1741  _elem_default_orders.clear();
1742  _mesh_subdomains.clear();
1744 
1745  for (const auto & elem : this->active_element_ptr_range())
1746  {
1747  _elem_dims.insert(cast_int<unsigned char>(elem->dim()));
1748  _elem_default_orders.insert(elem->default_order());
1749  _mesh_subdomains.insert(elem->subdomain_id());
1751  static_cast<Order>
1752  (std::min(static_cast<int>(_supported_nodal_order),
1753  static_cast<int>(elem->supported_nodal_order())));
1754  }
1755 
1756  if (!this->is_serial())
1757  {
1758  // Some different dimension/order/subdomain elements may only live
1759  // on other processors
1760  this->comm().set_union(_elem_dims);
1762  this->comm().min(_supported_nodal_order);
1763  this->comm().set_union(_mesh_subdomains);
1764  }
1765 
1766  // If the largest element dimension found is larger than the current
1767  // _spatial_dimension, increase _spatial_dimension.
1768  unsigned int max_dim = this->mesh_dimension();
1769  if (max_dim > _spatial_dimension)
1770  _spatial_dimension = cast_int<unsigned char>(max_dim);
1771 
1772  // _spatial_dimension may need to increase from 1->2 or 2->3 if the
1773  // mesh is full of 1D elements but they are not x-aligned, or the
1774  // mesh is full of 2D elements but they are not in the x-y plane.
1775  // If the mesh is x-aligned or x-y planar, we will end up checking
1776  // every node's coordinates and not breaking out of the loop
1777  // early...
1778  if (_spatial_dimension < LIBMESH_DIM)
1779  {
1780  for (const auto & node : this->node_ptr_range())
1781  {
1782  // Note: the exact floating point comparison is intentional,
1783  // we don't want to get tripped up by tolerances.
1784  if ((*node)(0) != 0. && _spatial_dimension < 1)
1785  _spatial_dimension = 1;
1786 
1787  if ((*node)(1) != 0. && _spatial_dimension < 2)
1788  {
1789  _spatial_dimension = 2;
1790 #if LIBMESH_DIM == 2
1791  // If libmesh is compiled in 2D mode, this is the
1792  // largest spatial dimension possible so we can break
1793  // out.
1794  break;
1795 #endif
1796  }
1797 
1798 #if LIBMESH_DIM > 2
1799  if ((*node)(2) != 0.)
1800  {
1801  // Spatial dimension can't get any higher than this, so
1802  // we can break out.
1803  _spatial_dimension = 3;
1804  break;
1805  }
1806 #endif
1807  }
1808  }
1809 }
std::set< subdomain_id_type > _mesh_subdomains
We cache the subdomain ids of the elements present in the mesh.
Definition: mesh_base.h:1995
Order
defines an enum for polynomial orders.
Definition: enum_order.h:40
const Parallel::Communicator & comm() const
unsigned char _spatial_dimension
The "spatial dimension" of the Mesh.
Definition: mesh_base.h:2027
virtual bool is_serial() const
Definition: mesh_base.h:211
void min(const T &r, T &o, Request &req) const
std::set< Order > _elem_default_orders
We cache the (default) order of the geometric elements present in the mesh.
Definition: mesh_base.h:1984
Order _supported_nodal_order
We cache the maximum nodal order supported by all the mesh&#39;s elements (the minimum supported_nodal_or...
Definition: mesh_base.h:1990
std::set< unsigned char > _elem_dims
We cache the dimension of the elements present in the mesh.
Definition: mesh_base.h:1977
unsigned int mesh_dimension() const
Definition: mesh_base.C:372
void set_union(T &data, const unsigned int root_id) const

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

References libMesh::MeshBase::cache_elem_data().

1726 {
1727  libmesh_deprecated();
1728 
1729  this->cache_elem_data();
1730 }
void cache_elem_data()
Definition: mesh_base.C:1733

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

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

455 {
456  // Look up elemset ids for old_code
457  auto it = _elemset_codes.find(old_code);
458 
459  // If we don't have the old_code, then do nothing. Alternatively, we
460  // could throw an error since trying to change an elemset code you
461  // don't have could indicate there's a problem...
462  if (it == _elemset_codes.end())
463  return;
464 
465  // Make copy of the set of elemset ids. We are not changing these,
466  // only updating the elemset code it corresponds to.
467  elemset_type id_set_copy = *(it->second);
468 
469  // Look up the corresponding entry in the inverse map. Note: we want
470  // the iterator because we are going to remove it.
471  auto inverse_it = _elemset_codes_inverse_map.find(id_set_copy);
472  libmesh_error_msg_if(inverse_it == _elemset_codes_inverse_map.end(),
473  "Expected _elemset_codes_inverse_map entry for elemset code " << old_code);
474 
475  // Erase entry from inverse map
476  _elemset_codes_inverse_map.erase(inverse_it);
477 
478  // Erase entry from forward map
479  _elemset_codes.erase(it);
480 
481  // Add new code with original set of ids.
482  this->add_elemset_code(new_code, id_set_copy);
483 
484  // We can't update any actual elemset codes if there is no extra integer defined for it.
485  if (!this->has_elem_integer("elemset_code"))
486  return;
487 
488  // Get index of elemset_code extra integer
489  unsigned int elemset_index = this->get_elem_integer_index("elemset_code");
490 
491  // Loop over all elems and update code
492  for (auto & elem : this->element_ptr_range())
493  {
494  dof_id_type elemset_code =
495  elem->get_extra_integer(elemset_index);
496 
497  if (elemset_code == old_code)
498  elem->set_extra_integer(elemset_index, new_code);
499  }
500 }
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:2019
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:398
bool has_elem_integer(std::string_view name) const
Definition: mesh_base.C:638
std::map< MeshBase::elemset_type, dof_id_type > _elemset_codes_inverse_map
Definition: mesh_base.h:2020
unsigned int get_elem_integer_index(std::string_view name) const
Definition: mesh_base.C:626
std::set< elemset_id_type > elemset_type
Typedef for the "set" container used to store elemset ids.
Definition: mesh_base.h:318
uint8_t dof_id_type
Definition: id_types.h:67

◆ change_elemset_id()

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

Replace elemset id "old_id" with "new_id".

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

Definition at line 502 of file mesh_base.C.

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

503 {
504  // Early return if we don't have old_id
505  if (!_all_elemset_ids.count(old_id))
506  return;
507 
508  // Throw an error if the new_id is already used
509  libmesh_error_msg_if(_all_elemset_ids.count(new_id),
510  "Cannot change elemset id " << old_id <<
511  " to " << new_id << ", " << new_id << " already exists.");
512 
513  // We will build up a new version of the inverse map so we can iterate over
514  // the current one without invalidating anything.
515  std::map<MeshBase::elemset_type, dof_id_type> new_elemset_codes_inverse_map;
516  for (const auto & [id_set, elemset_code] : _elemset_codes_inverse_map)
517  {
518  auto id_set_copy = id_set;
519  if (id_set_copy.count(old_id))
520  {
521  // Remove old_id, insert new_id
522  id_set_copy.erase(old_id);
523  id_set_copy.insert(new_id);
524  }
525 
526  // Store in new version of map
527  new_elemset_codes_inverse_map.emplace(id_set_copy, elemset_code);
528  }
529 
530  // Swap existing map with newly-built one
531  _elemset_codes_inverse_map.swap(new_elemset_codes_inverse_map);
532 
533  // Reconstruct _elemset_codes map
534  _elemset_codes.clear();
535  for (const auto & [id_set, elemset_code] : _elemset_codes_inverse_map)
536  _elemset_codes.emplace(elemset_code, &id_set);
537 
538  // Update _all_elemset_ids
539  _all_elemset_ids.erase(old_id);
540  _all_elemset_ids.insert(new_id);
541 }
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:2019
std::map< MeshBase::elemset_type, dof_id_type > _elemset_codes_inverse_map
Definition: mesh_base.h:2020
MeshBase::elemset_type _all_elemset_ids
Definition: mesh_base.h:2021

◆ clear()

void libMesh::DistributedMesh::clear ( )
overridevirtual

Clear all internal data.

Reimplemented from libMesh::MeshBase.

Definition at line 997 of file distributed_mesh.C.

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

Referenced by ~DistributedMesh().

998 {
999  // Call parent clear function
1000  MeshBase::clear();
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.
1019  _deleted_coarse_elements = false;
1020 
1021  // Correct our caches
1022  _n_nodes = 0;
1023  _max_node_id = 0;
1026 }
bool _is_serial_on_proc_0
A boolean remembering whether we&#39;re serialized to proc 0 or not.
dof_id_type _n_nodes
Cached data from the last renumber_nodes_and_elements call.
dof_id_type _next_free_local_node_id
Guaranteed globally unused IDs for use when adding new nodes or elements.
bool _is_serial
A boolean remembering whether we&#39;re serialized 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:901
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.
processor_id_type n_processors() const
virtual void clear_elems() override
Clear internal Elem data.
virtual void clear()
Deletes all the element and node data that is currently stored.
Definition: mesh_base.C:920
dof_id_type _next_free_unpartitioned_node_id
processor_id_type processor_id() const
bool _deleted_coarse_elements
A boolean remembering whether we&#39;ve recently deleted top-level elements or not.

◆ clear_elems()

void libMesh::DistributedMesh::clear_elems ( )
overridevirtual

Clear internal Elem data.

Implements libMesh::MeshBase.

Definition at line 1030 of file distributed_mesh.C.

References _elements, _max_elem_id, _n_elem, _next_free_local_elem_id, _next_free_unpartitioned_elem_id, libMesh::ParallelObject::n_processors(), and libMesh::ParallelObject::processor_id().

Referenced by clear().

1031 {
1032  for (auto & elem : _elements)
1033  delete elem;
1034 
1035  _elements.clear();
1036 
1037  // Correct our caches
1038  _n_elem = 0;
1039  _max_elem_id = 0;
1042 }
processor_id_type n_processors() const
dofobject_container< Elem > _elements
The elements in the mesh.
dof_id_type _next_free_unpartitioned_elem_id
processor_id_type processor_id() const
dof_id_type _next_free_local_elem_id

◆ clear_extra_ghost_elems() [1/2]

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

Clears extra ghost elements.

Definition at line 257 of file distributed_mesh.h.

References _extra_ghost_elems.

257 { _extra_ghost_elems.clear(); }
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...

◆ clear_extra_ghost_elems() [2/2]

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

Clears specified extra ghost elements.

Definition at line 1809 of file distributed_mesh.C.

References _extra_ghost_elems, and extra_ghost_elems().

1810 {
1811  std::set<Elem *> tmp;
1812  std::set_difference(_extra_ghost_elems.begin(), _extra_ghost_elems.end(),
1813  extra_ghost_elems.begin(), extra_ghost_elems.end(),
1814  std::inserter(tmp, tmp.begin()));
1815  _extra_ghost_elems = tmp;
1816 }
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...
const std::set< Elem * > & extra_ghost_elems() const
Const accessor to the ghosted elements.

◆ clear_point_locator()

void libMesh::MeshBase::clear_point_locator ( )
inherited

Releases the current PointLocator object.

Definition at line 1671 of file mesh_base.C.

References libMesh::MeshBase::_point_locator.

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

1672 {
1673  _point_locator.reset(nullptr);
1674 }
std::unique_ptr< PointLocatorBase > _point_locator
A PointLocator class for this mesh.
Definition: mesh_base.h:1905

◆ clone()

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

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.

References libMesh::libmesh_assert().

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

◆ comm()

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

Definition at line 97 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_tao_equality_constraints(), libMesh::__libmesh_tao_equality_constraints_jacobian(), libMesh::__libmesh_tao_gradient(), libMesh::__libmesh_tao_hessian(), libMesh::__libmesh_tao_inequality_constraints(), libMesh::__libmesh_tao_inequality_constraints_jacobian(), libMesh::__libmesh_tao_objective(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::Partitioner::_find_global_index_by_pid_map(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< libMesh::Number >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_mult(), libMesh::SlepcEigenSolver< libMesh::Number >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_mult_add(), libMesh::MeshRefinement::_refine_elements(), libMesh::MeshRefinement::_smooth_flags(), libMesh::DofMap::add_constraints_to_send_list(), add_cube_convex_hull_to_mesh(), libMesh::PetscDMWrapper::add_dofs_helper(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::RBEIMEvaluation::add_interpolation_data(), libMesh::CondensedEigenSystem::add_matrices(), libMesh::EigenSystem::add_matrices(), libMesh::System::add_matrix(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::System::add_variable(), libMesh::System::add_variables(), libMesh::System::add_vector(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::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::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_section(), libMesh::PetscDMWrapper::build_sf(), libMesh::MeshBase::cache_elem_data(), libMesh::System::calculate_norm(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::RBSCMConstruction::compute_SCM_bounds_on_training_set(), libMesh::DofMap::computed_sparsity_already(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ContinuationSystem::ContinuationSystem(), libMesh::MeshBase::copy_constraint_rows(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::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::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::PatchRecoveryErrorEstimator::estimate_error(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_error_tolerance(), libMesh::MeshRefinement::flag_elements_by_mean_stddev(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::DofMap::gather_constraints(), libMesh::MeshfreeInterpolation::gather_remote_data(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::RBEIMEvaluation::get_eim_basis_function_node_value(), libMesh::RBEIMEvaluation::get_eim_basis_function_side_value(), libMesh::RBEIMEvaluation::get_eim_basis_function_value(), libMesh::MeshBase::get_info(), libMesh::System::get_info(), libMesh::DofMap::get_info(), libMesh::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(), AssembleOptimization::inequality_constraints(), AssembleOptimization::inequality_constraints_jacobian(), libMesh::LocationMap< T >::init(), libMesh::TimeSolver::init(), libMesh::StaticCondensation::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), 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::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_assert_valid_parallel_flags(), libmesh_assert_valid_parallel_object_ids(), libmesh_assert_valid_parallel_p_levels(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshTools::libmesh_assert_valid_unique_ids(), libMesh::libmesh_petsc_linesearch_shellfunc(), libMesh::libmesh_petsc_preconditioner_apply(), libMesh::libmesh_petsc_recalculate_monitor(), libMesh::libmesh_petsc_snes_fd_residual(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_mffd_interface(), libMesh::libmesh_petsc_snes_mffd_residual(), libMesh::libmesh_petsc_snes_postcheck(), libMesh::libmesh_petsc_snes_precheck(), libMesh::libmesh_petsc_snes_residual(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::limit_overrefined_boundary(), libMesh::MeshRefinement::limit_underrefined_boundary(), libMesh::LinearImplicitSystem::LinearImplicitSystem(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshRefinement::make_flags_parallel_consistent(), libMesh::MeshCommunication::make_new_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_new_nodes_parallel_consistent(), libMesh::MeshCommunication::make_node_bcids_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_unique_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshCommunication::make_p_levels_parallel_consistent(), libMesh::MeshRefinement::make_refinement_compatible(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), libMesh::FEMSystem::mesh_position_set(), libMesh::TriangulatorInterface::MeshedHole::MeshedHole(), LinearElasticityWithContact::move_mesh(), 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::MeshBase::operator==(), parallel_max_elem_id(), parallel_max_node_id(), libMesh::ReplicatedMesh::parallel_max_unique_id(), parallel_max_unique_id(), parallel_n_elem(), parallel_n_nodes(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::BoundaryInfo::parallel_sync_node_ids(), libMesh::BoundaryInfo::parallel_sync_side_ids(), libMesh::MeshTools::paranoid_n_levels(), libMesh::Partitioner::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::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(), FEMParameters::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::EquationSystems::read(), libMesh::ExodusII_IO::read_header(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), libMesh::RBEIMEvaluation::read_in_interior_basis_functions(), libMesh::RBEIMEvaluation::read_in_node_basis_functions(), libMesh::RBEIMEvaluation::read_in_side_basis_functions(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::System::read_legacy_data(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::Nemesis_IO_Helper::read_var_names_impl(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::SimplexRefiner::refine_via_edges(), libMesh::StaticCondensationDofMap::reinit(), renumber_dof_objects(), 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::ClawSystem::solve_conservation_law(), libMesh::split_mesh(), libMesh::RBEIMConstruction::store_eim_solutions_for_training_set(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), ConstraintOperatorTest::test1DCoarseningNewNodes(), ConstraintOperatorTest::test1DCoarseningOperator(), libMesh::MeshRefinement::test_level_one(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), libMesh::MeshRefinement::test_unflagged(), DofMapTest::testBadElemFECombo(), SystemsTest::testBlockRestrictedVarNDofs(), BoundaryInfoTest::testBoundaryOnChildrenErrors(), VolumeTest::testC0PolygonMethods(), VolumeTest::testC0PolyhedronMethods(), ConstraintOperatorTest::testCoreform(), ConnectedComponentsTest::testEdge(), MeshInputTest::testExodusIGASidesets(), MeshTriangulationTest::testFoundCenters(), PointLocatorTest::testLocator(), BoundaryInfoTest::testMesh(), PointLocatorTest::testPlanar(), MeshTriangulationTest::testPoly2TriRefinementBase(), SystemsTest::testProjectCubeWithMeshFunction(), BoundaryInfoTest::testRenumber(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), MeshTriangulationTest::testTriangulatorInterp(), MeshTriangulationTest::testTriangulatorMeshedHoles(), MeshTriangulationTest::testTriangulatorRoundHole(), libMesh::MeshTools::total_weight(), libMesh::RBConstruction::train_reduced_basis_with_POD(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::Poly2TriTriangulator::triangulate(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::MeshRefinement::uniformly_coarsen(), update_current_local_solution(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::MeshTools::volume(), libMesh::STLIO::write(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::VTKIO::write_nodal_data(), libMesh::RBEIMEvaluation::write_out_interior_basis_functions(), libMesh::RBEIMEvaluation::write_out_node_basis_functions(), libMesh::RBEIMEvaluation::write_out_side_basis_functions(), libMesh::RBEvaluation::write_out_vectors(), libMesh::TransientRBConstruction::write_riesz_representors_to_files(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::RBDataSerialization::RBEvaluationSerialization::write_to_file(), libMesh::RBDataSerialization::TransientRBEvaluationSerialization::write_to_file(), libMesh::RBDataSerialization::RBEIMEvaluationSerialization::write_to_file(), and libMesh::RBDataSerialization::RBSCMEvaluationSerialization::write_to_file().

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

◆ contract()

bool libMesh::UnstructuredMesh::contract ( )
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 1395 of file unstructured_mesh.C.

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

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

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

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

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

2005 {
2006  this->_spatial_dimension = other_mesh._spatial_dimension;
2007  this->_elem_dims = other_mesh._elem_dims;
2008  this->_elem_default_orders = other_mesh._elem_default_orders;
2009  this->_supported_nodal_order = other_mesh._supported_nodal_order;
2010  this->_mesh_subdomains = other_mesh._mesh_subdomains;
2011 }
std::set< subdomain_id_type > _mesh_subdomains
We cache the subdomain ids of the elements present in the mesh.
Definition: mesh_base.h:1995
unsigned char _spatial_dimension
The "spatial dimension" of the Mesh.
Definition: mesh_base.h:2027
std::set< Order > _elem_default_orders
We cache the (default) order of the geometric elements present in the mesh.
Definition: mesh_base.h:1984
Order _supported_nodal_order
We cache the maximum nodal order supported by all the mesh&#39;s elements (the minimum supported_nodal_or...
Definition: mesh_base.h:1990
std::set< unsigned char > _elem_dims
We cache the dimension of the elements present in the mesh.
Definition: mesh_base.h:1977

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

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

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

2064 {
2065  LOG_SCOPE("copy_constraint_rows(mesh)", "MeshBase");
2066 
2067  _constraint_rows.clear();
2068 
2069  const auto & other_constraint_rows = other_mesh.get_constraint_rows();
2070  for (const auto & [other_node, other_node_constraints] : other_constraint_rows)
2071  {
2072  const Node * const our_node = this->node_ptr(other_node->id());
2073  constraint_rows_mapped_type our_node_constraints;
2074  for (const auto & [other_inner_key_pair, constraint_value] : other_node_constraints)
2075  {
2076  const auto & [other_elem, local_node_id] = other_inner_key_pair;
2077  const Elem * const our_elem = this->elem_ptr(other_elem->id());
2078  our_node_constraints.emplace_back(std::make_pair(our_elem, local_node_id), constraint_value);
2079  }
2080  _constraint_rows[our_node] = std::move(our_node_constraints);
2081  }
2082 }
std::vector< std::pair< std::pair< const Elem *, unsigned int >, Real > > constraint_rows_mapped_type
Definition: mesh_base.h:1697
constraint_rows_type _constraint_rows
Definition: mesh_base.h:2104
virtual const Elem * elem_ptr(const dof_id_type i) const =0
virtual const Node * node_ptr(const dof_id_type i) const =0

◆ copy_constraint_rows() [2/2]

template<typename T >
void libMesh::MeshBase::copy_constraint_rows ( const SparseMatrix< T > &  constraint_operator,
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 2087 of file mesh_base.C.

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(), TIMPI::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(), TIMPI::Communicator::set_union(), libMesh::MeshBase::subdomain_ids(), libMesh::Elem::supported_nodal_order(), and libMesh::TOLERANCE.

2089 {
2090  LOG_SCOPE("copy_constraint_rows(mat)", "MeshBase");
2091 
2092  this->_constraint_rows.clear();
2093 
2094  // We're not going to support doing this distributed yet; it'd be
2095  // pointless unless we temporarily had a linear partitioning to
2096  // better match the constraint operator.
2097  MeshSerializer serialize(*this);
2098 
2099  // Our current mesh should already reflect the desired assembly space
2100  libmesh_error_msg_if(this->n_nodes() != constraint_operator.m(),
2101  "Constraint operator matrix with " <<
2102  constraint_operator.m() <<
2103  "rows does not match this mesh with " <<
2104  this->n_nodes() << " nodes");
2105 
2106  // First, find what new unconstrained DoFs we need to add. We can't
2107  // iterate over columns in a SparseMatrix, so we'll iterate over
2108  // rows and keep track of columns.
2109 
2110  // If we have nodes that will work unconstrained, keep track of
2111  // their node ids and corresponding column indices.
2112  // existing_unconstrained_nodes[column_id] = node_id
2113  std::map<dof_id_type, dof_id_type> existing_unconstrained_columns;
2114  std::set<dof_id_type> existing_unconstrained_nodes;
2115 
2116  // In case we need new nodes, keep track of their columns.
2117  // columns[j][k] will be the kth row index and value of column j
2118  typedef
2119  std::unordered_map<dof_id_type,
2120  std::vector<std::pair<dof_id_type, Real>>>
2121  columns_type;
2122  columns_type columns(constraint_operator.n());
2123 
2124  // If we need to precondition the constraint operator (e.g. it's an
2125  // unpreconditioned extraction operator for a Flex IGA matrix),
2126  // we'll want to keep track of the sum of each column, because we'll
2127  // be dividing each column by that sum (Jacobi preconditioning on
2128  // the right, which then leads to symmetric preconditioning on a
2129  // physics Jacobian).
2130  std::unordered_map<dof_id_type, Real> column_sums;
2131 
2132  // Work in parallel, though we'll have to sync shortly
2133  for (auto i : make_range(constraint_operator.row_start(),
2134  constraint_operator.row_stop()))
2135  {
2136  std::vector<numeric_index_type> indices;
2137  std::vector<T> values;
2138 
2139  constraint_operator.get_row(i, indices, values);
2140  libmesh_assert_equal_to(indices.size(), values.size());
2141 
2142  if (indices.size() == 1 &&
2143  values[0] == T(1))
2144  {
2145  // If we have multiple simple Ui=Uj constraints, let the
2146  // first one be our "unconstrained" node and let the others
2147  // be constrained to it.
2148  if (existing_unconstrained_columns.find(indices[0]) !=
2149  existing_unconstrained_columns.end())
2150  {
2151  const auto j = indices[0];
2152  columns[j].emplace_back(i, 1);
2153  }
2154  else
2155  {
2156  existing_unconstrained_nodes.insert(i);
2157  existing_unconstrained_columns.emplace(indices[0],i);
2158  }
2159  }
2160  else
2161  for (auto jj : index_range(indices))
2162  {
2163  const auto j = indices[jj];
2164  const Real coef = libmesh_real(values[jj]);
2165  libmesh_assert_equal_to(coef, values[jj]);
2166  columns[j].emplace_back(i, coef);
2167  }
2168  }
2169 
2170  // Merge data from different processors' slabs of the matrix
2171  this->comm().set_union(existing_unconstrained_nodes);
2172  this->comm().set_union(existing_unconstrained_columns);
2173 
2174  std::vector<columns_type> all_columns;
2175  this->comm().allgather(columns, all_columns);
2176 
2177  columns.clear();
2178  for (auto p : index_range(all_columns))
2179  for (auto & [j, subcol] : all_columns[p])
2180  for (auto [i, v] : subcol)
2181  columns[j].emplace_back(i,v);
2182 
2183  // Keep track of elements on which unconstrained nodes exist, and
2184  // their local node indices.
2185  // node_to_elem_ptrs[node] = [elem_id, local_node_num]
2186  std::unordered_map<const Node *, std::pair<dof_id_type, unsigned int>> node_to_elem_ptrs;
2187 
2188  // Find elements attached to any existing nodes that will stay
2189  // unconstrained. We'll also build a subdomain set here so we don't
2190  // have to assert that the mesh is already prepared before we pick a
2191  // new subdomain for any NodeElems we need to add.
2192  std::set<subdomain_id_type> subdomain_ids;
2193  for (const Elem * elem : this->element_ptr_range())
2194  {
2195  subdomain_ids.insert(elem->subdomain_id());
2196  for (auto n : make_range(elem->n_nodes()))
2197  {
2198  const Node * node = elem->node_ptr(n);
2199  if (existing_unconstrained_nodes.count(node->id()))
2200  node_to_elem_ptrs.emplace(node, std::make_pair(elem->id(), n));
2201  }
2202  }
2203 
2204  const subdomain_id_type new_sbd_id = *subdomain_ids.rbegin() + 1;
2205 
2206  for (auto j : make_range(constraint_operator.n()))
2207  {
2208  // If we already have a good node for this then we're done
2209  if (existing_unconstrained_columns.count(j))
2210  continue;
2211 
2212  // Get a half-decent spot to place a new NodeElem for
2213  // unconstrained DoF(s) here. Getting a *fully*-decent spot
2214  // would require finding a Moore-Penrose pseudoinverse, and I'm
2215  // not going to do that, but scaling a transpose will at least
2216  // get us a little uniqueness to make visualization reasonable.
2217  Point newpt;
2218  Real total_scaling = 0;
2219  unsigned int total_entries = 0;
2220 
2221  // We'll get a decent initial pid choice here too, if only to
2222  // aid in later repartitioning.
2223  std::map<processor_id_type, int> pids;
2224 
2225  auto & column = columns[j];
2226  for (auto [i, r] : column)
2227  {
2228  Node & constrained_node = this->node_ref(i);
2229  const Point constrained_pt = constrained_node;
2230  newpt += r*constrained_pt;
2231  total_scaling += r;
2232  ++total_entries;
2233  ++pids[constrained_node.processor_id()];
2234  }
2235 
2236  if (precondition_constraint_operator)
2237  column_sums[j] = total_scaling;
2238 
2239  libmesh_error_msg_if
2240  (!total_entries,
2241  "Empty column " << j <<
2242  " found in constraint operator matrix");
2243 
2244  // If we have *cancellation* here then we can end up dividing by
2245  // zero; try just evenly scaling across all constrained node
2246  // points instead.
2247  if (total_scaling > TOLERANCE)
2248  newpt /= total_scaling;
2249  else
2250  newpt /= total_entries;
2251 
2252  Node *n = this->add_point(newpt);
2253  std::unique_ptr<Elem> elem = Elem::build(NODEELEM);
2254  elem->set_node(0, n);
2255  elem->subdomain_id() = new_sbd_id;
2256 
2257  Elem * added_elem = this->add_elem(std::move(elem));
2258  this->_elem_dims.insert(0);
2259  this->_elem_default_orders.insert(added_elem->default_order());
2260  this->_supported_nodal_order =
2261  static_cast<Order>
2262  (std::min(static_cast<int>(this->_supported_nodal_order),
2263  static_cast<int>(added_elem->supported_nodal_order())));
2264  this->_mesh_subdomains.insert(new_sbd_id);
2265  node_to_elem_ptrs.emplace(n, std::make_pair(added_elem->id(), 0));
2266  existing_unconstrained_columns.emplace(j,n->id());
2267 
2268  // Repartition the new objects *after* adding them, so a
2269  // DistributedMesh doesn't get confused and think you're not
2270  // adding them on all processors at once.
2271  int n_pids = 0;
2272  for (auto [pid, count] : pids)
2273  if (count >= n_pids)
2274  {
2275  n_pids = count;
2276  added_elem->processor_id() = pid;
2277  n->processor_id() = pid;
2278  }
2279  }
2280 
2281  // Calculate constraint rows in an indexed form that's easy for us
2282  // to allgather
2283  std::unordered_map<dof_id_type,
2284  std::vector<std::pair<std::pair<dof_id_type, unsigned int>,Real>>>
2285  indexed_constraint_rows;
2286 
2287  for (auto i : make_range(constraint_operator.row_start(),
2288  constraint_operator.row_stop()))
2289  {
2290  if (existing_unconstrained_nodes.count(i))
2291  continue;
2292 
2293  std::vector<numeric_index_type> indices;
2294  std::vector<T> values;
2295 
2296  constraint_operator.get_row(i, indices, values);
2297 
2298  std::vector<std::pair<std::pair<dof_id_type, unsigned int>, Real>> constraint_row;
2299 
2300  for (auto jj : index_range(indices))
2301  {
2302  const dof_id_type node_id =
2303  existing_unconstrained_columns[indices[jj]];
2304 
2305  Node & constraining_node = this->node_ref(node_id);
2306 
2307  libmesh_assert(node_to_elem_ptrs.count(&constraining_node));
2308 
2309  auto p = node_to_elem_ptrs[&constraining_node];
2310 
2311  Real coef = libmesh_real(values[jj]);
2312  libmesh_assert_equal_to(coef, values[jj]);
2313 
2314  // If we're preconditioning and we created a nodeelem then
2315  // we can scale the meaning of that nodeelem's value to give
2316  // us a better-conditioned matrix after the constraints are
2317  // applied.
2318  if (precondition_constraint_operator)
2319  if (auto sum_it = column_sums.find(indices[jj]);
2320  sum_it != column_sums.end())
2321  {
2322  const Real scaling = sum_it->second;
2323 
2324  if (scaling > TOLERANCE)
2325  coef /= scaling;
2326  }
2327 
2328  constraint_row.emplace_back(std::make_pair(p, coef));
2329  }
2330 
2331  indexed_constraint_rows.emplace(i, std::move(constraint_row));
2332  }
2333 
2334  this->comm().set_union(indexed_constraint_rows);
2335 
2336  // Add constraint rows as mesh constraint rows
2337  for (auto & [node_id, indexed_row] : indexed_constraint_rows)
2338  {
2339  Node * constrained_node = this->node_ptr(node_id);
2340 
2341  constraint_rows_mapped_type constraint_row;
2342 
2343  for (auto [p, coef] : indexed_row)
2344  {
2345  const Elem * elem = this->elem_ptr(p.first);
2346  constraint_row.emplace_back
2347  (std::make_pair(std::make_pair(elem, p.second), coef));
2348  }
2349 
2350  this->_constraint_rows.emplace(constrained_node,
2351  std::move(constraint_row));
2352  }
2353 }
T libmesh_real(T a)
std::set< subdomain_id_type > _mesh_subdomains
We cache the subdomain ids of the elements present in the mesh.
Definition: mesh_base.h:1995
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
Order
defines an enum for polynomial orders.
Definition: enum_order.h:40
static constexpr Real TOLERANCE
std::vector< std::pair< std::pair< const Elem *, unsigned int >, Real > > constraint_rows_mapped_type
Definition: mesh_base.h:1697
TestClass subdomain_id_type
Based on the 4-byte comment warning above, this probably doesn&#39;t work with exodusII at all...
Definition: id_types.h:43
constraint_rows_type _constraint_rows
Definition: mesh_base.h:2104
const Parallel::Communicator & comm() const
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
Add a new Node at Point p to the end of the vertex array, with processor_id procid.
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
Definition: elem.C:444
std::set< Order > _elem_default_orders
We cache the (default) order of the geometric elements present in the mesh.
Definition: mesh_base.h:1984
void subdomain_ids(std::set< subdomain_id_type > &ids, const bool global=true) const
Constructs a list of all subdomain identifiers in the local mesh if global == false, and in the global mesh if global == true (default).
Definition: mesh_base.C:959
libmesh_assert(ctx)
Order _supported_nodal_order
We cache the maximum nodal order supported by all the mesh&#39;s elements (the minimum supported_nodal_or...
Definition: mesh_base.h:1990
std::set< unsigned char > _elem_dims
We cache the dimension of the elements present in the mesh.
Definition: mesh_base.h:1977
virtual const Elem * elem_ptr(const dof_id_type i) const =0
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:140
virtual const Node & node_ref(const dof_id_type i) const
Definition: mesh_base.h:596
virtual const Node * node_ptr(const dof_id_type i) const =0
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:117
virtual dof_id_type n_nodes() const =0
uint8_t dof_id_type
Definition: id_types.h:67
void set_union(T &data, const unsigned int root_id) const

◆ copy_nodes_and_elements()

void libMesh::UnstructuredMesh::copy_nodes_and_elements ( const MeshBase other_mesh,
const bool  skip_find_neighbors = false,
dof_id_type  element_id_offset = 0,
dof_id_type  node_id_offset = 0,
unique_id_type  unique_id_offset = 0,
std::unordered_map< subdomain_id_type, subdomain_id_type > *  id_remapping = nullptr 
)
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.

Definition at line 639 of file unstructured_mesh.C.

References libMesh::MeshBase::_elem_integer_names, libMesh::MeshBase::_node_integer_names, libMesh::Elem::add_child(), libMesh::MeshBase::add_elem(), libMesh::DofObject::add_extra_integers(), libMesh::MeshBase::add_point(), libMesh::MeshBase::allow_find_neighbors(), libMesh::MeshBase::allow_remote_element_removal(), libMesh::MeshBase::allow_renumbering(), libMesh::Elem::disconnected_clone(), libMesh::MeshBase::elem_ptr(), libMesh::MeshBase::is_prepared(), libMesh::MeshTools::libmesh_assert_valid_amr_elem_ids(), libMesh::MeshBase::merge_extra_integer_names(), libMesh::MeshBase::mesh_dimension(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::MeshBase::n_partitions(), libMesh::ParallelObject::n_processors(), libMesh::Elem::neighbor_ptr(), 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::Elem::set_interior_parent(), libMesh::MeshBase::set_isnt_prepared(), libMesh::Elem::set_neighbor(), libMesh::MeshBase::set_next_unique_id(), and libMesh::MeshBase::skip_partitioning().

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

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

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

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

1285 {
1286 
1287  // Issue a warning if the number the number of processors
1288  // currently available is less that that requested for
1289  // partitioning. This is not necessarily an error since
1290  // you may run on one processor and still partition the
1291  // mesh into several partitions.
1292 #ifdef DEBUG
1293  if (this->n_processors() < pid)
1294  {
1295  libMesh::out << "WARNING: You are creating a "
1296  << "mesh for a processor id (="
1297  << pid
1298  << ") greater than "
1299  << "the number of processors available for "
1300  << "the calculation. (="
1301  << this->n_processors()
1302  << ")."
1303  << std::endl;
1304  }
1305 #endif
1306 
1307  this->create_submesh (pid_mesh,
1308  this->active_pid_elements_begin(pid),
1309  this->active_pid_elements_end(pid));
1310 }
processor_id_type n_processors() const
OStreamProxy out
void create_submesh(UnstructuredMesh &new_mesh, const const_element_iterator &it, const const_element_iterator &it_end) const
Constructs a mesh called "new_mesh" from the current mesh by iterating over the elements between it a...

◆ create_submesh()

void libMesh::UnstructuredMesh::create_submesh ( UnstructuredMesh new_mesh,
const const_element_iterator it,
const const_element_iterator it_end 
) const
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 1318 of file unstructured_mesh.C.

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

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

◆ DECLARE_ELEM_ITERATORS() [1/20]

libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( )

Elem and Node iterator accessor functions.

See MeshBase for documentation.

◆ DECLARE_ELEM_ITERATORS() [2/20]

libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( active_  )

◆ DECLARE_ELEM_ITERATORS() [3/20]

libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( ancestor_  )

◆ DECLARE_ELEM_ITERATORS() [4/20]

libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( local_  )

◆ DECLARE_ELEM_ITERATORS() [5/20]

libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( facelocal_  )

◆ DECLARE_ELEM_ITERATORS() [6/20]

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

◆ DECLARE_ELEM_ITERATORS() [7/20]

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

◆ DECLARE_ELEM_ITERATORS() [8/20]

libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( not_active_  )

◆ DECLARE_ELEM_ITERATORS() [9/20]

libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( not_ancestor_  )

◆ DECLARE_ELEM_ITERATORS() [10/20]

libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( not_subactive_  )

◆ DECLARE_ELEM_ITERATORS() [11/20]

libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( not_local_  )

◆ DECLARE_ELEM_ITERATORS() [12/20]

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

◆ DECLARE_ELEM_ITERATORS() [13/20]

libMesh::DistributedMesh::DECLARE_ELEM_ITERATORS ( active_not_local_  )

◆ DECLARE_ELEM_ITERATORS() [14/20]

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

◆ DECLARE_ELEM_ITERATORS() [15/20]

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

◆ DECLARE_ELEM_ITERATORS() [16/20]

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

◆ DECLARE_ELEM_ITERATORS() [17/20]

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

◆ DECLARE_ELEM_ITERATORS() [18/20]

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

◆ DECLARE_ELEM_ITERATORS() [19/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   
)

◆ DECLARE_ELEM_ITERATORS() [20/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 
)

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

◆ 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 libMesh::DistributedMesh::DECLARE_NODE_ITERATORS ( bnd_  )

◆ 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 processor_id_type pid libMesh::DistributedMesh::DECLARE_NODE_ITERATORS ( bid_  ,
boundary_id_type  bid,
bid   
)

◆ default_ghosting()

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

Default ghosting functor.

Definition at line 1303 of file mesh_base.h.

References libMesh::MeshBase::_default_ghosting.

1303 { 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:2077

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

References libMesh::MeshBase::_default_mapping_data.

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

831  {
832  return _default_mapping_data;
833  }
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:1891

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

References libMesh::MeshBase::_default_mapping_type.

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

813  {
814  return _default_mapping_type;
815  }
ElemMappingType _default_mapping_type
The default mapping type (typically Lagrange) between master and physical space to assign to newly ad...
Definition: mesh_base.h:1884

◆ delete_elem()

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

Removes element e from the mesh.

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

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

Implements libMesh::MeshBase.

Definition at line 713 of file distributed_mesh.C.

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

Referenced by insert_elem().

714 {
715  libmesh_assert (e);
716 
717  // Try to make the cached elem data more accurate
718  _n_elem--;
719 
720  // Was this a coarse element, not just a coarsening where we still
721  // have some ancestor structure? Was it a *local* element, that we
722  // might have been depending on as an owner of local nodes? We'll
723  // have to be more careful with our nodes in contract() later; no
724  // telling if we just locally orphaned a node that should be
725  // globally retained.
726  if (e->processor_id() == this->processor_id() &&
727  !e->parent())
729 
730  // Delete the element from the BoundaryInfo object
731  this->get_boundary_info().remove(e);
732 
733  // But not yet from the container; we might invalidate
734  // an iterator that way!
735 
736  //_elements.erase(e->id());
737 
738  // Instead, we set it to nullptr for now
739 
740  _elements[e->id()] = nullptr;
741 
742  // delete the element
743  delete e;
744 }
void remove(const Node *node)
Removes the boundary conditions associated with node node, if any exist.
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:165
libmesh_assert(ctx)
dofobject_container< Elem > _elements
The elements in the mesh.
processor_id_type processor_id() const
bool _deleted_coarse_elements
A boolean remembering whether we&#39;ve recently deleted top-level elements or not.

◆ delete_node()

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

Removes the Node n from the mesh.

Implements libMesh::MeshBase.

Definition at line 931 of file distributed_mesh.C.

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

932 {
933  libmesh_assert(n);
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 }
dof_id_type _n_nodes
Cached data from the last renumber_nodes_and_elements call.
void remove(const Node *node)
Removes the boundary conditions associated with node node, if any exist.
constraint_rows_type _constraint_rows
Definition: mesh_base.h:2104
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:165
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.
libmesh_assert(ctx)

◆ delete_remote_elements()

void libMesh::DistributedMesh::delete_remote_elements ( )
overridevirtual

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 1724 of file distributed_mesh.C.

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

1725 {
1726 #ifdef DEBUG
1727  // Make sure our neighbor links are all fine
1729 
1730  // And our child/parent links, and our flags
1732 
1733  // Make sure our ids and flags are consistent
1736 
1737  libmesh_assert_equal_to (this->n_nodes(), this->parallel_n_nodes());
1738  libmesh_assert_equal_to (this->n_elem(), this->parallel_n_elem());
1739  const dof_id_type pmax_node_id = this->parallel_max_node_id();
1740  const dof_id_type pmax_elem_id = this->parallel_max_elem_id();
1741  libmesh_assert_equal_to (this->max_node_id(), pmax_node_id);
1742  libmesh_assert_equal_to (this->max_elem_id(), pmax_elem_id);
1743 #endif
1744 
1745  _is_serial = false;
1746  _is_serial_on_proc_0 = false;
1747 
1748  MeshCommunication().delete_remote_elements(*this, _extra_ghost_elems);
1749 
1750  libmesh_assert_equal_to (this->max_elem_id(), this->parallel_max_elem_id());
1751 
1752  // Now make sure the containers actually shrink - strip
1753  // any newly-created nullptr voids out of the element array
1754  dofobject_container<Elem>::veclike_iterator e_it = _elements.begin();
1755  const dofobject_container<Elem>::veclike_iterator e_end = _elements.end();
1756  while (e_it != e_end)
1757  if (!*e_it)
1758  e_it = _elements.erase(e_it);
1759  else
1760  ++e_it;
1761 
1762  dofobject_container<Node>::veclike_iterator n_it = _nodes.begin();
1763  const dofobject_container<Node>::veclike_iterator n_end = _nodes.end();
1764  while (n_it != n_end)
1765  if (!*n_it)
1766  n_it = _nodes.erase(n_it);
1767  else
1768  ++n_it;
1769 
1770  // We may have deleted no-longer-connected nodes or coarsened-away
1771  // elements; let's update our caches.
1772  this->update_parallel_id_counts();
1773 
1774  // We may have deleted nodes or elements that were the only local
1775  // representatives of some particular boundary id(s); let's update
1776  // those caches.
1778 
1779 #ifdef DEBUG
1780  // We might not have well-packed objects if the user didn't allow us
1781  // to renumber
1782  // libmesh_assert_equal_to (this->n_nodes(), this->max_node_id());
1783  // libmesh_assert_equal_to (this->n_elem(), this->max_elem_id());
1784 
1785  // Make sure our neighbor links are all fine
1787 
1788  // And our child/parent links, and our flags
1790 
1791  // Make sure our ids and flags are consistent
1794 #endif
1795 }
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
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&#39;re serialized to proc 0 or not.
void libmesh_assert_valid_refinement_tree(const MeshBase &mesh)
A function for verifying that elements on this processor have valid descendants and consistent active...
Definition: mesh_tools.C:1547
virtual dof_id_type n_nodes() const override final
bool _is_serial
A boolean remembering whether we&#39;re serialized or not.
void libmesh_assert_valid_parallel_flags() const
Verify refinement_flag and p_refinement_flag consistency of our elements containers.
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:165
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.
friend class MeshCommunication
Make the MeshCommunication class a friend so that it can directly broadcast *_integer_names.
Definition: mesh_base.h:2134
virtual dof_id_type parallel_n_elem() const override
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...
dof_id_type parallel_max_node_id() const
void regenerate_id_sets()
Clears and regenerates the cached sets of ids.
dofobject_container< Elem > _elements
The elements in the mesh.
virtual dof_id_type max_node_id() const override final
virtual dof_id_type n_elem() const override final
void libmesh_assert_valid_neighbors(const MeshBase &mesh, bool assert_valid_remote_elems=true)
A function for verifying that neighbor connectivity is correct (each element is a neighbor of or desc...
Definition: mesh_tools.C:2205
virtual dof_id_type max_elem_id() const override final
dof_id_type parallel_max_elem_id() const
uint8_t dof_id_type
Definition: id_types.h:67

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

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

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

1812 {
1813  // This requires an inspection on every processor
1814  parallel_object_only();
1815 
1816  // Check if the mesh contains mixed dimensions. If so, then we may
1817  // have interior parents to set. Otherwise return.
1818  if (this->elem_dimensions().size() == 1)
1819  return;
1820 
1821  // Do we have interior parent pointers going to a different mesh?
1822  // If so then we'll still check to make sure that's the only place
1823  // they go, so we can libmesh_not_implemented() if not.
1824  const bool separate_interior_mesh = (&(this->interior_mesh()) != this);
1825 
1826  // This map will be used to set interior parents
1827  std::unordered_map<dof_id_type, std::vector<dof_id_type>> node_to_elem;
1828 
1829  for (const auto & elem : this->element_ptr_range())
1830  {
1831  // Populating the node_to_elem map, same as MeshTools::build_nodes_to_elem_map
1832  for (auto n : make_range(elem->n_vertices()))
1833  {
1834  libmesh_assert_less (elem->id(), this->max_elem_id());
1835 
1836  node_to_elem[elem->node_id(n)].push_back(elem->id());
1837  }
1838  }
1839 
1840  // Automatically set interior parents
1841  for (const auto & element : this->element_ptr_range())
1842  {
1843  // Ignore an 3D element or an element that already has an interior parent
1844  if (element->dim()>=LIBMESH_DIM || element->interior_parent())
1845  continue;
1846 
1847  // Start by generating a SET of elements that are dim+1 to the current
1848  // element at each vertex of the current element, thus ignoring interior nodes.
1849  // If one of the SET of elements is empty, then we will not have an interior parent
1850  // since an interior parent must be connected to all vertices of the current element
1851  std::vector<std::set<dof_id_type>> neighbors( element->n_vertices() );
1852 
1853  bool found_interior_parents = false;
1854 
1855  for (auto n : make_range(element->n_vertices()))
1856  {
1857  std::vector<dof_id_type> & element_ids = node_to_elem[element->node_id(n)];
1858  for (const auto & eid : element_ids)
1859  if (this->elem_ref(eid).dim() == element->dim()+1)
1860  neighbors[n].insert(eid);
1861 
1862  if (neighbors[n].size()>0)
1863  {
1864  found_interior_parents = true;
1865  }
1866  else
1867  {
1868  // We have found an empty set, no reason to continue
1869  // Ensure we set this flag to false before the break since it could have
1870  // been set to true for previous vertex
1871  found_interior_parents = false;
1872  break;
1873  }
1874  }
1875 
1876  // If we have successfully generated a set of elements for each vertex, we will compare
1877  // the set for vertex 0 will the sets for the vertices until we find a id that exists in
1878  // all sets. If found, this is our an interior parent id. The interior parent id found
1879  // will be the lowest element id if there is potential for multiple interior parents.
1880  if (found_interior_parents)
1881  {
1882  std::set<dof_id_type> & neighbors_0 = neighbors[0];
1883  for (const auto & interior_parent_id : neighbors_0)
1884  {
1885  found_interior_parents = false;
1886  for (auto n : make_range(1u, element->n_vertices()))
1887  {
1888  if (neighbors[n].count(interior_parent_id))
1889  {
1890  found_interior_parents = true;
1891  }
1892  else
1893  {
1894  found_interior_parents = false;
1895  break;
1896  }
1897  }
1898 
1899  if (found_interior_parents)
1900  {
1901  element->set_interior_parent(this->elem_ptr(interior_parent_id));
1902  break;
1903  }
1904  }
1905 
1906  // Do we have a mixed dimensional mesh that contains some of
1907  // its own interior parents, but we already expect to have
1908  // interior parents on a different mesh? That's going to
1909  // take some work to support if anyone needs it.
1910  if (separate_interior_mesh)
1911  libmesh_not_implemented_msg
1912  ("interior_parent() values in multiple meshes are unsupported.");
1913  }
1914  }
1915 }
const MeshBase & interior_mesh() const
Definition: mesh_base.h:1797
unsigned int dim
virtual dof_id_type max_elem_id() const =0
const std::set< unsigned char > & elem_dimensions() const
Definition: mesh_base.h:282
virtual const Elem * elem_ptr(const dof_id_type i) const =0
virtual const Elem & elem_ref(const dof_id_type i) const
Definition: mesh_base.h:639
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:140

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

References libMesh::MeshBase::_elem_default_orders.

290  { return _elem_default_orders; }
std::set< Order > _elem_default_orders
We cache the (default) order of the geometric elements present in the mesh.
Definition: mesh_base.h:1984

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

References libMesh::MeshBase::_elem_dims.

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

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

◆ elem_ptr() [1/2]

const Elem * libMesh::DistributedMesh::elem_ptr ( const dof_id_type  i) const
finaloverridevirtual
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 480 of file distributed_mesh.C.

References _elements, and libMesh::libmesh_assert().

Referenced by DistributedMesh(), and fix_broken_node_and_element_numbering().

481 {
483  libmesh_assert_equal_to (_elements[i]->id(), i);
484 
485  return _elements[i];
486 }
libmesh_assert(ctx)
dofobject_container< Elem > _elements
The elements in the mesh.

◆ elem_ptr() [2/2]

Elem * libMesh::DistributedMesh::elem_ptr ( const dof_id_type  i)
finaloverridevirtual
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 491 of file distributed_mesh.C.

References _elements, and libMesh::libmesh_assert().

492 {
494  libmesh_assert_equal_to (_elements[i]->id(), i);
495 
496  return _elements[i];
497 }
libmesh_assert(ctx)
dofobject_container< Elem > _elements
The elements in the mesh.

◆ elem_ref() [1/2]

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

Definition at line 639 of file mesh_base.h.

References libMesh::MeshBase::elem_ptr().

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

640  {
641  return *this->elem_ptr(i);
642  }
virtual const Elem * elem_ptr(const dof_id_type i) const =0

◆ elem_ref() [2/2]

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

Definition at line 649 of file mesh_base.h.

References libMesh::MeshBase::elem_ptr().

650  {
651  return *this->elem_ptr(i);
652  }
virtual const Elem * elem_ptr(const dof_id_type i) const =0

◆ extra_ghost_elems()

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

Const accessor to the ghosted elements.

Definition at line 267 of file distributed_mesh.h.

References _extra_ghost_elems.

Referenced by clear_extra_ghost_elems().

267 { return _extra_ghost_elems; }
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...

◆ find_neighbors()

void libMesh::UnstructuredMesh::find_neighbors ( const bool  reset_remote_elements = false,
const bool  reset_current_list = 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 872 of file unstructured_mesh.C.

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

Referenced by libMesh::TriangleWrapper::copy_tri_to_mesh(), libMesh::Poly2TriTriangulator::insert_refinement_points(), libMesh::UnstructuredMesh::stitching_helper(), and libMesh::TriangleInterface::triangulate().

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

◆ fix_broken_node_and_element_numbering()

void libMesh::DistributedMesh::fix_broken_node_and_element_numbering ( )
overridevirtual

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 1669 of file distributed_mesh.C.

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

1670 {
1671  // We can't use range-for here because we need access to the special
1672  // iterators' methods, not just to their dereferenced values.
1673 
1674  // Nodes first
1675  for (auto pr = this->_nodes.begin(),
1676  end = this->_nodes.end(); pr != end; ++pr)
1677  {
1678  Node * n = *pr;
1679  if (n != nullptr)
1680  {
1681  const dof_id_type id = pr.index();
1682  n->set_id() = id;
1683  libmesh_assert_equal_to(this->node_ptr(id), n);
1684  }
1685  }
1686 
1687  // Elements next
1688  for (auto pr = this->_elements.begin(),
1689  end = this->_elements.end(); pr != end; ++pr)
1690  {
1691  Elem * e = *pr;
1692  if (e != nullptr)
1693  {
1694  const dof_id_type id = pr.index();
1695  e->set_id() = id;
1696  libmesh_assert_equal_to(this->elem_ptr(id), e);
1697  }
1698  }
1699 }
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.
virtual const Elem * elem_ptr(const dof_id_type i) const override final
dofobject_container< Elem > _elements
The elements in the mesh.
uint8_t dof_id_type
Definition: id_types.h:67
virtual const Node * node_ptr(const dof_id_type i) const override final

◆ gather_to_zero()

void libMesh::DistributedMesh::gather_to_zero ( )
overridevirtual

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

Reimplemented from libMesh::MeshBase.

Definition at line 1849 of file distributed_mesh.C.

References _is_serial_on_proc_0, and libMesh::MeshBase::MeshCommunication.

1850 {
1852  return;
1853 
1854  _is_serial_on_proc_0 = true;
1855  MeshCommunication().gather(0, *this);
1856 }
bool _is_serial_on_proc_0
A boolean remembering whether we&#39;re serialized to proc 0 or not.
friend class MeshCommunication
Make the MeshCommunication class a friend so that it can directly broadcast *_integer_names.
Definition: mesh_base.h:2134

◆ get_boundary_info() [1/2]

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

The information about boundary ids on the mesh.

Definition at line 165 of file mesh_base.h.

References libMesh::MeshBase::boundary_info.

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

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

◆ get_boundary_info() [2/2]

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

Writable information about boundary ids on the mesh.

Definition at line 170 of file mesh_base.h.

References libMesh::MeshBase::boundary_info.

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

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

References libMesh::MeshBase::_constraint_rows.

1707  { return _constraint_rows; }
constraint_rows_type _constraint_rows
Definition: mesh_base.h:2104

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

References libMesh::MeshBase::_count_lower_dim_elems_in_point_locator.

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

1686 {
1688 }
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:1911

◆ get_elem_integer_index()

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

Definition at line 626 of file mesh_base.C.

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

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

627 {
628  for (auto i : index_range(_elem_integer_names))
629  if (_elem_integer_names[i] == name)
630  return i;
631 
632  libmesh_error_msg("Unknown elem integer " << name);
633  return libMesh::invalid_uint;
634 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
Definition: libmesh.h:310
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:2033
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:117

◆ get_elem_integer_name()

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

Definition at line 944 of file mesh_base.h.

References libMesh::MeshBase::_elem_integer_names.

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

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

◆ get_elemset_code()

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

Definition at line 439 of file mesh_base.C.

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

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

440 {
441  auto it = _elemset_codes_inverse_map.find(id_set);
442  return (it == _elemset_codes_inverse_map.end()) ? DofObject::invalid_id : it->second;
443 }
std::map< MeshBase::elemset_type, dof_id_type > _elemset_codes_inverse_map
Definition: mesh_base.h:2020
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:482

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

References libMesh::MeshBase::_elemset_codes.

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

446 {
447  std::vector<dof_id_type> ret;
448  ret.reserve(_elemset_codes.size());
449  for (const auto & pr : _elemset_codes)
450  ret.push_back(pr.first);
451  return ret;
452 }
std::map< dof_id_type, const MeshBase::elemset_type * > _elemset_codes
Map from "element set code" to list of set ids to which that element belongs (and vice-versa)...
Definition: mesh_base.h:2019

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

References libMesh::MeshBase::_elemset_codes.

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

430 {
431  // If we don't recognize this elemset_code, hand back an empty set
432  id_set_to_fill.clear();
433 
434  if (const auto it = _elemset_codes.find(elemset_code);
435  it != _elemset_codes.end())
436  id_set_to_fill.insert(it->second->begin(), it->second->end());
437 }
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:2019

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

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

1713 {
1714  // Linear search over the map values.
1715  for (const auto & [sbd_id, sbd_name] : _block_id_to_name)
1716  if (sbd_name == name)
1717  return sbd_id;
1718 
1719  // If we made it here without returning, we don't have a subdomain
1720  // with the requested name, so return Elem::invalid_subdomain_id.
1722 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
static const subdomain_id_type invalid_subdomain_id
A static integral constant representing an invalid subdomain id.
Definition: elem.h:251
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:1970

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

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::MeshTools::elem_types(), libMesh::Utility::enum_to_string(), libMesh::MeshBase::get_boundary_info(), libMesh::BoundaryInfo::get_edge_boundary_ids(), libMesh::BoundaryInfo::get_edgeset_name_map(), libMesh::BoundaryInfo::get_node_boundary_ids(), libMesh::BoundaryInfo::get_nodeset_name_map(), libMesh::BoundaryInfo::get_side_boundary_ids(), libMesh::BoundaryInfo::get_sideset_name_map(), libMesh::MeshBase::get_subdomain_name_map(), libMesh::DofObject::id(), libMesh::DofObject::invalid_processor_id, libMesh::MeshBase::is_prepared(), libMesh::MeshBase::is_replicated(), libMesh::libmesh_assert(), libMesh::Elem::loose_bounding_box(), TIMPI::Communicator::max(), TIMPI::Communicator::min(), libMesh::MeshBase::n_active_elem(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_elemsets(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::MeshBase::n_local_subdomains(), libMesh::MeshBase::n_nodes(), libMesh::MeshBase::n_partitions(), libMesh::ParallelObject::n_processors(), libMesh::MeshBase::n_subdomains(), libMesh::n_threads(), libMesh::Quality::name(), libMesh::Elem::node_ref_range(), libMesh::ParallelObject::processor_id(), libMesh::Real, TIMPI::Communicator::set_union(), libMesh::MeshBase::spatial_dimension(), TIMPI::Communicator::sum(), libMesh::MeshBase::supported_nodal_order(), libMesh::Elem::type(), libMesh::BoundingBox::union_with(), libMesh::MeshTools::volume(), and libMesh::Elem::volume().

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

1083 {
1084  std::ostringstream oss;
1085 
1086  oss << " Mesh Information:" << '\n';
1087 
1088  if (!_elem_dims.empty())
1089  {
1090  oss << " elem_dimensions()={";
1091  std::copy(_elem_dims.begin(),
1092  --_elem_dims.end(), // --end() is valid if the set is non-empty
1093  std::ostream_iterator<unsigned int>(oss, ", "));
1094  oss << cast_int<unsigned int>(*_elem_dims.rbegin());
1095  oss << "}\n";
1096  }
1097 
1098  if (!_elem_default_orders.empty())
1099  {
1100  oss << " elem_default_orders()={";
1101  std::transform(_elem_default_orders.begin(),
1102  --_elem_default_orders.end(),
1103  std::ostream_iterator<std::string>(oss, ", "),
1104  [](Order o)
1105  { return Utility::enum_to_string<Order>(o); });
1106  oss << Utility::enum_to_string<Order>(*_elem_default_orders.rbegin());
1107  oss << "}\n";
1108  }
1109 
1110  oss << " supported_nodal_order()=" << this->supported_nodal_order() << '\n'
1111  << " spatial_dimension()=" << this->spatial_dimension() << '\n'
1112  << " n_nodes()=" << this->n_nodes() << '\n'
1113  << " n_local_nodes()=" << this->n_local_nodes() << '\n'
1114  << " n_elem()=" << this->n_elem() << '\n'
1115  << " n_local_elem()=" << this->n_local_elem() << '\n';
1116 #ifdef LIBMESH_ENABLE_AMR
1117  oss << " n_active_elem()=" << this->n_active_elem() << '\n';
1118 #endif
1119  if (global)
1120  oss << " n_subdomains()=" << static_cast<std::size_t>(this->n_subdomains()) << '\n';
1121  else
1122  oss << " n_local_subdomains()= " << static_cast<std::size_t>(this->n_local_subdomains()) << '\n';
1123  oss << " n_elemsets()=" << static_cast<std::size_t>(this->n_elemsets()) << '\n';
1124  if (!_elemset_codes.empty())
1125  oss << " n_elemset_codes=" << _elemset_codes.size() << '\n';
1126  oss << " n_partitions()=" << static_cast<std::size_t>(this->n_partitions()) << '\n'
1127  << " n_processors()=" << static_cast<std::size_t>(this->n_processors()) << '\n'
1128  << " n_threads()=" << static_cast<std::size_t>(libMesh::n_threads()) << '\n'
1129  << " processor_id()=" << static_cast<std::size_t>(this->processor_id()) << '\n'
1130  << " is_prepared()=" << (this->is_prepared() ? "true" : "false") << '\n'
1131  << " is_replicated()=" << (this->is_replicated() ? "true" : "false") << '\n';
1132 
1133  if (verbosity > 0)
1134  {
1135  if (global)
1136  {
1137  libmesh_parallel_only(this->comm());
1138  if (this->processor_id() != 0)
1139  oss << "\n Detailed global get_info() (verbosity > 0) is reduced and output to only rank 0.";
1140  }
1141 
1142  // Helper for printing element types
1143  const auto elem_type_helper = [](const std::set<int> & elem_types) {
1144  std::stringstream ss;
1145  for (auto it = elem_types.begin(); it != elem_types.end();)
1146  {
1147  ss << Utility::enum_to_string((ElemType)*it);
1148  if (++it != elem_types.end())
1149  ss << ", ";
1150  }
1151  return ss.str();
1152  };
1153 
1154  // Helper for whether or not the given DofObject is to be included. If we're doing
1155  // a global reduction, we also count unpartitioned objects on rank 0.
1156  const auto include_object = [this, &global](const DofObject & dof_object) {
1157  return this->processor_id() == dof_object.processor_id() ||
1158  (global &&
1159  this->processor_id() == 0 &&
1160  dof_object.processor_id() == DofObject::invalid_processor_id);
1161  };
1162 
1163  Real volume = 0;
1164 
1165  // Add bounding box information
1166  const auto bbox = global ? MeshTools::create_bounding_box(*this) : MeshTools::create_local_bounding_box(*this);
1167  if (!global || this->processor_id() == 0)
1168  oss << "\n " << (global ? "" : "Local ") << "Mesh Bounding Box:\n"
1169  << " Minimum: " << bbox.min() << "\n"
1170  << " Maximum: " << bbox.max() << "\n"
1171  << " Delta: " << (bbox.max() - bbox.min()) << "\n";
1172 
1173  // Obtain the global or local element types
1174  std::set<int> elem_types;
1175  for (const Elem * elem : this->active_local_element_ptr_range())
1176  elem_types.insert(elem->type());
1177  if (global)
1178  {
1179  // Pick up unpartitioned elems on rank 0
1180  if (this->processor_id() == 0)
1181  for (const Elem * elem : this->active_unpartitioned_element_ptr_range())
1182  elem_types.insert(elem->type());
1183 
1184  this->comm().set_union(elem_types);
1185  }
1186 
1187  // Add element types
1188  if (!global || this->processor_id() == 0)
1189  oss << "\n " << (global ? "" : "Local ") << "Mesh Element Type(s):\n "
1190  << elem_type_helper(elem_types) << "\n";
1191 
1192  // Reduce the nodeset ids
1193  auto nodeset_ids = this->get_boundary_info().get_node_boundary_ids();
1194  if (global)
1195  this->comm().set_union(nodeset_ids);
1196 
1197  // Accumulate local information for each nodeset
1198  struct NodesetInfo
1199  {
1200  std::size_t num_nodes = 0;
1201  BoundingBox bbox;
1202  };
1203  std::map<boundary_id_type, NodesetInfo> nodeset_info_map;
1204  for (const auto & [node, id] : this->get_boundary_info().get_nodeset_map())
1205  {
1206  if (!include_object(*node))
1207  continue;
1208 
1209  NodesetInfo & info = nodeset_info_map[id];
1210 
1211  ++info.num_nodes;
1212 
1213  if (verbosity > 1)
1214  info.bbox.union_with(*node);
1215  }
1216 
1217  // Add nodeset info
1218  if (!global || this->processor_id() == 0)
1219  {
1220  oss << "\n " << (global ? "" : "Local ") << "Mesh Nodesets:\n";
1221  if (nodeset_ids.empty())
1222  oss << " None\n";
1223  }
1224 
1225  const auto & nodeset_name_map = this->get_boundary_info().get_nodeset_name_map();
1226  for (const auto id : nodeset_ids)
1227  {
1228  NodesetInfo & info = nodeset_info_map[id];
1229 
1230  // Reduce the local information for this nodeset if required
1231  if (global)
1232  {
1233  this->comm().sum(info.num_nodes);
1234  if (verbosity > 1)
1235  {
1236  this->comm().min(info.bbox.min());
1237  this->comm().max(info.bbox.max());
1238  }
1239  }
1240 
1241  const bool has_name = nodeset_name_map.count(id) && nodeset_name_map.at(id).size();
1242  const std::string name = has_name ? nodeset_name_map.at(id) : "";
1243  if (global)
1244  libmesh_assert(this->comm().verify(name));
1245 
1246  if (global ? this->processor_id() == 0 : info.num_nodes > 0)
1247  {
1248  oss << " Nodeset " << id;
1249  if (has_name)
1250  oss << " (" << name << ")";
1251  oss << ", " << info.num_nodes << " " << (global ? "" : "local ") << "nodes\n";
1252 
1253  if (verbosity > 1)
1254  {
1255  oss << " " << (global ? "Bounding" : "Local bounding") << " box minimum: "
1256  << info.bbox.min() << "\n"
1257  << " " << (global ? "Bounding" : "Local bounding") << " box maximum: "
1258  << info.bbox.max() << "\n"
1259  << " " << (global ? "Bounding" : "Local bounding") << " box delta: "
1260  << (info.bbox.max() - info.bbox.min()) << "\n";
1261  }
1262  }
1263  }
1264 
1265  // Reduce the sideset ids
1266  auto sideset_ids = this->get_boundary_info().get_side_boundary_ids();
1267  if (global)
1268  this->comm().set_union(sideset_ids);
1269 
1270  // Accumulate local information for each sideset
1271  struct SidesetInfo
1272  {
1273  std::size_t num_sides = 0;
1274  Real volume = 0;
1275  std::set<int> side_elem_types;
1276  std::set<int> elem_types;
1277  std::set<dof_id_type> elem_ids;
1278  std::set<dof_id_type> node_ids;
1279  BoundingBox bbox;
1280  };
1281  ElemSideBuilder side_builder;
1282  std::map<boundary_id_type, SidesetInfo> sideset_info_map;
1283  for (const auto & pair : this->get_boundary_info().get_sideset_map())
1284  {
1285  const Elem * elem = pair.first;
1286  if (!include_object(*elem))
1287  continue;
1288 
1289  const auto id = pair.second.second;
1290  SidesetInfo & info = sideset_info_map[id];
1291 
1292  const auto s = pair.second.first;
1293  const Elem & side = side_builder(*elem, s);
1294 
1295  ++info.num_sides;
1296  info.side_elem_types.insert(side.type());
1297  info.elem_types.insert(elem->type());
1298  info.elem_ids.insert(elem->id());
1299 
1300  for (const Node & node : side.node_ref_range())
1301  if (include_object(node))
1302  info.node_ids.insert(node.id());
1303 
1304  if (verbosity > 1)
1305  {
1306  info.volume += side.volume();
1307  info.bbox.union_with(side.loose_bounding_box());
1308  }
1309  }
1310 
1311  // Add sideset info
1312  if (!global || this->processor_id() == 0)
1313  {
1314  oss << "\n " << (global ? "" : "Local ") << "Mesh Sidesets:\n";
1315  if (sideset_ids.empty())
1316  oss << " None\n";
1317  }
1318  const auto & sideset_name_map = this->get_boundary_info().get_sideset_name_map();
1319  for (const auto id : sideset_ids)
1320  {
1321  SidesetInfo & info = sideset_info_map[id];
1322 
1323  auto num_elems = info.elem_ids.size();
1324  auto num_nodes = info.node_ids.size();
1325 
1326  // Reduce the local information for this sideset if required
1327  if (global)
1328  {
1329  this->comm().sum(info.num_sides);
1330  this->comm().set_union(info.side_elem_types, 0);
1331  this->comm().sum(num_elems);
1332  this->comm().set_union(info.elem_types, 0);
1333  this->comm().sum(num_nodes);
1334  if (verbosity > 1)
1335  {
1336  this->comm().sum(info.volume);
1337  this->comm().min(info.bbox.min());
1338  this->comm().max(info.bbox.max());
1339  }
1340  }
1341 
1342  const bool has_name = sideset_name_map.count(id) && sideset_name_map.at(id).size();
1343  const std::string name = has_name ? sideset_name_map.at(id) : "";
1344  if (global)
1345  libmesh_assert(this->comm().verify(name));
1346 
1347  if (global ? this->processor_id() == 0 : info.num_sides > 0)
1348  {
1349  oss << " Sideset " << id;
1350  if (has_name)
1351  oss << " (" << name << ")";
1352  oss << ", " << info.num_sides << " sides (" << elem_type_helper(info.side_elem_types) << ")"
1353  << ", " << num_elems << " " << (global ? "" : "local ") << "elems (" << elem_type_helper(info.elem_types) << ")"
1354  << ", " << num_nodes << " " << (global ? "" : "local ") << "nodes\n";
1355 
1356  if (verbosity > 1)
1357  {
1358  oss << " " << (global ? "Side" : "Local side") << " volume: " << info.volume << "\n"
1359  << " " << (global ? "Bounding" : "Local bounding") << " box minimum: "
1360  << info.bbox.min() << "\n"
1361  << " " << (global ? "Bounding" : "Local bounding") << " box maximum: "
1362  << info.bbox.max() << "\n"
1363  << " " << (global ? "Bounding" : "Local bounding") << " box delta: "
1364  << (info.bbox.max() - info.bbox.min()) << "\n";
1365  }
1366  }
1367  }
1368 
1369  // Reduce the edgeset ids
1370  auto edgeset_ids = this->get_boundary_info().get_edge_boundary_ids();
1371  if (global)
1372  this->comm().set_union(edgeset_ids);
1373 
1374  // Accumulate local information for each edgeset
1375  struct EdgesetInfo
1376  {
1377  std::size_t num_edges = 0;
1378  std::set<int> edge_elem_types;
1379  BoundingBox bbox;
1380  };
1381  std::map<boundary_id_type, EdgesetInfo> edgeset_info_map;
1382  std::unique_ptr<const Elem> edge;
1383 
1384  for (const auto & pair : this->get_boundary_info().get_edgeset_map())
1385  {
1386  const Elem * elem = pair.first;
1387  if (!include_object(*elem))
1388  continue;
1389 
1390  const auto id = pair.second.second;
1391  EdgesetInfo & info = edgeset_info_map[id];
1392 
1393  elem->build_edge_ptr(edge, pair.second.first);
1394 
1395  ++info.num_edges;
1396  info.edge_elem_types.insert(edge->type());
1397 
1398  if (verbosity > 1)
1399  info.bbox.union_with(edge->loose_bounding_box());
1400  }
1401 
1402  // Add edgeset info
1403  if (!global || this->processor_id() == 0)
1404  {
1405  oss << "\n " << (global ? "" : "Local ") << "Mesh Edgesets:\n";
1406  if (edgeset_ids.empty())
1407  oss << " None\n";
1408  }
1409 
1410  const auto & edgeset_name_map = this->get_boundary_info().get_edgeset_name_map();
1411  for (const auto id : edgeset_ids)
1412  {
1413  EdgesetInfo & info = edgeset_info_map[id];
1414 
1415  // Reduce the local information for this edgeset if required
1416  if (global)
1417  {
1418  this->comm().sum(info.num_edges);
1419  this->comm().set_union(info.edge_elem_types, 0);
1420  if (verbosity > 1)
1421  {
1422  this->comm().min(info.bbox.min());
1423  this->comm().min(info.bbox.max());
1424  }
1425  }
1426 
1427  const bool has_name = edgeset_name_map.count(id) && edgeset_name_map.at(id).size();
1428  const std::string name = has_name ? edgeset_name_map.at(id) : "";
1429  if (global)
1430  libmesh_assert(this->comm().verify(name));
1431 
1432  if (global ? this->processor_id() == 0 : info.num_edges > 0)
1433  {
1434  oss << " Edgeset " << id;
1435  if (has_name)
1436  oss << " (" << name << ")";
1437  oss << ", " << info.num_edges << " " << (global ? "" : "local ") << "edges ("
1438  << elem_type_helper(info.edge_elem_types) << ")\n";
1439 
1440  if (verbosity > 1)
1441  {
1442  oss << " " << (global ? "Bounding" : "Local bounding") << " box minimum: "
1443  << info.bbox.min() << "\n"
1444  << " " << (global ? "Bounding" : "Local bounding") << " box maximum: "
1445  << info.bbox.max() << "\n"
1446  << " " << (global ? "Bounding" : "Local bounding") << " box delta: "
1447  << (info.bbox.max() - info.bbox.min()) << "\n";
1448  }
1449  }
1450  }
1451 
1452  // Reduce the block IDs and block names
1453  std::set<subdomain_id_type> subdomains;
1454  for (const Elem * elem : this->active_element_ptr_range())
1455  if (include_object(*elem))
1456  subdomains.insert(elem->subdomain_id());
1457  if (global)
1458  this->comm().set_union(subdomains);
1459 
1460  // Accumulate local information for each subdomain
1461  struct SubdomainInfo
1462  {
1463  std::size_t num_elems = 0;
1464  Real volume = 0;
1465  std::set<int> elem_types;
1466  std::set<dof_id_type> active_node_ids;
1467 #ifdef LIBMESH_ENABLE_AMR
1468  std::size_t num_active_elems = 0;
1469 #endif
1470  BoundingBox bbox;
1471  };
1472  std::map<subdomain_id_type, SubdomainInfo> subdomain_info_map;
1473  for (const Elem * elem : this->element_ptr_range())
1474  if (include_object(*elem))
1475  {
1476  SubdomainInfo & info = subdomain_info_map[elem->subdomain_id()];
1477 
1478  ++info.num_elems;
1479  info.elem_types.insert(elem->type());
1480 
1481 #ifdef LIBMESH_ENABLE_AMR
1482  if (elem->active())
1483  ++info.num_active_elems;
1484 #endif
1485 
1486  for (const Node & node : elem->node_ref_range())
1487  if (include_object(node) && node.active())
1488  info.active_node_ids.insert(node.id());
1489 
1490  if (verbosity > 1 && elem->active())
1491  {
1492  info.volume += elem->volume();
1493  info.bbox.union_with(elem->loose_bounding_box());
1494  }
1495  }
1496 
1497  // Add subdomain info
1498  oss << "\n " << (global ? "" : "Local ") << "Mesh Subdomains:\n";
1499  const auto & subdomain_name_map = this->get_subdomain_name_map();
1500  for (const auto id : subdomains)
1501  {
1502  SubdomainInfo & info = subdomain_info_map[id];
1503 
1504  auto num_active_nodes = info.active_node_ids.size();
1505 
1506  // Reduce the information for this subdomain if needed
1507  if (global)
1508  {
1509  this->comm().sum(info.num_elems);
1510 #ifdef LIBMESH_ENABLE_AMR
1511  this->comm().sum(info.num_active_elems);
1512 #endif
1513  this->comm().sum(num_active_nodes);
1514  this->comm().set_union(info.elem_types, 0);
1515  if (verbosity > 1)
1516  {
1517  this->comm().min(info.bbox.min());
1518  this->comm().max(info.bbox.max());
1519  this->comm().sum(info.volume);
1520  }
1521  }
1522  if (verbosity > 1)
1523  volume += info.volume;
1524 
1525  const bool has_name = subdomain_name_map.count(id);
1526  const std::string name = has_name ? subdomain_name_map.at(id) : "";
1527  if (global)
1528  libmesh_assert(this->comm().verify(name));
1529 
1530  if (!global || this->processor_id() == 0)
1531  {
1532  oss << " Subdomain " << id;
1533  if (has_name)
1534  oss << " (" << name << ")";
1535  oss << ": " << info.num_elems << " " << (global ? "" : "local ") << "elems "
1536  << "(" << elem_type_helper(info.elem_types);
1537 #ifdef LIBMESH_ENABLE_AMR
1538  oss << ", " << info.num_active_elems << " active";
1539 #endif
1540  oss << "), " << num_active_nodes << " " << (global ? "" : "local ") << "active nodes\n";
1541  if (verbosity > 1)
1542  {
1543  oss << " " << (global ? "Volume" : "Local volume") << ": " << info.volume << "\n";
1544  oss << " " << (global ? "Bounding" : "Local bounding") << " box minimum: "
1545  << info.bbox.min() << "\n"
1546  << " " << (global ? "Bounding" : "Local bounding") << " box maximum: "
1547  << info.bbox.max() << "\n"
1548  << " " << (global ? "Bounding" : "Local bounding") << " box delta: "
1549  << (info.bbox.max() - info.bbox.min()) << "\n";
1550  }
1551  }
1552  }
1553 
1554  oss << " " << (global ? "Global" : "Local") << " mesh volume = " << volume << "\n";
1555 
1556  }
1557 
1558  return oss.str();
1559 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
ElemType
Defines an enum for geometric element types.
void elem_types(const MeshBase &mesh, std::vector< ElemType > &et)
Fills in a vector of all element types in the mesh.
Definition: mesh_tools.C:716
const std::set< boundary_id_type > & get_side_boundary_ids() const
bool is_prepared() const
Definition: mesh_base.h:198
Order
defines an enum for polynomial orders.
Definition: enum_order.h:40
virtual dof_id_type n_active_elem() const =0
unsigned int n_threads()
Definition: libmesh_base.h:96
MPI_Info info
libMesh::BoundingBox create_bounding_box(const MeshBase &mesh)
Definition: mesh_tools.C:559
subdomain_id_type n_local_subdomains() const
Definition: mesh_base.C:1011
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:2019
void sum(T &r) const
const std::map< boundary_id_type, std::string > & get_sideset_name_map() const
dof_id_type n_local_nodes() const
Definition: mesh_base.h:442
const Parallel::Communicator & comm() const
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:165
dof_id_type n_local_elem() const
Definition: mesh_base.h:548
libMesh::BoundingBox create_local_bounding_box(const MeshBase &mesh)
Definition: mesh_tools.C:624
const std::set< boundary_id_type > & get_node_boundary_ids() const
Order supported_nodal_order() const
Definition: mesh_base.h:297
processor_id_type n_processors() const
const std::map< boundary_id_type, std::string > & get_nodeset_name_map() const
void min(const T &r, T &o, Request &req) const
const std::map< subdomain_id_type, std::string > & get_subdomain_name_map() const
Definition: mesh_base.h:1694
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:493
const Point & min() const
Definition: bounding_box.h:77
const std::map< boundary_id_type, std::string > & get_edgeset_name_map() const
std::set< Order > _elem_default_orders
We cache the (default) order of the geometric elements present in the mesh.
Definition: mesh_base.h:1984
libmesh_assert(ctx)
unsigned int n_elemsets() const
Returns the number of unique elemset ids which have been added via add_elemset_code(), which is the size of the _all_elemset_ids set.
Definition: mesh_base.C:424
std::set< unsigned char > _elem_dims
We cache the dimension of the elements present in the mesh.
Definition: mesh_base.h:1977
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 =...
Definition: mesh_tools.C:985
std::string enum_to_string(const T e)
unsigned int n_partitions() const
Definition: mesh_base.h:1345
subdomain_id_type n_subdomains() const
Definition: mesh_base.C:997
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void max(const T &r, T &o, Request &req) const
unsigned int spatial_dimension() const
Definition: mesh_base.C:543
const std::set< boundary_id_type > & get_edge_boundary_ids() const
virtual bool is_replicated() const
Definition: mesh_base.h:233
virtual dof_id_type n_elem() const =0
processor_id_type processor_id() const
virtual dof_id_type n_nodes() const =0
void set_union(T &data, const unsigned int root_id) const

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

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

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

2385 {
2386  std::ostringstream os;
2387 
2388  if (print_nonlocal)
2389  os << "All ";
2390  else
2391  os << "Local ";
2392 
2393  os << "Mesh Constraint Rows:"
2394  << std::endl;
2395 
2396  for (const auto & [node, row] : _constraint_rows)
2397  {
2398  const bool local = (node->processor_id() == this->processor_id());
2399 
2400  // Skip non-local dofs if requested
2401  if (!print_nonlocal && !local)
2402  continue;
2403 
2404  os << "Constraints for " << (local ? "Local" : "Ghost") << " Node " << node->id()
2405  << ": \t";
2406 
2407  for (const auto & [elem_and_node, coef] : row)
2408  os << " ((" << elem_and_node.first->id() << ',' << elem_and_node.second << "), " << coef << ")\t";
2409 
2410  os << std::endl;
2411  }
2412 
2413  return os.str();
2414 }
constraint_rows_type _constraint_rows
Definition: mesh_base.h:2104
processor_id_type processor_id() const

◆ get_mesh_subdomains()

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

Definition at line 1814 of file mesh_base.h.

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

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

◆ get_node_integer_index()

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

Definition at line 715 of file mesh_base.C.

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

716 {
717  for (auto i : index_range(_node_integer_names))
718  if (_node_integer_names[i] == name)
719  return i;
720 
721  libmesh_error_msg("Unknown node integer " << name);
722  return libMesh::invalid_uint;
723 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
Definition: libmesh.h:310
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:2045
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:117

◆ get_node_integer_name()

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

Definition at line 1066 of file mesh_base.h.

References libMesh::MeshBase::_node_integer_names.

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

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

◆ get_point_locator_close_to_point_tol()

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

Definition at line 1933 of file mesh_base.C.

References libMesh::MeshBase::_point_locator_close_to_point_tol.

1934 {
1936 }
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:2110

◆ get_subdomain_name_map()

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

Definition at line 1694 of file mesh_base.h.

References libMesh::MeshBase::_block_id_to_name.

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

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

◆ ghosting_functors_begin()

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

Beginning of range of ghosting functors.

Definition at line 1291 of file mesh_base.h.

References libMesh::MeshBase::_ghosting_functors.

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

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

◆ ghosting_functors_end()

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

End of range of ghosting functors.

Definition at line 1297 of file mesh_base.h.

References libMesh::MeshBase::_ghosting_functors.

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

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

◆ has_elem_integer()

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

Definition at line 638 of file mesh_base.C.

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

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

639 {
640  for (auto & entry : _elem_integer_names)
641  if (entry == name)
642  return true;
643 
644  return false;
645 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
std::vector< std::string > _elem_integer_names
The array of names for integer data associated with each element in the mesh.
Definition: mesh_base.h:2033

◆ has_node_integer()

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

Definition at line 727 of file mesh_base.C.

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

Referenced by ExtraIntegersTest::checkpoint_helper().

728 {
729  for (auto & entry : _node_integer_names)
730  if (entry == name)
731  return true;
732 
733  return false;
734 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
std::vector< std::string > _node_integer_names
The array of names for integer data associated with each node in the mesh.
Definition: mesh_base.h:2045

◆ insert_elem() [1/2]

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

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

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

Implements libMesh::MeshBase.

Definition at line 656 of file distributed_mesh.C.

References libMesh::MeshBase::_elem_integer_default_values, libMesh::MeshBase::_elem_integer_names, _elements, _n_elem, libMesh::MeshBase::_next_unique_id, _next_unpartitioned_unique_id, libMesh::DofObject::add_extra_integers(), libMesh::MeshBase::default_mapping_data(), libMesh::MeshBase::default_mapping_type(), delete_elem(), libMesh::DofObject::id(), libMesh::DofObject::invalid_processor_id, libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::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 insert_elem().

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  // Make sure any new element is given space for any extra integers
693  // we've requested
694  e->add_extra_integers(_elem_integer_names.size(),
696 
697  // And set mapping type and data on any new element
698  e->set_mapping_type(this->default_mapping_type());
699  e->set_mapping_data(this->default_mapping_data());
700 
701  return e;
702 }
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:2033
virtual void delete_elem(Elem *e) override final
Removes element e from the mesh.
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:812
unique_id_type _next_unique_id
The next available unique id for assigning ids to DOF objects.
Definition: mesh_base.h:1925
uint8_t processor_id_type
processor_id_type n_processors() const
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:493
unsigned char default_mapping_data() const
Returns any default data value used by the master space to physical space mapping.
Definition: mesh_base.h:830
dofobject_container< Elem > _elements
The elements 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...
Definition: mesh_base.h:2039
unique_id_type _next_unpartitioned_unique_id
The next available unique id for assigning ids to unpartitioned DOF objects.
processor_id_type processor_id() const

◆ insert_elem() [2/2]

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

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 704 of file distributed_mesh.C.

References insert_elem().

705 {
706  // The mesh now takes ownership of the Elem. Eventually the guts of
707  // insert_elem(Elem*) will get moved to a private helper function, and
708  // calling insert_elem(Elem*) directly will be deprecated.
709  return insert_elem(e.release());
710 }
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...

◆ insert_node() [1/2]

Node * libMesh::DistributedMesh::insert_node ( Node n)
finaloverridevirtual

These methods are deprecated.

Please use add_node instead Calls add_node().

Implements libMesh::MeshBase.

Definition at line 917 of file distributed_mesh.C.

References add_node().

Referenced by insert_node().

918 {
919  libmesh_deprecated();
920  return DistributedMesh::add_node(n);
921 }
virtual Node * add_node(Node *n) override final
Add Node n to the end of the vertex array.

◆ insert_node() [2/2]

Node * libMesh::DistributedMesh::insert_node ( std::unique_ptr< Node n)
finaloverridevirtual

This method is deprecated.

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

Implements libMesh::MeshBase.

Definition at line 923 of file distributed_mesh.C.

References insert_node().

924 {
925  libmesh_deprecated();
926  return insert_node(n.release());
927 }
virtual Node * insert_node(Node *n) override final
These methods are deprecated.

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

References libMesh::MeshBase::_interior_mesh.

Referenced by libMesh::BoundaryInfo::add_elements(), and libMesh::MeshBase::detect_interior_parents().

1797 { return *_interior_mesh; }
MeshBase * _interior_mesh
Defaulting to this, a pointer to the mesh used to generate boundary elements on this.
Definition: mesh_base.h:1932

◆ interior_mesh() [2/2]

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

Definition at line 1802 of file mesh_base.h.

References libMesh::MeshBase::_interior_mesh.

1802 { return *_interior_mesh; }
MeshBase * _interior_mesh
Defaulting to this, a pointer to the mesh used to generate boundary elements on this.
Definition: mesh_base.h:1932

◆ is_prepared()

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

◆ is_replicated()

virtual bool libMesh::DistributedMesh::is_replicated ( ) const
inlinefinaloverridevirtual
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
inlinefinaloverridevirtual
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.

References _is_serial.

Referenced by redistribute().

161  { return _is_serial; }
bool _is_serial
A boolean remembering whether we&#39;re serialized or not.

◆ is_serial_on_zero()

virtual bool libMesh::DistributedMesh::is_serial_on_zero ( ) const
inlinefinaloverridevirtual
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.

References _is_serial, and _is_serial_on_proc_0.

168  { return _is_serial || _is_serial_on_proc_0; }
bool _is_serial_on_proc_0
A boolean remembering whether we&#39;re serialized to proc 0 or not.
bool _is_serial
A boolean remembering whether we&#39;re serialized or not.

◆ libmesh_assert_valid_parallel_flags()

void libMesh::DistributedMesh::libmesh_assert_valid_parallel_flags ( ) const

Verify refinement_flag and p_refinement_flag consistency of our elements containers.

Calls libmesh_assert() on each possible failure.

Definition at line 1177 of file distributed_mesh.C.

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

Referenced by allgather(), delete_remote_elements(), and renumber_nodes_and_elements().

1178 {
1179 #if defined(LIBMESH_ENABLE_AMR) && !defined(NDEBUG)
1180  // This function must be run on all processors at once
1181  parallel_object_only();
1182 
1183  dof_id_type pmax_elem_id = this->parallel_max_elem_id();
1184 
1185  for (dof_id_type i=0; i != pmax_elem_id; ++i)
1186  {
1187  Elem * el = _elements[i]; // Returns nullptr if there's no map entry
1188 
1189  unsigned int refinement_flag = el ?
1190  static_cast<unsigned int> (el->refinement_flag()) : libMesh::invalid_uint;
1191  unsigned int p_refinement_flag = el ?
1192  static_cast<unsigned int> (el->p_refinement_flag()) : libMesh::invalid_uint;
1193 
1194  libmesh_assert(this->comm().semiverify(el ? &refinement_flag : nullptr));
1195 
1196  // p refinement flags aren't always kept correct on inactive
1197  // ghost elements
1198  libmesh_assert(this->comm().semiverify((el && el->active()) ? &p_refinement_flag : nullptr));
1199  }
1200 #endif // LIBMESH_ENABLE_AMR
1201 }
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:310
const Parallel::Communicator & comm() const
libmesh_assert(ctx)
dofobject_container< Elem > _elements
The elements in the mesh.
dof_id_type parallel_max_elem_id() const
uint8_t dof_id_type
Definition: id_types.h:67

◆ libmesh_assert_valid_parallel_ids()

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

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 1146 of file distributed_mesh.C.

References _elements, and libmesh_assert_valid_parallel_object_ids().

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

1147 {
1150 }
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...
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.

◆ libmesh_assert_valid_parallel_object_ids()

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

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 1090 of file distributed_mesh.C.

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

Referenced by libmesh_assert_valid_parallel_ids().

1091 {
1092  // This function must be run on all processors at once
1093  parallel_object_only();
1094 
1095  const dof_id_type pmax_node_id = this->parallel_max_node_id();
1096  const dof_id_type pmax_elem_id = this->parallel_max_elem_id();
1097  const dof_id_type pmax_id = std::max(pmax_node_id, pmax_elem_id);
1098 
1099  for (dof_id_type i=0; i != pmax_id; ++i)
1100  {
1101  T * obj = objects[i]; // Returns nullptr if there's no map entry
1102 
1103  // Local lookups by id should return the requested object
1104  libmesh_assert(!obj || obj->id() == i);
1105 
1106  // All processors with an object should agree on id
1107 #ifndef NDEBUG
1108  const dof_id_type dofid = obj && obj->valid_id() ?
1109  obj->id() : DofObject::invalid_id;
1110  libmesh_assert(this->comm().semiverify(obj ? &dofid : nullptr));
1111 #endif
1112 
1113  // All processors with an object should agree on processor id
1114  const dof_id_type procid = obj && obj->valid_processor_id() ?
1115  obj->processor_id() : DofObject::invalid_processor_id;
1116  libmesh_assert(this->comm().semiverify(obj ? &procid : nullptr));
1117 
1118  dof_id_type min_procid = procid;
1119  this->comm().min(min_procid);
1120 
1121  // Either:
1122  // 1.) I own this elem (min_procid == this->processor_id()) *and* I have a valid pointer to it (obj != nullptr)
1123  // or
1124  // 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.)
1125 
1126  // Original assert logic
1127  // libmesh_assert (min_procid != this->processor_id() || obj);
1128 
1129  // More human-understandable logic...
1130  libmesh_assert (
1131  ((min_procid == this->processor_id()) && obj)
1132  ||
1133  (min_procid != this->processor_id())
1134  );
1135 
1136 #if defined(LIBMESH_ENABLE_UNIQUE_ID) && !defined(NDEBUG)
1137  // All processors with an object should agree on unique id
1138  const unique_id_type uniqueid = obj ? obj->unique_id() : 0;
1139  libmesh_assert(this->comm().semiverify(obj ? &uniqueid : nullptr));
1140 #endif
1141  }
1142 }
const Parallel::Communicator & comm() const
void min(const T &r, T &o, Request &req) const
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:493
libmesh_assert(ctx)
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:482
dof_id_type parallel_max_node_id() const
processor_id_type processor_id() const
uint8_t unique_id_type
Definition: id_types.h:86
dof_id_type parallel_max_elem_id() const
uint8_t dof_id_type
Definition: id_types.h:67

◆ libmesh_assert_valid_parallel_p_levels()

void libMesh::DistributedMesh::libmesh_assert_valid_parallel_p_levels ( ) const

Verify p_level consistency of our elements containers.

Calls libmesh_assert() on each possible failure.

Definition at line 1154 of file distributed_mesh.C.

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

Referenced by renumber_nodes_and_elements().

1155 {
1156 #ifndef NDEBUG
1157  // This function must be run on all processors at once
1158  parallel_object_only();
1159 
1160  dof_id_type pmax_elem_id = this->parallel_max_elem_id();
1161 
1162  for (dof_id_type i=0; i != pmax_elem_id; ++i)
1163  {
1164  Elem * el = _elements[i]; // Returns nullptr if there's no map entry
1165 
1166  unsigned int p_level = el ? (el->p_level()) : libMesh::invalid_uint;
1167 
1168  // All processors with an active element should agree on p level
1169  libmesh_assert(this->comm().semiverify((el && el->active()) ? &p_level : nullptr));
1170  }
1171 #endif
1172 }
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:310
const Parallel::Communicator & comm() const
libmesh_assert(ctx)
dofobject_container< Elem > _elements
The elements in the mesh.
dof_id_type parallel_max_elem_id() const
uint8_t dof_id_type
Definition: id_types.h:67

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

References libMesh::MeshBase::_all_elemset_ids, libMesh::MeshBase::_allow_remote_element_removal, libMesh::MeshBase::_block_id_to_name, libMesh::MeshBase::_constraint_rows, libMesh::MeshBase::_count_lower_dim_elems_in_point_locator, libMesh::MeshBase::_default_ghosting, libMesh::MeshBase::_default_mapping_data, libMesh::MeshBase::_default_mapping_type, libMesh::MeshBase::_elem_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::_is_prepared, libMesh::MeshBase::_mesh_subdomains, libMesh::MeshBase::_n_parts, libMesh::MeshBase::_node_integer_default_values, libMesh::MeshBase::_node_integer_names, libMesh::MeshBase::_partitioner, libMesh::MeshBase::_point_locator_close_to_point_tol, libMesh::MeshBase::_skip_all_partitioning, libMesh::MeshBase::_skip_find_neighbors, libMesh::MeshBase::_skip_noncritical_partitioning, libMesh::MeshBase::_skip_renumber_nodes_and_elements, libMesh::MeshBase::_spatial_dimension, libMesh::MeshBase::_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==().

237 {
238  // Check whether (almost) everything in the base is equal
239  //
240  // We don't check _next_unique_id here, because it's expected to
241  // change in a DistributedMesh prepare_for_use(); it's conceptually
242  // "mutable".
243  //
244  // We use separate if statements instead of logical operators here,
245  // to make it easy to see the failing condition when using a
246  // debugger to figure out why a MeshTools::valid_is_prepared(mesh)
247  // is failing.
248  if (_n_parts != other_mesh._n_parts)
249  return false;
250  if (_default_mapping_type != other_mesh._default_mapping_type)
251  return false;
252  if (_default_mapping_data != other_mesh._default_mapping_data)
253  return false;
254  if (_is_prepared != other_mesh._is_prepared)
255  return false;
257  other_mesh._count_lower_dim_elems_in_point_locator)
258  return false;
259 
260  // We should either both have our own interior parents or both not;
261  // but if we both don't then we can't really assert anything else
262  // because pointing at the same interior mesh is fair but so is
263  // pointing at two different copies of "the same" interior mesh.
264  if ((_interior_mesh == this) !=
265  (other_mesh._interior_mesh == &other_mesh))
266  return false;
267 
268  if (_skip_noncritical_partitioning != other_mesh._skip_noncritical_partitioning)
269  return false;
270  if (_skip_all_partitioning != other_mesh._skip_all_partitioning)
271  return false;
272  if (_skip_renumber_nodes_and_elements != other_mesh._skip_renumber_nodes_and_elements)
273  return false;
274  if (_skip_find_neighbors != other_mesh._skip_find_neighbors)
275  return false;
276  if (_allow_remote_element_removal != other_mesh._allow_remote_element_removal)
277  return false;
278  if (_spatial_dimension != other_mesh._spatial_dimension)
279  return false;
280  if (_point_locator_close_to_point_tol != other_mesh._point_locator_close_to_point_tol)
281  return false;
282  if (_block_id_to_name != other_mesh._block_id_to_name)
283  return false;
284  if (_elem_dims != other_mesh._elem_dims)
285  return false;
286  if (_elem_default_orders != other_mesh._elem_default_orders)
287  return false;
288  if (_supported_nodal_order != other_mesh._supported_nodal_order)
289  return false;
290  if (_mesh_subdomains != other_mesh._mesh_subdomains)
291  return false;
292  if (_all_elemset_ids != other_mesh._all_elemset_ids)
293  return false;
294  if (_elem_integer_names != other_mesh._elem_integer_names)
295  return false;
296  if (_elem_integer_default_values != other_mesh._elem_integer_default_values)
297  return false;
298  if (_node_integer_names != other_mesh._node_integer_names)
299  return false;
300  if (_node_integer_default_values != other_mesh._node_integer_default_values)
301  return false;
302  if (bool(_default_ghosting) != bool(other_mesh._default_ghosting))
303  return false;
304  if (bool(_partitioner) != bool(other_mesh._partitioner))
305  return false;
306  if (*boundary_info != *other_mesh.boundary_info)
307  return false;
308 
309  const constraint_rows_type & other_rows =
310  other_mesh.get_constraint_rows();
311  for (const auto & [node, row] : this->_constraint_rows)
312  {
313  const dof_id_type node_id = node->id();
314  const Node * other_node = other_mesh.query_node_ptr(node_id);
315  if (!other_node)
316  return false;
317 
318  auto it = other_rows.find(other_node);
319  if (it == other_rows.end())
320  return false;
321 
322  const auto & other_row = it->second;
323  if (row.size() != other_row.size())
324  return false;
325 
326  for (auto i : index_range(row))
327  {
328  const auto & [elem_pair, coef] = row[i];
329  const auto & [other_elem_pair, other_coef] = other_row[i];
330  libmesh_assert(elem_pair.first);
331  libmesh_assert(other_elem_pair.first);
332  if (elem_pair.first->id() !=
333  other_elem_pair.first->id() ||
334  elem_pair.second !=
335  other_elem_pair.second ||
336  coef != other_coef)
337  return false;
338  }
339  }
340 
341  for (const auto & [elemset_code, elemset_ptr] : this->_elemset_codes)
342  if (const auto it = other_mesh._elemset_codes.find(elemset_code);
343  it == other_mesh._elemset_codes.end() || *elemset_ptr != *it->second)
344  return false;
345 
346  // FIXME: we have no good way to compare ghosting functors, since
347  // they're in a set sorted by pointer, and we have no way *at all*
348  // to compare ghosting functors, since they don't have operator==
349  // defined and we encourage users to subclass them. We can check if
350  // we have the same number, is all.
351  if (_ghosting_functors.size() !=
352  other_mesh._ghosting_functors.size())
353  return false;
354 
355  // Same deal for partitioners. We tested that we both have one or
356  // both don't, but are they equivalent? Let's guess "yes".
357 
358  // Now let the subclasses decide whether everything else is equal
359  return this->subclass_locally_equals(other_mesh);
360 }
std::set< subdomain_id_type > _mesh_subdomains
We cache the subdomain ids of the elements present in the mesh.
Definition: mesh_base.h:1995
virtual bool subclass_locally_equals(const MeshBase &other_mesh) const =0
Shim to allow operator == (&) to behave like a virtual function without having to be one...
bool _skip_renumber_nodes_and_elements
If this is true then renumbering will be kept to a minimum.
Definition: mesh_base.h:1950
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:2033
MeshBase * _interior_mesh
Defaulting to this, a pointer to the mesh used to generate boundary elements on this.
Definition: mesh_base.h:1932
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:2019
constraint_rows_type _constraint_rows
Definition: mesh_base.h:2104
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:1938
unsigned char _spatial_dimension
The "spatial dimension" of the Mesh.
Definition: mesh_base.h:2027
std::unique_ptr< BoundaryInfo > boundary_info
This class holds the boundary information.
Definition: mesh_base.h:1830
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:1963
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:2045
MeshBase::elemset_type _all_elemset_ids
Definition: mesh_base.h:2021
std::set< GhostingFunctor * > _ghosting_functors
The list of all GhostingFunctor objects to be used when distributing a DistributedMesh.
Definition: mesh_base.h:2086
unsigned int _n_parts
The number of partitions the mesh has.
Definition: mesh_base.h:1878
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:1891
ElemMappingType _default_mapping_type
The default mapping type (typically Lagrange) between master and physical space to assign to newly ad...
Definition: mesh_base.h:1884
std::unique_ptr< Partitioner > _partitioner
A partitioner to use at each prepare_for_use().
Definition: mesh_base.h:1919
std::set< Order > _elem_default_orders
We cache the (default) order of the geometric elements present in the mesh.
Definition: mesh_base.h:1984
libmesh_assert(ctx)
bool _skip_find_neighbors
If this is true then we will skip find_neighbors in prepare_for_use.
Definition: mesh_base.h:1955
Order _supported_nodal_order
We cache the maximum nodal order supported by all the mesh&#39;s elements (the minimum supported_nodal_or...
Definition: mesh_base.h:1990
std::set< unsigned char > _elem_dims
We cache the dimension of the elements present in the mesh.
Definition: mesh_base.h:1977
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:2051
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:2039
std::map< const Node *, constraint_rows_mapped_type > constraint_rows_type
Definition: mesh_base.h:1698
bool _is_prepared
Flag indicating if the mesh has been prepared for use.
Definition: mesh_base.h:1896
std::unique_ptr< GhostingFunctor > _default_ghosting
The default geometric GhostingFunctor, used to implement standard libMesh element ghosting behavior...
Definition: mesh_base.h:2077
bool _skip_all_partitioning
If this is true then no partitioning should be done.
Definition: mesh_base.h:1943
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:2110
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:1911
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:1970
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:117
uint8_t dof_id_type
Definition: id_types.h:67

◆ max_elem_id()

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

References _max_elem_id.

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

275 { return _max_elem_id; }

◆ max_node_id()

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

References _max_node_id.

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

271 { return _max_node_id; }

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

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

Referenced by libMesh::UnstructuredMesh::copy_nodes_and_elements(), and libMesh::UnstructuredMesh::create_submesh().

1959 {
1960  std::pair<std::vector<unsigned int>, std::vector<unsigned int>> returnval;
1961  returnval.first = this->add_elem_integers(other._elem_integer_names, true, &other._elem_integer_default_values);
1962  returnval.second = this->add_node_integers(other._node_integer_names, true, &other._node_integer_default_values);
1963  return returnval;
1964 }
std::vector< unsigned int > add_elem_integers(const std::vector< std::string > &names, bool allocate_data=true, const std::vector< dof_id_type > *default_values=nullptr)
Register integer data (of type dof_id_type) to be added to each element in the mesh, one string name for each new integer.
Definition: mesh_base.C:583
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:672

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

References libMesh::MeshBase::_elem_dims.

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

373 {
374  if (!_elem_dims.empty())
375  return cast_int<unsigned int>(*_elem_dims.rbegin());
376  return 0;
377 }
std::set< unsigned char > _elem_dims
We cache the dimension of the elements present in the mesh.
Definition: mesh_base.h:1977

◆ 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
finaloverridevirtual
Returns
The number of active elements in the mesh.

Implemented in terms of active_element_iterators.

Implements libMesh::MeshBase.

Definition at line 1703 of file distributed_mesh.C.

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

1704 {
1705  parallel_object_only();
1706 
1707  // Get local active elements first
1708  dof_id_type active_elements =
1709  static_cast<dof_id_type>(std::distance (this->active_local_elements_begin(),
1710  this->active_local_elements_end()));
1711  this->comm().sum(active_elements);
1712 
1713  // Then add unpartitioned active elements, which should exist on
1714  // every processor
1715  active_elements +=
1716  static_cast<dof_id_type>(std::distance
1717  (this->active_pid_elements_begin(DofObject::invalid_processor_id),
1718  this->active_pid_elements_end(DofObject::invalid_processor_id)));
1719  return active_elements;
1720 }
void sum(T &r) const
const Parallel::Communicator & comm() const
Real distance(const Point &p)
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:493
uint8_t dof_id_type
Definition: id_types.h:67

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

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

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

1050 {
1051  libmesh_assert_less (proc_id, this->n_processors());
1052  return static_cast<dof_id_type>(std::distance (this->active_pid_elements_begin(proc_id),
1053  this->active_pid_elements_end (proc_id)));
1054 }
Real distance(const Point &p)
processor_id_type n_processors() const
uint8_t dof_id_type
Definition: id_types.h:67

◆ n_active_local_elem()

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

◆ n_active_sub_elem()

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

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

Definition at line 1070 of file mesh_base.C.

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

1071 {
1072  dof_id_type ne=0;
1073 
1074  for (const auto & elem : this->active_element_ptr_range())
1075  ne += elem->n_sub_elem();
1076 
1077  return ne;
1078 }
uint8_t dof_id_type
Definition: id_types.h:67

◆ n_constraint_rows()

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

Definition at line 2044 of file mesh_base.C.

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

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

2045 {
2046  dof_id_type n_local_rows=0, n_unpartitioned_rows=0;
2047  for (const auto & [node, node_constraints] : _constraint_rows)
2048  {
2049  // Unpartitioned nodes
2050  if (node->processor_id() == DofObject::invalid_processor_id)
2051  n_unpartitioned_rows++;
2052  else if (node->processor_id() == this->processor_id())
2053  n_local_rows++;
2054  }
2055 
2056  this->comm().sum(n_local_rows);
2057 
2058  return n_unpartitioned_rows + n_local_rows;
2059 }
void sum(T &r) const
constraint_rows_type _constraint_rows
Definition: mesh_base.h:2104
const Parallel::Communicator & comm() const
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:493
processor_id_type processor_id() const
uint8_t dof_id_type
Definition: id_types.h:67

◆ n_elem()

virtual dof_id_type libMesh::DistributedMesh::n_elem ( ) const
inlinefinaloverridevirtual
Returns
The number of elements in the mesh.

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

Implements libMesh::MeshBase.

Definition at line 273 of file distributed_mesh.h.

References _n_elem.

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

273 { return _n_elem; }

◆ n_elem_integers()

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

Definition at line 955 of file mesh_base.h.

References libMesh::MeshBase::_elem_integer_names.

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

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

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

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

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

1037 {
1038  // We're either counting a processor's elements or unpartitioned
1039  // elements
1040  libmesh_assert (proc_id < this->n_processors() ||
1041  proc_id == DofObject::invalid_processor_id);
1042 
1043  return static_cast<dof_id_type>(std::distance (this->pid_elements_begin(proc_id),
1044  this->pid_elements_end (proc_id)));
1045 }
Real distance(const Point &p)
processor_id_type n_processors() const
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:493
libmesh_assert(ctx)
uint8_t dof_id_type
Definition: id_types.h:67

◆ n_elemsets()

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

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

Definition at line 424 of file mesh_base.C.

References libMesh::MeshBase::_all_elemset_ids.

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

425 {
426  return _all_elemset_ids.size();
427 }
MeshBase::elemset_type _all_elemset_ids
Definition: mesh_base.h:2021

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

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

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

549  { 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:1036
processor_id_type processor_id() const

◆ n_local_nodes()

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

Definition at line 442 of file mesh_base.h.

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

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

443  { 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:1023
processor_id_type processor_id() const

◆ n_local_subdomains()

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

Definition at line 1011 of file mesh_base.C.

References libMesh::MeshBase::subdomain_ids().

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

1012 {
1013  std::set<subdomain_id_type> ids;
1014 
1015  this->subdomain_ids (ids, /* global = */ false);
1016 
1017  return cast_int<subdomain_id_type>(ids.size());
1018 }
void subdomain_ids(std::set< subdomain_id_type > &ids, const bool global=true) const
Constructs a list of all subdomain identifiers in the local mesh if global == false, and in the global mesh if global == true (default).
Definition: mesh_base.C:959

◆ n_node_integers()

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

Definition at line 1077 of file mesh_base.h.

References libMesh::MeshBase::_node_integer_names.

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

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

◆ n_nodes()

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

References _n_nodes.

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

270 { return _n_nodes; }
dof_id_type _n_nodes
Cached data from the last renumber_nodes_and_elements call.

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

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

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

1024 {
1025  // We're either counting a processor's nodes or unpartitioned
1026  // nodes
1027  libmesh_assert (proc_id < this->n_processors() ||
1028  proc_id == DofObject::invalid_processor_id);
1029 
1030  return static_cast<dof_id_type>(std::distance (this->pid_nodes_begin(proc_id),
1031  this->pid_nodes_end (proc_id)));
1032 }
Real distance(const Point &p)
processor_id_type n_processors() const
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:493
libmesh_assert(ctx)
uint8_t dof_id_type
Definition: id_types.h:67

◆ n_partitions()

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

Definition at line 1345 of file mesh_base.h.

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

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

◆ n_processors()

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

Definition at line 103 of file parallel_object.h.

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

Referenced by libMesh::Partitioner::_find_global_index_by_pid_map(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::DofMap::add_constraints_to_send_list(), libMesh::PetscDMWrapper::add_dofs_to_section(), add_elem(), libMesh::DofMap::add_neighbors_to_send_list(), 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(), clear(), 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::DofMap::distribute_dofs(), libMesh::DofMap::distribute_scalar_dofs(), DistributedMesh(), libMesh::EnsightIO::EnsightIO(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::MeshBase::get_info(), libMesh::StaticCondensation::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_petscdm(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize(), insert_elem(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_elem_on_proc(), libMesh::DofMap::n_dofs_per_processor(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::Partitioner::partition(), libMesh::MeshBase::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::DofMap::prepare_send_list(), libMesh::MeshBase::print_constraint_rows(), libMesh::DofMap::print_dof_constraints(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::XdrIO::read_header(), libMesh::CheckpointIO::read_nodes(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::System::read_serialized_vector(), renumber_dof_objects(), libMesh::Partitioner::repartition(), OverlappingFunctorTest::run_partitioner_test(), libMesh::DofMap::scatter_constraints(), set_next_unique_id(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), WriteVecAndScalar::setupTests(), libMesh::RBEIMEvaluation::side_gather_bfs(), DistributedMeshTest::testRemoteElemError(), CheckpointIOTest::testSplitter(), libMesh::MeshRefinement::uniformly_coarsen(), update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::VTKIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

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

◆ n_sub_elem()

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

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

Definition at line 1058 of file mesh_base.C.

1059 {
1060  dof_id_type ne=0;
1061 
1062  for (const auto & elem : this->element_ptr_range())
1063  ne += elem->n_sub_elem();
1064 
1065  return ne;
1066 }
uint8_t dof_id_type
Definition: id_types.h:67

◆ n_subdomains()

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

Definition at line 997 of file mesh_base.C.

References libMesh::MeshBase::subdomain_ids().

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

998 {
999  // This requires an inspection on every processor
1000  parallel_object_only();
1001 
1002  std::set<subdomain_id_type> ids;
1003 
1004  this->subdomain_ids (ids);
1005 
1006  return cast_int<subdomain_id_type>(ids.size());
1007 }
void subdomain_ids(std::set< subdomain_id_type > &ids, const bool global=true) const
Constructs a list of all subdomain identifiers in the local mesh if global == false, and in the global mesh if global == true (default).
Definition: mesh_base.C:959

◆ n_unpartitioned_elem()

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

Definition at line 554 of file mesh_base.h.

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

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

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

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

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

Referenced by parallel_n_nodes().

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

◆ next_unique_id()

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

Definition at line 461 of file mesh_base.h.

References libMesh::MeshBase::_next_unique_id.

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

◆ node_ptr() [1/2]

const Node * libMesh::DistributedMesh::node_ptr ( const dof_id_type  i) const
finaloverridevirtual
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 426 of file distributed_mesh.C.

References _nodes, and libMesh::libmesh_assert().

Referenced by fix_broken_node_and_element_numbering(), and ExodusTest< elem_type >::meshes_equal_enough().

427 {
429  libmesh_assert_equal_to (_nodes[i]->id(), i);
430 
431  return _nodes[i];
432 }
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.
libmesh_assert(ctx)

◆ node_ptr() [2/2]

Node * libMesh::DistributedMesh::node_ptr ( const dof_id_type  i)
finaloverridevirtual
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 437 of file distributed_mesh.C.

References _nodes, and libMesh::libmesh_assert().

438 {
440  libmesh_assert_equal_to (_nodes[i]->id(), i);
441 
442  return _nodes[i];
443 }
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.
libmesh_assert(ctx)

◆ node_ref() [1/2]

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

◆ node_ref() [2/2]

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

Definition at line 605 of file mesh_base.h.

References libMesh::MeshBase::node_ptr().

606  {
607  return *this->node_ptr(i);
608  }
virtual const Node * node_ptr(const dof_id_type i) const =0

◆ nodes_and_elements_equal()

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

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

Helper function for subclass_equals() in unstructured mesh subclasses.

Definition at line 2014 of file mesh_base.C.

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

2015 {
2016  for (const auto & other_node : other_mesh.node_ptr_range())
2017  {
2018  const Node * node = this->query_node_ptr(other_node->id());
2019  if (!node)
2020  return false;
2021  if (*other_node != *node)
2022  return false;
2023  }
2024  for (const auto & node : this->node_ptr_range())
2025  if (!other_mesh.query_node_ptr(node->id()))
2026  return false;
2027 
2028  for (const auto & other_elem : other_mesh.element_ptr_range())
2029  {
2030  const Elem * elem = this->query_elem_ptr(other_elem->id());
2031  if (!elem)
2032  return false;
2033  if (!other_elem->topologically_equal(*elem))
2034  return false;
2035  }
2036  for (const auto & elem : this->element_ptr_range())
2037  if (!other_mesh.query_elem_ptr(elem->id()))
2038  return false;
2039 
2040  return true;
2041 }
virtual const Node * query_node_ptr(const dof_id_type i) const =0
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0

◆ operator!=()

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

Definition at line 133 of file mesh_base.h.

134  {
135  return !(*this == other_mesh);
136  }

◆ operator=() [1/2]

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

Copy assignment is not allowed.

◆ operator=() [2/2]

DistributedMesh& libMesh::DistributedMesh::operator= ( DistributedMesh &&  other_mesh)

Overloaded operator= will move contents of other_mesh to calling DistributedMesh object.

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

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

227 {
228  LOG_SCOPE("operator==()", "MeshBase");
229 
230  bool is_equal = this->locally_equals(other_mesh);
231  this->comm().min(is_equal);
232  return is_equal;
233 }
const Parallel::Communicator & comm() const
void min(const T &r, T &o, Request &req) const
bool locally_equals(const MeshBase &other_mesh) const
This behaves the same as operator==, but only for the local and ghosted aspects of the mesh; i...
Definition: mesh_base.C:236

◆ own_node()

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

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 788 of file distributed_mesh.C.

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

789 {
790  // This had better be a node in our mesh
791  libmesh_assert(_nodes[n.id()] == &n);
792 
793  _nodes[n.id()] = nullptr;
794  _n_nodes--;
795 
796  n.set_id(DofObject::invalid_id);
797  n.processor_id() = this->processor_id();
798 
799  this->add_node(&n);
800 }
dof_id_type _n_nodes
Cached data from the last renumber_nodes_and_elements call.
virtual Node * add_node(Node *n) override final
Add Node n to the end of the vertex array.
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.
libmesh_assert(ctx)
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:482
processor_id_type processor_id() const

◆ parallel_max_elem_id()

dof_id_type libMesh::DistributedMesh::parallel_max_elem_id ( ) const

Definition at line 312 of file distributed_mesh.C.

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

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

313 {
314  // This function must be run on all processors at once
315  parallel_object_only();
316 
317  dof_id_type max_local = 0;
318 
319  dofobject_container<Elem>::const_reverse_veclike_iterator
320  rit = _elements.rbegin();
321 
322  const dofobject_container<Elem>::const_reverse_veclike_iterator
323  rend = _elements.rend();
324 
325  // Look for the maximum element id. Search backwards through
326  // elements so we can break out early. Beware of nullptr entries that
327  // haven't yet been cleared from _elements.
328  for (; rit != rend; ++rit)
329  {
330  const DofObject *d = *rit;
331  if (d)
332  {
333  libmesh_assert(_elements[d->id()] == d);
334  max_local = d->id() + 1;
335  break;
336  }
337  }
338 
339  this->comm().max(max_local);
340  return max_local;
341 }
const Parallel::Communicator & comm() const
libmesh_assert(ctx)
dofobject_container< Elem > _elements
The elements in the mesh.
void max(const T &r, T &o, Request &req) const
uint8_t dof_id_type
Definition: id_types.h:67

◆ parallel_max_node_id()

dof_id_type libMesh::DistributedMesh::parallel_max_node_id ( ) const

Definition at line 386 of file distributed_mesh.C.

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

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

387 {
388  // This function must be run on all processors at once
389  parallel_object_only();
390 
391  dof_id_type max_local = 0;
392 
393  dofobject_container<Node>::const_reverse_veclike_iterator
394  rit = _nodes.rbegin();
395 
396  const dofobject_container<Node>::const_reverse_veclike_iterator
397  rend = _nodes.rend();
398 
399  // Look for the maximum node id. Search backwards through
400  // nodes so we can break out early. Beware of nullptr entries that
401  // haven't yet been cleared from _nodes
402  for (; rit != rend; ++rit)
403  {
404  const DofObject *d = *rit;
405  if (d)
406  {
407  libmesh_assert(_nodes[d->id()] == d);
408  max_local = d->id() + 1;
409  break;
410  }
411  }
412 
413  this->comm().max(max_local);
414  return max_local;
415 }
const Parallel::Communicator & comm() const
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.
libmesh_assert(ctx)
void max(const T &r, T &o, Request &req) const
uint8_t dof_id_type
Definition: id_types.h:67

◆ parallel_max_unique_id()

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

Implements libMesh::MeshBase.

Definition at line 346 of file distributed_mesh.C.

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

Referenced by update_parallel_id_counts().

347 {
348  // This function must be run on all processors at once
349  parallel_object_only();
350 
351  unique_id_type max_local = std::max(_next_unique_id,
353  this->comm().max(max_local);
354  return max_local;
355 }
const Parallel::Communicator & comm() const
unique_id_type _next_unique_id
The next available unique id for assigning ids to DOF objects.
Definition: mesh_base.h:1925
void max(const T &r, T &o, Request &req) const
unique_id_type _next_unpartitioned_unique_id
The next available unique id for assigning ids to unpartitioned DOF objects.
uint8_t unique_id_type
Definition: id_types.h:86

◆ parallel_n_elem()

dof_id_type libMesh::DistributedMesh::parallel_n_elem ( ) const
overridevirtual
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 299 of file distributed_mesh.C.

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

Referenced by allgather(), delete_remote_elements(), renumber_nodes_and_elements(), and update_parallel_id_counts().

300 {
301  // This function must be run on all processors at once
302  parallel_object_only();
303 
304  dof_id_type n_local = this->n_local_elem();
305  this->comm().sum(n_local);
306  n_local += this->n_unpartitioned_elem();
307  return n_local;
308 }
void sum(T &r) const
const Parallel::Communicator & comm() const
dof_id_type n_unpartitioned_elem() const
Definition: mesh_base.h:554
dof_id_type n_local_elem() const
Definition: mesh_base.h:548
uint8_t dof_id_type
Definition: id_types.h:67

◆ parallel_n_nodes()

dof_id_type libMesh::DistributedMesh::parallel_n_nodes ( ) const
overridevirtual
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 373 of file distributed_mesh.C.

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

Referenced by allgather(), delete_remote_elements(), renumber_nodes_and_elements(), and update_parallel_id_counts().

374 {
375  // This function must be run on all processors at once
376  parallel_object_only();
377 
378  dof_id_type n_local = this->n_local_nodes();
379  this->comm().sum(n_local);
380  n_local += this->n_unpartitioned_nodes();
381  return n_local;
382 }
dof_id_type n_unpartitioned_nodes() const
Definition: mesh_base.h:448
void sum(T &r) const
dof_id_type n_local_nodes() const
Definition: mesh_base.h:442
const Parallel::Communicator & comm() const
uint8_t dof_id_type
Definition: id_types.h:67

◆ partition() [1/2]

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

Call the default partitioner (currently metis_partition()).

Definition at line 1576 of file mesh_base.C.

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

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

1577 {
1578  // If we get here and we have unpartitioned elements, we need that
1579  // fixed.
1580  if (this->n_unpartitioned_elem() > 0)
1581  {
1582  libmesh_assert (partitioner().get());
1583  libmesh_assert (this->is_serial());
1584  partitioner()->partition (*this, n_parts);
1585  }
1586  // A nullptr partitioner or a skip_partitioning(true) call or a
1587  // skip_noncritical_partitioning(true) call means don't repartition;
1588  // skip_noncritical_partitioning() checks all these.
1589  else if (!skip_noncritical_partitioning())
1590  {
1591  partitioner()->partition (*this, n_parts);
1592  }
1593  else
1594  {
1595  // Adaptive coarsening may have "orphaned" nodes on processors
1596  // whose elements no longer share them. We need to check for
1597  // and possibly fix that.
1599 
1600  // Make sure locally cached partition count is correct
1601  this->recalculate_n_partitions();
1602 
1603  // Make sure any other locally cached data is correct
1604  this->update_post_partitioning();
1605  }
1606 }
void correct_node_proc_ids(MeshBase &)
Changes the processor ids on each node so be the same as the id of the lowest element touching that n...
Definition: mesh_tools.C:2393
bool skip_noncritical_partitioning() const
Definition: mesh_base.h:1239
virtual std::unique_ptr< Partitioner > & partitioner()
A partitioner to use at each prepare_for_use()
Definition: mesh_base.h:160
dof_id_type n_unpartitioned_elem() const
Definition: mesh_base.h:554
virtual bool is_serial() const
Definition: mesh_base.h:211
libmesh_assert(ctx)
unsigned int recalculate_n_partitions()
In a few (very rare) cases, the user may have manually tagged the elements with specific processor ID...
Definition: mesh_base.C:1618
virtual void update_post_partitioning()
Recalculate any cached data after elements and nodes have been repartitioned.
Definition: mesh_base.h:1177

◆ partition() [2/2]

void libMesh::MeshBase::partition ( )
inlineinherited

Definition at line 1162 of file mesh_base.h.

References libMesh::ParallelObject::n_processors().

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

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

◆ partitioner()

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

A partitioner to use at each prepare_for_use()

Definition at line 160 of file mesh_base.h.

References libMesh::MeshBase::_partitioner.

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

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

◆ point()

const Point & libMesh::DistributedMesh::point ( const dof_id_type  i) const
finaloverridevirtual
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 419 of file distributed_mesh.C.

References libMesh::MeshBase::node_ref().

420 {
421  return this->node_ref(i);
422 }
virtual const Node & node_ref(const dof_id_type i) const
Definition: mesh_base.h:596

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

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

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

1970 {
1971  // Now that all the DofObject moving is done, we can move the GhostingFunctor objects
1972  // which include the _default_ghosting,_ghosting_functors and _shared_functors. We also need
1973  // to set the mesh object associated with these functors to the assignee mesh.
1974 
1975  // _default_ghosting
1976  _default_ghosting = std::move(other_mesh._default_ghosting);
1977  _default_ghosting->set_mesh(this);
1978 
1979  // _ghosting_functors
1980  _ghosting_functors = std::move(other_mesh._ghosting_functors);
1981 
1982  for (const auto gf : _ghosting_functors )
1983  {
1984  gf->set_mesh(this);
1985  }
1986 
1987  // _shared_functors
1988  _shared_functors = std::move(other_mesh._shared_functors);
1989 
1990  for (const auto & sf : _shared_functors )
1991  {
1992  (sf.second)->set_mesh(this);
1993  }
1994 
1995  // _constraint_rows
1996  _constraint_rows = std::move(other_mesh._constraint_rows);
1997 
1998  if (other_mesh.partitioner())
1999  _partitioner = std::move(other_mesh.partitioner());
2000 }
constraint_rows_type _constraint_rows
Definition: mesh_base.h:2104
std::set< GhostingFunctor * > _ghosting_functors
The list of all GhostingFunctor objects to be used when distributing a DistributedMesh.
Definition: mesh_base.h:2086
std::unique_ptr< Partitioner > _partitioner
A partitioner to use at each prepare_for_use().
Definition: mesh_base.h:1919
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:2092
std::unique_ptr< GhostingFunctor > _default_ghosting
The default geometric GhostingFunctor, used to implement standard libMesh element ghosting behavior...
Definition: mesh_base.h:2077

◆ prepare_for_use() [1/3]

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

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

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

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

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

Definition at line 759 of file mesh_base.C.

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

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

760 {
761  libmesh_deprecated();
762 
763  // We only respect the users wish if they tell us to skip renumbering. If they tell us not to
764  // skip renumbering but someone previously called allow_renumbering(false), then the latter takes
765  // precedence
766  if (skip_renumber_nodes_and_elements)
767  this->allow_renumbering(false);
768 
769  // We always accept the user's value for skip_find_neighbors, in contrast to skip_renumber
770  const bool old_allow_find_neighbors = this->allow_find_neighbors();
771  this->allow_find_neighbors(!skip_find_neighbors);
772 
773  this->prepare_for_use();
774 
775  this->allow_find_neighbors(old_allow_find_neighbors);
776 }
bool allow_find_neighbors() const
Definition: mesh_base.h:1204
void prepare_for_use()
Definition: mesh_base.C:794
bool allow_renumbering() const
Definition: mesh_base.h:1197

◆ prepare_for_use() [2/3]

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

Definition at line 778 of file mesh_base.C.

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

779 {
780  libmesh_deprecated();
781 
782  // We only respect the users wish if they tell us to skip renumbering. If they tell us not to
783  // skip renumbering but someone previously called allow_renumbering(false), then the latter takes
784  // precedence
785  if (skip_renumber_nodes_and_elements)
786  this->allow_renumbering(false);
787 
788  this->prepare_for_use();
789 }
void prepare_for_use()
Definition: mesh_base.C:794
bool allow_renumbering() const
Definition: mesh_base.h:1197

◆ prepare_for_use() [3/3]

void libMesh::MeshBase::prepare_for_use ( )
inherited

Definition at line 794 of file mesh_base.C.

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

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

795 {
796  LOG_SCOPE("prepare_for_use()", "MeshBase");
797 
798  parallel_object_only();
799 
800  libmesh_assert(this->comm().verify(this->is_serial()));
801 
802  // If we don't go into this method with valid constraint rows, we're
803  // only going to be able to make that worse.
804 #ifdef DEBUG
806 #endif
807 
808  // A distributed mesh may have processors with no elements (or
809  // processors with no elements of higher dimension, if we ever
810  // support mixed-dimension meshes), but we want consistent
811  // mesh_dimension anyways.
812  //
813  // cache_elem_data() should get the elem_dimensions() and
814  // mesh_dimension() correct later, and we don't need it earlier.
815 
816 
817  // Renumber the nodes and elements so that they in contiguous
818  // blocks. By default, _skip_renumber_nodes_and_elements is false.
819  //
820  // Instances where you if prepare_for_use() should not renumber the nodes
821  // and elements include reading in e.g. an xda/r or gmv file. In
822  // this case, the ordering of the nodes may depend on an accompanying
823  // solution, and the node ordering cannot be changed.
824 
825 
826  // Mesh modification operations might not leave us with consistent
827  // id counts, or might leave us with orphaned nodes we're no longer
828  // using, but our partitioner might need that consistency and/or
829  // might be confused by orphaned nodes.
832  else
833  {
834  this->remove_orphaned_nodes();
836  }
837 
838  // Let all the elements find their neighbors
840  this->find_neighbors();
841 
842  // The user may have set boundary conditions. We require that the
843  // boundary conditions were set consistently. Because we examine
844  // neighbors when evaluating non-raw boundary condition IDs, this
845  // assert is only valid when our neighbor links are in place.
846 #ifdef DEBUG
848 #endif
849 
850  // Search the mesh for all the dimensions of the elements
851  // and cache them.
852  this->cache_elem_data();
853 
854  // Search the mesh for elements that have a neighboring element
855  // of dim+1 and set that element as the interior parent
856  this->detect_interior_parents();
857 
858  // Fix up node unique ids in case mesh generation code didn't take
859  // exceptional care to do so.
860  // MeshCommunication().make_node_unique_ids_parallel_consistent(*this);
861 
862  // We're going to still require that mesh generation code gets
863  // element unique ids consistent.
864 #if defined(DEBUG) && defined(LIBMESH_ENABLE_UNIQUE_ID)
866 #endif
867 
868  // Reset our PointLocator. Any old locator is invalidated any time
869  // the elements in the underlying elements in the mesh have changed,
870  // so we clear it here.
871  this->clear_point_locator();
872 
873  // Allow our GhostingFunctor objects to reinit if necessary.
874  // Do this before partitioning and redistributing, and before
875  // deleting remote elements.
876  this->reinit_ghosting_functors();
877 
878  // Partition the mesh unless *all* partitioning is to be skipped.
879  // If only noncritical partitioning is to be skipped, the
880  // partition() call will still check for orphaned nodes.
881  if (!skip_partitioning())
882  this->partition();
883 
884  // If we're using DistributedMesh, we'll probably want it
885  // parallelized.
887  this->delete_remote_elements();
888 
889  // Much of our boundary info may have been for now-remote parts of the mesh,
890  // in which case we don't want to keep local copies of data meant to be
891  // local. On the other hand we may have deleted, or the user may have added in
892  // a distributed fashion, boundary data that is meant to be global. So we
893  // handle both of those scenarios here
895 
898 
899  // The mesh is now prepared for use.
900  _is_prepared = true;
901 
902 #ifdef DEBUG
904 #ifdef LIBMESH_ENABLE_UNIQUE_ID
906 #endif
907 #endif
908 }
bool _skip_renumber_nodes_and_elements
If this is true then renumbering will be kept to a minimum.
Definition: mesh_base.h:1950
void remove_orphaned_nodes()
Removes any orphaned nodes, nodes not connected to any elements.
Definition: mesh_base.C:738
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:1811
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...
Definition: mesh_tools.C:1665
const Parallel::Communicator & comm() const
bool _allow_remote_element_removal
If this is false then even on DistributedMesh remote elements will not be deleted during mesh prepara...
Definition: mesh_base.h:1963
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:165
virtual bool is_serial() const
Definition: mesh_base.h:211
virtual void find_neighbors(const bool reset_remote_elements=false, const bool reset_current_list=true)=0
Locate element face (edge in 2D) neighbors.
virtual void update_parallel_id_counts()=0
Updates parallel caches so that methods like n_elem() accurately reflect changes on other processors...
void cache_elem_data()
Definition: mesh_base.C:1733
void clear_point_locator()
Releases the current PointLocator object.
Definition: mesh_base.C:1671
libmesh_assert(ctx)
void libmesh_assert_valid_boundary_ids(const MeshBase &mesh)
A function for verifying that boundary condition ids match across processors.
Definition: mesh_tools.C:1708
bool _skip_find_neighbors
If this is true then we will skip find_neighbors in prepare_for_use.
Definition: mesh_base.h:1955
void regenerate_id_sets()
Clears and regenerates the cached sets of ids.
bool skip_partitioning() const
Definition: mesh_base.h:1256
bool _is_prepared
Flag indicating if the mesh has been prepared for use.
Definition: mesh_base.h:1896
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:253
void reinit_ghosting_functors()
Loops over ghosting functors and calls mesh_reinit()
Definition: mesh_base.C:911
void libmesh_assert_valid_unique_ids(const MeshBase &mesh)
A function for verifying that unique ids match across processors.
Definition: mesh_tools.C:1906
virtual void renumber_nodes_and_elements()=0
After partitioning a mesh it is useful to renumber the nodes and elements so that they lie in contigu...

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

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

2358 {
2359  parallel_object_only();
2360 
2361  std::string local_constraints =
2362  this->get_local_constraints(print_nonlocal);
2363 
2364  if (this->processor_id())
2365  {
2366  this->comm().send(0, local_constraints);
2367  }
2368  else
2369  {
2370  os << "Processor 0:\n";
2371  os << local_constraints;
2372 
2373  for (auto p : IntRange<processor_id_type>(1, this->n_processors()))
2374  {
2375  this->comm().receive(p, local_constraints);
2376  os << "Processor " << p << ":\n";
2377  os << local_constraints;
2378  }
2379  }
2380 }
const Parallel::Communicator & comm() const
processor_id_type n_processors() const
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_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:2384
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const
processor_id_type processor_id() const

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

References libMesh::MeshBase::get_info().

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

1563 {
1564  os << this->get_info(verbosity, global)
1565  << std::endl;
1566 }
std::string get_info(const unsigned int verbosity=0, const bool global=true) const
Definition: mesh_base.C:1082

◆ processor_id()

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

Definition at line 114 of file parallel_object.h.

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

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscDMWrapper::add_dofs_to_section(), add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DofMap::add_neighbors_to_send_list(), add_node(), libMesh::MeshTools::Modification::all_tri(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::Partitioner::assign_partitioning(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::Partitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::MeshFunction::check_found_elem(), clear(), 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(), delete_elem(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_scalar_dofs(), 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::DofMap::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(), insert_elem(), libMesh::DofMap::is_evaluable(), libMesh::SparsityPattern::Build::join(), libMesh::TransientRBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEvaluation::legacy_write_offline_data_to_files(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libmesh_assert_valid_parallel_object_ids(), libMesh::DofMap::local_variable_indices(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), AugmentSparsityOnInterface::mesh_reinit(), libMesh::TriangulatorInterface::MeshedHole::MeshedHole(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::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(), own_node(), libMesh::BoundaryInfo::parallel_sync_node_ids(), libMesh::BoundaryInfo::parallel_sync_side_ids(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::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::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read(), libMesh::EquationSystems::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_global_values(), libMesh::ExodusII_IO::read_header(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::DynaIO::read_mesh(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::System::read_parallel_data(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::System::read_serialized_data(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::Nemesis_IO_Helper::read_var_names_impl(), libMesh::SimplexRefiner::refine_via_edges(), libMesh::StaticCondensationDofMap::reinit(), renumber_dof_objects(), renumber_nodes_and_elements(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), set_next_unique_id(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::RBEIMEvaluation::side_gather_bfs(), ExodusTest< elem_type >::test_read_gold(), ExodusTest< elem_type >::test_write(), MeshInputTest::testAbaqusRead(), MeshInputTest::testBadGmsh(), 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(), MeshInputTest::testLowOrderEdgeBlocks(), SystemsTest::testProjectMatrix3D(), BoundaryInfoTest::testShellFaceConstraints(), MeshInputTest::testSingleElementImpl(), WriteVecAndScalar::testSolution(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), libMesh::MeshTools::total_weight(), libMesh::NetGenMeshInterface::triangulate(), libMesh::MeshRefinement::uniformly_coarsen(), update_parallel_id_counts(), libMesh::DTKAdapter::update_variable_values(), libMesh::MeshTools::volume(), libMesh::STLIO::write(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::CheckpointIO::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_element_values_element_major(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO_Helper::write_elemset_data(), libMesh::ExodusII_IO_Helper::write_elemsets(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), libMesh::System::write_header(), libMesh::ExodusII_IO::write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::UCDIO::write_nodal_data(), libMesh::VTKIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_common(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), libMesh::ExodusII_IO_Helper::write_nodeset_data(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::RBEIMEvaluation::write_out_interior_basis_functions(), libMesh::RBEIMEvaluation::write_out_node_basis_functions(), libMesh::RBEIMEvaluation::write_out_side_basis_functions(), write_output_solvedata(), libMesh::System::write_parallel_data(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::System::write_serialized_data(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), libMesh::ExodusII_IO_Helper::write_sideset_data(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), libMesh::ExodusII_IO_Helper::write_timestep(), and libMesh::ExodusII_IO::write_timestep_discontinuous().

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

◆ query_elem_ptr() [1/2]

const Elem * libMesh::DistributedMesh::query_elem_ptr ( const dof_id_type  i) const
finaloverridevirtual
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 502 of file distributed_mesh.C.

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

Referenced by subclass_locally_equals().

503 {
504  if (const auto it = _elements.find(i);
505  it != _elements.end())
506  {
507  const Elem * e = *it;
508  libmesh_assert (!e || e->id() == i);
509  return e;
510  }
511 
512  return nullptr;
513 }
libmesh_assert(ctx)
dofobject_container< Elem > _elements
The elements in the mesh.

◆ query_elem_ptr() [2/2]

Elem * libMesh::DistributedMesh::query_elem_ptr ( const dof_id_type  i)
finaloverridevirtual
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 518 of file distributed_mesh.C.

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

519 {
520  if (auto it = _elements.find(i);
521  it != _elements.end())
522  {
523  Elem * e = *it;
524  libmesh_assert (!e || e->id() == i);
525  return e;
526  }
527 
528  return nullptr;
529 }
libmesh_assert(ctx)
dofobject_container< Elem > _elements
The elements in the mesh.

◆ query_node_ptr() [1/2]

const Node * libMesh::DistributedMesh::query_node_ptr ( const dof_id_type  i) const
finaloverridevirtual
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 448 of file distributed_mesh.C.

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

Referenced by add_point().

449 {
450  if (const auto it = _nodes.find(i);
451  it != _nodes.end())
452  {
453  const Node * n = *it;
454  libmesh_assert (!n || n->id() == i);
455  return n;
456  }
457 
458  return nullptr;
459 }
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.
libmesh_assert(ctx)

◆ query_node_ptr() [2/2]

Node * libMesh::DistributedMesh::query_node_ptr ( const dof_id_type  i)
finaloverridevirtual
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 464 of file distributed_mesh.C.

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

465 {
466  if (auto it = _nodes.find(i);
467  it != _nodes.end())
468  {
469  Node * n = *it;
470  libmesh_assert (!n || n->id() == i);
471  return n;
472  }
473 
474  return nullptr;
475 }
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.
libmesh_assert(ctx)

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

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

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

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

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

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

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

1619 {
1620  // This requires an inspection on every processor
1621  parallel_object_only();
1622 
1623  unsigned int max_proc_id=0;
1624 
1625  for (const auto & elem : this->active_local_element_ptr_range())
1626  max_proc_id = std::max(max_proc_id, static_cast<unsigned int>(elem->processor_id()));
1627 
1628  // The number of partitions is one more than the max processor ID.
1629  _n_parts = max_proc_id+1;
1630 
1631  this->comm().max(_n_parts);
1632 
1633  return _n_parts;
1634 }
const Parallel::Communicator & comm() const
unsigned int _n_parts
The number of partitions the mesh has.
Definition: mesh_base.h:1878
void max(const T &r, T &o, Request &req) const

◆ redistribute()

void libMesh::DistributedMesh::redistribute ( )
overridevirtual

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.

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

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 
1056  this->update_parallel_id_counts();
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 void update_parallel_id_counts() override
Updates parallel caches so that methods like n_elem() accurately reflect changes on other processors...
friend class MeshCommunication
Make the MeshCommunication class a friend so that it can directly broadcast *_integer_names.
Definition: mesh_base.h:2134
virtual bool is_serial() const override final
virtual void redistribute()
Redistribute elements between processors.
Definition: mesh_base.C:985

◆ reinit_ghosting_functors()

void libMesh::MeshBase::reinit_ghosting_functors ( )
inherited

Loops over ghosting functors and calls mesh_reinit()

Definition at line 911 of file mesh_base.C.

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

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

912 {
913  for (auto & gf : _ghosting_functors)
914  {
915  libmesh_assert(gf);
916  gf->mesh_reinit();
917  }
918 }
std::set< GhostingFunctor * > _ghosting_functors
The list of all GhostingFunctor objects to be used when distributing a DistributedMesh.
Definition: mesh_base.h:2086
libmesh_assert(ctx)

◆ remove_ghosting_functor()

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

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

Definition at line 948 of file mesh_base.C.

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

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

949 {
950  _ghosting_functors.erase(&ghosting_functor);
951 
952  if (const auto it = _shared_functors.find(&ghosting_functor);
953  it != _shared_functors.end())
954  _shared_functors.erase(it);
955 }
std::set< GhostingFunctor * > _ghosting_functors
The list of all GhostingFunctor objects to be used when distributing a DistributedMesh.
Definition: mesh_base.h:2086
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:2092

◆ remove_orphaned_nodes()

void libMesh::MeshBase::remove_orphaned_nodes ( )
inherited

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

Typically done automatically in prepare_for_use

Definition at line 738 of file mesh_base.C.

References libMesh::MeshBase::delete_node().

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

739 {
740  LOG_SCOPE("remove_orphaned_nodes()", "MeshBase");
741 
742  // Will hold the set of nodes that are currently connected to elements
743  std::unordered_set<Node *> connected_nodes;
744 
745  // Loop over the elements. Find which nodes are connected to at
746  // least one of them.
747  for (const auto & element : this->element_ptr_range())
748  for (auto & n : element->node_ref_range())
749  connected_nodes.insert(&n);
750 
751  for (const auto & node : this->node_ptr_range())
752  if (!connected_nodes.count(node))
753  this->delete_node(node);
754 }
virtual void delete_node(Node *n)=0
Removes the Node n from the mesh.

◆ renumber_dof_objects()

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

Renumber a parallel objects container.

Returns
The smallest globally unused id for that container.

Definition at line 1207 of file distributed_mesh.C.

References TIMPI::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::MeshTools::Subdivision::next, pid, and libMesh::ParallelObject::processor_id().

Referenced by renumber_nodes_and_elements().

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

◆ renumber_elem()

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

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 748 of file distributed_mesh.C.

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

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

750 {
751  // This could be a no-op
752  if (old_id == new_id)
753  return;
754 
755  Elem * el = _elements[old_id];
756  libmesh_assert (el);
757  libmesh_assert_equal_to (el->id(), old_id);
758 
759  el->set_id(new_id);
760  libmesh_assert (!_elements[new_id]);
761  _elements[new_id] = el;
762  _elements.erase(old_id);
763 }
libmesh_assert(ctx)
dofobject_container< Elem > _elements
The elements in the mesh.

◆ renumber_node()

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

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.

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

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

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 }
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.
libmesh_assert(ctx)

◆ renumber_nodes_and_elements()

void libMesh::DistributedMesh::renumber_nodes_and_elements ( )
overridevirtual

Remove nullptr elements from arrays.

Implements libMesh::MeshBase.

Definition at line 1461 of file distributed_mesh.C.

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

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

◆ reserve_elem()

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

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)
inlinefinaloverridevirtual

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

References libMesh::MeshBase::_count_lower_dim_elems_in_point_locator.

1679 {
1680  _count_lower_dim_elems_in_point_locator = count_lower_dim_elems;
1681 }
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:1911

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

References libMesh::MeshBase::_default_mapping_data.

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

840  {
841  _default_mapping_data = data;
842  }
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:1891

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

References libMesh::MeshBase::_default_mapping_type.

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

822  {
823  _default_mapping_type = type;
824  }
ElemMappingType _default_mapping_type
The default mapping type (typically Lagrange) between master and physical space to assign to newly ad...
Definition: mesh_base.h:1884

◆ set_distributed()

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

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.

References _is_serial, and _is_serial_on_proc_0.

175  { _is_serial = false;
176  _is_serial_on_proc_0 = false; }
bool _is_serial_on_proc_0
A boolean remembering whether we&#39;re serialized to proc 0 or not.
bool _is_serial
A boolean remembering whether we&#39;re serialized or not.

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

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

382 {
383 #ifdef DEBUG
384  // In debug mode, we call cache_elem_data() and then make sure
385  // the result actually agrees with what the user specified.
386  parallel_object_only();
387 
388  this->cache_elem_data();
389  libmesh_assert_msg(_elem_dims == elem_dims, \
390  "Specified element dimensions does not match true element dimensions!");
391 #endif
392 
393  _elem_dims = std::move(elem_dims);
394 }
void cache_elem_data()
Definition: mesh_base.C:1733
std::set< unsigned char > _elem_dims
We cache the dimension of the elements present in the mesh.
Definition: mesh_base.h:1977

◆ set_interior_mesh()

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

Sets the interior mesh.

For advanced use only.

Definition at line 1807 of file mesh_base.h.

References libMesh::MeshBase::_interior_mesh.

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

1807 { _interior_mesh = &int_mesh; }
MeshBase * _interior_mesh
Defaulting to this, a pointer to the mesh used to generate boundary elements on this.
Definition: mesh_base.h:1932

◆ set_isnt_prepared()

void libMesh::MeshBase::set_isnt_prepared ( )
inlineinherited

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

Definition at line 204 of file mesh_base.h.

References libMesh::MeshBase::_is_prepared.

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

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

◆ set_mesh_dimension()

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

Resets the logical dimension of the mesh.

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

Definition at line 275 of file mesh_base.h.

References libMesh::MeshBase::_elem_dims.

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

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

◆ set_n_partitions()

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

Definition at line 1865 of file mesh_base.h.

References libMesh::MeshBase::_n_parts.

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

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

◆ set_next_unique_id()

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

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 359 of file distributed_mesh.C.

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

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

360 {
361  _next_unique_id = id;
363  ((_next_unique_id-1) / (this->n_processors() + 1) + 1) *
364  (this->n_processors() + 1) + this->n_processors();
366  ((_next_unique_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
367  (this->n_processors() + 1) + this->processor_id();
368 }
unique_id_type _next_unique_id
The next available unique id for assigning ids to DOF objects.
Definition: mesh_base.h:1925
processor_id_type n_processors() const
unique_id_type _next_unpartitioned_unique_id
The next available unique id for assigning ids to unpartitioned DOF objects.
processor_id_type processor_id() const

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

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

1920 {
1922  if (_point_locator)
1923  {
1924  if (val > 0.)
1925  _point_locator->set_close_to_point_tol(val);
1926  else
1927  _point_locator->unset_close_to_point_tol();
1928  }
1929 }
std::unique_ptr< PointLocatorBase > _point_locator
A PointLocator class for this mesh.
Definition: mesh_base.h:1905
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:2110

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

References libMesh::MeshBase::_spatial_dimension.

Referenced by libMesh::MeshTools::Modification::rotate(), MeshSpatialDimensionTest::test2D(), and InfFERadialTest::testRefinement().

551 {
552  // The user can set the _spatial_dimension however they wish,
553  // libMesh will only *increase* the spatial dimension, however,
554  // never decrease it.
555  _spatial_dimension = d;
556 }
unsigned char _spatial_dimension
The "spatial dimension" of the Mesh.
Definition: mesh_base.h:2027

◆ set_subdomain_name_map()

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

Definition at line 1692 of file mesh_base.h.

References libMesh::MeshBase::_block_id_to_name.

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

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

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

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

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

1941 {
1942  const std::size_t new_size = _elem_integer_names.size();
1943  for (auto elem : this->element_ptr_range())
1944  elem->add_extra_integers(new_size, _elem_integer_default_values);
1945 }
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:2033
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:2039

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

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

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

1950 {
1951  const std::size_t new_size = _node_integer_names.size();
1952  for (auto node : this->node_ptr_range())
1953  node->add_extra_integers(new_size, _node_integer_default_values);
1954 }
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:2045
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:2051

◆ skip_noncritical_partitioning() [1/2]

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

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

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

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

Definition at line 1236 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().

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

◆ skip_noncritical_partitioning() [2/2]

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

Definition at line 1239 of file mesh_base.h.

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

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

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

◆ skip_partitioning() [1/2]

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

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

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

Definition at line 1254 of file mesh_base.h.

References libMesh::MeshBase::_skip_all_partitioning.

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

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

◆ skip_partitioning() [2/2]

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

◆ spatial_dimension()

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

The spatial dimension is defined as:

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

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

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

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

Definition at line 543 of file mesh_base.C.

References libMesh::MeshBase::_spatial_dimension.

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

544 {
545  return cast_int<unsigned int>(_spatial_dimension);
546 }
unsigned char _spatial_dimension
The "spatial dimension" of the Mesh.
Definition: mesh_base.h:2027

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

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

References libMesh::UnstructuredMesh::stitching_helper().

1739 {
1740  LOG_SCOPE("stitch_meshes()", "UnstructuredMesh");
1741  return stitching_helper(&other_mesh,
1742  this_mesh_boundary_id,
1743  other_mesh_boundary_id,
1744  tol,
1745  clear_stitched_boundary_ids,
1746  verbose,
1747  use_binary_search,
1748  enforce_all_nodes_match_on_boundaries,
1749  true,
1750  merge_boundary_nodes_all_or_nothing,
1751  remap_subdomain_ids);
1752 }
std::size_t stitching_helper(const MeshBase *other_mesh, boundary_id_type boundary_id_1, boundary_id_type boundary_id_2, Real tol, bool clear_stitched_boundary_ids, bool verbose, bool use_binary_search, bool enforce_all_nodes_match_on_boundaries, bool skip_find_neighbors, bool merge_boundary_nodes_all_or_nothing, bool remap_subdomain_ids)
Helper function for stitch_meshes and stitch_surfaces that does the mesh stitching.

◆ stitch_surfaces()

std::size_t libMesh::UnstructuredMesh::stitch_surfaces ( boundary_id_type  boundary_id_1,
boundary_id_type  boundary_id_2,
Real  tol = TOLERANCE,
bool  clear_stitched_boundary_ids = false,
bool  verbose = true,
bool  use_binary_search = true,
bool  enforce_all_nodes_match_on_boundaries = false,
bool  merge_boundary_nodes_all_or_nothing = false 
)
inherited

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

Definition at line 1756 of file unstructured_mesh.C.

References libMesh::UnstructuredMesh::stitching_helper().

1765 {
1766  return stitching_helper(nullptr,
1767  boundary_id_1,
1768  boundary_id_2,
1769  tol,
1770  clear_stitched_boundary_ids,
1771  verbose,
1772  use_binary_search,
1773  enforce_all_nodes_match_on_boundaries,
1774  true,
1775  merge_boundary_nodes_all_or_nothing,
1776  false);
1777 }
std::size_t stitching_helper(const MeshBase *other_mesh, boundary_id_type boundary_id_1, boundary_id_type boundary_id_2, Real tol, bool clear_stitched_boundary_ids, bool verbose, bool use_binary_search, bool enforce_all_nodes_match_on_boundaries, bool skip_find_neighbors, bool merge_boundary_nodes_all_or_nothing, bool remap_subdomain_ids)
Helper function for stitch_meshes and stitch_surfaces that does the mesh stitching.

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

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

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

1639 {
1640  // If there's no master point locator, then we need one.
1641  if (_point_locator.get() == nullptr)
1642  {
1643  // PointLocator construction may not be safe within threads
1645 
1646  // And it may require parallel communication
1647  parallel_object_only();
1648 
1649 #ifdef LIBMESH_ENABLE_NANOFLANN_POINTLOCATOR
1651 #else
1653 #endif
1654 
1656  _point_locator->set_close_to_point_tol(_point_locator_close_to_point_tol);
1657  }
1658 
1659  // Otherwise there was a master point locator, and we can grab a
1660  // sub-locator easily.
1661  return
1662 #ifdef LIBMESH_ENABLE_NANOFLANN_POINTLOCATOR
1664 #else
1666 #endif
1667 }
bool in_threads
A boolean which is true iff we are in a Threads:: function It may be useful to assert(!Threadsin_thre...
Definition: threads.C:32
libmesh_assert(ctx)
std::unique_ptr< PointLocatorBase > _point_locator
A PointLocator class for this mesh.
Definition: mesh_base.h:1905
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:2110
static std::unique_ptr< PointLocatorBase > build(PointLocatorType t, const MeshBase &mesh, const PointLocatorBase *master=nullptr)
Builds an PointLocator for the mesh mesh.

◆ subclass_locally_equals()

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

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.

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

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 }
bool _is_serial_on_proc_0
A boolean remembering whether we&#39;re serialized to proc 0 or not.
dof_id_type _n_nodes
Cached data from the last renumber_nodes_and_elements call.
bool _is_serial
A boolean remembering whether we&#39;re serialized or not.
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...
libmesh_assert(ctx)
DistributedMesh(const Parallel::Communicator &comm_in, unsigned char dim=1)
Constructor.
bool _deleted_coarse_elements
A boolean remembering whether we&#39;ve recently deleted top-level elements or not.
virtual const Elem * query_elem_ptr(const dof_id_type i) const override final

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

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

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

960 {
961  // This requires an inspection on every processor
962  if (global)
963  parallel_object_only();
964 
965  ids.clear();
966 
967  for (const auto & elem : this->active_local_element_ptr_range())
968  ids.insert(elem->subdomain_id());
969 
970  if (global)
971  {
972  // Only include the unpartitioned elements if the user requests the global IDs.
973  // In the case of the local subdomain IDs, it doesn't make sense to include the
974  // unpartitioned elements because said elements do not have a sense of locality.
975  for (const auto & elem : this->active_unpartitioned_element_ptr_range())
976  ids.insert(elem->subdomain_id());
977 
978  // Some subdomains may only live on other processors
979  this->comm().set_union(ids);
980  }
981 }
const Parallel::Communicator & comm() const
void set_union(T &data, const unsigned int root_id) const

◆ subdomain_name() [1/2]

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

Definition at line 1692 of file mesh_base.C.

References libMesh::MeshBase::_block_id_to_name.

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

1693 {
1694  return _block_id_to_name[id];
1695 }
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:1970

◆ subdomain_name() [2/2]

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

Definition at line 1697 of file mesh_base.C.

References libMesh::MeshBase::_block_id_to_name.

1698 {
1699  // An empty string to return when no matching subdomain name is found
1700  static const std::string empty;
1701 
1702  if (const auto iter = _block_id_to_name.find(id);
1703  iter == _block_id_to_name.end())
1704  return empty;
1705  else
1706  return iter->second;
1707 }
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:1970

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

References libMesh::MeshBase::_supported_nodal_order.

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

298  { return _supported_nodal_order; }
Order _supported_nodal_order
We cache the maximum nodal order supported by all the mesh&#39;s elements (the minimum supported_nodal_or...
Definition: mesh_base.h:1990

◆ update_parallel_id_counts()

void libMesh::DistributedMesh::update_parallel_id_counts ( )
overridevirtual

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

Implements libMesh::MeshBase.

Definition at line 257 of file distributed_mesh.C.

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

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

258 {
259  // This function must be run on all processors at once
260  parallel_object_only();
261 
262  _n_elem = this->parallel_n_elem();
263  _n_nodes = this->parallel_n_nodes();
266 
269  ((_max_elem_id-1) / (this->n_processors() + 1) + 1) *
270  (this->n_processors() + 1) + this->n_processors();
273  ((_max_elem_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
274  (this->n_processors() + 1) + this->processor_id();
275 
278  ((_max_node_id-1) / (this->n_processors() + 1) + 1) *
279  (this->n_processors() + 1) + this->n_processors();
282  ((_max_node_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
283  (this->n_processors() + 1) + this->processor_id();
284 
285 #ifdef LIBMESH_ENABLE_UNIQUE_ID
288  ((_next_unique_id-1) / (this->n_processors() + 1) + 1) *
289  (this->n_processors() + 1) + this->n_processors();
291  ((_next_unique_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
292  (this->n_processors() + 1) + this->processor_id();
293 #endif
294 }
virtual dof_id_type parallel_n_nodes() const override
dof_id_type _n_nodes
Cached data from the last renumber_nodes_and_elements call.
dof_id_type _next_free_local_node_id
Guaranteed globally unused IDs for use when adding new nodes or elements.
virtual unique_id_type parallel_max_unique_id() const override
unique_id_type _next_unique_id
The next available unique id for assigning ids to DOF objects.
Definition: mesh_base.h:1925
processor_id_type n_processors() const
virtual dof_id_type parallel_n_elem() const override
dof_id_type parallel_max_node_id() const
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.
processor_id_type processor_id() const
dof_id_type _next_free_local_elem_id
dof_id_type parallel_max_elem_id() const

◆ update_post_partitioning()

void libMesh::DistributedMesh::update_post_partitioning ( )
overridevirtual

Recalculate cached data after elements and nodes have been repartitioned.

Reimplemented from libMesh::MeshBase.

Definition at line 1079 of file distributed_mesh.C.

References update_parallel_id_counts().

1080 {
1081  // this->recalculate_n_partitions();
1082 
1083  // Partitioning changes our numbers of unpartitioned objects
1084  this->update_parallel_id_counts();
1085 }
virtual void update_parallel_id_counts() override
Updates parallel caches so that methods like n_elem() accurately reflect changes on other processors...

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

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

Referenced by main().

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

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

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

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

Member Data Documentation

◆ _all_elemset_ids

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

◆ _allow_remote_element_removal

bool libMesh::MeshBase::_allow_remote_element_removal
protectedinherited

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

This is true by default.

Definition at line 1963 of file mesh_base.h.

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

◆ _block_id_to_name

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

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

Currently this is only implemented for ExodusII

Definition at line 1970 of file mesh_base.h.

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

◆ _communicator

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

◆ _constraint_rows

constraint_rows_type libMesh::MeshBase::_constraint_rows
protectedinherited

◆ _count_lower_dim_elems_in_point_locator

bool libMesh::MeshBase::_count_lower_dim_elems_in_point_locator
protectedinherited

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

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

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

◆ _default_mapping_data

unsigned char libMesh::MeshBase::_default_mapping_data
protectedinherited

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

Definition at line 1891 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 1884 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

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 450 of file distributed_mesh.h.

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

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

◆ _elements

dofobject_container<Elem> libMesh::DistributedMesh::_elements

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

These are extra ghost elements that we want to make sure not to delete when we call delete_remote_elements()

Definition at line 477 of file distributed_mesh.h.

Referenced by add_extra_ghost_elem(), clear_extra_ghost_elems(), delete_remote_elements(), DistributedMesh(), extra_ghost_elems(), and subclass_locally_equals().

◆ _ghosting_functors

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

◆ _interior_mesh

MeshBase* libMesh::MeshBase::_interior_mesh
protectedinherited

Defaulting to this, a pointer to the mesh used to generate boundary elements on this.

Definition at line 1932 of file mesh_base.h.

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

◆ _is_prepared

bool libMesh::MeshBase::_is_prepared
protectedinherited

◆ _is_serial

bool libMesh::DistributedMesh::_is_serial

A boolean remembering whether we're serialized or not.

Definition at line 438 of file distributed_mesh.h.

Referenced by allgather(), clear(), delete_remote_elements(), DistributedMesh(), is_serial(), is_serial_on_zero(), set_distributed(), and subclass_locally_equals().

◆ _is_serial_on_proc_0

bool libMesh::DistributedMesh::_is_serial_on_proc_0

A boolean remembering whether we're serialized to proc 0 or not.

Definition at line 443 of file distributed_mesh.h.

Referenced by allgather(), clear(), delete_remote_elements(), DistributedMesh(), gather_to_zero(), is_serial_on_zero(), set_distributed(), and subclass_locally_equals().

◆ _max_elem_id

dof_id_type libMesh::DistributedMesh::_max_elem_id

◆ _max_node_id

dof_id_type libMesh::DistributedMesh::_max_node_id

◆ _mesh_subdomains

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

◆ _n_elem

dof_id_type libMesh::DistributedMesh::_n_elem

◆ _n_nodes

dof_id_type libMesh::DistributedMesh::_n_nodes

Cached data from the last renumber_nodes_and_elements call.

Definition at line 455 of file distributed_mesh.h.

Referenced by add_node(), clear(), delete_node(), DistributedMesh(), n_nodes(), own_node(), renumber_nodes_and_elements(), subclass_locally_equals(), and update_parallel_id_counts().

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

◆ _next_free_local_node_id

dof_id_type libMesh::DistributedMesh::_next_free_local_node_id

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

Definition at line 461 of file distributed_mesh.h.

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

◆ _next_free_unpartitioned_elem_id

dof_id_type libMesh::DistributedMesh::_next_free_unpartitioned_elem_id

◆ _next_free_unpartitioned_node_id

dof_id_type libMesh::DistributedMesh::_next_free_unpartitioned_node_id

Definition at line 463 of file distributed_mesh.h.

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

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

The next available unique id for assigning ids to unpartitioned DOF objects.

Definition at line 470 of file distributed_mesh.h.

Referenced by add_elem(), add_node(), DistributedMesh(), insert_elem(), parallel_max_unique_id(), set_next_unique_id(), and update_parallel_id_counts().

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

Move node and elements from a DistributedMesh.

The vertices (spatial coordinates) of the mesh.

Definition at line 415 of file distributed_mesh.h.

Referenced by add_node(), clear(), delete_node(), delete_remote_elements(), node_ptr(), own_node(), parallel_max_node_id(), query_node_ptr(), renumber_node(), and renumber_nodes_and_elements().

◆ _partitioner

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

A partitioner to use at each prepare_for_use().

This will be built in the constructor of each derived class, but can be replaced by the user through the partitioner() accessor.

Definition at line 1919 of file mesh_base.h.

Referenced by DistributedMesh(), libMesh::MeshBase::locally_equals(), libMesh::MeshBase::MeshBase(), libMesh::MeshBase::partitioner(), libMesh::MeshBase::post_dofobject_moves(), libMesh::ReplicatedMesh::ReplicatedMesh(), and libMesh::MeshBase::skip_noncritical_partitioning().

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

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

◆ _point_locator_close_to_point_tol

Real libMesh::MeshBase::_point_locator_close_to_point_tol
protectedinherited

◆ _shared_functors

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

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

Definition at line 2092 of file mesh_base.h.

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

◆ _skip_all_partitioning

bool libMesh::MeshBase::_skip_all_partitioning
protectedinherited

◆ _skip_find_neighbors

bool libMesh::MeshBase::_skip_find_neighbors
protectedinherited

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

Definition at line 1955 of file mesh_base.h.

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

◆ _skip_noncritical_partitioning

bool libMesh::MeshBase::_skip_noncritical_partitioning
protectedinherited

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

Definition at line 1938 of file mesh_base.h.

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

◆ _skip_renumber_nodes_and_elements

bool libMesh::MeshBase::_skip_renumber_nodes_and_elements
protectedinherited

◆ _spatial_dimension

unsigned char libMesh::MeshBase::_spatial_dimension
protectedinherited

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

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

◆ level [1/2]

unsigned int libMesh::DistributedMesh::level

Definition at line 361 of file distributed_mesh.h.

◆ level [2/2]

processor_id_type pid unsigned int libMesh::DistributedMesh::level

Definition at line 388 of file distributed_mesh.h.

◆ pid [1/2]

processor_id_type libMesh::DistributedMesh::pid

Definition at line 386 of file distributed_mesh.h.

Referenced by renumber_dof_objects(), and renumber_nodes_and_elements().

◆ 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

Definition at line 410 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

Definition at line 400 of file distributed_mesh.h.

◆ ss [1/2]

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

Definition at line 366 of file distributed_mesh.h.

Referenced by active_subdomain_set_elements_ptr_range().

◆ ss [2/2]

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

Definition at line 390 of file distributed_mesh.h.

◆ type

unsigned int level ElemType libMesh::DistributedMesh::type

Definition at line 363 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

Definition at line 396 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

Definition at line 413 of file distributed_mesh.h.


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