libMesh::ReplicatedMesh Class Reference

Mesh data structure replicated on all processors. More...

#include <replicated_mesh.h>

Inheritance diagram for libMesh::ReplicatedMesh:

Public Types

typedef Predicates::multi_predicate Predicate
 

Public Member Functions

 ReplicatedMesh (const Parallel::Communicator &comm_in, unsigned char dim=1)
 
 ReplicatedMesh (const UnstructuredMesh &other_mesh)
 
 ReplicatedMesh (const ReplicatedMesh &other_mesh)
 
 ReplicatedMesh (ReplicatedMesh &&)=default
 
ReplicatedMeshoperator= (const ReplicatedMesh &)=delete
 
ReplicatedMeshoperator= (ReplicatedMesh &&)=delete
 
virtual std::unique_ptr< MeshBaseclone () const override
 
virtual ~ReplicatedMesh ()
 
virtual void clear () override
 
virtual void renumber_nodes_and_elements () override
 
virtual dof_id_type n_nodes () const override
 
virtual dof_id_type parallel_n_nodes () const override
 
virtual dof_id_type max_node_id () const override
 
virtual void reserve_nodes (const dof_id_type nn) override
 
virtual dof_id_type n_elem () const override
 
virtual dof_id_type parallel_n_elem () const override
 
virtual dof_id_type n_active_elem () const override
 
virtual dof_id_type max_elem_id () const override
 
virtual unique_id_type parallel_max_unique_id () const override
 
virtual void reserve_elem (const dof_id_type ne) override
 
virtual void update_parallel_id_counts () override
 
virtual const Pointpoint (const dof_id_type i) const override
 
virtual const Nodenode_ptr (const dof_id_type i) const override
 
virtual Nodenode_ptr (const dof_id_type i) override
 
virtual const Nodequery_node_ptr (const dof_id_type i) const override
 
virtual Nodequery_node_ptr (const dof_id_type i) override
 
virtual const Elemelem_ptr (const dof_id_type i) const override
 
virtual Elemelem_ptr (const dof_id_type i) override
 
virtual const Elemquery_elem_ptr (const dof_id_type i) const override
 
virtual Elemquery_elem_ptr (const dof_id_type i) 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) override
 
virtual Nodeadd_node (Node *n) override
 
virtual Nodeinsert_node (Node *n) override
 
virtual void delete_node (Node *n) override
 
virtual void renumber_node (dof_id_type old_id, dof_id_type new_id) override
 
virtual Elemadd_elem (Elem *e) override
 
virtual Eleminsert_elem (Elem *e) override
 
virtual void delete_elem (Elem *e) override
 
virtual void renumber_elem (dof_id_type old_id, dof_id_type new_id) override
 
virtual void fix_broken_node_and_element_numbering () override
 
void stitch_meshes (const ReplicatedMesh &other_mesh, boundary_id_type this_mesh_boundary, boundary_id_type other_mesh_boundary, Real tol=TOLERANCE, bool clear_stitched_boundary_ids=false, bool verbose=true, bool use_binary_search=true, bool enforce_all_nodes_match_on_boundaries=false)
 
void stitch_surfaces (boundary_id_type boundary_id_1, boundary_id_type boundary_id_2, Real tol=TOLERANCE, bool clear_stitched_boundary_ids=false, bool verbose=true, bool use_binary_search=true, bool enforce_all_nodes_match_on_boundaries=false)
 
virtual element_iterator elements_begin () override
 
virtual element_iterator elements_end () override
 
virtual const_element_iterator elements_begin () const override
 
virtual const_element_iterator elements_end () const override
 
virtual SimpleRange< element_iteratorelement_ptr_range () override
 
virtual SimpleRange< const_element_iteratorelement_ptr_range () const override
 
virtual element_iterator active_elements_begin () override
 
virtual element_iterator active_elements_end () override
 
virtual const_element_iterator active_elements_begin () const override
 
virtual const_element_iterator active_elements_end () const override
 
virtual SimpleRange< element_iteratoractive_element_ptr_range () override
 
virtual SimpleRange< const_element_iteratoractive_element_ptr_range () const override
 
virtual element_iterator ancestor_elements_begin () override
 
virtual element_iterator ancestor_elements_end () override
 
virtual const_element_iterator ancestor_elements_begin () const override
 
virtual const_element_iterator ancestor_elements_end () const override
 
virtual element_iterator subactive_elements_begin () override
 
virtual element_iterator subactive_elements_end () override
 
virtual const_element_iterator subactive_elements_begin () const override
 
virtual const_element_iterator subactive_elements_end () const override
 
virtual element_iterator not_active_elements_begin () override
 
virtual element_iterator not_active_elements_end () override
 
virtual const_element_iterator not_active_elements_begin () const override
 
virtual const_element_iterator not_active_elements_end () const override
 
virtual element_iterator not_ancestor_elements_begin () override
 
virtual element_iterator not_ancestor_elements_end () override
 
virtual const_element_iterator not_ancestor_elements_begin () const override
 
virtual const_element_iterator not_ancestor_elements_end () const override
 
virtual element_iterator not_subactive_elements_begin () override
 
virtual element_iterator not_subactive_elements_end () override
 
virtual const_element_iterator not_subactive_elements_begin () const override
 
virtual const_element_iterator not_subactive_elements_end () const override
 
virtual element_iterator local_elements_begin () override
 
virtual element_iterator local_elements_end () override
 
virtual const_element_iterator local_elements_begin () const override
 
virtual const_element_iterator local_elements_end () const override
 
virtual element_iterator semilocal_elements_begin () override
 
virtual element_iterator semilocal_elements_end () override
 
virtual const_element_iterator semilocal_elements_begin () const override
 
virtual const_element_iterator semilocal_elements_end () const override
 
virtual element_iterator active_semilocal_elements_begin () override
 
virtual element_iterator active_semilocal_elements_end () override
 
virtual const_element_iterator active_semilocal_elements_begin () const override
 
virtual const_element_iterator active_semilocal_elements_end () const override
 
virtual element_iterator facelocal_elements_begin () override
 
virtual element_iterator facelocal_elements_end () override
 
virtual const_element_iterator facelocal_elements_begin () const override
 
virtual const_element_iterator facelocal_elements_end () const override
 
virtual element_iterator not_local_elements_begin () override
 
virtual element_iterator not_local_elements_end () override
 
virtual const_element_iterator not_local_elements_begin () const override
 
virtual const_element_iterator not_local_elements_end () const override
 
virtual element_iterator active_local_elements_begin () override
 
virtual element_iterator active_local_elements_end () override
 
virtual const_element_iterator active_local_elements_begin () const override
 
virtual const_element_iterator active_local_elements_end () const override
 
virtual SimpleRange< element_iteratoractive_local_element_ptr_range () override
 
virtual SimpleRange< const_element_iteratoractive_local_element_ptr_range () const override
 
virtual element_iterator active_not_local_elements_begin () override
 
virtual element_iterator active_not_local_elements_end () override
 
virtual const_element_iterator active_not_local_elements_begin () const override
 
virtual const_element_iterator active_not_local_elements_end () const override
 
virtual element_iterator level_elements_begin (unsigned int level) override
 
virtual element_iterator level_elements_end (unsigned int level) override
 
virtual const_element_iterator level_elements_begin (unsigned int level) const override
 
virtual const_element_iterator level_elements_end (unsigned int level) const override
 
virtual element_iterator not_level_elements_begin (unsigned int level) override
 
virtual element_iterator not_level_elements_end (unsigned int level) override
 
virtual const_element_iterator not_level_elements_begin (unsigned int level) const override
 
virtual const_element_iterator not_level_elements_end (unsigned int level) const override
 
virtual element_iterator local_level_elements_begin (unsigned int level) override
 
virtual element_iterator local_level_elements_end (unsigned int level) override
 
virtual const_element_iterator local_level_elements_begin (unsigned int level) const override
 
virtual const_element_iterator local_level_elements_end (unsigned int level) const override
 
virtual element_iterator local_not_level_elements_begin (unsigned int level) override
 
virtual element_iterator local_not_level_elements_end (unsigned int level) override
 
virtual const_element_iterator local_not_level_elements_begin (unsigned int level) const override
 
virtual const_element_iterator local_not_level_elements_end (unsigned int level) const override
 
virtual element_iterator pid_elements_begin (processor_id_type proc_id) override
 
virtual element_iterator pid_elements_end (processor_id_type proc_id) override
 
virtual const_element_iterator pid_elements_begin (processor_id_type proc_id) const override
 
virtual const_element_iterator pid_elements_end (processor_id_type proc_id) const override
 
virtual element_iterator type_elements_begin (ElemType type) override
 
virtual element_iterator type_elements_end (ElemType type) override
 
virtual const_element_iterator type_elements_begin (ElemType type) const override
 
virtual const_element_iterator type_elements_end (ElemType type) const override
 
virtual element_iterator active_type_elements_begin (ElemType type) override
 
virtual element_iterator active_type_elements_end (ElemType type) override
 
virtual const_element_iterator active_type_elements_begin (ElemType type) const override
 
virtual const_element_iterator active_type_elements_end (ElemType type) const override
 
virtual element_iterator active_pid_elements_begin (processor_id_type proc_id) override
 
virtual element_iterator active_pid_elements_end (processor_id_type proc_id) override
 
virtual const_element_iterator active_pid_elements_begin (processor_id_type proc_id) const override
 
virtual const_element_iterator active_pid_elements_end (processor_id_type proc_id) const override
 
virtual element_iterator unpartitioned_elements_begin () override
 
virtual element_iterator unpartitioned_elements_end () override
 
virtual const_element_iterator unpartitioned_elements_begin () const override
 
virtual const_element_iterator unpartitioned_elements_end () const override
 
virtual element_iterator active_unpartitioned_elements_begin () override
 
virtual element_iterator active_unpartitioned_elements_end () override
 
virtual const_element_iterator active_unpartitioned_elements_begin () const override
 
virtual const_element_iterator active_unpartitioned_elements_end () const override
 
virtual element_iterator active_local_subdomain_elements_begin (subdomain_id_type subdomain_id) override
 
virtual element_iterator active_local_subdomain_elements_end (subdomain_id_type subdomain_id) override
 
virtual const_element_iterator active_local_subdomain_elements_begin (subdomain_id_type subdomain_id) const override
 
virtual const_element_iterator active_local_subdomain_elements_end (subdomain_id_type subdomain_id) const override
 
virtual element_iterator active_subdomain_elements_begin (subdomain_id_type subdomain_id) override
 
virtual element_iterator active_subdomain_elements_end (subdomain_id_type subdomain_id) override
 
virtual const_element_iterator active_subdomain_elements_begin (subdomain_id_type subdomain_id) const override
 
virtual const_element_iterator active_subdomain_elements_end (subdomain_id_type subdomain_id) const override
 
virtual element_iterator active_subdomain_set_elements_begin (std::set< subdomain_id_type > ss) override
 
virtual element_iterator active_subdomain_set_elements_end (std::set< subdomain_id_type > ss) override
 
virtual const_element_iterator active_subdomain_set_elements_begin (std::set< subdomain_id_type > ss) const override
 
virtual const_element_iterator active_subdomain_set_elements_end (std::set< subdomain_id_type > ss) const override
 
virtual element_iterator ghost_elements_begin () override
 
virtual element_iterator ghost_elements_end () override
 
virtual const_element_iterator ghost_elements_begin () const override
 
virtual const_element_iterator ghost_elements_end () const override
 
virtual element_iterator evaluable_elements_begin (const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint) override
 
virtual element_iterator evaluable_elements_end (const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint) override
 
virtual const_element_iterator evaluable_elements_begin (const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint) const override
 
virtual const_element_iterator evaluable_elements_end (const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint) const override
 
virtual element_iterator flagged_elements_begin (unsigned char rflag) override
 
virtual element_iterator flagged_elements_end (unsigned char rflag) override
 
virtual const_element_iterator flagged_elements_begin (unsigned char rflag) const override
 
virtual const_element_iterator flagged_elements_end (unsigned char rflag) const override
 
virtual element_iterator flagged_pid_elements_begin (unsigned char rflag, processor_id_type pid) override
 
virtual element_iterator flagged_pid_elements_end (unsigned char rflag, processor_id_type pid) override
 
virtual const_element_iterator flagged_pid_elements_begin (unsigned char rflag, processor_id_type pid) const override
 
virtual const_element_iterator flagged_pid_elements_end (unsigned char rflag, processor_id_type pid) const override
 
virtual node_iterator nodes_begin () override
 
virtual node_iterator nodes_end () override
 
virtual const_node_iterator nodes_begin () const override
 
virtual const_node_iterator nodes_end () const override
 
virtual SimpleRange< node_iteratornode_ptr_range () override
 
virtual SimpleRange< const_node_iteratornode_ptr_range () const override
 
virtual node_iterator active_nodes_begin () override
 
virtual node_iterator active_nodes_end () override
 
virtual const_node_iterator active_nodes_begin () const override
 
virtual const_node_iterator active_nodes_end () const override
 
virtual node_iterator local_nodes_begin () override
 
virtual node_iterator local_nodes_end () override
 
virtual const_node_iterator local_nodes_begin () const override
 
virtual const_node_iterator local_nodes_end () const override
 
virtual SimpleRange< node_iteratorlocal_node_ptr_range () override
 
virtual SimpleRange< const_node_iteratorlocal_node_ptr_range () const override
 
virtual node_iterator pid_nodes_begin (processor_id_type proc_id) override
 
virtual node_iterator pid_nodes_end (processor_id_type proc_id) override
 
virtual const_node_iterator pid_nodes_begin (processor_id_type proc_id) const override
 
virtual const_node_iterator pid_nodes_end (processor_id_type proc_id) const override
 
virtual node_iterator bid_nodes_begin (boundary_id_type bndry_id) override
 
virtual node_iterator bid_nodes_end (boundary_id_type bndry_id) override
 
virtual const_node_iterator bid_nodes_begin (boundary_id_type bndry_id) const override
 
virtual const_node_iterator bid_nodes_end (boundary_id_type bndry_id) const override
 
virtual node_iterator bnd_nodes_begin () override
 
virtual node_iterator bnd_nodes_end () override
 
virtual const_node_iterator bnd_nodes_begin () const override
 
virtual const_node_iterator bnd_nodes_end () const override
 
virtual node_iterator evaluable_nodes_begin (const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint) override
 
virtual node_iterator evaluable_nodes_end (const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint) override
 
virtual const_node_iterator evaluable_nodes_begin (const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint) const override
 
virtual const_node_iterator evaluable_nodes_end (const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint) const override
 
virtual void read (const std::string &name, void *mesh_data=nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false) override
 
virtual void write (const std::string &name) override
 
void write (const std::string &name, const std::vector< Number > &values, const std::vector< std::string > &variable_names)
 
virtual void all_first_order () override
 
virtual void all_second_order (const bool full_ordered=true) override
 
void create_pid_mesh (UnstructuredMesh &pid_mesh, const processor_id_type pid) const
 
void create_submesh (UnstructuredMesh &new_mesh, const 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, dof_id_type element_id_offset=0, dof_id_type node_id_offset=0, unique_id_type unique_id_offset=0)
 
virtual void find_neighbors (const bool reset_remote_elements=false, const bool reset_current_list=true) override
 
virtual bool contract () override
 
virtual std::unique_ptr< Partitioner > & partitioner ()
 
const BoundaryInfoget_boundary_info () const
 
BoundaryInfoget_boundary_info ()
 
bool is_prepared () const
 
virtual bool is_serial () const
 
virtual bool is_serial_on_zero () const
 
virtual void set_distributed ()
 
virtual bool is_replicated () const
 
virtual void allgather ()
 
virtual void gather_to_zero ()
 
virtual void delete_remote_elements ()
 
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)
 
virtual void own_node (Node &)
 
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 ()
 
virtual void redistribute ()
 
virtual void update_post_partitioning ()
 
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
 
GhostingFunctordefault_ghosting ()
 
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
 
virtual void libmesh_assert_valid_parallel_ids () 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

std::vector< Node * > _nodes
 
std::vector< Elem * > _elements
 
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 std::vector< Elem * >::iterator elem_iterator_imp
 
typedef std::vector< Elem * >::const_iterator const_elem_iterator_imp
 
typedef std::vector< Node * >::iterator node_iterator_imp
 
typedef std::vector< Node * >::const_iterator const_node_iterator_imp
 

Private Member Functions

void stitching_helper (const ReplicatedMesh *other_mesh, boundary_id_type boundary_id_1, boundary_id_type boundary_id_2, Real tol, bool clear_stitched_boundary_ids, bool verbose, bool use_binary_search, bool enforce_all_nodes_match_on_boundaries, bool skip_find_neighbors)
 

Detailed Description

Mesh data structure replicated on all processors.

The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of a full mesh data structure on each processor.

Most methods for this class are found in MeshBase, and most implementation details are found in UnstructuredMesh.

Author
Roy Stogner
Date
2007

Definition at line 46 of file replicated_mesh.h.

Member Typedef Documentation

◆ const_elem_iterator_imp

typedef std::vector<Elem *>::const_iterator libMesh::ReplicatedMesh::const_elem_iterator_imp
private

Definition at line 497 of file replicated_mesh.h.

◆ const_node_iterator_imp

typedef std::vector<Node *>::const_iterator libMesh::ReplicatedMesh::const_node_iterator_imp
private

Definition at line 504 of file replicated_mesh.h.

◆ elem_iterator_imp

typedef std::vector<Elem *>::iterator libMesh::ReplicatedMesh::elem_iterator_imp
private

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

