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

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

#include <unstructured_mesh.h>

Inheritance diagram for libMesh::UnstructuredMesh:
[legend]

Public Types

typedef Predicates::multi_predicate Predicate
 We need an empty, generic class to act as a predicate for this and derived mesh classes. More...
 

Public Member Functions

 UnstructuredMesh (const Parallel::Communicator &comm_in, unsigned char dim=1)
 Constructor. More...
 
 UnstructuredMesh (unsigned char dim=1)
 Constructor which takes dim, the dimension of the mesh. More...
 
virtual ~UnstructuredMesh ()
 Destructor. More...
 
virtual void read (const std::string &name, void *mesh_data=libmesh_nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false) libmesh_override
 Reads the file specified by name. More...
 
virtual void write (const std::string &name) libmesh_override
 Write the file specified by name. More...
 
void write (const std::string &name, const std::vector< Number > &values, const std::vector< std::string > &variable_names)
 Write to the file specified by name. More...
 
virtual void all_first_order () libmesh_override
 Converts a mesh with higher-order elements into a mesh with linear elements. More...
 
virtual void all_second_order (const bool full_ordered=true) libmesh_override
 Converts a (conforming, non-refined) mesh with linear elements into a mesh with second-order elements. More...
 
void create_pid_mesh (UnstructuredMesh &pid_mesh, const processor_id_type pid) const
 Generates a new mesh containing all the elements which are assigned to processor pid. More...
 
void create_submesh (UnstructuredMesh &new_mesh, const_element_iterator &it, const const_element_iterator &it_end) const
 Constructs a mesh called "new_mesh" from the current mesh by iterating over the elements between it and it_end and adding them to the new mesh. More...
 
virtual void copy_nodes_and_elements (const UnstructuredMesh &other_mesh, const bool skip_find_neighbors=false)
 Deep copy of another unstructured mesh class (used by subclass copy constructors) More...
 
virtual void find_neighbors (const bool reset_remote_elements=false, const bool reset_current_list=true) libmesh_override
 Other functions from MeshBase requiring re-definition. More...
 
