libMesh::DistributedMesh Class Reference

Mesh data structure which is distributed across all processors. More...

#include <distributed_mesh.h>

Inheritance diagram for libMesh::DistributedMesh:

Public Types

typedef Predicates::multi_predicate Predicate
 

Public Member Functions

 DistributedMesh (const Parallel::Communicator &comm_in, unsigned char dim=1)
 
 DistributedMesh (unsigned char dim=1)
 
 DistributedMesh (const UnstructuredMesh &other_mesh)
 
 DistributedMesh (const DistributedMesh &other_mesh)
 
virtual std::unique_ptr< MeshBaseclone () const libmesh_override
 
virtual ~DistributedMesh ()
 
virtual void clear () libmesh_override
 
virtual void redistribute () libmesh_override
 
virtual void update_post_partitioning () libmesh_override
 
virtual bool is_serial () const libmesh_override
 
virtual bool is_serial_on_zero () const libmesh_override
 
virtual void set_distributed () libmesh_override
 
virtual bool is_replicated () const libmesh_override
 
template<typename T >
void libmesh_assert_valid_parallel_object_ids (const mapvector< T *, dof_id_type > &) const
 
virtual void libmesh_assert_valid_parallel_ids () const libmesh_override
 
void libmesh_assert_valid_parallel_p_levels () const
 
void libmesh_assert_valid_parallel_flags () const
 
template<typename T >
dof_id_type renumber_dof_objects (mapvector< T *, dof_id_type > &)
 
virtual void renumber_nodes_and_elements () libmesh_override
 
virtual void allgather () libmesh_override
 
virtual void gather_to_zero () libmesh_override
 
virtual void delete_remote_elements () libmesh_override
 
virtual void add_extra_ghost_elem (Elem *e)
 
virtual void clear_extra_ghost_elems ()
 
virtual dof_id_type n_nodes () const libmesh_override
 
virtual dof_id_type max_node_id () const libmesh_override
 
virtual void reserve_nodes (const dof_id_type) libmesh_override
 
virtual dof_id_type n_elem () const libmesh_override
 
virtual dof_id_type n_active_elem () const libmesh_override
 
virtual dof_id_type max_elem_id () const libmesh_override
 
virtual void reserve_elem (const dof_id_type) libmesh_override
 
virtual void update_parallel_id_counts () libmesh_override
 
virtual dof_id_type parallel_n_nodes () const libmesh_override
 
dof_id_type parallel_max_node_id () const
 
virtual dof_id_type parallel_n_elem () const libmesh_override
 
dof_id_type parallel_max_elem_id () const
 
virtual unique_id_type parallel_max_unique_id () const libmesh_override
 
virtual const Pointpoint (const dof_id_type i) const libmesh_override
 
virtual const Nodenode_ptr (const dof_id_type i) const libmesh_override
 
virtual Nodenode_ptr (const dof_id_type i) libmesh_override
 
virtual const Nodequery_node_ptr (const dof_id_type i) const libmesh_override
 
virtual Nodequery_node_ptr (const dof_id_type i) libmesh_override
 
virtual const Elemelem_ptr (const dof_id_type i) const libmesh_override
 
virtual Elemelem_ptr (const dof_id_type i) libmesh_override
 
virtual const Elemquery_elem_ptr (const dof_id_type i) const libmesh_override
 
virtual Elemquery_elem_ptr (const dof_id_type i) libmesh_override
 
virtual Nodeadd_point (const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id) libmesh_override
 
virtual Nodeadd_node (Node *n) libmesh_override
 
virtual Nodeinsert_node (Node *n) libmesh_override
 
virtual void delete_node (Node *n) libmesh_override
 
virtual void renumber_node (dof_id_type old_id, dof_id_type new_id) libmesh_override
 
virtual Elemadd_elem (Elem *e) libmesh_override
 
virtual Eleminsert_elem (Elem *e) libmesh_override
 
virtual void delete_elem (Elem *e) libmesh_override
 
virtual void renumber_elem (dof_id_type old_id, dof_id_type new_id) libmesh_override
 
virtual void fix_broken_node_and_element_numbering () libmesh_override
 
virtual element_iterator elements_begin () libmesh_override
 
virtual element_iterator elements_end () libmesh_override
 
virtual const_element_iterator elements_begin () const libmesh_override
 
virtual const_element_iterator elements_end () const libmesh_override
 
virtual SimpleRange< element_iteratorelement_ptr_range () libmesh_override
 
virtual SimpleRange< const_element_iteratorelement_ptr_range () const libmesh_override
 
virtual element_iterator active_elements_begin () libmesh_override
 
virtual element_iterator active_elements_end () libmesh_override
 
virtual const_element_iterator active_elements_begin () const libmesh_override
 
virtual const_element_iterator active_elements_end () const libmesh_override
 
virtual SimpleRange< element_iteratoractive_element_ptr_range () libmesh_override
 
virtual SimpleRange< const_element_iteratoractive_element_ptr_range () const libmesh_override
 
virtual element_iterator ancestor_elements_begin () libmesh_override
 
virtual element_iterator ancestor_elements_end () libmesh_override
 
virtual const_element_iterator ancestor_elements_begin () const libmesh_override
 
virtual const_element_iterator ancestor_elements_end () const libmesh_override
 
virtual element_iterator subactive_elements_begin () libmesh_override
 
virtual element_iterator subactive_elements_end () libmesh_override
 
virtual const_element_iterator subactive_elements_begin () const libmesh_override
 
virtual const_element_iterator subactive_elements_end () const libmesh_override
 
virtual element_iterator not_active_elements_begin () libmesh_override
 
virtual element_iterator not_active_elements_end () libmesh_override
 
virtual const_element_iterator not_active_elements_begin () const libmesh_override
 
virtual const_element_iterator not_active_elements_end () const libmesh_override
 
virtual element_iterator not_ancestor_elements_begin () libmesh_override
 
virtual element_iterator not_ancestor_elements_end () libmesh_override
 
virtual const_element_iterator not_ancestor_elements_begin () const libmesh_override
 
virtual const_element_iterator not_ancestor_elements_end () const libmesh_override
 
virtual element_iterator not_subactive_elements_begin () libmesh_override
 
virtual element_iterator not_subactive_elements_end () libmesh_override
 
virtual const_element_iterator not_subactive_elements_begin () const libmesh_override
 
virtual const_element_iterator not_subactive_elements_end () const libmesh_override
 
virtual element_iterator local_elements_begin () libmesh_override
 
virtual element_iterator local_elements_end () libmesh_override
 
virtual const_element_iterator local_elements_begin () const libmesh_override
 
virtual const_element_iterator local_elements_end () const libmesh_override
 
virtual element_iterator semilocal_elements_begin () libmesh_override
 
virtual element_iterator semilocal_elements_end () libmesh_override
 
virtual const_element_iterator semilocal_elements_begin () const libmesh_override
 
virtual const_element_iterator semilocal_elements_end () const libmesh_override
 
virtual element_iterator active_semilocal_elements_begin () libmesh_override
 
virtual element_iterator active_semilocal_elements_end () libmesh_override
 
virtual const_element_iterator active_semilocal_elements_begin () const libmesh_override
 
virtual const_element_iterator active_semilocal_elements_end () const libmesh_override
 
virtual element_iterator facelocal_elements_begin () libmesh_override
 
virtual element_iterator facelocal_elements_end () libmesh_override
 
virtual const_element_iterator facelocal_elements_begin () const libmesh_override
 
virtual const_element_iterator facelocal_elements_end () const libmesh_override
 
virtual element_iterator not_local_elements_begin () libmesh_override
 
virtual element_iterator not_local_elements_end () libmesh_override
 
virtual const_element_iterator not_local_elements_begin () const libmesh_override
 
virtual const_element_iterator not_local_elements_end () const libmesh_override
 
virtual element_iterator active_local_elements_begin () libmesh_override
 
virtual element_iterator active_local_elements_end () libmesh_override
 
virtual const_element_iterator active_local_elements_begin () const libmesh_override
 
virtual const_element_iterator active_local_elements_end () const libmesh_override
 
virtual SimpleRange< element_iteratoractive_local_element_ptr_range () libmesh_override
 
virtual SimpleRange< const_element_iteratoractive_local_element_ptr_range () const libmesh_override
 
virtual element_iterator active_not_local_elements_begin () libmesh_override
 
virtual element_iterator active_not_local_elements_end () libmesh_override
 
virtual const_element_iterator active_not_local_elements_begin () const libmesh_override
 
virtual const_element_iterator active_not_local_elements_end () const libmesh_override
 
virtual element_iterator level_elements_begin (unsigned int level) libmesh_override
 
virtual element_iterator level_elements_end (unsigned int level) libmesh_override
 
virtual const_element_iterator level_elements_begin (unsigned int level) const libmesh_override
 
virtual const_element_iterator level_elements_end (unsigned int level) const libmesh_override
 
virtual element_iterator not_level_elements_begin (unsigned int level) libmesh_override
 
virtual element_iterator not_level_elements_end (unsigned int level) libmesh_override
 
virtual const_element_iterator not_level_elements_begin (unsigned int level) const libmesh_override
 
virtual const_element_iterator not_level_elements_end (unsigned int level) const libmesh_override
 
virtual element_iterator local_level_elements_begin (unsigned int level) libmesh_override
 
virtual element_iterator local_level_elements_end (unsigned int level) libmesh_override
 
virtual const_element_iterator local_level_elements_begin (unsigned int level) const libmesh_override
 
virtual const_element_iterator local_level_elements_end (unsigned int level) const libmesh_override
 
virtual element_iterator local_not_level_elements_begin (unsigned int level) libmesh_override
 
virtual element_iterator local_not_level_elements_end (unsigned int level) libmesh_override
 
virtual const_element_iterator local_not_level_elements_begin (unsigned int level) const libmesh_override
 
virtual const_element_iterator local_not_level_elements_end (unsigned int level) const libmesh_override
 
virtual element_iterator pid_elements_begin (processor_id_type proc_id) libmesh_override
 
virtual element_iterator pid_elements_end (processor_id_type proc_id) libmesh_override
 
virtual const_element_iterator pid_elements_begin (processor_id_type proc_id) const libmesh_override
 
virtual const_element_iterator pid_elements_end (processor_id_type proc_id) const libmesh_override
 
virtual element_iterator type_elements_begin (ElemType type) libmesh_override
 
virtual element_iterator type_elements_end (ElemType type) libmesh_override
 
virtual const_element_iterator type_elements_begin (ElemType type) const libmesh_override
 
virtual const_element_iterator type_elements_end (ElemType type) const libmesh_override
 
virtual element_iterator active_type_elements_begin (ElemType type) libmesh_override
 
virtual element_iterator active_type_elements_end (ElemType type) libmesh_override
 
virtual const_element_iterator active_type_elements_begin (ElemType type) const libmesh_override
 
virtual const_element_iterator active_type_elements_end (ElemType type) const libmesh_override
 
virtual element_iterator active_pid_elements_begin (processor_id_type proc_id) libmesh_override
 
virtual element_iterator active_pid_elements_end (processor_id_type proc_id) libmesh_override
 
virtual const_element_iterator active_pid_elements_begin (processor_id_type proc_id) const libmesh_override
 
virtual const_element_iterator active_pid_elements_end (processor_id_type proc_id) const libmesh_override
 
virtual element_iterator unpartitioned_elements_begin () libmesh_override
 
virtual element_iterator unpartitioned_elements_end () libmesh_override
 
virtual const_element_iterator unpartitioned_elements_begin () const libmesh_override
 
virtual const_element_iterator unpartitioned_elements_end () const libmesh_override
 
virtual element_iterator active_unpartitioned_elements_begin () libmesh_override
 
virtual element_iterator active_unpartitioned_elements_end () libmesh_override
 
virtual const_element_iterator active_unpartitioned_elements_begin () const libmesh_override
 
virtual const_element_iterator active_unpartitioned_elements_end () const libmesh_override
 
virtual element_iterator active_local_subdomain_elements_begin (subdomain_id_type subdomain_id) libmesh_override
 
virtual element_iterator active_local_subdomain_elements_end (subdomain_id_type subdomain_id) libmesh_override
 
virtual const_element_iterator active_local_subdomain_elements_begin (subdomain_id_type subdomain_id) const libmesh_override
 
virtual const_element_iterator active_local_subdomain_elements_end (subdomain_id_type subdomain_id) const libmesh_override
 
virtual element_iterator active_subdomain_elements_begin (subdomain_id_type subdomain_id) libmesh_override
 
virtual element_iterator active_subdomain_elements_end (subdomain_id_type subdomain_id) libmesh_override
 
virtual const_element_iterator active_subdomain_elements_begin (subdomain_id_type subdomain_id) const libmesh_override
 
virtual const_element_iterator active_subdomain_elements_end (subdomain_id_type subdomain_id) const libmesh_override
 
virtual element_iterator active_subdomain_set_elements_begin (std::set< subdomain_id_type > ss) libmesh_override
 
virtual element_iterator active_subdomain_set_elements_end (std::set< subdomain_id_type > ss) libmesh_override
 
virtual const_element_iterator active_subdomain_set_elements_begin (std::set< subdomain_id_type > ss) const libmesh_override
 
virtual const_element_iterator active_subdomain_set_elements_end (std::set< subdomain_id_type > ss) const libmesh_override
 
virtual element_iterator ghost_elements_begin () libmesh_override
 
virtual element_iterator ghost_elements_end () libmesh_override
 
virtual const_element_iterator ghost_elements_begin () const libmesh_override
 
virtual const_element_iterator ghost_elements_end () const libmesh_override
 
virtual element_iterator evaluable_elements_begin (const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint) libmesh_override
 
virtual element_iterator evaluable_elements_end (const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint) libmesh_override
 
virtual const_element_iterator evaluable_elements_begin (const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint) const libmesh_override
 
virtual const_element_iterator evaluable_elements_end (const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint) const libmesh_override
 
virtual element_iterator flagged_elements_begin (unsigned char rflag) libmesh_override
 
virtual element_iterator flagged_elements_end (unsigned char rflag) libmesh_override
 
virtual const_element_iterator flagged_elements_begin (unsigned char rflag) const libmesh_override
 
virtual const_element_iterator flagged_elements_end (unsigned char rflag) const libmesh_override
 
virtual element_iterator flagged_pid_elements_begin (unsigned char rflag, processor_id_type pid) libmesh_override
 
virtual element_iterator flagged_pid_elements_end (unsigned char rflag, processor_id_type pid) libmesh_override
 
virtual const_element_iterator flagged_pid_elements_begin (unsigned char rflag, processor_id_type pid) const libmesh_override
 
virtual const_element_iterator flagged_pid_elements_end (unsigned char rflag, processor_id_type pid) const libmesh_override
 
virtual node_iterator nodes_begin () libmesh_override
 
virtual node_iterator nodes_end () libmesh_override
 
virtual const_node_iterator nodes_begin () const libmesh_override
 
virtual const_node_iterator nodes_end () const libmesh_override
 
virtual SimpleRange< node_iteratornode_ptr_range () libmesh_override
 
virtual SimpleRange< const_node_iteratornode_ptr_range () const libmesh_override
 
virtual node_iterator active_nodes_begin () libmesh_override
 
virtual node_iterator active_nodes_end () libmesh_override
 
virtual const_node_iterator active_nodes_begin () const libmesh_override
 
virtual const_node_iterator active_nodes_end () const libmesh_override
 
virtual node_iterator local_nodes_begin () libmesh_override
 
virtual node_iterator local_nodes_end () libmesh_override
 
virtual const_node_iterator local_nodes_begin () const libmesh_override
 
virtual const_node_iterator local_nodes_end () const libmesh_override
 
virtual SimpleRange< node_iteratorlocal_node_ptr_range () libmesh_override
 
virtual SimpleRange< const_node_iteratorlocal_node_ptr_range () const libmesh_override
 
virtual node_iterator pid_nodes_begin (processor_id_type proc_id) libmesh_override
 
virtual node_iterator pid_nodes_end (processor_id_type proc_id) libmesh_override
 
virtual const_node_iterator pid_nodes_begin (processor_id_type proc_id) const libmesh_override
 
virtual const_node_iterator pid_nodes_end (processor_id_type proc_id) const libmesh_override
 
virtual node_iterator bid_nodes_begin (boundary_id_type bndry_id) libmesh_override
 
virtual node_iterator bid_nodes_end (boundary_id_type bndry_id) libmesh_override
 
virtual const_node_iterator bid_nodes_begin (boundary_id_type bndry_id) const libmesh_override
 
virtual const_node_iterator bid_nodes_end (boundary_id_type bndry_id) const libmesh_override
 
virtual node_iterator bnd_nodes_begin () libmesh_override
 
virtual node_iterator bnd_nodes_end () libmesh_override
 
virtual const_node_iterator bnd_nodes_begin () const libmesh_override
 
virtual const_node_iterator bnd_nodes_end () const libmesh_override
 
virtual node_iterator evaluable_nodes_begin (const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint) libmesh_override
 
virtual node_iterator evaluable_nodes_end (const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint) libmesh_override
 
virtual const_node_iterator evaluable_nodes_begin (const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint) const libmesh_override
 
virtual const_node_iterator evaluable_nodes_end (const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint) const libmesh_override
 
virtual void read (const std::string &name, void *mesh_data=libmesh_nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false) libmesh_override
 
virtual void write (const std::string &name) libmesh_override
 
void write (const std::string &name, const std::vector< Number > &values, const std::vector< std::string > &variable_names)
 
virtual void all_first_order () libmesh_override
 
virtual void all_second_order (const bool full_ordered=true) libmesh_override
 
void create_pid_mesh (UnstructuredMesh &pid_mesh, const processor_id_type pid) const
 
void create_submesh (UnstructuredMesh &new_mesh, const_element_iterator &it, const const_element_iterator &it_end) const
 
virtual void copy_nodes_and_elements (const UnstructuredMesh &other_mesh, const bool skip_find_neighbors=false)
 
virtual void find_neighbors (const bool reset_remote_elements=false, const bool reset_current_list=true) libmesh_override
 
virtual bool contract () libmesh_override
 
virtual std::unique_ptr< Partitioner > & partitioner ()
 
const BoundaryInfoget_boundary_info () const
 
BoundaryInfoget_boundary_info ()
 
bool is_prepared () const
 
unsigned int mesh_dimension () const
 
void set_mesh_dimension (unsigned char d)
 
const std::set< unsigned char > & elem_dimensions () const
 
unsigned int spatial_dimension () const
 
void set_spatial_dimension (unsigned char d)
 
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 ()
 