Definition at line 496 of file replicated_mesh.h.

◆ node_iterator_imp

typedef std::vector<Node *>::iterator libMesh::ReplicatedMesh::node_iterator_imp
private

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

Definition at line 503 of file replicated_mesh.h.

◆ Predicate

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

Definition at line 931 of file mesh_base.h.

Constructor & Destructor Documentation

◆ ReplicatedMesh() [1/4]

libMesh::ReplicatedMesh::ReplicatedMesh ( 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 119 of file replicated_mesh.C.

References libMesh::MeshBase::_next_unique_id, and libMesh::MeshBase::_partitioner.

120  :
121  UnstructuredMesh (comm_in,d)
122 {
123 #ifdef LIBMESH_ENABLE_UNIQUE_ID
124  // In serial we just need to reset the next unique id to zero
125  // here in the constructor.
126  _next_unique_id = 0;
127 #endif
128  _partitioner = libmesh_make_unique<MetisPartitioner>();
129 }
unique_id_type _next_unique_id
Definition: mesh_base.h:1418
std::unique_ptr< Partitioner > _partitioner
Definition: mesh_base.h:1412
UnstructuredMesh(const Parallel::Communicator &comm_in, unsigned char dim=1)

◆ ReplicatedMesh() [2/4]

libMesh::ReplicatedMesh::ReplicatedMesh ( const UnstructuredMesh other_mesh)

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

Definition at line 153 of file replicated_mesh.C.

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

153  :
154  UnstructuredMesh (other_mesh)
155 {
156  this->copy_nodes_and_elements(other_mesh);
157  this->get_boundary_info() = other_mesh.get_boundary_info();
158 }
virtual void copy_nodes_and_elements(const UnstructuredMesh &other_mesh, const bool skip_find_neighbors=false, dof_id_type element_id_offset=0, dof_id_type node_id_offset=0, unique_id_type unique_id_offset=0)
const BoundaryInfo & get_boundary_info() const
Definition: mesh_base.h:131
UnstructuredMesh(const Parallel::Communicator &comm_in, unsigned char dim=1)

◆ ReplicatedMesh() [3/4]

libMesh::ReplicatedMesh::ReplicatedMesh ( const ReplicatedMesh other_mesh)

Copy-constructor, possibly specialized for a serial mesh.

Definition at line 142 of file replicated_mesh.C.

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

142  :
143  UnstructuredMesh (other_mesh)
144 {
145  this->copy_nodes_and_elements(other_mesh);
146  this->get_boundary_info() = other_mesh.get_boundary_info();
147 #ifdef LIBMESH_ENABLE_UNIQUE_ID
148  this->_next_unique_id = other_mesh._next_unique_id;
149 #endif
150 }
virtual void copy_nodes_and_elements(const UnstructuredMesh &other_mesh, const bool skip_find_neighbors=false, dof_id_type element_id_offset=0, dof_id_type node_id_offset=0, unique_id_type unique_id_offset=0)
const BoundaryInfo & get_boundary_info() const
Definition: mesh_base.h:131
unique_id_type _next_unique_id
Definition: mesh_base.h:1418
UnstructuredMesh(const Parallel::Communicator &comm_in, unsigned char dim=1)

◆ ReplicatedMesh() [4/4]

libMesh::ReplicatedMesh::ReplicatedMesh ( ReplicatedMesh &&  )
default

Move-constructor.

◆ ~ReplicatedMesh()

libMesh::ReplicatedMesh::~ReplicatedMesh ( )
virtual

Destructor.

Definition at line 133 of file replicated_mesh.C.

References clear().

134 {
135  this->clear(); // Free nodes and elements
136 }
virtual void clear() override

Member Function Documentation

◆ active_element_ptr_range() [1/2]

virtual SimpleRange<element_iterator> libMesh::ReplicatedMesh::active_element_ptr_range ( )
inlineoverridevirtual

Implements libMesh::MeshBase.

Definition at line 246 of file replicated_mesh.h.

References active_elements_begin(), and active_elements_end().

virtual element_iterator active_elements_end() override
virtual element_iterator active_elements_begin() override

◆ active_element_ptr_range() [2/2]

virtual SimpleRange<const_element_iterator> libMesh::ReplicatedMesh::active_element_ptr_range ( ) const
inlineoverridevirtual

Implements libMesh::MeshBase.

Definition at line 247 of file replicated_mesh.h.

References active_elements_begin(), and active_elements_end().

virtual element_iterator active_elements_end() override
virtual element_iterator active_elements_begin() override

◆ active_elements_begin() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::active_elements_begin ( )
overridevirtual

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(), n_active_elem(), and stitching_helper().

◆ active_elements_begin() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::active_elements_begin ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ active_elements_end() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::active_elements_end ( )
overridevirtual

◆ active_elements_end() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::active_elements_end ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ active_local_element_ptr_range() [1/2]

virtual SimpleRange<element_iterator> libMesh::ReplicatedMesh::active_local_element_ptr_range ( )
inlineoverridevirtual

Implements libMesh::MeshBase.

Definition at line 303 of file replicated_mesh.h.

References active_local_elements_begin(), and active_local_elements_end().

virtual element_iterator active_local_elements_begin() override
virtual element_iterator active_local_elements_end() override

◆ active_local_element_ptr_range() [2/2]

virtual SimpleRange<const_element_iterator> libMesh::ReplicatedMesh::active_local_element_ptr_range ( ) const
inlineoverridevirtual

Implements libMesh::MeshBase.

Definition at line 304 of file replicated_mesh.h.

References active_local_elements_begin(), and active_local_elements_end().

virtual element_iterator active_local_elements_begin() override
virtual element_iterator active_local_elements_end() override

◆ active_local_elements_begin() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::active_local_elements_begin ( )
overridevirtual

◆ active_local_elements_begin() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::active_local_elements_begin ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ active_local_elements_end() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::active_local_elements_end ( )
overridevirtual

◆ active_local_elements_end() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::active_local_elements_end ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ active_local_subdomain_elements_begin() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::active_local_subdomain_elements_begin ( subdomain_id_type  subdomain_id)
overridevirtual

Implements libMesh::MeshBase.

◆ active_local_subdomain_elements_begin() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::active_local_subdomain_elements_begin ( subdomain_id_type  subdomain_id) const
overridevirtual

Implements libMesh::MeshBase.

◆ active_local_subdomain_elements_end() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::active_local_subdomain_elements_end ( subdomain_id_type  subdomain_id)
overridevirtual

Implements libMesh::MeshBase.

◆ active_local_subdomain_elements_end() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::active_local_subdomain_elements_end ( subdomain_id_type  subdomain_id) const
overridevirtual

Implements libMesh::MeshBase.

◆ active_nodes_begin() [1/2]

virtual node_iterator libMesh::ReplicatedMesh::active_nodes_begin ( )
overridevirtual

Iterate over only the active nodes in the Mesh.

Implements libMesh::MeshBase.

◆ active_nodes_begin() [2/2]

virtual const_node_iterator libMesh::ReplicatedMesh::active_nodes_begin ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ active_nodes_end() [1/2]

virtual node_iterator libMesh::ReplicatedMesh::active_nodes_end ( )
overridevirtual

Implements libMesh::MeshBase.

◆ active_nodes_end() [2/2]

virtual const_node_iterator libMesh::ReplicatedMesh::active_nodes_end ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ active_not_local_elements_begin() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::active_not_local_elements_begin ( )
overridevirtual

Implements libMesh::MeshBase.

◆ active_not_local_elements_begin() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::active_not_local_elements_begin ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ active_not_local_elements_end() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::active_not_local_elements_end ( )
overridevirtual

Implements libMesh::MeshBase.

◆ active_not_local_elements_end() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::active_not_local_elements_end ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ active_pid_elements_begin() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::active_pid_elements_begin ( processor_id_type  proc_id)
overridevirtual

Implements libMesh::MeshBase.

◆ active_pid_elements_begin() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::active_pid_elements_begin ( processor_id_type  proc_id) const
overridevirtual

Implements libMesh::MeshBase.

◆ active_pid_elements_end() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::active_pid_elements_end ( processor_id_type  proc_id)
overridevirtual

Implements libMesh::MeshBase.

◆ active_pid_elements_end() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::active_pid_elements_end ( processor_id_type  proc_id) const
overridevirtual

Implements libMesh::MeshBase.

◆ active_semilocal_elements_begin() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::active_semilocal_elements_begin ( )
overridevirtual

Implements libMesh::MeshBase.

◆ active_semilocal_elements_begin() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::active_semilocal_elements_begin ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ active_semilocal_elements_end() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::active_semilocal_elements_end ( )
overridevirtual

Implements libMesh::MeshBase.

◆ active_semilocal_elements_end() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::active_semilocal_elements_end ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ active_subdomain_elements_begin() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::active_subdomain_elements_begin ( subdomain_id_type  subdomain_id)
overridevirtual

Implements libMesh::MeshBase.

◆ active_subdomain_elements_begin() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::active_subdomain_elements_begin ( subdomain_id_type  subdomain_id) const
overridevirtual

Implements libMesh::MeshBase.

◆ active_subdomain_elements_end() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::active_subdomain_elements_end ( subdomain_id_type  subdomain_id)
overridevirtual

Implements libMesh::MeshBase.

◆ active_subdomain_elements_end() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::active_subdomain_elements_end ( subdomain_id_type  subdomain_id) const
overridevirtual

Implements libMesh::MeshBase.

◆ active_subdomain_set_elements_begin() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::active_subdomain_set_elements_begin ( std::set< subdomain_id_type ss)
overridevirtual

Implements libMesh::MeshBase.

◆ active_subdomain_set_elements_begin() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::active_subdomain_set_elements_begin ( std::set< subdomain_id_type ss) const
overridevirtual

Implements libMesh::MeshBase.

◆ active_subdomain_set_elements_end() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::active_subdomain_set_elements_end ( std::set< subdomain_id_type ss)
overridevirtual

Implements libMesh::MeshBase.

◆ active_subdomain_set_elements_end() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::active_subdomain_set_elements_end ( std::set< subdomain_id_type ss) const
overridevirtual

Implements libMesh::MeshBase.

◆ active_type_elements_begin() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::active_type_elements_begin ( ElemType  type)
overridevirtual

Implements libMesh::MeshBase.

◆ active_type_elements_begin() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::active_type_elements_begin ( ElemType  type) const
overridevirtual

Implements libMesh::MeshBase.

◆ active_type_elements_end() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::active_type_elements_end ( ElemType  type)
overridevirtual

Implements libMesh::MeshBase.

◆ active_type_elements_end() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::active_type_elements_end ( ElemType  type) const
overridevirtual

Implements libMesh::MeshBase.

◆ active_unpartitioned_elements_begin() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::active_unpartitioned_elements_begin ( )
overridevirtual

Iterate over active unpartitioned elements in the Mesh.

Implements libMesh::MeshBase.

◆ active_unpartitioned_elements_begin() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::active_unpartitioned_elements_begin ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ active_unpartitioned_elements_end() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::active_unpartitioned_elements_end ( )
overridevirtual

Implements libMesh::MeshBase.

◆ active_unpartitioned_elements_end() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::active_unpartitioned_elements_end ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ add_elem()

Elem * libMesh::ReplicatedMesh::add_elem ( Elem e)
overridevirtual

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 269 of file replicated_mesh.C.

References _elements, libMesh::MeshBase::_next_unique_id, libMesh::DofObject::id(), libMesh::DofObject::set_id(), libMesh::DofObject::set_unique_id(), libMesh::DofObject::valid_id(), and libMesh::DofObject::valid_unique_id().

270 {
271  libmesh_assert(e);
272 
273  // We no longer merely append elements with ReplicatedMesh
274 
275  // If the user requests a valid id that doesn't correspond to an
276  // existing element, let's give them that id, resizing the elements
277  // container if necessary.
278  if (!e->valid_id())
279  e->set_id (cast_int<dof_id_type>(_elements.size()));
280 
281 #ifdef LIBMESH_ENABLE_UNIQUE_ID
282  if (!e->valid_unique_id())
284 #endif
285 
286  const dof_id_type id = e->id();
287 
288  if (id < _elements.size())
289  {
290  // Overwriting existing elements is still probably a mistake.
291  libmesh_assert(!_elements[id]);
292  }
293  else
294  {
295  _elements.resize(id+1, nullptr);
296  }
297 
298  _elements[id] = e;
299 
300  return e;
301 }
unique_id_type & set_unique_id()
Definition: dof_object.h:685
std::vector< Elem * > _elements
dof_id_type & set_id()
Definition: dof_object.h:664
unique_id_type _next_unique_id
Definition: mesh_base.h:1418
dof_id_type id() const
Definition: dof_object.h:655
bool valid_unique_id() const
Definition: dof_object.h:705
bool valid_id() const
Definition: dof_object.h:697
uint8_t dof_id_type
Definition: id_types.h:64

◆ add_ghosting_functor()

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

References libMesh::MeshBase::_ghosting_functors.

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

824  { _ghosting_functors.insert(&ghosting_functor); }
std::set< GhostingFunctor * > _ghosting_functors
Definition: mesh_base.h:1475

◆ add_node()

Node * libMesh::ReplicatedMesh::add_node ( Node n)
overridevirtual

Add Node n to the end of the vertex array.

Implements libMesh::MeshBase.

Definition at line 439 of file replicated_mesh.C.

References libMesh::MeshBase::_next_unique_id, _nodes, libMesh::DofObject::id(), libMesh::DofObject::set_id(), libMesh::DofObject::set_unique_id(), libMesh::DofObject::valid_id(), and libMesh::DofObject::valid_unique_id().

440 {
441  libmesh_assert(n);
442  // We only append points with ReplicatedMesh
443  libmesh_assert(!n->valid_id() || n->id() == _nodes.size());
444 
445  n->set_id (cast_int<dof_id_type>(_nodes.size()));
446 
447 #ifdef LIBMESH_ENABLE_UNIQUE_ID
448  if (!n->valid_unique_id())
450 #endif
451 
452  _nodes.push_back(n);
453 
454  return n;
455 }
unique_id_type & set_unique_id()
Definition: dof_object.h:685
dof_id_type & set_id()
Definition: dof_object.h:664
unique_id_type _next_unique_id
Definition: mesh_base.h:1418
dof_id_type id() const
Definition: dof_object.h:655
std::vector< Node * > _nodes
bool valid_unique_id() const
Definition: dof_object.h:705
bool valid_id() const
Definition: dof_object.h:697

◆ add_point()

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

functions for adding /deleting nodes elements.

Implements libMesh::MeshBase.

Definition at line 386 of file replicated_mesh.C.

References libMesh::MeshBase::_next_unique_id, _nodes, libMesh::Node::build(), libMesh::DofObject::invalid_id, libMesh::DofObject::processor_id(), libMesh::DofObject::set_unique_id(), and libMesh::DofObject::valid_unique_id().

389 {
390  // // We only append points with ReplicatedMesh
391  // libmesh_assert(id == DofObject::invalid_id || id == _nodes.size());
392  // Node *n = Node::build(p, _nodes.size()).release();
393  // n->processor_id() = proc_id;
394  // _nodes.push_back (n);
395 
396  Node * n = nullptr;
397 
398  // If the user requests a valid id, either
399  // provide the existing node or resize the container
400  // to fit the new node.
401  if (id != DofObject::invalid_id)
402  if (id < _nodes.size())
403  n = _nodes[id];
404  else
405  _nodes.resize(id+1);
406  else
407  _nodes.push_back (static_cast<Node *>(nullptr));
408 
409  // if the node already exists, then assign new (x,y,z) values
410  if (n)
411  *n = p;
412  // otherwise build a new node, put it in the right spot, and return
413  // a valid pointer.
414  else
415  {
416  n = Node::build(p, (id == DofObject::invalid_id) ?
417  cast_int<dof_id_type>(_nodes.size()-1) : id).release();
418  n->processor_id() = proc_id;
419 
420 #ifdef LIBMESH_ENABLE_UNIQUE_ID
421  if (!n->valid_unique_id())
423 #endif
424 
425  if (id == DofObject::invalid_id)
426  _nodes.back() = n;
427  else
428  _nodes[id] = n;
429  }
430 
431  // better not pass back a nullptr.
432  libmesh_assert (n);
433 
434  return n;
435 }
unique_id_type & set_unique_id()
Definition: dof_object.h:685
A geometric point in (x,y,z) space associated with a DOF.
Definition: node.h:52
unique_id_type _next_unique_id
Definition: mesh_base.h:1418
static const dof_id_type invalid_id
Definition: dof_object.h:347
std::vector< Node * > _nodes
bool valid_unique_id() const
Definition: dof_object.h:705
static std::unique_ptr< Node > build(const Node &n)
Definition: node.h:304
processor_id_type processor_id() const
Definition: dof_object.h:717

◆ all_first_order()

void libMesh::UnstructuredMesh::all_first_order ( )
overridevirtualinherited

Converts a mesh with higher-order elements into a mesh with linear elements. For example, a mesh consisting of Tet10 will be converted to a mesh with Tet4 etc.

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

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

Implements libMesh::MeshBase.

Definition at line 832 of file unstructured_mesh.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::element_ptr_range(), libMesh::Elem::first_order_equivalent_type(), libMesh::MeshBase::get_boundary_info(), libMesh::DofObject::id(), libMesh::MeshBase::insert_elem(), libMesh::MeshBase::max_node_id(), libMesh::Elem::n_vertices(), libMesh::MeshBase::node(), libMesh::Elem::node_id(), libMesh::MeshBase::node_ptr_range(), libMesh::Elem::parent(), libMesh::MeshBase::prepare_for_use(), libMesh::DofObject::processor_id(), libMesh::BoundaryInfo::regenerate_id_sets(), libMesh::remote_elem, libMesh::MeshBase::renumber_nodes_and_elements(), libMesh::Elem::replace_child(), libMesh::DofObject::set_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(), and libMesh::Elem::subdomain_id().

833 {
834  /*
835  * when the mesh is not prepared,
836  * at least renumber the nodes and
837  * elements, so that the node ids
838  * are correct
839  */
840  if (!this->_is_prepared)
842 
843  START_LOG("all_first_order()", "Mesh");
844 
848  std::vector<bool> node_touched_by_me(this->max_node_id(), false);
849 
850  // Loop over the high-ordered elements.
851  // First make sure they _are_ indeed high-order, and then replace
852  // them with an equivalent first-order element.
853  for (auto & so_elem : element_ptr_range())
854  {
855  libmesh_assert(so_elem);
856 
857  /*
858  * build the first-order equivalent, add to
859  * the new_elements list.
860  */
861  Elem * lo_elem = Elem::build
863  (so_elem->type()), so_elem->parent()).release();
864 
865  const unsigned short n_sides = so_elem->n_sides();
866 
867  for (unsigned short s=0; s != n_sides; ++s)
868  if (so_elem->neighbor_ptr(s) == remote_elem)
869  lo_elem->set_neighbor(s, const_cast<RemoteElem *>(remote_elem));
870 
871 #ifdef LIBMESH_ENABLE_AMR
872  /*
873  * Reset the parent links of any child elements
874  */
875  if (so_elem->has_children())
876  for (unsigned int c = 0, nc = so_elem->n_children(); c != nc; ++c)
877  {
878  Elem * child = so_elem->child_ptr(c);
879  child->set_parent(lo_elem);
880  lo_elem->add_child(child, c);
881  }
882 
883  /*
884  * Reset the child link of any parent element
885  */
886  if (so_elem->parent())
887  {
888  unsigned int c =
889  so_elem->parent()->which_child_am_i(so_elem);
890  lo_elem->parent()->replace_child(lo_elem, c);
891  }
892 
893  /*
894  * Copy as much data to the new element as makes sense
895  */
896  lo_elem->set_p_level(so_elem->p_level());
897  lo_elem->set_refinement_flag(so_elem->refinement_flag());
898  lo_elem->set_p_refinement_flag(so_elem->p_refinement_flag());
899 #endif
900 
901  libmesh_assert_equal_to (lo_elem->n_vertices(), so_elem->n_vertices());
902 
903  /*
904  * By definition the vertices of the linear and
905  * second order element are identically numbered.
906  * transfer these.
907  */
908  for (unsigned int v=0; v < so_elem->n_vertices(); v++)
909  {
910  lo_elem->set_node(v) = so_elem->node_ptr(v);
911  node_touched_by_me[lo_elem->node_id(v)] = true;
912  }
913 
914  /*
915  * find_neighbors relies on remote_elem neighbor links being
916  * properly maintained.
917  */
918  for (unsigned short s=0; s != n_sides; s++)
919  {
920  if (so_elem->neighbor_ptr(s) == remote_elem)
921  lo_elem->set_neighbor(s, const_cast<RemoteElem*>(remote_elem));
922  }
923 
931  (this->get_boundary_info(), so_elem, lo_elem);
932 
933  /*
934  * The new first-order element is ready.
935  * Inserting it into the mesh will replace and delete
936  * the second-order element.
937  */
938  lo_elem->set_id(so_elem->id());
939 #ifdef LIBMESH_ENABLE_UNIQUE_ID
940  lo_elem->set_unique_id() = so_elem->unique_id();
941 #endif
942  lo_elem->processor_id() = so_elem->processor_id();
943  lo_elem->subdomain_id() = so_elem->subdomain_id();
944  this->insert_elem(lo_elem);
945  }
946 
947  // Deleting nodes does not invalidate iterators, so this is safe.
948  for (const auto & node : this->node_ptr_range())
949  if (!node_touched_by_me[node->id()])
950  this->delete_node(node);
951 
952  // If crazy people applied boundary info to non-vertices and then
953  // deleted those non-vertices, we should make sure their boundary id
954  // caches are correct.
956 
957  STOP_LOG("all_first_order()", "Mesh");
958 
959  // On hanging nodes that used to also be second order nodes, we
960  // might now have an invalid nodal processor_id()
962 
963  // delete or renumber nodes if desired
964  this->prepare_for_use();
965 }
static void set_node_processor_ids(MeshBase &mesh)
Definition: partitioner.C:679
const BoundaryInfo & get_boundary_info() const
Definition: mesh_base.h:131
virtual SimpleRange< element_iterator > element_ptr_range()=0
dof_id_type id() const
Definition: dof_object.h:655
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
Definition: elem.C:245
virtual SimpleRange< node_iterator > node_ptr_range()=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:152
virtual const Node & node(const dof_id_type i) const
Definition: mesh_base.h:454
virtual Elem * insert_elem(Elem *e)=0
void copy_boundary_ids(const BoundaryInfo &old_boundary_info, const Elem *const old_elem, const Elem *const new_elem)
virtual dof_id_type max_node_id() const =0
static ElemType first_order_equivalent_type(const ElemType et)
Definition: elem.C:2584
virtual void renumber_nodes_and_elements()=0
const RemoteElem * remote_elem
Definition: remote_elem.C:57