virtual bool contract () libmesh_override
 Delete subactive (i.e. More...
 
virtual UniquePtr< MeshBaseclone () const =0
 Virtual "copy constructor". More...
 
virtual UniquePtr< Partitioner > & partitioner ()
 A partitioner to use at each prepare_for_use() More...
 
const BoundaryInfoget_boundary_info () const
 The information about boundary ids on the mesh. More...
 
BoundaryInfoget_boundary_info ()
 Writable information about boundary ids on the mesh. More...
 
virtual void clear ()
 Deletes all the data that are currently stored. More...
 
bool is_prepared () const
 
virtual bool is_serial () const
 
virtual bool is_serial_on_zero () const
 
virtual void set_distributed ()
 Asserts that not all elements and nodes of the mesh necessarily exist on the current processor. More...
 
virtual bool is_replicated () const
 
virtual void allgather ()
 Gathers all elements and nodes of the mesh onto every processor. More...
 
virtual void gather_to_zero ()
 Gathers all elements and nodes of the mesh onto processor zero. More...
 
virtual void delete_remote_elements ()
 When supported, deletes all nonlocal elements of the mesh except for "ghosts" which touch a local element, and deletes all nodes which are not part of a local or ghost element. More...
 
unsigned int mesh_dimension () const
 
void set_mesh_dimension (unsigned char d)
 Resets the logical dimension of the mesh. More...
 
const std::set< unsigned char > & elem_dimensions () const
 
unsigned int spatial_dimension () const
 
void set_spatial_dimension (unsigned char d)
 Sets the "spatial dimension" of the Mesh. More...
 
virtual dof_id_type n_nodes () const =0
 
virtual dof_id_type parallel_n_nodes () const =0
 
dof_id_type n_nodes_on_proc (const processor_id_type proc) const
 
dof_id_type n_local_nodes () const
 
dof_id_type n_unpartitioned_nodes () const
 
virtual dof_id_type max_node_id () const =0
 
unique_id_type next_unique_id ()
 
void set_next_unique_id (unique_id_type id)
 Sets the next unique id to be used. More...
 
virtual void reserve_nodes (const dof_id_type nn)=0
 Reserves space for a known number of nodes. More...
 
virtual dof_id_type n_elem () const =0
 
virtual dof_id_type parallel_n_elem () const =0
 
virtual dof_id_type max_elem_id () const =0
 
virtual unique_id_type parallel_max_unique_id () const =0
 
virtual void reserve_elem (const dof_id_type ne)=0
 Reserves space for a known number of elements. More...
 
virtual void update_parallel_id_counts ()=0
 Updates parallel caches so that methods like n_elem() accurately reflect changes on other processors. More...
 
virtual dof_id_type n_active_elem () const =0
 
dof_id_type n_elem_on_proc (const processor_id_type proc) const
 
dof_id_type n_local_elem () const
 
dof_id_type n_unpartitioned_elem () const
 
dof_id_type n_active_elem_on_proc (const processor_id_type proc) const
 
dof_id_type n_active_local_elem () const
 
dof_id_type n_sub_elem () const
 
dof_id_type n_active_sub_elem () const
 Same as n_sub_elem(), but only counts active elements. More...
 
virtual const Pointpoint (const dof_id_type i) const =0
 
virtual const Nodenode_ref (const dof_id_type i) const
 
virtual Nodenode_ref (const dof_id_type i)
 
virtual const Nodenode (const dof_id_type i) const
 
virtual Nodenode (const dof_id_type i)
 
virtual const Nodenode_ptr (const dof_id_type i) const =0
 
virtual Nodenode_ptr (const dof_id_type i)=0
 
virtual const Nodequery_node_ptr (const dof_id_type i) const =0
 
virtual Nodequery_node_ptr (const dof_id_type i)=0
 
virtual const Elemelem_ref (const dof_id_type i) const
 
virtual Elemelem_ref (const dof_id_type i)
 
virtual const Elemelem_ptr (const dof_id_type i) const =0
 
virtual Elemelem_ptr (const dof_id_type i)=0
 
virtual const Elemelem (const dof_id_type i) const
 
virtual Elemelem (const dof_id_type i)
 
virtual const Elemquery_elem_ptr (const dof_id_type i) const =0
 
virtual Elemquery_elem_ptr (const dof_id_type i)=0
 
virtual const Elemquery_elem (const dof_id_type i) const
 
virtual Elemquery_elem (const dof_id_type i)
 
virtual Nodeadd_point (const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
 Add a new Node at Point p to the end of the vertex array, with processor_id procid. More...
 
virtual Nodeadd_node (Node *n)=0
 Add Node n to the end of the vertex array. More...
 
virtual Nodeinsert_node (Node *n)=0
 Insert Node n into the Mesh at a location consistent with n->id(), allocating extra storage if necessary. More...
 
virtual void delete_node (Node *n)=0
 Removes the Node n from the mesh. More...
 
virtual void renumber_node (dof_id_type old_id, dof_id_type new_id)=0
 Changes the id of node old_id, both by changing node(old_id)->id() and by moving node(old_id) in the mesh's internal container. More...
 
virtual Elemadd_elem (Elem *e)=0
 Add elem e to the end of the element array. More...
 
virtual Eleminsert_elem (Elem *e)=0
 Insert elem e to the element array, preserving its id and replacing/deleting any existing element with the same id. More...
 
virtual void delete_elem (Elem *e)=0
 Removes element e from the mesh. More...
 
virtual void renumber_elem (dof_id_type old_id, dof_id_type new_id)=0
 Changes the id of element old_id, both by changing elem(old_id)->id() and by moving elem(old_id) in the mesh's internal container. More...
 
virtual void renumber_nodes_and_elements ()=0
 After partitioning a mesh it is useful to renumber the nodes and elements so that they lie in contiguous blocks on the processors. More...
 
virtual void fix_broken_node_and_element_numbering ()=0
 There is no reason for a user to ever call this function. More...
 
void prepare_for_use (const bool skip_renumber_nodes_and_elements=false, const bool skip_find_neighbors=false)
 Prepare a newly created (or read) mesh for use. More...
 
virtual void partition (const unsigned int n_parts)
 Call the default partitioner (currently metis_partition()). More...
 
void partition ()
 
virtual void redistribute ()
 Redistribute elements between processors. More...
 
virtual void update_post_partitioning ()
 Recalculate any cached data after elements and nodes have been repartitioned. More...
 
void allow_renumbering (bool allow)
 If false is passed in then this mesh will no longer be renumbered when being prepared for use. More...
 
bool allow_renumbering () const
 
void allow_remote_element_removal (bool allow)
 If false is passed in then this mesh will no longer have remote elements deleted when being prepared for use; i.e. More...
 
bool allow_remote_element_removal () const
 
void skip_partitioning (bool skip)
 If true is passed in then this mesh will no longer be (re)partitioned. More...
 
bool skip_partitioning () const
 
void add_ghosting_functor (GhostingFunctor &ghosting_functor)
 Adds a functor which can specify ghosting requirements for use on distributed meshes. More...
 
void remove_ghosting_functor (GhostingFunctor &ghosting_functor)
 Removes a functor which was previously added to the set of ghosting functors. More...
 
std::set< GhostingFunctor * >::const_iterator ghosting_functors_begin () const
 Beginning of range of ghosting functors. More...
 
std::set< GhostingFunctor * >::const_iterator ghosting_functors_end () const
 End of range of ghosting functors. More...
 
void subdomain_ids (std::set< subdomain_id_type > &ids) const
 Constructs a list of all subdomain identifiers in the global mesh. More...
 
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
 Prints relevant information about the mesh. More...
 
unsigned int recalculate_n_partitions ()
 In a few (very rare) cases, the user may have manually tagged the elements with specific processor IDs by hand, without using a partitioner. More...
 
const PointLocatorBasepoint_locator () const
 
UniquePtr< PointLocatorBasesub_point_locator () const
 
void clear_point_locator ()
 Releases the current PointLocator object. More...
 
void set_count_lower_dim_elems_in_point_locator (bool count_lower_dim_elems)
 In the point locator, do we count lower dimensional elements when we refine point locator regions? This is relevant in tree-based point locators, for example. More...
 
bool get_count_lower_dim_elems_in_point_locator () const
 Get the current value of _count_lower_dim_elems_in_point_locator. More...
 
virtual void libmesh_assert_valid_parallel_ids () const
 Verify id and processor_id consistency of our elements and nodes containers. More...
 
std::string & subdomain_name (subdomain_id_type id)
 
const std::string & subdomain_name (subdomain_id_type id) const
 
subdomain_id_type get_id_by_name (const std::string &name) const
 
virtual element_iterator elements_begin ()=0
 Iterate over all the elements in the Mesh. More...
 
virtual const_element_iterator elements_begin () const =0
 
virtual element_iterator elements_end ()=0
 
virtual const_element_iterator elements_end () const =0
 
virtual SimpleRange< element_iteratorelement_ptr_range ()=0
 
virtual SimpleRange< const_element_iteratorelement_ptr_range () const =0
 
virtual element_iterator ancestor_elements_begin ()=0
 Iterate over elements for which elem->ancestor() is true. More...
 
virtual const_element_iterator ancestor_elements_begin () const =0
 
virtual element_iterator ancestor_elements_end ()=0
 
virtual const_element_iterator ancestor_elements_end () const =0
 
virtual element_iterator subactive_elements_begin ()=0
 Iterate over elements for which elem->subactive() is true. More...
 
virtual const_element_iterator subactive_elements_begin () const =0
 
virtual element_iterator subactive_elements_end ()=0
 
virtual const_element_iterator subactive_elements_end () const =0
 
virtual element_iterator semilocal_elements_begin ()=0
 Iterate over elements for which elem->is_semilocal() is true for the current processor. More...
 
virtual const_element_iterator semilocal_elements_begin () const =0
 
virtual element_iterator semilocal_elements_end ()=0
 
virtual const_element_iterator semilocal_elements_end () const =0
 
virtual element_iterator facelocal_elements_begin ()=0
 Iterate over elements which are on or have a neighbor on the current processor. More...
 
virtual const_element_iterator facelocal_elements_begin () const =0
 
virtual element_iterator facelocal_elements_end ()=0
 
virtual const_element_iterator facelocal_elements_end () const =0
 
virtual element_iterator level_elements_begin (unsigned int level)=0
 Iterate over elements of a given level. More...
 
virtual const_element_iterator level_elements_begin (unsigned int level) const =0
 
virtual element_iterator level_elements_end (unsigned int level)=0
 
virtual const_element_iterator level_elements_end (unsigned int level) const =0
 
virtual element_iterator pid_elements_begin (processor_id_type proc_id)=0
 Iterate over all elements with a specified processor id. More...
 
virtual const_element_iterator pid_elements_begin (processor_id_type proc_id) const =0
 
virtual element_iterator pid_elements_end (processor_id_type proc_id)=0
 
virtual const_element_iterator pid_elements_end (processor_id_type proc_id) const =0
 
virtual element_iterator type_elements_begin (ElemType type)=0
 Iterate over all elements with a specified geometric type. More...
 
virtual const_element_iterator type_elements_begin (ElemType type) const =0
 
virtual element_iterator type_elements_end (ElemType type)=0
 
virtual const_element_iterator type_elements_end (ElemType type) const =0
 
virtual element_iterator unpartitioned_elements_begin ()=0
 Iterate over unpartitioned elements in the Mesh. More...
 
virtual const_element_iterator unpartitioned_elements_begin () const =0
 
virtual element_iterator unpartitioned_elements_end ()=0
 
virtual const_element_iterator unpartitioned_elements_end () const =0
 
virtual element_iterator active_unpartitioned_elements_begin ()=0
 Iterate over active unpartitioned elements in the Mesh. More...
 
virtual const_element_iterator active_unpartitioned_elements_begin () const =0
 
virtual element_iterator active_unpartitioned_elements_end ()=0
 
virtual const_element_iterator active_unpartitioned_elements_end () const =0
 
virtual element_iterator ghost_elements_begin ()=0
 Iterate over "ghost" elements in the Mesh. More...
 
virtual const_element_iterator ghost_elements_begin () const =0
 
virtual element_iterator ghost_elements_end ()=0
 
virtual const_element_iterator ghost_elements_end () const =0
 
virtual element_iterator evaluable_elements_begin (const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint)=0
 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. More...
 
virtual const_element_iterator evaluable_elements_begin (const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint) const =0
 
virtual element_iterator evaluable_elements_end (const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint)=0
 
virtual const_element_iterator evaluable_elements_end (const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint) const =0
 
virtual element_iterator flagged_elements_begin (unsigned char rflag)=0
 Iterate over all elements with a specified refinement flag. More...
 
virtual const_element_iterator flagged_elements_begin (unsigned char rflag) const =0
 
virtual element_iterator flagged_elements_end (unsigned char rflag)=0
 
virtual const_element_iterator flagged_elements_end (unsigned char rflag) const =0
 
virtual element_iterator flagged_pid_elements_begin (unsigned char rflag, processor_id_type pid)=0
 Iterate over all elements with a specified refinement flag on a specified processor. More...
 
virtual const_element_iterator flagged_pid_elements_begin (unsigned char rflag, processor_id_type pid) const =0
 
virtual element_iterator flagged_pid_elements_end (unsigned char rflag, processor_id_type pid)=0
 
virtual const_element_iterator flagged_pid_elements_end (unsigned char rflag, processor_id_type pid) const =0
 
virtual element_iterator active_elements_begin ()=0
 Active, local, and negation forms of the element iterators described above. More...
 
virtual const_element_iterator active_elements_begin () const =0
 
virtual element_iterator active_elements_end ()=0
 
virtual const_element_iterator active_elements_end () const =0
 
virtual SimpleRange< element_iteratoractive_element_ptr_range ()=0
 
virtual SimpleRange< const_element_iteratoractive_element_ptr_range () const =0
 
virtual element_iterator local_elements_begin ()=0
 
virtual const_element_iterator local_elements_begin () const =0
 
virtual element_iterator local_elements_end ()=0
 
virtual const_element_iterator local_elements_end () const =0
 
virtual element_iterator active_semilocal_elements_begin ()=0
 
virtual const_element_iterator active_semilocal_elements_begin () const =0
 
virtual element_iterator active_semilocal_elements_end ()=0
 
virtual const_element_iterator active_semilocal_elements_end () const =0
 
virtual element_iterator active_type_elements_begin (ElemType type)=0
 
virtual const_element_iterator active_type_elements_begin (ElemType type) const =0
 
virtual element_iterator active_type_elements_end (ElemType type)=0
 
virtual const_element_iterator active_type_elements_end (ElemType type) const =0
 
virtual element_iterator active_pid_elements_begin (processor_id_type proc_id)=0
 
virtual const_element_iterator active_pid_elements_begin (processor_id_type proc_id) const =0
 
virtual element_iterator active_pid_elements_end (processor_id_type proc_id)=0
 
virtual const_element_iterator active_pid_elements_end (processor_id_type proc_id) const =0
 
virtual element_iterator active_subdomain_elements_begin (subdomain_id_type subdomain_id)=0
 
virtual const_element_iterator active_subdomain_elements_begin (subdomain_id_type subdomain_id) const =0
 
virtual element_iterator active_subdomain_elements_end (subdomain_id_type subdomain_id)=0
 
virtual const_element_iterator active_subdomain_elements_end (subdomain_id_type subdomain_id) const =0
 
virtual element_iterator active_subdomain_set_elements_begin (std::set< subdomain_id_type > ss)=0
 
virtual const_element_iterator active_subdomain_set_elements_begin (std::set< subdomain_id_type > ss) const =0
 
virtual element_iterator active_subdomain_set_elements_end (std::set< subdomain_id_type > ss)=0
 
virtual const_element_iterator active_subdomain_set_elements_end (std::set< subdomain_id_type > ss) const =0
 
virtual element_iterator active_local_subdomain_elements_begin (subdomain_id_type subdomain_id)=0
 
virtual const_element_iterator active_local_subdomain_elements_begin (subdomain_id_type subdomain_id) const =0
 
virtual element_iterator active_local_subdomain_elements_end (subdomain_id_type subdomain_id)=0
 
virtual const_element_iterator active_local_subdomain_elements_end (subdomain_id_type subdomain_id) const =0
 
virtual element_iterator local_level_elements_begin (unsigned int level)=0
 
virtual const_element_iterator local_level_elements_begin (unsigned int level) const =0
 
virtual element_iterator local_level_elements_end (unsigned int level)=0
 
virtual const_element_iterator local_level_elements_end (unsigned int level) const =0
 
virtual element_iterator local_not_level_elements_begin (unsigned int level)=0
 
virtual const_element_iterator local_not_level_elements_begin (unsigned int level) const =0
 
virtual element_iterator local_not_level_elements_end (unsigned int level)=0
 
virtual const_element_iterator local_not_level_elements_end (unsigned int level) const =0
 
virtual element_iterator not_level_elements_begin (unsigned int level)=0
 
virtual const_element_iterator not_level_elements_begin (unsigned int level) const =0
 
virtual element_iterator not_level_elements_end (unsigned int level)=0
 
virtual const_element_iterator not_level_elements_end (unsigned int level) const =0
 
virtual element_iterator active_local_elements_begin ()=0
 
virtual const_element_iterator active_local_elements_begin () const =0
 
virtual element_iterator active_local_elements_end ()=0
 
virtual const_element_iterator active_local_elements_end () const =0
 
virtual SimpleRange< element_iteratoractive_local_element_ptr_range ()=0
 
virtual SimpleRange< const_element_iteratoractive_local_element_ptr_range () const =0
 
virtual element_iterator active_not_local_elements_begin ()=0
 
virtual const_element_iterator active_not_local_elements_begin () const =0
 
virtual element_iterator active_not_local_elements_end ()=0
 
virtual const_element_iterator active_not_local_elements_end () const =0
 
virtual element_iterator not_local_elements_begin ()=0
 
virtual const_element_iterator not_local_elements_begin () const =0
 
virtual element_iterator not_local_elements_end ()=0
 
virtual const_element_iterator not_local_elements_end () const =0
 
virtual element_iterator not_subactive_elements_begin ()=0
 
virtual const_element_iterator not_subactive_elements_begin () const =0
 
virtual element_iterator not_subactive_elements_end ()=0
 
virtual const_element_iterator not_subactive_elements_end () const =0
 
virtual element_iterator not_active_elements_begin ()=0
 
virtual const_element_iterator not_active_elements_begin () const =0
 
virtual element_iterator not_active_elements_end ()=0
 
virtual const_element_iterator not_active_elements_end () const =0
 
virtual element_iterator not_ancestor_elements_begin ()=0
 
virtual const_element_iterator not_ancestor_elements_begin () const =0
 
virtual element_iterator not_ancestor_elements_end ()=0
 
virtual const_element_iterator not_ancestor_elements_end () const =0
 
virtual node_iterator nodes_begin ()=0
 Iterate over all the nodes in the Mesh. More...
 
virtual const_node_iterator nodes_begin () const =0
 
virtual node_iterator nodes_end ()=0
 
virtual const_node_iterator nodes_end () const =0
 
virtual SimpleRange< node_iteratornode_ptr_range ()=0
 
virtual SimpleRange< const_node_iteratornode_ptr_range () const =0
 
virtual node_iterator active_nodes_begin ()=0
 Iterate over only the active nodes in the Mesh. More...
 
virtual const_node_iterator active_nodes_begin () const =0
 
virtual node_iterator active_nodes_end ()=0
 
virtual const_node_iterator active_nodes_end () const =0
 
virtual node_iterator local_nodes_begin ()=0
 Iterate over local nodes (nodes whose processor_id() matches the current processor). More...
 
virtual const_node_iterator local_nodes_begin () const =0
 
virtual node_iterator local_nodes_end ()=0
 
virtual const_node_iterator local_nodes_end () const =0
 
virtual SimpleRange< node_iteratorlocal_node_ptr_range ()=0
 
virtual SimpleRange< const_node_iteratorlocal_node_ptr_range () const =0
 
virtual node_iterator pid_nodes_begin (processor_id_type proc_id)=0
 Iterate over nodes with processor_id() == proc_id. More...
 
virtual const_node_iterator pid_nodes_begin (processor_id_type proc_id) const =0
 
virtual node_iterator pid_nodes_end (processor_id_type proc_id)=0
 
virtual const_node_iterator pid_nodes_end (processor_id_type proc_id) const =0
 
virtual node_iterator bid_nodes_begin (boundary_id_type bndry_id)=0
 Iterate over nodes for which BoundaryInfo::has_boundary_id(node, bndry_id) is true. More...
 
virtual const_node_iterator bid_nodes_begin (boundary_id_type bndry_id) const =0
 
virtual node_iterator bid_nodes_end (boundary_id_type bndry_id)=0
 
virtual const_node_iterator bid_nodes_end (boundary_id_type bndry_id) const =0
 
virtual node_iterator bnd_nodes_begin ()=0
 Iterate over nodes for which BoundaryInfo::n_boundary_ids(node) > 0. More...
 
virtual const_node_iterator bnd_nodes_begin () const =0
 
virtual node_iterator bnd_nodes_end ()=0
 
virtual const_node_iterator bnd_nodes_end () const =0
 
virtual node_iterator evaluable_nodes_begin (const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint)=0
 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. More...
 
virtual const_node_iterator evaluable_nodes_begin (const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint) const =0
 
virtual node_iterator evaluable_nodes_end (const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint)=0
 
virtual const_node_iterator evaluable_nodes_end (const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint) const =0
 
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 ()
 Search the mesh and cache the different dimensions of the elements present in the mesh. More...
 
void detect_interior_parents ()
 Search the mesh for elements that have a neighboring element of dim+1 and set that element as the interior parent. More...
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Public Attributes

UniquePtr< BoundaryInfoboundary_info
 This class holds the boundary information. More...
 

Protected Member Functions

unsigned intset_n_partitions ()
 

Protected Attributes

unsigned int _n_parts
 The number of partitions the mesh has. More...
 
bool _is_prepared
 Flag indicating if the mesh has been prepared for use. More...
 
UniquePtr< PointLocatorBase_point_locator
 A PointLocator class for this mesh. More...
 
bool _count_lower_dim_elems_in_point_locator
 Do we count lower dimensional elements in point locator refinement? This is relevant in tree-based point locators, for example. More...
 
UniquePtr< Partitioner_partitioner
 A partitioner to use at each prepare_for_use(). More...
 
unique_id_type _next_unique_id
 The next available unique id for assigning ids to DOF objects. More...
 
bool _skip_partitioning
 If this is true then no partitioning should be done. More...
 
bool _skip_renumber_nodes_and_elements
 If this is true then renumbering will be kept to a minimum. More...
 
bool _allow_remote_element_removal
 If this is false then even on DistributedMesh remote elements will not be deleted during mesh preparation. More...
 
std::map< subdomain_id_type, std::string > _block_id_to_name
 This structure maintains the mapping of named blocks for file formats that support named blocks. More...
 
std::set< unsigned char > _elem_dims
 We cache the dimension of the elements present in the mesh. More...
 
unsigned char _spatial_dimension
 The "spatial dimension" of the Mesh. More...
 
UniquePtr< GhostingFunctor_default_ghosting
 The default geometric GhostingFunctor, used to implement standard libMesh element ghosting behavior. More...
 
std::set< GhostingFunctor * > _ghosting_functors
 The list of all GhostingFunctor objects to be used when distributing a DistributedMesh. More...
 
const Parallel::Communicator_communicator
 

Detailed Description

The UnstructuredMesh class is derived from the MeshBase class.

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

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

Definition at line 48 of file unstructured_mesh.h.

Member Typedef Documentation

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

Definition at line 889 of file mesh_base.h.

Constructor & Destructor Documentation

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

Constructor.

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

Definition at line 51 of file unstructured_mesh.C.

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

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

52  :
53  MeshBase (comm_in,d)
54 {
56 }
libmesh_assert(j)
MeshBase(const Parallel::Communicator &comm_in, unsigned char dim=1)
Constructor.
Definition: mesh_base.C:49
bool initialized()
Checks that library initialization has been done.
Definition: libmesh.C:274
libMesh::UnstructuredMesh::UnstructuredMesh ( unsigned char  dim = 1)

Constructor which takes dim, the dimension of the mesh.

The mesh dimension can be changed (and may automatically be changed by mesh generation/loading) later.

Deprecated:
LIBMESH_DISABLE_COMMWORLD is now the default, use the constructor that takes a Parallel::Communicator instead.

Definition at line 62 of file unstructured_mesh.C.

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

62  :
63  MeshBase (d)
64 {
65  libmesh_deprecated();
67 }
libmesh_assert(j)
MeshBase(const Parallel::Communicator &comm_in, unsigned char dim=1)
Constructor.
Definition: mesh_base.C:49
bool initialized()
Checks that library initialization has been done.
Definition: libmesh.C:274
libMesh::UnstructuredMesh::~UnstructuredMesh ( )
virtual

Destructor.

Definition at line 217 of file unstructured_mesh.C.

References libMesh::closed().

218 {
219  // this->clear (); // Nothing to clear at this level
220 
221  libmesh_exceptionless_assert (!libMesh::closed());
222 }
bool closed()
Checks that the library has been closed.
Definition: libmesh.C:281

Member Function Documentation

virtual SimpleRange<element_iterator> libMesh::MeshBase::active_element_ptr_range ( )
pure virtualinherited

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

Referenced by libMesh::MeshRefinement::_refine_elements(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::AbaqusIO::assign_sideset_ids(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::ParmetisPartitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_side_list_from_node_list(), libMesh::MeshTools::Generation::build_sphere(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshTools::Modification::distort(), DMlibMeshSetSystem_libMesh(), libMesh::TecplotIO::elem_dimension(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::LocationMap< T >::fill(), libMesh::MeshTools::find_boundary_nodes(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_error_tolerance(), libMesh::MeshRefinement::flag_elements_by_mean_stddev(), libMesh::MeshTools::Modification::flatten(), libMesh::BoundaryInfo::get_side_and_node_maps(), libMesh::UNVIO::groups_in(), libMesh::ExodusII_IO_Helper::initialize(), LinearElasticityWithContact::initialize_contact_load_paths(), libMesh::DofMap::invalidate_dofs(), libMesh::MeshTools::libmesh_assert_valid_elem_ids(), libMesh::MeshBase::libmesh_assert_valid_parallel_ids(), 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::MeshRefinement::make_refinement_compatible(), AugmentSparsityOnInterface::mesh_reinit(), LinearElasticityWithContact::move_mesh(), libMesh::PointLocatorTree::perform_fuzzy_linear_search(), libMesh::PointLocatorTree::perform_linear_search(), libMesh::VariationalMeshSmoother::readgr(), libMesh::DofMap::reinit(), libMesh::HPSingularity::select_refinement(), libMesh::Partitioner::set_node_processor_ids(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::Tree< N >::Tree(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::MeshRefinement::uniformly_p_coarsen(), libMesh::MeshRefinement::uniformly_p_refine(), libMesh::MeshRefinement::uniformly_refine(), libMesh::FroIO::write(), libMesh::PostscriptIO::write(), libMesh::TetGenIO::write(), libMesh::MEDITIO::write_ascii(), libMesh::TecplotIO::write_ascii(), libMesh::GMVIO::write_ascii_new_impl(), libMesh::GMVIO::write_ascii_old_impl(), libMesh::TecplotIO::write_binary(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::GmshIO::write_post(), and libMesh::GnuPlotIO::write_solution().

virtual SimpleRange<const_element_iterator> libMesh::MeshBase::active_element_ptr_range ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::active_elements_begin ( )
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::active_elements_begin ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::active_elements_end ( )
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::active_elements_end ( ) const
pure virtualinherited
virtual SimpleRange<element_iterator> libMesh::MeshBase::active_local_element_ptr_range ( )
pure virtualinherited

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

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::MeshRefinement::_refine_elements(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), assemble(), LinearElasticity::assemble(), assemble_1D(), AssembleOptimization::assemble_A_and_F(), assemble_biharmonic(), assemble_cd(), assemble_elasticity(), assemble_ellipticdg(), assemble_helmholtz(), assemble_laplace(), assemble_mass(), assemble_matrices(), assemble_poisson(), assemble_shell(), assemble_stokes(), assemble_wave(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::ParmetisPartitioner::build_graph(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::VTKIO::cells_to_vtk(), libMesh::Nemesis_IO_Helper::compute_internal_and_border_elems_and_internal_nodes(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), compute_stresses(), LinearElasticity::compute_stresses(), libMesh::MeshRefinement::create_parent_error_vector(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::MeshTools::find_hanging_nodes_and_parents(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::EquationSystems::get_solution(), libMesh::LaplaceMeshSmoother::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), integrate_function(), LaplaceYoung::jacobian(), libMesh::MeshBase::libmesh_assert_valid_parallel_ids(), libMesh::DofMap::local_variable_indices(), libMesh::DofMap::max_constraint_error(), libMesh::FEMSystem::mesh_position_get(), libMesh::FEMSystem::mesh_position_set(), libMesh::MeshTools::n_active_local_levels(), libMesh::PointLocatorTree::perform_fuzzy_linear_search(), libMesh::PointLocatorTree::perform_linear_search(), libMesh::ErrorVector::plot_error(), LaplaceYoung::residual(), libMesh::HPCoarsenTest::select_refinement(), libMesh::MeshRefinement::test_level_one(), libMesh::MeshRefinement::test_unflagged(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::BoundaryVolumeSolutionTransfer::transfer_volume_boundary(), libMesh::Tree< N >::Tree(), libMesh::RBEIMConstruction::truth_solve(), libMesh::EnsightIO::write_geometry_ascii(), libMesh::EnsightIO::write_scalar_ascii(), libMesh::EnsightIO::write_vector_ascii(), and libMesh::System::zero_variable().

virtual SimpleRange<const_element_iterator> libMesh::MeshBase::active_local_element_ptr_range ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::active_local_elements_begin ( )
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::active_local_elements_begin ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::active_local_elements_end ( )
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::active_local_elements_end ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::active_local_subdomain_elements_begin ( subdomain_id_type  subdomain_id)
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::active_local_subdomain_elements_begin ( subdomain_id_type  subdomain_id) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::active_local_subdomain_elements_end ( subdomain_id_type  subdomain_id)
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::active_local_subdomain_elements_end ( subdomain_id_type  subdomain_id) const
pure virtualinherited
virtual node_iterator libMesh::MeshBase::active_nodes_begin ( )
pure virtualinherited

Iterate over only the active nodes in the Mesh.

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

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

virtual const_node_iterator libMesh::MeshBase::active_nodes_begin ( ) const
pure virtualinherited
virtual node_iterator libMesh::MeshBase::active_nodes_end ( )
pure virtualinherited
virtual const_node_iterator libMesh::MeshBase::active_nodes_end ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::active_not_local_elements_begin ( )
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::active_not_local_elements_begin ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::active_not_local_elements_end ( )
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::active_not_local_elements_end ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::active_pid_elements_begin ( processor_id_type  proc_id)
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::active_pid_elements_begin ( processor_id_type  proc_id) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::active_pid_elements_end ( processor_id_type  proc_id)
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::active_pid_elements_end ( processor_id_type  proc_id) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::active_semilocal_elements_begin ( )
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::active_semilocal_elements_begin ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::active_semilocal_elements_end ( )
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::active_semilocal_elements_end ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::active_subdomain_elements_begin ( subdomain_id_type  subdomain_id)
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::active_subdomain_elements_begin ( subdomain_id_type  subdomain_id) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::active_subdomain_elements_end ( subdomain_id_type  subdomain_id)
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::active_subdomain_elements_end ( subdomain_id_type  subdomain_id) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::active_subdomain_set_elements_begin ( std::set< subdomain_id_type ss)
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::active_subdomain_set_elements_begin ( std::set< subdomain_id_type ss) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::active_subdomain_set_elements_end ( std::set< subdomain_id_type ss)
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::active_subdomain_set_elements_end ( std::set< subdomain_id_type ss) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::active_type_elements_begin ( ElemType  type)
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::active_type_elements_begin ( ElemType  type) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::active_type_elements_end ( ElemType  type)
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::active_type_elements_end ( ElemType  type) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::active_unpartitioned_elements_begin ( )
pure virtualinherited

Iterate over active unpartitioned elements in the Mesh.

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

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

virtual const_element_iterator libMesh::MeshBase::active_unpartitioned_elements_begin ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::active_unpartitioned_elements_end ( )
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::active_unpartitioned_elements_end ( ) const
pure virtualinherited
virtual Elem* libMesh::MeshBase::add_elem ( Elem e)
pure virtualinherited

Add elem e to the end of the element array.

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

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

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

Referenced by libMesh::GMVIO::_read_one_cell(), libMesh::MeshTools::Subdivision::add_boundary_ghosts(), LinearElasticityWithContact::add_contact_edge_elements(), add_cube_convex_hull_to_mesh(), libMesh::MeshRefinement::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::MeshTools::Modification::all_tri(), libMesh::MeshTools::Generation::build_cube(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::MeshTools::Generation::build_sphere(), copy_nodes_and_elements(), libMesh::TriangleWrapper::copy_tri_to_mesh(), create_submesh(), libMesh::UNVIO::elements_in(), libMesh::MeshTools::Modification::flatten(), libMesh::mesh_inserter_iterator< T >::operator=(), libMesh::TetGenMeshInterface::pointset_convexhull(), libMesh::MeshBase::query_elem(), libMesh::Nemesis_IO::read(), libMesh::ExodusII_IO::read(), libMesh::VTKIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::AbaqusIO::read_elements(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::OFFIO::read_stream(), libMesh::MatlabIO::read_stream(), libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole(), and libMesh::TetGenMeshInterface::triangulate_pointset().

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

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

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

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

Definition at line 786 of file mesh_base.h.

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

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

787  { _ghosting_functors.insert(&ghosting_functor); }
std::set< GhostingFunctor * > _ghosting_functors
The list of all GhostingFunctor objects to be used when distributing a DistributedMesh.
Definition: mesh_base.h:1433
virtual Node* libMesh::MeshBase::add_node ( Node n)
pure virtualinherited

Add Node n to the end of the vertex array.

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

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

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

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

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

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

Referenced by libMesh::MeshTools::Subdivision::add_boundary_ghosts(), add_cube_convex_hull_to_mesh(), libMesh::MeshRefinement::add_node(), all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::MeshTools::Generation::build_cube(), libMesh::MeshTools::Generation::build_delaunay_square(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::MeshTools::Generation::build_sphere(), copy_nodes_and_elements(), libMesh::TriangleWrapper::copy_tri_to_mesh(), create_submesh(), libMesh::UNVIO::nodes_in(), libMesh::mesh_inserter_iterator< T >::operator=(), libMesh::MeshBase::query_elem(), libMesh::Nemesis_IO::read(), libMesh::ExodusII_IO::read(), libMesh::VTKIO::read(), libMesh::AbaqusIO::read_nodes(), libMesh::CheckpointIO::read_nodes(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::OFFIO::read_stream(), libMesh::MatlabIO::read_stream(), libMesh::BoundaryInfo::sync(), libMesh::TriangleInterface::triangulate(), and libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole().

void libMesh::UnstructuredMesh::all_first_order ( )
virtual

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

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

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

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

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

Implements libMesh::MeshBase.

Definition at line 283 of file mesh_modification.C.

References libMesh::MeshBase::_is_prepared, libMesh::Elem::add_child(), libMesh::Elem::build(), libMesh::Elem::child_ptr(), libMesh::BoundaryInfo::copy_boundary_ids(), libMesh::MeshBase::delete_node(), libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::Elem::first_order_equivalent_type(), libMesh::MeshBase::get_boundary_info(), libMesh::Elem::has_children(), libMesh::DofObject::id(), libMesh::MeshBase::insert_elem(), libMesh::libmesh_assert(), libMesh::MeshBase::max_node_id(), libMesh::Elem::n_children(), libMesh::Elem::n_sides(), libMesh::Elem::n_vertices(), libMesh::Elem::neighbor_ptr(), libMesh::Elem::node_id(), libMesh::Elem::node_ptr(), libMesh::MeshBase::nodes_begin(), libMesh::MeshBase::nodes_end(), libMesh::Elem::p_level(), libMesh::Elem::p_refinement_flag(), libMesh::Elem::parent(), libMesh::MeshBase::prepare_for_use(), libMesh::DofObject::processor_id(), libMesh::Elem::refinement_flag(), libMesh::BoundaryInfo::regenerate_id_sets(), libMesh::remote_elem, libMesh::MeshBase::renumber_nodes_and_elements(), libMesh::Elem::replace_child(), libMesh::DofObject::set_id(), libMesh::Elem::set_neighbor(), libMesh::Elem::set_node(), libMesh::Partitioner::set_node_processor_ids(), libMesh::Elem::set_p_level(), libMesh::Elem::set_p_refinement_flag(), libMesh::Elem::set_parent(), libMesh::Elem::set_refinement_flag(), libMesh::DofObject::set_unique_id(), libMesh::Elem::subdomain_id(), libMesh::Elem::type(), libMesh::DofObject::unique_id(), and libMesh::Elem::which_child_am_i().

Referenced by main().

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

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

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

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

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

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

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

Implements libMesh::MeshBase.

Definition at line 431 of file mesh_modification.C.

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

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

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

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

Reimplemented in libMesh::DistributedMesh.

Definition at line 169 of file mesh_base.h.

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

169 {}
void libMesh::MeshBase::allow_remote_element_removal ( bool  allow)
inherited

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

References libMesh::MeshBase::_allow_remote_element_removal.

Referenced by copy_nodes_and_elements().

bool _allow_remote_element_removal
If this is false then even on DistributedMesh remote elements will not be deleted during mesh prepara...
Definition: mesh_base.h:1397
bool libMesh::MeshBase::allow_remote_element_removal ( ) const
inherited

Definition at line 759 of file mesh_base.h.

References libMesh::MeshBase::_allow_remote_element_removal.

Referenced by copy_nodes_and_elements().

bool _allow_remote_element_removal
If this is false then even on DistributedMesh remote elements will not be deleted during mesh prepara...
Definition: mesh_base.h:1397
void libMesh::MeshBase::allow_renumbering ( bool  allow)
inherited

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

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

Definition at line 749 of file mesh_base.h.

References libMesh::MeshBase::_skip_renumber_nodes_and_elements.

Referenced by SlitMeshTest::build_mesh(), copy_nodes_and_elements(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ErrorVector::plot_error(), libMesh::RBEIMEvaluation::RBEIMEvaluation(), libMesh::NameBasedIO::read(), libMesh::GMVIO::read(), EquationSystemsTest::testRefineThenReinitPreserveFlags(), and WriteVecAndScalar::testWrite().

bool _skip_renumber_nodes_and_elements
If this is true then renumbering will be kept to a minimum.
Definition: mesh_base.h:1389
bool libMesh::MeshBase::allow_renumbering ( ) const
inherited

Definition at line 750 of file mesh_base.h.

References libMesh::MeshBase::_skip_renumber_nodes_and_elements.

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

bool _skip_renumber_nodes_and_elements
If this is true then renumbering will be kept to a minimum.
Definition: mesh_base.h:1389
virtual element_iterator libMesh::MeshBase::ancestor_elements_begin ( )
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::ancestor_elements_begin ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::ancestor_elements_end ( )
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::ancestor_elements_end ( ) const
pure virtualinherited
virtual node_iterator libMesh::MeshBase::bid_nodes_begin ( boundary_id_type  bndry_id)
pure virtualinherited

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

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

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

virtual const_node_iterator libMesh::MeshBase::bid_nodes_begin ( boundary_id_type  bndry_id) const
pure virtualinherited
virtual node_iterator libMesh::MeshBase::bid_nodes_end ( boundary_id_type  bndry_id)
pure virtualinherited
virtual const_node_iterator libMesh::MeshBase::bid_nodes_end ( boundary_id_type  bndry_id) const
pure virtualinherited
virtual node_iterator libMesh::MeshBase::bnd_nodes_begin ( )
pure virtualinherited

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

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

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

virtual const_node_iterator libMesh::MeshBase::bnd_nodes_begin ( ) const
pure virtualinherited
virtual node_iterator libMesh::MeshBase::bnd_nodes_end ( )
pure virtualinherited
virtual const_node_iterator libMesh::MeshBase::bnd_nodes_end ( ) const
pure virtualinherited
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 612 of file mesh_base.C.

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

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

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

Deletes all the data that are currently stored.

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

Definition at line 285 of file mesh_base.C.

References libMesh::MeshBase::_elem_dims, libMesh::MeshBase::_is_prepared, libMesh::MeshBase::_n_parts, libMesh::BoundaryInfo::clear(), libMesh::MeshBase::clear_point_locator(), and libMesh::MeshBase::get_boundary_info().

Referenced by libMesh::MeshCommunication::broadcast(), libMesh::MeshTools::Generation::build_cube(), libMesh::MeshTools::Generation::build_delaunay_square(), libMesh::MeshTools::Generation::build_sphere(), libMesh::ReplicatedMesh::clear(), libMesh::DistributedMesh::clear(), libMesh::TriangleWrapper::copy_tri_to_mesh(), create_submesh(), libMesh::MeshBase::get_boundary_info(), libMesh::AbaqusIO::read(), libMesh::GMVIO::read(), libMesh::ExodusII_IO::read(), libMesh::VTKIO::read(), libMesh::OFFIO::read_stream(), libMesh::MatlabIO::read_stream(), libMesh::BoundaryInfo::sync(), libMesh::TriangleInterface::triangulate(), and libMesh::MeshBase::~MeshBase().

286 {
287  // Reset the number of partitions
288  _n_parts = 1;
289 
290  // Reset the _is_prepared flag
291  _is_prepared = false;
292 
293  // Clear boundary information
294  this->get_boundary_info().clear();
295 
296  // Clear element dimensions
297  _elem_dims.clear();
298 
299  // Clear our point locator.
300  this->clear_point_locator();
301 }
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:117
unsigned int _n_parts
The number of partitions the mesh has.
Definition: mesh_base.h:1342
void clear_point_locator()
Releases the current PointLocator object.
Definition: mesh_base.C:555
std::set< unsigned char > _elem_dims
We cache the dimension of the elements present in the mesh.
Definition: mesh_base.h:1411
void clear()
Clears the underlying data structures and restores the object to a pristine state with no data stored...
bool _is_prepared
Flag indicating if the mesh has been prepared for use.
Definition: mesh_base.h:1347
void libMesh::MeshBase::clear_point_locator ( )
inherited
virtual UniquePtr<MeshBase> libMesh::MeshBase::clone ( ) const
pure virtualinherited
const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inherited
Returns
A reference to the Parallel::Communicator object used by this mesh.

Definition at line 87 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_preconditioner_apply(), libMesh::__libmesh_petsc_snes_jacobian(), libMesh::__libmesh_petsc_snes_postcheck(), libMesh::__libmesh_petsc_snes_residual(), libMesh::__libmesh_tao_equality_constraints(), libMesh::__libmesh_tao_equality_constraints_jacobian(), libMesh::__libmesh_tao_gradient(), libMesh::__libmesh_tao_hessian(), libMesh::__libmesh_tao_inequality_constraints(), libMesh::__libmesh_tao_inequality_constraints_jacobian(), libMesh::__libmesh_tao_objective(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::ParmetisPartitioner::_do_repartition(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult_add(), libMesh::EquationSystems::_read_impl(), libMesh::MeshRefinement::_refine_elements(), libMesh::MeshRefinement::_smooth_flags(), add_cube_convex_hull_to_mesh(), libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::ImplicitSystem::add_matrix(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::System::add_vector(), libMesh::EigenSparseLinearSolver< T >::adjoint_solve(), all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::DofMap::attach_matrix(), libMesh::Parallel::BinSorter< KeyType, IdxType >::binsort(), libMesh::Parallel::Sort< KeyType, IdxType >::binsort(), libMesh::MeshCommunication::broadcast(), libMesh::SparseMatrix< T >::build(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::Parallel::Histogram< KeyType, IdxType >::build_histogram(), libMesh::PetscNonlinearSolver< T >::build_mat_null_space(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::MeshBase::cache_elem_dims(), libMesh::System::calculate_norm(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::Parallel::Sort< KeyType, IdxType >::communicate_bins(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBSCMConstruction::compute_SCM_bounds_on_training_set(), 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::RBEIMConstruction::enrich_RB_space(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::RBConstruction::enrich_RB_space(), AssembleOptimization::equality_constraints(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::RBEIMConstruction::evaluate_mesh_function(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), libMesh::MeshfreeInterpolation::gather_remote_data(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::DofMap::get_info(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::EquationSystems::get_solution(), AssembleOptimization::inequality_constraints(), AssembleOptimization::inequality_constraints_jacobian(), libMesh::LocationMap< T >::init(), libMesh::TopologyMap::init(), libMesh::PetscDiffSolver::init(), libMesh::TimeSolver::init(), libMesh::TaoOptimizationSolver< T >::init(), libMesh::PetscNonlinearSolver< T >::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::EigenSystem::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::ParmetisPartitioner::initialize(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::RBEIMConstruction::initialize_rb_construction(), integrate_function(), 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::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::limit_overrefined_boundary(), libMesh::MeshRefinement::limit_underrefined_boundary(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshRefinement::make_flags_parallel_consistent(), libMesh::MeshCommunication::make_new_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_new_nodes_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_unique_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshCommunication::make_p_levels_parallel_consistent(), libMesh::MeshRefinement::make_refinement_compatible(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), libMesh::FEMSystem::mesh_position_set(), libMesh::MeshSerializer::MeshSerializer(), LinearElasticityWithContact::move_mesh(), 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(), new_function_base(), libMesh::DistributedMesh::parallel_max_elem_id(), libMesh::DistributedMesh::parallel_max_node_id(), libMesh::ReplicatedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_n_elem(), libMesh::DistributedMesh::parallel_n_nodes(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::MeshTools::paranoid_n_levels(), libMesh::Partitioner::partition(), libMesh::MetisPartitioner::partition_range(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::SparseMatrix< T >::print(), FEMParameters::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshCommunication::redistribute(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::DistributedMesh::renumber_dof_objects(), LinearElasticityWithContact::residual_and_jacobian(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::TransientRBConstruction::set_error_temporal_data(), libMesh::RBEIMConstruction::set_explicit_sys_subvector(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::Parallel::Sort< KeyType, IdxType >::sort(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::Parallel::sync_element_data_by_parent_id(), libMesh::Parallel::sync_node_data_by_element_id(), libMesh::MeshRefinement::test_level_one(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), libMesh::MeshRefinement::test_unflagged(), PointLocatorTest::testLocator(), BoundaryInfoTest::testMesh(), SystemsTest::testProjectCubeWithMeshFunction(), libMesh::MeshTools::total_weight(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::RBEIMConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::RBEvaluation::write_out_vectors(), libMesh::TransientRBConstruction::write_riesz_representors_to_files(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::RBDataSerialization::RBEvaluationSerialization::write_to_file(), libMesh::RBDataSerialization::TransientRBEvaluationSerialization::write_to_file(), libMesh::RBDataSerialization::RBEIMEvaluationSerialization::write_to_file(), and libMesh::RBDataSerialization::RBSCMEvaluationSerialization::write_to_file().

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

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

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

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

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

Definition at line 73 of file unstructured_mesh.C.

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

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

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

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

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

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

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

Definition at line 693 of file unstructured_mesh.C.

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

Referenced by construct_mesh_of_active_elements(), and create_pid_mesh().

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

Removes element e from the mesh.

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

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

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

Referenced by libMesh::MeshTools::Modification::all_tri(), libMesh::MeshTools::Generation::build_cube(), contract(), libMesh::TetGenMeshInterface::delete_2D_hull_elements(), libMesh::MeshTools::Modification::flatten(), libMesh::TetGenMeshInterface::pointset_convexhull(), libMesh::MeshBase::query_elem(), libMesh::AbaqusIO::read(), and libMesh::UNVIO::read_implementation().

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

Removes the Node n from the mesh.

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

Referenced by all_first_order(), and libMesh::MeshBase::query_elem().

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

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

References libMesh::MeshBase::mesh_dimension().

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

182 {}
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 678 of file mesh_base.C.

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

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

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

References libMesh::MeshBase::elem_ptr().

Referenced by libMesh::MeshBase::detect_interior_parents(), and libMesh::DTKAdapter::DTKAdapter().

524  {
525  libmesh_deprecated();
526  return this->elem_ptr(i);
527  }
virtual const Elem * elem_ptr(const dof_id_type i) const =0
virtual Elem* libMesh::MeshBase::elem ( const dof_id_type  i)
virtualinherited
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 538 of file mesh_base.h.

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

539  {
540  libmesh_deprecated();
541  return this->elem_ptr(i);
542  }
virtual const Elem * elem_ptr(const dof_id_type i) const =0
const std::set<unsigned char>& libMesh::MeshBase::elem_dimensions ( ) const
inherited
Returns
A const reference to a std::set of element dimensions present in the mesh.

Definition at line 206 of file mesh_base.h.

References libMesh::MeshBase::_elem_dims, libMesh::MeshBase::n_nodes(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::MeshBase::parallel_n_nodes(), libMesh::MeshBase::set_spatial_dimension(), and libMesh::MeshBase::spatial_dimension().

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

207  { return _elem_dims; }
std::set< unsigned char > _elem_dims
We cache the dimension of the elements present in the mesh.
Definition: mesh_base.h:1411
virtual const Elem* libMesh::MeshBase::elem_ptr ( const dof_id_type  i) const
pure virtualinherited
virtual Elem* libMesh::MeshBase::elem_ptr ( const dof_id_type  i)
pure virtualinherited
Returns
A writable pointer to the $ i^{th} $ element, which should be present in this processor's subset of the mesh data structure.

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

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

Definition at line 490 of file mesh_base.h.

References libMesh::MeshBase::elem_ptr().

Referenced by libMesh::SyncRefinementFlags::act_on_data(), libMesh::AbaqusIO::assign_sideset_ids(), libMesh::AbaqusIO::assign_subdomain_ids(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::InfElemBuilder::build_inf_elem(), MixedDimensionNonUniformRefinement::build_mesh(), MixedDimensionNonUniformRefinementTriangle::build_mesh(), MixedDimensionNonUniformRefinement3D::build_mesh(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::MeshBase::detect_interior_parents(), libMesh::SyncRefinementFlags::gather_data(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::ExodusII_IO::read(), libMesh::CheckpointIO::read_remote_elem(), libMesh::Parallel::sync_element_data_by_parent_id(), libMesh::Parallel::sync_node_data_by_element_id(), MeshExtruderTest::testExtruder(), MixedDimensionMeshTest::testMesh(), SlitMeshTest::testMesh(), MixedDimensionNonUniformRefinement::testMesh(), MixedDimensionNonUniformRefinementTriangle::testMesh(), MixedDimensionNonUniformRefinement3D::testMesh(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::FroIO::write(), libMesh::Nemesis_IO_Helper::write_elements(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::Nemesis_IO_Helper::write_sidesets(), and libMesh::ExodusII_IO_Helper::write_sidesets().

490  {
491  return *this->elem_ptr(i);
492  }
virtual const Elem * elem_ptr(const dof_id_type i) const =0
virtual Elem& libMesh::MeshBase::elem_ref ( const dof_id_type  i)
virtualinherited
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 499 of file mesh_base.h.

References libMesh::MeshBase::elem_ptr().

499  {
500  return *this->elem_ptr(i);
501  }
virtual const Elem * elem_ptr(const dof_id_type i) const =0
virtual SimpleRange<element_iterator> libMesh::MeshBase::element_ptr_range ( )
pure virtualinherited

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

Referenced by libMesh::EquationSystems::_add_system_to_nodes_and_elems(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::MeshRefinement::_refine_elements(), libMesh::BoundaryInfo::add_elements(), libMesh::MeshRefinement::add_p_to_h_refinement(), libMesh::MeshTools::Subdivision::all_subdivision(), libMesh::MeshTools::Modification::all_tri(), libMesh::EquationSystems::allgather(), libMesh::MeshCommunication::assign_global_indices(), libMesh::MeshTools::Generation::build_cube(), libMesh::MeshTools::Generation::build_delaunay_square(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::MeshTools::build_nodes_to_elem_map(), libMesh::MeshTools::Modification::change_subdomain_id(), libMesh::TetGenMeshInterface::check_hull_integrity(), libMesh::MeshRefinement::clean_refinement_flags(), libMesh::MeshRefinement::coarsen_elements(), copy_nodes_and_elements(), libMesh::TetGenMeshInterface::delete_2D_hull_elements(), libMesh::DofMap::distribute_dofs(), libMesh::MeshTools::elem_types(), libMesh::UNVIO::elements_out(), libMesh::TopologyMap::fill(), libMesh::MeshTools::Modification::flatten(), libMesh::MeshTools::get_not_subactive_node_ids(), libMesh::EquationSystems::init(), libMesh::MeshTools::libmesh_assert_connected_nodes(), libMesh::MeshTools::libmesh_assert_equal_n_systems(), libMesh::MeshTools::libmesh_assert_no_links_to_elem(), libMesh::MeshTools::libmesh_assert_old_dof_objects(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_amr_elem_ids(), libMesh::MeshTools::libmesh_assert_valid_amr_interior_parents(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::MeshTools::libmesh_assert_valid_node_pointers(), libMesh::MeshBase::libmesh_assert_valid_parallel_ids(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshTools::libmesh_assert_valid_refinement_tree(), main(), libMesh::MeshTools::paranoid_n_levels(), libMesh::ErrorVector::plot_error(), libMesh::TetGenMeshInterface::pointset_convexhull(), libMesh::MeshTools::Subdivision::prepare_subdivision_mesh(), libMesh::AbaqusIO::read(), libMesh::UNVIO::read_implementation(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::MeshRefinement::refine_elements(), libMesh::EquationSystems::reinit(), libMesh::DofMap::reinit(), libMesh::MeshRefinement::switch_h_to_p_refinement(), libMesh::BoundaryInfo::sync(), libMesh::MeshTools::Subdivision::tag_boundary_ghosts(), libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole(), and libMesh::UCDIO::write_interior_elems().

virtual SimpleRange<const_element_iterator> libMesh::MeshBase::element_ptr_range ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::elements_begin ( )
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::elements_begin ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::elements_end ( )
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::elements_end ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::evaluable_elements_begin ( const DofMap dof_map,
unsigned int  var_num = libMesh::invalid_uint 
)
pure virtualinherited

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.

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

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

virtual const_element_iterator libMesh::MeshBase::evaluable_elements_begin ( const DofMap dof_map,
unsigned int  var_num = libMesh::invalid_uint 
) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::evaluable_elements_end ( const DofMap dof_map,
unsigned int  var_num = libMesh::invalid_uint 
)
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::evaluable_elements_end ( const DofMap dof_map,
unsigned int  var_num = libMesh::invalid_uint 
) const
pure virtualinherited
virtual node_iterator libMesh::MeshBase::evaluable_nodes_begin ( const DofMap dof_map,
unsigned int  var_num = libMesh::invalid_uint 
)
pure virtualinherited

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.

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

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

virtual const_node_iterator libMesh::MeshBase::evaluable_nodes_begin ( const DofMap dof_map,
unsigned int  var_num = libMesh::invalid_uint 
) const
pure virtualinherited
virtual node_iterator libMesh::MeshBase::evaluable_nodes_end ( const DofMap dof_map,
unsigned int  var_num = libMesh::invalid_uint 
)
pure virtualinherited
virtual const_node_iterator libMesh::MeshBase::evaluable_nodes_end ( const DofMap dof_map,
unsigned int  var_num = libMesh::invalid_uint 
) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::facelocal_elements_begin ( )
pure virtualinherited

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

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

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

virtual const_element_iterator libMesh::MeshBase::facelocal_elements_begin ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::facelocal_elements_end ( )
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::facelocal_elements_end ( ) const
pure virtualinherited
void libMesh::UnstructuredMesh::find_neighbors ( const bool  reset_remote_elements = false,
const bool  reset_current_list = true 
)
virtual

Other functions from MeshBase requiring re-definition.

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

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

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

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

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

Implements libMesh::MeshBase.

Definition at line 228 of file unstructured_mesh.C.

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

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

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

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

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

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

Referenced by libMesh::EquationSystems::_read_impl(), libMesh::MeshBase::query_elem(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), and libMesh::RBEvaluation::write_out_vectors().

virtual element_iterator libMesh::MeshBase::flagged_elements_begin ( unsigned char  rflag)
pure virtualinherited

Iterate over all elements with a specified refinement flag.

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

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

virtual const_element_iterator libMesh::MeshBase::flagged_elements_begin ( unsigned char  rflag) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::flagged_elements_end ( unsigned char  rflag)
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::flagged_elements_end ( unsigned char  rflag) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::flagged_pid_elements_begin ( unsigned char  rflag,
processor_id_type  pid 
)
pure virtualinherited

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

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

Referenced by libMesh::MeshBase::libmesh_assert_valid_parallel_ids(), libMesh::query_ghosting_functors(), and libMesh::MeshCommunication::send_coarse_ghosts().

virtual const_element_iterator libMesh::MeshBase::flagged_pid_elements_begin ( unsigned char  rflag,
processor_id_type  pid 
) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::flagged_pid_elements_end ( unsigned char  rflag,
processor_id_type  pid 
)
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::flagged_pid_elements_end ( unsigned char  rflag,
processor_id_type  pid 
) const
pure virtualinherited
virtual void libMesh::MeshBase::gather_to_zero ( )
virtualinherited

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

Reimplemented in libMesh::DistributedMesh.

Definition at line 175 of file mesh_base.h.

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

175 {}
const BoundaryInfo& libMesh::MeshBase::get_boundary_info ( ) const
inherited

The information about boundary ids on the mesh.

Definition at line 117 of file mesh_base.h.

References libMesh::MeshBase::boundary_info.

Referenced by libMesh::MeshRefinement::_coarsen_elements(), libMesh::MeshTools::Subdivision::add_boundary_ghosts(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), all_first_order(), all_second_order(), libMesh::MeshTools::Subdivision::all_subdivision(), libMesh::MeshTools::Modification::all_tri(), LinearElasticity::assemble(), assemble_elasticity(), assemble_poisson(), assemble_shell(), libMesh::AbaqusIO::assign_boundary_node_ids(), libMesh::AbaqusIO::assign_sideset_ids(), AssemblyA0::boundary_assembly(), AssemblyF0::boundary_assembly(), AssemblyA1::boundary_assembly(), AssemblyF1::boundary_assembly(), AssemblyF2::boundary_assembly(), AssemblyA2::boundary_assembly(), libMesh::MeshCommunication::broadcast(), libMesh::MeshTools::Generation::build_cube(), libMesh::MeshTools::Generation::build_delaunay_square(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::MeshTools::Generation::build_sphere(), libMesh::MeshTools::Modification::change_boundary_id(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::MeshBase::clear(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::FEGenericBase< OutputType >::compute_periodic_constraints(), libMesh::FEAbstract::compute_periodic_node_constraints(), create_submesh(), libMesh::TetGenMeshInterface::delete_2D_hull_elements(), libMesh::ReplicatedMesh::delete_elem(), libMesh::DistributedMesh::delete_elem(), libMesh::ReplicatedMesh::delete_node(), libMesh::DistributedMesh::delete_node(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DistributedMesh::DistributedMesh(), libMesh::MeshTools::Modification::flatten(), libMesh::UNVIO::groups_in(), libMesh::ExodusII_IO_Helper::initialize(), LinearElasticityWithContact::initialize_contact_load_paths(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), main(), AugmentSparsityOnInterface::mesh_reinit(), libMesh::BoundaryProjectSolution::operator()(), libMesh::Parallel::Packing< const Node * >::pack(), libMesh::Parallel::Packing< const Elem * >::pack(), libMesh::Parallel::Packing< const Node * >::packable_size(), libMesh::Parallel::Packing< const Elem * >::packable_size(), libMesh::TetGenMeshInterface::pointset_convexhull(), libMesh::Nemesis_IO::prepare_to_write_nodal_data(), libMesh::AbaqusIO::read(), libMesh::Nemesis_IO::read(), libMesh::ExodusII_IO::read(), libMesh::CheckpointIO::read_bcs(), libMesh::CheckpointIO::read_header(), libMesh::CheckpointIO::read_nodesets(), libMesh::ReplicatedMesh::renumber_nodes_and_elements(), libMesh::DistributedMesh::renumber_nodes_and_elements(), libMesh::ReplicatedMesh::ReplicatedMesh(), libMesh::ReplicatedMesh::stitching_helper(), libMesh::BoundaryInfo::sync(), AllTriTest::test_helper_2D(), AllTriTest::test_helper_3D(), BoundaryInfoTest::testEdgeBoundaryConditions(), BoundaryInfoTest::testMesh(), BoundaryInfoTest::testShellFaceConstraints(), libMesh::Elem::topological_neighbor(), libMesh::Parallel::Packing< Node * >::unpack(), libMesh::Parallel::Packing< Elem * >::unpack(), libMesh::FroIO::write(), libMesh::Nemesis_IO::write(), libMesh::ExodusII_IO::write(), libMesh::CheckpointIO::write(), libMesh::XdrIO::write(), libMesh::ExodusII_IO::write_nodal_data_common(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::Nemesis_IO_Helper::write_sidesets(), and libMesh::ExodusII_IO_Helper::write_sidesets().

117 { return *boundary_info; }
UniquePtr< BoundaryInfo > boundary_info
This class holds the boundary information.
Definition: mesh_base.h:1321
BoundaryInfo& libMesh::MeshBase::get_boundary_info ( )
inherited

Writable information about boundary ids on the mesh.

Definition at line 122 of file mesh_base.h.

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

122 { return *boundary_info; }
UniquePtr< BoundaryInfo > boundary_info
This class holds the boundary information.
Definition: mesh_base.h:1321
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 569 of file mesh_base.C.

References libMesh::MeshBase::_count_lower_dim_elems_in_point_locator.

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

570 {
572 }
bool _count_lower_dim_elems_in_point_locator
Do we count lower dimensional elements in point locator refinement? This is relevant in tree-based po...
Definition: mesh_base.h:1362
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 596 of file mesh_base.C.

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

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

597 {
598  // Linear search over the map values.
599  std::map<subdomain_id_type, std::string>::const_iterator
600  iter = _block_id_to_name.begin(),
601  end_iter = _block_id_to_name.end();
602 
603  for ( ; iter != end_iter; ++iter)
604  if (iter->second == name)
605  return iter->first;
606 
607  // If we made it here without returning, we don't have a subdomain
608  // with the requested name, so return Elem::invalid_subdomain_id.
610 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
static const subdomain_id_type invalid_subdomain_id
A static integral constant representing an invalid subdomain id.
Definition: elem.h:237
std::map< subdomain_id_type, std::string > _block_id_to_name
This structure maintains the mapping of named blocks for file formats that support named blocks...
Definition: mesh_base.h:1404
std::string libMesh::MeshBase::get_info ( ) const
inherited
Returns
A string containing relevant information about the mesh.

Definition at line 414 of file mesh_base.C.

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

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

415 {
416  std::ostringstream oss;
417 
418  oss << " Mesh Information:" << '\n';
419 
420  if (!_elem_dims.empty())
421  {
422  oss << " elem_dimensions()={";
423  std::copy(_elem_dims.begin(),
424  --_elem_dims.end(), // --end() is valid if the set is non-empty
425  std::ostream_iterator<unsigned int>(oss, ", "));
426  oss << cast_int<unsigned int>(*_elem_dims.rbegin());
427  oss << "}\n";
428  }
429 
430  oss << " spatial_dimension()=" << this->spatial_dimension() << '\n'
431  << " n_nodes()=" << this->n_nodes() << '\n'
432  << " n_local_nodes()=" << this->n_local_nodes() << '\n'
433  << " n_elem()=" << this->n_elem() << '\n'
434  << " n_local_elem()=" << this->n_local_elem() << '\n'
435 #ifdef LIBMESH_ENABLE_AMR
436  << " n_active_elem()=" << this->n_active_elem() << '\n'
437 #endif
438  << " n_subdomains()=" << static_cast<std::size_t>(this->n_subdomains()) << '\n'
439  << " n_partitions()=" << static_cast<std::size_t>(this->n_partitions()) << '\n'
440  << " n_processors()=" << static_cast<std::size_t>(this->n_processors()) << '\n'
441  << " n_threads()=" << static_cast<std::size_t>(libMesh::n_threads()) << '\n'
442  << " processor_id()=" << static_cast<std::size_t>(this->processor_id()) << '\n';
443 
444  return oss.str();
445 }
virtual dof_id_type n_active_elem() const =0
unsigned int n_threads()
Definition: libmesh_base.h:125
dof_id_type n_local_nodes() const
Definition: mesh_base.h:272
unsigned int n_partitions() const
Definition: mesh_base.h:833
processor_id_type n_processors() const
std::set< unsigned char > _elem_dims
We cache the dimension of the elements present in the mesh.
Definition: mesh_base.h:1411
unsigned int spatial_dimension() const
Definition: mesh_base.C:157
dof_id_type n_local_elem() const
Definition: mesh_base.h:372
subdomain_id_type n_subdomains() const
Definition: mesh_base.C:334
virtual dof_id_type n_nodes() const =0
virtual dof_id_type n_elem() const =0
processor_id_type processor_id() const
const std::map<subdomain_id_type, std::string>& libMesh::MeshBase::get_subdomain_name_map ( ) const
inherited

Definition at line 1295 of file mesh_base.h.

References libMesh::MeshBase::_block_id_to_name, libMesh::MeshBase::cache_elem_dims(), and libMesh::MeshBase::detect_interior_parents().

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

1296  { return _block_id_to_name; }
std::map< subdomain_id_type, std::string > _block_id_to_name
This structure maintains the mapping of named blocks for file formats that support named blocks...
Definition: mesh_base.h:1404
virtual element_iterator libMesh::MeshBase::ghost_elements_begin ( )
pure virtualinherited

Iterate over "ghost" elements in the Mesh.

A ghost element is one which is not local, but is semilocal.

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

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

virtual const_element_iterator libMesh::MeshBase::ghost_elements_begin ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::ghost_elements_end ( )
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::ghost_elements_end ( ) const
pure virtualinherited
std::set<GhostingFunctor *>::const_iterator libMesh::MeshBase::ghosting_functors_begin ( ) const
inherited

Beginning of range of ghosting functors.

Definition at line 798 of file mesh_base.h.

References libMesh::MeshBase::_ghosting_functors.

Referenced by contract(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::MeshBase::prepare_for_use(), libMesh::query_ghosting_functors(), libMesh::MeshCommunication::redistribute(), and libMesh::MeshCommunication::send_coarse_ghosts().

799  { return _ghosting_functors.begin(); }
std::set< GhostingFunctor * > _ghosting_functors
The list of all GhostingFunctor objects to be used when distributing a DistributedMesh.
Definition: mesh_base.h:1433
std::set<GhostingFunctor *>::const_iterator libMesh::MeshBase::ghosting_functors_end ( ) const
inherited

End of range of ghosting functors.

Definition at line 804 of file mesh_base.h.

References libMesh::MeshBase::_ghosting_functors, libMesh::MeshBase::n_subdomains(), and libMesh::MeshBase::subdomain_ids().

Referenced by contract(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::MeshBase::prepare_for_use(), libMesh::query_ghosting_functors(), libMesh::MeshCommunication::redistribute(), and libMesh::MeshCommunication::send_coarse_ghosts().

805  { return _ghosting_functors.end(); }
std::set< GhostingFunctor * > _ghosting_functors
The list of all GhostingFunctor objects to be used when distributing a DistributedMesh.
Definition: mesh_base.h:1433
virtual Elem* libMesh::MeshBase::insert_elem ( Elem e)
pure virtualinherited

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

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

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

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

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

Insert Node n into the Mesh at a location consistent with n->id(), allocating extra storage if necessary.

Will error rather than overwriting an existing Node. Primarily intended for use with the mesh_inserter_iterator, only use if you know what you are doing...

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

Referenced by libMesh::mesh_inserter_iterator< T >::operator=(), and libMesh::MeshBase::query_elem().

bool libMesh::MeshBase::is_prepared ( ) const
inherited
Returns
true if the mesh has been prepared via a call to prepare_for_use, false otherwise.

Definition at line 133 of file mesh_base.h.

References libMesh::MeshBase::_is_prepared.

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

134  { return _is_prepared; }
bool _is_prepared
Flag indicating if the mesh has been prepared for use.
Definition: mesh_base.h:1347
virtual bool libMesh::MeshBase::is_replicated ( ) const
virtualinherited
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 162 of file mesh_base.h.

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

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

Reimplemented in libMesh::DistributedMesh.

Definition at line 140 of file mesh_base.h.

Referenced by libMesh::MeshRefinement::_coarsen_elements(), libMesh::MeshRefinement::_smooth_flags(), libMesh::BoundaryInfo::add_elements(), all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::EquationSystems::allgather(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::DofMap::create_dof_constraints(), create_submesh(), libMesh::LocationMap< T >::init(), libMesh::TopologyMap::init(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshSerializer::MeshSerializer(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::MeshBase::partition(), libMesh::MetisPartitioner::partition_range(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::Nemesis_IO::read(), libMesh::DofMap::scatter_constraints(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::BoundaryInfo::sync(), libMesh::MeshTools::total_weight(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::CheckpointIO::write(), and libMesh::XdrIO::write_parallel().

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

Reimplemented in libMesh::DistributedMesh.

Definition at line 147 of file mesh_base.h.

148  { return true; }
virtual element_iterator libMesh::MeshBase::level_elements_begin ( unsigned int  level)
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::level_elements_begin ( unsigned int  level) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::level_elements_end ( unsigned int  level)
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::level_elements_end ( unsigned int  level) const
pure virtualinherited
virtual void libMesh::MeshBase::libmesh_assert_valid_parallel_ids ( ) const
virtualinherited

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

References libMesh::MeshBase::active_element_ptr_range(), libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), libMesh::MeshBase::active_local_element_ptr_range(), libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libMesh::MeshBase::active_local_subdomain_elements_begin(), libMesh::MeshBase::active_local_subdomain_elements_end(), libMesh::MeshBase::active_nodes_begin(), libMesh::MeshBase::active_nodes_end(), libMesh::MeshBase::active_not_local_elements_begin(), libMesh::MeshBase::active_not_local_elements_end(), libMesh::MeshBase::active_pid_elements_begin(), libMesh::MeshBase::active_pid_elements_end(), libMesh::MeshBase::active_semilocal_elements_begin(), libMesh::MeshBase::active_semilocal_elements_end(), libMesh::MeshBase::active_subdomain_elements_begin(), libMesh::MeshBase::active_subdomain_elements_end(), libMesh::MeshBase::active_subdomain_set_elements_begin(), libMesh::MeshBase::active_subdomain_set_elements_end(), libMesh::MeshBase::active_type_elements_begin(), libMesh::MeshBase::active_type_elements_end(), libMesh::MeshBase::active_unpartitioned_elements_begin(), libMesh::MeshBase::active_unpartitioned_elements_end(), libMesh::MeshBase::ancestor_elements_begin(), libMesh::MeshBase::ancestor_elements_end(), libMesh::MeshBase::bid_nodes_begin(), libMesh::MeshBase::bid_nodes_end(), libMesh::MeshBase::bnd_nodes_begin(), libMesh::MeshBase::bnd_nodes_end(), libMesh::MeshBase::element_ptr_range(), libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::MeshBase::evaluable_elements_begin(), libMesh::MeshBase::evaluable_elements_end(), libMesh::MeshBase::evaluable_nodes_begin(), libMesh::MeshBase::evaluable_nodes_end(), libMesh::MeshBase::facelocal_elements_begin(), libMesh::MeshBase::facelocal_elements_end(), libMesh::MeshBase::flagged_elements_begin(), libMesh::MeshBase::flagged_elements_end(), libMesh::MeshBase::flagged_pid_elements_begin(), libMesh::MeshBase::flagged_pid_elements_end(), libMesh::MeshBase::get_id_by_name(), libMesh::MeshBase::ghost_elements_begin(), libMesh::MeshBase::ghost_elements_end(), libMesh::invalid_uint, libMesh::MeshBase::level_elements_begin(), libMesh::MeshBase::level_elements_end(), libMesh::MeshBase::local_elements_begin(), libMesh::MeshBase::local_elements_end(), libMesh::MeshBase::local_level_elements_begin(), libMesh::MeshBase::local_level_elements_end(), libMesh::MeshBase::local_node_ptr_range(), libMesh::MeshBase::local_nodes_begin(), libMesh::MeshBase::local_nodes_end(), libMesh::MeshBase::local_not_level_elements_begin(), libMesh::MeshBase::local_not_level_elements_end(), libMesh::MeshBase::node_ptr_range(), libMesh::MeshBase::nodes_begin(), libMesh::MeshBase::nodes_end(), libMesh::MeshBase::not_active_elements_begin(), libMesh::MeshBase::not_active_elements_end(), libMesh::MeshBase::not_ancestor_elements_begin(), libMesh::MeshBase::not_ancestor_elements_end(), libMesh::MeshBase::not_level_elements_begin(), libMesh::MeshBase::not_level_elements_end(), libMesh::MeshBase::not_local_elements_begin(), libMesh::MeshBase::not_local_elements_end(), libMesh::MeshBase::not_subactive_elements_begin(), libMesh::MeshBase::not_subactive_elements_end(), libMesh::MeshBase::pid_elements_begin(), libMesh::MeshBase::pid_elements_end(), libMesh::MeshBase::pid_nodes_begin(), libMesh::MeshBase::pid_nodes_end(), libMesh::MeshBase::semilocal_elements_begin(), libMesh::MeshBase::semilocal_elements_end(), libMesh::MeshBase::subactive_elements_begin(), libMesh::MeshBase::subactive_elements_end(), libMesh::MeshBase::subdomain_name(), libMesh::MeshBase::type_elements_begin(), libMesh::MeshBase::type_elements_end(), libMesh::MeshBase::unpartitioned_elements_begin(), and libMesh::MeshBase::unpartitioned_elements_end().

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

965 {}
virtual element_iterator libMesh::MeshBase::local_elements_begin ( )
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::local_elements_begin ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::local_elements_end ( )
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::local_elements_end ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::local_level_elements_begin ( unsigned int  level)
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::local_level_elements_begin ( unsigned int  level) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::local_level_elements_end ( unsigned int  level)
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::local_level_elements_end ( unsigned int  level) const
pure virtualinherited
virtual SimpleRange<node_iterator> libMesh::MeshBase::local_node_ptr_range ( )
pure virtualinherited
virtual SimpleRange<const_node_iterator> libMesh::MeshBase::local_node_ptr_range ( ) const
pure virtualinherited
virtual node_iterator libMesh::MeshBase::local_nodes_begin ( )
pure virtualinherited
virtual const_node_iterator libMesh::MeshBase::local_nodes_begin ( ) const
pure virtualinherited
virtual node_iterator libMesh::MeshBase::local_nodes_end ( )
pure virtualinherited
virtual const_node_iterator libMesh::MeshBase::local_nodes_end ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::local_not_level_elements_begin ( unsigned int  level)
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::local_not_level_elements_begin ( unsigned int  level) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::local_not_level_elements_end ( unsigned int  level)
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::local_not_level_elements_end ( unsigned int  level) const
pure virtualinherited
virtual dof_id_type libMesh::MeshBase::max_elem_id ( ) const
pure virtualinherited
virtual dof_id_type libMesh::MeshBase::max_node_id ( ) const
pure virtualinherited
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 148 of file mesh_base.C.

References libMesh::MeshBase::_elem_dims.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::HPCoarsenTest::add_projection(), all_second_order(), libMesh::MeshTools::Modification::all_tri(), assemble(), LinearElasticity::assemble(), assemble_1D(), AssembleOptimization::assemble_A_and_F(), assemble_biharmonic(), assemble_cd(), assemble_elasticity(), assemble_ellipticdg(), assemble_helmholtz(), assemble_laplace(), assemble_mass(), assemble_matrices(), assemble_poisson(), assemble_shell(), assemble_stokes(), assemble_wave(), libMesh::MeshTools::Generation::build_cube(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::MeshTools::Generation::build_sphere(), libMesh::EquationSystems::build_variable_names(), libMesh::MeshBase::cache_elem_dims(), compute_stresses(), LinearElasticity::compute_stresses(), libMesh::DofMap::create_dof_constraints(), libMesh::MeshBase::delete_remote_elements(), libMesh::MeshTools::Modification::distort(), SolidSystem::element_time_derivative(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::LaplaceMeshSmoother::init(), libMesh::PointLocatorTree::init(), SolidSystem::init_data(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::RBEIMAssembly::initialize_fe(), integrate_function(), LaplaceYoung::jacobian(), main(), libMesh::FEInterface::n_vec_dim(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::BoundaryProjectSolution::operator()(), libMesh::GMVIO::read(), libMesh::Nemesis_IO::read(), libMesh::ExodusII_IO::read(), libMesh::VTKIO::read(), libMesh::XdrIO::read_serialized_connectivity(), LaplaceYoung::residual(), SolidSystem::save_initial_mesh(), libMesh::HPCoarsenTest::select_refinement(), setup(), libMesh::MeshTools::Modification::smooth(), MeshSpatialDimensionTest::test1D(), MeshSpatialDimensionTest::test2D(), libMesh::BoundaryVolumeSolutionTransfer::transfer(), libMesh::DTKSolutionTransfer::transfer(), libMesh::DofMap::use_coupled_neighbor_dofs(), libMesh::PostscriptIO::write(), libMesh::CheckpointIO::write(), libMesh::TecplotIO::write_binary(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::UCDIO::write_nodal_data(), libMesh::EnsightIO::write_scalar_ascii(), libMesh::GnuPlotIO::write_solution(), and libMesh::EnsightIO::write_vector_ascii().

149 {
150  if (!_elem_dims.empty())
151  return cast_int<unsigned int>(*_elem_dims.rbegin());
152  return 0;
153 }
std::set< unsigned char > _elem_dims
We cache the dimension of the elements present in the mesh.
Definition: mesh_base.h:1411
virtual dof_id_type libMesh::MeshBase::n_active_elem ( ) const
pure virtualinherited
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 375 of file mesh_base.C.

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

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

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

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

Definition at line 399 of file mesh_base.C.

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

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

400 {
401  dof_id_type ne=0;
402 
403  const_element_iterator el = this->active_elements_begin();
404  const const_element_iterator end = this->active_elements_end();
405 
406  for (; el!=end; ++el)
407  ne += (*el)->n_sub_elem();
408 
409  return ne;
410 }
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
virtual element_iterator active_elements_begin()=0
Active, local, and negation forms of the element iterators described above.
virtual element_iterator active_elements_end()=0
uint8_t dof_id_type
Definition: id_types.h:64
virtual dof_id_type libMesh::MeshBase::n_elem ( ) const
pure virtualinherited
Returns
The number of elements in the mesh.

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

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

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::MeshTools::Subdivision::add_boundary_ghosts(), all_second_order(), libMesh::MeshTools::Subdivision::all_subdivision(), libMesh::MeshTools::Modification::all_tri(), libMesh::MeshCommunication::assign_global_indices(), libMesh::MeshCommunication::broadcast(), libMesh::MeshTools::Generation::build_cube(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::MeshTools::build_nodes_to_elem_map(), libMesh::TetGenMeshInterface::check_hull_integrity(), copy_nodes_and_elements(), libMesh::DofMap::create_dof_constraints(), create_submesh(), libMesh::MeshTools::Modification::distort(), libMesh::MeshBase::get_info(), libMesh::EquationSystems::get_solution(), libMesh::ExodusII_IO_Helper::initialize(), main(), libMesh::SFCPartitioner::partition_range(), libMesh::ErrorVector::plot_error(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::MeshTools::Modification::redistribute(), libMesh::MeshBase::set_next_unique_id(), libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole(), libMesh::RBEIMConstruction::truth_solve(), libMesh::FroIO::write(), libMesh::TetGenIO::write(), libMesh::XdrIO::write(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::UCDIO::write_nodal_data(), and libMesh::XdrIO::write_serialized_connectivity().

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

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

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

363 {
364  // We're either counting a processor's elements or unpartitioned
365  // elements
366  libmesh_assert (proc_id < this->n_processors() ||
368 
369  return static_cast<dof_id_type>(std::distance (this->pid_elements_begin(proc_id),
370  this->pid_elements_end (proc_id)));
371 }
processor_id_type n_processors() const
Real distance(const Point &p)
libmesh_assert(j)
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:335
virtual element_iterator pid_elements_begin(processor_id_type proc_id)=0
Iterate over all elements with a specified processor id.
uint8_t dof_id_type
Definition: id_types.h:64
virtual element_iterator pid_elements_end(processor_id_type proc_id)=0
dof_id_type libMesh::MeshBase::n_local_elem ( ) const
inherited
Returns
The number of elements on the local processor.

Definition at line 372 of file mesh_base.h.

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

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

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

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

273  { 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:349
processor_id_type processor_id() const
virtual dof_id_type libMesh::MeshBase::n_nodes ( ) const
pure virtualinherited
Returns
The number of nodes in the mesh.

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

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

Referenced by all_second_order(), libMesh::MeshCommunication::assign_global_indices(), libMesh::MeshCommunication::broadcast(), libMesh::MeshTools::Generation::build_cube(), libMesh::MeshTools::Generation::build_delaunay_square(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::MeshTools::build_nodes_to_elem_map(), libMesh::EquationSystems::build_parallel_solution_vector(), copy_nodes_and_elements(), create_submesh(), libMesh::MeshTools::Modification::distort(), libMesh::MeshBase::elem_dimensions(), fill_dirichlet_bc(), libMesh::TetGenMeshInterface::fill_pointlist(), libMesh::MeshBase::get_info(), libMesh::TreeNode< N >::insert(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), main(), libMesh::VariationalMeshSmoother::metr_data_gen(), libMesh::ErrorVector::plot_error(), libMesh::Nemesis_IO::read(), libMesh::AbaqusIO::read_nodes(), libMesh::MeshTools::Modification::redistribute(), libMesh::MeshTools::Modification::smooth(), libMesh::VariationalMeshSmoother::smooth(), libMesh::DirectSolutionTransfer::transfer(), libMesh::TreeNode< N >::transform_nodes_to_elements(), libMesh::TriangleInterface::triangulate(), libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole(), libMesh::FroIO::write(), libMesh::TetGenIO::write(), libMesh::XdrIO::write(), libMesh::MEDITIO::write_ascii(), libMesh::TecplotIO::write_ascii(), libMesh::GMVIO::write_ascii_new_impl(), libMesh::GMVIO::write_ascii_old_impl(), libMesh::TecplotIO::write_binary(), libMesh::GMVIO::write_binary(), libMesh::UCDIO::write_header(), libMesh::VTKIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::GmshIO::write_post(), libMesh::XdrIO::write_serialized_nodes(), libMesh::UCDIO::write_soln(), and libMesh::VariationalMeshSmoother::writegr().

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

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

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

350 {
351  // We're either counting a processor's nodes or unpartitioned
352  // nodes
353  libmesh_assert (proc_id < this->n_processors() ||
355 
356  return static_cast<dof_id_type>(std::distance (this->pid_nodes_begin(proc_id),
357  this->pid_nodes_end (proc_id)));
358 }
virtual node_iterator pid_nodes_end(processor_id_type proc_id)=0
processor_id_type n_processors() const
Real distance(const Point &p)
libmesh_assert(j)
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:335
virtual node_iterator pid_nodes_begin(processor_id_type proc_id)=0
Iterate over nodes with processor_id() == proc_id.
uint8_t dof_id_type
Definition: id_types.h:64
unsigned int libMesh::MeshBase::n_partitions ( ) const
inherited
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 833 of file mesh_base.h.

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

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

834  { return _n_parts; }
unsigned int _n_parts
The number of partitions the mesh has.
Definition: mesh_base.h:1342
processor_id_type libMesh::ParallelObject::n_processors ( ) const
inherited
Returns
The number of processors in the group.

Definition at line 93 of file parallel_object.h.

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

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

94  { return cast_int<processor_id_type>(_communicator.size()); }
unsigned int size() const
Definition: parallel.h:726
const Parallel::Communicator & _communicator
dof_id_type libMesh::MeshBase::n_sub_elem ( ) const
inherited
Returns
The number of elements that will be written out in certain I/O formats.

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

Definition at line 384 of file mesh_base.C.

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

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

385 {
386  dof_id_type ne=0;
387 
388  const_element_iterator el = this->elements_begin();
389  const const_element_iterator end = this->elements_end();
390 
391  for (; el!=end; ++el)
392  ne += (*el)->n_sub_elem();
393 
394  return ne;
395 }
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
virtual element_iterator elements_begin()=0
Iterate over all the elements in the Mesh.
virtual element_iterator elements_end()=0
uint8_t dof_id_type
Definition: id_types.h:64
subdomain_id_type libMesh::MeshBase::n_subdomains ( ) const
inherited
Returns
The number of subdomains in the global mesh. Subdomains correspond to separate subsets of the mesh which could correspond e.g. to different materials in a solid mechanics application, or regions where different physical processes are important. The subdomain mapping is independent from the parallel decomposition.

Definition at line 334 of file mesh_base.C.

References libMesh::MeshBase::subdomain_ids().

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

335 {
336  // This requires an inspection on every processor
337  parallel_object_only();
338 
339  std::set<subdomain_id_type> ids;
340 
341  this->subdomain_ids (ids);
342 
343  return cast_int<subdomain_id_type>(ids.size());
344 }
void subdomain_ids(std::set< subdomain_id_type > &ids) const
Constructs a list of all subdomain identifiers in the global mesh.
Definition: mesh_base.C:315
dof_id_type libMesh::MeshBase::n_unpartitioned_elem ( ) const
inherited
Returns
The number of elements owned by no processor.

Definition at line 378 of file mesh_base.h.

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

Referenced by 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:362
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:335
dof_id_type libMesh::MeshBase::n_unpartitioned_nodes ( ) const
inherited
Returns
The number of nodes owned by no processor.

Definition at line 278 of file mesh_base.h.

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

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

dof_id_type n_nodes_on_proc(const processor_id_type proc) const
Definition: mesh_base.C:349
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:335
unique_id_type libMesh::MeshBase::next_unique_id ( )
inherited
Returns
The next unique id to be used.

Definition at line 291 of file mesh_base.h.

References libMesh::MeshBase::_next_unique_id.

291 { return _next_unique_id; }
unique_id_type _next_unique_id
The next available unique id for assigning ids to DOF objects.
Definition: mesh_base.h:1376
virtual const Node& libMesh::MeshBase::node ( const dof_id_type  i) const
virtualinherited
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 440 of file mesh_base.h.

References libMesh::MeshBase::node_ptr().

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

441  {
442  libmesh_deprecated();
443  return *this->node_ptr(i);
444  }
virtual const Node * node_ptr(const dof_id_type i) const =0
virtual Node& libMesh::MeshBase::node ( const dof_id_type  i)
virtualinherited
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 454 of file mesh_base.h.

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

455  {
456  libmesh_deprecated();
457  return *this->node_ptr(i);
458  }
virtual const Node * node_ptr(const dof_id_type i) const =0
virtual const Node* libMesh::MeshBase::node_ptr ( const dof_id_type  i) const
pure virtualinherited
virtual Node* libMesh::MeshBase::node_ptr ( const dof_id_type  i)
pure virtualinherited
Returns
A writable pointer to the $ i^{th} $ node, which should be present in this processor's subset of the mesh data structure.

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

virtual SimpleRange<node_iterator> libMesh::MeshBase::node_ptr_range ( )
pure virtualinherited
virtual SimpleRange<const_node_iterator> libMesh::MeshBase::node_ptr_range ( ) const
pure virtualinherited
virtual const Node& libMesh::MeshBase::node_ref ( const dof_id_type  i) const
virtualinherited
virtual Node& libMesh::MeshBase::node_ref ( const dof_id_type  i)
virtualinherited
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 428 of file mesh_base.h.

References libMesh::MeshBase::node_ptr().

428  {
429  return *this->node_ptr(i);
430  }
virtual const Node * node_ptr(const dof_id_type i) const =0
virtual node_iterator libMesh::MeshBase::nodes_begin ( )
pure virtualinherited
virtual const_node_iterator libMesh::MeshBase::nodes_begin ( ) const
pure virtualinherited
virtual node_iterator libMesh::MeshBase::nodes_end ( )
pure virtualinherited
virtual const_node_iterator libMesh::MeshBase::nodes_end ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::not_active_elements_begin ( )
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::not_active_elements_begin ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::not_active_elements_end ( )
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::not_active_elements_end ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::not_ancestor_elements_begin ( )
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::not_ancestor_elements_begin ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::not_ancestor_elements_end ( )
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::not_ancestor_elements_end ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::not_level_elements_begin ( unsigned int  level)
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::not_level_elements_begin ( unsigned int  level) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::not_level_elements_end ( unsigned int  level)
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::not_level_elements_end ( unsigned int  level) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::not_local_elements_begin ( )
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::not_local_elements_begin ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::not_local_elements_end ( )
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::not_local_elements_end ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::not_subactive_elements_begin ( )
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::not_subactive_elements_begin ( ) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::not_subactive_elements_end ( )
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::not_subactive_elements_end ( ) const
pure virtualinherited
virtual unique_id_type libMesh::MeshBase::parallel_max_unique_id ( ) const
pure virtualinherited
virtual dof_id_type libMesh::MeshBase::parallel_n_elem ( ) const
pure virtualinherited
Returns
The number of elements in the mesh.

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

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

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

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

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

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

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

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

Call the default partitioner (currently metis_partition()).

Definition at line 462 of file mesh_base.C.

References libMesh::MeshBase::is_serial(), libMesh::libmesh_assert(), libMesh::MeshBase::n_unpartitioned_elem(), libMesh::MeshBase::partitioner(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::Partitioner::set_node_processor_ids(), libMesh::MeshBase::skip_partitioning(), and libMesh::MeshBase::update_post_partitioning().

Referenced by main(), and MappedSubdomainPartitionerTest::testMappedSubdomainPartitioner().

463 {
464  // If we get here and we have unpartitioned elements, we need that
465  // fixed.
466  if (this->n_unpartitioned_elem() > 0)
467  {
468  libmesh_assert (partitioner().get());
469  libmesh_assert (this->is_serial());
470  partitioner()->partition (*this, n_parts);
471  }
472  // NULL partitioner means don't repartition
473  // Non-serial meshes may not be ready for repartitioning here.
474  else if (!skip_partitioning() && partitioner().get())
475  {
476  partitioner()->partition (*this, n_parts);
477  }
478  else
479  {
480  // Adaptive coarsening may have "orphaned" nodes on processors
481  // whose elements no longer share them. We need to check for
482  // and possibly fix that.
484 
485  // Make sure locally cached partition count
486  this->recalculate_n_partitions();
487 
488  // Make sure any other locally cached data is correct
489  this->update_post_partitioning();
490  }
491 }
virtual bool is_serial() const
Definition: mesh_base.h:140
bool skip_partitioning() const
Definition: mesh_base.h:775
static void set_node_processor_ids(MeshBase &mesh)
This function is called after partitioning to set the processor IDs for the nodes.
Definition: partitioner.C:416
dof_id_type n_unpartitioned_elem() const
Definition: mesh_base.h:378
libmesh_assert(j)
unsigned int recalculate_n_partitions()
In a few (very rare) cases, the user may have manually tagged the elements with specific processor ID...
Definition: mesh_base.C:493
virtual UniquePtr< Partitioner > & partitioner()
A partitioner to use at each prepare_for_use()
Definition: mesh_base.h:112
virtual void update_post_partitioning()
Recalculate any cached data after elements and nodes have been repartitioned.
Definition: mesh_base.h:741
void libMesh::MeshBase::partition ( )
inherited

Definition at line 727 of file mesh_base.h.

References libMesh::ParallelObject::n_processors().

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

728  { this->partition(this->n_processors()); }
processor_id_type n_processors() const
virtual UniquePtr<Partitioner>& libMesh::MeshBase::partitioner ( )
virtualinherited
virtual element_iterator libMesh::MeshBase::pid_elements_begin ( processor_id_type  proc_id)
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::pid_elements_begin ( processor_id_type  proc_id) const
pure virtualinherited
virtual element_iterator libMesh::MeshBase::pid_elements_end ( processor_id_type  proc_id)
pure virtualinherited
virtual const_element_iterator libMesh::MeshBase::pid_elements_end ( processor_id_type  proc_id) const
pure virtualinherited
virtual node_iterator libMesh::MeshBase::pid_nodes_begin ( processor_id_type  proc_id)
pure virtualinherited
virtual const_node_iterator libMesh::MeshBase::pid_nodes_begin ( processor_id_type  proc_id) const
pure virtualinherited
virtual node_iterator libMesh::MeshBase::pid_nodes_end ( processor_id_type  proc_id)
pure virtualinherited
virtual const_node_iterator libMesh::MeshBase::pid_nodes_end ( processor_id_type  proc_id) const
pure virtualinherited
virtual const Point& libMesh::MeshBase::point ( const dof_id_type  i) const
pure virtualinherited
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 517 of file mesh_base.C.

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

518 {
519  libmesh_deprecated();
520 
521  if (_point_locator.get() == libmesh_nullptr)
522  {
523  // PointLocator construction may not be safe within threads
525 
526  _point_locator.reset (PointLocatorBase::build(TREE_ELEMENTS, *this).release());
527  }
528 
529  return *_point_locator;
530 }
UniquePtr< PointLocatorBase > _point_locator
A PointLocator class for this mesh.
Definition: mesh_base.h:1356
const class libmesh_nullptr_t libmesh_nullptr
bool in_threads
A boolean which is true iff we are in a Threads:: function It may be useful to assert(!Threadsin_thre...
Definition: threads.C:31
libmesh_assert(j)
static UniquePtr< PointLocatorBase > build(PointLocatorType t, const MeshBase &mesh, const PointLocatorBase *master=libmesh_nullptr)
Builds an PointLocator for the mesh mesh.
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 174 of file mesh_base.C.

References libMesh::MeshBase::_allow_remote_element_removal, 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::ghosting_functors_begin(), libMesh::MeshBase::ghosting_functors_end(), libMesh::MeshBase::is_serial(), libMesh::libmesh_assert(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_unique_ids(), libMesh::GhostingFunctor::mesh_reinit(), libMesh::MeshBase::partition(), libMesh::MeshBase::renumber_nodes_and_elements(), libMesh::MeshBase::update_parallel_id_counts(), and libMesh::Parallel::verify().

Referenced by LinearElasticityWithContact::add_contact_edge_elements(), all_first_order(), all_second_order(), libMesh::MeshTools::Subdivision::all_subdivision(), libMesh::MeshTools::Modification::all_tri(), libMesh::MeshTools::Generation::build_cube(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::InfElemBuilder::build_inf_elem(), MixedDimensionMeshTest::build_mesh(), MeshfunctionDFEM::build_mesh(), SlitMeshTest::build_mesh(), MixedDimensionNonUniformRefinement::build_mesh(), MixedDimensionNonUniformRefinementTriangle::build_mesh(), MixedDimensionNonUniformRefinement3D::build_mesh(), libMesh::MeshTools::Generation::build_sphere(), libMesh::MeshRefinement::coarsen_elements(), copy_nodes_and_elements(), create_submesh(), libMesh::MeshTools::Modification::flatten(), main(), libMesh::MeshTools::Subdivision::prepare_subdivision_mesh(), libMesh::MeshBase::query_elem(), libMesh::GMVIO::read(), read(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::MeshRefinement::refine_elements(), libMesh::ReplicatedMesh::stitching_helper(), libMesh::BoundaryInfo::sync(), MeshSpatialDimensionTest::test1D(), MeshSpatialDimensionTest::test2D(), EquationSystemsTest::testPostInitAddElem(), BoundaryInfoTest::testShellFaceConstraints(), WriteVecAndScalar::testWrite(), tetrahedralize_domain(), libMesh::TriangleInterface::triangulate(), libMesh::MeshRefinement::uniformly_coarsen(), and libMesh::MeshRefinement::uniformly_refine().

175 {
176  LOG_SCOPE("prepare_for_use()", "MeshBase");
177 
178  parallel_object_only();
179 
180  libmesh_assert(this->comm().verify(this->is_serial()));
181 
182  // A distributed mesh may have processors with no elements (or
183  // processors with no elements of higher dimension, if we ever
184  // support mixed-dimension meshes), but we want consistent
185  // mesh_dimension anyways.
186  //
187  // cache_elem_dims() should get the elem_dimensions() and
188  // mesh_dimension() correct later, and we don't need it earlier.
189 
190 
191  // Renumber the nodes and elements so that they in contiguous
192  // blocks. By default, _skip_renumber_nodes_and_elements is false.
193  //
194  // We may currently change that by passing
195  // skip_renumber_nodes_and_elements==true to this function, but we
196  // should use the allow_renumbering() accessor instead.
197  //
198  // Instances where you if prepare_for_use() should not renumber the nodes
199  // and elements include reading in e.g. an xda/r or gmv file. In
200  // this case, the ordering of the nodes may depend on an accompanying
201  // solution, and the node ordering cannot be changed.
202 
203  if (skip_renumber_nodes_and_elements)
204  {
205  libmesh_deprecated();
206  this->allow_renumbering(false);
207  }
208 
209  // Mesh modification operations might not leave us with consistent
210  // id counts, but our partitioner might need that consistency.
213  else
215 
216  // Let all the elements find their neighbors
217  if (!skip_find_neighbors)
218  this->find_neighbors();
219 
220  // The user may have set boundary conditions. We require that the
221  // boundary conditions were set consistently. Because we examine
222  // neighbors when evaluating non-raw boundary condition IDs, this
223  // assert is only valid when our neighbor links are in place.
224 #ifdef DEBUG
226 #endif
227 
228  // Search the mesh for all the dimensions of the elements
229  // and cache them.
230  this->cache_elem_dims();
231 
232  // Search the mesh for elements that have a neighboring element
233  // of dim+1 and set that element as the interior parent
234  this->detect_interior_parents();
235 
236  // Fix up node unique ids in case mesh generation code didn't take
237  // exceptional care to do so.
238  // MeshCommunication().make_node_unique_ids_parallel_consistent(*this);
239 
240  // We're going to still require that mesh generation code gets
241  // element unique ids consistent.
242 #if defined(DEBUG) && defined(LIBMESH_ENABLE_UNIQUE_ID)
244 #endif
245 
246  // Reset our PointLocator. Any old locator is invalidated any time
247  // the elements in the underlying elements in the mesh have changed,
248  // so we clear it here.
249  this->clear_point_locator();
250 
251  // Allow our GhostingFunctor objects to reinit if necessary.
252  // Do this before partitioning and redistributing, and before
253  // deleting remote elements.
254  std::set<GhostingFunctor *>::iterator gf_it = this->ghosting_functors_begin();
255  const std::set<GhostingFunctor *>::iterator gf_end = this->ghosting_functors_end();
256  for (; gf_it != gf_end; ++gf_it)
257  {
258  GhostingFunctor * gf = *gf_it;
259  libmesh_assert(gf);
260  gf->mesh_reinit();
261  }
262 
263  // Partition the mesh.
264  this->partition();
265 
266  // If we're using DistributedMesh, we'll probably want it
267  // parallelized.
269  this->delete_remote_elements();
270 
273 
274  // The mesh is now prepared for use.
275  _is_prepared = true;
276 
277 #if defined(DEBUG) && defined(LIBMESH_ENABLE_UNIQUE_ID)
280 #endif
281 }
bool _skip_renumber_nodes_and_elements
If this is true then renumbering will be kept to a minimum.
Definition: mesh_base.h:1389
virtual bool is_serial() const
Definition: mesh_base.h:140
void detect_interior_parents()
Search the mesh for elements that have a neighboring element of dim+1 and set that element as the int...
Definition: mesh_base.C:678
bool _allow_remote_element_removal
If this is false then even on DistributedMesh remote elements will not be deleted during mesh prepara...
Definition: mesh_base.h:1397
libmesh_assert(j)
std::set< GhostingFunctor * >::const_iterator ghosting_functors_end() const
End of range of ghosting functors.
Definition: mesh_base.h:804
virtual void find_neighbors(const bool reset_remote_elements=false, const bool reset_current_list=true)=0
Locate element face (edge in 2D) neighbors.
virtual void update_parallel_id_counts()=0
Updates parallel caches so that methods like n_elem() accurately reflect changes on other processors...
void clear_point_locator()
Releases the current PointLocator object.
Definition: mesh_base.C:555
void libmesh_assert_valid_boundary_ids(const MeshBase &mesh)
A function for verifying that boundary condition ids match across processors.
Definition: mesh_tools.C:1194
std::set< GhostingFunctor * >::const_iterator ghosting_functors_begin() const
Beginning of range of ghosting functors.
Definition: mesh_base.h:798
bool verify(const T &r, const Communicator &comm=Communicator_World)
const Parallel::Communicator & comm() const
bool allow_renumbering() const
Definition: mesh_base.h:750
bool _is_prepared
Flag indicating if the mesh has been prepared for use.
Definition: mesh_base.h:1347
virtual void delete_remote_elements()
When supported, deletes all nonlocal elements of the mesh except for "ghosts" which touch a local ele...
Definition: mesh_base.h:182
void cache_elem_dims()
Search the mesh and cache the different dimensions of the elements present in the mesh...
Definition: mesh_base.C:612