void set_next_unique_id (unique_id_type 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
 
virtual const Nodenode_ref (const dof_id_type i) const
 
virtual Nodenode_ref (const dof_id_type i)
 
virtual const Nodenode (const dof_id_type i) const
 
virtual Nodenode (const dof_id_type i)
 
virtual const Elemelem_ref (const dof_id_type i) const
 
virtual Elemelem_ref (const dof_id_type i)
 
virtual const Elemelem (const dof_id_type i) const
 
virtual Elemelem (const dof_id_type i)
 
virtual const Elemquery_elem (const dof_id_type i) const
 
virtual Elemquery_elem (const dof_id_type i)
 
void prepare_for_use (const bool skip_renumber_nodes_and_elements=false, const bool skip_find_neighbors=false)
 
virtual void partition (const unsigned int n_parts)
 
void partition ()
 
void allow_renumbering (bool allow)
 
bool allow_renumbering () const
 
void allow_remote_element_removal (bool allow)
 
bool allow_remote_element_removal () const
 
void skip_partitioning (bool skip)
 
bool skip_partitioning () const
 
void add_ghosting_functor (GhostingFunctor &ghosting_functor)
 
void remove_ghosting_functor (GhostingFunctor &ghosting_functor)
 
std::set< GhostingFunctor * >::const_iterator ghosting_functors_begin () const
 
std::set< GhostingFunctor * >::const_iterator ghosting_functors_end () const
 
void subdomain_ids (std::set< subdomain_id_type > &ids) const
 
subdomain_id_type n_subdomains () const
 
unsigned int n_partitions () const
 
std::string get_info () const
 
void print_info (std::ostream &os=libMesh::out) const
 
unsigned int recalculate_n_partitions ()
 
const PointLocatorBasepoint_locator () const
 
std::unique_ptr< PointLocatorBasesub_point_locator () const
 
void clear_point_locator ()
 
void set_count_lower_dim_elems_in_point_locator (bool count_lower_dim_elems)
 
bool get_count_lower_dim_elems_in_point_locator () const
 
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 (const std::string &name) const
 
std::map< subdomain_id_type, std::string > & set_subdomain_name_map ()
 
const std::map< subdomain_id_type, std::string > & get_subdomain_name_map () const
 
void cache_elem_dims ()
 
void detect_interior_parents ()
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Public Attributes

std::unique_ptr< BoundaryInfoboundary_info
 

Protected Member Functions

unsigned int & set_n_partitions ()
 

Protected Attributes

mapvector< Node *, dof_id_type_nodes
 
mapvector< Elem *, dof_id_type_elements
 
bool _is_serial
 
bool _is_serial_on_proc_0
 
dof_id_type _n_nodes
 
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
 
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
 
std::set< Elem * > _extra_ghost_elems
 
unsigned int _n_parts
 
bool _is_prepared
 
std::unique_ptr< PointLocatorBase_point_locator
 
bool _count_lower_dim_elems_in_point_locator
 
std::unique_ptr< Partitioner_partitioner
 
unique_id_type _next_unique_id
 
bool _skip_partitioning
 
bool _skip_renumber_nodes_and_elements
 
bool _allow_remote_element_removal
 
std::map< subdomain_id_type, std::string > _block_id_to_name
 
std::set< unsigned char > _elem_dims
 
unsigned char _spatial_dimension
 
std::unique_ptr< GhostingFunctor_default_ghosting
 
std::set< GhostingFunctor * > _ghosting_functors
 
const Parallel::Communicator_communicator
 

Private Types

typedef mapvector< Elem *, dof_id_type >::veclike_iterator elem_iterator_imp
 
typedef mapvector< Elem *, dof_id_type >::const_veclike_iterator const_elem_iterator_imp
 
typedef mapvector< Node *, dof_id_type >::veclike_iterator node_iterator_imp
 
typedef mapvector< Node *, dof_id_type >::const_veclike_iterator const_node_iterator_imp
 

Detailed Description

Mesh data structure which is distributed across all processors.

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

Definition at line 50 of file distributed_mesh.h.

Member Typedef Documentation

typedef mapvector<Elem *, dof_id_type>::const_veclike_iterator libMesh::DistributedMesh::const_elem_iterator_imp
private

Definition at line 576 of file distributed_mesh.h.

typedef mapvector<Node *, dof_id_type>::const_veclike_iterator libMesh::DistributedMesh::const_node_iterator_imp
private

Definition at line 583 of file distributed_mesh.h.

Typedefs for the container implementation. In this case, it's just a std::vector<Elem *>.

Definition at line 575 of file distributed_mesh.h.

Typedefs for the container implementation. In this case, it's just a std::vector<Node *>.

Definition at line 582 of file distributed_mesh.h.

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

Definition at line 890 of file mesh_base.h.

Constructor & Destructor Documentation

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

References _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, libMesh::MeshBase::_partitioner, clear(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::UnstructuredMesh::UnstructuredMesh(), and ~DistributedMesh().

35  :
36  UnstructuredMesh (comm_in,d), _is_serial(true),
43 #ifdef LIBMESH_ENABLE_UNIQUE_ID
45 #endif
46 {
47 #ifdef LIBMESH_ENABLE_UNIQUE_ID
48  _next_unique_id = this->processor_id();
49 #endif
50 
51  // FIXME: give parmetis the communicator!
52  _partitioner = libmesh_make_unique<ParmetisPartitioner>();
53 }
54 
55 
56 #ifndef LIBMESH_DISABLE_COMMWORLD
57 #ifdef LIBMESH_ENABLE_DEPRECATED
58 DistributedMesh::DistributedMesh (unsigned char d) :
65 #ifdef LIBMESH_ENABLE_UNIQUE_ID
67 #endif
68 {
69  libmesh_deprecated();
70 
71 #ifdef LIBMESH_ENABLE_UNIQUE_ID
72  _next_unique_id = this->processor_id();
73 #endif
74 
75  // FIXME: give parmetis the communicator!
76  _partitioner = libmesh_make_unique<ParmetisPartitioner>();
77 }
78 #endif
79 #endif
80 
81 
83 {
84  this->clear(); // Free nodes and elements
85 }
dof_id_type _next_free_local_node_id
processor_id_type n_processors() const
unique_id_type _next_unique_id
Definition: mesh_base.h:1377
std::unique_ptr< Partitioner > _partitioner
Definition: mesh_base.h:1371
dof_id_type _next_free_unpartitioned_node_id
UnstructuredMesh(const Parallel::Communicator &comm_in, unsigned char dim=1)
dof_id_type _next_free_unpartitioned_elem_id
DistributedMesh(const Parallel::Communicator &comm_in, unsigned char dim=1)
unique_id_type _next_unpartitioned_unique_id
dof_id_type _next_free_local_elem_id
processor_id_type processor_id()
Definition: libmesh_base.h:96
virtual void clear()
Definition: function_base.h:87
processor_id_type processor_id() const
libMesh::DistributedMesh::DistributedMesh ( unsigned char  dim = 1)
explicit

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

Deprecated:
LIBMESH_DISABLE_COMMWORLD is now the default, use the constructor that takes a Parallel::Communicator instead.
libMesh::DistributedMesh::DistributedMesh ( const UnstructuredMesh other_mesh)

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

Definition at line 130 of file distributed_mesh.C.

References libMesh::MeshBase::_next_unique_id, libMesh::UnstructuredMesh::copy_nodes_and_elements(), libMesh::MeshBase::get_boundary_info(), libMesh::MeshBase::parallel_max_unique_id(), and update_parallel_id_counts().

130  :
131  UnstructuredMesh (other_mesh), _is_serial(other_mesh.is_serial()),
132  _is_serial_on_proc_0(other_mesh.is_serial()),
133  _n_nodes(0), _n_elem(0), _max_node_id(0), _max_elem_id(0),
138 {
139  this->copy_nodes_and_elements(other_mesh);
140  this->get_boundary_info() = other_mesh.get_boundary_info();
141 
142 #ifdef LIBMESH_ENABLE_UNIQUE_ID
143  _next_unique_id = other_mesh.parallel_max_unique_id();
144 #endif
146 }
const BoundaryInfo & get_boundary_info() const
Definition: mesh_base.h:118
virtual void copy_nodes_and_elements(const UnstructuredMesh &other_mesh, const bool skip_find_neighbors=false)
dof_id_type _next_free_local_node_id
processor_id_type n_processors() const
virtual void update_parallel_id_counts() libmesh_override
unique_id_type _next_unique_id
Definition: mesh_base.h:1377
dof_id_type _next_free_unpartitioned_node_id
UnstructuredMesh(const Parallel::Communicator &comm_in, unsigned char dim=1)
dof_id_type _next_free_unpartitioned_elem_id
dof_id_type _next_free_local_elem_id
processor_id_type processor_id() const
libMesh::DistributedMesh::DistributedMesh ( const DistributedMesh other_mesh)

Copy-constructor, possibly specialized for a distributed mesh.

Definition at line 91 of file distributed_mesh.C.

References _extra_ghost_elems, _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::UnstructuredMesh::copy_nodes_and_elements(), libMesh::MeshBase::get_boundary_info(), max_elem_id(), max_node_id(), n_elem(), and n_nodes().

91  :
92  UnstructuredMesh (other_mesh), _is_serial(other_mesh._is_serial),
93  _is_serial_on_proc_0(other_mesh._is_serial_on_proc_0),
99 {
100  this->copy_nodes_and_elements(other_mesh);
101  _n_nodes = other_mesh.n_nodes();
102  _n_elem = other_mesh.n_elem();
103  _max_node_id = other_mesh.max_node_id();
104  _max_elem_id = other_mesh.max_elem_id();
106  other_mesh._next_free_local_node_id;
108  other_mesh._next_free_local_elem_id;
110  other_mesh._next_free_unpartitioned_node_id;
112  other_mesh._next_free_unpartitioned_elem_id;
113 #ifdef LIBMESH_ENABLE_UNIQUE_ID
115  other_mesh._next_unique_id;
117  other_mesh._next_unpartitioned_unique_id;
118 #endif
119  this->get_boundary_info() = other_mesh.get_boundary_info();
120 
121  // Need to copy extra_ghost_elems
122  for (std::set<Elem *>::iterator it = other_mesh._extra_ghost_elems.begin();
123  it != other_mesh._extra_ghost_elems.end();
124  ++it)
125  _extra_ghost_elems.insert(this->elem_ptr((*it)->id()));
126 }
const BoundaryInfo & get_boundary_info() const
Definition: mesh_base.h:118
virtual void copy_nodes_and_elements(const UnstructuredMesh &other_mesh, const bool skip_find_neighbors=false)
dof_id_type _next_free_local_node_id
processor_id_type n_processors() const
unique_id_type _next_unique_id
Definition: mesh_base.h:1377
std::set< Elem * > _extra_ghost_elems
dof_id_type _next_free_unpartitioned_node_id
UnstructuredMesh(const Parallel::Communicator &comm_in, unsigned char dim=1)
dof_id_type _next_free_unpartitioned_elem_id
unique_id_type _next_unpartitioned_unique_id
dof_id_type _next_free_local_elem_id
processor_id_type processor_id() const
virtual libMesh::DistributedMesh::~DistributedMesh ( )
virtual

Destructor.

Referenced by clone(), and DistributedMesh().

Member Function Documentation

virtual SimpleRange<element_iterator> libMesh::DistributedMesh::active_element_ptr_range ( )
inlinevirtual

Implements libMesh::MeshBase.

Definition at line 302 of file distributed_mesh.h.

References active_elements_begin(), and active_elements_end().

virtual element_iterator active_elements_begin() libmesh_override
virtual element_iterator active_elements_end() libmesh_override
virtual element_iterator libMesh::DistributedMesh::active_elements_begin ( )
virtual

Active, local, and negation forms of the element iterators described above. An "active" element is an element without children (i.e. has not been refined). A "local" element is one whose processor_id() matches the current processor.

Implements libMesh::MeshBase.

Referenced by active_element_ptr_range(), and element_ptr_range().

virtual const_element_iterator libMesh::DistributedMesh::active_elements_begin ( ) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::active_elements_end ( )
virtual
virtual const_element_iterator libMesh::DistributedMesh::active_elements_end ( ) const
virtual

Implements libMesh::MeshBase.

virtual SimpleRange<element_iterator> libMesh::DistributedMesh::active_local_element_ptr_range ( )
inlinevirtual

Implements libMesh::MeshBase.

Definition at line 359 of file distributed_mesh.h.

References active_local_elements_begin(), and active_local_elements_end().

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

virtual element_iterator active_local_elements_begin() libmesh_override
virtual element_iterator active_local_elements_end() libmesh_override
virtual SimpleRange<const_element_iterator> libMesh::DistributedMesh::active_local_element_ptr_range ( ) const
inlinevirtual

Implements libMesh::MeshBase.

Definition at line 360 of file distributed_mesh.h.

References active_local_elements_begin(), active_local_elements_end(), active_local_subdomain_elements_begin(), active_local_subdomain_elements_end(), active_not_local_elements_begin(), active_not_local_elements_end(), active_pid_elements_begin(), active_pid_elements_end(), active_subdomain_elements_begin(), active_subdomain_elements_end(), active_subdomain_set_elements_begin(), active_subdomain_set_elements_end(), active_type_elements_begin(), active_type_elements_end(), active_unpartitioned_elements_begin(), active_unpartitioned_elements_end(), evaluable_elements_begin(), evaluable_elements_end(), flagged_elements_begin(), flagged_elements_end(), flagged_pid_elements_begin(), flagged_pid_elements_end(), ghost_elements_begin(), ghost_elements_end(), libMesh::invalid_uint, level_elements_begin(), level_elements_end(), local_level_elements_begin(), local_level_elements_end(), local_not_level_elements_begin(), local_not_level_elements_end(), nodes_begin(), nodes_end(), not_level_elements_begin(), not_level_elements_end(), pid_elements_begin(), pid_elements_end(), type_elements_begin(), type_elements_end(), unpartitioned_elements_begin(), and unpartitioned_elements_end().

virtual element_iterator active_local_elements_begin() libmesh_override
virtual element_iterator active_local_elements_end() libmesh_override
virtual element_iterator libMesh::DistributedMesh::active_local_elements_begin ( )
virtual
virtual const_element_iterator libMesh::DistributedMesh::active_local_elements_begin ( ) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::active_local_elements_end ( )
virtual
virtual const_element_iterator libMesh::DistributedMesh::active_local_elements_end ( ) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::active_local_subdomain_elements_begin ( subdomain_id_type  subdomain_id)
virtual
virtual const_element_iterator libMesh::DistributedMesh::active_local_subdomain_elements_begin ( subdomain_id_type  subdomain_id) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::active_local_subdomain_elements_end ( subdomain_id_type  subdomain_id)
virtual
virtual const_element_iterator libMesh::DistributedMesh::active_local_subdomain_elements_end ( subdomain_id_type  subdomain_id) const
virtual

Implements libMesh::MeshBase.

virtual node_iterator libMesh::DistributedMesh::active_nodes_begin ( )
virtual

Iterate over only the active nodes in the Mesh.

Implements libMesh::MeshBase.

Referenced by node_ptr_range().

virtual const_node_iterator libMesh::DistributedMesh::active_nodes_begin ( ) const
virtual

Implements libMesh::MeshBase.

virtual node_iterator libMesh::DistributedMesh::active_nodes_end ( )
virtual

Implements libMesh::MeshBase.

Referenced by node_ptr_range().

virtual const_node_iterator libMesh::DistributedMesh::active_nodes_end ( ) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::active_not_local_elements_begin ( )
virtual
virtual const_element_iterator libMesh::DistributedMesh::active_not_local_elements_begin ( ) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::active_not_local_elements_end ( )
virtual
virtual const_element_iterator libMesh::DistributedMesh::active_not_local_elements_end ( ) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::active_pid_elements_begin ( processor_id_type  proc_id)
virtual
virtual const_element_iterator libMesh::DistributedMesh::active_pid_elements_begin ( processor_id_type  proc_id) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::active_pid_elements_end ( processor_id_type  proc_id)
virtual
virtual const_element_iterator libMesh::DistributedMesh::active_pid_elements_end ( processor_id_type  proc_id) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::active_semilocal_elements_begin ( )
virtual

Implements libMesh::MeshBase.

Referenced by active_element_ptr_range().

virtual const_element_iterator libMesh::DistributedMesh::active_semilocal_elements_begin ( ) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::active_semilocal_elements_end ( )
virtual

Implements libMesh::MeshBase.

Referenced by active_element_ptr_range().

virtual const_element_iterator libMesh::DistributedMesh::active_semilocal_elements_end ( ) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::active_subdomain_elements_begin ( subdomain_id_type  subdomain_id)
virtual
virtual const_element_iterator libMesh::DistributedMesh::active_subdomain_elements_begin ( subdomain_id_type  subdomain_id) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::active_subdomain_elements_end ( subdomain_id_type  subdomain_id)
virtual
virtual const_element_iterator libMesh::DistributedMesh::active_subdomain_elements_end ( subdomain_id_type  subdomain_id) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::active_subdomain_set_elements_begin ( std::set< subdomain_id_type ss)
virtual
virtual const_element_iterator libMesh::DistributedMesh::active_subdomain_set_elements_begin ( std::set< subdomain_id_type ss) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::active_subdomain_set_elements_end ( std::set< subdomain_id_type ss)
virtual
virtual const_element_iterator libMesh::DistributedMesh::active_subdomain_set_elements_end ( std::set< subdomain_id_type ss) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::active_type_elements_begin ( ElemType  type)
virtual
virtual const_element_iterator libMesh::DistributedMesh::active_type_elements_begin ( ElemType  type) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::active_type_elements_end ( ElemType  type)
virtual
virtual const_element_iterator libMesh::DistributedMesh::active_type_elements_end ( ElemType  type) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::active_unpartitioned_elements_begin ( )
virtual

Iterate over active unpartitioned elements in the Mesh.

Implements libMesh::MeshBase.

Referenced by active_local_element_ptr_range().

virtual const_element_iterator libMesh::DistributedMesh::active_unpartitioned_elements_begin ( ) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::active_unpartitioned_elements_end ( )
virtual
virtual const_element_iterator libMesh::DistributedMesh::active_unpartitioned_elements_end ( ) const
virtual

Implements libMesh::MeshBase.

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

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

References _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::id(), libMesh::DofObject::invalid_processor_id, std::max(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::DofObject::set_id(), libMesh::DofObject::set_unique_id(), libMesh::DofObject::valid_id(), and libMesh::DofObject::valid_unique_id().

Referenced by add_extra_ghost_elem(), and reserve_elem().

412 {
413  // Don't try to add NULLs!
414  libmesh_assert(e);
415 
416  // Trying to add an existing element is a no-op
417  if (e->valid_id() && _elements[e->id()] == e)
418  return e;
419 
420  const processor_id_type elem_procid = e->processor_id();
421 
422  if (!e->valid_id())
423  {
424  // We should only be creating new ids past the end of the range
425  // of existing ids
426  libmesh_assert_greater_equal(_next_free_unpartitioned_elem_id,
427  _max_elem_id);
428  libmesh_assert_greater_equal(_next_free_local_elem_id, _max_elem_id);
429 
430  // Use the unpartitioned ids for unpartitioned elems, and
431  // temporarily for ghost elems
433  if (elem_procid == this->processor_id())
434  next_id = &_next_free_local_elem_id;
435  e->set_id (*next_id);
436  }
437 
438  {
439  // Advance next_ids up high enough that each is pointing to an
440  // unused id and any subsequent increments will still point us
441  // to unused ids
443  static_cast<dof_id_type>(e->id()+1));
444 
447  ((_max_elem_id-1) / (this->n_processors() + 1) + 1) *
448  (this->n_processors() + 1) + this->n_processors();
451  ((_max_elem_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
452  (this->n_processors() + 1) + this->processor_id();
453 
454 #ifndef NDEBUG
455  // We need a const mapvector so we don't inadvertently create
456  // NULL entries when testing for non-NULL ones
457  const mapvector<Elem *, dof_id_type> & const_elements = _elements;
458 #endif
459  libmesh_assert(!const_elements[_next_free_unpartitioned_elem_id]);
460  libmesh_assert(!const_elements[_next_free_local_elem_id]);
461  }
462 
463  // Don't try to overwrite existing elems
464  libmesh_assert (!_elements[e->id()]);
465 
466  _elements[e->id()] = e;
467 
468  // Try to make the cached elem data more accurate
469  if (elem_procid == this->processor_id() ||
470  elem_procid == DofObject::invalid_processor_id)
471  _n_elem++;
472 
473 #ifdef LIBMESH_ENABLE_UNIQUE_ID
474  if (!e->valid_unique_id())
475  {
476  if (processor_id() == e->processor_id())
477  {
478  e->set_unique_id() = _next_unique_id;
479  _next_unique_id += this->n_processors() + 1;
480  }
481  else
482  {
483  e->set_unique_id() = _next_unpartitioned_unique_id;
485  }
486  }
487 #endif
488 
489  // Unpartitioned elems should be added on every processor
490  // And shouldn't be added in the same batch as ghost elems
491  // But we might be just adding on processor 0 to
492  // broadcast later
493  // #ifdef DEBUG
494  // if (elem_procid == DofObject::invalid_processor_id)
495  // {
496  // dof_id_type elem_id = e->id();
497  // this->comm().max(elem_id);
498  // libmesh_assert_equal_to (elem_id, e->id());
499  // }
500  // #endif
501 
502  return e;
503 }
mapvector< Elem *, dof_id_type > _elements
processor_id_type n_processors() const
uint8_t processor_id_type
Definition: id_types.h:99
long double max(long double a, double b)
unique_id_type _next_unique_id
Definition: mesh_base.h:1377
static const processor_id_type invalid_processor_id
Definition: dof_object.h:335
dof_id_type _next_free_unpartitioned_elem_id
unique_id_type _next_unpartitioned_unique_id
dof_id_type _next_free_local_elem_id
processor_id_type processor_id() const
uint8_t dof_id_type
Definition: id_types.h:64
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 1425 of file distributed_mesh.C.

References _extra_ghost_elems, and add_elem().

Referenced by is_replicated().

1426 {
1427  // First add the elem like normal
1428  add_elem(e);
1429 
1430  // Now add it to the set that won't be deleted when we call
1431  // delete_remote_elements()
1432  _extra_ghost_elems.insert(e);
1433 }
std::set< Elem * > _extra_ghost_elems
virtual Elem * add_elem(Elem *e) libmesh_override
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 787 of file mesh_base.h.

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

Referenced by libMesh::DofMap::add_algebraic_ghosting_functor(), and libMesh::DofMap::add_coupling_functor().

788  { _ghosting_functors.insert(&ghosting_functor); }
std::set< GhostingFunctor * > _ghosting_functors
Definition: mesh_base.h:1434
Node * libMesh::DistributedMesh::add_node ( Node n)
virtual

Add Node n to the end of the vertex array.

Implements libMesh::MeshBase.

Definition at line 608 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, _nodes, libMesh::DofObject::id(), libMesh::DofObject::invalid_processor_id, std::max(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::DofObject::set_id(), libMesh::DofObject::set_unique_id(), libMesh::DofObject::valid_id(), and libMesh::DofObject::valid_unique_id().

Referenced by add_point(), insert_node(), and reserve_elem().

609 {
610  // Don't try to add NULLs!
611  libmesh_assert(n);
612 
613  // Trying to add an existing node is a no-op
614  if (n->valid_id() && _nodes[n->id()] == n)
615  return n;
616 
617  const processor_id_type node_procid = n->processor_id();
618 
619  if (!n->valid_id())
620  {
621  // We should only be creating new ids past the end of the range
622  // of existing ids
623  libmesh_assert_greater_equal(_next_free_unpartitioned_node_id,
624  _max_node_id);
625  libmesh_assert_greater_equal(_next_free_local_node_id, _max_node_id);
626 
627  // Use the unpartitioned ids for unpartitioned nodes,
628  // and temporarily for ghost nodes
630  if (node_procid == this->processor_id())
631  next_id = &_next_free_local_node_id;
632  n->set_id (*next_id);
633  }
634 
635  {
636  // Advance next_ids up high enough that each is pointing to an
637  // unused id and any subsequent increments will still point us
638  // to unused ids
640  static_cast<dof_id_type>(n->id()+1));
641 
644  ((_max_node_id-1) / (this->n_processors() + 1) + 1) *
645  (this->n_processors() + 1) + this->n_processors();
648  ((_max_node_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
649  (this->n_processors() + 1) + this->processor_id();
650 
651 #ifndef NDEBUG
652  // We need a const mapvector so we don't inadvertently create
653  // NULL entries when testing for non-NULL ones
654  const mapvector<Node *,dof_id_type> & const_nodes = _nodes;
655 #endif
656  libmesh_assert(!const_nodes[_next_free_unpartitioned_node_id]);
657  libmesh_assert(!const_nodes[_next_free_local_node_id]);
658  }
659 
660  // Don't try to overwrite existing nodes
661  libmesh_assert (!_nodes[n->id()]);
662 
663  _nodes[n->id()] = n;
664 
665  // Try to make the cached node data more accurate
666  if (node_procid == this->processor_id() ||
667  node_procid == DofObject::invalid_processor_id)
668  _n_nodes++;
669 
670 #ifdef LIBMESH_ENABLE_UNIQUE_ID
671  if (!n->valid_unique_id())
672  {
673  if (processor_id() == n->processor_id())
674  {
675  n->set_unique_id() = _next_unique_id;
676  _next_unique_id += this->n_processors();
677  }
678  else
679  {
680  n->set_unique_id() = _next_unpartitioned_unique_id;
682  }
683  }
684 #endif
685 
686 
687  // Unpartitioned nodes should be added on every processor
688  // And shouldn't be added in the same batch as ghost nodes
689  // But we might be just adding on processor 0 to
690  // broadcast later
691  // #ifdef DEBUG
692  // if (node_procid == DofObject::invalid_processor_id)
693  // {
694  // dof_id_type node_id = n->id();
695  // this->comm().max(node_id);
696  // libmesh_assert_equal_to (node_id, n->id());
697  // }
698  // #endif
699 
700  return n;
701 }
dof_id_type _next_free_local_node_id
processor_id_type n_processors() const
uint8_t processor_id_type
Definition: id_types.h:99
long double max(long double a, double b)
unique_id_type _next_unique_id
Definition: mesh_base.h:1377
mapvector< Node *, dof_id_type > _nodes
static const processor_id_type invalid_processor_id
Definition: dof_object.h:335
dof_id_type _next_free_unpartitioned_node_id
unique_id_type _next_unpartitioned_unique_id
processor_id_type processor_id() const
uint8_t dof_id_type
Definition: id_types.h:64
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 
)
virtual

functions for adding /deleting nodes elements.

Implements libMesh::MeshBase.

Definition at line 584 of file distributed_mesh.C.

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

Referenced by reserve_elem().

587 {
588  if (_nodes.count(id))
589  {
590  Node * n = _nodes[id];
591  libmesh_assert (n);
592  libmesh_assert_equal_to (n->id(), id);
593 
594  *n = p;
595  n->processor_id() = proc_id;
596 
597  return n;
598  }
599 
600  Node * n = Node::build(p, id).release();
601  n->processor_id() = proc_id;
602 
603  return DistributedMesh::add_node(n);
604 }
virtual Node * add_node(Node *n) libmesh_override
mapvector< Node *, dof_id_type > _nodes
static std::unique_ptr< Node > build(const Node &n)
Definition: node.h:298
void libMesh::UnstructuredMesh::all_first_order ( )
virtualinherited

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.

Loop over the high-ordered elements. First make sure they are indeed high-order, and then replace them with an equivalent first-order element.

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 283 of file mesh_modification.C.

References libMesh::MeshBase::_is_prepared, libMesh::Elem::add_child(), libMesh::Elem::build(), libMesh::Elem::child_ptr(), libMesh::BoundaryInfo::copy_boundary_ids(), libMesh::MeshBase::delete_node(), libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::Elem::first_order_equivalent_type(), libMesh::MeshBase::get_boundary_info(), libMesh::Elem::has_children(), libMesh::DofObject::id(), libMesh::MeshBase::insert_elem(), libMesh::MeshBase::max_node_id(), libMesh::Elem::n_children(), libMesh::Elem::n_sides(), libMesh::Elem::n_vertices(), libMesh::Elem::neighbor_ptr(), libMesh::Elem::node_id(), libMesh::Elem::node_ptr(), libMesh::MeshBase::nodes_begin(), libMesh::MeshBase::nodes_end(), libMesh::Elem::p_level(), libMesh::Elem::p_refinement_flag(), libMesh::Elem::parent(), libMesh::MeshBase::prepare_for_use(), libMesh::DofObject::processor_id(), libMesh::Elem::refinement_flag(), libMesh::BoundaryInfo::regenerate_id_sets(), libMesh::remote_elem, libMesh::MeshBase::renumber_nodes_and_elements(), libMesh::Elem::replace_child(), 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(), libMesh::DofObject::set_unique_id(), libMesh::Elem::subdomain_id(), libMesh::Elem::type(), libMesh::DofObject::unique_id(), and libMesh::Elem::which_child_am_i().

284 {
285  /*
286  * when the mesh is not prepared,
287  * at least renumber the nodes and
288  * elements, so that the node ids
289  * are correct
290  */
291  if (!this->_is_prepared)
293 
294  START_LOG("all_first_order()", "Mesh");
295 
299  std::vector<bool> node_touched_by_me(this->max_node_id(), false);
300 
306  element_iterator endit = elements_end();
307  for (element_iterator it = elements_begin();
308  it != endit; ++it)
309  {
310  Elem * so_elem = *it;
311 
312  libmesh_assert(so_elem);
313 
314  /*
315  * build the first-order equivalent, add to
316  * the new_elements list.
317  */
318  Elem * lo_elem = Elem::build
320  (so_elem->type()), so_elem->parent()).release();
321 
322  const unsigned short n_sides = so_elem->n_sides();
323 
324  for (unsigned short s=0; s != n_sides; ++s)
325  if (so_elem->neighbor_ptr(s) == remote_elem)
326  lo_elem->set_neighbor(s, const_cast<RemoteElem *>(remote_elem));
327 
328 #ifdef LIBMESH_ENABLE_AMR
329  /*
330  * Reset the parent links of any child elements
331  */
332  if (so_elem->has_children())
333  for (unsigned int c = 0, nc = so_elem->n_children(); c != nc; ++c)
334  {
335  Elem * child = so_elem->child_ptr(c);
336  child->set_parent(lo_elem);
337  lo_elem->add_child(child, c);
338  }
339 
340  /*
341  * Reset the child link of any parent element
342  */
343  if (so_elem->parent())
344  {
345  unsigned int c =
346  so_elem->parent()->which_child_am_i(so_elem);
347  lo_elem->parent()->replace_child(lo_elem, c);
348  }
349 
350  /*
351  * Copy as much data to the new element as makes sense
352  */
353  lo_elem->set_p_level(so_elem->p_level());
354  lo_elem->set_refinement_flag(so_elem->refinement_flag());
355  lo_elem->set_p_refinement_flag(so_elem->p_refinement_flag());
356 #endif
357 
358  libmesh_assert_equal_to (lo_elem->n_vertices(), so_elem->n_vertices());
359 
360  /*
361  * By definition the vertices of the linear and
362  * second order element are identically numbered.
363  * transfer these.
364  */
365  for (unsigned int v=0; v < so_elem->n_vertices(); v++)
366  {
367  lo_elem->set_node(v) = so_elem->node_ptr(v);
368  node_touched_by_me[lo_elem->node_id(v)] = true;
369  }
370 
371  /*
372  * find_neighbors relies on remote_elem neighbor links being
373  * properly maintained.
374  */
375  for (unsigned short s=0; s != n_sides; s++)
376  {
377  if (so_elem->neighbor_ptr(s) == remote_elem)
378  lo_elem->set_neighbor(s, const_cast<RemoteElem*>(remote_elem));
379  }
380 
388  (this->get_boundary_info(), so_elem, lo_elem);
389 
390  /*
391  * The new first-order element is ready.
392  * Inserting it into the mesh will replace and delete
393  * the second-order element.
394  */
395  lo_elem->set_id(so_elem->id());
396 #ifdef LIBMESH_ENABLE_UNIQUE_ID
397  lo_elem->set_unique_id() = so_elem->unique_id();
398 #endif
399  lo_elem->processor_id() = so_elem->processor_id();
400  lo_elem->subdomain_id() = so_elem->subdomain_id();
401  this->insert_elem(lo_elem);
402  }
403 
404  const MeshBase::node_iterator nd_end = this->nodes_end();
405  MeshBase::node_iterator nd = this->nodes_begin();
406  while (nd != nd_end)
407  {
408  Node * the_node = *nd;
409  ++nd;
410  if (!node_touched_by_me[the_node->id()])
411  this->delete_node(the_node);
412  }
413 
414  // If crazy people applied boundary info to non-vertices and then
415  // deleted those non-vertices, we should make sure their boundary id
416  // caches are correct.
418 
419  STOP_LOG("all_first_order()", "Mesh");
420 
421  // On hanging nodes that used to also be second order nodes, we
422  // might now have an invalid nodal processor_id()
424 
425  // delete or renumber nodes if desired
426  this->prepare_for_use();
427 }
const BoundaryInfo & get_boundary_info() const
Definition: mesh_base.h:118
static void set_node_processor_ids(MeshBase &mesh)
Definition: partitioner.C:416
virtual dof_id_type max_node_id() const =0
virtual node_iterator nodes_begin()=0
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
virtual void delete_node(Node *n)=0
void prepare_for_use(const bool skip_renumber_nodes_and_elements=false, const bool skip_find_neighbors=false)
Definition: mesh_base.C:176
virtual Elem * insert_elem(Elem *e)=0
virtual node_iterator nodes_end()=0
void copy_boundary_ids(const BoundaryInfo &old_boundary_info, const Elem *const old_elem, const Elem *const new_elem)
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=libmesh_nullptr)
Definition: elem.C:239
static ElemType first_order_equivalent_type(const ElemType et)
Definition: elem.C:2613
virtual void renumber_nodes_and_elements()=0
const RemoteElem * remote_elem
Definition: remote_elem.C:57
void libMesh::UnstructuredMesh::all_second_order ( const bool  full_ordered = true)
virtualinherited

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.

Loop over the low-ordered elements in the elements vector. First make sure they _are indeed low-order, and then replace them with an equivalent second-order element. Don't forget to delete the low-order element, or else it will leak!

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

Also, prepare_for_use() will reconstruct most of our neighbor links, but if we have any remote_elem links in a distributed mesh, they need to be preserved. We do that in the same loop here.

Implements libMesh::MeshBase.

Definition at line 431 of file mesh_modification.C.

References libMesh::MeshBase::_is_prepared, libMesh::MeshBase::add_point(), libMesh::Elem::build(), libMesh::ParallelObject::comm(), libMesh::BoundaryInfo::copy_boundary_ids(), libMesh::Elem::default_order(), libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::FIRST, libMesh::MeshBase::get_boundary_info(), libMesh::DofObject::id(), libMesh::MeshBase::insert_elem(), libMesh::DofObject::invalid_id, libMesh::MeshBase::is_serial(), libMesh::Elem::level(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::Parallel::Communicator::max(), libMesh::MeshBase::mesh_dimension(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::Elem::n_vertices(), libMesh::Elem::neighbor_ptr(), libMesh::Elem::node_ptr(), libMesh::MeshBase::point(), libMesh::MeshBase::prepare_for_use(), libMesh::DofObject::processor_id(), libMesh::Real, libMesh::remote_elem, libMesh::MeshBase::renumber_nodes_and_elements(), libMesh::MeshBase::reserve_nodes(), libMesh::Elem::second_order_equivalent_type(), libMesh::Elem::side_index_range(), libMesh::Elem::subdomain_id(), libMesh::Elem::type(), and libMesh::DofObject::unique_id().

Referenced by libMesh::MeshTools::Generation::build_cube(), and libMesh::MeshTools::Generation::build_sphere().

432 {
433  // This function must be run on all processors at once
434  parallel_object_only();
435 
436  /*
437  * when the mesh is not prepared,
438  * at least renumber the nodes and
439  * elements, so that the node ids
440  * are correct
441  */
442  if (!this->_is_prepared)
444 
445  /*
446  * If the mesh is empty
447  * then we have nothing to do
448  */
449  if (!this->n_elem())
450  return;
451 
452  /*
453  * If the mesh is already second order
454  * then we have nothing to do.
455  * We have to test for this in a round-about way to avoid
456  * a bug on distributed parallel meshes with more processors
457  * than elements.
458  */
459  bool already_second_order = false;
460  if (this->elements_begin() != this->elements_end() &&
461  (*(this->elements_begin()))->default_order() != FIRST)
462  already_second_order = true;
463  this->comm().max(already_second_order);
464  if (already_second_order)
465  return;
466 
467  START_LOG("all_second_order()", "Mesh");
468 
469  /*
470  * this map helps in identifying second order
471  * nodes. Namely, a second-order node:
472  * - edge node
473  * - face node
474  * - bubble node
475  * is uniquely defined through a set of adjacent
476  * vertices. This set of adjacent vertices is
477  * used to identify already added higher-order
478  * nodes. We are safe to use node id's since we
479  * make sure that these are correctly numbered.
480  */
481  std::map<std::vector<dof_id_type>, Node *> adj_vertices_to_so_nodes;
482 
483  /*
484  * for speed-up of the \p add_point() method, we
485  * can reserve memory. Guess the number of additional
486  * nodes for different dimensions
487  */
488  switch (this->mesh_dimension())
489  {
490  case 1:
491  /*
492  * in 1D, there can only be order-increase from Edge2
493  * to Edge3. Something like 1/2 of n_nodes() have
494  * to be added
495  */
496  this->reserve_nodes(static_cast<unsigned int>
497  (1.5*static_cast<double>(this->n_nodes())));
498  break;
499 
500  case 2:
501  /*
502  * in 2D, either refine from Tri3 to Tri6 (double the nodes)
503  * or from Quad4 to Quad8 (again, double) or Quad9 (2.25 that much)
504  */
505  this->reserve_nodes(static_cast<unsigned int>
506  (2*static_cast<double>(this->n_nodes())));
507  break;
508 
509 
510  case 3:
511  /*
512  * in 3D, either refine from Tet4 to Tet10 (factor = 2.5) up to
513  * Hex8 to Hex27 (something > 3). Since in 3D there _are_ already
514  * quite some nodes, and since we do not want to overburden the memory by
515  * a too conservative guess, use the lower bound
516  */
517  this->reserve_nodes(static_cast<unsigned int>
518  (2.5*static_cast<double>(this->n_nodes())));
519  break;
520 
521  default:
522  // Hm?
523  libmesh_error_msg("Unknown mesh dimension " << this->mesh_dimension());
524  }
525 
526 
527 
528  /*
529  * form a vector that will hold the node id's of
530  * the vertices that are adjacent to the son-th
531  * second-order node. Pull this outside of the
532  * loop so that silly compilers don't repeatedly
533  * create and destroy the vector.
534  */
535  std::vector<dof_id_type> adjacent_vertices_ids;
536 
543  element_iterator
544  it = elements_begin(),
545  endit = elements_end();
546 
547  for (; it != endit; ++it)
548  {
549  // the linear-order element
550  Elem * lo_elem = *it;
551 
552  libmesh_assert(lo_elem);
553 
554  // make sure it is linear order
555  if (lo_elem->default_order() != FIRST)
556  libmesh_error_msg("ERROR: This is not a linear element: type=" << lo_elem->type());
557 
558  // this does _not_ work for refined elements
559  libmesh_assert_equal_to (lo_elem->level (), 0);
560 
561  /*
562  * build the second-order equivalent, add to
563  * the new_elements list. Note that this here
564  * is the only point where \p full_ordered
565  * is necessary. The remaining code works well
566  * for either type of second-order equivalent, e.g.
567  * Hex20 or Hex27, as equivalents for Hex8
568  */
569  Elem * so_elem =
571  full_ordered) ).release();
572 
573  libmesh_assert_equal_to (lo_elem->n_vertices(), so_elem->n_vertices());
574 
575 
576  /*
577  * By definition the vertices of the linear and
578  * second order element are identically numbered.
579  * transfer these.
580  */
581  for (unsigned int v=0; v < lo_elem->n_vertices(); v++)
582  so_elem->set_node(v) = lo_elem->node_ptr(v);
583 
584  /*
585  * Now handle the additional mid-side nodes. This
586  * is simply handled through a map that remembers
587  * the already-added nodes. This map maps the global
588  * ids of the vertices (that uniquely define this
589  * higher-order node) to the new node.
590  * Notation: son = second-order node
591  */
592  const unsigned int son_begin = so_elem->n_vertices();
593  const unsigned int son_end = so_elem->n_nodes();
594 
595 
596  for (unsigned int son=son_begin; son<son_end; son++)
597  {
598  const unsigned int n_adjacent_vertices =
599  so_elem->n_second_order_adjacent_vertices(son);
600 
601  adjacent_vertices_ids.resize(n_adjacent_vertices);
602 
603  for (unsigned int v=0; v<n_adjacent_vertices; v++)
604  adjacent_vertices_ids[v] =
605  so_elem->node_id( so_elem->second_order_adjacent_vertex(son,v) );
606 
607  /*
608  * \p adjacent_vertices_ids is now in order of the current
609  * side. sort it, so that comparisons with the
610  * \p adjacent_vertices_ids created through other elements'
611  * sides can match
612  */
613  std::sort(adjacent_vertices_ids.begin(),
614  adjacent_vertices_ids.end());
615 
616 
617  // does this set of vertices already has a mid-node added?
618  std::pair<std::map<std::vector<dof_id_type>, Node *>::iterator,
619  std::map<std::vector<dof_id_type>, Node *>::iterator>
620  pos = adj_vertices_to_so_nodes.equal_range (adjacent_vertices_ids);
621 
622  // no, not added yet
623  if (pos.first == pos.second)
624  {
625  /*
626  * for this set of vertices, there is no
627  * second_order node yet. Add it.
628  *
629  * compute the location of the new node as
630  * the average over the adjacent vertices.
631  */
632  Point new_location = this->point(adjacent_vertices_ids[0]);
633  for (unsigned int v=1; v<n_adjacent_vertices; v++)
634  new_location += this->point(adjacent_vertices_ids[v]);
635 
636  new_location /= static_cast<Real>(n_adjacent_vertices);
637 
638  /* Add the new point to the mesh.
639  * If we are on a serialized mesh, then we're doing this
640  * all in sync, and the node processor_id will be
641  * consistent between processors.
642  * If we are on a distributed mesh, we can fix
643  * inconsistent processor ids later, but only if every
644  * processor gives new nodes a *locally* consistent
645  * processor id, so we'll give the new node the
646  * processor id of an adjacent element for now and then
647  * we'll update that later if appropriate.
648  */
649  Node * so_node = this->add_point
650  (new_location, DofObject::invalid_id,
651  lo_elem->processor_id());
652 
653  /*
654  * insert the new node with its defining vertex
655  * set into the map, and relocate pos to this
656  * new entry, so that the so_elem can use
657  * \p pos for inserting the node
658  */
659  adj_vertices_to_so_nodes.insert(pos.first,
660  std::make_pair(adjacent_vertices_ids,
661  so_node));
662 
663  so_elem->set_node(son) = so_node;
664  }
665  // yes, already added.
666  else
667  {
668  Node * so_node = pos.first->second;
669  libmesh_assert(so_node);
670 
671  so_elem->set_node(son) = so_node;
672 
673  // We need to ensure that the processor who should own a
674  // node *knows* they own the node.
675  if (so_node->processor_id() > lo_elem->processor_id())
676  so_node->processor_id() = lo_elem->processor_id();
677  }
678  }
679 
680  /*
681  * find_neighbors relies on remote_elem neighbor links being
682  * properly maintained.
683  */
684  for (auto s : lo_elem->side_index_range())
685  {
686  if (lo_elem->neighbor_ptr(s) == remote_elem)
687  so_elem->set_neighbor(s, const_cast<RemoteElem*>(remote_elem));
688  }
689 
702  (this->get_boundary_info(), lo_elem, so_elem);
703 
704  /*
705  * The new second-order element is ready.
706  * Inserting it into the mesh will replace and delete
707  * the first-order element.
708  */
709  so_elem->set_id(lo_elem->id());
710 #ifdef LIBMESH_ENABLE_UNIQUE_ID
711  so_elem->set_unique_id() = lo_elem->unique_id();
712 #endif
713  so_elem->processor_id() = lo_elem->processor_id();
714  so_elem->subdomain_id() = lo_elem->subdomain_id();
715  this->insert_elem(so_elem);
716  }
717 
718  // we can clear the map
719  adj_vertices_to_so_nodes.clear();
720 
721 
722  STOP_LOG("all_second_order()", "Mesh");
723 
724  // In a DistributedMesh our ghost node processor ids may be bad,
725  // the ids of nodes touching remote elements may be inconsistent,
726  // and unique_ids of newly added non-local nodes remain unset.
727  // make_nodes_parallel_consistent() will fix all this.
728  if (!this->is_serial())
729  MeshCommunication().make_nodes_parallel_consistent (*this);
730 
731  // renumber nodes, elements etc
732  this->prepare_for_use(/*skip_renumber =*/ false);
733 }
const BoundaryInfo & get_boundary_info() const
Definition: mesh_base.h:118
virtual void reserve_nodes(const dof_id_type nn)=0
virtual bool is_serial() const
Definition: mesh_base.h:141
virtual const Point & point(const dof_id_type i) const =0
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
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
static const dof_id_type invalid_id
Definition: dof_object.h:324
void prepare_for_use(const bool skip_renumber_nodes_and_elements=false, const bool skip_find_neighbors=false)
Definition: mesh_base.C:176
static ElemType second_order_equivalent_type(const ElemType et, const bool full_ordered=true)
Definition: elem.C:2672
virtual Elem * insert_elem(Elem *e)=0
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void copy_boundary_ids(const BoundaryInfo &old_boundary_info, const Elem *const old_elem, const Elem *const new_elem)
const Parallel::Communicator & comm() const
unsigned int mesh_dimension() const
Definition: mesh_base.C:150
virtual dof_id_type n_nodes() const =0
virtual dof_id_type n_elem() const =0
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=libmesh_nullptr)
Definition: elem.C:239
virtual void renumber_nodes_and_elements()=0
const RemoteElem * remote_elem
Definition: remote_elem.C:57
void libMesh::DistributedMesh::allgather ( )
virtual

Gathers all elements and nodes of the mesh onto every processor

Reimplemented from libMesh::MeshBase.

Definition at line 1436 of file distributed_mesh.C.

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

Referenced by is_replicated().

1437 {
1438  if (_is_serial)
1439  return;
1440  MeshCommunication().allgather(*this);
1441  _is_serial = true;
1442  _is_serial_on_proc_0 = true;
1443 
1444  // Make sure our caches are up to date and our
1445  // DofObjects are well packed
1446 #ifdef DEBUG
1447  libmesh_assert_equal_to (this->n_nodes(), this->parallel_n_nodes());
1448  libmesh_assert_equal_to (this->n_elem(), this->parallel_n_elem());
1449  const dof_id_type pmax_node_id = this->parallel_max_node_id();
1450  const dof_id_type pmax_elem_id = this->parallel_max_elem_id();
1451  libmesh_assert_equal_to (this->max_node_id(), pmax_node_id);
1452  libmesh_assert_equal_to (this->max_elem_id(), pmax_elem_id);
1453 
1454  // If we've disabled renumbering we can't be sure we're contiguous
1455  // libmesh_assert_equal_to (this->n_nodes(), this->max_node_id());
1456  // libmesh_assert_equal_to (this->n_elem(), this->max_elem_id());
1457 
1458  // Make sure our neighbor links are all fine
1460 
1461  // Make sure our ids and flags are consistent
1464 #endif
1465 }
virtual dof_id_type n_elem() const libmesh_override
dof_id_type parallel_max_elem_id() const
void libmesh_assert_valid_parallel_flags() const
dof_id_type parallel_max_node_id() const
virtual dof_id_type n_nodes() const libmesh_override
virtual dof_id_type max_node_id() const libmesh_override
virtual dof_id_type parallel_n_nodes() const libmesh_override
void libmesh_assert_valid_neighbors(const MeshBase &mesh, bool assert_valid_remote_elems=true)
Definition: mesh_tools.C:1707
virtual dof_id_type parallel_n_elem() const libmesh_override
virtual dof_id_type max_elem_id() const libmesh_override
uint8_t dof_id_type
Definition: id_types.h:64
virtual void libmesh_assert_valid_parallel_ids() const libmesh_override
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 759 of file mesh_base.h.

References libMesh::MeshBase::_allow_remote_element_removal.

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

bool _allow_remote_element_removal
Definition: mesh_base.h:1398
bool libMesh::MeshBase::allow_remote_element_removal ( ) const
inlineinherited
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.

Definition at line 750 of file mesh_base.h.

References libMesh::MeshBase::_skip_renumber_nodes_and_elements.

Referenced by libMesh::UnstructuredMesh::copy_nodes_and_elements(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ErrorVector::plot_error(), libMesh::NameBasedIO::read(), and libMesh::GMVIO::read().

bool _skip_renumber_nodes_and_elements
Definition: mesh_base.h:1390
bool libMesh::MeshBase::allow_renumbering ( ) const
inlineinherited
virtual element_iterator libMesh::DistributedMesh::ancestor_elements_begin ( )
virtual

Iterate over elements for which elem->ancestor() is true.

Implements libMesh::MeshBase.

Referenced by active_element_ptr_range().

virtual const_element_iterator libMesh::DistributedMesh::ancestor_elements_begin ( ) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::ancestor_elements_end ( )
virtual

Implements libMesh::MeshBase.

Referenced by active_element_ptr_range().

virtual const_element_iterator libMesh::DistributedMesh::ancestor_elements_end ( ) const
virtual

Implements libMesh::MeshBase.

virtual node_iterator libMesh::DistributedMesh::bid_nodes_begin ( boundary_id_type  bndry_id)
virtual

Iterate over nodes for which BoundaryInfo::has_boundary_id(node, bndry_id) is true.

Implements libMesh::MeshBase.

Referenced by local_node_ptr_range().

virtual const_node_iterator libMesh::DistributedMesh::bid_nodes_begin ( boundary_id_type  bndry_id) const
virtual

Implements libMesh::MeshBase.

virtual node_iterator libMesh::DistributedMesh::bid_nodes_end ( boundary_id_type  bndry_id)
virtual

Implements libMesh::MeshBase.

Referenced by local_node_ptr_range().

virtual const_node_iterator libMesh::DistributedMesh::bid_nodes_end ( boundary_id_type  bndry_id) const
virtual

Implements libMesh::MeshBase.

virtual node_iterator libMesh::DistributedMesh::bnd_nodes_begin ( )
virtual

Iterate over nodes for which BoundaryInfo::n_boundary_ids(node) > 0.

Implements libMesh::MeshBase.

Referenced by local_node_ptr_range().

virtual const_node_iterator libMesh::DistributedMesh::bnd_nodes_begin ( ) const
virtual

Implements libMesh::MeshBase.

virtual node_iterator libMesh::DistributedMesh::bnd_nodes_end ( )
virtual

Implements libMesh::MeshBase.

Referenced by local_node_ptr_range().

virtual const_node_iterator libMesh::DistributedMesh::bnd_nodes_end ( ) const
virtual

Implements libMesh::MeshBase.

void libMesh::MeshBase::cache_elem_dims ( )
inherited

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

References libMesh::MeshBase::_elem_dims, libMesh::MeshBase::_spatial_dimension, libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), libMesh::ParallelObject::comm(), end, libMesh::MeshBase::mesh_dimension(), libMesh::MeshBase::node(), libMesh::MeshBase::nodes_begin(), libMesh::MeshBase::nodes_end(), and libMesh::Parallel::Communicator::set_union().

Referenced by libMesh::MeshCommunication::broadcast(), libMesh::MeshBase::get_subdomain_name_map(), and libMesh::MeshBase::prepare_for_use().

615 {
616  // This requires an inspection on every processor
617  parallel_object_only();
618 
619  // Need to clear _elem_dims first in case all elements of a
620  // particular dimension have been deleted.
621  _elem_dims.clear();
622 
623  const_element_iterator el = this->active_elements_begin();
624  const_element_iterator end = this->active_elements_end();
625 
626  for (; el!=end; ++el)
627  _elem_dims.insert((*el)->dim());
628 
629  // Some different dimension elements may only live on other processors
630  this->comm().set_union(_elem_dims);
631 
632  // If the largest element dimension found is larger than the current
633  // _spatial_dimension, increase _spatial_dimension.
634  unsigned int max_dim = this->mesh_dimension();
635  if (max_dim > _spatial_dimension)
636  _spatial_dimension = cast_int<unsigned char>(max_dim);
637 
638  // _spatial_dimension may need to increase from 1->2 or 2->3 if the
639  // mesh is full of 1D elements but they are not x-aligned, or the
640  // mesh is full of 2D elements but they are not in the x-y plane.
641  // If the mesh is x-aligned or x-y planar, we will end up checking
642  // every node's coordinates and not breaking out of the loop
643  // early...
644  if (_spatial_dimension < 3)
645  {
646  const_node_iterator node_it = this->nodes_begin();
647  const_node_iterator node_end = this->nodes_end();
648  for (; node_it != node_end; ++node_it)
649  {
650  Node & node = **node_it;
651 
652 #if LIBMESH_DIM > 1
653  // Note: the exact floating point comparison is intentional,
654  // we don't want to get tripped up by tolerances.
655  if (node(1) != 0.)
656  {
657  _spatial_dimension = 2;
658 #if LIBMESH_DIM == 2
659  // If libmesh is compiled in 2D mode, this is the
660  // largest spatial dimension possible so we can break
661  // out.
662  break;
663 #endif
664  }
665 #endif
666 
667 #if LIBMESH_DIM > 2
668  if (node(2) != 0.)
669  {
670  // Spatial dimension can't get any higher than this, so
671  // we can break out.
672  _spatial_dimension = 3;
673  break;
674  }
675 #endif
676  }
677  }
678 }
IterBase * end
unsigned char _spatial_dimension
Definition: mesh_base.h:1418
virtual node_iterator nodes_begin()=0
std::set< unsigned char > _elem_dims
Definition: mesh_base.h:1412
virtual element_iterator active_elements_begin()=0
virtual element_iterator active_elements_end()=0
virtual node_iterator nodes_end()=0
const Parallel::Communicator & comm() const
unsigned int mesh_dimension() const
Definition: mesh_base.C:150
virtual const Node & node(const dof_id_type i) const
Definition: mesh_base.h:441
void set_union(T &data, const unsigned int root_id) const
void libMesh::DistributedMesh::clear ( )
virtual

Clear all internal data.

Reimplemented from libMesh::MeshBase.

Definition at line 776 of file distributed_mesh.C.

References _elements, _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, _nodes, libMesh::MeshBase::clear(), end, libMesh::ParallelObject::n_processors(), and libMesh::ParallelObject::processor_id().

Referenced by clone(), DistributedMesh(), and libMesh::BoundaryMesh::~BoundaryMesh().

777 {
778  // Call parent clear function
779  MeshBase::clear();
780 
781 
782  // Clear our elements and nodes
783  {
784  elem_iterator_imp it = _elements.begin();
785  const elem_iterator_imp end = _elements.end();
786 
787  // There is no need to remove the elements from
788  // the BoundaryInfo data structure since we
789  // already cleared it.
790  for (; it != end; ++it)
791  delete *it;
792 
793  _elements.clear();
794  }
795 
796  // clear the nodes data structure
797  {
798  node_iterator_imp it = _nodes.begin();
799  node_iterator_imp end = _nodes.end();
800 
801  // There is no need to remove the nodes from
802  // the BoundaryInfo data structure since we
803  // already cleared it.
804  for (; it != end; ++it)
805  delete *it;
806 
807  _nodes.clear();
808  }
809 
810  // We're no longer distributed if we were before
811  _is_serial = true;
812  _is_serial_on_proc_0 = true;
813 
814  // Correct our caches
815  _n_nodes = 0;
816  _n_elem = 0;
817  _max_node_id = 0;
818  _max_elem_id = 0;
823 }
mapvector< Elem *, dof_id_type > _elements
dof_id_type _next_free_local_node_id
processor_id_type n_processors() const
IterBase * end
mapvector< Node *, dof_id_type >::veclike_iterator node_iterator_imp
mapvector< Node *, dof_id_type > _nodes
virtual void clear()
Definition: mesh_base.C:287
dof_id_type _next_free_unpartitioned_node_id
dof_id_type _next_free_unpartitioned_elem_id
mapvector< Elem *, dof_id_type >::veclike_iterator elem_iterator_imp
dof_id_type _next_free_local_elem_id
processor_id_type processor_id() const
virtual void libMesh::DistributedMesh::clear_extra_ghost_elems ( )
inlinevirtual

Clears extra ghost elements.

Definition at line 221 of file distributed_mesh.h.

References _extra_ghost_elems.

221 { _extra_ghost_elems.clear(); }
std::set< Elem * > _extra_ghost_elems
void libMesh::MeshBase::clear_point_locator ( )
inherited
virtual std::unique_ptr<MeshBase> libMesh::DistributedMesh::clone ( ) const
inlinevirtual

Virtual copy-constructor, creates a copy of this mesh

Implements libMesh::MeshBase.

Reimplemented in libMesh::ParallelMesh.

Definition at line 94 of file distributed_mesh.h.

References clear(), redistribute(), update_post_partitioning(), and ~DistributedMesh().

95  { return libmesh_make_unique<DistributedMesh>(*this); }
const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inlineinherited
Returns
A reference to the Parallel::Communicator object used by this mesh.

Definition at line 87 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_petsc_snes_fd_residual(), libMesh::__libmesh_petsc_snes_jacobian(), libMesh::__libmesh_petsc_snes_mffd_residual(), libMesh::__libmesh_petsc_snes_postcheck(), libMesh::__libmesh_petsc_snes_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::ParmetisPartitioner::_do_repartition(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult_add(), libMesh::EquationSystems::_read_impl(), libMesh::MeshRefinement::_refine_elements(), libMesh::MeshRefinement::_smooth_flags(), libMesh::ImplicitSystem::add_matrix(), libMesh::System::add_vector(), libMesh::EigenSparseLinearSolver< T >::adjoint_solve(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::DofMap::attach_matrix(), libMesh::Parallel::BinSorter< KeyType, IdxType >::binsort(), libMesh::Parallel::Sort< KeyType, IdxType >::binsort(), libMesh::MeshCommunication::broadcast(), libMesh::SparseMatrix< T >::build(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::Parallel::Histogram< KeyType, IdxType >::build_histogram(), libMesh::PetscNonlinearSolver< T >::build_mat_null_space(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::MeshBase::cache_elem_dims(), libMesh::System::calculate_norm(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::DistributedVector< T >::clone(), libMesh::EigenSparseVector< T >::clone(), libMesh::LaspackVector< T >::clone(), libMesh::EpetraVector< T >::clone(), libMesh::PetscVector< T >::clone(), libMesh::EpetraVector< T >::close(), libMesh::Parallel::Sort< KeyType, IdxType >::communicate_bins(), 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::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshTools::create_bounding_box(), 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::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), DMVariableBounds_libMesh(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::EpetraVector< T >::EpetraVector(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::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_nelem_target(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::DofMap::get_info(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::EquationSystems::get_solution(), libMesh::LocationMap< T >::init(), libMesh::TopologyMap::init(), libMesh::TimeSolver::init(), libMesh::TaoOptimizationSolver< T >::init(), libMesh::PetscNonlinearSolver< T >::init(), libMesh::DistributedVector< T >::init(), libMesh::EpetraVector< T >::init(), libMesh::PetscVector< T >::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::EigenSystem::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::ParmetisPartitioner::initialize(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), 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_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_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::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_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::DistributedVector< T >::max(), libMesh::FEMSystem::mesh_position_set(), libMesh::MeshSerializer::MeshSerializer(), libMesh::DistributedVector< T >::min(), n_active_elem(), libMesh::MeshTools::n_active_levels(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::MeshTools::n_levels(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::MeshTools::n_p_levels(), libMesh::BoundaryInfo::n_shellface_conds(), 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::MeshTools::paranoid_n_levels(), libMesh::Partitioner::partition(), libMesh::LinearPartitioner::partition_range(), libMesh::MetisPartitioner::partition_range(), 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::SparseMatrix< T >::print(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshCommunication::redistribute(), libMesh::MeshRefinement::refine_and_coarsen_elements(), renumber_dof_objects(), libMesh::CheckpointIO::select_split_config(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::PetscDiffSolver::setup_petsc_data(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::Parallel::Sort< KeyType, IdxType >::sort(), libMesh::split_mesh(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::Parallel::sync_element_data_by_parent_id(), libMesh::Parallel::sync_node_data_by_element_id(), libMesh::MeshRefinement::test_level_one(), libMesh::MeshRefinement::test_unflagged(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::DistributedVector< T >::zero_clone(), libMesh::EigenSparseVector< T >::zero_clone(), libMesh::LaspackVector< T >::zero_clone(), libMesh::EpetraVector< T >::zero_clone(), and libMesh::PetscVector< T >::zero_clone().

88  { return _communicator; }
const Parallel::Communicator & _communicator
bool libMesh::UnstructuredMesh::contract ( )
virtualinherited

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

References libMesh::Elem::active(), libMesh::Elem::ancestor(), libMesh::MeshBase::clear_point_locator(), libMesh::Elem::contract(), libMesh::MeshBase::delete_elem(), libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), end, libMesh::MeshBase::ghosting_functors_begin(), libMesh::MeshBase::ghosting_functors_end(), libmesh_nullptr, libMesh::GhostingFunctor::mesh_reinit(), libMesh::Elem::parent(), libMesh::MeshBase::renumber_nodes_and_elements(), and libMesh::Elem::subactive().

779 {
780  LOG_SCOPE ("contract()", "Mesh");
781 
782  // Flag indicating if this call actually changes the mesh
783  bool mesh_changed = false;
784 
785  element_iterator in = elements_begin();
786  const element_iterator end = elements_end();
787 
788 #ifdef DEBUG
789  for ( ; in != end; ++in)
790  if (*in != libmesh_nullptr)
791  {
792  Elem * el = *in;
793  libmesh_assert(el->active() || el->subactive() || el->ancestor());
794  }
795  in = elements_begin();
796 #endif
797 
798  // Loop over the elements.
799  for ( ; in != end; ++in)
800  if (*in != libmesh_nullptr)
801  {
802  Elem * el = *in;
803 
804  // Delete all the subactive ones
805  if (el->subactive())
806  {
807  // No level-0 element should be subactive.
808  // Note that we CAN'T test elem->level(), as that
809  // touches elem->parent()->dim(), and elem->parent()
810  // might have already been deleted!
811  libmesh_assert(el->parent());
812 
813  // Delete the element
814  // This just sets a pointer to NULL, and doesn't
815  // invalidate any iterators
816  this->delete_elem(el);
817 
818  // the mesh has certainly changed
819  mesh_changed = true;
820  }
821  else
822  {
823  // Compress all the active ones
824  if (el->active())
825  el->contract();
826  else
827  libmesh_assert (el->ancestor());
828  }
829  }
830 
831  // Strip any newly-created NULL voids out of the element array
833 
834  // FIXME: Need to understand why deleting subactive children
835  // invalidates the point locator. For now we will clear it explicitly
836  this->clear_point_locator();
837 
838  // Allow our GhostingFunctor objects to reinit if necessary.
839  std::set<GhostingFunctor *>::iterator gf_it = this->ghosting_functors_begin();
840  const std::set<GhostingFunctor *>::iterator gf_end = this->ghosting_functors_end();
841  for (; gf_it != gf_end; ++gf_it)
842  {
843  GhostingFunctor *gf = *gf_it;
844  libmesh_assert(gf);
845  gf->mesh_reinit();
846  }
847 
848  return mesh_changed;
849 }
const class libmesh_nullptr_t libmesh_nullptr
IterBase * end
std::set< GhostingFunctor * >::const_iterator ghosting_functors_end() const
Definition: mesh_base.h:805
virtual element_iterator elements_begin()=0
virtual void delete_elem(Elem *e)=0
virtual element_iterator elements_end()=0
void clear_point_locator()
Definition: mesh_base.C:557
std::set< GhostingFunctor * >::const_iterator ghosting_functors_begin() const
Definition: mesh_base.h:799
virtual void renumber_nodes_and_elements()=0
void libMesh::UnstructuredMesh::copy_nodes_and_elements ( const UnstructuredMesh other_mesh,
const bool  skip_find_neighbors = false 
)
virtualinherited

Deep copy of another unstructured mesh class (used by subclass copy constructors)

Definition at line 73 of file unstructured_mesh.C.

References libMesh::MeshBase::_is_prepared, libMesh::MeshBase::_n_parts, libMesh::Elem::add_child(), libMesh::MeshBase::add_elem(), libMesh::MeshBase::add_point(), libMesh::MeshBase::allow_remote_element_removal(), libMesh::MeshBase::allow_renumbering(), libMesh::Elem::build(), libMesh::MeshBase::elem_ptr(), libMesh::MeshBase::element_ptr_range(), libMesh::MeshTools::libmesh_assert_valid_amr_elem_ids(), libmesh_nullptr, libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::Elem::neighbor_ptr(), libMesh::MeshBase::node_ptr(), libMesh::MeshBase::node_ptr_range(), libMesh::Elem::parent(), libMesh::MeshBase::prepare_for_use(), libMesh::DofObject::processor_id(), libMesh::remote_elem, libMesh::MeshBase::reserve_elem(), libMesh::MeshBase::reserve_nodes(), libMesh::Elem::set_neighbor(), libMesh::DofObject::set_unique_id(), libMesh::MeshBase::skip_partitioning(), and libMesh::Elem::subdomain_id().

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

75 {
76  LOG_SCOPE("copy_nodes_and_elements()", "UnstructuredMesh");
77 
78  // We expect to have at least as many processors as the other mesh
79  // is partitioned into, so that our partitioning will still be
80  // consistent afterwards.
81  libmesh_assert_greater_equal (_n_parts, other_mesh._n_parts);
82 
83  // We're assuming our subclass data needs no copy
84  libmesh_assert_equal_to (_is_prepared, other_mesh._is_prepared);
85 
86  // We're assuming the other mesh has proper element number ordering,
87  // so that we add parents before their children.
88 #ifdef DEBUG
90 #endif
91 
92  //Copy in Nodes
93  {
94  //Preallocate Memory if necessary
95  this->reserve_nodes(other_mesh.n_nodes());
96 
97  for (const auto & oldn : other_mesh.node_ptr_range())
98  {
99  // Add new nodes in old node Point locations
100 #ifdef LIBMESH_ENABLE_UNIQUE_ID
101  Node * newn =
102 #endif
103  this->add_point(*oldn, oldn->id(), oldn->processor_id());
104 
105 #ifdef LIBMESH_ENABLE_UNIQUE_ID
106  newn->set_unique_id() = oldn->unique_id();
107 #endif
108  }
109  }
110 
111  //Copy in Elements
112  {
113  //Preallocate Memory if necessary
114  this->reserve_elem(other_mesh.n_elem());
115 
116  // Declare a map linking old and new elements, needed to copy the neighbor lists
117  typedef std::unordered_map<const Elem *, Elem *> map_type;
118  map_type old_elems_to_new_elems;
119 
120  // Loop over the elements
121  for (const auto & old : other_mesh.element_ptr_range())
122  {
123  // Build a new element
124  Elem * newparent = old->parent() ?
125  this->elem_ptr(old->parent()->id()) : libmesh_nullptr;
126  std::unique_ptr<Elem> ap = Elem::build(old->type(), newparent);
127  Elem * el = ap.release();
128 
129  el->subdomain_id() = old->subdomain_id();
130 
131  for (auto s : old->side_index_range())
132  if (old->neighbor_ptr(s) == remote_elem)
133  el->set_neighbor(s, const_cast<RemoteElem *>(remote_elem));
134 
135 #ifdef LIBMESH_ENABLE_AMR
136  if (old->has_children())
137  for (unsigned int c = 0, nc = old->n_children(); c != nc; ++c)
138  if (old->child_ptr(c) == remote_elem)
139  el->add_child(const_cast<RemoteElem *>(remote_elem), c);
140 
141  //Create the parent's child pointers if necessary
142  if (newparent)
143  {
144  unsigned int oldc = old->parent()->which_child_am_i(old);
145  newparent->add_child(el, oldc);
146  }
147 
148  // Copy the refinement flags
149  el->set_refinement_flag(old->refinement_flag());
150 
151  // Use hack_p_level since we may not have sibling elements
152  // added yet
153  el->hack_p_level(old->p_level());
154 
155  el->set_p_refinement_flag(old->p_refinement_flag());
156 #endif // #ifdef LIBMESH_ENABLE_AMR
157 
158  //Assign all the nodes
159  for (auto i : el->node_index_range())
160  el->set_node(i) = this->node_ptr(old->node_id(i));
161 
162  // And start it off in the same subdomain
163  el->processor_id() = old->processor_id();
164 
165  // Give it the same element and unique ids
166  el->set_id(old->id());
167 
168 #ifdef LIBMESH_ENABLE_UNIQUE_ID
169  el->set_unique_id() = old->unique_id();
170 #endif
171 
172  //Hold onto it
173  if (!skip_find_neighbors)
174  {
175  this->add_elem(el);
176  }
177  else
178  {
179  Elem * new_el = this->add_elem(el);
180  old_elems_to_new_elems[old] = new_el;
181  }
182 
183  // Add the link between the original element and this copy to the map
184  if (skip_find_neighbors)
185  old_elems_to_new_elems[old] = el;
186  }
187 
188  // Loop (again) over the elements to fill in the neighbors
189  if (skip_find_neighbors)
190  {
191  for (const auto & old_elem : other_mesh.element_ptr_range())
192  {
193  Elem * new_elem = old_elems_to_new_elems[old_elem];
194  for (auto s : old_elem->side_index_range())
195  {
196  const Elem * old_neighbor = old_elem->neighbor_ptr(s);
197  Elem * new_neighbor = old_elems_to_new_elems[old_neighbor];
198  new_elem->set_neighbor(s, new_neighbor);
199  }
200  }
201  }
202  }
203 
204  //Finally prepare the new Mesh for use. Keep the same numbering and
205  //partitioning for now.
206  this->allow_renumbering(false);
207  this->allow_remote_element_removal(false);
208  this->skip_partitioning(true);
209 
210  this->prepare_for_use(false, skip_find_neighbors);
211 
212  //But in the long term, use the same renumbering and partitioning
213  //policies as our source mesh.
214  this->allow_renumbering(other_mesh.allow_renumbering());
215  this->allow_remote_element_removal(other_mesh.allow_remote_element_removal());
216  this->skip_partitioning(other_mesh.skip_partitioning());
217 }
unique_id_type & set_unique_id()
Definition: dof_object.h:662
virtual void reserve_nodes(const dof_id_type nn)=0
bool skip_partitioning() const
Definition: mesh_base.h:776
const class libmesh_nullptr_t libmesh_nullptr
virtual const Node * node_ptr(const dof_id_type i) const =0
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
unsigned int _n_parts
Definition: mesh_base.h:1343
virtual Elem * add_elem(Elem *e)=0
void libmesh_assert_valid_amr_elem_ids(const MeshBase &mesh)
Definition: mesh_tools.C:1113
void prepare_for_use(const bool skip_renumber_nodes_and_elements=false, const bool skip_find_neighbors=false)
Definition: mesh_base.C:176
bool allow_renumbering() const
Definition: mesh_base.h:751
virtual const Elem * elem_ptr(const dof_id_type i) const =0
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=libmesh_nullptr)
Definition: elem.C:239
bool allow_remote_element_removal() const
Definition: mesh_base.h:760
virtual void reserve_elem(const dof_id_type ne)=0
processor_id_type processor_id() const
Definition: dof_object.h:694
const RemoteElem * remote_elem
Definition: remote_elem.C:57
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 657 of file unstructured_mesh.C.

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

659 {
660 
661  // Issue a warning if the number the number of processors
662  // currently available is less that that requested for
663  // partitioning. This is not necessarily an error since
664  // you may run on one processor and still partition the
665  // mesh into several partitions.
666 #ifdef DEBUG
667  if (this->n_processors() < pid)
668  {
669  libMesh::out << "WARNING: You are creating a "
670  << "mesh for a processor id (="
671  << pid
672  << ") greater than "
673  << "the number of processors available for "
674  << "the calculation. (="
675  << this->n_processors()
676  << ")."
677  << std::endl;
678  }
679 #endif
680 
681  // Create iterators to loop over the list of elements
682  // const_active_pid_elem_iterator it(this->elements_begin(), pid);
683  // const const_active_pid_elem_iterator it_end(this->elements_end(), pid);
684 
685  const_element_iterator it = this->active_pid_elements_begin(pid);
686  const const_element_iterator it_end = this->active_pid_elements_end(pid);
687 
688  this->create_submesh (pid_mesh, it, it_end);
689 }
processor_id_type n_processors() const
void create_submesh(UnstructuredMesh &new_mesh, const_element_iterator &it, const const_element_iterator &it_end) const
virtual element_iterator active_pid_elements_begin(processor_id_type proc_id)=0
virtual element_iterator active_pid_elements_end(processor_id_type proc_id)=0
OStreamProxy out(std::cout)
void libMesh::UnstructuredMesh::create_submesh ( UnstructuredMesh new_mesh,
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 697 of file unstructured_mesh.C.

References libMesh::MeshBase::add_elem(), libMesh::MeshBase::add_point(), libMesh::BoundaryInfo::add_side(), libMesh::BoundaryInfo::boundary_ids(), libMesh::Elem::build(), libMesh::MeshBase::clear(), libMesh::MeshBase::delete_remote_elements(), libMesh::MeshBase::get_boundary_info(), libMesh::DofObject::id(), libMesh::MeshBase::is_serial(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::Elem::node_id(), libMesh::Elem::node_index_range(), libMesh::Elem::node_ptr(), libMesh::MeshBase::node_ptr(), libMesh::Elem::point(), libMesh::MeshBase::prepare_for_use(), libMesh::DofObject::processor_id(), libMesh::MeshBase::query_node_ptr(), libMesh::DofObject::set_id(), libMesh::Elem::set_node(), libMesh::DofObject::set_unique_id(), libMesh::Elem::side_index_range(), libMesh::Elem::subdomain_id(), libMesh::Elem::type(), and libMesh::DofObject::unique_id().

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

700 {
701  // Just in case the subdomain_mesh already has some information
702  // in it, get rid of it.
703  new_mesh.clear();
704 
705  // If we're not serial, our submesh isn't either.
706  // There are no remote elements to delete on an empty mesh, but
707  // calling the method to do so marks the mesh as parallel.
708  if (!this->is_serial())
709  new_mesh.delete_remote_elements();
710 
711  // Fail if (*this == new_mesh), we cannot create a submesh inside ourself!
712  // This may happen if the user accidentally passes the original mesh into
713  // this function! We will check this by making sure we did not just
714  // clear ourself.
715  libmesh_assert_not_equal_to (this->n_nodes(), 0);
716  libmesh_assert_not_equal_to (this->n_elem(), 0);
717 
718  // Container to catch boundary IDs handed back by BoundaryInfo
719  std::vector<boundary_id_type> bc_ids;
720 
721  for (; it != it_end; ++it)
722  {
723  const Elem * old_elem = *it;
724 
725  // Add an equivalent element type to the new_mesh.
726  // Copy ids for this element.
727  Elem * new_elem = Elem::build(old_elem->type()).release();
728  new_elem->set_id() = old_elem->id();
729 #ifdef LIBMESH_ENABLE_UNIQUE_ID
730  new_elem->set_unique_id() = old_elem->unique_id();
731 #endif
732  new_elem->subdomain_id() = old_elem->subdomain_id();
733  new_elem->processor_id() = old_elem->processor_id();
734 
735  new_mesh.add_elem (new_elem);
736 
737  libmesh_assert(new_elem);
738 
739  // Loop over the nodes on this element.
740  for (auto n : old_elem->node_index_range())
741  {
742  const dof_id_type this_node_id = old_elem->node_id(n);
743 
744  // Add this node to the new mesh if it's not there already
745  if (!new_mesh.query_node_ptr(this_node_id))
746  {
747 #ifdef LIBMESH_ENABLE_UNIQUE_ID
748  Node *newn =
749 #endif
750  new_mesh.add_point (old_elem->point(n),
751  this_node_id,
752  old_elem->node_ptr(n)->processor_id());
753 
754 #ifdef LIBMESH_ENABLE_UNIQUE_ID
755  newn->set_unique_id() = old_elem->node_ptr(n)->unique_id();
756 #endif
757  }
758 
759  // Define this element's connectivity on the new mesh
760  new_elem->set_node(n) = new_mesh.node_ptr(this_node_id);
761  }
762 
763  // Maybe add boundary conditions for this element
764  for (auto s : old_elem->side_index_range())
765  {
766  this->get_boundary_info().boundary_ids(old_elem, s, bc_ids);
767  new_mesh.get_boundary_info().add_side (new_elem, s, bc_ids);
768  }
769  } // end loop over elements
770 
771  // Prepare the new_mesh for use
772  new_mesh.prepare_for_use(/*skip_renumber =*/false);
773 }
const BoundaryInfo & get_boundary_info() const
Definition: mesh_base.h:118
virtual bool is_serial() const
Definition: mesh_base.h:141
std::vector< boundary_id_type > boundary_ids(const Node *node) const
virtual dof_id_type n_nodes() const =0
virtual dof_id_type n_elem() const =0
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=libmesh_nullptr)
Definition: elem.C:239
uint8_t dof_id_type
Definition: id_types.h:64
void libMesh::DistributedMesh::delete_elem ( Elem e)
virtual

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

References _elements, _n_elem, libMesh::MeshBase::get_boundary_info(), libMesh::DofObject::id(), libMesh::DofObject::invalid_processor_id, libmesh_nullptr, libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), and libMesh::BoundaryInfo::remove().

Referenced by libMesh::MeshCommunication::delete_remote_elements(), insert_elem(), and reserve_elem().

542 {
543  libmesh_assert (e);
544 
545  // Try to make the cached elem data more accurate
546  processor_id_type elem_procid = e->processor_id();
547  if (elem_procid == this->processor_id() ||
548  elem_procid == DofObject::invalid_processor_id)
549  _n_elem--;
550 
551  // Delete the element from the BoundaryInfo object
552  this->get_boundary_info().remove(e);
553 
554  // But not yet from the container; we might invalidate
555  // an iterator that way!
556 
557  //_elements.erase(e->id());
558 
559  // Instead, we set it to NULL for now
560 
561  _elements[e->id()] = libmesh_nullptr;
562 
563  // delete the element
564  delete e;
565 }
const BoundaryInfo & get_boundary_info() const
Definition: mesh_base.h:118
mapvector< Elem *, dof_id_type > _elements
void remove(const Node *node)
uint8_t processor_id_type
Definition: id_types.h:99
const class libmesh_nullptr_t libmesh_nullptr
static const processor_id_type invalid_processor_id
Definition: dof_object.h:335
processor_id_type processor_id() const
void libMesh::DistributedMesh::delete_node ( Node n)
virtual

Removes the Node n from the mesh.

Implements libMesh::MeshBase.

Definition at line 712 of file distributed_mesh.C.

References _n_nodes, _nodes, libMesh::MeshBase::get_boundary_info(), libMesh::DofObject::id(), libMesh::DofObject::invalid_processor_id, libmesh_nullptr, libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), and libMesh::BoundaryInfo::remove().

Referenced by libMesh::MeshCommunication::delete_remote_elements(), and reserve_elem().

713 {
714  libmesh_assert(n);
715  libmesh_assert(_nodes[n->id()]);
716 
717  // Try to make the cached elem data more accurate
718  processor_id_type node_procid = n->processor_id();
719  if (node_procid == this->processor_id() ||
720  node_procid == DofObject::invalid_processor_id)
721  _n_nodes--;
722 
723  // Delete the node from the BoundaryInfo object
724  this->get_boundary_info().remove(n);
725 
726  // But not yet from the container; we might invalidate
727  // an iterator that way!
728 
729  //_nodes.erase(n->id());
730 
731  // Instead, we set it to NULL for now
732 
733  _nodes[n->id()] = libmesh_nullptr;
734 
735  // delete the node
736  delete n;
737 }
const BoundaryInfo & get_boundary_info() const
Definition: mesh_base.h:118
void remove(const Node *node)
uint8_t processor_id_type
Definition: id_types.h:99
const class libmesh_nullptr_t libmesh_nullptr
mapvector< Node *, dof_id_type > _nodes
static const processor_id_type invalid_processor_id
Definition: dof_object.h:335
processor_id_type processor_id() const
void libMesh::DistributedMesh::delete_remote_elements ( )
virtual

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

References _elements, _extra_ghost_elems, _is_serial, _is_serial_on_proc_0, _nodes, libMesh::MeshCommunication::delete_remote_elements(), 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(), n_elem(), n_nodes(), parallel_max_elem_id(), parallel_max_node_id(), parallel_n_elem(), parallel_n_nodes(), and update_parallel_id_counts().

Referenced by is_replicated().

1357 {
1358 #ifdef DEBUG
1359  // Make sure our neighbor links are all fine
1361 
1362  // And our child/parent links, and our flags
1364 
1365  // Make sure our ids and flags are consistent
1368 
1369  libmesh_assert_equal_to (this->n_nodes(), this->parallel_n_nodes());
1370  libmesh_assert_equal_to (this->n_elem(), this->parallel_n_elem());
1371  const dof_id_type pmax_node_id = this->parallel_max_node_id();
1372  const dof_id_type pmax_elem_id = this->parallel_max_elem_id();
1373  libmesh_assert_equal_to (this->max_node_id(), pmax_node_id);
1374  libmesh_assert_equal_to (this->max_elem_id(), pmax_elem_id);
1375 #endif
1376 
1377  _is_serial = false;
1378  _is_serial_on_proc_0 = false;
1379 
1380  MeshCommunication().delete_remote_elements(*this, _extra_ghost_elems);
1381 
1382  libmesh_assert_equal_to (this->max_elem_id(), this->parallel_max_elem_id());
1383 
1384  // Now make sure the containers actually shrink - strip
1385  // any newly-created NULL voids out of the element array
1386  mapvector<Elem *,dof_id_type>::veclike_iterator e_it = _elements.begin();
1387  const mapvector<Elem *,dof_id_type>::veclike_iterator e_end = _elements.end();
1388  for (; e_it != e_end;)
1389  if (!*e_it)
1390  _elements.erase(e_it++);
1391  else
1392  ++e_it;
1393 
1394  mapvector<Node *,dof_id_type>::veclike_iterator n_it = _nodes.begin();
1395  const mapvector<Node *,dof_id_type>::veclike_iterator n_end = _nodes.end();
1396  for (; n_it != n_end;)
1397  if (!*n_it)
1398  _nodes.erase(n_it++);
1399  else
1400  ++n_it;
1401 
1402  // We may have deleted no-longer-connected nodes or coarsened-away
1403  // elements; let's update our caches.
1404  this->update_parallel_id_counts();
1405 
1406 #ifdef DEBUG
1407  // We might not have well-packed objects if the user didn't allow us
1408  // to renumber
1409  // libmesh_assert_equal_to (this->n_nodes(), this->max_node_id());
1410  // libmesh_assert_equal_to (this->n_elem(), this->max_elem_id());
1411 
1412  // Make sure our neighbor links are all fine
1414 
1415  // And our child/parent links, and our flags
1417 
1418  // Make sure our ids and flags are consistent
1421 #endif
1422 }
mapvector< Elem *, dof_id_type > _elements
virtual dof_id_type n_elem() const libmesh_override
void libmesh_assert_valid_refinement_tree(const MeshBase &mesh)
Definition: mesh_tools.C:1672
dof_id_type parallel_max_elem_id() const
void libmesh_assert_valid_parallel_flags() const
virtual void update_parallel_id_counts() libmesh_override
dof_id_type parallel_max_node_id() const
mapvector< Node *, dof_id_type > _nodes
std::set< Elem * > _extra_ghost_elems
virtual dof_id_type n_nodes() const libmesh_override
virtual dof_id_type max_node_id() const libmesh_override
virtual dof_id_type parallel_n_nodes() const libmesh_override
void libmesh_assert_valid_neighbors(const MeshBase &mesh, bool assert_valid_remote_elems=true)
Definition: mesh_tools.C:1707
virtual dof_id_type parallel_n_elem() const libmesh_override
virtual dof_id_type max_elem_id() const libmesh_override
uint8_t dof_id_type
Definition: id_types.h:64
virtual void libmesh_assert_valid_parallel_ids() const libmesh_override
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 680 of file mesh_base.C.

References libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), libMesh::Elem::dim(), libMesh::MeshBase::elem(), libMesh::MeshBase::elem_dimensions(), libMesh::MeshBase::elem_ptr(), libMesh::MeshBase::elem_ref(), libMesh::MeshBase::elements_begin(), end, libMesh::DofObject::id(), libMesh::Elem::interior_parent(), libMesh::MeshBase::max_elem_id(), libMesh::Elem::n_vertices(), libMesh::Elem::node_id(), and libMesh::Elem::set_interior_parent().

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

681 {
682  // This requires an inspection on every processor
683  parallel_object_only();
684 
685  // Check if the mesh contains mixed dimensions. If so, then set interior parents, otherwise return.
686  if (this->elem_dimensions().size() == 1)
687  return;
688 
689  //This map will be used to set interior parents
690  std::unordered_map<dof_id_type, std::vector<dof_id_type>> node_to_elem;
691 
692  const_element_iterator el = this->active_elements_begin();
693  const_element_iterator end = this->active_elements_end();
694 
695  for (; el!=end; ++el)
696  {
697  const Elem * elem = *el;
698 
699  // Populating the node_to_elem map, same as MeshTools::build_nodes_to_elem_map
700  for (unsigned int n=0; n<elem->n_vertices(); n++)
701  {
702  libmesh_assert_less (elem->id(), this->max_elem_id());
703 
704  node_to_elem[elem->node_id(n)].push_back(elem->id());
705  }
706  }
707 
708  // Automatically set interior parents
709  el = this->elements_begin();
710  for (; el!=end; ++el)
711  {
712  Elem * element = *el;
713 
714  // Ignore an 3D element or an element that already has an interior parent
715  if (element->dim()>=LIBMESH_DIM || element->interior_parent())
716  continue;
717 
718  // Start by generating a SET of elements that are dim+1 to the current
719  // element at each vertex of the current element, thus ignoring interior nodes.
720  // If one of the SET of elements is empty, then we will not have an interior parent
721  // since an interior parent must be connected to all vertices of the current element
722  std::vector<std::set<dof_id_type>> neighbors( element->n_vertices() );
723 
724  bool found_interior_parents = false;
725 
726  for (dof_id_type n=0; n < element->n_vertices(); n++)
727  {
728  std::vector<dof_id_type> & element_ids = node_to_elem[element->node_id(n)];
729  for (std::vector<dof_id_type>::iterator e_it = element_ids.begin();
730  e_it != element_ids.end(); e_it++)
731  {
732  dof_id_type eid = *e_it;
733  if (this->elem_ref(eid).dim() == element->dim()+1)
734  neighbors[n].insert(eid);
735  }
736  if (neighbors[n].size()>0)
737  {
738  found_interior_parents = true;
739  }
740  else
741  {
742  // We have found an empty set, no reason to continue
743  // Ensure we set this flag to false before the break since it could have
744  // been set to true for previous vertex
745  found_interior_parents = false;
746  break;
747  }
748  }
749 
750  // If we have successfully generated a set of elements for each vertex, we will compare
751  // the set for vertex 0 will the sets for the vertices until we find a id that exists in
752  // all sets. If found, this is our an interior parent id. The interior parent id found
753  // will be the lowest element id if there is potential for multiple interior parents.
754  if (found_interior_parents)
755  {
756  std::set<dof_id_type> & neighbors_0 = neighbors[0];
757  for (std::set<dof_id_type>::iterator e_it = neighbors_0.begin();
758  e_it != neighbors_0.end(); e_it++)
759  {
760  found_interior_parents=false;
761  dof_id_type interior_parent_id = *e_it;
762  for (dof_id_type n=1; n < element->n_vertices(); n++)
763  {
764  if (neighbors[n].find(interior_parent_id)!=neighbors[n].end())
765  {
766  found_interior_parents=true;
767  }
768  else
769  {
770  found_interior_parents=false;
771  break;
772  }
773  }
774  if (found_interior_parents)
775  {
776  element->set_interior_parent(this->elem_ptr(interior_parent_id));
777  break;
778  }
779  }
780  }
781  }
782 }
virtual const Elem * elem(const dof_id_type i) const
Definition: mesh_base.h:524
IterBase * end
virtual element_iterator elements_begin()=0
virtual dof_id_type max_elem_id() const =0
const std::set< unsigned char > & elem_dimensions() const
Definition: mesh_base.h:207
virtual element_iterator active_elements_begin()=0
virtual element_iterator active_elements_end()=0
virtual const Elem & elem_ref(const dof_id_type i) const
Definition: mesh_base.h:491
virtual unsigned int dim() const =0
virtual const Elem * elem_ptr(const dof_id_type i) const =0
uint8_t dof_id_type
Definition: id_types.h:64
virtual const Elem* libMesh::MeshBase::elem ( const dof_id_type  i) const
inlinevirtualinherited
Returns
A pointer to the $ i^{th} $ element, which should be present in this processor's subset of the mesh data structure.
Deprecated:
Use the less confusingly-named elem_ptr() instead.

Definition at line 524 of file mesh_base.h.

References libMesh::MeshBase::elem_ptr().

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

525  {
526  libmesh_deprecated();
527  return this->elem_ptr(i);
528  }
virtual const Elem * elem_ptr(const dof_id_type i) const =0
virtual Elem* libMesh::MeshBase::elem ( const dof_id_type  i)
inlinevirtualinherited
Returns
A writable pointer to the $ i^{th} $ element, which should be present in this processor's subset of the mesh data structure.
Deprecated:
Use the less confusingly-named elem_ptr() instead.

Definition at line 539 of file mesh_base.h.

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

540  {
541  libmesh_deprecated();
542  return this->elem_ptr(i);
543  }
virtual const Elem * elem_ptr(const dof_id_type i) const =0
const std::set<unsigned char>& libMesh::MeshBase::elem_dimensions ( ) const
inlineinherited
const Elem * libMesh::DistributedMesh::elem_ptr ( const dof_id_type  i) const
virtual
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 357 of file distributed_mesh.C.

References _elements.

Referenced by reserve_elem().

358 {
359  libmesh_assert(_elements[i]);
360  libmesh_assert_equal_to (_elements[i]->id(), i);
361 
362  return _elements[i];
363 }
mapvector< Elem *, dof_id_type > _elements
Elem * libMesh::DistributedMesh::elem_ptr ( const dof_id_type  i)
virtual
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 368 of file distributed_mesh.C.

References _elements.

369 {
370  libmesh_assert(_elements[i]);
371  libmesh_assert_equal_to (_elements[i]->id(), i);
372 
373  return _elements[i];
374 }
mapvector< Elem *, dof_id_type > _elements
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 500 of file mesh_base.h.

References libMesh::MeshBase::elem_ptr().

500  {
501  return *this->elem_ptr(i);
502  }
virtual const Elem * elem_ptr(const dof_id_type i) const =0
virtual SimpleRange<element_iterator> libMesh::DistributedMesh::element_ptr_range ( )
inlinevirtual

Implements libMesh::MeshBase.

Definition at line 295 of file distributed_mesh.h.

References elements_begin(), and elements_end().

295 { return {elements_begin(), elements_end()}; }
virtual element_iterator elements_begin() libmesh_override
virtual element_iterator elements_end() libmesh_override
virtual SimpleRange<const_element_iterator> libMesh::DistributedMesh::element_ptr_range ( ) const
inlinevirtual

Implements libMesh::MeshBase.

Definition at line 296 of file distributed_mesh.h.

References active_elements_begin(), active_elements_end(), elements_begin(), and elements_end().

296 { return {elements_begin(), elements_end()}; }
virtual element_iterator elements_begin() libmesh_override
virtual element_iterator elements_end() libmesh_override
virtual element_iterator libMesh::DistributedMesh::elements_begin ( )
virtual
virtual const_element_iterator libMesh::DistributedMesh::elements_begin ( ) const
virtual

Implements libMesh::MeshBase.

virtual const_element_iterator libMesh::DistributedMesh::elements_end ( ) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::evaluable_elements_begin ( const DofMap dof_map,
unsigned int  var_num = libMesh::invalid_uint 
)
virtual

Iterate over elements in the Mesh where the solution (as distributed by the given DofMap) can be evaluated, for the given variable var_num, or for all variables by default.

Implements libMesh::MeshBase.

Referenced by active_local_element_ptr_range().

virtual const_element_iterator libMesh::DistributedMesh::evaluable_elements_begin ( const DofMap dof_map,
unsigned int  var_num = libMesh::invalid_uint 
) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::evaluable_elements_end ( const DofMap dof_map,
unsigned int  var_num = libMesh::invalid_uint 
)
virtual
virtual const_element_iterator libMesh::DistributedMesh::evaluable_elements_end ( const DofMap dof_map,
unsigned int  var_num = libMesh::invalid_uint 
) const
virtual

Implements libMesh::MeshBase.

virtual node_iterator libMesh::DistributedMesh::evaluable_nodes_begin ( const DofMap dof_map,
unsigned int  var_num = libMesh::invalid_uint 
)
virtual

Iterate over nodes in the Mesh where the solution (as distributed by the given DofMap) can be evaluated, for the given variable var_num, or for all variables by default.

Implements libMesh::MeshBase.

Referenced by local_node_ptr_range().

virtual const_node_iterator libMesh::DistributedMesh::evaluable_nodes_begin ( const DofMap dof_map,
unsigned int  var_num = libMesh::invalid_uint 
) const
virtual

Implements libMesh::MeshBase.

virtual node_iterator libMesh::DistributedMesh::evaluable_nodes_end ( const DofMap dof_map,
unsigned int  var_num = libMesh::invalid_uint 
)
virtual

Implements libMesh::MeshBase.

Referenced by local_node_ptr_range().

virtual const_node_iterator libMesh::DistributedMesh::evaluable_nodes_end ( const DofMap dof_map,
unsigned int  var_num = libMesh::invalid_uint 
) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::facelocal_elements_begin ( )
virtual

Iterate over elements which are on or have a neighbor on the current processor.

Implements libMesh::MeshBase.

Referenced by active_element_ptr_range().

virtual const_element_iterator libMesh::DistributedMesh::facelocal_elements_begin ( ) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::facelocal_elements_end ( )
virtual

Implements libMesh::MeshBase.

Referenced by active_element_ptr_range().

virtual const_element_iterator libMesh::DistributedMesh::facelocal_elements_end ( ) const
virtual

Implements libMesh::MeshBase.

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

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

References libMesh::Elem::active(), libMesh::Elem::ancestor(), libMesh::Elem::centroid(), libMesh::Elem::child_ptr(), libMesh::Elem::child_ref_range(), libMesh::Elem::dim(), libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), end, 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::key(), libMesh::Elem::level(), libMesh::MeshBase::level_elements_begin(), libMesh::MeshBase::level_elements_end(), libMesh::MeshTools::libmesh_assert_valid_amr_interior_parents(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libmesh_nullptr, libMesh::Elem::n_children(), libMesh::MeshTools::n_levels(), libMesh::Elem::neighbor_ptr(), libMesh::Elem::neighbor_ptr_range(), libMesh::Elem::node_ref_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_index_range(), libMesh::Elem::side_ptr(), libMesh::Elem::subactive(), libMesh::TOLERANCE, libMesh::Elem::which_child_am_i(), and libMesh::NameBasedIO::write().

Referenced by libMesh::TriangleWrapper::copy_tri_to_mesh(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), and redistribute().

234 {
235  // We might actually want to run this on an empty mesh
236  // (e.g. the boundary mesh for a nonexistent bcid!)
237  // libmesh_assert_not_equal_to (this->n_nodes(), 0);
238  // libmesh_assert_not_equal_to (this->n_elem(), 0);
239 
240  // This function must be run on all processors at once
241  parallel_object_only();
242 
243  LOG_SCOPE("find_neighbors()", "Mesh");
244 
245  const element_iterator el_end = this->elements_end();
246 
247  //TODO:[BSK] This should be removed later?!
248  if (reset_current_list)
249  for (element_iterator el = this->elements_begin(); el != el_end; ++el)
250  {
251  Elem * e = *el;
252  for (auto s : e->side_index_range())
253  if (e->neighbor_ptr(s) != remote_elem ||
254  reset_remote_elements)
255  e->set_neighbor(s, libmesh_nullptr);
256  }
257 
258  // Find neighboring elements by first finding elements
259  // with identical side keys and then check to see if they
260  // are neighbors
261  {
262  // data structures -- Use the hash_multimap if available
263  typedef unsigned int key_type;
264  typedef std::pair<Elem *, unsigned char> val_type;
265  typedef std::pair<key_type, val_type> key_val_pair;
266 
267  typedef std::unordered_multimap<key_type, val_type> map_type;
268 
269  // A map from side keys to corresponding elements & side numbers
270  map_type side_to_elem_map;
271 
272 
273 
274  for (element_iterator el = this->elements_begin(); el != el_end; ++el)
275  {
276  Elem * element = *el;
277 
278  for (auto ms : element->side_index_range())
279  {
280  next_side:
281  // If we haven't yet found a neighbor on this side, try.
282  // Even if we think our neighbor is remote, that
283  // information may be out of date.
284  if (element->neighbor_ptr(ms) == libmesh_nullptr ||
285  element->neighbor_ptr(ms) == remote_elem)
286  {
287  // Get the key for the side of this element
288  const unsigned int key = element->key(ms);
289 
290  // Look for elements that have an identical side key
291  std::pair <map_type::iterator, map_type::iterator>
292  bounds = side_to_elem_map.equal_range(key);
293 
294  // May be multiple keys, check all the possible
295  // elements which _might_ be neighbors.
296  if (bounds.first != bounds.second)
297  {
298  // Get the side for this element
299  const std::unique_ptr<Elem> my_side(element->side_ptr(ms));
300 
301  // Look at all the entries with an equivalent key
302  while (bounds.first != bounds.second)
303  {
304  // Get the potential element
305  Elem * neighbor = bounds.first->second.first;
306 
307  // Get the side for the neighboring element
308  const unsigned int ns = bounds.first->second.second;
309  const std::unique_ptr<Elem> their_side(neighbor->side_ptr(ns));
310  //libmesh_assert(my_side.get());
311  //libmesh_assert(their_side.get());
312 
313  // If found a match with my side
314  //
315  // We need special tests here for 1D:
316  // since parents and children have an equal
317  // side (i.e. a node), we need to check
318  // ns != ms, and we also check level() to
319  // avoid setting our neighbor pointer to
320  // any of our neighbor's descendants
321  if ((*my_side == *their_side) &&
322  (element->level() == neighbor->level()) &&
323  ((element->dim() != 1) || (ns != ms)))
324  {
325  // So share a side. Is this a mixed pair
326  // of subactive and active/ancestor
327  // elements?
328  // If not, then we're neighbors.
329  // If so, then the subactive's neighbor is
330 
331  if (element->subactive() ==
332  neighbor->subactive())
333  {
334  // an element is only subactive if it has
335  // been coarsened but not deleted
336  element->set_neighbor (ms,neighbor);
337  neighbor->set_neighbor(ns,element);
338  }
339  else if (element->subactive())
340  {
341  element->set_neighbor(ms,neighbor);
342  }
343  else if (neighbor->subactive())
344  {
345  neighbor->set_neighbor(ns,element);
346  }
347  side_to_elem_map.erase (bounds.first);
348 
349  // get out of this nested crap
350  goto next_side;
351  }
352 
353  ++bounds.first;
354  }
355  }
356 
357  // didn't find a match...
358  // Build the map entry for this element
359  key_val_pair kvp;
360 
361  kvp.first = key;
362  kvp.second.first = element;
363  kvp.second.second = ms;
364  side_to_elem_map.insert (kvp);
365  }
366  }
367  }
368  }
369 
370 #ifdef LIBMESH_ENABLE_AMR
371 
399  const unsigned int n_levels = MeshTools::n_levels(*this);
400  for (unsigned int level = 1; level < n_levels; ++level)
401  {
402  element_iterator end = this->level_elements_end(level);
403  for (element_iterator el = this->level_elements_begin(level);
404  el != end; ++el)
405  {
406  Elem * current_elem = *el;
407  libmesh_assert(current_elem);
408  Elem * parent = current_elem->parent();
409  libmesh_assert(parent);
410  const unsigned int my_child_num = parent->which_child_am_i(current_elem);
411 
412  for (auto s : current_elem->side_index_range())
413  {
414  if (current_elem->neighbor_ptr(s) == libmesh_nullptr ||
415  (current_elem->neighbor_ptr(s) == remote_elem &&
416  parent->is_child_on_side(my_child_num, s)))
417  {
418  Elem * neigh = parent->neighbor_ptr(s);
419 
420  // If neigh was refined and had non-subactive children
421  // made remote earlier, then our current elem should
422  // actually have one of those remote children as a
423  // neighbor
424  if (neigh &&
425  (neigh->ancestor() ||
426  // If neigh has subactive children which should have
427  // matched as neighbors of the current element but
428  // did not, then those likewise must be remote
429  // children.
430  (current_elem->subactive() && neigh->has_children() &&
431  (neigh->level()+1) == current_elem->level())))
432  {
433 #ifdef DEBUG
434  // Let's make sure that "had children made remote"
435  // situation is actually the case
436  libmesh_assert(neigh->has_children());
437  bool neigh_has_remote_children = false;
438  for (auto & child : neigh->child_ref_range())
439  if (&child == remote_elem)
440  neigh_has_remote_children = true;
441  libmesh_assert(neigh_has_remote_children);
442 
443  // And let's double-check that we don't have
444  // a remote_elem neighboring an active local element
445  if (current_elem->active())
446  libmesh_assert_not_equal_to (current_elem->processor_id(),
447  this->processor_id());
448 #endif // DEBUG
449  neigh = const_cast<RemoteElem *>(remote_elem);
450  }
451  // If neigh and current_elem are more than one level
452  // apart, figuring out whether we have a remote
453  // neighbor here becomes much harder.
454  else if (neigh && (current_elem->subactive() &&
455  neigh->has_children()))
456  {
457  // Find the deepest descendant of neigh which
458  // we could consider for a neighbor. If we run
459  // out of neigh children, then that's our
460  // neighbor. If we find a potential neighbor
461  // with remote_children and we don't find any
462  // potential neighbors among its non-remote
463  // children, then our neighbor must be remote.
464  while (neigh != remote_elem &&
465  neigh->has_children())
466  {
467  bool found_neigh = false;
468  for (unsigned int c = 0, nc = neigh->n_children();
469  !found_neigh && c != nc; ++c)
470  {
471  Elem * child = neigh->child_ptr(c);
472  if (child == remote_elem)
473  continue;
474  for (auto ncn : child->neighbor_ptr_range())
475  {
476  if (ncn != remote_elem &&
477  ncn->is_ancestor_of(current_elem))
478  {
479  neigh = ncn;
480  found_neigh = true;
481  break;
482  }
483  }
484  }
485  if (!found_neigh)
486  neigh = const_cast<RemoteElem *>(remote_elem);
487  }
488  }
489  current_elem->set_neighbor(s, neigh);
490 #ifdef DEBUG
491  if (neigh != libmesh_nullptr && neigh != remote_elem)
492  // We ignore subactive elements here because
493  // we don't care about neighbors of subactive element.
494  if ((!neigh->active()) && (!current_elem->subactive()))
495  {
496  libMesh::err << "On processor " << this->processor_id()
497  << std::endl;
498  libMesh::err << "Bad element ID = " << current_elem->id()
499  << ", Side " << s << ", Bad neighbor ID = " << neigh->id() << std::endl;
500  libMesh::err << "Bad element proc_ID = " << current_elem->processor_id()
501  << ", Bad neighbor proc_ID = " << neigh->processor_id() << std::endl;
502  libMesh::err << "Bad element size = " << current_elem->hmin()
503  << ", Bad neighbor size = " << neigh->hmin() << std::endl;
504  libMesh::err << "Bad element center = " << current_elem->centroid()
505  << ", Bad neighbor center = " << neigh->centroid() << std::endl;
506  libMesh::err << "ERROR: "
507  << (current_elem->active()?"Active":"Ancestor")
508  << " Element at level "
509  << current_elem->level() << std::endl;
510  libMesh::err << "with "
511  << (parent->active()?"active":
512  (parent->subactive()?"subactive":"ancestor"))
513  << " parent share "
514  << (neigh->subactive()?"subactive":"ancestor")
515  << " neighbor at level " << neigh->level()
516  << std::endl;
517  NameBasedIO(*this).write ("bad_mesh.gmv");
518  libmesh_error_msg("Problematic mesh written to bad_mesh.gmv.");
519  }
520 #endif // DEBUG
521  }
522  }
523 
524  // We can skip to the next element if we're full-dimension
525  // and therefore don't have any interior parents
526  if (current_elem->dim() >= LIBMESH_DIM)
527  continue;
528 
529  // We have no interior parents unless we can find one later
530  current_elem->set_interior_parent(libmesh_nullptr);
531 
532  Elem * pip = parent->interior_parent();
533 
534  if (!pip)
535  continue;
536 
537  // If there's no interior_parent children, whether due to a
538  // remote element or a non-conformity, then there's no
539  // children to search.
540  if (pip == remote_elem || pip->active())
541  {
542  current_elem->set_interior_parent(pip);
543  continue;
544  }
545 
546  // For node comparisons we'll need a sensible tolerance
547  Real node_tolerance = current_elem->hmin() * TOLERANCE;
548 
549  // Otherwise our interior_parent should be a child of our
550  // parent's interior_parent.
551  for (auto & child : pip->child_ref_range())
552  {
553  // If we have a remote_elem, that might be our
554  // interior_parent. We'll set it provisionally now and
555  // keep trying to find something better.
556  if (&child == remote_elem)
557  {
558  current_elem->set_interior_parent
559  (const_cast<RemoteElem *>(remote_elem));
560  continue;
561  }
562 
563  bool child_contains_our_nodes = true;
564  for (auto & n : current_elem->node_ref_range())
565  {
566  bool child_contains_this_node = false;
567  for (auto & cn : child.node_ref_range())
568  if (cn.absolute_fuzzy_equals
569  (n, node_tolerance))
570  {
571  child_contains_this_node = true;
572  break;
573  }
574  if (!child_contains_this_node)
575  {
576  child_contains_our_nodes = false;
577  break;
578  }
579  }
580  if (child_contains_our_nodes)
581  {
582  current_elem->set_interior_parent(&child);
583  break;
584  }
585  }
586 
587  // We should have found *some* interior_parent at this
588  // point, whether semilocal or remote.
589  libmesh_assert(current_elem->interior_parent());
590  }
591  }
592 
593 #endif // AMR
594 
595 
596 #ifdef DEBUG
598  !reset_remote_elements);
600 #endif
601 }
bool has_children() const
Definition: elem.h:2296
void libmesh_assert_valid_amr_interior_parents(const MeshBase &mesh)
Definition: mesh_tools.C:1133
bool active() const
Definition: elem.h:2258
virtual element_iterator level_elements_begin(unsigned int level)=0
const class libmesh_nullptr_t libmesh_nullptr
static const Real TOLERANCE
IterBase * end
virtual element_iterator elements_begin()=0
virtual element_iterator level_elements_end(unsigned int level)=0
virtual bool is_child_on_side(const unsigned int, const unsigned int) const libmesh_override
Definition: remote_elem.h:140
bool is_ancestor_of(const Elem *descendant) const
Definition: elem.h:2326
virtual element_iterator elements_end()=0
unsigned int n_levels(const MeshBase &mesh)
Definition: mesh_tools.C:603
OStreamProxy err(std::cerr)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void libmesh_assert_valid_neighbors(const MeshBase &mesh, bool assert_valid_remote_elems=true)
Definition: mesh_tools.C:1707
processor_id_type processor_id() const
const RemoteElem * remote_elem
Definition: remote_elem.C:57
void libMesh::DistributedMesh::fix_broken_node_and_element_numbering ( )
virtual

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

References _elements, _nodes, libMesh::mapvector< Val, index_t >::begin(), libMesh::mapvector< Val, index_t >::end(), end, and libmesh_nullptr.

Referenced by reserve_elem().

1304 {
1305  // We need access to iterators for the underlying containers,
1306  // not the mapvector<> reimplementations.
1309 
1310  // Nodes first
1311  {
1312  mapvector<Node *,dof_id_type>::maptype::iterator
1313  it = nodes.begin(),
1314  end = nodes.end();
1315 
1316  for (; it != end; ++it)
1317  if (it->second != libmesh_nullptr)
1318  it->second->set_id() = it->first;
1319  }
1320 
1321  // Elements next
1322  {
1323  mapvector<Elem *,dof_id_type>::maptype::iterator
1324  it = elems.begin(),
1325  end = elems.end();
1326 
1327  for (; it != end; ++it)
1328  if (it->second != libmesh_nullptr)
1329  it->second->set_id() = it->first;
1330  }
1331 }
std::map< index_t, Val > maptype
Definition: mapvector.h:42
mapvector< Elem *, dof_id_type > _elements
const class libmesh_nullptr_t libmesh_nullptr
IterBase * end
mapvector< Node *, dof_id_type > _nodes
virtual element_iterator libMesh::DistributedMesh::flagged_elements_begin ( unsigned char  rflag)
virtual

Iterate over all elements with a specified refinement flag.

Implements libMesh::MeshBase.

Referenced by active_local_element_ptr_range().

virtual const_element_iterator libMesh::DistributedMesh::flagged_elements_begin ( unsigned char  rflag) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::flagged_elements_end ( unsigned char  rflag)
virtual
virtual const_element_iterator libMesh::DistributedMesh::flagged_elements_end ( unsigned char  rflag) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::flagged_pid_elements_begin ( unsigned char  rflag,
processor_id_type  pid 
)
virtual

Iterate over all elements with a specified refinement flag on a specified processor.

Implements libMesh::MeshBase.

Referenced by active_local_element_ptr_range().

virtual const_element_iterator libMesh::DistributedMesh::flagged_pid_elements_begin ( unsigned char  rflag,
processor_id_type  pid 
) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::flagged_pid_elements_end ( unsigned char  rflag,
processor_id_type  pid 
)
virtual
virtual const_element_iterator libMesh::DistributedMesh::flagged_pid_elements_end ( unsigned char  rflag,
processor_id_type  pid 
) const
virtual

Implements libMesh::MeshBase.

void libMesh::DistributedMesh::gather_to_zero ( )
virtual

Gathers all elements and nodes of the mesh onto processor zero

Reimplemented from libMesh::MeshBase.

Definition at line 1467 of file distributed_mesh.C.

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

Referenced by is_replicated().

1468 {
1470  return;
1471 
1472  _is_serial_on_proc_0 = true;
1473  MeshCommunication().gather(0, *this);
1474 }
const BoundaryInfo& libMesh::MeshBase::get_boundary_info ( ) const
inlineinherited

The information about boundary ids on the mesh

Definition at line 118 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::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Subdivision::all_subdivision(), libMesh::MeshTools::Modification::all_tri(), libMesh::AbaqusIO::assign_boundary_node_ids(), libMesh::AbaqusIO::assign_sideset_ids(), libMesh::MeshCommunication::broadcast(), libMesh::MeshTools::Generation::build_cube(), libMesh::MeshTools::Generation::build_delaunay_square(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::MeshTools::Generation::build_sphere(), libMesh::MeshTools::Modification::change_boundary_id(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::MeshBase::clear(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::FEGenericBase< OutputType >::compute_periodic_constraints(), libMesh::FEAbstract::compute_periodic_node_constraints(), libMesh::UnstructuredMesh::create_submesh(), libMesh::TetGenMeshInterface::delete_2D_hull_elements(), libMesh::ReplicatedMesh::delete_elem(), delete_elem(), libMesh::ReplicatedMesh::delete_node(), delete_node(), libMesh::MeshCommunication::delete_remote_elements(), DistributedMesh(), libMesh::MeshTools::Modification::flatten(), libMesh::UNVIO::groups_in(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::Parallel::Packing< const Node * >::pack(), libMesh::Parallel::Packing< const Elem * >::pack(), libMesh::Parallel::Packing< const Node * >::packable_size(), libMesh::Parallel::Packing< const Elem * >::packable_size(), libMesh::TetGenMeshInterface::pointset_convexhull(), libMesh::Nemesis_IO::prepare_to_write_nodal_data(), libMesh::AbaqusIO::read(), libMesh::Nemesis_IO::read(), libMesh::ExodusII_IO::read(), libMesh::CheckpointIO::read_bcs(), libMesh::CheckpointIO::read_header(), libMesh::CheckpointIO::read_nodesets(), libMesh::ReplicatedMesh::renumber_nodes_and_elements(), renumber_nodes_and_elements(), libMesh::ReplicatedMesh::ReplicatedMesh(), libMesh::ReplicatedMesh::stitching_helper(), libMesh::BoundaryInfo::sync(), libMesh::Elem::topological_neighbor(), libMesh::Parallel::Packing< Node * >::unpack(), libMesh::Parallel::Packing< Elem * >::unpack(), libMesh::FroIO::write(), libMesh::Nemesis_IO::write(), libMesh::ExodusII_IO::write(), libMesh::XdrIO::write(), libMesh::CheckpointIO::write(), libMesh::ExodusII_IO::write_nodal_data_common(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::Nemesis_IO_Helper::write_sidesets(), and libMesh::ExodusII_IO_Helper::write_sidesets().

118 { return *boundary_info; }
std::unique_ptr< BoundaryInfo > boundary_info
Definition: mesh_base.h:1322
BoundaryInfo& libMesh::MeshBase::get_boundary_info ( )
inlineinherited

Writable information about boundary ids on the mesh

Definition at line 123 of file mesh_base.h.

References libMesh::MeshBase::boundary_info, and libMesh::MeshBase::clear().

123 { return *boundary_info; }
std::unique_ptr< BoundaryInfo > boundary_info
Definition: mesh_base.h:1322
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 571 of file mesh_base.C.

References libMesh::MeshBase::_count_lower_dim_elems_in_point_locator.

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

572 {
574 }
bool _count_lower_dim_elems_in_point_locator
Definition: mesh_base.h:1363
subdomain_id_type libMesh::MeshBase::get_id_by_name ( const std::string &  name) const
inherited
Returns
The id of the named subdomain if it exists, Elem::invalid_subdomain_id otherwise.

Definition at line 598 of file mesh_base.C.

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

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

599 {
600  // Linear search over the map values.
601  std::map<subdomain_id_type, std::string>::const_iterator
602  iter = _block_id_to_name.begin(),
603  end_iter = _block_id_to_name.end();
604 
605  for ( ; iter != end_iter; ++iter)
606  if (iter->second == name)
607  return iter->first;
608 
609  // If we made it here without returning, we don't have a subdomain
610  // with the requested name, so return Elem::invalid_subdomain_id.
612 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
static const subdomain_id_type invalid_subdomain_id
Definition: elem.h:238
std::map< subdomain_id_type, std::string > _block_id_to_name
Definition: mesh_base.h:1405
std::string libMesh::MeshBase::get_info ( ) const
inherited
Returns
A string containing relevant information about the mesh.

Definition at line 416 of file mesh_base.C.

References libMesh::MeshBase::_elem_dims, libMesh::MeshBase::n_active_elem(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::MeshBase::n_nodes(), libMesh::MeshBase::n_partitions(), libMesh::ParallelObject::n_processors(), libMesh::MeshBase::n_subdomains(), libMesh::n_threads(), libMesh::ParallelObject::processor_id(), and libMesh::MeshBase::spatial_dimension().

Referenced by libMesh::MeshBase::n_partitions(), and libMesh::MeshBase::print_info().

417 {
418  std::ostringstream oss;
419 
420  oss << " Mesh Information:" << '\n';
421 
422  if (!_elem_dims.empty())
423  {
424  oss << " elem_dimensions()={";
425  std::copy(_elem_dims.begin(),
426  --_elem_dims.end(), // --end() is valid if the set is non-empty
427  std::ostream_iterator<unsigned int>(oss, ", "));
428  oss << cast_int<unsigned int>(*_elem_dims.rbegin());
429  oss << "}\n";
430  }
431 
432  oss << " spatial_dimension()=" << this->spatial_dimension() << '\n'
433  << " n_nodes()=" << this->n_nodes() << '\n'
434  << " n_local_nodes()=" << this->n_local_nodes() << '\n'
435  << " n_elem()=" << this->n_elem() << '\n'
436  << " n_local_elem()=" << this->n_local_elem() << '\n'
437 #ifdef LIBMESH_ENABLE_AMR
438  << " n_active_elem()=" << this->n_active_elem() << '\n'
439 #endif
440  << " n_subdomains()=" << static_cast<std::size_t>(this->n_subdomains()) << '\n'
441  << " n_partitions()=" << static_cast<std::size_t>(this->n_partitions()) << '\n'
442  << " n_processors()=" << static_cast<std::size_t>(this->n_processors()) << '\n'
443  << " n_threads()=" << static_cast<std::size_t>(libMesh::n_threads()) << '\n'
444  << " processor_id()=" << static_cast<std::size_t>(this->processor_id()) << '\n';
445 
446  return oss.str();
447 }
virtual dof_id_type n_active_elem() const =0
unsigned int n_threads()
Definition: libmesh_base.h:125
dof_id_type n_local_nodes() const
Definition: mesh_base.h:273
unsigned int n_partitions() const
Definition: mesh_base.h:834
processor_id_type n_processors() const
std::set< unsigned char > _elem_dims
Definition: mesh_base.h:1412
unsigned int spatial_dimension() const
Definition: mesh_base.C:159
dof_id_type n_local_elem() const
Definition: mesh_base.h:373
subdomain_id_type n_subdomains() const
Definition: mesh_base.C:336
virtual dof_id_type n_nodes() const =0
virtual dof_id_type n_elem() const =0
processor_id_type processor_id() const
const std::map<subdomain_id_type, std::string>& libMesh::MeshBase::get_subdomain_name_map ( ) const
inlineinherited
virtual element_iterator libMesh::DistributedMesh::ghost_elements_begin ( )
virtual

Iterate over "ghost" elements in the Mesh. A ghost element is one which is not local, but is semilocal.

Implements libMesh::MeshBase.

Referenced by active_local_element_ptr_range().

virtual const_element_iterator libMesh::DistributedMesh::ghost_elements_begin ( ) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::ghost_elements_end ( )
virtual
virtual const_element_iterator libMesh::DistributedMesh::ghost_elements_end ( ) const
virtual

Implements libMesh::MeshBase.

std::set<GhostingFunctor *>::const_iterator libMesh::MeshBase::ghosting_functors_begin ( ) const
inlineinherited
Elem * libMesh::DistributedMesh::insert_elem ( Elem e)
virtual

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

References _elements, _n_elem, libMesh::MeshBase::_next_unique_id, _next_unpartitioned_unique_id, delete_elem(), libMesh::DofObject::id(), libMesh::DofObject::invalid_processor_id, libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::DofObject::set_unique_id(), and libMesh::DofObject::valid_unique_id().

Referenced by reserve_elem().

508 {
509  if (_elements[e->id()])
510  this->delete_elem(_elements[e->id()]);
511 
512 #ifdef LIBMESH_ENABLE_UNIQUE_ID
513  if (!e->valid_unique_id())
514  {
515  if (processor_id() == e->processor_id())
516  {
517  e->set_unique_id() = _next_unique_id;
518  _next_unique_id += this->n_processors() + 1;
519  }
520  else
521  {
522  e->set_unique_id() = _next_unpartitioned_unique_id;
524  }
525  }
526 #endif
527 
528  // Try to make the cached elem data more accurate
529  processor_id_type elem_procid = e->processor_id();
530  if (elem_procid == this->processor_id() ||
531  elem_procid == DofObject::invalid_processor_id)
532  _n_elem++;
533 
534  _elements[e->id()] = e;
535 
536  return e;
537 }
mapvector< Elem *, dof_id_type > _elements
processor_id_type n_processors() const
uint8_t processor_id_type
Definition: id_types.h:99
unique_id_type _next_unique_id
Definition: mesh_base.h:1377
static const processor_id_type invalid_processor_id
Definition: dof_object.h:335
unique_id_type _next_unpartitioned_unique_id
virtual void delete_elem(Elem *e) libmesh_override
processor_id_type processor_id() const
Node * libMesh::DistributedMesh::insert_node ( Node n)
virtual

Calls add_node().

Implements libMesh::MeshBase.

Definition at line 705 of file distributed_mesh.C.

References add_node().

Referenced by reserve_elem().

706 {
707  return DistributedMesh::add_node(n);
708 }
virtual Node * add_node(Node *n) libmesh_override
bool libMesh::MeshBase::is_prepared ( ) const
inlineinherited
Returns
true if the mesh has been prepared via a call to prepare_for_use, false otherwise.

Definition at line 134 of file mesh_base.h.

References libMesh::MeshBase::_is_prepared.

Referenced by libMesh::DofMap::build_sparsity(), libMesh::DofMap::create_dof_constraints(), libMesh::DofMap::distribute_dofs(), and libMesh::DofMap::reinit().

135  { return _is_prepared; }
virtual bool libMesh::DistributedMesh::is_replicated ( ) const
inlinevirtual
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 146 of file distributed_mesh.h.

References add_extra_ghost_elem(), allgather(), delete_remote_elements(), gather_to_zero(), libmesh_assert_valid_parallel_flags(), libmesh_assert_valid_parallel_ids(), libmesh_assert_valid_parallel_object_ids(), libmesh_assert_valid_parallel_p_levels(), renumber_dof_objects(), and renumber_nodes_and_elements().

147  { return false; }
virtual bool libMesh::DistributedMesh::is_serial ( ) const
inlinevirtual
Returns
true if all elements and nodes of the mesh exist on the current processor, false otherwise

Reimplemented from libMesh::MeshBase.

Definition at line 124 of file distributed_mesh.h.

References _is_serial.

Referenced by libMesh::MeshCommunication::delete_remote_elements(), libMesh::MeshCommunication::redistribute(), and redistribute().

125  { return _is_serial; }
virtual bool libMesh::DistributedMesh::is_serial_on_zero ( ) const
inlinevirtual
Returns
true if all elements and nodes of the mesh exist on the processor 0, false otherwise

Reimplemented from libMesh::MeshBase.

Definition at line 131 of file distributed_mesh.h.

References _is_serial, and _is_serial_on_proc_0.

virtual element_iterator libMesh::DistributedMesh::level_elements_begin ( unsigned int  level)
virtual
virtual const_element_iterator libMesh::DistributedMesh::level_elements_begin ( unsigned int  level) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::level_elements_end ( unsigned int  level)
virtual
virtual const_element_iterator libMesh::DistributedMesh::level_elements_end ( unsigned int  level) const
virtual

Implements libMesh::MeshBase.

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

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

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

956 {
957 #if defined(LIBMESH_ENABLE_AMR) && !defined(NDEBUG)
958  // This function must be run on all processors at once
959  parallel_object_only();
960 
961  dof_id_type pmax_elem_id = this->parallel_max_elem_id();
962 
963  for (dof_id_type i=0; i != pmax_elem_id; ++i)
964  {
965  Elem * el = _elements[i]; // Returns NULL if there's no map entry
966 
967  unsigned int refinement_flag = el ?
968  static_cast<unsigned int> (el->refinement_flag()) : libMesh::invalid_uint;
969  unsigned int p_refinement_flag = el ?
970  static_cast<unsigned int> (el->p_refinement_flag()) : libMesh::invalid_uint;
971 
972  libmesh_assert(this->comm().semiverify(el ? &refinement_flag : libmesh_nullptr));
973 
974  // p refinement flags aren't always kept correct on inactive
975  // ghost elements
976  libmesh_assert(this->comm().semiverify((el && el->active()) ? &p_refinement_flag : libmesh_nullptr));
977  }
978 #endif // LIBMESH_ENABLE_AMR
979 }
mapvector< Elem *, dof_id_type > _elements
const unsigned int invalid_uint
Definition: libmesh.h:184
const class libmesh_nullptr_t libmesh_nullptr
dof_id_type parallel_max_elem_id() const
const Parallel::Communicator & comm() const
uint8_t dof_id_type
Definition: id_types.h:64
void libMesh::DistributedMesh::libmesh_assert_valid_parallel_ids ( ) const
virtual

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

References _elements, _nodes, and libmesh_assert_valid_parallel_object_ids().

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

925 {
928 }
mapvector< Elem *, dof_id_type > _elements
mapvector< Node *, dof_id_type > _nodes
void libmesh_assert_valid_parallel_object_ids(const mapvector< T *, dof_id_type > &) const
template<typename T >
void libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids ( const mapvector< T *, dof_id_type > &  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 868 of file distributed_mesh.C.

References libMesh::ParallelObject::comm(), libMesh::DofObject::invalid_id, libMesh::DofObject::invalid_processor_id, libmesh_nullptr, std::max(), libMesh::Parallel::Communicator::min(), parallel_max_elem_id(), parallel_max_node_id(), and libMesh::ParallelObject::processor_id().

Referenced by is_replicated(), and libmesh_assert_valid_parallel_ids().

869 {
870  // This function must be run on all processors at once
871  parallel_object_only();
872 
873  const dof_id_type pmax_node_id = this->parallel_max_node_id();
874  const dof_id_type pmax_elem_id = this->parallel_max_elem_id();
875  const dof_id_type pmax_id = std::max(pmax_node_id, pmax_elem_id);
876 
877  for (dof_id_type i=0; i != pmax_id; ++i)
878  {
879  T * obj = objects[i]; // Returns NULL if there's no map entry
880 
881  // Local lookups by id should return the requested object
882  libmesh_assert(!obj || obj->id() == i);
883 
884  // All processors with an object should agree on id
885 #ifndef NDEBUG
886  const dof_id_type dofid = obj && obj->valid_id() ?
887  obj->id() : DofObject::invalid_id;
888  libmesh_assert(this->comm().semiverify(obj ? &dofid : libmesh_nullptr));
889 #endif
890 
891  // All processors with an object should agree on processor id
892  const dof_id_type procid = obj && obj->valid_processor_id() ?
893  obj->processor_id() : DofObject::invalid_processor_id;
894  libmesh_assert(this->comm().semiverify(obj ? &procid : libmesh_nullptr));
895 
896  dof_id_type min_procid = procid;
897  this->comm().min(min_procid);
898 
899  // Either:
900  // 1.) I own this elem (min_procid == this->processor_id()) *and* I have a valid pointer to it (obj != NULL)
901  // or
902  // 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.)
903 
904  // Original assert logic
905  // libmesh_assert (min_procid != this->processor_id() || obj);
906 
907  // More human-understandable logic...
908  libmesh_assert (
909  ((min_procid == this->processor_id()) && obj)
910  ||
911  (min_procid != this->processor_id())
912  );
913 
914 #if defined(LIBMESH_ENABLE_UNIQUE_ID) && !defined(NDEBUG)
915  // All processors with an object should agree on unique id
916  const unique_id_type uniqueid = obj ? obj->unique_id() : 0;
917  libmesh_assert(this->comm().semiverify(obj ? &uniqueid : libmesh_nullptr));
918 #endif
919  }
920 }
const class libmesh_nullptr_t libmesh_nullptr
dof_id_type parallel_max_elem_id() const
long double max(long double a, double b)
dof_id_type parallel_max_node_id() const
static const processor_id_type invalid_processor_id
Definition: dof_object.h:335
static const dof_id_type invalid_id
Definition: dof_object.h:324
const Parallel::Communicator & comm() const
uint8_t unique_id_type
Definition: id_types.h:79
processor_id_type processor_id() const
uint8_t dof_id_type
Definition: id_types.h:64
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 932 of file distributed_mesh.C.

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

Referenced by is_replicated(), and renumber_nodes_and_elements().

933 {
934 #ifndef NDEBUG
935  // This function must be run on all processors at once
936  parallel_object_only();
937 
938  dof_id_type pmax_elem_id = this->parallel_max_elem_id();
939 
940  for (dof_id_type i=0; i != pmax_elem_id; ++i)
941  {
942  Elem * el = _elements[i]; // Returns NULL if there's no map entry
943 
944  unsigned int p_level = el ? (el->p_level()) : libMesh::invalid_uint;
945 
946  // All processors with an active element should agree on p level
947  libmesh_assert(this->comm().semiverify((el && el->active()) ? &p_level : libmesh_nullptr));
948  }
949 #endif
950 }
mapvector< Elem *, dof_id_type > _elements
const unsigned int invalid_uint
Definition: libmesh.h:184
const class libmesh_nullptr_t libmesh_nullptr
dof_id_type parallel_max_elem_id() const
const Parallel::Communicator & comm() const
uint8_t dof_id_type
Definition: id_types.h:64
virtual element_iterator libMesh::DistributedMesh::local_elements_begin ( )
virtual

Implements libMesh::MeshBase.

Referenced by active_element_ptr_range().

virtual const_element_iterator libMesh::DistributedMesh::local_elements_begin ( ) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::local_elements_end ( )
virtual

Implements libMesh::MeshBase.

Referenced by active_element_ptr_range().

virtual const_element_iterator libMesh::DistributedMesh::local_elements_end ( ) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::local_level_elements_begin ( unsigned int  level)
virtual
virtual const_element_iterator libMesh::DistributedMesh::local_level_elements_begin ( unsigned int  level) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::local_level_elements_end ( unsigned int  level)
virtual
virtual const_element_iterator libMesh::DistributedMesh::local_level_elements_end ( unsigned int  level) const
virtual

Implements libMesh::MeshBase.

virtual SimpleRange<node_iterator> libMesh::DistributedMesh::local_node_ptr_range ( )
inlinevirtual

Implements libMesh::MeshBase.

Definition at line 488 of file distributed_mesh.h.

References local_nodes_begin(), and local_nodes_end().

488 { return {local_nodes_begin(), local_nodes_end()}; }
virtual node_iterator local_nodes_end() libmesh_override
virtual node_iterator local_nodes_begin() libmesh_override
virtual SimpleRange<const_node_iterator> libMesh::DistributedMesh::local_node_ptr_range ( ) const
inlinevirtual
virtual node_iterator libMesh::DistributedMesh::local_nodes_begin ( )
virtual

Iterate over local nodes (nodes whose processor_id() matches the current processor).

Implements libMesh::MeshBase.

Referenced by local_node_ptr_range(), and node_ptr_range().

virtual const_node_iterator libMesh::DistributedMesh::local_nodes_begin ( ) const
virtual

Implements libMesh::MeshBase.

virtual node_iterator libMesh::DistributedMesh::local_nodes_end ( )
virtual
virtual const_node_iterator libMesh::DistributedMesh::local_nodes_end ( ) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::local_not_level_elements_begin ( unsigned int  level)
virtual
virtual const_element_iterator libMesh::DistributedMesh::local_not_level_elements_begin ( unsigned int  level) const
virtual

Implements libMesh::MeshBase.

virtual element_iterator libMesh::DistributedMesh::local_not_level_elements_end ( unsigned int  level)
virtual
virtual const_element_iterator libMesh::DistributedMesh::local_not_level_elements_end ( unsigned int  level) const
virtual

Implements libMesh::MeshBase.

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

Implements libMesh::MeshBase.

Definition at line 229 of file distributed_mesh.h.

References _max_elem_id.

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

229 { return _max_elem_id; }
virtual dof_id_type libMesh::DistributedMesh::max_node_id ( ) const
inlinevirtual
Returns
A number greater than or equal to the maximum node id in the mesh.

Implements libMesh::MeshBase.

Definition at line 225 of file distributed_mesh.h.

References _max_node_id.

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

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

Definition at line 150 of file mesh_base.C.

References libMesh::MeshBase::_elem_dims.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::HPCoarsenTest::add_projection(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::MeshTools::Generation::build_cube(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::MeshTools::Generation::build_sphere(), libMesh::EquationSystems::build_variable_names(), libMesh::MeshBase::cache_elem_dims(), libMesh::DofMap::create_dof_constraints(), libMesh::MeshBase::delete_remote_elements(), libMesh::MeshTools::Modification::distort(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::LaplaceMeshSmoother::init(), libMesh::PointLocatorTree::init(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::FEInterface::n_vec_dim(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::GMVIO::read(), libMesh::Nemesis_IO::read(), libMesh::ExodusII_IO::read(), libMesh::VTKIO::read(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::HPCoarsenTest::select_refinement(), libMesh::MeshTools::Modification::smooth(), libMesh::DofMap::use_coupled_neighbor_dofs(), libMesh::PostscriptIO::write(), libMesh::CheckpointIO::write(), libMesh::TecplotIO::write_binary(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::UCDIO::write_nodal_data(), libMesh::EnsightIO::write_scalar_ascii(), libMesh::GnuPlotIO::write_solution(), and libMesh::EnsightIO::write_vector_ascii().

151 {
152  if (!_elem_dims.empty())
153  return cast_int<unsigned int>(*_elem_dims.rbegin());
154  return 0;
155 }
std::set< unsigned char > _elem_dims
Definition: mesh_base.h:1412
dof_id_type libMesh::DistributedMesh::n_active_elem ( ) const
virtual
Returns
The number of active elements in the mesh.

Implemented in terms of active_element_iterators.

Implements libMesh::MeshBase.

Definition at line 1335 of file distributed_mesh.C.

References active_local_elements_begin(), active_local_elements_end(), active_pid_elements_begin(), active_pid_elements_end(), libMesh::ParallelObject::comm(), libMesh::DofObject::invalid_processor_id, and libMesh::Parallel::Communicator::sum().

Referenced by n_elem().

1336 {
1337  parallel_object_only();
1338 
1339  // Get local active elements first
1340  dof_id_type active_elements =
1341  static_cast<dof_id_type>(std::distance (this->active_local_elements_begin(),
1342  this->active_local_elements_end()));
1343  this->comm().sum(active_elements);
1344 
1345  // Then add unpartitioned active elements, which should exist on
1346  // every processor
1347  active_elements +=
1348  static_cast<dof_id_type>(std::distance
1351  return active_elements;
1352 }
virtual element_iterator active_local_elements_begin() libmesh_override
virtual element_iterator active_local_elements_end() libmesh_override
static const processor_id_type invalid_processor_id
Definition: dof_object.h:335
virtual element_iterator active_pid_elements_begin(processor_id_type proc_id) libmesh_override
const Parallel::Communicator & comm() const
uint8_t dof_id_type
Definition: id_types.h:64
virtual element_iterator active_pid_elements_end(processor_id_type proc_id) libmesh_override
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 377 of file mesh_base.C.

References libMesh::MeshBase::active_pid_elements_begin(), libMesh::MeshBase::active_pid_elements_end(), and libMesh::ParallelObject::n_processors().

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

378 {
379  libmesh_assert_less (proc_id, this->n_processors());
380  return static_cast<dof_id_type>(std::distance (this->active_pid_elements_begin(proc_id),
381  this->active_pid_elements_end (proc_id)));
382 }
processor_id_type n_processors() const
virtual element_iterator active_pid_elements_begin(processor_id_type proc_id)=0
virtual element_iterator active_pid_elements_end(processor_id_type proc_id)=0
uint8_t dof_id_type
Definition: id_types.h:64
dof_id_type libMesh::MeshBase::n_active_local_elem ( ) const
inlineinherited
dof_id_type libMesh::MeshBase::n_active_sub_elem ( ) const
inherited

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

Definition at line 401 of file mesh_base.C.

References libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), and end.

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

402 {
403  dof_id_type ne=0;
404 
405  const_element_iterator el = this->active_elements_begin();
406  const const_element_iterator end = this->active_elements_end();
407 
408  for (; el!=end; ++el)
409  ne += (*el)->n_sub_elem();
410 
411  return ne;
412 }
IterBase * end
virtual element_iterator active_elements_begin()=0
virtual element_iterator active_elements_end()=0
uint8_t dof_id_type
Definition: id_types.h:64
virtual dof_id_type libMesh::DistributedMesh::n_elem ( ) const
inlinevirtual
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 227 of file distributed_mesh.h.

References _n_elem, and n_active_elem().

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

227 { return _n_elem; }
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 364 of file mesh_base.C.

References libMesh::DofObject::invalid_processor_id, libMesh::ParallelObject::n_processors(), libMesh::MeshBase::pid_elements_begin(), and libMesh::MeshBase::pid_elements_end().

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

365 {
366  // We're either counting a processor's elements or unpartitioned
367  // elements
368  libmesh_assert (proc_id < this->n_processors() ||
370 
371  return static_cast<dof_id_type>(std::distance (this->pid_elements_begin(proc_id),
372  this->pid_elements_end (proc_id)));
373 }
processor_id_type n_processors() const
static const processor_id_type invalid_processor_id
Definition: dof_object.h:335
virtual element_iterator pid_elements_begin(processor_id_type proc_id)=0
uint8_t dof_id_type
Definition: id_types.h:64
virtual element_iterator pid_elements_end(processor_id_type proc_id)=0
dof_id_type libMesh::MeshBase::n_local_elem ( ) const
inlineinherited
Returns
The number of elements on the local processor.

Definition at line 373 of file mesh_base.h.

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

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

374  { 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:364
processor_id_type processor_id() const
dof_id_type libMesh::MeshBase::n_local_nodes ( ) const
inlineinherited
Returns
The number of nodes on the local processor.

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

274  { 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:351
processor_id_type processor_id() const
virtual dof_id_type libMesh::DistributedMesh::n_nodes ( ) const
inlinevirtual
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 224 of file distributed_mesh.h.

References _n_nodes.

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

224 { return _n_nodes; }
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 351 of file mesh_base.C.

References libMesh::DofObject::invalid_processor_id, libMesh::ParallelObject::n_processors(), libMesh::MeshBase::pid_nodes_begin(), and libMesh::MeshBase::pid_nodes_end().

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

352 {
353  // We're either counting a processor's nodes or unpartitioned
354  // nodes
355  libmesh_assert (proc_id < this->n_processors() ||
357 
358  return static_cast<dof_id_type>(std::distance (this->pid_nodes_begin(proc_id),
359  this->pid_nodes_end (proc_id)));
360 }
virtual node_iterator pid_nodes_end(processor_id_type proc_id)=0
processor_id_type n_processors() const
static const processor_id_type invalid_processor_id
Definition: dof_object.h:335
virtual node_iterator pid_nodes_begin(processor_id_type proc_id)=0
uint8_t dof_id_type
Definition: id_types.h:64
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 834 of file mesh_base.h.

References libMesh::MeshBase::_n_parts, libMesh::MeshBase::all_first_order(), libMesh::MeshBase::all_second_order(), libMesh::MeshBase::get_info(), libmesh_nullptr, libMesh::Quality::name(), libMesh::MeshBase::operator<<, libMesh::out, libMesh::MeshBase::print_info(), libMesh::MeshBase::read(), and libMesh::MeshBase::write().

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

835  { return _n_parts; }
unsigned int _n_parts
Definition: mesh_base.h:1343
processor_id_type libMesh::ParallelObject::n_processors ( ) const
inlineinherited
Returns
The number of processors in the group.

Definition at line 93 of file parallel_object.h.

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

Referenced by libMesh::ParmetisPartitioner::_do_repartition(), libMesh::BoundaryInfo::_find_id_maps(), add_elem(), add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assembly(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::MeshCommunication::broadcast(), libMesh::BoundaryInfo::build_node_list_from_side_list(), clear(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), DistributedMesh(), libMesh::EnsightIO::EnsightIO(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), libMesh::MeshBase::get_info(), libMesh::EquationSystems::get_solution(), libMesh::DistributedVector< T >::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::Nemesis_IO_Helper::initialize(), insert_elem(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_elem_on_proc(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::Partitioner::partition(), libMesh::MeshBase::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::PetscLinearSolver< T >::PetscLinearSolver(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::SparseMatrix< T >::print(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::XdrIO::read_header(), libMesh::CheckpointIO::read_nodes(), libMesh::MeshCommunication::redistribute(), renumber_dof_objects(), libMesh::Partitioner::repartition(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Parallel::Sort< KeyType, IdxType >::sort(), libMesh::MeshRefinement::uniformly_coarsen(), update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

94  { return cast_int<processor_id_type>(_communicator.size()); }
unsigned int size() const
Definition: parallel.h:725
const Parallel::Communicator & _communicator
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 386 of file mesh_base.C.

References libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), and end.

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

387 {
388  dof_id_type ne=0;
389 
390  const_element_iterator el = this->elements_begin();
391  const const_element_iterator end = this->elements_end();
392 
393  for (; el!=end; ++el)
394  ne += (*el)->n_sub_elem();
395 
396  return ne;
397 }
IterBase * end
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
uint8_t dof_id_type
Definition: id_types.h:64
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 336 of file mesh_base.C.

References libMesh::MeshBase::subdomain_ids().

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

337 {
338  // This requires an inspection on every processor
339  parallel_object_only();
340 
341  std::set<subdomain_id_type> ids;
342 
343  this->subdomain_ids (ids);
344 
345  return cast_int<subdomain_id_type>(ids.size());
346 }
void subdomain_ids(std::set< subdomain_id_type > &ids) const
Definition: mesh_base.C:317
dof_id_type libMesh::MeshBase::n_unpartitioned_elem ( ) const
inlineinherited
Returns
The number of elements owned by no processor.

Definition at line 379 of file mesh_base.h.

References libMesh::DofObject::invalid_processor_id, libMesh::MeshBase::n_active_elem_on_proc(), 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:364
static const processor_id_type invalid_processor_id
Definition: dof_object.h:335
dof_id_type libMesh::MeshBase::n_unpartitioned_nodes ( ) const
inlineinherited
Returns
The number of nodes owned by no processor.

Definition at line 279 of file mesh_base.h.

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

Referenced by parallel_n_nodes().

dof_id_type n_nodes_on_proc(const processor_id_type proc) const
Definition: mesh_base.C:351
static const processor_id_type invalid_processor_id
Definition: dof_object.h:335
unique_id_type libMesh::MeshBase::next_unique_id ( )
inlineinherited
Returns
The next unique id to be used.

Definition at line 292 of file mesh_base.h.

References libMesh::MeshBase::_next_unique_id.

292 { return _next_unique_id; }
unique_id_type _next_unique_id
Definition: mesh_base.h:1377
virtual const Node& libMesh::MeshBase::node ( const dof_id_type  i) const
inlinevirtualinherited
Returns
A constant reference (for reading only) to the $ i^{th} $ node, which should be present in this processor's subset of the mesh data structure.
Deprecated:
Use the less confusingly-named node_ref() instead.

Definition at line 441 of file mesh_base.h.

References libMesh::MeshBase::node_ptr().

Referenced by libMesh::MeshBase::cache_elem_dims(), and libMesh::MeshTools::Modification::change_boundary_id().

442  {
443  libmesh_deprecated();
444  return *this->node_ptr(i);
445  }
virtual const Node * node_ptr(const dof_id_type i) const =0
virtual Node& libMesh::MeshBase::node ( 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.
Deprecated:
Use the less confusingly-named node_ref() instead.

Definition at line 455 of file mesh_base.h.

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

456  {
457  libmesh_deprecated();
458  return *this->node_ptr(i);
459  }
virtual const Node * node_ptr(const dof_id_type i) const =0