◆ all_second_order()

void libMesh::UnstructuredMesh::all_second_order ( const bool  full_ordered = true)
overridevirtualinherited

Converts a (conforming, non-refined) mesh with linear elements into a mesh with second-order elements. For example, a mesh consisting of Tet4 will be converted to a mesh with Tet10 etc.

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

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 969 of file unstructured_mesh.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_replicated(), libMesh::MeshBase::is_serial(), libMesh::Elem::level(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::Parallel::Communicator::max(), libMesh::MeshBase::mesh_dimension(), std::min(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::Elem::n_vertices(), libMesh::Elem::neighbor_ptr(), libMesh::Elem::node_ptr(), libMesh::MeshBase::own_node(), libMesh::MeshBase::point(), libMesh::MeshBase::prepare_for_use(), libMesh::ParallelObject::processor_id(), 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().

970 {
971  // This function must be run on all processors at once
972  parallel_object_only();
973 
974  /*
975  * when the mesh is not prepared,
976  * at least renumber the nodes and
977  * elements, so that the node ids
978  * are correct
979  */
980  if (!this->_is_prepared)
982 
983  /*
984  * If the mesh is empty
985  * then we have nothing to do
986  */
987  if (!this->n_elem())
988  return;
989 
990  /*
991  * If the mesh is already second order
992  * then we have nothing to do.
993  * We have to test for this in a round-about way to avoid
994  * a bug on distributed parallel meshes with more processors
995  * than elements.
996  */
997  bool already_second_order = false;
998  if (this->elements_begin() != this->elements_end() &&
999  (*(this->elements_begin()))->default_order() != FIRST)
1000  already_second_order = true;
1001  this->comm().max(already_second_order);
1002  if (already_second_order)
1003  return;
1004 
1005  START_LOG("all_second_order()", "Mesh");
1006 
1007  /*
1008  * this map helps in identifying second order
1009  * nodes. Namely, a second-order node:
1010  * - edge node
1011  * - face node
1012  * - bubble node
1013  * is uniquely defined through a set of adjacent
1014  * vertices. This set of adjacent vertices is
1015  * used to identify already added higher-order
1016  * nodes. We are safe to use node id's since we
1017  * make sure that these are correctly numbered.
1018  */
1019  std::map<std::vector<dof_id_type>, Node *> adj_vertices_to_so_nodes;
1020 
1021  /*
1022  * for speed-up of the \p add_point() method, we
1023  * can reserve memory. Guess the number of additional
1024  * nodes for different dimensions
1025  */
1026  switch (this->mesh_dimension())
1027  {
1028  case 1:
1029  /*
1030  * in 1D, there can only be order-increase from Edge2
1031  * to Edge3. Something like 1/2 of n_nodes() have
1032  * to be added
1033  */
1034  this->reserve_nodes(static_cast<unsigned int>
1035  (1.5*static_cast<double>(this->n_nodes())));
1036  break;
1037 
1038  case 2:
1039  /*
1040  * in 2D, either refine from Tri3 to Tri6 (double the nodes)
1041  * or from Quad4 to Quad8 (again, double) or Quad9 (2.25 that much)
1042  */
1043  this->reserve_nodes(static_cast<unsigned int>
1044  (2*static_cast<double>(this->n_nodes())));
1045  break;
1046 
1047 
1048  case 3:
1049  /*
1050  * in 3D, either refine from Tet4 to Tet10 (factor = 2.5) up to
1051  * Hex8 to Hex27 (something > 3). Since in 3D there _are_ already
1052  * quite some nodes, and since we do not want to overburden the memory by
1053  * a too conservative guess, use the lower bound
1054  */
1055  this->reserve_nodes(static_cast<unsigned int>
1056  (2.5*static_cast<double>(this->n_nodes())));
1057  break;
1058 
1059  default:
1060  // Hm?
1061  libmesh_error_msg("Unknown mesh dimension " << this->mesh_dimension());
1062  }
1063 
1064 
1065 
1066  /*
1067  * form a vector that will hold the node id's of
1068  * the vertices that are adjacent to the son-th
1069  * second-order node. Pull this outside of the
1070  * loop so that silly compilers don't repeatedly
1071  * create and destroy the vector.
1072  */
1073  std::vector<dof_id_type> adjacent_vertices_ids;
1074 
1081  element_iterator
1082  it = elements_begin(),
1083  endit = elements_end();
1084 
1085  for (; it != endit; ++it)
1086  {
1087  // the linear-order element
1088  Elem * lo_elem = *it;
1089 
1090  libmesh_assert(lo_elem);
1091 
1092  // make sure it is linear order
1093  if (lo_elem->default_order() != FIRST)
1094  libmesh_error_msg("ERROR: This is not a linear element: type=" << lo_elem->type());
1095 
1096  // this does _not_ work for refined elements
1097  libmesh_assert_equal_to (lo_elem->level (), 0);
1098 
1099  /*
1100  * build the second-order equivalent, add to
1101  * the new_elements list. Note that this here
1102  * is the only point where \p full_ordered
1103  * is necessary. The remaining code works well
1104  * for either type of second-order equivalent, e.g.
1105  * Hex20 or Hex27, as equivalents for Hex8
1106  */
1107  Elem * so_elem =
1109  full_ordered) ).release();
1110 
1111  libmesh_assert_equal_to (lo_elem->n_vertices(), so_elem->n_vertices());
1112 
1113 
1114  /*
1115  * By definition the vertices of the linear and
1116  * second order element are identically numbered.
1117  * transfer these.
1118  */
1119  for (unsigned int v=0; v < lo_elem->n_vertices(); v++)
1120  so_elem->set_node(v) = lo_elem->node_ptr(v);
1121 
1122  /*
1123  * Now handle the additional mid-side nodes. This
1124  * is simply handled through a map that remembers
1125  * the already-added nodes. This map maps the global
1126  * ids of the vertices (that uniquely define this
1127  * higher-order node) to the new node.
1128  * Notation: son = second-order node
1129  */
1130  const unsigned int son_begin = so_elem->n_vertices();
1131  const unsigned int son_end = so_elem->n_nodes();
1132 
1133 
1134  for (unsigned int son=son_begin; son<son_end; son++)
1135  {
1136  const unsigned int n_adjacent_vertices =
1137  so_elem->n_second_order_adjacent_vertices(son);
1138 
1139  adjacent_vertices_ids.resize(n_adjacent_vertices);
1140 
1141  for (unsigned int v=0; v<n_adjacent_vertices; v++)
1142  adjacent_vertices_ids[v] =
1143  so_elem->node_id( so_elem->second_order_adjacent_vertex(son,v) );
1144 
1145  /*
1146  * \p adjacent_vertices_ids is now in order of the current
1147  * side. sort it, so that comparisons with the
1148  * \p adjacent_vertices_ids created through other elements'
1149  * sides can match
1150  */
1151  std::sort(adjacent_vertices_ids.begin(),
1152  adjacent_vertices_ids.end());
1153 
1154 
1155  // does this set of vertices already have a mid-node added?
1156  auto pos = adj_vertices_to_so_nodes.equal_range (adjacent_vertices_ids);
1157 
1158  // no, not added yet
1159  if (pos.first == pos.second)
1160  {
1161  /*
1162  * for this set of vertices, there is no
1163  * second_order node yet. Add it.
1164  *
1165  * compute the location of the new node as
1166  * the average over the adjacent vertices.
1167  */
1168  Point new_location = this->point(adjacent_vertices_ids[0]);
1169  for (unsigned int v=1; v<n_adjacent_vertices; v++)
1170  new_location += this->point(adjacent_vertices_ids[v]);
1171 
1172  new_location /= static_cast<Real>(n_adjacent_vertices);
1173 
1174  /* Add the new point to the mesh.
1175  * If we are on a serialized mesh, then we're doing this
1176  * all in sync, and the node processor_id will be
1177  * consistent between processors.
1178  * If we are on a distributed mesh, we can fix
1179  * inconsistent processor ids later, but only if every
1180  * processor gives new nodes a *locally* consistent
1181  * processor id, so we'll give the new node the
1182  * processor id of an adjacent element for now and then
1183  * we'll update that later if appropriate.
1184  */
1185  Node * so_node = this->add_point
1186  (new_location, DofObject::invalid_id,
1187  lo_elem->processor_id());
1188 
1189  /*
1190  * insert the new node with its defining vertex
1191  * set into the map, and relocate pos to this
1192  * new entry, so that the so_elem can use
1193  * \p pos for inserting the node
1194  */
1195  adj_vertices_to_so_nodes.insert(pos.first,
1196  std::make_pair(adjacent_vertices_ids,
1197  so_node));
1198 
1199  so_elem->set_node(son) = so_node;
1200  }
1201  // yes, already added.
1202  else
1203  {
1204  Node * so_node = pos.first->second;
1205  libmesh_assert(so_node);
1206 
1207  so_elem->set_node(son) = so_node;
1208 
1209  // We need to ensure that the processor who should own a
1210  // node *knows* they own the node. And because
1211  // Node::choose_processor_id() may depend on Node id,
1212  // which may not yet be authoritative, we still have to
1213  // use a dumb-but-id-independent partitioning heuristic.
1214  processor_id_type chosen_pid =
1215  std::min (so_node->processor_id(),
1216  lo_elem->processor_id());
1217 
1218  // Plus, if we just discovered that we own this node,
1219  // then on a distributed mesh we need to make sure to
1220  // give it a valid id, not just a placeholder id!
1221  if (!this->is_replicated() &&
1222  so_node->processor_id() != this->processor_id() &&
1223  chosen_pid == this->processor_id())
1224  this->own_node(*so_node);
1225 
1226  so_node->processor_id() = chosen_pid;
1227  }
1228  }
1229 
1230  /*
1231  * find_neighbors relies on remote_elem neighbor links being
1232  * properly maintained.
1233  */
1234  for (auto s : lo_elem->side_index_range())
1235  {
1236  if (lo_elem->neighbor_ptr(s) == remote_elem)
1237  so_elem->set_neighbor(s, const_cast<RemoteElem*>(remote_elem));
1238  }
1239 
1252  (this->get_boundary_info(), lo_elem, so_elem);
1253 
1254  /*
1255  * The new second-order element is ready.
1256  * Inserting it into the mesh will replace and delete
1257  * the first-order element.
1258  */
1259  so_elem->set_id(lo_elem->id());
1260 #ifdef LIBMESH_ENABLE_UNIQUE_ID
1261  so_elem->set_unique_id() = lo_elem->unique_id();
1262 #endif
1263  so_elem->processor_id() = lo_elem->processor_id();
1264  so_elem->subdomain_id() = lo_elem->subdomain_id();
1265  this->insert_elem(so_elem);
1266  }
1267 
1268  // we can clear the map
1269  adj_vertices_to_so_nodes.clear();
1270 
1271 
1272  STOP_LOG("all_second_order()", "Mesh");
1273 
1274  // On a DistributedMesh our ghost node processor ids may be bad,
1275  // the ids of nodes touching remote elements may be inconsistent,
1276  // unique_ids of newly added non-local nodes remain unset, and our
1277  // partitioning of new nodes may not be well balanced.
1278  //
1279  // make_nodes_parallel_consistent() will fix all this.
1280  if (!this->is_serial())
1281  MeshCommunication().make_nodes_parallel_consistent (*this);
1282 
1283  // renumber nodes, elements etc
1284  this->prepare_for_use(/*skip_renumber =*/ false);
1285 }
virtual void reserve_nodes(const dof_id_type nn)=0
uint8_t processor_id_type
Definition: id_types.h:99
const Parallel::Communicator & comm() const
virtual void own_node(Node &)
Definition: mesh_base.h:639
const BoundaryInfo & get_boundary_info() const
Definition: mesh_base.h:131
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 bool is_serial() const
Definition: mesh_base.h:154
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
Definition: elem.C:245
virtual element_iterator elements_end()=0
static const dof_id_type invalid_id
Definition: dof_object.h:347
void prepare_for_use(const bool skip_renumber_nodes_and_elements=false, const bool skip_find_neighbors=false)
Definition: mesh_base.C:152
static ElemType second_order_equivalent_type(const ElemType et, const bool full_ordered=true)
Definition: elem.C:2643
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)
virtual bool is_replicated() const
Definition: mesh_base.h:176
unsigned int mesh_dimension() const
Definition: mesh_base.C:126
virtual const Point & point(const dof_id_type i) const =0
virtual dof_id_type n_elem() const =0
processor_id_type processor_id() const
long double min(long double a, double b)
virtual dof_id_type n_nodes() const =0
virtual void renumber_nodes_and_elements()=0
const RemoteElem * remote_elem
Definition: remote_elem.C:57

◆ allgather()

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

Gathers all elements and nodes of the mesh onto every processor

Reimplemented in libMesh::DistributedMesh.

Definition at line 183 of file mesh_base.h.

Referenced by libMesh::EquationSystems::allgather(), and libMesh::MeshSerializer::MeshSerializer().

183 {}

◆ allow_remote_element_removal() [1/2]

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

If false is passed in then this mesh will no longer have remote elements deleted when being prepared for use; i.e. even a DistributedMesh will remain (if it is already) serialized. This may adversely affect performance and memory use.

Definition at line 791 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:1439

◆ allow_remote_element_removal() [2/2]

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

◆ allow_renumbering() [1/2]

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

If false is passed in then this mesh will no longer be renumbered when being prepared for use. This may slightly adversely affect performance during subsequent element access, particularly when using a distributed mesh.

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

Definition at line 782 of file mesh_base.h.

References libMesh::MeshBase::_skip_renumber_nodes_and_elements.

Referenced by libMesh::UnstructuredMesh::copy_nodes_and_elements(), libMesh::NameBasedIO::read(), and libMesh::GMVIO::read().

bool _skip_renumber_nodes_and_elements
Definition: mesh_base.h:1431

◆ allow_renumbering() [2/2]

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

◆ ancestor_elements_begin() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::ancestor_elements_begin ( )
overridevirtual

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

Implements libMesh::MeshBase.

◆ ancestor_elements_begin() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::ancestor_elements_begin ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ ancestor_elements_end() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::ancestor_elements_end ( )
overridevirtual

Implements libMesh::MeshBase.

◆ ancestor_elements_end() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::ancestor_elements_end ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ bid_nodes_begin() [1/2]

virtual node_iterator libMesh::ReplicatedMesh::bid_nodes_begin ( boundary_id_type  bndry_id)
overridevirtual

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

Implements libMesh::MeshBase.

◆ bid_nodes_begin() [2/2]

virtual const_node_iterator libMesh::ReplicatedMesh::bid_nodes_begin ( boundary_id_type  bndry_id) const
overridevirtual

Implements libMesh::MeshBase.

◆ bid_nodes_end() [1/2]

virtual node_iterator libMesh::ReplicatedMesh::bid_nodes_end ( boundary_id_type  bndry_id)
overridevirtual

Implements libMesh::MeshBase.

◆ bid_nodes_end() [2/2]

virtual const_node_iterator libMesh::ReplicatedMesh::bid_nodes_end ( boundary_id_type  bndry_id) const
overridevirtual

Implements libMesh::MeshBase.

◆ bnd_nodes_begin() [1/2]

virtual node_iterator libMesh::ReplicatedMesh::bnd_nodes_begin ( )
overridevirtual

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

Implements libMesh::MeshBase.

◆ bnd_nodes_begin() [2/2]

virtual const_node_iterator libMesh::ReplicatedMesh::bnd_nodes_begin ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ bnd_nodes_end() [1/2]

virtual node_iterator libMesh::ReplicatedMesh::bnd_nodes_end ( )
overridevirtual

Implements libMesh::MeshBase.

◆ bnd_nodes_end() [2/2]

virtual const_node_iterator libMesh::ReplicatedMesh::bnd_nodes_end ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ cache_elem_dims()

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

References libMesh::MeshBase::_elem_dims, libMesh::MeshBase::_spatial_dimension, libMesh::MeshBase::active_element_ptr_range(), libMesh::ParallelObject::comm(), libMesh::Elem::dim(), libMesh::MeshBase::elem(), libMesh::MeshBase::mesh_dimension(), libMesh::MeshBase::node(), libMesh::MeshBase::node_ptr_range(), and libMesh::Parallel::Communicator::set_union().

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

575 {
576  // This requires an inspection on every processor
577  parallel_object_only();
578 
579  // Need to clear _elem_dims first in case all elements of a
580  // particular dimension have been deleted.
581  _elem_dims.clear();
582 
583  for (const auto & elem : this->active_element_ptr_range())
584  _elem_dims.insert(cast_int<unsigned char>(elem->dim()));
585 
586  // Some different dimension elements may only live on other processors
587  this->comm().set_union(_elem_dims);
588 
589  // If the largest element dimension found is larger than the current
590  // _spatial_dimension, increase _spatial_dimension.
591  unsigned int max_dim = this->mesh_dimension();
592  if (max_dim > _spatial_dimension)
593  _spatial_dimension = cast_int<unsigned char>(max_dim);
594 
595  // _spatial_dimension may need to increase from 1->2 or 2->3 if the
596  // mesh is full of 1D elements but they are not x-aligned, or the
597  // mesh is full of 2D elements but they are not in the x-y plane.
598  // If the mesh is x-aligned or x-y planar, we will end up checking
599  // every node's coordinates and not breaking out of the loop
600  // early...
601  if (_spatial_dimension < 3)
602  {
603  for (const auto & node : this->node_ptr_range())
604  {
605 #if LIBMESH_DIM > 1
606  // Note: the exact floating point comparison is intentional,
607  // we don't want to get tripped up by tolerances.
608  if ((*node)(1) != 0.)
609  {
610  _spatial_dimension = 2;
611 #if LIBMESH_DIM == 2
612  // If libmesh is compiled in 2D mode, this is the
613  // largest spatial dimension possible so we can break
614  // out.
615  break;
616 #endif
617  }
618 #endif
619 
620 #if LIBMESH_DIM > 2
621  if ((*node)(2) != 0.)
622  {
623  // Spatial dimension can't get any higher than this, so
624  // we can break out.
625  _spatial_dimension = 3;
626  break;
627  }
628 #endif
629  }
630  }
631 }
void set_union(T &data, const unsigned int root_id) const
virtual const Elem * elem(const dof_id_type i) const
Definition: mesh_base.h:537
const Parallel::Communicator & comm() const
virtual SimpleRange< element_iterator > active_element_ptr_range()=0
unsigned char _spatial_dimension
Definition: mesh_base.h:1459
virtual SimpleRange< node_iterator > node_ptr_range()=0
std::set< unsigned char > _elem_dims
Definition: mesh_base.h:1453
virtual const Node & node(const dof_id_type i) const
Definition: mesh_base.h:454
virtual unsigned short dim() const =0
unsigned int mesh_dimension() const
Definition: mesh_base.C:126

◆ clear()

void libMesh::ReplicatedMesh::clear ( )
overridevirtual

Clear all internal data.

Reimplemented from libMesh::MeshBase.

Definition at line 556 of file replicated_mesh.C.

References _elements, _nodes, libMesh::MeshBase::clear(), libMesh::MeshBase::elem(), and libMesh::MeshBase::node().

Referenced by ~ReplicatedMesh().

557 {
558  // Call parent clear function
559  MeshBase::clear();
560 
561  // Clear our elements and nodes
562  // There is no need to remove the elements from
563  // the BoundaryInfo data structure since we
564  // already cleared it.
565  for (auto & elem : _elements)
566  delete elem;
567 
568  _elements.clear();
569 
570  // clear the nodes data structure
571  // There is no need to remove the nodes from
572  // the BoundaryInfo data structure since we
573  // already cleared it.
574  for (auto & node : _nodes)
575  delete node;
576 
577  _nodes.clear();
578 }
virtual const Elem * elem(const dof_id_type i) const
Definition: mesh_base.h:537
std::vector< Elem * > _elements
std::vector< Node * > _nodes
virtual void clear()
Definition: mesh_base.C:260
virtual const Node & node(const dof_id_type i) const
Definition: mesh_base.h:454

◆ clear_point_locator()

void libMesh::MeshBase::clear_point_locator ( )
inherited

Releases the current PointLocator object.

Definition at line 517 of file mesh_base.C.

References libMesh::MeshBase::_point_locator.

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

518 {
519  _point_locator.reset(nullptr);
520 }
std::unique_ptr< PointLocatorBase > _point_locator
Definition: mesh_base.h:1398

◆ clone()

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

Virtual copy-constructor, creates a copy of this mesh

Implements libMesh::MeshBase.

Reimplemented in libMesh::SerialMesh.

Definition at line 85 of file replicated_mesh.h.

86  { return libmesh_make_unique<ReplicatedMesh>(*this); }

◆ comm()

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

Definition at line 89 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_tao_equality_constraints(), libMesh::__libmesh_tao_equality_constraints_jacobian(), libMesh::__libmesh_tao_gradient(), libMesh::__libmesh_tao_hessian(), libMesh::__libmesh_tao_inequality_constraints(), libMesh::__libmesh_tao_inequality_constraints_jacobian(), libMesh::__libmesh_tao_objective(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< 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::PetscDMWrapper::add_dofs_helper(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::ImplicitSystem::add_matrix(), libMesh::System::add_vector(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::DofMap::attach_matrix(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_section(), libMesh::PetscDMWrapper::build_sf(), libMesh::MeshBase::cache_elem_dims(), libMesh::System::calculate_norm(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::PetscDMWrapper::check_section_n_dofs(), 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::CondensedEigenSystem::get_eigenpair(), libMesh::DofMap::get_info(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::LocationMap< T >::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::EigenSystem::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_flags(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_p_levels(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshTools::libmesh_assert_valid_unique_ids(), libMesh::libmesh_petsc_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_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::FEMSystem::mesh_position_set(), libMesh::DistributedMesh::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(), libMesh::DistributedMesh::parallel_max_elem_id(), libMesh::DistributedMesh::parallel_max_node_id(), parallel_max_unique_id(), libMesh::DistributedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_n_elem(), libMesh::DistributedMesh::parallel_n_nodes(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::MeshTools::paranoid_n_levels(), libMesh::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::CheckpointIO::select_split_config(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::PetscDiffSolver::setup_petsc_data(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::split_mesh(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::MeshRefinement::test_level_one(), libMesh::MeshRefinement::test_unflagged(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

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

◆ contract()

bool libMesh::UnstructuredMesh::contract ( )
overridevirtualinherited

Delete subactive (i.e. children of coarsened) elements. This removes all elements descended from currently active elements in the mesh.

Implements libMesh::MeshBase.

Definition at line 769 of file unstructured_mesh.C.

References libMesh::Elem::active(), libMesh::Elem::ancestor(), libMesh::as_range(), libMesh::MeshBase::clear_point_locator(), libMesh::Elem::contract(), libMesh::MeshBase::delete_elem(), libMesh::MeshBase::elem(), libMesh::MeshBase::element_ptr_range(), libMesh::MeshBase::ghosting_functors_begin(), libMesh::MeshBase::ghosting_functors_end(), libMesh::Elem::parent(), libMesh::MeshBase::renumber_nodes_and_elements(), and libMesh::Elem::subactive().

770 {
771  LOG_SCOPE ("contract()", "Mesh");
772 
773  // Flag indicating if this call actually changes the mesh
774  bool mesh_changed = false;
775 
776 #ifdef DEBUG
777  for (const auto & elem : this->element_ptr_range())
778  libmesh_assert(elem->active() || elem->subactive() || elem->ancestor());
779 #endif
780 
781  // Loop over the elements.
782  for (auto & elem : this->element_ptr_range())
783  {
784  // Delete all the subactive ones
785  if (elem->subactive())
786  {
787  // No level-0 element should be subactive.
788  // Note that we CAN'T test elem->level(), as that
789  // touches elem->parent()->dim(), and elem->parent()
790  // might have already been deleted!
791  libmesh_assert(elem->parent());
792 
793  // Delete the element
794  // This just sets a pointer to nullptr, and doesn't
795  // invalidate any iterators
796  this->delete_elem(elem);
797 
798  // the mesh has certainly changed
799  mesh_changed = true;
800  }
801  else
802  {
803  // Compress all the active ones
804  if (elem->active())
805  elem->contract();
806  else
807  libmesh_assert (elem->ancestor());
808  }
809  }
810 
811  // Strip any newly-created nullptr voids out of the element array
813 
814  // FIXME: Need to understand why deleting subactive children
815  // invalidates the point locator. For now we will clear it explicitly
816  this->clear_point_locator();
817 
818  // Allow our GhostingFunctor objects to reinit if necessary.
819  for (auto & gf : as_range(this->ghosting_functors_begin(),
820  this->ghosting_functors_end()))
821  {
822  libmesh_assert(gf);
823  gf->mesh_reinit();
824  }
825 
826  return mesh_changed;
827 }
const Elem * parent() const
Definition: elem.h:2479
virtual const Elem * elem(const dof_id_type i) const
Definition: mesh_base.h:537
bool ancestor() const
Definition: elem.C:1427
virtual void delete_elem(Elem *e)=0
virtual SimpleRange< element_iterator > element_ptr_range()=0
void clear_point_locator()
Definition: mesh_base.C:517
SimpleRange< I > as_range(const std::pair< I, I > &p)
Definition: simple_range.h:57
std::set< GhostingFunctor * >::const_iterator ghosting_functors_begin() const
Definition: mesh_base.h:835
bool subactive() const
Definition: elem.h:2408
bool active() const
Definition: elem.h:2390
virtual void renumber_nodes_and_elements()=0
std::set< GhostingFunctor * >::const_iterator ghosting_functors_end() const
Definition: mesh_base.h:841

◆ copy_nodes_and_elements()

void libMesh::UnstructuredMesh::copy_nodes_and_elements ( const UnstructuredMesh other_mesh,
const bool  skip_find_neighbors = false,
dof_id_type  element_id_offset = 0,
dof_id_type  node_id_offset = 0,
unique_id_type  unique_id_offset = 0 
)
virtualinherited

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

Definition at line 61 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::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 libMesh::DistributedMesh::DistributedMesh(), ReplicatedMesh(), and stitching_helper().

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

◆ create_pid_mesh()

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

Generates a new mesh containing all the elements which are assigned to processor pid. This mesh is written to the pid_mesh reference which you must create and pass to the function.

Definition at line 655 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.

657 {
658 
659  // Issue a warning if the number the number of processors
660  // currently available is less that that requested for
661  // partitioning. This is not necessarily an error since
662  // you may run on one processor and still partition the
663  // mesh into several partitions.
664 #ifdef DEBUG
665  if (this->n_processors() < pid)
666  {
667  libMesh::out << "WARNING: You are creating a "
668  << "mesh for a processor id (="
669  << pid
670  << ") greater than "
671  << "the number of processors available for "
672  << "the calculation. (="
673  << this->n_processors()
674  << ")."
675  << std::endl;
676  }
677 #endif
678 
679  this->create_submesh (pid_mesh,
680  this->active_pid_elements_begin(pid),
681  this->active_pid_elements_end(pid));
682 }
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
OStreamProxy out(std::cout)
void create_submesh(UnstructuredMesh &new_mesh, const const_element_iterator &it, const const_element_iterator &it_end) const

◆ create_submesh()

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

Constructs a mesh called "new_mesh" from the current mesh by iterating over the elements between it and it_end and adding them to the new mesh.

Definition at line 690 of file unstructured_mesh.C.

References libMesh::MeshBase::add_elem(), libMesh::MeshBase::add_point(), libMesh::BoundaryInfo::add_side(), libMesh::as_range(), libMesh::BoundaryInfo::boundary_ids(), libMesh::Elem::build(), libMesh::MeshBase::clear(), libMesh::MeshBase::delete_remote_elements(), libMesh::MeshBase::get_boundary_info(), libMesh::MeshBase::is_serial(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::MeshBase::node_ptr(), 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(), and libMesh::Elem::subdomain_id().

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

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

◆ default_ghosting()

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

Default ghosting functor

Definition at line 847 of file mesh_base.h.

References libMesh::MeshBase::_default_ghosting.

847 { return *_default_ghosting; }
std::unique_ptr< GhostingFunctor > _default_ghosting
Definition: mesh_base.h:1466

◆ delete_elem()

void libMesh::ReplicatedMesh::delete_elem ( Elem e)
overridevirtual

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 329 of file replicated_mesh.C.

References _elements, libMesh::MeshBase::get_boundary_info(), libMesh::DofObject::id(), and libMesh::BoundaryInfo::remove().

Referenced by insert_elem().

330 {
331  libmesh_assert(e);
332 
333  // Initialize an iterator to eventually point to the element we want to delete
334  std::vector<Elem *>::iterator pos = _elements.end();
335 
336  // In many cases, e->id() gives us a clue as to where e
337  // is located in the _elements vector. Try that first
338  // before trying the O(n_elem) search.
339  libmesh_assert_less (e->id(), _elements.size());
340 
341  if (_elements[e->id()] == e)
342  {
343  // We found it!
344  pos = _elements.begin();
345  std::advance(pos, e->id());
346  }
347 
348  else
349  {
350  // This search is O(n_elem)
351  pos = std::find (_elements.begin(),
352  _elements.end(),
353  e);
354  }
355 
356  // Huh? Element not in the vector?
357  libmesh_assert (pos != _elements.end());
358 
359  // Remove the element from the BoundaryInfo object
360  this->get_boundary_info().remove(e);
361 
362  // delete the element
363  delete e;
364 
365  // explicitly zero the pointer
366  *pos = nullptr;
367 }
std::vector< Elem * > _elements
void remove(const Node *node)
const BoundaryInfo & get_boundary_info() const
Definition: mesh_base.h:131
dof_id_type id() const
Definition: dof_object.h:655

◆ delete_node()

void libMesh::ReplicatedMesh::delete_node ( Node n)
overridevirtual

Removes the Node n from the mesh.

Implements libMesh::MeshBase.

Definition at line 502 of file replicated_mesh.C.

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

Referenced by stitching_helper().

503 {
504  libmesh_assert(n);
505  libmesh_assert_less (n->id(), _nodes.size());
506 
507  // Initialize an iterator to eventually point to the element we want
508  // to delete
509  std::vector<Node *>::iterator pos;
510 
511  // In many cases, e->id() gives us a clue as to where e
512  // is located in the _elements vector. Try that first
513  // before trying the O(n_elem) search.
514  if (_nodes[n->id()] == n)
515  {
516  pos = _nodes.begin();
517  std::advance(pos, n->id());
518  }
519  else
520  {
521  pos = std::find (_nodes.begin(),
522  _nodes.end(),
523  n);
524  }
525 
526  // Huh? Node not in the vector?
527  libmesh_assert (pos != _nodes.end());
528 
529  // Delete the node from the BoundaryInfo object
530  this->get_boundary_info().remove(n);
531 
532  // delete the node
533  delete n;
534 
535  // explicitly zero the pointer
536  *pos = nullptr;
537 }
void remove(const Node *node)
const BoundaryInfo & get_boundary_info() const
Definition: mesh_base.h:131
dof_id_type id() const
Definition: dof_object.h:655
std::vector< Node * > _nodes

◆ delete_remote_elements()

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

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

Reimplemented in libMesh::DistributedMesh.

Definition at line 196 of file mesh_base.h.

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

196 {}

◆ detect_interior_parents()

void libMesh::MeshBase::detect_interior_parents ( )
inherited

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

Definition at line 633 of file mesh_base.C.

References libMesh::MeshBase::active_element_ptr_range(), libMesh::Elem::dim(), libMesh::MeshBase::elem(), libMesh::MeshBase::elem_dimensions(), libMesh::MeshBase::elem_ptr(), libMesh::MeshBase::elem_ref(), libMesh::MeshBase::element_ptr_range(), libMesh::DofObject::id(), libMesh::MeshBase::max_elem_id(), libMesh::Elem::n_vertices(), and libMesh::Elem::node_id().

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

634 {
635  // This requires an inspection on every processor
636  parallel_object_only();
637 
638  // Check if the mesh contains mixed dimensions. If so, then set interior parents, otherwise return.
639  if (this->elem_dimensions().size() == 1)
640  return;
641 
642  //This map will be used to set interior parents
643  std::unordered_map<dof_id_type, std::vector<dof_id_type>> node_to_elem;
644 
645  for (const auto & elem : this->active_element_ptr_range())
646  {
647  // Populating the node_to_elem map, same as MeshTools::build_nodes_to_elem_map
648  for (unsigned int n=0; n<elem->n_vertices(); n++)
649  {
650  libmesh_assert_less (elem->id(), this->max_elem_id());
651 
652  node_to_elem[elem->node_id(n)].push_back(elem->id());
653  }
654  }
655 
656  // Automatically set interior parents
657  for (const auto & element : this->element_ptr_range())
658  {
659  // Ignore an 3D element or an element that already has an interior parent
660  if (element->dim()>=LIBMESH_DIM || element->interior_parent())
661  continue;
662 
663  // Start by generating a SET of elements that are dim+1 to the current
664  // element at each vertex of the current element, thus ignoring interior nodes.
665  // If one of the SET of elements is empty, then we will not have an interior parent
666  // since an interior parent must be connected to all vertices of the current element
667  std::vector<std::set<dof_id_type>> neighbors( element->n_vertices() );
668 
669  bool found_interior_parents = false;
670 
671  for (dof_id_type n=0; n < element->n_vertices(); n++)
672  {
673  std::vector<dof_id_type> & element_ids = node_to_elem[element->node_id(n)];
674  for (const auto & eid : element_ids)
675  if (this->elem_ref(eid).dim() == element->dim()+1)
676  neighbors[n].insert(eid);
677 
678  if (neighbors[n].size()>0)
679  {
680  found_interior_parents = true;
681  }
682  else
683  {
684  // We have found an empty set, no reason to continue
685  // Ensure we set this flag to false before the break since it could have
686  // been set to true for previous vertex
687  found_interior_parents = false;
688  break;
689  }
690  }
691 
692  // If we have successfully generated a set of elements for each vertex, we will compare
693  // the set for vertex 0 will the sets for the vertices until we find a id that exists in
694  // all sets. If found, this is our an interior parent id. The interior parent id found
695  // will be the lowest element id if there is potential for multiple interior parents.
696  if (found_interior_parents)
697  {
698  std::set<dof_id_type> & neighbors_0 = neighbors[0];
699  for (const auto & interior_parent_id : neighbors_0)
700  {
701  found_interior_parents = false;
702  for (dof_id_type n=1; n < element->n_vertices(); n++)
703  {
704  if (neighbors[n].find(interior_parent_id)!=neighbors[n].end())
705  {
706  found_interior_parents=true;
707  }
708  else
709  {
710  found_interior_parents=false;
711  break;
712  }
713  }
714  if (found_interior_parents)
715  {
716  element->set_interior_parent(this->elem_ptr(interior_parent_id));
717  break;
718  }
719  }
720  }
721  }
722 }
virtual const Elem * elem(const dof_id_type i) const
Definition: mesh_base.h:537
virtual SimpleRange< element_iterator > active_element_ptr_range()=0
virtual SimpleRange< element_iterator > element_ptr_range()=0
dof_id_type id() const
Definition: dof_object.h:655
virtual dof_id_type max_elem_id() const =0
const std::set< unsigned char > & elem_dimensions() const
Definition: mesh_base.h:220
virtual const Elem * elem_ptr(const dof_id_type i) const =0
virtual unsigned int n_vertices() const =0
virtual unsigned short dim() const =0
virtual const Elem & elem_ref(const dof_id_type i) const
Definition: mesh_base.h:504
dof_id_type node_id(const unsigned int i) const
Definition: elem.h:1914
uint8_t dof_id_type
Definition: id_types.h:64

◆ elem() [1/2]

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

References libMesh::MeshBase::elem_ptr().

Referenced by libMesh::MeshBase::cache_elem_dims(), clear(), libMesh::DistributedMesh::clear(), libMesh::UnstructuredMesh::contract(), libMesh::MeshBase::detect_interior_parents(), libMesh::DistributedMesh::DistributedMesh(), libMesh::MeshBase::n_active_sub_elem(), libMesh::MeshBase::n_sub_elem(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::DistributedMesh::renumber_nodes_and_elements(), and libMesh::MeshBase::subdomain_ids().

538  {
539  libmesh_deprecated();
540  return this->elem_ptr(i);
541  }
virtual const Elem * elem_ptr(const dof_id_type i) const =0

◆ elem() [2/2]

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

References libMesh::MeshBase::elem_ptr().

553  {
554  libmesh_deprecated();
555  return this->elem_ptr(i);
556  }
virtual const Elem * elem_ptr(const dof_id_type i) const =0

◆ elem_dimensions()

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

Definition at line 220 of file mesh_base.h.

References libMesh::MeshBase::_elem_dims.

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

221  { return _elem_dims; }
std::set< unsigned char > _elem_dims
Definition: mesh_base.h:1453

◆ elem_ptr() [1/2]

const Elem * libMesh::ReplicatedMesh::elem_ptr ( const dof_id_type  i) const
overridevirtual
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 219 of file replicated_mesh.C.

References _elements, and n_elem().

Referenced by stitching_helper().

220 {
221  libmesh_assert_less (i, this->n_elem());
222  libmesh_assert(_elements[i]);
223  libmesh_assert_equal_to (_elements[i]->id(), i); // This will change soon
224 
225  return _elements[i];
226 }
std::vector< Elem * > _elements
virtual dof_id_type n_elem() const override

◆ elem_ptr() [2/2]

Elem * libMesh::ReplicatedMesh::elem_ptr ( const dof_id_type  i)
overridevirtual
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 231 of file replicated_mesh.C.

References _elements, and n_elem().

232 {
233  libmesh_assert_less (i, this->n_elem());
234  libmesh_assert(_elements[i]);
235  libmesh_assert_equal_to (_elements[i]->id(), i); // This will change soon
236 
237  return _elements[i];
238 }
std::vector< Elem * > _elements
virtual dof_id_type n_elem() const override

◆ elem_ref() [1/2]

◆ elem_ref() [2/2]

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

Definition at line 513 of file mesh_base.h.

References libMesh::MeshBase::elem_ptr().

513  {
514  return *this->elem_ptr(i);
515  }
virtual const Elem * elem_ptr(const dof_id_type i) const =0

◆ element_ptr_range() [1/2]

virtual SimpleRange<element_iterator> libMesh::ReplicatedMesh::element_ptr_range ( )
inlineoverridevirtual

Implements libMesh::MeshBase.

Definition at line 239 of file replicated_mesh.h.

References elements_begin(), and elements_end().

Referenced by stitching_helper().

239 { return {elements_begin(), elements_end()}; }
virtual element_iterator elements_begin() override
virtual element_iterator elements_end() override

◆ element_ptr_range() [2/2]

virtual SimpleRange<const_element_iterator> libMesh::ReplicatedMesh::element_ptr_range ( ) const
inlineoverridevirtual

Implements libMesh::MeshBase.

Definition at line 240 of file replicated_mesh.h.

References elements_begin(), and elements_end().

240 { return {elements_begin(), elements_end()}; }
virtual element_iterator elements_begin() override
virtual element_iterator elements_end() override

◆ elements_begin() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::elements_begin ( )
overridevirtual

Elem iterator accessor functions.

Implements libMesh::MeshBase.

Referenced by element_ptr_range().

◆ elements_begin() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::elements_begin ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ elements_end() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::elements_end ( )
overridevirtual

Implements libMesh::MeshBase.

Referenced by element_ptr_range().

◆ elements_end() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::elements_end ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ evaluable_elements_begin() [1/2]

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

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.

◆ evaluable_elements_begin() [2/2]

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

Implements libMesh::MeshBase.

◆ evaluable_elements_end() [1/2]

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

Implements libMesh::MeshBase.

◆ evaluable_elements_end() [2/2]

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

Implements libMesh::MeshBase.

◆ evaluable_nodes_begin() [1/2]

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

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.

◆ evaluable_nodes_begin() [2/2]

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

Implements libMesh::MeshBase.

◆ evaluable_nodes_end() [1/2]

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

Implements libMesh::MeshBase.

◆ evaluable_nodes_end() [2/2]

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

Implements libMesh::MeshBase.

◆ facelocal_elements_begin() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::facelocal_elements_begin ( )
overridevirtual

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

Implements libMesh::MeshBase.

◆ facelocal_elements_begin() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::facelocal_elements_begin ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ facelocal_elements_end() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::facelocal_elements_end ( )
overridevirtual

Implements libMesh::MeshBase.

◆ facelocal_elements_end() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::facelocal_elements_end ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ find_neighbors()

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

Other functions from MeshBase requiring re-definition.

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

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

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

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

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

Implements libMesh::MeshBase.

Definition at line 240 of file unstructured_mesh.C.

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

Referenced by libMesh::TriangleWrapper::copy_tri_to_mesh(), and libMesh::DistributedMesh::redistribute().

242 {
243  // We might actually want to run this on an empty mesh
244  // (e.g. the boundary mesh for a nonexistent bcid!)
245  // libmesh_assert_not_equal_to (this->n_nodes(), 0);
246  // libmesh_assert_not_equal_to (this->n_elem(), 0);
247 
248  // This function must be run on all processors at once
249  parallel_object_only();
250 
251  LOG_SCOPE("find_neighbors()", "Mesh");
252 
253  //TODO:[BSK] This should be removed later?!
254  if (reset_current_list)
255  for (const auto & e : this->element_ptr_range())
256  for (auto s : e->side_index_range())
257  if (e->neighbor_ptr(s) != remote_elem || reset_remote_elements)
258  e->set_neighbor(s, nullptr);
259 
260  // Find neighboring elements by first finding elements
261  // with identical side keys and then check to see if they
262  // are neighbors
263  {
264  // data structures -- Use the hash_multimap if available
265  typedef unsigned int key_type;
266  typedef std::pair<Elem *, unsigned char> val_type;
267  typedef std::pair<key_type, val_type> key_val_pair;
268 
269  typedef std::unordered_multimap<key_type, val_type> map_type;
270 
271  // A map from side keys to corresponding elements & side numbers
272  map_type side_to_elem_map;
273 
274  // Pull objects out of the loop to reduce heap operations
275  std::unique_ptr<Elem> my_side, their_side;
276 
277  for (const auto & element : this->element_ptr_range())
278  {
279  for (auto ms : element->side_index_range())
280  {
281  next_side:
282  // If we haven't yet found a neighbor on this side, try.
283  // Even if we think our neighbor is remote, that
284  // information may be out of date.
285  if (element->neighbor_ptr(ms) == nullptr ||
286  element->neighbor_ptr(ms) == remote_elem)
287  {
288  // Get the key for the side of this element
289  const unsigned int key = element->key(ms);
290 
291  // Look for elements that have an identical side key
292  auto 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  element->side_ptr(my_side, 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  neighbor->side_ptr(their_side, 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 = cast_int<unsigned char>(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  for (auto & current_elem : as_range(level_elements_begin(level),
403  level_elements_end(level)))
404  {
405  libmesh_assert(current_elem);
406  Elem * parent = current_elem->parent();
407  libmesh_assert(parent);
408  const unsigned int my_child_num = parent->which_child_am_i(current_elem);
409 
410  for (auto s : current_elem->side_index_range())
411  {
412  if (current_elem->neighbor_ptr(s) == nullptr ||
413  (current_elem->neighbor_ptr(s) == remote_elem &&
414  parent->is_child_on_side(my_child_num, s)))
415  {
416  Elem * neigh = parent->neighbor_ptr(s);
417 
418  // If neigh was refined and had non-subactive children
419  // made remote earlier, then our current elem should
420  // actually have one of those remote children as a
421  // neighbor
422  if (neigh &&
423  (neigh->ancestor() ||
424  // If neigh has subactive children which should have
425  // matched as neighbors of the current element but
426  // did not, then those likewise must be remote
427  // children.
428  (current_elem->subactive() && neigh->has_children() &&
429  (neigh->level()+1) == current_elem->level())))
430  {
431 #ifdef DEBUG
432  // Let's make sure that "had children made remote"
433  // situation is actually the case
434  libmesh_assert(neigh->has_children());
435  bool neigh_has_remote_children = false;
436  for (auto & child : neigh->child_ref_range())
437  if (&child == remote_elem)
438  neigh_has_remote_children = true;
439  libmesh_assert(neigh_has_remote_children);
440 
441  // And let's double-check that we don't have
442  // a remote_elem neighboring an active local element
443  if (current_elem->active())
444  libmesh_assert_not_equal_to (current_elem->processor_id(),
445  this->processor_id());
446 #endif // DEBUG
447  neigh = const_cast<RemoteElem *>(remote_elem);
448  }
449  // If neigh and current_elem are more than one level
450  // apart, figuring out whether we have a remote
451  // neighbor here becomes much harder.
452  else if (neigh && (current_elem->subactive() &&
453  neigh->has_children()))
454  {
455  // Find the deepest descendant of neigh which
456  // we could consider for a neighbor. If we run
457  // out of neigh children, then that's our
458  // neighbor. If we find a potential neighbor
459  // with remote_children and we don't find any
460  // potential neighbors among its non-remote
461  // children, then our neighbor must be remote.
462  while (neigh != remote_elem &&
463  neigh->has_children())
464  {
465  bool found_neigh = false;
466  for (unsigned int c = 0, nc = neigh->n_children();
467  !found_neigh && c != nc; ++c)
468  {
469  Elem * child = neigh->child_ptr(c);
470  if (child == remote_elem)
471  continue;
472  for (auto ncn : child->neighbor_ptr_range())
473  {
474  if (ncn != remote_elem &&
475  ncn->is_ancestor_of(current_elem))
476  {
477  neigh = ncn;
478  found_neigh = true;
479  break;
480  }
481  }
482  }
483  if (!found_neigh)
484  neigh = const_cast<RemoteElem *>(remote_elem);
485  }
486  }
487  current_elem->set_neighbor(s, neigh);
488 #ifdef DEBUG
489  if (neigh != nullptr && neigh != remote_elem)
490  // We ignore subactive elements here because
491  // we don't care about neighbors of subactive element.
492  if ((!neigh->active()) && (!current_elem->subactive()))
493  {
494  libMesh::err << "On processor " << this->processor_id()
495  << std::endl;
496  libMesh::err << "Bad element ID = " << current_elem->id()
497  << ", Side " << s << ", Bad neighbor ID = " << neigh->id() << std::endl;
498  libMesh::err << "Bad element proc_ID = " << current_elem->processor_id()
499  << ", Bad neighbor proc_ID = " << neigh->processor_id() << std::endl;
500  libMesh::err << "Bad element size = " << current_elem->hmin()
501  << ", Bad neighbor size = " << neigh->hmin() << std::endl;
502  libMesh::err << "Bad element center = " << current_elem->centroid()
503  << ", Bad neighbor center = " << neigh->centroid() << std::endl;
504  libMesh::err << "ERROR: "
505  << (current_elem->active()?"Active":"Ancestor")
506  << " Element at level "
507  << current_elem->level() << std::endl;
508  libMesh::err << "with "
509  << (parent->active()?"active":
510  (parent->subactive()?"subactive":"ancestor"))
511  << " parent share "
512  << (neigh->subactive()?"subactive":"ancestor")
513  << " neighbor at level " << neigh->level()
514  << std::endl;
515  NameBasedIO(*this).write ("bad_mesh.gmv");
516  libmesh_error_msg("Problematic mesh written to bad_mesh.gmv.");
517  }
518 #endif // DEBUG
519  }
520  }
521 
522  // We can skip to the next element if we're full-dimension
523  // and therefore don't have any interior parents
524  if (current_elem->dim() >= LIBMESH_DIM)
525  continue;
526 
527  // We have no interior parents unless we can find one later
528  current_elem->set_interior_parent(nullptr);
529 
530  Elem * pip = parent->interior_parent();
531 
532  if (!pip)
533  continue;
534 
535  // If there's no interior_parent children, whether due to a
536  // remote element or a non-conformity, then there's no
537  // children to search.
538  if (pip == remote_elem || pip->active())
539  {
540  current_elem->set_interior_parent(pip);
541  continue;
542  }
543 
544  // For node comparisons we'll need a sensible tolerance
545  Real node_tolerance = current_elem->hmin() * TOLERANCE;
546 
547  // Otherwise our interior_parent should be a child of our
548  // parent's interior_parent.
549  for (auto & child : pip->child_ref_range())
550  {
551  // If we have a remote_elem, that might be our
552  // interior_parent. We'll set it provisionally now and
553  // keep trying to find something better.
554  if (&child == remote_elem)
555  {
556  current_elem->set_interior_parent
557  (const_cast<RemoteElem *>(remote_elem));
558  continue;
559  }
560 
561  bool child_contains_our_nodes = true;
562  for (auto & n : current_elem->node_ref_range())
563  {
564  bool child_contains_this_node = false;
565  for (auto & cn : child.node_ref_range())
566  if (cn.absolute_fuzzy_equals
567  (n, node_tolerance))
568  {
569  child_contains_this_node = true;
570  break;
571  }
572  if (!child_contains_this_node)
573  {
574  child_contains_our_nodes = false;
575  break;
576  }
577  }
578  if (child_contains_our_nodes)
579  {
580  current_elem->set_interior_parent(&child);
581  break;
582  }
583  }
584 
585  // We should have found *some* interior_parent at this
586  // point, whether semilocal or remote.
587  libmesh_assert(current_elem->interior_parent());
588  }
589  }
590 
591 #endif // AMR
592 
593 
594 #ifdef DEBUG
596  !reset_remote_elements);
598 #endif
599 }
bool is_ancestor_of(const Elem *descendant) const
Definition: elem.h:2458
void libmesh_assert_valid_amr_interior_parents(const MeshBase &mesh)
Definition: mesh_tools.C:1340
virtual element_iterator level_elements_begin(unsigned int level)=0
static const Real TOLERANCE
virtual element_iterator level_elements_end(unsigned int level)=0
virtual SimpleRange< element_iterator > element_ptr_range()=0
unsigned int n_levels(const MeshBase &mesh)
Definition: mesh_tools.C:653
SimpleRange< I > as_range(const std::pair< I, I > &p)
Definition: simple_range.h:57
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:2068
processor_id_type processor_id() const
bool active() const
Definition: elem.h:2390
bool has_children() const
Definition: elem.h:2428
virtual bool is_child_on_side(const unsigned int, const unsigned int) const override
Definition: remote_elem.h:152
const RemoteElem * remote_elem
Definition: remote_elem.C:57

◆ fix_broken_node_and_element_numbering()

void libMesh::ReplicatedMesh::fix_broken_node_and_element_numbering ( )
overridevirtual

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

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

Implements libMesh::MeshBase.

Definition at line 761 of file replicated_mesh.C.

References _elements, and _nodes.

762 {
763  // Nodes first
764  for (std::size_t n=0; n<this->_nodes.size(); n++)
765  if (this->_nodes[n] != nullptr)
766  this->_nodes[n]->set_id() = cast_int<dof_id_type>(n);
767 
768  // Elements next
769  for (std::size_t e=0; e<this->_elements.size(); e++)
770  if (this->_elements[e] != nullptr)
771  this->_elements[e]->set_id() = cast_int<dof_id_type>(e);
772 }
std::vector< Elem * > _elements
std::vector< Node * > _nodes

◆ flagged_elements_begin() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::flagged_elements_begin ( unsigned char  rflag)
overridevirtual

Iterate over all elements with a specified refinement flag.

Implements libMesh::MeshBase.

◆ flagged_elements_begin() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::flagged_elements_begin ( unsigned char  rflag) const
overridevirtual

Implements libMesh::MeshBase.

◆ flagged_elements_end() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::flagged_elements_end ( unsigned char  rflag)
overridevirtual

Implements libMesh::MeshBase.

◆ flagged_elements_end() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::flagged_elements_end ( unsigned char  rflag) const
overridevirtual

Implements libMesh::MeshBase.

◆ flagged_pid_elements_begin() [1/2]

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

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

Implements libMesh::MeshBase.

◆ flagged_pid_elements_begin() [2/2]

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

Implements libMesh::MeshBase.

◆ flagged_pid_elements_end() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::flagged_pid_elements_end ( unsigned char  rflag,
processor_id_type  pid 
)
overridevirtual

Implements libMesh::MeshBase.

◆ flagged_pid_elements_end() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::flagged_pid_elements_end ( unsigned char  rflag,
processor_id_type  pid 
) const
overridevirtual

Implements libMesh::MeshBase.

◆ gather_to_zero()

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

Gathers all elements and nodes of the mesh onto processor zero

Reimplemented in libMesh::DistributedMesh.

Definition at line 189 of file mesh_base.h.

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

189 {}

◆ get_boundary_info() [1/2]

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

The information about boundary ids on the mesh

Definition at line 131 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::MeshTools::Generation::build_delaunay_square(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::MeshTools::Modification::change_boundary_id(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::FEGenericBase< FEOutputType< T >::type >::compute_periodic_constraints(), libMesh::UnstructuredMesh::create_submesh(), libMesh::TetGenMeshInterface::delete_2D_hull_elements(), delete_elem(), libMesh::DistributedMesh::delete_elem(), delete_node(), libMesh::DistributedMesh::delete_node(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DistributedMesh::DistributedMesh(), libMesh::MeshTools::Modification::flatten(), libMesh::UNVIO::groups_in(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::Parallel::Packing< T >::pack(), libMesh::Parallel::Packing< T >::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::GmshIO::read_mesh(), libMesh::CheckpointIO::read_nodesets(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_nodesets(), renumber_nodes_and_elements(), libMesh::DistributedMesh::renumber_nodes_and_elements(), ReplicatedMesh(), stitching_helper(), libMesh::BoundaryInfo::sync(), libMesh::Parallel::Packing< T >::unpack(), libMesh::FroIO::write(), libMesh::Nemesis_IO::write(), libMesh::ExodusII_IO::write(), libMesh::XdrIO::write(), libMesh::CheckpointIO::write(), libMesh::GmshIO::write_mesh(), libMesh::ExodusII_IO::write_nodal_data_common(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_nodesets(), and libMesh::ExodusII_IO_Helper::write_sidesets().

131 { return *boundary_info; }
std::unique_ptr< BoundaryInfo > boundary_info
Definition: mesh_base.h:1363

◆ get_boundary_info() [2/2]

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

Writable information about boundary ids on the mesh

Definition at line 136 of file mesh_base.h.

References libMesh::MeshBase::boundary_info.

136 { return *boundary_info; }
std::unique_ptr< BoundaryInfo > boundary_info
Definition: mesh_base.h:1363

◆ get_count_lower_dim_elems_in_point_locator()

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

Get the current value of _count_lower_dim_elems_in_point_locator.

Definition at line 531 of file mesh_base.C.

References libMesh::MeshBase::_count_lower_dim_elems_in_point_locator.

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

532 {
534 }
bool _count_lower_dim_elems_in_point_locator
Definition: mesh_base.h:1404

◆ get_id_by_name()

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

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

559 {
560  // Linear search over the map values.
561  std::map<subdomain_id_type, std::string>::const_iterator
562  iter = _block_id_to_name.begin(),
563  end_iter = _block_id_to_name.end();
564 
565  for ( ; iter != end_iter; ++iter)
566  if (iter->second == name)
567  return iter->first;
568 
569  // If we made it here without returning, we don't have a subdomain
570  // with the requested name, so return Elem::invalid_subdomain_id.
572 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:42
static const subdomain_id_type invalid_subdomain_id
Definition: elem.h:262
std::map< subdomain_id_type, std::string > _block_id_to_name
Definition: mesh_base.h:1446

◆ get_info()

std::string libMesh::MeshBase::get_info ( ) const
inherited
Returns
A string containing relevant information about the mesh.

Definition at line 378 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::print_info().

379 {
380  std::ostringstream oss;
381 
382  oss << " Mesh Information:" << '\n';
383 
384  if (!_elem_dims.empty())
385  {
386  oss << " elem_dimensions()={";
387  std::copy(_elem_dims.begin(),
388  --_elem_dims.end(), // --end() is valid if the set is non-empty
389  std::ostream_iterator<unsigned int>(oss, ", "));
390  oss << cast_int<unsigned int>(*_elem_dims.rbegin());
391  oss << "}\n";
392  }
393 
394  oss << " spatial_dimension()=" << this->spatial_dimension() << '\n'
395  << " n_nodes()=" << this->n_nodes() << '\n'
396  << " n_local_nodes()=" << this->n_local_nodes() << '\n'
397  << " n_elem()=" << this->n_elem() << '\n'
398  << " n_local_elem()=" << this->n_local_elem() << '\n'
399 #ifdef LIBMESH_ENABLE_AMR
400  << " n_active_elem()=" << this->n_active_elem() << '\n'
401 #endif
402  << " n_subdomains()=" << static_cast<std::size_t>(this->n_subdomains()) << '\n'
403  << " n_partitions()=" << static_cast<std::size_t>(this->n_partitions()) << '\n'
404  << " n_processors()=" << static_cast<std::size_t>(this->n_processors()) << '\n'
405  << " n_threads()=" << static_cast<std::size_t>(libMesh::n_threads()) << '\n'
406  << " processor_id()=" << static_cast<std::size_t>(this->processor_id()) << '\n';
407 
408  return oss.str();
409 }
virtual dof_id_type n_active_elem() const =0
unsigned int n_threads()
Definition: libmesh_base.h:96
dof_id_type n_local_nodes() const
Definition: mesh_base.h:286
dof_id_type n_local_elem() const
Definition: mesh_base.h:386
processor_id_type n_processors() const
std::set< unsigned char > _elem_dims
Definition: mesh_base.h:1453
unsigned int n_partitions() const
Definition: mesh_base.h:875
subdomain_id_type n_subdomains() const
Definition: mesh_base.C:304
unsigned int spatial_dimension() const
Definition: mesh_base.C:135
virtual dof_id_type n_elem() const =0
processor_id_type processor_id() const
virtual dof_id_type n_nodes() const =0

◆ get_subdomain_name_map()

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

Definition at line 1337 of file mesh_base.h.

References libMesh::MeshBase::_block_id_to_name.

Referenced by libMesh::XdrIO::write_serialized_subdomain_names(), and libMesh::CheckpointIO::write_subdomain_names().

1338  { return _block_id_to_name; }
std::map< subdomain_id_type, std::string > _block_id_to_name
Definition: mesh_base.h:1446

◆ ghost_elements_begin() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::ghost_elements_begin ( )
overridevirtual

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

Implements libMesh::MeshBase.

◆ ghost_elements_begin() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::ghost_elements_begin ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ ghost_elements_end() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::ghost_elements_end ( )
overridevirtual

Implements libMesh::MeshBase.

◆ ghost_elements_end() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::ghost_elements_end ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ ghosting_functors_begin()

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

Beginning of range of ghosting functors

Definition at line 835 of file mesh_base.h.

References libMesh::MeshBase::_ghosting_functors.

Referenced by libMesh::UnstructuredMesh::contract(), libMesh::MeshCommunication::delete_remote_elements(), and libMesh::query_ghosting_functors().

836  { return _ghosting_functors.begin(); }
std::set< GhostingFunctor * > _ghosting_functors
Definition: mesh_base.h:1475

◆ ghosting_functors_end()

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

End of range of ghosting functors

Definition at line 841 of file mesh_base.h.

References libMesh::MeshBase::_ghosting_functors.

Referenced by libMesh::UnstructuredMesh::contract(), libMesh::MeshCommunication::delete_remote_elements(), and libMesh::query_ghosting_functors().

842  { return _ghosting_functors.end(); }
std::set< GhostingFunctor * > _ghosting_functors
Definition: mesh_base.h:1475

◆ insert_elem()

Elem * libMesh::ReplicatedMesh::insert_elem ( Elem e)
overridevirtual

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 305 of file replicated_mesh.C.

References _elements, libMesh::MeshBase::_next_unique_id, delete_elem(), libMesh::DofObject::id(), libMesh::DofObject::set_unique_id(), and libMesh::DofObject::valid_unique_id().

306 {
307 #ifdef LIBMESH_ENABLE_UNIQUE_ID
308  if (!e->valid_unique_id())
310 #endif
311 
312  dof_id_type eid = e->id();
313  libmesh_assert_less (eid, _elements.size());
314  Elem * oldelem = _elements[eid];
315 
316  if (oldelem)
317  {
318  libmesh_assert_equal_to (oldelem->id(), eid);
319  this->delete_elem(oldelem);
320  }
321 
322  _elements[e->id()] = e;
323 
324  return e;
325 }
unique_id_type & set_unique_id()
Definition: dof_object.h:685
std::vector< Elem * > _elements
The base class for all geometric element types.
Definition: elem.h:100
unique_id_type _next_unique_id
Definition: mesh_base.h:1418
dof_id_type id() const
Definition: dof_object.h:655
bool valid_unique_id() const
Definition: dof_object.h:705
virtual void delete_elem(Elem *e) override
uint8_t dof_id_type
Definition: id_types.h:64

◆ insert_node()

Node * libMesh::ReplicatedMesh::insert_node ( Node n)
overridevirtual

Insert Node n into the Mesh at a location consistent with n->id(), allocating extra storage if necessary. Throws an error if: .) n==nullptr .) n->id() == DofObject::invalid_id .) A node already exists in position n->id().

This function differs from the ReplicatedMesh::add_node() function, which is only capable of appending nodes at the end of the nodes storage.

Implements libMesh::MeshBase.

Definition at line 459 of file replicated_mesh.C.

References libMesh::MeshBase::_next_unique_id, _nodes, libMesh::DofObject::id(), libMesh::DofObject::invalid_id, libMesh::DofObject::set_unique_id(), and libMesh::DofObject::valid_unique_id().

460 {
461  if (!n)
462  libmesh_error_msg("Error, attempting to insert nullptr node.");
463 
464  if (n->id() == DofObject::invalid_id)
465  libmesh_error_msg("Error, cannot insert node with invalid id.");
466 
467  if (n->id() < _nodes.size())
468  {
469  // Don't allow inserting on top of an existing Node.
470 
471  // Doing so doesn't have to be *error*, in the case where a
472  // redundant insert is done, but when that happens we ought to
473  // always be able to make the code more efficient by avoiding
474  // the redundant insert, so let's keep screaming "Error" here.
475  if (_nodes[ n->id() ] != nullptr)
476  libmesh_error_msg("Error, cannot insert node on top of existing node.");
477  }
478  else
479  {
480  // Allocate just enough space to store the new node. This will
481  // cause highly non-ideal memory allocation behavior if called
482  // repeatedly...
483  _nodes.resize(n->id() + 1);
484  }
485 
486 #ifdef LIBMESH_ENABLE_UNIQUE_ID
487  if (!n->valid_unique_id())
489 #endif
490 
491  // We have enough space and this spot isn't already occupied by
492  // another node, so go ahead and add it.
493  _nodes[ n->id() ] = n;
494 
495  // If we made it this far, we just inserted the node the user handed
496  // us, so we can give it right back.
497  return n;
498 }
unique_id_type & set_unique_id()
Definition: dof_object.h:685
unique_id_type _next_unique_id
Definition: mesh_base.h:1418
dof_id_type id() const
Definition: dof_object.h:655
static const dof_id_type invalid_id
Definition: dof_object.h:347
std::vector< Node * > _nodes
bool valid_unique_id() const
Definition: dof_object.h:705

◆ is_prepared()

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

References libMesh::MeshBase::_is_prepared.

Referenced by libMesh::DofMap::create_dof_constraints().

148  { return _is_prepared; }

◆ is_replicated()

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

Reimplemented in libMesh::DistributedMesh.

Definition at line 176 of file mesh_base.h.

Referenced by libMesh::MeshRefinement::_refine_elements(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::CheckpointIO::read(), and libMesh::MeshRefinement::uniformly_coarsen().

177  { return true; }

◆ is_serial()

◆ is_serial_on_zero()

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

Reimplemented in libMesh::DistributedMesh.

Definition at line 161 of file mesh_base.h.

162  { return true; }

◆ level_elements_begin() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::level_elements_begin ( unsigned int  level)
overridevirtual

Iterate over elements of a given level.

Implements libMesh::MeshBase.

◆ level_elements_begin() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::level_elements_begin ( unsigned int  level) const
overridevirtual

Implements libMesh::MeshBase.

◆ level_elements_end() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::level_elements_end ( unsigned int  level)
overridevirtual

Implements libMesh::MeshBase.

◆ level_elements_end() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::level_elements_end ( unsigned int  level) const
overridevirtual

Implements libMesh::MeshBase.

◆ libmesh_assert_valid_parallel_ids()

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

Verify id and processor_id consistency of our elements and nodes containers. Calls libmesh_assert() on each possible failure. Currently only implemented on DistributedMesh; a serial data structure is much harder to get out of sync.

Reimplemented in libMesh::DistributedMesh.

Definition at line 1007 of file mesh_base.h.

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

1007 {}

◆ local_elements_begin() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::local_elements_begin ( )
overridevirtual

Implements libMesh::MeshBase.

◆ local_elements_begin() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::local_elements_begin ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ local_elements_end() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::local_elements_end ( )
overridevirtual

Implements libMesh::MeshBase.

◆ local_elements_end() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::local_elements_end ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ local_level_elements_begin() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::local_level_elements_begin ( unsigned int  level)
overridevirtual

Implements libMesh::MeshBase.

◆ local_level_elements_begin() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::local_level_elements_begin ( unsigned int  level) const
overridevirtual

Implements libMesh::MeshBase.

◆ local_level_elements_end() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::local_level_elements_end ( unsigned int  level)
overridevirtual

Implements libMesh::MeshBase.

◆ local_level_elements_end() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::local_level_elements_end ( unsigned int  level) const
overridevirtual

Implements libMesh::MeshBase.

◆ local_node_ptr_range() [1/2]

virtual SimpleRange<node_iterator> libMesh::ReplicatedMesh::local_node_ptr_range ( )
inlineoverridevirtual

Implements libMesh::MeshBase.

Definition at line 432 of file replicated_mesh.h.

References local_nodes_begin(), and local_nodes_end().

432 { return {local_nodes_begin(), local_nodes_end()}; }
virtual node_iterator local_nodes_begin() override
virtual node_iterator local_nodes_end() override

◆ local_node_ptr_range() [2/2]

virtual SimpleRange<const_node_iterator> libMesh::ReplicatedMesh::local_node_ptr_range ( ) const
inlineoverridevirtual

Implements libMesh::MeshBase.

Definition at line 433 of file replicated_mesh.h.

References local_nodes_begin(), and local_nodes_end().

433 { return {local_nodes_begin(), local_nodes_end()}; }
virtual node_iterator local_nodes_begin() override
virtual node_iterator local_nodes_end() override

◆ local_nodes_begin() [1/2]

virtual node_iterator libMesh::ReplicatedMesh::local_nodes_begin ( )
overridevirtual

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

Implements libMesh::MeshBase.

Referenced by local_node_ptr_range().

◆ local_nodes_begin() [2/2]

virtual const_node_iterator libMesh::ReplicatedMesh::local_nodes_begin ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ local_nodes_end() [1/2]

virtual node_iterator libMesh::ReplicatedMesh::local_nodes_end ( )
overridevirtual

Implements libMesh::MeshBase.

Referenced by local_node_ptr_range().

◆ local_nodes_end() [2/2]

virtual const_node_iterator libMesh::ReplicatedMesh::local_nodes_end ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ local_not_level_elements_begin() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::local_not_level_elements_begin ( unsigned int  level)
overridevirtual

Implements libMesh::MeshBase.

◆ local_not_level_elements_begin() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::local_not_level_elements_begin ( unsigned int  level) const
overridevirtual

Implements libMesh::MeshBase.

◆ local_not_level_elements_end() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::local_not_level_elements_end ( unsigned int  level)
overridevirtual

Implements libMesh::MeshBase.

◆ local_not_level_elements_end() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::local_not_level_elements_end ( unsigned int  level) const
overridevirtual

Implements libMesh::MeshBase.

◆ max_elem_id()

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

Implements libMesh::MeshBase.

Definition at line 123 of file replicated_mesh.h.

References _elements.

Referenced by stitching_helper().

124  { return cast_int<dof_id_type>(_elements.size()); }
std::vector< Elem * > _elements

◆ max_node_id()

virtual dof_id_type libMesh::ReplicatedMesh::max_node_id ( ) const
inlineoverridevirtual
Returns
A number greater than or equal to the maximum node id in the mesh.

Implements libMesh::MeshBase.

Definition at line 109 of file replicated_mesh.h.

References _nodes.

Referenced by stitching_helper().

110  { return cast_int<dof_id_type>(_nodes.size()); }
std::vector< Node * > _nodes

◆ mesh_dimension()

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

Definition at line 126 of file mesh_base.C.

References libMesh::MeshBase::_elem_dims.

Referenced by libMesh::HPCoarsenTest::add_projection(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::EquationSystems::build_variable_names(), libMesh::MeshBase::cache_elem_dims(), libMesh::DofMap::create_dof_constraints(), libMesh::MeshTools::Modification::distort(), 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::Nemesis_IO::read(), libMesh::ExodusII_IO::read(), libMesh::GMVIO::read(), libMesh::VTKIO::read(), libMesh::System::read_header(), libMesh::UCDIO::read_implementation(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::MeshTools::Modification::smooth(), libMesh::PostscriptIO::write(), libMesh::CheckpointIO::write(), libMesh::TecplotIO::write_binary(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::UCDIO::write_implementation(), libMesh::UCDIO::write_nodal_data(), libMesh::EnsightIO::write_scalar_ascii(), libMesh::GnuPlotIO::write_solution(), and libMesh::EnsightIO::write_vector_ascii().

127 {
128  if (!_elem_dims.empty())
129  return cast_int<unsigned int>(*_elem_dims.rbegin());
130  return 0;
131 }
std::set< unsigned char > _elem_dims
Definition: mesh_base.h:1453

◆ n_active_elem()

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

Implemented in terms of active_element_iterators.

Implements libMesh::MeshBase.

Definition at line 1371 of file replicated_mesh.C.

References active_elements_begin(), and active_elements_end().

1372 {
1373  return static_cast<dof_id_type>(std::distance (this->active_elements_begin(),
1374  this->active_elements_end()));
1375 }
virtual element_iterator active_elements_end() override
virtual element_iterator active_elements_begin() override
uint8_t dof_id_type
Definition: id_types.h:64

◆ n_active_elem_on_proc()

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

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

346 {
347  libmesh_assert_less (proc_id, this->n_processors());
348  return static_cast<dof_id_type>(std::distance (this->active_pid_elements_begin(proc_id),
349  this->active_pid_elements_end (proc_id)));
350 }
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

◆ n_active_local_elem()

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

Definition at line 403 of file mesh_base.h.

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

Referenced by libMesh::VTKIO::cells_to_vtk().

404  { return this->n_active_elem_on_proc (this->processor_id()); }
dof_id_type n_active_elem_on_proc(const processor_id_type proc) const
Definition: mesh_base.C:345
processor_id_type processor_id() const

◆ n_active_sub_elem()

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

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

Definition at line 366 of file mesh_base.C.

References libMesh::MeshBase::active_element_ptr_range(), libMesh::MeshBase::elem(), and libMesh::Elem::n_sub_elem().

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

367 {
368  dof_id_type ne=0;
369 
370  for (const auto & elem : this->active_element_ptr_range())
371  ne += elem->n_sub_elem();
372 
373  return ne;
374 }
virtual const Elem * elem(const dof_id_type i) const
Definition: mesh_base.h:537
virtual SimpleRange< element_iterator > active_element_ptr_range()=0
virtual unsigned int n_sub_elem() const =0
uint8_t dof_id_type
Definition: id_types.h:64

◆ n_elem()

virtual dof_id_type libMesh::ReplicatedMesh::n_elem ( ) const
inlineoverridevirtual
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 115 of file replicated_mesh.h.

References _elements.

Referenced by elem_ptr(), and query_elem_ptr().

116  { return cast_int<dof_id_type>(_elements.size()); }
std::vector< Elem * > _elements

◆ n_elem_on_proc()

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

Definition at line 332 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(), and libMesh::MeshBase::n_unpartitioned_elem().

333 {
334  // We're either counting a processor's elements or unpartitioned
335  // elements
336  libmesh_assert (proc_id < this->n_processors() ||
338 
339  return static_cast<dof_id_type>(std::distance (this->pid_elements_begin(proc_id),
340  this->pid_elements_end (proc_id)));
341 }
processor_id_type n_processors() const
static const processor_id_type invalid_processor_id
Definition: dof_object.h:358
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

◆ n_local_elem()

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

Definition at line 386 of file mesh_base.h.

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

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

387  { 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:332
processor_id_type processor_id() const

◆ n_local_nodes()

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

Definition at line 286 of file mesh_base.h.

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

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

287  { 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:319
processor_id_type processor_id() const

◆ n_nodes()

virtual dof_id_type libMesh::ReplicatedMesh::n_nodes ( ) const
inlineoverridevirtual
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 103 of file replicated_mesh.h.

References _nodes.

Referenced by node_ptr(), and query_node_ptr().

104  { return cast_int<dof_id_type>(_nodes.size()); }
std::vector< Node * > _nodes

◆ n_nodes_on_proc()

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

Definition at line 319 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::n_local_nodes(), and libMesh::MeshBase::n_unpartitioned_nodes().

320 {
321  // We're either counting a processor's nodes or unpartitioned
322  // nodes
323  libmesh_assert (proc_id < this->n_processors() ||
325 
326  return static_cast<dof_id_type>(std::distance (this->pid_nodes_begin(proc_id),
327  this->pid_nodes_end (proc_id)));
328 }
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:358
virtual node_iterator pid_nodes_begin(processor_id_type proc_id)=0
uint8_t dof_id_type
Definition: id_types.h:64

◆ n_partitions()

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

Definition at line 875 of file mesh_base.h.

References libMesh::MeshBase::_n_parts.

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

876  { return _n_parts; }
unsigned int _n_parts
Definition: mesh_base.h:1384

◆ n_processors()

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

Definition at line 95 of file parallel_object.h.

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

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::DistributedMesh::add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assembly(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::DistributedMesh::clear(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), 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(), libMesh::EnsightIO::EnsightIO(), libMesh::MeshBase::get_info(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::DistributedMesh::insert_elem(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_elem_on_proc(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::MeshBase::partition(), libMesh::PetscLinearSolver< T >::PetscLinearSolver(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::XdrIO::read_header(), libMesh::CheckpointIO::read_nodes(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::System::read_serialized_vector(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

96  { return cast_int<processor_id_type>(_communicator.size()); }
processor_id_type size() const
Definition: communicator.h:175
const Parallel::Communicator & _communicator

◆ n_sub_elem()

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

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

Definition at line 354 of file mesh_base.C.

References libMesh::MeshBase::elem(), libMesh::MeshBase::element_ptr_range(), and libMesh::Elem::n_sub_elem().

355 {
356  dof_id_type ne=0;
357 
358  for (const auto & elem : this->element_ptr_range())
359  ne += elem->n_sub_elem();
360 
361  return ne;
362 }
virtual const Elem * elem(const dof_id_type i) const
Definition: mesh_base.h:537
virtual SimpleRange< element_iterator > element_ptr_range()=0
virtual unsigned int n_sub_elem() const =0
uint8_t dof_id_type
Definition: id_types.h:64

◆ n_subdomains()

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

Definition at line 304 of file mesh_base.C.

References libMesh::MeshBase::subdomain_ids().

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

305 {
306  // This requires an inspection on every processor
307  parallel_object_only();
308 
309  std::set<subdomain_id_type> ids;
310 
311  this->subdomain_ids (ids);
312 
313  return cast_int<subdomain_id_type>(ids.size());
314 }
void subdomain_ids(std::set< subdomain_id_type > &ids) const
Definition: mesh_base.C:288

◆ n_unpartitioned_elem()

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

Definition at line 392 of file mesh_base.h.

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

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

dof_id_type n_elem_on_proc(const processor_id_type proc) const
Definition: mesh_base.C:332
static const processor_id_type invalid_processor_id
Definition: dof_object.h:358

◆ n_unpartitioned_nodes()

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

Definition at line 292 of file mesh_base.h.

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

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

static const processor_id_type invalid_processor_id
Definition: dof_object.h:358
dof_id_type n_nodes_on_proc(const processor_id_type proc) const
Definition: mesh_base.C:319

◆ next_unique_id()

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

Definition at line 305 of file mesh_base.h.

References libMesh::MeshBase::_next_unique_id.

305 { return _next_unique_id; }
unique_id_type _next_unique_id
Definition: mesh_base.h:1418

◆ node() [1/2]

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

References libMesh::MeshBase::node_ptr().

Referenced by libMesh::UnstructuredMesh::all_first_order(), libMesh::MeshBase::cache_elem_dims(), clear(), libMesh::DistributedMesh::clear(), and renumber_nodes_and_elements().

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

◆ node() [2/2]

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

References libMesh::MeshBase::node_ptr().

469  {
470  libmesh_deprecated();
471  return *this->node_ptr(i);
472  }
virtual const Node * node_ptr(const dof_id_type i) const =0

◆ node_ptr() [1/2]

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

Implements libMesh::MeshBase.

Definition at line 169 of file replicated_mesh.C.

References _nodes, and n_nodes().

Referenced by stitching_helper().

170 {
171  libmesh_assert_less (i, this->n_nodes());
172  libmesh_assert(_nodes[i]);
173  libmesh_assert_equal_to (_nodes[i]->id(), i); // This will change soon
174 
175  return _nodes[i];
176 }
virtual dof_id_type n_nodes() const override
std::vector< Node * > _nodes

◆ node_ptr() [2/2]

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

Implements libMesh::MeshBase.

Definition at line 181 of file replicated_mesh.C.

References _nodes, and n_nodes().

182 {
183  libmesh_assert_less (i, this->n_nodes());
184  libmesh_assert(_nodes[i]);
185  libmesh_assert_equal_to (_nodes[i]->id(), i); // This will change soon
186 
187  return _nodes[i];
188 }
virtual dof_id_type n_nodes() const override
std::vector< Node * > _nodes

◆ node_ptr_range() [1/2]

virtual SimpleRange<node_iterator> libMesh::ReplicatedMesh::node_ptr_range ( )
inlineoverridevirtual

Implements libMesh::MeshBase.

Definition at line 420 of file replicated_mesh.h.

References nodes_begin(), and nodes_end().

420 { return {nodes_begin(), nodes_end()}; }
virtual node_iterator nodes_end() override
virtual node_iterator nodes_begin() override

◆ node_ptr_range() [2/2]

virtual SimpleRange<const_node_iterator> libMesh::ReplicatedMesh::node_ptr_range ( ) const
inlineoverridevirtual

Implements libMesh::MeshBase.

Definition at line 421 of file replicated_mesh.h.

References nodes_begin(), and nodes_end().

421 { return {nodes_begin(), nodes_end()}; }
virtual node_iterator nodes_end() override
virtual node_iterator nodes_begin() override

◆ node_ref() [1/2]

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

Definition at line 434 of file mesh_base.h.

References libMesh::MeshBase::node_ptr().

Referenced by libMesh::SyncNodalPositions::act_on_data(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::MeshTools::correct_node_proc_ids(), point(), libMesh::DistributedMesh::point(), libMesh::XdrIO::read_serialized_nodes(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::MeshTools::Modification::smooth(), stitching_helper(), and libMesh::GmshIO::write_mesh().

434  {
435  return *this->node_ptr(i);
436  }
virtual const Node * node_ptr(const dof_id_type i) const =0

◆ node_ref() [2/2]

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

Definition at line 442 of file mesh_base.h.

References libMesh::MeshBase::node_ptr().

442  {
443  return *this->node_ptr(i);
444  }
virtual const Node * node_ptr(const dof_id_type i) const =0

◆ nodes_begin() [1/2]

virtual node_iterator libMesh::ReplicatedMesh::nodes_begin ( )
overridevirtual

Node iterator accessor functions.

Implements libMesh::MeshBase.

Referenced by node_ptr_range().

◆ nodes_begin() [2/2]

virtual const_node_iterator libMesh::ReplicatedMesh::nodes_begin ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ nodes_end() [1/2]

virtual node_iterator libMesh::ReplicatedMesh::nodes_end ( )
overridevirtual

Implements libMesh::MeshBase.

Referenced by node_ptr_range().

◆ nodes_end() [2/2]

virtual const_node_iterator libMesh::ReplicatedMesh::nodes_end ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ not_active_elements_begin() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::not_active_elements_begin ( )
overridevirtual

Implements libMesh::MeshBase.

◆ not_active_elements_begin() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::not_active_elements_begin ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ not_active_elements_end() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::not_active_elements_end ( )
overridevirtual

Implements libMesh::MeshBase.

◆ not_active_elements_end() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::not_active_elements_end ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ not_ancestor_elements_begin() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::not_ancestor_elements_begin ( )
overridevirtual

Implements libMesh::MeshBase.

◆ not_ancestor_elements_begin() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::not_ancestor_elements_begin ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ not_ancestor_elements_end() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::not_ancestor_elements_end ( )
overridevirtual

Implements libMesh::MeshBase.

◆ not_ancestor_elements_end() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::not_ancestor_elements_end ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ not_level_elements_begin() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::not_level_elements_begin ( unsigned int  level)
overridevirtual

Implements libMesh::MeshBase.

◆ not_level_elements_begin() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::not_level_elements_begin ( unsigned int  level) const
overridevirtual

Implements libMesh::MeshBase.

◆ not_level_elements_end() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::not_level_elements_end ( unsigned int  level)
overridevirtual

Implements libMesh::MeshBase.

◆ not_level_elements_end() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::not_level_elements_end ( unsigned int  level) const
overridevirtual

Implements libMesh::MeshBase.

◆ not_local_elements_begin() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::not_local_elements_begin ( )
overridevirtual

Implements libMesh::MeshBase.

◆ not_local_elements_begin() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::not_local_elements_begin ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ not_local_elements_end() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::not_local_elements_end ( )
overridevirtual

Implements libMesh::MeshBase.

◆ not_local_elements_end() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::not_local_elements_end ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ not_subactive_elements_begin() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::not_subactive_elements_begin ( )
overridevirtual

Implements libMesh::MeshBase.

◆ not_subactive_elements_begin() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::not_subactive_elements_begin ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ not_subactive_elements_end() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::not_subactive_elements_end ( )
overridevirtual

Implements libMesh::MeshBase.

◆ not_subactive_elements_end() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::not_subactive_elements_end ( ) const
overridevirtual

Implements libMesh::MeshBase.

◆ operator=() [1/2]

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

Copy and move assignment are not allowed.

◆ operator=() [2/2]

ReplicatedMesh& libMesh::ReplicatedMesh::operator= ( ReplicatedMesh &&  )
delete

◆ own_node()

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

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

Reimplemented in libMesh::DistributedMesh.

Definition at line 639 of file mesh_base.h.

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

639 {}

◆ parallel_max_unique_id()

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

Implements libMesh::MeshBase.

Definition at line 592 of file replicated_mesh.C.

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

Referenced by stitching_helper(), and update_parallel_id_counts().

593 {
594  // This function must be run on all processors at once
595  parallel_object_only();
596 
597  unique_id_type max_local = _next_unique_id;
598  this->comm().max(max_local);
599  return max_local;
600 }
const Parallel::Communicator & comm() const
unique_id_type _next_unique_id
Definition: mesh_base.h:1418
uint8_t unique_id_type
Definition: id_types.h:79

◆ parallel_n_elem()

virtual dof_id_type libMesh::ReplicatedMesh::parallel_n_elem ( ) const
inlineoverridevirtual
Returns
The number of elements in the mesh.

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

Implements libMesh::MeshBase.

Definition at line 118 of file replicated_mesh.h.

References _elements.

119  { return cast_int<dof_id_type>(_elements.size()); }
std::vector< Elem * > _elements

◆ parallel_n_nodes()

virtual dof_id_type libMesh::ReplicatedMesh::parallel_n_nodes ( ) const
inlineoverridevirtual
Returns
The number of nodes in the mesh.

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

Implements libMesh::MeshBase.

Definition at line 106 of file replicated_mesh.h.

References _nodes.

107  { return cast_int<dof_id_type>(_nodes.size()); }
std::vector< Node * > _nodes

◆ partition() [1/2]

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

Call the default partitioner (currently metis_partition()).

Definition at line 426 of file mesh_base.C.

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

Referenced by libMesh::split_mesh().

427 {
428  // If we get here and we have unpartitioned elements, we need that
429  // fixed.
430  if (this->n_unpartitioned_elem() > 0)
431  {
432  libmesh_assert (partitioner().get());
433  libmesh_assert (this->is_serial());
434  partitioner()->partition (*this, n_parts);
435  }
436  // A nullptr partitioner means don't repartition; skip_partitioning()
437  // checks on this.
438  // Non-serial meshes may not be ready for repartitioning here.
439  else if (!skip_partitioning())
440  {
441  partitioner()->partition (*this, n_parts);
442  }
443  else
444  {
445  // Adaptive coarsening may have "orphaned" nodes on processors
446  // whose elements no longer share them. We need to check for
447  // and possibly fix that.
449 
450  // Make sure locally cached partition count is correct
451  this->recalculate_n_partitions();
452 
453  // Make sure any other locally cached data is correct
454  this->update_post_partitioning();
455  }
456 }
void correct_node_proc_ids(MeshBase &)
Definition: mesh_tools.C:2259
virtual std::unique_ptr< Partitioner > & partitioner()
Definition: mesh_base.h:126
dof_id_type n_unpartitioned_elem() const
Definition: mesh_base.h:392
virtual bool is_serial() const
Definition: mesh_base.h:154
bool skip_partitioning() const
Definition: mesh_base.h:812
unsigned int recalculate_n_partitions()
Definition: mesh_base.C:458
virtual void update_post_partitioning()
Definition: mesh_base.h:763

◆ partition() [2/2]

void libMesh::MeshBase::partition ( )
inlineinherited

Definition at line 749 of file mesh_base.h.

References libMesh::ParallelObject::n_processors().

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

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

◆ partitioner()

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

A partitioner to use at each prepare_for_use()

Definition at line 126 of file mesh_base.h.

References libMesh::MeshBase::_partitioner.

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

126 { return _partitioner; }
std::unique_ptr< Partitioner > _partitioner
Definition: mesh_base.h:1412

◆ pid_elements_begin() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::pid_elements_begin ( processor_id_type  proc_id)
overridevirtual

Iterate over all elements with a specified processor id.

Implements libMesh::MeshBase.

◆ pid_elements_begin() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::pid_elements_begin ( processor_id_type  proc_id) const
overridevirtual

Implements libMesh::MeshBase.

◆ pid_elements_end() [1/2]

virtual element_iterator libMesh::ReplicatedMesh::pid_elements_end ( processor_id_type  proc_id)
overridevirtual

Implements libMesh::MeshBase.

◆ pid_elements_end() [2/2]

virtual const_element_iterator libMesh::ReplicatedMesh::pid_elements_end ( processor_id_type  proc_id) const
overridevirtual

Implements libMesh::MeshBase.

◆ pid_nodes_begin() [1/2]

virtual node_iterator libMesh::ReplicatedMesh::pid_nodes_begin ( processor_id_type  proc_id)
overridevirtual

Iterate over nodes with processor_id() == proc_id

Implements libMesh::MeshBase.

◆ pid_nodes_begin() [2/2]

virtual const_node_iterator libMesh::ReplicatedMesh::pid_nodes_begin ( processor_id_type  proc_id) const
overridevirtual

Implements libMesh::MeshBase.

◆ pid_nodes_end() [1/2]

virtual node_iterator libMesh::ReplicatedMesh::pid_nodes_end ( processor_id_type  proc_id)
overridevirtual

Implements libMesh::MeshBase.

◆ pid_nodes_end() [2/2]

virtual const_node_iterator libMesh::ReplicatedMesh::pid_nodes_end ( processor_id_type  proc_id) const
overridevirtual

Implements libMesh::MeshBase.

◆ point()

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

Implements libMesh::MeshBase.

Definition at line 161 of file replicated_mesh.C.

References libMesh::MeshBase::node_ref().

Referenced by stitching_helper().

162 {
163  return this->node_ref(i);
164 }
virtual const Node & node_ref(const dof_id_type i) const
Definition: mesh_base.h:434

◆ point_locator()

const PointLocatorBase & libMesh::MeshBase::point_locator ( ) const
inherited
Returns
A pointer to a PointLocatorBase object for this mesh, constructing a master PointLocator first if necessary.
Deprecated:
This should never be used in threaded or non-parallel_only code.

Definition at line 479 of file mesh_base.C.

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

480 {
481  libmesh_deprecated();
482 
483  if (_point_locator.get() == nullptr)
484  {
485  // PointLocator construction may not be safe within threads
486  libmesh_assert(!Threads::in_threads);
487 
489  }
490 
491  return *_point_locator;
492 }
bool in_threads
Definition: threads.C:31
std::unique_ptr< PointLocatorBase > _point_locator
Definition: mesh_base.h:1398
static std::unique_ptr< PointLocatorBase > build(PointLocatorType t, const MeshBase &mesh, const PointLocatorBase *master=nullptr)

◆ prepare_for_use()

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

Prepare a newly created (or read) mesh for use. This involves 4 steps: 1.) call find_neighbors() 2.) call partition() 3.) call renumber_nodes_and_elements() 4.) call cache_elem_dims()

The argument to skip renumbering is now deprecated - to prevent a mesh from being renumbered, set allow_renumbering(false).

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

Definition at line 152 of file mesh_base.C.

References libMesh::MeshBase::_allow_remote_element_removal, libMesh::MeshBase::_ghosting_functors, libMesh::MeshBase::_is_prepared, libMesh::MeshBase::_skip_renumber_nodes_and_elements, libMesh::MeshBase::allow_renumbering(), libMesh::MeshBase::cache_elem_dims(), libMesh::MeshBase::clear_point_locator(), libMesh::ParallelObject::comm(), libMesh::MeshBase::delete_remote_elements(), libMesh::MeshBase::detect_interior_parents(), libMesh::MeshBase::find_neighbors(), libMesh::MeshBase::is_serial(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_unique_ids(), libMesh::MeshBase::partition(), libMesh::MeshBase::renumber_nodes_and_elements(), and libMesh::MeshBase::update_parallel_id_counts().

Referenced by libMesh::UnstructuredMesh::all_first_order(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Subdivision::all_subdivision(), libMesh::MeshTools::Modification::all_tri(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::MeshRefinement::coarsen_elements(), libMesh::UnstructuredMesh::copy_nodes_and_elements(), libMesh::UnstructuredMesh::create_submesh(), libMesh::MeshTools::Modification::flatten(), libMesh::MeshTools::Subdivision::prepare_subdivision_mesh(), libMesh::GMVIO::read(), libMesh::UnstructuredMesh::read(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::MeshRefinement::refine_elements(), stitching_helper(), libMesh::BoundaryInfo::sync(), libMesh::TriangleInterface::triangulate(), libMesh::MeshRefinement::uniformly_coarsen(), and libMesh::MeshRefinement::uniformly_refine().

153 {
154  LOG_SCOPE("prepare_for_use()", "MeshBase");
155 
156  parallel_object_only();
157 
158  libmesh_assert(this->comm().verify(this->is_serial()));
159 
160  // A distributed mesh may have processors with no elements (or
161  // processors with no elements of higher dimension, if we ever
162  // support mixed-dimension meshes), but we want consistent
163  // mesh_dimension anyways.
164  //
165  // cache_elem_dims() should get the elem_dimensions() and
166  // mesh_dimension() correct later, and we don't need it earlier.
167 
168 
169  // Renumber the nodes and elements so that they in contiguous
170  // blocks. By default, _skip_renumber_nodes_and_elements is false.
171  //
172  // We may currently change that by passing
173  // skip_renumber_nodes_and_elements==true to this function, but we
174  // should use the allow_renumbering() accessor instead.
175  //
176  // Instances where you if prepare_for_use() should not renumber the nodes
177  // and elements include reading in e.g. an xda/r or gmv file. In
178  // this case, the ordering of the nodes may depend on an accompanying
179  // solution, and the node ordering cannot be changed.
180 
181  if (skip_renumber_nodes_and_elements)
182  {
183  libmesh_deprecated();
184  this->allow_renumbering(false);
185  }
186 
187  // Mesh modification operations might not leave us with consistent
188  // id counts, but our partitioner might need that consistency.
191  else
193 
194  // Let all the elements find their neighbors
195  if (!skip_find_neighbors)
196  this->find_neighbors();
197 
198  // The user may have set boundary conditions. We require that the
199  // boundary conditions were set consistently. Because we examine
200  // neighbors when evaluating non-raw boundary condition IDs, this
201  // assert is only valid when our neighbor links are in place.
202 #ifdef DEBUG
204 #endif
205 
206  // Search the mesh for all the dimensions of the elements
207  // and cache them.
208  this->cache_elem_dims();
209 
210  // Search the mesh for elements that have a neighboring element
211  // of dim+1 and set that element as the interior parent
212  this->detect_interior_parents();
213 
214  // Fix up node unique ids in case mesh generation code didn't take
215  // exceptional care to do so.
216  // MeshCommunication().make_node_unique_ids_parallel_consistent(*this);
217 
218  // We're going to still require that mesh generation code gets
219  // element unique ids consistent.
220 #if defined(DEBUG) && defined(LIBMESH_ENABLE_UNIQUE_ID)
222 #endif
223 
224  // Reset our PointLocator. Any old locator is invalidated any time
225  // the elements in the underlying elements in the mesh have changed,
226  // so we clear it here.
227  this->clear_point_locator();
228 
229  // Allow our GhostingFunctor objects to reinit if necessary.
230  // Do this before partitioning and redistributing, and before
231  // deleting remote elements.
232  for (auto & gf : _ghosting_functors)
233  {
234  libmesh_assert(gf);
235  gf->mesh_reinit();
236  }
237 
238  // Partition the mesh.
239  this->partition();
240 
241  // If we're using DistributedMesh, we'll probably want it
242  // parallelized.
244  this->delete_remote_elements();
245 
248 
249  // The mesh is now prepared for use.
250  _is_prepared = true;
251 
252 #if defined(DEBUG) && defined(LIBMESH_ENABLE_UNIQUE_ID)
255 #endif
256 }
bool _skip_renumber_nodes_and_elements
Definition: mesh_base.h:1431
void detect_interior_parents()
Definition: mesh_base.C:633
const Parallel::Communicator & comm() const
bool _allow_remote_element_removal
Definition: mesh_base.h:1439
std::set< GhostingFunctor * > _ghosting_functors
Definition: mesh_base.h:1475
virtual bool is_serial() const
Definition: mesh_base.h:154
virtual void find_neighbors(const bool reset_remote_elements=false, const bool reset_current_list=true)=0
virtual void update_parallel_id_counts()=0
void clear_point_locator()
Definition: mesh_base.C:517
void libmesh_assert_valid_boundary_ids(const MeshBase &mesh)
Definition: mesh_tools.C:1401
bool allow_renumbering() const
Definition: mesh_base.h:783
virtual void delete_remote_elements()
Definition: mesh_base.h:196
void cache_elem_dims()
Definition: mesh_base.C:574
void libmesh_assert_valid_unique_ids(const MeshBase &mesh)
Definition: mesh_tools.C:1641
virtual void renumber_nodes_and_elements()=0

◆ print_info()

void libMesh::MeshBase::print_info ( std::ostream &  os = libMesh::out) const
inherited

Prints relevant information about the mesh.

Definition at line 412 of file mesh_base.C.

References libMesh::MeshBase::get_info().

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

413 {
414  os << this->get_info()
415  << std::endl;
416 }
std::string get_info() const
Definition: mesh_base.C:378

◆ processor_id()

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

Definition at line 101 of file parallel_object.h.

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

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::EquationSystems::_read_impl(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::FEMSystem::assembly(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::DistributedMesh::clear(), libMesh::ExodusII_IO_Helper::close(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::compute_communication_map_parameters(), libMesh::Nemesis_IO_Helper::compute_internal_and_border_elems_and_internal_nodes(), libMesh::Nemesis_IO_Helper::compute_node_communication_maps(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::ExodusII_IO_Helper::create(), libMesh::DistributedMesh::delete_elem(), libMesh::DistributedMesh::delete_node(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DistributedMesh::DistributedMesh(), libMesh::DofMap::end_dof(), libMesh::DofMap::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::MeshFunction::find_element(), libMesh::MeshFunction::find_elements(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMap::first_dof(), libMesh::DofMap::first_old_dof(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::MeshBase::get_info(), libMesh::DofMap::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), libMesh::SparsityPattern::Build::handle_vi_vj(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::DistributedMesh::insert_elem(), libMesh::DofMap::is_evaluable(), libMesh::SparsityPattern::Build::join(), libMesh::DofMap::last_dof(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::DofMap::n_local_dofs(), libMesh::System::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::SparsityPattern::Build::operator()(), libMesh::DistributedMesh::own_node(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::Nemesis_IO_Helper::put_cmap_params(), libMesh::Nemesis_IO_Helper::put_elem_cmap(), libMesh::Nemesis_IO_Helper::put_elem_map(), libMesh::Nemesis_IO_Helper::put_loadbal_param(), libMesh::Nemesis_IO_Helper::put_node_cmap(), libMesh::Nemesis_IO_Helper::put_node_map(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_global_values(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::System::read_serialized_data(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::CheckpointIO::select_split_config(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::Parallel::Packing< T >::unpack(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::CheckpointIO::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), libMesh::System::write_header(), libMesh::ExodusII_IO::write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::UCDIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::System::write_serialized_data(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), libMesh::ExodusII_IO_Helper::write_timestep(), and libMesh::ExodusII_IO::write_timestep_discontinuous().

102  { return cast_int<processor_id_type>(_communicator.rank()); }
const Parallel::Communicator & _communicator
processor_id_type rank() const
Definition: communicator.h:173

◆ query_elem() [1/2]

virtual const Elem* libMesh::MeshBase::query_elem ( const dof_id_type  i) const
inlinevirtualinherited
Returns
A pointer to the $ i^{th} $ element, or nullptr if no such element exists in this processor's mesh data structure.
Deprecated:
Use the less confusingly-named query_elem_ptr() instead.

Definition at line 578 of file mesh_base.h.

References libMesh::MeshBase::query_elem_ptr().

579  {
580  libmesh_deprecated();
581  return this->query_elem_ptr(i);
582  }
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0

◆ query_elem() [2/2]

virtual Elem* libMesh::MeshBase::query_elem ( const dof_id_type  i)
inlinevirtualinherited
Returns
A writable pointer to the $ i^{th} $ element, or nullptr if no such element exists in this processor's mesh data structure.
Deprecated:
Use the less confusingly-named query_elem_ptr() instead.

Definition at line 592 of file mesh_base.h.

References libMesh::MeshBase::query_elem_ptr().

593  {
594  libmesh_deprecated();
595  return this->query_elem_ptr(i);
596  }
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0

◆ query_elem_ptr() [1/2]

const Elem * libMesh::ReplicatedMesh::query_elem_ptr ( const