libMesh::BoundaryMesh Class Reference

#include <boundary_mesh.h>

Inheritance diagram for libMesh::BoundaryMesh:

Public Types

typedef Predicates::multi_predicate Predicate
 

Public Member Functions

 BoundaryMesh (const Parallel::Communicator &comm, unsigned int dim=1)
 
 BoundaryMesh (unsigned int dim=1)
 
 ~BoundaryMesh ()
 
virtual AutoPtr< MeshBaseclone () const
 
virtual void clear ()
 
virtual void redistribute ()
 
virtual void update_post_partitioning ()
 
virtual bool is_serial () const
 
template<typename T >
void libmesh_assert_valid_parallel_object_ids (const mapvector< T *, dof_id_type > &) const
 
virtual void libmesh_assert_valid_parallel_ids () const
 
void libmesh_assert_valid_parallel_flags () const
 
template<typename T >
dof_id_type renumber_dof_objects (mapvector< T *, dof_id_type > &)
 
virtual void renumber_nodes_and_elements ()
 
virtual void allgather ()
 
virtual void delete_remote_elements ()
 
virtual void add_extra_ghost_elem (Elem *e)
 
virtual void clear_extra_ghost_elems ()
 
virtual dof_id_type n_nodes () const
 
virtual dof_id_type max_node_id () const
 
virtual void reserve_nodes (const dof_id_type)
 
virtual dof_id_type n_elem () const
 
virtual dof_id_type n_active_elem () const
 
virtual dof_id_type max_elem_id () const
 
virtual void reserve_elem (const dof_id_type)
 
virtual void update_parallel_id_counts ()
 
dof_id_type parallel_n_nodes () const
 
dof_id_type parallel_max_node_id () const
 
dof_id_type parallel_n_elem () const
 
dof_id_type parallel_max_elem_id () const
 
virtual const Pointpoint (const dof_id_type i) const
 
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
 
virtual Nodenode_ptr (const dof_id_type i)
 
virtual const Nodequery_node_ptr (const dof_id_type i) const
 
virtual Nodequery_node_ptr (const dof_id_type i)
 
virtual const Elemelem (const dof_id_type i) const
 
virtual Elemelem (const dof_id_type i)
 
virtual const Elemquery_elem (const dof_id_type i) const
 
virtual Elemquery_elem (const dof_id_type i)
 
virtual Nodeadd_point (const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)
 
virtual Nodeadd_node (Node *n)
 
virtual Nodeinsert_node (Node *n)
 
virtual void delete_node (Node *n)
 
virtual void renumber_node (dof_id_type old_id, dof_id_type new_id)
 
virtual Elemadd_elem (Elem *e)
 
virtual Eleminsert_elem (Elem *e)
 
virtual void delete_elem (Elem *e)
 
virtual void renumber_elem (dof_id_type old_id, dof_id_type new_id)
 
virtual void fix_broken_node_and_element_numbering ()
 
element_iterator elements_begin ()
 
const_element_iterator elements_begin () const
 
element_iterator elements_end ()
 
const_element_iterator elements_end () const
 
element_iterator active_elements_begin ()
 
const_element_iterator active_elements_begin () const
 
element_iterator active_elements_end ()
 
const_element_iterator active_elements_end () const
 
element_iterator ancestor_elements_begin ()
 
const_element_iterator ancestor_elements_begin () const
 
element_iterator ancestor_elements_end ()
 
const_element_iterator ancestor_elements_end () const
 
element_iterator subactive_elements_begin ()
 
const_element_iterator subactive_elements_begin () const
 
element_iterator subactive_elements_end ()
 
const_element_iterator subactive_elements_end () const
 
element_iterator not_active_elements_begin ()
 
const_element_iterator not_active_elements_begin () const
 
element_iterator not_active_elements_end ()
 
const_element_iterator not_active_elements_end () const
 
element_iterator not_ancestor_elements_begin ()
 
const_element_iterator not_ancestor_elements_begin () const
 
element_iterator not_ancestor_elements_end ()
 
const_element_iterator not_ancestor_elements_end () const
 
element_iterator not_subactive_elements_begin ()
 
const_element_iterator not_subactive_elements_begin () const
 
element_iterator not_subactive_elements_end ()
 
const_element_iterator not_subactive_elements_end () const
 
element_iterator local_elements_begin ()
 
const_element_iterator local_elements_begin () const
 
element_iterator local_elements_end ()
 
const_element_iterator local_elements_end () const
 
element_iterator not_local_elements_begin ()
 
const_element_iterator not_local_elements_begin () const
 
element_iterator not_local_elements_end ()
 
const_element_iterator not_local_elements_end () const
 
element_iterator active_local_elements_begin ()
 
const_element_iterator active_local_elements_begin () const
 
element_iterator active_local_elements_end ()
 
const_element_iterator active_local_elements_end () const
 
element_iterator active_not_local_elements_begin ()
 
const_element_iterator active_not_local_elements_begin () const
 
element_iterator active_not_local_elements_end ()
 
const_element_iterator active_not_local_elements_end () const
 
element_iterator level_elements_begin (const unsigned int level)
 
const_element_iterator level_elements_begin (const unsigned int level) const
 
element_iterator level_elements_end (const unsigned int level)
 
const_element_iterator level_elements_end (const unsigned int level) const
 
element_iterator not_level_elements_begin (const unsigned int level)
 
const_element_iterator not_level_elements_begin (const unsigned int level) const
 
element_iterator not_level_elements_end (const unsigned int level)
 
const_element_iterator not_level_elements_end (const unsigned int level) const
 
element_iterator local_level_elements_begin (const unsigned int level)
 
const_element_iterator local_level_elements_begin (const unsigned int level) const
 
element_iterator local_level_elements_end (const unsigned int level)
 
const_element_iterator local_level_elements_end (const unsigned int level) const
 
element_iterator local_not_level_elements_begin (const unsigned int level)
 
const_element_iterator local_not_level_elements_begin (const unsigned int level) const
 
element_iterator local_not_level_elements_end (const unsigned int level)
 
const_element_iterator local_not_level_elements_end (const unsigned int level) const
 
element_iterator pid_elements_begin (const processor_id_type proc_id)
 
const_element_iterator pid_elements_begin (const processor_id_type proc_id) const
 
element_iterator pid_elements_end (const processor_id_type proc_id)
 
const_element_iterator pid_elements_end (const processor_id_type proc_id) const
 
element_iterator type_elements_begin (const ElemType type)
 
const_element_iterator type_elements_begin (const ElemType type) const
 
element_iterator type_elements_end (const ElemType type)
 
const_element_iterator type_elements_end (const ElemType type) const
 
element_iterator active_type_elements_begin (const ElemType type)
 
const_element_iterator active_type_elements_begin (const ElemType type) const
 
element_iterator active_type_elements_end (const ElemType type)
 
const_element_iterator active_type_elements_end (const ElemType type) const
 
element_iterator active_pid_elements_begin (const processor_id_type proc_id)
 
const_element_iterator active_pid_elements_begin (const processor_id_type proc_id) const
 
element_iterator active_pid_elements_end (const processor_id_type proc_id)
 
const_element_iterator active_pid_elements_end (const processor_id_type proc_id) const
 
element_iterator unpartitioned_elements_begin ()
 
const_element_iterator unpartitioned_elements_begin () const
 
element_iterator unpartitioned_elements_end ()
 
const_element_iterator unpartitioned_elements_end () const
 
element_iterator active_local_subdomain_elements_begin (const subdomain_id_type subdomain_id)
 
const_element_iterator active_local_subdomain_elements_begin (const subdomain_id_type subdomain_id) const
 
element_iterator active_local_subdomain_elements_end (const subdomain_id_type subdomain_id)
 
const_element_iterator active_local_subdomain_elements_end (const subdomain_id_type subdomain_id) const
 
element_iterator active_subdomain_elements_begin (const subdomain_id_type subdomain_id)
 
const_element_iterator active_subdomain_elements_begin (const subdomain_id_type subdomain_id) const
 
element_iterator active_subdomain_elements_end (const subdomain_id_type subdomain_id)
 
const_element_iterator active_subdomain_elements_end (const subdomain_id_type subdomain_id) const
 
node_iterator nodes_begin ()
 
const_node_iterator nodes_begin () const
 
node_iterator nodes_end ()
 
const_node_iterator nodes_end () const
 
node_iterator active_nodes_begin ()
 
const_node_iterator active_nodes_begin () const
 
node_iterator active_nodes_end ()
 
const_node_iterator active_nodes_end () const
 
node_iterator local_nodes_begin ()
 
const_node_iterator local_nodes_begin () const
 
node_iterator local_nodes_end ()
 
const_node_iterator local_nodes_end () const
 
node_iterator pid_nodes_begin (const processor_id_type proc_id)
 
const_node_iterator pid_nodes_begin (const processor_id_type proc_id) const
 
node_iterator pid_nodes_end (const processor_id_type proc_id)
 
const_node_iterator pid_nodes_end (const processor_id_type proc_id) const
 
void read (const std::string &name, MeshData *mesh_data=NULL, bool skip_renumber_nodes_and_elements=false)
 
void write (const std::string &name, MeshData *mesh_data=NULL)
 
void write (const std::string &name, const std::vector< Number > &values, const std::vector< std::string > &variable_names)
 
virtual void all_first_order ()
 
virtual void all_second_order (const bool full_ordered=true)
 
void create_pid_mesh (UnstructuredMesh &pid_mesh, const processor_id_type pid) const
 
void create_submesh (UnstructuredMesh &new_mesh, const_element_iterator &it, const const_element_iterator &it_end) const
 
virtual void copy_nodes_and_elements (const UnstructuredMesh &other_mesh)
 
virtual void find_neighbors (const bool reset_remote_elements=false, const bool reset_current_list=true)
 
virtual bool contract ()
 
virtual AutoPtr< Partitioner > & partitioner ()
 
bool is_prepared () const
 
unsigned int mesh_dimension () const
 
void set_mesh_dimension (unsigned int d)
 
unsigned int spatial_dimension () const
 
dof_id_type n_nodes_on_proc (const processor_id_type proc) const
 
dof_id_type n_local_nodes () const
 
dof_id_type n_unpartitioned_nodes () const
 
unique_id_type next_unique_id ()
 
void set_next_unique_id (unique_id_type id)
 
dof_id_type n_elem_on_proc (const processor_id_type proc) const
 
dof_id_type n_local_elem () const
 
dof_id_type n_unpartitioned_elem () const
 
dof_id_type n_active_elem_on_proc (const processor_id_type proc) const
 
dof_id_type n_active_local_elem () const
 
dof_id_type n_sub_elem () const
 
dof_id_type n_active_sub_elem () const
 
void prepare_for_use (const bool skip_renumber_nodes_and_elements=false)
 
virtual void partition (const unsigned int n_parts)
 
void partition ()
 
void allow_renumbering (bool allow)
 
bool allow_renumbering () const
 
void skip_partitioning (bool skip)
 
bool skip_partitioning () const
 
void subdomain_ids (std::set< subdomain_id_type > &ids) const
 
subdomain_id_type n_subdomains () const
 
unsigned int n_partitions () const
 
std::string get_info () const
 
void print_info (std::ostream &os=libMesh::out) const
 
unsigned int recalculate_n_partitions ()
 
const PointLocatorBasepoint_locator () const
 
AutoPtr< PointLocatorBasesub_point_locator () const
 
void clear_point_locator ()
 
std::string & subdomain_name (subdomain_id_type id)
 
const std::string & subdomain_name (subdomain_id_type id) const
 
subdomain_id_type get_id_by_name (const std::string &name) const
 
std::map< subdomain_id_type,
std::string > & 
set_subdomain_name_map ()
 
const std::map
< subdomain_id_type,
std::string > & 
get_subdomain_name_map () const
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Public Attributes

AutoPtr< BoundaryInfoboundary_info
 

Protected Member Functions

virtual void assign_unique_ids ()
 
unsigned int & set_n_partitions ()
 

Protected Attributes

mapvector< Node *, dof_id_type_nodes
 
mapvector< Elem *, dof_id_type_elements
 
bool _is_serial
 
dof_id_type _n_nodes
 
dof_id_type _n_elem
 
dof_id_type _max_node_id
 
dof_id_type _max_elem_id
 
dof_id_type _next_free_local_node_id
 
dof_id_type _next_free_local_elem_id
 
dof_id_type _next_free_unpartitioned_node_id
 
dof_id_type _next_free_unpartitioned_elem_id
 
std::set< Elem * > _extra_ghost_elems
 
unsigned int _n_parts
 
unsigned int _dim
 
bool _is_prepared
 
AutoPtr< PointLocatorBase_point_locator
 
AutoPtr< Partitioner_partitioner
 
unique_id_type _next_unique_id
 
bool _skip_partitioning
 
bool _skip_renumber_nodes_and_elements
 
std::map< subdomain_id_type,
std::string > 
_block_id_to_name
 
const Parallel::Communicator_communicator
 

Detailed Description

The BoundaryMesh is a Mesh in its own right, but it contains a description of the boundary of some other mesh. This is useful for writing the boundary of a domain for inspecting boundary conditions and other things.

Definition at line 42 of file boundary_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 632 of file mesh_base.h.

Constructor & Destructor Documentation

libMesh::BoundaryMesh::BoundaryMesh ( const Parallel::Communicator comm,
unsigned int  dim = 1 
)
explicit

Constructor. Initializes dimenstion and processor id.

Definition at line 32 of file boundary_mesh.C.

33  :
34  Mesh(comm,d)
35 {
36 }
libMesh::BoundaryMesh::BoundaryMesh ( unsigned int  dim = 1)
explicit

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

Definition at line 42 of file boundary_mesh.C.

42  :
43  Mesh(d)
44 {
45 }
libMesh::BoundaryMesh::~BoundaryMesh ( )

Destructor.

Definition at line 50 of file boundary_mesh.C.

References libMesh::ParallelMesh::clear().

51 {
52  this->clear();
53 }

Member Function Documentation

ParallelMesh::element_iterator libMesh::ParallelMesh::active_elements_begin ( )
virtualinherited

Implements libMesh::MeshBase.

Definition at line 47 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

48 {
49  Predicates::Active<elem_iterator_imp> p;
50  return element_iterator(_elements.begin(), _elements.end(), p);
51 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::active_elements_begin ( ) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 272 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

273 {
274  Predicates::Active<const_elem_iterator_imp> p;
275  return const_element_iterator(_elements.begin(), _elements.end(), p);
276 }
ParallelMesh::element_iterator libMesh::ParallelMesh::active_elements_end ( )
virtualinherited

Implements libMesh::MeshBase.

Definition at line 494 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

495 {
496  Predicates::Active<elem_iterator_imp> p;
497  return element_iterator(_elements.end(), _elements.end(), p);
498 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::active_elements_end ( ) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 719 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

720 {
721  Predicates::Active<const_elem_iterator_imp> p;
722  return const_element_iterator(_elements.end(), _elements.end(), p);
723 }
ParallelMesh::element_iterator libMesh::ParallelMesh::active_local_elements_begin ( )
virtualinherited

Implements libMesh::MeshBase.

Definition at line 127 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

Referenced by libMesh::ParallelMesh::n_active_elem().

128 {
129  Predicates::ActiveLocal<elem_iterator_imp> p(this->processor_id());
130  return element_iterator(_elements.begin(), _elements.end(), p);
131 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::active_local_elements_begin ( ) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 351 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

352 {
353  Predicates::ActiveLocal<const_elem_iterator_imp> p(this->processor_id());
354  return const_element_iterator(_elements.begin(), _elements.end(), p);
355 }
ParallelMesh::element_iterator libMesh::ParallelMesh::active_local_elements_end ( )
virtualinherited

Implements libMesh::MeshBase.

Definition at line 574 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

Referenced by libMesh::ParallelMesh::n_active_elem().

575 {
576  Predicates::ActiveLocal<elem_iterator_imp> p(this->processor_id());
577  return element_iterator(_elements.end(), _elements.end(), p);
578 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::active_local_elements_end ( ) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 799 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

800 {
801  Predicates::ActiveLocal<const_elem_iterator_imp> p(this->processor_id());
802  return const_element_iterator(_elements.end(), _elements.end(), p);
803 }
ParallelMesh::element_iterator libMesh::ParallelMesh::active_local_subdomain_elements_begin ( const subdomain_id_type  subdomain_id)
virtualinherited

Implements libMesh::MeshBase.

Definition at line 236 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

237 {
238  Predicates::ActiveLocalSubdomain<elem_iterator_imp> p(this->processor_id(),subdomain_id);
239  return element_iterator(_elements.begin(), _elements.end(), p);
240 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::active_local_subdomain_elements_begin ( const subdomain_id_type  subdomain_id) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 460 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

461 {
462  Predicates::ActiveLocalSubdomain<const_elem_iterator_imp> p(this->processor_id(),subdomain_id);
463  return const_element_iterator(_elements.begin(), _elements.end(), p);
464 }
ParallelMesh::element_iterator libMesh::ParallelMesh::active_local_subdomain_elements_end ( const subdomain_id_type  subdomain_id)
virtualinherited

Implements libMesh::MeshBase.

Definition at line 683 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

684 {
685  Predicates::ActiveLocalSubdomain<elem_iterator_imp> p(this->processor_id(),subdomain_id);
686  return element_iterator(_elements.end(), _elements.end(), p);
687 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::active_local_subdomain_elements_end ( const subdomain_id_type  subdomain_id) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 907 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

908 {
909  Predicates::ActiveLocalSubdomain<const_elem_iterator_imp> p(this->processor_id(),subdomain_id);
910  return const_element_iterator(_elements.end(), _elements.end(), p);
911 }
ParallelMesh::node_iterator libMesh::ParallelMesh::active_nodes_begin ( )
virtualinherited

Implements libMesh::MeshBase.

Definition at line 941 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_nodes.

942 {
943  Predicates::Active<node_iterator_imp> p;
944  return node_iterator(_nodes.begin(), _nodes.end(), p);
945 }
ParallelMesh::const_node_iterator libMesh::ParallelMesh::active_nodes_begin ( ) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 981 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_nodes.

982 {
983  Predicates::Active<const_node_iterator_imp> p;
984  return const_node_iterator(_nodes.begin(), _nodes.end(), p);
985 }
ParallelMesh::node_iterator libMesh::ParallelMesh::active_nodes_end ( )
virtualinherited

Implements libMesh::MeshBase.

Definition at line 1021 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_nodes.

1022 {
1023  Predicates::Active<node_iterator_imp> p;
1024  return node_iterator(_nodes.end(), _nodes.end(), p);
1025 }
ParallelMesh::const_node_iterator libMesh::ParallelMesh::active_nodes_end ( ) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 1061 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_nodes.

1062 {
1063  Predicates::Active<const_node_iterator_imp> p;
1064  return const_node_iterator(_nodes.end(), _nodes.end(), p);
1065 }
ParallelMesh::element_iterator libMesh::ParallelMesh::active_not_local_elements_begin ( )
virtualinherited

Implements libMesh::MeshBase.

Definition at line 137 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

138 {
139  Predicates::ActiveNotLocal<elem_iterator_imp> p(this->processor_id());
140  return element_iterator(_elements.begin(), _elements.end(), p);
141 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::active_not_local_elements_begin ( ) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 361 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

362 {
363  Predicates::ActiveNotLocal<const_elem_iterator_imp> p(this->processor_id());
364  return const_element_iterator(_elements.begin(), _elements.end(), p);
365 }
ParallelMesh::element_iterator libMesh::ParallelMesh::active_not_local_elements_end ( )
virtualinherited

Implements libMesh::MeshBase.

Definition at line 584 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

585 {
586  Predicates::ActiveNotLocal<elem_iterator_imp> p(this->processor_id());
587  return element_iterator(_elements.end(), _elements.end(), p);
588 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::active_not_local_elements_end ( ) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 809 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

810 {
811  Predicates::ActiveNotLocal<const_elem_iterator_imp> p(this->processor_id());
812  return const_element_iterator(_elements.end(), _elements.end(), p);
813 }
ParallelMesh::element_iterator libMesh::ParallelMesh::active_pid_elements_begin ( const processor_id_type  proc_id)
virtualinherited

Implements libMesh::MeshBase.

Definition at line 217 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

Referenced by libMesh::ParallelMesh::n_active_elem().

218 {
219  Predicates::ActivePID<elem_iterator_imp> p(proc_id);
220  return element_iterator(_elements.begin(), _elements.end(), p);
221 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::active_pid_elements_begin ( const processor_id_type  proc_id) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 441 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

442 {
443  Predicates::ActivePID<const_elem_iterator_imp> p(proc_id);
444  return const_element_iterator(_elements.begin(), _elements.end(), p);
445 }
ParallelMesh::element_iterator libMesh::ParallelMesh::active_pid_elements_end ( const processor_id_type  proc_id)
virtualinherited

Implements libMesh::MeshBase.

Definition at line 664 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

Referenced by libMesh::ParallelMesh::n_active_elem().

665 {
666  Predicates::ActivePID<elem_iterator_imp> p(proc_id);
667  return element_iterator(_elements.end(), _elements.end(), p);
668 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::active_pid_elements_end ( const processor_id_type  proc_id) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 888 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

889 {
890  Predicates::ActivePID<const_elem_iterator_imp> p(proc_id);
891  return const_element_iterator(_elements.end(), _elements.end(), p);
892 }
ParallelMesh::element_iterator libMesh::ParallelMesh::active_subdomain_elements_begin ( const subdomain_id_type  subdomain_id)
virtualinherited

Implements libMesh::MeshBase.

Definition at line 246 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

247 {
248  Predicates::ActiveSubdomain<elem_iterator_imp> p(subdomain_id);
249  return element_iterator(_elements.begin(), _elements.end(), p);
250 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::active_subdomain_elements_begin ( const subdomain_id_type  subdomain_id) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 470 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

471 {
472  Predicates::ActiveSubdomain<const_elem_iterator_imp> p(subdomain_id);
473  return const_element_iterator(_elements.begin(), _elements.end(), p);
474 }
ParallelMesh::element_iterator libMesh::ParallelMesh::active_subdomain_elements_end ( const subdomain_id_type  subdomain_id)
virtualinherited

Implements libMesh::MeshBase.

Definition at line 693 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

694 {
695  Predicates::ActiveSubdomain<elem_iterator_imp> p(subdomain_id);
696  return element_iterator(_elements.end(), _elements.end(), p);
697 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::active_subdomain_elements_end ( const subdomain_id_type  subdomain_id) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 917 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

918 {
919  Predicates::ActiveSubdomain<const_elem_iterator_imp> p(subdomain_id);
920  return const_element_iterator(_elements.end(), _elements.end(), p);
921 }
ParallelMesh::element_iterator libMesh::ParallelMesh::active_type_elements_begin ( const ElemType  type)
virtualinherited

Implements libMesh::MeshBase.

Definition at line 207 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

208 {
209  Predicates::ActiveType<elem_iterator_imp> p(type);
210  return element_iterator(_elements.begin(), _elements.end(), p);
211 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::active_type_elements_begin ( const ElemType  type) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 431 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

432 {
433  Predicates::ActiveType<const_elem_iterator_imp> p(type);
434  return const_element_iterator(_elements.begin(), _elements.end(), p);
435 }
ParallelMesh::element_iterator libMesh::ParallelMesh::active_type_elements_end ( const ElemType  type)
virtualinherited

Implements libMesh::MeshBase.

Definition at line 654 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

655 {
656  Predicates::ActiveType<elem_iterator_imp> p(type);
657  return element_iterator(_elements.end(), _elements.end(), p);
658 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::active_type_elements_end ( const ElemType  type) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 878 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

879 {
880  Predicates::ActiveType<const_elem_iterator_imp> p(type);
881  return const_element_iterator(_elements.end(), _elements.end(), p);
882 }
Elem * libMesh::ParallelMesh::add_elem ( Elem e)
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.

Implements libMesh::MeshBase.

Definition at line 359 of file parallel_mesh.C.

References libMesh::ParallelMesh::_elements, libMesh::ParallelMesh::_max_elem_id, libMesh::ParallelMesh::_n_elem, libMesh::ParallelMesh::_next_free_local_elem_id, libMesh::ParallelMesh::_next_free_unpartitioned_elem_id, libMesh::MeshBase::_next_unique_id, libMesh::ParallelObject::comm(), libMesh::DofObject::id(), libMesh::DofObject::invalid_processor_id, libMesh::ParallelMesh::is_serial(), libMesh::libmesh_assert(), std::max(), libMesh::Parallel::Communicator::max(), libMesh::ParallelObject::n_processors(), libMesh::processor_id(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::DofObject::set_id(), libMesh::DofObject::set_unique_id(), libMesh::DofObject::valid_id(), and libMesh::DofObject::valid_unique_id().

Referenced by libMesh::ParallelMesh::add_extra_ghost_elem().

360 {
361  // Don't try to add NULLs!
362  libmesh_assert(e);
363 
364  // Trying to add an existing element is a no-op
365  if (e->valid_id() && _elements[e->id()] == e)
366  return e;
367 
368  const processor_id_type elem_procid = e->processor_id();
369 
370  if (!e->valid_id())
371  {
372  // We should only be creating new ids past the end of the range
373  // of existing ids
374  libmesh_assert_greater_equal(_next_free_unpartitioned_elem_id,
375  _max_elem_id);
376  libmesh_assert_greater_equal(_next_free_local_elem_id, _max_elem_id);
377 
378  // Use the unpartitioned ids for unpartitioned elems,
379  // in serial, and temporarily for ghost elems
381  if (elem_procid == this->processor_id() &&
382  !this->is_serial())
383  next_id = &_next_free_local_elem_id;
384  e->set_id (*next_id);
385  }
386 
387  {
388  // Advance next_ids up high enough that each is pointing to an
389  // unused id and any subsequent increments will still point us
390  // to unused ids
392  static_cast<dof_id_type>(e->id()+1));
393 
396  ((_max_elem_id-1) / (this->n_processors() + 1) + 1) *
397  (this->n_processors() + 1) + this->n_processors();
400  ((_max_elem_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
401  (this->n_processors() + 1) + this->processor_id();
402 
403 #ifndef NDEBUG
404  // We need a const mapvector so we don't inadvertently create
405  // NULL entries when testing for non-NULL ones
406  const mapvector<Elem*,dof_id_type>& const_elements = _elements;
407 #endif
409  libmesh_assert(!const_elements[_next_free_local_elem_id]);
410  }
411 
412  // Don't try to overwrite existing elems
413  libmesh_assert (!_elements[e->id()]);
414 
415  _elements[e->id()] = e;
416 
417  // Try to make the cached elem data more accurate
418  if (elem_procid == this->processor_id() ||
419  elem_procid == DofObject::invalid_processor_id)
420  _n_elem++;
421 
422 #ifdef LIBMESH_ENABLE_UNIQUE_ID
423  if (!e->valid_unique_id() && libMesh::processor_id() == e->processor_id())
424  {
425  e->set_unique_id() = _next_unique_id;
426  _next_unique_id += this->n_processors();
427  }
428 #endif
429 
430 // Unpartitioned elems should be added on every processor
431 // And shouldn't be added in the same batch as ghost elems
432 // But we might be just adding on processor 0 to
433 // broadcast later
434 #if 0
435 #ifdef DEBUG
436  if (elem_procid == DofObject::invalid_processor_id)
437  {
438  dof_id_type elem_id = e->id();
439  this->comm().max(elem_id);
440  libmesh_assert_equal_to (elem_id, e->id());
441  }
442 #endif
443 #endif
444 
445  return e;
446 }
void libMesh::ParallelMesh::add_extra_ghost_elem ( Elem e)
virtualinherited

Inserts the element and adds it to a list of elements not to get deleted by delete_remote_elements. This is handy for inserting off-processor elements that you want to keep track of on this processor.

Definition at line 1282 of file parallel_mesh.C.

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

1283 {
1284  // First add the elem like normal
1285  add_elem(e);
1286 
1287  // Now add it to the set that won't be deleted when we call
1288  // delete_remote_elements()
1289  _extra_ghost_elems.insert(e);
1290 }
Node * libMesh::ParallelMesh::add_node ( Node n)
virtualinherited

Add Node n to the end of the vertex array.

Implements libMesh::MeshBase.

Definition at line 523 of file parallel_mesh.C.

References libMesh::ParallelMesh::_max_node_id, libMesh::ParallelMesh::_n_nodes, libMesh::ParallelMesh::_next_free_local_node_id, libMesh::ParallelMesh::_next_free_unpartitioned_node_id, libMesh::MeshBase::_next_unique_id, libMesh::ParallelMesh::_nodes, libMesh::ParallelObject::comm(), libMesh::DofObject::id(), libMesh::DofObject::invalid_processor_id, libMesh::ParallelMesh::is_serial(), libMesh::libmesh_assert(), std::max(), libMesh::Parallel::Communicator::max(), libMesh::ParallelObject::n_processors(), libMesh::processor_id(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::DofObject::set_id(), libMesh::DofObject::set_unique_id(), libMesh::DofObject::valid_id(), and libMesh::DofObject::valid_unique_id().

Referenced by libMesh::ParallelMesh::add_point(), and libMesh::ParallelMesh::insert_node().

524 {
525  // Don't try to add NULLs!
526  libmesh_assert(n);
527 
528  // Trying to add an existing node is a no-op
529  if (n->valid_id() && _nodes[n->id()] == n)
530  return n;
531 
532  const processor_id_type node_procid = n->processor_id();
533 
534  if (!n->valid_id())
535  {
536  // We should only be creating new ids past the end of the range
537  // of existing ids
538  libmesh_assert_greater_equal(_next_free_unpartitioned_node_id,
539  _max_node_id);
540  libmesh_assert_greater_equal(_next_free_local_node_id, _max_node_id);
541 
542  // Use the unpartitioned ids for unpartitioned nodes,
543  // in serial, and temporarily for ghost nodes
545  if (node_procid == this->processor_id() &&
546  !this->is_serial())
547  next_id = &_next_free_local_node_id;
548  n->set_id (*next_id);
549  }
550 
551  {
552  // Advance next_ids up high enough that each is pointing to an
553  // unused id and any subsequent increments will still point us
554  // to unused ids
556  static_cast<dof_id_type>(n->id()+1));
557 
560  ((_max_node_id-1) / (this->n_processors() + 1) + 1) *
561  (this->n_processors() + 1) + this->n_processors();
564  ((_max_node_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
565  (this->n_processors() + 1) + this->processor_id();
566 
567 #ifndef NDEBUG
568  // We need a const mapvector so we don't inadvertently create
569  // NULL entries when testing for non-NULL ones
570  const mapvector<Node*,dof_id_type>& const_nodes = _nodes;
571 #endif
574  }
575 
576  // Don't try to overwrite existing nodes
577  libmesh_assert (!_nodes[n->id()]);
578 
579  _nodes[n->id()] = n;
580 
581  // Try to make the cached node data more accurate
582  if (node_procid == this->processor_id() ||
583  node_procid == DofObject::invalid_processor_id)
584  _n_nodes++;
585 
586 #ifdef LIBMESH_ENABLE_UNIQUE_ID
587  if (!n->valid_unique_id() && libMesh::processor_id() == n->processor_id())
588  {
589  n->set_unique_id() = _next_unique_id;
590  _next_unique_id += this->n_processors();
591  }
592 #endif
593 
594 
595 // Unpartitioned nodes should be added on every processor
596 // And shouldn't be added in the same batch as ghost nodes
597 // But we might be just adding on processor 0 to
598 // broadcast later
599 #if 0
600 #ifdef DEBUG
601  if (node_procid == DofObject::invalid_processor_id)
602  {
603  dof_id_type node_id = n->id();
604  this->comm().max(node_id);
605  libmesh_assert_equal_to (node_id, n->id());
606  }
607 #endif
608 #endif
609 
610  return n;
611 }
Node * libMesh::ParallelMesh::add_point ( const Point p,
const dof_id_type  id = DofObject::invalid_id,
const processor_id_type  proc_id = DofObject::invalid_processor_id 
)
virtualinherited

functions for adding /deleting nodes elements.

Implements libMesh::MeshBase.

Definition at line 499 of file parallel_mesh.C.

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

502 {
503  if (_nodes.count(id))
504  {
505  Node *n = _nodes[id];
506  libmesh_assert (n);
507  libmesh_assert_equal_to (n->id(), id);
508 
509  *n = p;
510  n->processor_id() = proc_id;
511 
512  return n;
513  }
514 
515  Node* n = Node::build(p, id).release();
516  n->processor_id() = proc_id;
517 
518  return ParallelMesh::add_node(n);
519 }
void libMesh::UnstructuredMesh::all_first_order ( )
virtualinherited

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

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

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

If the second order element had any boundary conditions they should be transfered 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 254 of file mesh_modification.C.

References libMesh::MeshBase::_is_prepared, libMesh::Elem::add_child(), libMesh::MeshBase::boundary_info, libMesh::Elem::build(), libMesh::Elem::child(), libMesh::MeshBase::delete_node(), libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::Elem::first_order_equivalent_type(), libMesh::Elem::get_node(), 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(), libMesh::Elem::node(), 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::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::START_LOG(), libMesh::STOP_LOG(), libMesh::Elem::subdomain_id(), libMesh::Elem::type(), and libMesh::Elem::which_child_am_i().

255 {
256  /*
257  * when the mesh is not prepared,
258  * at least renumber the nodes and
259  * elements, so that the node ids
260  * are correct
261  */
262  if (!this->_is_prepared)
264 
265  START_LOG("all_first_order()", "Mesh");
266 
270  std::vector<bool> node_touched_by_me(this->max_node_id(), false);
271 
277  element_iterator endit = elements_end();
278  for (element_iterator it = elements_begin();
279  it != endit; ++it)
280  {
281  Elem* so_elem = *it;
282 
283  libmesh_assert(so_elem);
284 
285  /*
286  * build the first-order equivalent, add to
287  * the new_elements list.
288  */
289  Elem* lo_elem = Elem::build
291  (so_elem->type()), so_elem->parent()).release();
292 
293  for (unsigned int s=0; s != so_elem->n_sides(); ++s)
294  if (so_elem->neighbor(s) == remote_elem)
295  lo_elem->set_neighbor(s, const_cast<RemoteElem*>(remote_elem));
296 
297 #ifdef LIBMESH_ENABLE_AMR
298  /*
299  * Reset the parent links of any child elements
300  */
301  if (so_elem->has_children())
302  for (unsigned int c=0; c != so_elem->n_children(); ++c)
303  {
304  so_elem->child(c)->set_parent(lo_elem);
305  lo_elem->add_child(so_elem->child(c), c);
306  }
307 
308  /*
309  * Reset the child link of any parent element
310  */
311  if (so_elem->parent())
312  {
313  unsigned int c =
314  so_elem->parent()->which_child_am_i(so_elem);
315  lo_elem->parent()->replace_child(lo_elem, c);
316  }
317 
318  /*
319  * Copy as much data to the new element as makes sense
320  */
321  lo_elem->set_p_level(so_elem->p_level());
322  lo_elem->set_refinement_flag(so_elem->refinement_flag());
323  lo_elem->set_p_refinement_flag(so_elem->p_refinement_flag());
324 #endif
325 
326  libmesh_assert_equal_to (lo_elem->n_vertices(), so_elem->n_vertices());
327 
328  /*
329  * By definition the vertices of the linear and
330  * second order element are identically numbered.
331  * transfer these.
332  */
333  for (unsigned int v=0; v < so_elem->n_vertices(); v++)
334  {
335  lo_elem->set_node(v) = so_elem->get_node(v);
336  node_touched_by_me[lo_elem->node(v)] = true;
337  }
338 
345  libmesh_assert_equal_to (lo_elem->n_sides(), so_elem->n_sides());
346 
347  for (unsigned int s=0; s<so_elem->n_sides(); s++)
348  {
349  const std::vector<boundary_id_type> boundary_ids =
350  this->boundary_info->raw_boundary_ids (so_elem, s);
351 
352  this->boundary_info->add_side (lo_elem, s, boundary_ids);
353  }
354 
355  /*
356  * The new first-order element is ready.
357  * Inserting it into the mesh will replace and delete
358  * the second-order element.
359  */
360  lo_elem->set_id(so_elem->id());
361  lo_elem->processor_id() = so_elem->processor_id();
362  lo_elem->subdomain_id() = so_elem->subdomain_id();
363  this->insert_elem(lo_elem);
364  }
365 
366  const MeshBase::node_iterator nd_end = this->nodes_end();
367  MeshBase::node_iterator nd = this->nodes_begin();
368  while (nd != nd_end)
369  {
370  Node *the_node = *nd;
371  ++nd;
372  if (!node_touched_by_me[the_node->id()])
373  this->delete_node(the_node);
374  }
375 
376  STOP_LOG("all_first_order()", "Mesh");
377 
378  // On hanging nodes that used to also be second order nodes, we
379  // might now have an invalid nodal processor_id()
381 
382  // delete or renumber nodes, etc
383  this->prepare_for_use(/*skip_renumber =*/ false);
384 }
void libMesh::UnstructuredMesh::all_second_order ( const bool  full_ordered = true)
virtualinherited

Converts a (conforming, non-refined) mesh with linear elements into a mesh with second-order elements. For example, a mesh consisting of Tet4 will be converted to a mesh with Tet10 etc. Note that 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 ...

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

References libMesh::MeshBase::_is_prepared, libMesh::MeshBase::add_point(), libMesh::MeshBase::boundary_info, libMesh::Elem::build(), libMesh::ParallelObject::comm(), libMesh::Elem::default_order(), libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::err, libMeshEnums::FIRST, libMesh::Elem::get_node(), 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_sides(), libMesh::Elem::n_vertices(), libMesh::Elem::neighbor(), libMesh::MeshBase::node(), libMesh::MeshBase::point(), libMesh::MeshBase::prepare_for_use(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::Real, libMesh::remote_elem, libMesh::MeshBase::renumber_nodes_and_elements(), libMesh::MeshBase::reserve_nodes(), libMesh::Elem::second_order_equivalent_type(), libMesh::START_LOG(), libMesh::STOP_LOG(), libMesh::Elem::subdomain_id(), and libMesh::Elem::type().

Referenced by libMesh::MeshTools::Generation::build_cube().

389 {
390  // This function must be run on all processors at once
391  parallel_object_only();
392 
393  /*
394  * when the mesh is not prepared,
395  * at least renumber the nodes and
396  * elements, so that the node ids
397  * are correct
398  */
399  if (!this->_is_prepared)
401 
402  /*
403  * If the mesh is empty
404  * then we have nothing to do
405  */
406  if (!this->n_elem())
407  return;
408 
409  /*
410  * If the mesh is already second order
411  * then we have nothing to do.
412  * We have to test for this in a round-about way to avoid
413  * a bug on distributed parallel meshes with more processors
414  * than elements.
415  */
416  bool already_second_order = false;
417  if (this->elements_begin() != this->elements_end() &&
418  (*(this->elements_begin()))->default_order() != FIRST)
419  already_second_order = true;
420  this->comm().max(already_second_order);
421  if (already_second_order)
422  return;
423 
424  START_LOG("all_second_order()", "Mesh");
425 
426  /*
427  * this map helps in identifying second order
428  * nodes. Namely, a second-order node:
429  * - edge node
430  * - face node
431  * - bubble node
432  * is uniquely defined through a set of adjacent
433  * vertices. This set of adjacent vertices is
434  * used to identify already added higher-order
435  * nodes. We are safe to use node id's since we
436  * make sure that these are correctly numbered.
437  */
438  std::map<std::vector<dof_id_type>, Node*> adj_vertices_to_so_nodes;
439 
440  /*
441  * for speed-up of the \p add_point() method, we
442  * can reserve memory. Guess the number of additional
443  * nodes for different dimensions
444  */
445  switch (this->mesh_dimension())
446  {
447  case 1:
448  /*
449  * in 1D, there can only be order-increase from Edge2
450  * to Edge3. Something like 1/2 of n_nodes() have
451  * to be added
452  */
453  this->reserve_nodes(static_cast<unsigned int>
454  (1.5*static_cast<double>(this->n_nodes())));
455  break;
456 
457  case 2:
458  /*
459  * in 2D, either refine from Tri3 to Tri6 (double the nodes)
460  * or from Quad4 to Quad8 (again, double) or Quad9 (2.25 that much)
461  */
462  this->reserve_nodes(static_cast<unsigned int>
463  (2*static_cast<double>(this->n_nodes())));
464  break;
465 
466 
467  case 3:
468  /*
469  * in 3D, either refine from Tet4 to Tet10 (factor = 2.5) up to
470  * Hex8 to Hex27 (something > 3). Since in 3D there _are_ already
471  * quite some nodes, and since we do not want to overburden the memory by
472  * a too conservative guess, use the lower bound
473  */
474  this->reserve_nodes(static_cast<unsigned int>
475  (2.5*static_cast<double>(this->n_nodes())));
476  break;
477 
478  default:
479  // Hm?
480  libmesh_error();
481  }
482 
483 
484 
485  /*
486  * form a vector that will hold the node id's of
487  * the vertices that are adjacent to the son-th
488  * second-order node. Pull this outside of the
489  * loop so that silly compilers don't repeatedly
490  * create and destroy the vector.
491  */
492  std::vector<dof_id_type> adjacent_vertices_ids;
493 
500  const_element_iterator endit = elements_end();
501  for (const_element_iterator it = elements_begin();
502  it != endit; ++it)
503  {
504  // the linear-order element
505  const Elem* lo_elem = *it;
506 
507  libmesh_assert(lo_elem);
508 
509  // make sure it is linear order
510  if (lo_elem->default_order() != FIRST)
511  {
512  libMesh::err << "ERROR: This is not a linear element: type="
513  << lo_elem->type() << std::endl;
514  libmesh_error();
515  }
516 
517  // this does _not_ work for refined elements
518  libmesh_assert_equal_to (lo_elem->level (), 0);
519 
520  /*
521  * build the second-order equivalent, add to
522  * the new_elements list. Note that this here
523  * is the only point where \p full_ordered
524  * is necessary. The remaining code works well
525  * for either type of seconrd-order equivalent, e.g.
526  * Hex20 or Hex27, as equivalents for Hex8
527  */
528  Elem* so_elem =
530  full_ordered) ).release();
531 
532  libmesh_assert_equal_to (lo_elem->n_vertices(), so_elem->n_vertices());
533 
534 
535  /*
536  * By definition the vertices of the linear and
537  * second order element are identically numbered.
538  * transfer these.
539  */
540  for (unsigned int v=0; v < lo_elem->n_vertices(); v++)
541  so_elem->set_node(v) = lo_elem->get_node(v);
542 
543  /*
544  * Now handle the additional mid-side nodes. This
545  * is simply handled through a map that remembers
546  * the already-added nodes. This map maps the global
547  * ids of the vertices (that uniquely define this
548  * higher-order node) to the new node.
549  * Notation: son = second-order node
550  */
551  const unsigned int son_begin = so_elem->n_vertices();
552  const unsigned int son_end = so_elem->n_nodes();
553 
554 
555  for (unsigned int son=son_begin; son<son_end; son++)
556  {
557  const unsigned int n_adjacent_vertices =
558  so_elem->n_second_order_adjacent_vertices(son);
559 
560  adjacent_vertices_ids.resize(n_adjacent_vertices);
561 
562  for (unsigned int v=0; v<n_adjacent_vertices; v++)
563  adjacent_vertices_ids[v] =
564  so_elem->node( so_elem->second_order_adjacent_vertex(son,v) );
565 
566  /*
567  * \p adjacent_vertices_ids is now in order of the current
568  * side. sort it, so that comparisons with the
569  * \p adjacent_vertices_ids created through other elements'
570  * sides can match
571  */
572  std::sort(adjacent_vertices_ids.begin(),
573  adjacent_vertices_ids.end());
574 
575 
576  // does this set of vertices already has a mid-node added?
577  std::pair<std::map<std::vector<dof_id_type>, Node*>::iterator,
578  std::map<std::vector<dof_id_type>, Node*>::iterator>
579  pos = adj_vertices_to_so_nodes.equal_range (adjacent_vertices_ids);
580 
581  // no, not added yet
582  if (pos.first == pos.second)
583  {
584  /*
585  * for this set of vertices, there is no
586  * second_order node yet. Add it.
587  *
588  * compute the location of the new node as
589  * the average over the adjacent vertices.
590  */
591  Point new_location = this->point(adjacent_vertices_ids[0]);
592  for (unsigned int v=1; v<n_adjacent_vertices; v++)
593  new_location += this->point(adjacent_vertices_ids[v]);
594 
595  new_location /= static_cast<Real>(n_adjacent_vertices);
596 
597  /* Add the new point to the mesh, giving it a globally
598  * well-defined processor id.
599  */
600  Node* so_node = this->add_point
601  (new_location, DofObject::invalid_id,
602  this->node(adjacent_vertices_ids[0]).processor_id());
603 
604  /*
605  * insert the new node with its defining vertex
606  * set into the map, and relocate pos to this
607  * new entry, so that the so_elem can use
608  * \p pos for inserting the node
609  */
610  adj_vertices_to_so_nodes.insert(pos.first,
611  std::make_pair(adjacent_vertices_ids,
612  so_node));
613 
614  so_elem->set_node(son) = so_node;
615  }
616  // yes, already added.
617  else
618  {
619  libmesh_assert(pos.first->second);
620 
621  so_elem->set_node(son) = pos.first->second;
622  }
623  }
624 
625 
637  libmesh_assert_equal_to (lo_elem->n_sides(), so_elem->n_sides());
638 
639  for (unsigned int s=0; s<lo_elem->n_sides(); s++)
640  {
641  const std::vector<boundary_id_type> boundary_ids =
642  this->boundary_info->raw_boundary_ids (lo_elem, s);
643 
644  this->boundary_info->add_side (so_elem, s, boundary_ids);
645 
646  if (lo_elem->neighbor(s) == remote_elem)
647  so_elem->set_neighbor(s, const_cast<RemoteElem*>(remote_elem));
648  }
649 
650  /*
651  * The new second-order element is ready.
652  * Inserting it into the mesh will replace and delete
653  * the first-order element.
654  */
655  so_elem->set_id(lo_elem->id());
656  so_elem->processor_id() = lo_elem->processor_id();
657  so_elem->subdomain_id() = lo_elem->subdomain_id();
658  this->insert_elem(so_elem);
659  }
660 
661  // we can clear the map
662  adj_vertices_to_so_nodes.clear();
663 
664 
665  STOP_LOG("all_second_order()", "Mesh");
666 
667  // In a ParallelMesh our ghost node processor ids may be bad and
668  // the ids of nodes touching remote elements may be inconsistent.
669  // Fix them.
670  if (!this->is_serial())
671  {
672  LocationMap<Node> loc_map;
673  MeshCommunication().make_nodes_parallel_consistent
674  (*this, loc_map);
675  }
676 
677  // renumber nodes, elements etc
678  this->prepare_for_use(/*skip_renumber =*/ false);
679 }
void libMesh::ParallelMesh::allgather ( )
virtualinherited

Gathers all elements and nodes of the mesh onto every processor

Reimplemented from libMesh::MeshBase.

Definition at line 1293 of file parallel_mesh.C.

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

1294 {
1295  if (_is_serial)
1296  return;
1297  _is_serial = true;
1298  MeshCommunication().allgather(*this);
1299 
1300 // Make sure our caches are up to date and our
1301 // DofObjects are well packed
1302 #ifdef DEBUG
1303  libmesh_assert_equal_to (this->n_nodes(), this->parallel_n_nodes());
1304  libmesh_assert_equal_to (this->n_elem(), this->parallel_n_elem());
1305  const dof_id_type pmax_node_id = this->parallel_max_node_id();
1306  const dof_id_type pmax_elem_id = this->parallel_max_elem_id();
1307  libmesh_assert_equal_to (this->max_node_id(), pmax_node_id);
1308  libmesh_assert_equal_to (this->max_elem_id(), pmax_elem_id);
1309 
1310  // If we've disabled renumbering we can't be sure we're contiguous
1311  // libmesh_assert_equal_to (this->n_nodes(), this->max_node_id());
1312  // libmesh_assert_equal_to (this->n_elem(), this->max_elem_id());
1313 
1314 // Make sure our neighbor links are all fine
1316 
1317 // Make sure our ids and flags are consistent
1320 #endif
1321 }
void libMesh::MeshBase::allow_renumbering ( bool  allow)
inlineinherited

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

Definition at line 536 of file mesh_base.h.

References libMesh::MeshBase::_skip_renumber_nodes_and_elements.

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

bool libMesh::MeshBase::allow_renumbering ( ) const
inlineinherited
ParallelMesh::element_iterator libMesh::ParallelMesh::ancestor_elements_begin ( )
virtualinherited

Implements libMesh::MeshBase.

Definition at line 67 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

68 {
69  Predicates::Ancestor<elem_iterator_imp> p;
70  return element_iterator(_elements.begin(), _elements.end(), p);
71 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::ancestor_elements_begin ( ) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 291 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

292 {
293  Predicates::Ancestor<const_elem_iterator_imp> p;
294  return const_element_iterator(_elements.begin(), _elements.end(), p);
295 }
ParallelMesh::element_iterator libMesh::ParallelMesh::ancestor_elements_end ( )
virtualinherited

Implements libMesh::MeshBase.

Definition at line 514 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

515 {
516  Predicates::Ancestor<elem_iterator_imp> p;
517  return element_iterator(_elements.end(), _elements.end(), p);
518 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::ancestor_elements_end ( ) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 739 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

740 {
741  Predicates::Ancestor<const_elem_iterator_imp> p;
742  return const_element_iterator(_elements.end(), _elements.end(), p);
743 }
void libMesh::ParallelMesh::assign_unique_ids ( )
protectedvirtualinherited

Assign globally unique IDs to all DOF objects (Elements and Nodes) if the library has been configured with unique_id support.

Implements libMesh::MeshBase.

Definition at line 1324 of file parallel_mesh.C.

References libMesh::ParallelMesh::_elements, libMesh::MeshBase::_next_unique_id, libMesh::ParallelMesh::_nodes, end, libMesh::ParallelObject::n_processors(), and libMesh::processor_id().

1325 {
1326  {
1327  elem_iterator_imp it = _elements.begin();
1328  const elem_iterator_imp end = _elements.end();
1329 
1330  for (; it != end; ++it)
1331  if ((*it) && ! (*it)->valid_unique_id() && libMesh::processor_id() == (*it)->processor_id())
1332  {
1333  (*it)->set_unique_id() = _next_unique_id;
1334  _next_unique_id += this->n_processors();
1335  }
1336  }
1337 
1338  {
1339  node_iterator_imp it = _nodes.begin();
1340  node_iterator_imp end = _nodes.end();
1341 
1342  for (; it != end; ++it)
1343  if ((*it) && ! (*it)->valid_unique_id() && libMesh::processor_id() == (*it)->processor_id())
1344  {
1345  (*it)->set_unique_id() = _next_unique_id;
1346  _next_unique_id += this->n_processors();
1347  }
1348  }
1349 }
void libMesh::ParallelMesh::clear ( )
virtualinherited

Clear all internal data.

Reimplemented from libMesh::MeshBase.

Definition at line 660 of file parallel_mesh.C.

References libMesh::ParallelMesh::_elements, libMesh::ParallelMesh::_is_serial, libMesh::ParallelMesh::_max_elem_id, libMesh::ParallelMesh::_max_node_id, libMesh::ParallelMesh::_n_elem, libMesh::ParallelMesh::_n_nodes, libMesh::ParallelMesh::_next_free_local_elem_id, libMesh::ParallelMesh::_next_free_local_node_id, libMesh::ParallelMesh::_next_free_unpartitioned_elem_id, libMesh::ParallelMesh::_next_free_unpartitioned_node_id, libMesh::ParallelMesh::_nodes, libMesh::MeshBase::clear(), end, libMesh::ParallelObject::n_processors(), and libMesh::ParallelObject::processor_id().

Referenced by ~BoundaryMesh(), and libMesh::ParallelMesh::~ParallelMesh().

661 {
662  // Call parent clear function
663  MeshBase::clear();
664 
665 
666  // Clear our elements and nodes
667  {
668  elem_iterator_imp it = _elements.begin();
669  const elem_iterator_imp end = _elements.end();
670 
671  // There is no need to remove the elements from
672  // the BoundaryInfo data structure since we
673  // already cleared it.
674  for (; it != end; ++it)
675  delete *it;
676 
677  _elements.clear();
678  }
679 
680  // clear the nodes data structure
681  {
682  node_iterator_imp it = _nodes.begin();
683  node_iterator_imp end = _nodes.end();
684 
685  // There is no need to remove the nodes from
686  // the BoundaryInfo data structure since we
687  // already cleared it.
688  for (; it != end; ++it)
689  delete *it;
690 
691  _nodes.clear();
692  }
693 
694  // We're no longer distributed if we were before
695  _is_serial = true;
696 
697  // Correct our caches
698  _n_nodes = 0;
699  _n_elem = 0;
700  _max_node_id = 0;
701  _max_elem_id = 0;
706 }
virtual void libMesh::ParallelMesh::clear_extra_ghost_elems ( )
inlinevirtualinherited

Clears extra ghost elements.

Definition at line 179 of file parallel_mesh.h.

References libMesh::ParallelMesh::_extra_ghost_elems.

179 { _extra_ghost_elems.clear(); }
void libMesh::MeshBase::clear_point_locator ( )
inherited

Releases the current PointLocator object.

Definition at line 414 of file mesh_base.C.

References libMesh::MeshBase::_point_locator.

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

415 {
416  _point_locator.reset(NULL);
417 }
virtual AutoPtr<MeshBase> libMesh::ParallelMesh::clone ( ) const
inlinevirtualinherited

Virtual copy-constructor, creates a copy of this mesh

Implements libMesh::MeshBase.

Definition at line 88 of file parallel_mesh.h.

References libMesh::ParallelMesh::ParallelMesh().

89  { return AutoPtr<MeshBase>(new ParallelMesh(*this)); }
const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inlineinherited
Returns
a reference to the Parallel::Communicator object used by this mesh.

Definition at line 86 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_snes_jacobian(), libMesh::__libmesh_petsc_snes_residual(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::MetisPartitioner::_do_partition(), libMesh::ParmetisPartitioner::_do_repartition(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult_add(), libMesh::EquationSystems::_read_impl(), libMesh::MeshRefinement::_refine_elements(), libMesh::ParallelMesh::add_elem(), libMesh::ImplicitSystem::add_matrix(), libMesh::ParallelMesh::add_node(), libMesh::System::add_vector(), libMesh::UnstructuredMesh::all_second_order(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::DofMap::attach_matrix(), libMesh::MeshTools::bounding_box(), libMesh::System::calculate_norm(), libMesh::MeshRefinement::coarsen_elements(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMLibMeshSetSystem(), DMVariableBounds_libMesh(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::for(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::LocationMap< T >::init(), libMesh::PetscDiffSolver::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::EigenSystem::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::ParmetisPartitioner::initialize(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::ParallelMesh::libmesh_assert_valid_parallel_flags(), libMesh::MeshTools::libmesh_assert_valid_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshRefinement::make_flags_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshRefinement::make_refinement_compatible(), libMesh::FEMSystem::mesh_position_set(), libMesh::MeshSerializer::MeshSerializer(), libMesh::ParallelMesh::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::ParallelMesh::parallel_max_elem_id(), libMesh::ParallelMesh::parallel_max_node_id(), libMesh::ParallelMesh::parallel_n_elem(), libMesh::ParallelMesh::parallel_n_nodes(), libMesh::Partitioner::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::System::project_vector(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::MeshRefinement::refine_elements(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::Parallel::sync_element_data_by_parent_id(), libMesh::MeshRefinement::test_level_one(), libMesh::MeshRefinement::test_unflagged(), libMesh::MeshTools::total_weight(), libMesh::CheckpointIO::write(), libMesh::XdrIO::write(), libMesh::UnstructuredMesh::write(), libMesh::LegacyXdrIO::write_mesh(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), and libMesh::DivaIO::write_stream().

87  { return _communicator; }
bool libMesh::UnstructuredMesh::contract ( )
virtualinherited

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

Implements libMesh::MeshBase.

Definition at line 1099 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::libmesh_assert(), libMesh::Elem::parent(), libMesh::MeshBase::renumber_nodes_and_elements(), libMesh::START_LOG(), libMesh::STOP_LOG(), and libMesh::Elem::subactive().

1100 {
1101  START_LOG ("contract()", "Mesh");
1102 
1103  // Flag indicating if this call actually changes the mesh
1104  bool mesh_changed = false;
1105 
1106  element_iterator in = elements_begin();
1107  const element_iterator end = elements_end();
1108 
1109 #ifdef DEBUG
1110  for ( ; in != end; ++in)
1111  if (*in != NULL)
1112  {
1113  Elem* el = *in;
1114  libmesh_assert(el->active() || el->subactive() || el->ancestor());
1115  }
1116  in = elements_begin();
1117 #endif
1118 
1119  // Loop over the elements.
1120  for ( ; in != end; ++in)
1121  if (*in != NULL)
1122  {
1123  Elem* el = *in;
1124 
1125  // Delete all the subactive ones
1126  if (el->subactive())
1127  {
1128  // No level-0 element should be subactive.
1129  // Note that we CAN'T test elem->level(), as that
1130  // touches elem->parent()->dim(), and elem->parent()
1131  // might have already been deleted!
1132  libmesh_assert(el->parent());
1133 
1134  // Delete the element
1135  // This just sets a pointer to NULL, and doesn't
1136  // invalidate any iterators
1137  this->delete_elem(el);
1138 
1139  // the mesh has certainly changed
1140  mesh_changed = true;
1141  }
1142  else
1143  {
1144  // Compress all the active ones
1145  if (el->active())
1146  el->contract();
1147  else
1148  libmesh_assert (el->ancestor());
1149  }
1150  }
1151 
1152  // Strip any newly-created NULL voids out of the element array
1154 
1155  // FIXME: Need to understand why deleting subactive children
1156  // invalidates the point locator. For now we will clear it explicitly
1157  this->clear_point_locator();
1158 
1159  STOP_LOG ("contract()", "Mesh");
1160 
1161  return mesh_changed;
1162 }
void libMesh::UnstructuredMesh::copy_nodes_and_elements ( const UnstructuredMesh other_mesh)
virtualinherited

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

Definition at line 104 of file unstructured_mesh.C.

References libMesh::MeshBase::_dim, libMesh::MeshBase::_is_prepared, libMesh::MeshBase::_n_parts, libMesh::Elem::add_child(), libMesh::MeshBase::allow_renumbering(), libMesh::Elem::build(), libMesh::Elem::child(), libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), end, libMesh::Elem::has_children(), libMesh::DofObject::id(), libMesh::MeshTools::libmesh_assert_valid_amr_elem_ids(), libMesh::Elem::n_children(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::Elem::n_sides(), libMesh::Elem::neighbor(), libMesh::Elem::node(), libMesh::MeshBase::nodes_begin(), libMesh::MeshBase::nodes_end(), libMesh::Elem::p_refinement_flag(), libMesh::Elem::parent(), libMesh::DofObject::processor_id(), libMesh::Elem::refinement_flag(), libMesh::remote_elem, libMesh::MeshBase::skip_partitioning(), libMesh::Elem::subdomain_id(), libMesh::Elem::type(), and libMesh::Elem::which_child_am_i().

Referenced by libMesh::ParallelMesh::ParallelMesh(), libMesh::SerialMesh::SerialMesh(), and libMesh::SerialMesh::stitching_helper().

105 {
106  // We're assuming our subclass data needs no copy
107  libmesh_assert_equal_to (_n_parts, other_mesh._n_parts);
108  libmesh_assert_equal_to (_dim, other_mesh._dim);
109  libmesh_assert_equal_to (_is_prepared, other_mesh._is_prepared);
110 
111  // We're assuming the other mesh has proper element number ordering,
112  // so that we add parents before their children.
113 #ifdef DEBUG
115 #endif
116 
117  //Copy in Nodes
118  {
119  //Preallocate Memory if necessary
120  this->reserve_nodes(other_mesh.n_nodes());
121 
122  const_node_iterator it = other_mesh.nodes_begin();
123  const_node_iterator end = other_mesh.nodes_end();
124 
125  for (; it != end; ++it)
126  {
127  const Node *oldn = *it;
128 
129  // Add new nodes in old node Point locations
130  /*Node *newn =*/ this->add_point(*oldn, oldn->id(), oldn->processor_id());
131 
132  // And start them off in the same subdomain
133 // newn->processor_id() = oldn->processor_id();
134  }
135  }
136 
137  //Copy in Elements
138  {
139  //Preallocate Memory if necessary
140  this->reserve_elem(other_mesh.n_elem());
141 
142  // Loop over the elements
143  MeshBase::const_element_iterator it = other_mesh.elements_begin();
144  const MeshBase::const_element_iterator end = other_mesh.elements_end();
145 
146  // FIXME: Where do we set element IDs??
147  for (; it != end; ++it)
148  {
149  //Look at the old element
150  const Elem *old = *it;
151  //Build a new element
152  Elem *newparent = old->parent() ?
153  this->elem(old->parent()->id()) : NULL;
154  AutoPtr<Elem> ap = Elem::build(old->type(), newparent);
155  Elem * el = ap.release();
156 
157  el->subdomain_id() = old->subdomain_id();
158 
159  for (unsigned int s=0; s != old->n_sides(); ++s)
160  if (old->neighbor(s) == remote_elem)
161  el->set_neighbor(s, const_cast<RemoteElem*>(remote_elem));
162 
163 #ifdef LIBMESH_ENABLE_AMR
164  if (old->has_children())
165  for (unsigned int c=0; c != old->n_children(); ++c)
166  if (old->child(c) == remote_elem)
167  el->add_child(const_cast<RemoteElem*>(remote_elem), c);
168 
169  //Create the parent's child pointers if necessary
170  if (newparent)
171  {
172  unsigned int oldc = old->parent()->which_child_am_i(old);
173  newparent->add_child(el, oldc);
174  }
175 
176  // Copy the refinement flags
177  el->set_refinement_flag(old->refinement_flag());
178  el->set_p_refinement_flag(old->p_refinement_flag());
179 #endif // #ifdef LIBMESH_ENABLE_AMR
180 
181  //Assign all the nodes
182  for(unsigned int i=0;i<el->n_nodes();i++)
183  el->set_node(i) = &this->node(old->node(i));
184 
185  // And start it off in the same subdomain
186  el->processor_id() = old->processor_id();
187 
188  // Give it the same id
189  el->set_id(old->id());
190 
191  //Hold onto it
192  this->add_elem(el);
193  }
194  }
195 
196  //Finally prepare the new Mesh for use. Keep the same numbering and
197  //partitioning but also the same renumbering and partitioning
198  //policies as our source mesh.
199  this->allow_renumbering(false);
200  this->skip_partitioning(true);
201  this->prepare_for_use();
202  this->allow_renumbering(other_mesh.allow_renumbering());
203  this->skip_partitioning(other_mesh.skip_partitioning());
204 }
void libMesh::UnstructuredMesh::create_pid_mesh ( UnstructuredMesh pid_mesh,
const processor_id_type  pid 
) const
inherited

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

Definition at line 965 of file unstructured_mesh.C.

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

967 {
968 
969  // Issue a warning if the number the number of processors
970  // currently available is less that that requested for
971  // partitioning. This is not necessarily an error since
972  // you may run on one processor and still partition the
973  // mesh into several partitions.
974 #ifdef DEBUG
975  if (this->n_processors() < pid)
976  {
977  libMesh::out << "WARNING: You are creating a "
978  << "mesh for a processor id (="
979  << pid
980  << ") greater than "
981  << "the number of processors available for "
982  << "the calculation. (="
983  << this->n_processors()
984  << ")."
985  << std::endl;
986  }
987 #endif
988 
989  // Create iterators to loop over the list of elements
990 // const_active_pid_elem_iterator it(this->elements_begin(), pid);
991 // const const_active_pid_elem_iterator it_end(this->elements_end(), pid);
992 
993  const_element_iterator it = this->active_pid_elements_begin(pid);
994  const const_element_iterator it_end = this->active_pid_elements_end(pid);
995 
996  this->create_submesh (pid_mesh, it, it_end);
997 }
void libMesh::UnstructuredMesh::create_submesh ( UnstructuredMesh new_mesh,
const_element_iterator it,
const const_element_iterator it_end 
) const
inherited

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

Definition at line 1005 of file unstructured_mesh.C.

References libMesh::MeshBase::add_elem(), libMesh::MeshBase::add_point(), bc_id, libMesh::MeshBase::boundary_info, libMesh::Elem::build(), libMesh::MeshBase::clear(), libMesh::DofObject::invalid_id, libMesh::libmesh_assert(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::Elem::n_nodes(), libMesh::Elem::n_sides(), libMesh::Elem::node(), libMesh::MeshBase::node_ptr(), libMesh::Elem::point(), libMesh::MeshBase::prepare_for_use(), libMesh::DofObject::processor_id(), libMesh::Elem::set_node(), libMesh::Elem::subdomain_id(), and libMesh::Elem::type().

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

1008 {
1009  // Just in case the subdomain_mesh already has some information
1010  // in it, get rid of it.
1011  new_mesh.clear();
1012 
1013  // Fail if (*this == new_mesh), we cannot create a submesh inside ourself!
1014  // This may happen if the user accidently passes the original mesh into
1015  // this function! We will check this by making sure we did not just
1016  // clear ourself.
1017  libmesh_assert_not_equal_to (this->n_nodes(), 0);
1018  libmesh_assert_not_equal_to (this->n_elem(), 0);
1019 
1020  // How the nodes on this mesh will be renumbered to nodes
1021  // on the new_mesh.
1022  std::vector<dof_id_type> new_node_numbers (this->n_nodes());
1023 
1024  std::fill (new_node_numbers.begin(),
1025  new_node_numbers.end(),
1027 
1028 
1029 
1030  // the number of nodes on the new mesh, will be incremented
1031  dof_id_type n_new_nodes = 0;
1032  dof_id_type n_new_elem = 0;
1033 
1034  for (; it != it_end; ++it)
1035  {
1036  // increment the new element counter
1037  n_new_elem++;
1038 
1039  const Elem* old_elem = *it;
1040 
1041  // Add an equivalent element type to the new_mesh
1042  Elem* new_elem =
1043  new_mesh.add_elem (Elem::build(old_elem->type()).release());
1044 
1045  libmesh_assert(new_elem);
1046 
1047  // Loop over the nodes on this element.
1048  for (unsigned int n=0; n<old_elem->n_nodes(); n++)
1049  {
1050  libmesh_assert_less (old_elem->node(n), new_node_numbers.size());
1051 
1052  if (new_node_numbers[old_elem->node(n)] == DofObject::invalid_id)
1053  {
1054  new_node_numbers[old_elem->node(n)] = n_new_nodes;
1055 
1056  // Add this node to the new mesh
1057  new_mesh.add_point (old_elem->point(n));
1058 
1059  // Increment the new node counter
1060  n_new_nodes++;
1061  }
1062 
1063  // Define this element's connectivity on the new mesh
1064  libmesh_assert_less (new_node_numbers[old_elem->node(n)], new_mesh.n_nodes());
1065 
1066  new_elem->set_node(n) = new_mesh.node_ptr (new_node_numbers[old_elem->node(n)]);
1067  }
1068 
1069  // Copy ids for this element
1070  new_elem->subdomain_id() = old_elem->subdomain_id();
1071  new_elem->processor_id() = old_elem->processor_id();
1072 
1073  // Maybe add boundary conditions for this element
1074  for (unsigned int s=0; s<old_elem->n_sides(); s++)
1075 // We're supporting boundary ids on internal sides now
1076 // if (old_elem->neighbor(s) == NULL)
1077  {
1078  const std::vector<boundary_id_type>& bc_ids = this->boundary_info->boundary_ids(old_elem, s);
1079  for (std::vector<boundary_id_type>::const_iterator id_it=bc_ids.begin(); id_it!=bc_ids.end(); ++id_it)
1080  {
1081  const boundary_id_type bc_id = *id_it;
1082  if (bc_id != this->boundary_info->invalid_id)
1083  new_mesh.boundary_info->add_side (new_elem,
1084  s,
1085  bc_id);
1086  }
1087  }
1088  } // end loop over elements
1089 
1090 
1091  // Prepare the new_mesh for use
1092  new_mesh.prepare_for_use(/*skip_renumber =*/false);
1093 
1094 }
void libMesh::ParallelMesh::delete_elem ( Elem e)
virtualinherited

Removes element e from the mesh. Note that calling this method may produce isolated nodes, i.e. nodes not connected to any element. This method must be implemented in derived classes in such a way that it does not invalidate element iterators.

Implements libMesh::MeshBase.

Definition at line 462 of file parallel_mesh.C.

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

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

463 {
464  libmesh_assert (e);
465 
466  // Delete the element from the BoundaryInfo object
467  this->boundary_info->remove(e);
468 
469  // But not yet from the container; we might invalidate
470  // an iterator that way!
471 
472  //_elements.erase(e->id());
473 
474  // Instead, we set it to NULL for now
475 
476  _elements[e->id()] = NULL;
477 
478  // delete the element
479  delete e;
480 }
void libMesh::ParallelMesh::delete_node ( Node n)
virtualinherited

Removes the Node n from the mesh.

Implements libMesh::MeshBase.

Definition at line 622 of file parallel_mesh.C.

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

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

623 {
624  libmesh_assert(n);
625  libmesh_assert(_nodes[n->id()]);
626 
627  // Delete the node from the BoundaryInfo object
628  this->boundary_info->remove(n);
629 
630  // But not yet from the container; we might invalidate
631  // an iterator that way!
632 
633  //_nodes.erase(n->id());
634 
635  // Instead, we set it to NULL for now
636 
637  _nodes[n->id()] = NULL;
638 
639  // delete the node
640  delete n;
641 }
void libMesh::ParallelMesh::delete_remote_elements ( )
virtualinherited

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

Reimplemented from libMesh::MeshBase.

Definition at line 1215 of file parallel_mesh.C.

References libMesh::ParallelMesh::_elements, libMesh::ParallelMesh::_extra_ghost_elems, libMesh::ParallelMesh::_is_serial, libMesh::ParallelMesh::_nodes, libMesh::MeshCommunication::delete_remote_elements(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::ParallelMesh::libmesh_assert_valid_parallel_flags(), libMesh::ParallelMesh::libmesh_assert_valid_parallel_ids(), libMesh::MeshTools::libmesh_assert_valid_refinement_tree(), libMesh::ParallelMesh::max_elem_id(), libMesh::ParallelMesh::max_node_id(), libMesh::ParallelMesh::n_elem(), libMesh::ParallelMesh::n_nodes(), libMesh::ParallelMesh::parallel_max_elem_id(), libMesh::ParallelMesh::parallel_max_node_id(), libMesh::ParallelMesh::parallel_n_elem(), libMesh::ParallelMesh::parallel_n_nodes(), and libMesh::ParallelMesh::update_parallel_id_counts().

1216 {
1217 #ifdef DEBUG
1218 // Make sure our neighbor links are all fine
1220 
1221 // And our child/parent links, and our flags
1223 
1224 // Make sure our ids and flags are consistent
1227 
1228  libmesh_assert_equal_to (this->n_nodes(), this->parallel_n_nodes());
1229  libmesh_assert_equal_to (this->n_elem(), this->parallel_n_elem());
1230  const dof_id_type pmax_node_id = this->parallel_max_node_id();
1231  const dof_id_type pmax_elem_id = this->parallel_max_elem_id();
1232  libmesh_assert_equal_to (this->max_node_id(), pmax_node_id);
1233  libmesh_assert_equal_to (this->max_elem_id(), pmax_elem_id);
1234 #endif
1235 
1236  _is_serial = false;
1237  MeshCommunication().delete_remote_elements(*this, _extra_ghost_elems);
1238 
1239  libmesh_assert_equal_to (this->max_elem_id(), this->parallel_max_elem_id());
1240 
1241  // Now make sure the containers actually shrink - strip
1242  // any newly-created NULL voids out of the element array
1243  mapvector<Elem*,dof_id_type>::veclike_iterator e_it = _elements.begin();
1244  const mapvector<Elem*,dof_id_type>::veclike_iterator e_end = _elements.end();
1245  for (; e_it != e_end;)
1246  if (!*e_it)
1247  _elements.erase(e_it++);
1248  else
1249  ++e_it;
1250 
1251  mapvector<Node*,dof_id_type>::veclike_iterator n_it = _nodes.begin();
1252  const mapvector<Node*,dof_id_type>::veclike_iterator n_end = _nodes.end();
1253  for (; n_it != n_end;)
1254  if (!*n_it)
1255  _nodes.erase(n_it++);
1256  else
1257  ++n_it;
1258 
1259  // We may have deleted no-longer-connected nodes or coarsened-away
1260  // elements; let's update our caches.
1261  this->update_parallel_id_counts();
1262 
1263 #ifdef DEBUG
1264  // We might not have well-packed objects if the user didn't allow us
1265  // to renumber
1266  // libmesh_assert_equal_to (this->n_nodes(), this->max_node_id());
1267  // libmesh_assert_equal_to (this->n_elem(), this->max_elem_id());
1268 
1269 // Make sure our neighbor links are all fine
1271 
1272 // And our child/parent links, and our flags
1274 
1275 // Make sure our ids and flags are consistent
1278 #endif
1279 }
const Elem * libMesh::ParallelMesh::elem ( const dof_id_type  i) const
virtualinherited

Return a pointer to the $ i^{th} $ element, which should be present in this processor's subset of the mesh data structure.

Implements libMesh::MeshBase.

Definition at line 305 of file parallel_mesh.C.

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

Referenced by libMesh::ParallelMesh::ParallelMesh().

306 {
308  libmesh_assert_equal_to (_elements[i]->id(), i);
309 
310  return _elements[i];
311 }
Elem * libMesh::ParallelMesh::elem ( const dof_id_type  i)
virtualinherited

Return a writeable pointer to the $ i^{th} $ element, which should be present in this processor's subset of the mesh data structure.

Implements libMesh::MeshBase.

Definition at line 316 of file parallel_mesh.C.

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

317 {
319  libmesh_assert_equal_to (_elements[i]->id(), i);
320 
321  return _elements[i];
322 }
ParallelMesh::element_iterator libMesh::ParallelMesh::elements_begin ( )
virtualinherited

Elem iterator accessor functions.

Implements libMesh::MeshBase.

Definition at line 37 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

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

38 {
39  Predicates::NotNull<elem_iterator_imp> p;
40  return element_iterator(_elements.begin(), _elements.end(), p);
41 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::elements_begin ( ) const
virtualinherited

const Elem iterator accessor functions.

Implements libMesh::MeshBase.

Definition at line 262 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

263 {
264  Predicates::NotNull<const_elem_iterator_imp> p;
265  return const_element_iterator(_elements.begin(), _elements.end(), p);
266 }
ParallelMesh::element_iterator libMesh::ParallelMesh::elements_end ( )
virtualinherited

Implements libMesh::MeshBase.

Definition at line 484 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

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

485 {
486  Predicates::NotNull<elem_iterator_imp> p;
487  return element_iterator(_elements.end(), _elements.end(), p);
488 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::elements_end ( ) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 709 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

710 {
711  Predicates::NotNull<const_elem_iterator_imp> p;
712  return const_element_iterator(_elements.end(), _elements.end(), p);
713 }
void libMesh::UnstructuredMesh::find_neighbors ( const bool  reset_remote_elements = false,
const bool  reset_current_list = true 
)
virtualinherited

Other functions from MeshBase requiring re-definition.

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

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

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

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

Implements libMesh::MeshBase.

Definition at line 219 of file unstructured_mesh.C.

References libMesh::MeshBase::_dim, libMesh::Elem::active(), libMesh::Elem::ancestor(), libMesh::Elem::centroid(), libMesh::Elem::child(), libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), end, libMesh::err, libMesh::Elem::has_children(), libMesh::Elem::hmin(), libMesh::DofObject::id(), 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_neighbors(), libMesh::Elem::n_children(), libMesh::MeshTools::n_levels(), libMesh::Elem::n_neighbors(), libMesh::Elem::neighbor(), libMesh::Elem::parent(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::remote_elem, libMesh::Elem::set_neighbor(), libMesh::Elem::side(), libMesh::START_LOG(), libMesh::STOP_LOG(), libMesh::Elem::subactive(), libMesh::Elem::which_child_am_i(), and libMesh::GMVIO::write().

Referenced by libMesh::TriangleWrapper::copy_tri_to_mesh().

221 {
222  // We might actually want to run this on an empty mesh
223  // (e.g. the boundary mesh for a nonexistant bcid!)
224  // libmesh_assert_not_equal_to (this->n_nodes(), 0);
225  // libmesh_assert_not_equal_to (this->n_elem(), 0);
226 
227  // This function must be run on all processors at once
228  parallel_object_only();
229 
230  START_LOG("find_neighbors()", "Mesh");
231 
232  const element_iterator el_end = this->elements_end();
233 
234  //TODO:[BSK] This should be removed later?!
235  if (reset_current_list)
236  for (element_iterator el = this->elements_begin(); el != el_end; ++el)
237  {
238  Elem* e = *el;
239  for (unsigned int s=0; s<e->n_neighbors(); s++)
240  if (e->neighbor(s) != remote_elem ||
241  reset_remote_elements)
242  e->set_neighbor(s,NULL);
243  }
244 
245  // Find neighboring elements by first finding elements
246  // with identical side keys and then check to see if they
247  // are neighbors
248  {
249  // data structures -- Use the hash_multimap if available
250  typedef unsigned int key_type;
251  typedef std::pair<Elem*, unsigned char> val_type;
252  typedef std::pair<key_type, val_type> key_val_pair;
253 
254  typedef LIBMESH_BEST_UNORDERED_MULTIMAP<key_type, val_type> map_type;
255 
256  // A map from side keys to corresponding elements & side numbers
257  map_type side_to_elem_map;
258 
259 
260 
261  for (element_iterator el = this->elements_begin(); el != el_end; ++el)
262  {
263  Elem* element = *el;
264 
265  for (unsigned int ms=0; ms<element->n_neighbors(); ms++)
266  {
267  next_side:
268  // If we haven't yet found a neighbor on this side, try.
269  // Even if we think our neighbor is remote, that
270  // information may be out of date.
271  if (element->neighbor(ms) == NULL ||
272  element->neighbor(ms) == remote_elem)
273  {
274  // Get the key for the side of this element
275  const unsigned int key = element->key(ms);
276 
277  // Look for elements that have an identical side key
278  std::pair <map_type::iterator, map_type::iterator>
279  bounds = side_to_elem_map.equal_range(key);
280 
281  // May be multiple keys, check all the possible
282  // elements which _might_ be neighbors.
283  if (bounds.first != bounds.second)
284  {
285  // Get the side for this element
286  const AutoPtr<Elem> my_side(element->side(ms));
287 
288  // Look at all the entries with an equivalent key
289  while (bounds.first != bounds.second)
290  {
291  // Get the potential element
292  Elem* neighbor = bounds.first->second.first;
293 
294  // Get the side for the neighboring element
295  const unsigned int ns = bounds.first->second.second;
296  const AutoPtr<Elem> their_side(neighbor->side(ns));
297  //libmesh_assert(my_side.get());
298  //libmesh_assert(their_side.get());
299 
300  // If found a match with my side
301  //
302  // We need special tests here for 1D:
303  // since parents and children have an equal
304  // side (i.e. a node), we need to check
305  // ns != ms, and we also check level() to
306  // avoid setting our neighbor pointer to
307  // any of our neighbor's descendants
308  if( (*my_side == *their_side) &&
309  (element->level() == neighbor->level()) &&
310  ((_dim != 1) || (ns != ms)) )
311  {
312  // So share a side. Is this a mixed pair
313  // of subactive and active/ancestor
314  // elements?
315  // If not, then we're neighbors.
316  // If so, then the subactive's neighbor is
317 
318  if (element->subactive() ==
319  neighbor->subactive())
320  {
321  // an element is only subactive if it has
322  // been coarsened but not deleted
323  element->set_neighbor (ms,neighbor);
324  neighbor->set_neighbor(ns,element);
325  }
326  else if (element->subactive())
327  {
328  element->set_neighbor(ms,neighbor);
329  }
330  else if (neighbor->subactive())
331  {
332  neighbor->set_neighbor(ns,element);
333  }
334  side_to_elem_map.erase (bounds.first);
335 
336  // get out of this nested crap
337  goto next_side;
338  }
339 
340  ++bounds.first;
341  }
342  }
343 
344  // didn't find a match...
345  // Build the map entry for this element
346  key_val_pair kvp;
347 
348  kvp.first = key;
349  kvp.second.first = element;
350  kvp.second.second = ms;
351 
352  // use the lower bound as a hint for
353  // where to put it.
354 #if defined(LIBMESH_HAVE_UNORDERED_MAP) || defined(LIBMESH_HAVE_TR1_UNORDERED_MAP) || defined(LIBMESH_HAVE_HASH_MAP) || defined(LIBMESH_HAVE_EXT_HASH_MAP)
355  side_to_elem_map.insert (kvp);
356 #else
357  side_to_elem_map.insert (bounds.first,kvp);
358 #endif
359  }
360  }
361  }
362  }
363 
364 #ifdef LIBMESH_ENABLE_AMR
365 
386  const unsigned int n_levels = MeshTools::n_levels(*this);
387  for (unsigned int level = 1; level < n_levels; ++level)
388  {
389  element_iterator end = this->level_elements_end(level);
390  for (element_iterator el = this->level_elements_begin(level);
391  el != end; ++el)
392  {
393  Elem* current_elem = *el;
394  libmesh_assert(current_elem);
395  Elem* parent = current_elem->parent();
396  libmesh_assert(parent);
397  const unsigned int my_child_num = parent->which_child_am_i(current_elem);
398 
399  for (unsigned int s=0; s < current_elem->n_neighbors(); s++)
400  {
401  if (current_elem->neighbor(s) == NULL ||
402  (current_elem->neighbor(s) == remote_elem &&
403  parent->is_child_on_side(my_child_num, s)))
404  {
405  Elem *neigh = parent->neighbor(s);
406 
407  // If neigh was refined and had non-subactive children
408  // made remote earlier, then a non-subactive elem should
409  // actually have one of those remote children as a
410  // neighbor
411  if (neigh && (neigh->ancestor()) && (!current_elem->subactive()))
412  {
413 #ifdef DEBUG
414  // Let's make sure that "had children made remote"
415  // situation is actually the case
416  libmesh_assert(neigh->has_children());
417  bool neigh_has_remote_children = false;
418  for (unsigned int c = 0; c != neigh->n_children(); ++c)
419  {
420  if (neigh->child(c) == remote_elem)
421  neigh_has_remote_children = true;
422  }
423  libmesh_assert(neigh_has_remote_children);
424 
425  // And let's double-check that we don't have
426  // a remote_elem neighboring a local element
427  libmesh_assert_not_equal_to (current_elem->processor_id(),
428  this->processor_id());
429 #endif // DEBUG
430  neigh = const_cast<RemoteElem*>(remote_elem);
431  }
432 
433  current_elem->set_neighbor(s, neigh);
434 #ifdef DEBUG
435  if (neigh != NULL && neigh != remote_elem)
436  // We ignore subactive elements here because
437  // we don't care about neighbors of subactive element.
438  if ((!neigh->active()) && (!current_elem->subactive()))
439  {
440  libMesh::err << "On processor " << this->processor_id()
441  << std::endl;
442  libMesh::err << "Bad element ID = " << current_elem->id()
443  << ", Side " << s << ", Bad neighbor ID = " << neigh->id() << std::endl;
444  libMesh::err << "Bad element proc_ID = " << current_elem->processor_id()
445  << ", Bad neighbor proc_ID = " << neigh->processor_id() << std::endl;
446  libMesh::err << "Bad element size = " << current_elem->hmin()
447  << ", Bad neighbor size = " << neigh->hmin() << std::endl;
448  libMesh::err << "Bad element center = " << current_elem->centroid()
449  << ", Bad neighbor center = " << neigh->centroid() << std::endl;
450  libMesh::err << "ERROR: "
451  << (current_elem->active()?"Active":"Ancestor")
452  << " Element at level "
453  << current_elem->level() << std::endl;
454  libMesh::err << "with "
455  << (parent->active()?"active":
456  (parent->subactive()?"subactive":"ancestor"))
457  << " parent share "
458  << (neigh->subactive()?"subactive":"ancestor")
459  << " neighbor at level " << neigh->level()
460  << std::endl;
461  GMVIO(*this).write ("bad_mesh.gmv");
462  libmesh_error();
463  }
464 #endif // DEBUG
465  }
466  }
467  }
468  }
469 
470 #endif // AMR
471 
472 
473 #ifdef DEBUG
475 #endif
476 
477  STOP_LOG("find_neighbors()", "Mesh");
478 }
void libMesh::ParallelMesh::fix_broken_node_and_element_numbering ( )
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(n)->id() == n.

Implements libMesh::MeshBase.

Definition at line 1162 of file parallel_mesh.C.

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

1163 {
1164  // We need access to iterators for the underlying containers,
1165  // not the mapvector<> reimplementations.
1166  mapvector<Node*,dof_id_type>::maptype &nodes = this->_nodes;
1167  mapvector<Elem*,dof_id_type>::maptype &elems = this->_elements;
1168 
1169  // Nodes first
1170  {
1171  mapvector<Node*,dof_id_type>::maptype::iterator
1172  it = nodes.begin(),
1173  end = nodes.end();
1174 
1175  for (; it != end; ++it)
1176  if (it->second != NULL)
1177  it->second->set_id() = it->first;
1178  }
1179 
1180  // Elements next
1181  {
1182  mapvector<Elem*,dof_id_type>::maptype::iterator
1183  it = elems.begin(),
1184  end = elems.end();
1185 
1186  for (; it != end; ++it)
1187  if (it->second != NULL)
1188  it->second->set_id() = it->first;
1189  }
1190 }
subdomain_id_type libMesh::MeshBase::get_id_by_name ( const std::string &  name) const
inherited

Returns a the id of the requested block by name. Throws an error if a block by name is not found

Definition at line 441 of file mesh_base.C.

References libMesh::MeshBase::_block_id_to_name, and libMesh::err.

442 {
443  // This function is searching the *values* of the map (linear search)
444  // We might want to make this more efficient...
445  std::map<subdomain_id_type, std::string>::const_iterator
446  iter = _block_id_to_name.begin(),
447  end_iter = _block_id_to_name.end();
448 
449  for ( ; iter != end_iter; ++iter)
450  {
451  if (iter->second == name)
452  return iter->first;
453  }
454 
455  libMesh::err << "Block '" << name << "' does not exist in mesh" << std::endl;
456  libmesh_error();
457 }
std::string libMesh::MeshBase::get_info ( ) const
inherited
Returns
a string containing relevant information about the mesh.

Definition at line 305 of file mesh_base.C.

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

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

306 {
307  std::ostringstream oss;
308 
309  oss << " Mesh Information:" << '\n'
310  << " mesh_dimension()=" << this->mesh_dimension() << '\n'
311  << " spatial_dimension()=" << this->spatial_dimension() << '\n'
312  << " n_nodes()=" << this->n_nodes() << '\n'
313  << " n_local_nodes()=" << this->n_local_nodes() << '\n'
314  << " n_elem()=" << this->n_elem() << '\n'
315  << " n_local_elem()=" << this->n_local_elem() << '\n'
316 #ifdef LIBMESH_ENABLE_AMR
317  << " n_active_elem()=" << this->n_active_elem() << '\n'
318 #endif
319  << " n_subdomains()=" << static_cast<std::size_t>(this->n_subdomains()) << '\n'
320  << " n_partitions()=" << static_cast<std::size_t>(this->n_partitions()) << '\n'
321  << " n_processors()=" << static_cast<std::size_t>(this->n_processors()) << '\n'
322  << " n_threads()=" << static_cast<std::size_t>(libMesh::n_threads()) << '\n'
323  << " processor_id()=" << static_cast<std::size_t>(this->processor_id()) << '\n';
324 
325  return oss.str();
326 }
const std::map<subdomain_id_type, std::string>& libMesh::MeshBase::get_subdomain_name_map ( ) const
inlineinherited
Elem * libMesh::ParallelMesh::insert_elem ( Elem e)
virtualinherited

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

Implements libMesh::MeshBase.

Definition at line 450 of file parallel_mesh.C.

References libMesh::ParallelMesh::_elements, libMesh::ParallelMesh::delete_elem(), and libMesh::DofObject::id().

451 {
452  if (_elements[e->id()])
453  this->delete_elem(_elements[e->id()]);
454 
455  _elements[e->id()] = e;
456 
457  return e;
458 }
Node * libMesh::ParallelMesh::insert_node ( Node n)
virtualinherited

Calls add_node().

Implements libMesh::MeshBase.

Definition at line 615 of file parallel_mesh.C.

References libMesh::ParallelMesh::add_node().

616 {
617  return ParallelMesh::add_node(n);
618 }
bool libMesh::MeshBase::is_prepared ( ) const
inlineinherited
Returns
true if the mesh has been prepared via a call to prepare_for_use, false otherwise.

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

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

Reimplemented from libMesh::MeshBase.

Definition at line 118 of file parallel_mesh.h.

References libMesh::ParallelMesh::_is_serial.

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

119  { return _is_serial; }
ParallelMesh::element_iterator libMesh::ParallelMesh::level_elements_begin ( const unsigned int  level)
virtualinherited

Implements libMesh::MeshBase.

Definition at line 147 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

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

148 {
149  Predicates::Level<elem_iterator_imp> p(level);
150  return element_iterator(_elements.begin(), _elements.end(), p);
151 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::level_elements_begin ( const unsigned int  level) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 371 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

372 {
373  Predicates::Level<const_elem_iterator_imp> p(level);
374  return const_element_iterator(_elements.begin(), _elements.end(), p);
375 }
ParallelMesh::element_iterator libMesh::ParallelMesh::level_elements_end ( const unsigned int  level)
virtualinherited

Implements libMesh::MeshBase.

Definition at line 594 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

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

595 {
596  Predicates::Level<elem_iterator_imp> p(level);
597  return element_iterator(_elements.end(), _elements.end(), p);
598 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::level_elements_end ( const unsigned int  level) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 819 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

820 {
821  Predicates::Level<const_elem_iterator_imp> p(level);
822  return const_element_iterator(_elements.end(), _elements.end(), p);
823 }
void libMesh::ParallelMesh::libmesh_assert_valid_parallel_flags ( ) const
inherited

Verify refinement_flag and p_refinement_flag consistency of our elements containers. Calls libmesh_assert() on each possible failure.

Definition at line 806 of file parallel_mesh.C.

References libMesh::ParallelMesh::_elements, libMesh::ParallelObject::comm(), libMesh::invalid_uint, libMesh::libmesh_assert(), libMesh::Parallel::Communicator::min(), libMesh::Elem::p_refinement_flag(), libMesh::ParallelMesh::parallel_max_elem_id(), and libMesh::Elem::refinement_flag().

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

807 {
808 #ifdef LIBMESH_ENABLE_AMR
809  // This function must be run on all processors at once
810  parallel_object_only();
811 
812  dof_id_type pmax_elem_id = this->parallel_max_elem_id();
813 
814  for (dof_id_type i=0; i != pmax_elem_id; ++i)
815  {
816  Elem* el = _elements[i]; // Returns NULL if there's no map entry
817 
818  unsigned int refinement_flag = el ?
819  static_cast<unsigned int> (el->refinement_flag()) : libMesh::invalid_uint;
820 #ifndef NDEBUG
821  unsigned int p_refinement_flag = el ?
822  static_cast<unsigned int> (el->p_refinement_flag()) : libMesh::invalid_uint;
823 #endif
824 
825  unsigned int min_rflag = refinement_flag;
826  this->comm().min(min_rflag);
827  // All processors with this element should agree on flag
828  libmesh_assert (!el || min_rflag == refinement_flag);
829 
830 #ifndef NDEBUG
831  unsigned int min_pflag = p_refinement_flag;
832 #endif
833  // All processors with this element should agree on flag
834  libmesh_assert (!el || min_pflag == p_refinement_flag);
835  }
836 #endif // LIBMESH_ENABLE_AMR
837 }
void libMesh::ParallelMesh::libmesh_assert_valid_parallel_ids ( ) const
virtualinherited
template<typename T >
void libMesh::ParallelMesh::libmesh_assert_valid_parallel_object_ids ( const mapvector< T *, dof_id_type > &  objects) const
inherited

Verify id and processor_id consistency of a parallel objects container. Calls libmesh_assert() on each possible failure in that container.

Definition at line 747 of file parallel_mesh.C.

References libMesh::comm, libMesh::DofObject::invalid_id, libMesh::DofObject::invalid_processor_id, libMesh::libmesh_assert(), std::max(), and libMesh::processor_id().

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

748 {
749  // This function must be run on all processors at once
750  parallel_object_only();
751 
752  const dof_id_type pmax_node_id = this->parallel_max_node_id();
753  const dof_id_type pmax_elem_id = this->parallel_max_elem_id();
754  const dof_id_type pmax_id = std::max(pmax_node_id, pmax_elem_id);
755 
756  for (dof_id_type i=0; i != pmax_id; ++i)
757  {
758  T* obj = objects[i]; // Returns NULL if there's no map entry
759 
760  dof_id_type dofid = obj && obj->valid_id() ?
761  obj->id() : DofObject::invalid_id;
762  // Local lookups by id should return the requested object
763  libmesh_assert(!obj || obj->id() == i);
764 
765  dof_id_type min_dofid = dofid;
766  this->comm().min(min_dofid);
767  // All processors with an object should agree on id
768  libmesh_assert (!obj || dofid == min_dofid);
769 
770  dof_id_type procid = obj && obj->valid_processor_id() ?
771  obj->processor_id() : DofObject::invalid_processor_id;
772 
773  dof_id_type min_procid = procid;
774  this->comm().min(min_procid);
775 
776  // All processors with an object should agree on processor id
777  libmesh_assert (!obj || procid == min_procid);
778 
779  // Either:
780  // 1.) I own this elem (min_procid == this->processor_id()) *and* I have a valid pointer to it (obj != NULL)
781  // or
782  // 2.) I don't own this elem (min_procid != this->processor_id()). (In this case I may or may not have a valid pointer to it.)
783 
784  // Original assert logic
785  // libmesh_assert (min_procid != this->processor_id() || obj);
786 
787  // More human-understandable logic...
789  ((min_procid == this->processor_id()) && obj)
790  ||
791  (min_procid != this->processor_id())
792  );
793  }
794 }
ParallelMesh::element_iterator libMesh::ParallelMesh::local_elements_begin ( )
virtualinherited

Implements libMesh::MeshBase.

Definition at line 107 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

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

108 {
109  Predicates::Local<elem_iterator_imp> p(this->processor_id());
110  return element_iterator(_elements.begin(), _elements.end(), p);
111 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::local_elements_begin ( ) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 331 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

332 {
333  Predicates::Local<const_elem_iterator_imp> p(this->processor_id());
334  return const_element_iterator(_elements.begin(), _elements.end(), p);
335 }
ParallelMesh::element_iterator libMesh::ParallelMesh::local_elements_end ( )
virtualinherited

Implements libMesh::MeshBase.

Definition at line 554 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

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

555 {
556  Predicates::Local<elem_iterator_imp> p(this->processor_id());
557  return element_iterator(_elements.end(), _elements.end(), p);
558 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::local_elements_end ( ) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 779 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

780 {
781  Predicates::Local<const_elem_iterator_imp> p(this->processor_id());
782  return const_element_iterator(_elements.end(), _elements.end(), p);
783 }
ParallelMesh::element_iterator libMesh::ParallelMesh::local_level_elements_begin ( const unsigned int  level)
virtualinherited

Implements libMesh::MeshBase.

Definition at line 167 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

168 {
169  Predicates::LocalLevel<elem_iterator_imp> p(this->processor_id(),level);
170  return element_iterator(_elements.begin(), _elements.end(), p);
171 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::local_level_elements_begin ( const unsigned int  level) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 391 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

392 {
393  Predicates::LocalLevel<const_elem_iterator_imp> p(this->processor_id(),level);
394  return const_element_iterator(_elements.begin(), _elements.end(), p);
395 }
ParallelMesh::element_iterator libMesh::ParallelMesh::local_level_elements_end ( const unsigned int  level)
virtualinherited

Implements libMesh::MeshBase.

Definition at line 614 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

615 {
616  Predicates::LocalLevel<elem_iterator_imp> p(this->processor_id(),level);
617  return element_iterator(_elements.end(), _elements.end(), p);
618 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::local_level_elements_end ( const unsigned int  level) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 839 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

840 {
841  Predicates::LocalLevel<const_elem_iterator_imp> p(this->processor_id(),level);
842  return const_element_iterator(_elements.end(), _elements.end(), p);
843 }
ParallelMesh::node_iterator libMesh::ParallelMesh::local_nodes_begin ( )
virtualinherited

Implements libMesh::MeshBase.

Definition at line 951 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_nodes, and libMesh::ParallelObject::processor_id().

952 {
953  Predicates::Local<node_iterator_imp> p(this->processor_id());
954  return node_iterator(_nodes.begin(), _nodes.end(), p);
955 }
ParallelMesh::const_node_iterator libMesh::ParallelMesh::local_nodes_begin ( ) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 991 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_nodes, and libMesh::ParallelObject::processor_id().

992 {
993  Predicates::Local<const_node_iterator_imp> p(this->processor_id());
994  return const_node_iterator(_nodes.begin(), _nodes.end(), p);
995 }
ParallelMesh::node_iterator libMesh::ParallelMesh::local_nodes_end ( )
virtualinherited

Implements libMesh::MeshBase.

Definition at line 1031 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_nodes, and libMesh::ParallelObject::processor_id().

1032 {
1033  Predicates::Local<node_iterator_imp> p(this->processor_id());
1034  return node_iterator(_nodes.end(), _nodes.end(), p);
1035 }
ParallelMesh::const_node_iterator libMesh::ParallelMesh::local_nodes_end ( ) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 1071 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_nodes, and libMesh::ParallelObject::processor_id().

1072 {
1073  Predicates::Local<const_node_iterator_imp> p(this->processor_id());
1074  return const_node_iterator(_nodes.end(), _nodes.end(), p);
1075 }
ParallelMesh::element_iterator libMesh::ParallelMesh::local_not_level_elements_begin ( const unsigned int  level)
virtualinherited

Implements libMesh::MeshBase.

Definition at line 177 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

178 {
179  Predicates::LocalNotLevel<elem_iterator_imp> p(this->processor_id(),level);
180  return element_iterator(_elements.begin(), _elements.end(), p);
181 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::local_not_level_elements_begin ( const unsigned int  level) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 401 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

402 {
403  Predicates::LocalNotLevel<const_elem_iterator_imp> p(this->processor_id(),level);
404  return const_element_iterator(_elements.begin(), _elements.end(), p);
405 }
ParallelMesh::element_iterator libMesh::ParallelMesh::local_not_level_elements_end ( const unsigned int  level)
virtualinherited

Implements libMesh::MeshBase.

Definition at line 624 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

625 {
626  Predicates::LocalNotLevel<elem_iterator_imp> p(this->processor_id(),level);
627  return element_iterator(_elements.end(), _elements.end(), p);
628 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::local_not_level_elements_end ( const unsigned int  level) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 849 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

850 {
851  Predicates::LocalNotLevel<const_elem_iterator_imp> p(this->processor_id(),level);
852  return const_element_iterator(_elements.end(), _elements.end(), p);
853 }
virtual dof_id_type libMesh::ParallelMesh::max_elem_id ( ) const
inlinevirtualinherited
virtual dof_id_type libMesh::ParallelMesh::max_node_id ( ) const
inlinevirtualinherited
unsigned int libMesh::MeshBase::mesh_dimension ( ) const
inlineinherited
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 155 of file mesh_base.h.

References libMesh::MeshBase::_dim.

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::HPCoarsenTest::add_projection(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Generation::build_cube(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_solution_vector(), libMesh::EquationSystems::build_variable_names(), libMesh::System::calculate_norm(), libMesh::DofMap::create_dof_constraints(), libMesh::MeshTools::Modification::distort(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::MeshBase::get_info(), libMesh::MeshFunction::gradient(), libMesh::MeshFunction::hessian(), libMesh::LaplaceMeshSmoother::init(), libMesh::PointLocatorTree::init(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_discontinuous(), libMesh::FEInterface::n_vec_dim(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::ProjectSolution::operator()(), libMesh::MeshFunction::operator()(), libMesh::BoundaryProjectSolution::operator()(), libMesh::MeshBase::prepare_for_use(), libMesh::Nemesis_IO::read(), libMesh::ExodusII_IO::read(), libMesh::GMVIO::read(), libMesh::VTKIO::read(), libMesh::System::read_header(), libMesh::GmshIO::read_mesh(), libMesh::LegacyXdrIO::read_mesh(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::MeshTools::Modification::rotate(), libMesh::HPCoarsenTest::select_refinement(), libMesh::MeshTools::Modification::smooth(), libMesh::BoundaryInfo::sync(), libMesh::DofMap::use_coupled_neighbor_dofs(), libMesh::PostscriptIO::write(), libMesh::TecplotIO::write_ascii(), libMesh::GMVIO::write_ascii_old_impl(), 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(), libMesh::DivaIO::write_stream(), and libMesh::EnsightIO::write_vector_ascii().

156  { return static_cast<unsigned int>(_dim); }
dof_id_type libMesh::ParallelMesh::n_active_elem ( ) const
virtualinherited

Returns the number of active elements in the mesh. Implemented in terms of active_element_iterators.

Implements libMesh::MeshBase.

Definition at line 1194 of file parallel_mesh.C.

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

1195 {
1196  parallel_object_only();
1197 
1198  // Get local active elements first
1199  dof_id_type active_elements =
1200  static_cast<dof_id_type>(std::distance (this->active_local_elements_begin(),
1201  this->active_local_elements_end()));
1202  this->comm().sum(active_elements);
1203 
1204  // Then add unpartitioned active elements, which should exist on
1205  // every processor
1206  active_elements +=
1207  static_cast<dof_id_type>(std::distance
1210  return active_elements;
1211 }
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 266 of file mesh_base.C.

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

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

267 {
268  libmesh_assert_less (proc_id, this->n_processors());
269  return static_cast<dof_id_type>(std::distance (this->active_pid_elements_begin(proc_id),
270  this->active_pid_elements_end (proc_id)));
271 }
dof_id_type libMesh::MeshBase::n_active_local_elem ( ) const
inlineinherited
dof_id_type libMesh::MeshBase::n_active_sub_elem ( ) const
inherited

Same, but only counts active elements.

Definition at line 290 of file mesh_base.C.

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

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

291 {
292  dof_id_type ne=0;
293 
294  const_element_iterator el = this->active_elements_begin();
295  const const_element_iterator end = this->active_elements_end();
296 
297  for (; el!=end; ++el)
298  ne += (*el)->n_sub_elem();
299 
300  return ne;
301 }
virtual dof_id_type libMesh::ParallelMesh::n_elem ( ) const
inlinevirtualinherited

Returns the number of elements in the mesh. The standard n_elem() function may return a cached value on distributed meshes, and so can be called by any processor at any time.

Implements libMesh::MeshBase.

Definition at line 185 of file parallel_mesh.h.

References libMesh::ParallelMesh::_n_elem.

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

185 { return _n_elem; }
dof_id_type libMesh::MeshBase::n_elem_on_proc ( const processor_id_type  proc) const
inherited

Returns the number of elements on processor proc.

Definition at line 253 of file mesh_base.C.

References 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(), and libMesh::MeshBase::n_unpartitioned_elem().

254 {
255  // We're either counting a processor's elements or unpartitioned
256  // elements
257  libmesh_assert (proc_id < this->n_processors() ||
259 
260  return static_cast<dof_id_type>(std::distance (this->pid_elements_begin(proc_id),
261  this->pid_elements_end (proc_id)));
262 }
dof_id_type libMesh::MeshBase::n_local_elem ( ) const
inlineinherited

Returns the number of elements on the local processor.

Definition at line 283 of file mesh_base.h.

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

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

284  { return this->n_elem_on_proc (this->processor_id()); }
dof_id_type libMesh::MeshBase::n_local_nodes ( ) const
inlineinherited

Returns the number of nodes on the local processor.

Definition at line 197 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::ParallelMesh::parallel_n_nodes().

198  { return this->n_nodes_on_proc (this->processor_id()); }
virtual dof_id_type libMesh::ParallelMesh::n_nodes ( ) const
inlinevirtualinherited

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

Implements libMesh::MeshBase.

Definition at line 182 of file parallel_mesh.h.

References libMesh::ParallelMesh::_n_nodes.

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

182 { return _n_nodes; }
dof_id_type libMesh::MeshBase::n_nodes_on_proc ( const processor_id_type  proc) const
inherited

Returns the number of nodes on processor proc.

Definition at line 240 of file mesh_base.C.

References 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::n_local_nodes(), and libMesh::MeshBase::n_unpartitioned_nodes().

241 {
242  // We're either counting a processor's nodes or unpartitioned
243  // nodes
244  libmesh_assert (proc_id < this->n_processors() ||
246 
247  return static_cast<dof_id_type>(std::distance (this->pid_nodes_begin(proc_id),
248  this->pid_nodes_end (proc_id)));
249 }
unsigned int libMesh::MeshBase::n_partitions ( ) const
inlineinherited

Returns the number of partitions which have been defined via a call to either mesh.partition() or by building a Partitioner object and calling partition. Note that the partitioner objects are responsible for setting this value.

Definition at line 578 of file mesh_base.h.

References libMesh::MeshBase::_n_parts.

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

579  { return _n_parts; }
processor_id_type libMesh::ParallelObject::n_processors ( ) const
inlineinherited
Returns
the number of processors in the group.

Definition at line 92 of file parallel_object.h.

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

Referenced by libMesh::ParmetisPartitioner::_do_repartition(), libMesh::ParallelMesh::add_elem(), libMesh::ParallelMesh::add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::ParallelMesh::assign_unique_ids(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::ParallelMesh::clear(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::EnsightIO::EnsightIO(), libMesh::MeshBase::get_info(), libMesh::EquationSystems::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshBase::n_active_elem_on_proc(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), 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::MeshTools::processor_bounding_box(), libMesh::System::project_vector(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::UnstructuredMesh::read(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::System::read_serialized_vector(), libMesh::Partitioner::repartition(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::BoundaryInfo::sync(), libMesh::ParallelMesh::update_parallel_id_counts(), libMesh::CheckpointIO::write(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

93  { return libmesh_cast_int<processor_id_type>(_communicator.size()); }
dof_id_type libMesh::MeshBase::n_sub_elem ( ) const
inherited

This function returns the number of elements that will be written out in the Tecplot format. 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 275 of file mesh_base.C.

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

276 {
277  dof_id_type ne=0;
278 
279  const_element_iterator el = this->elements_begin();
280  const const_element_iterator end = this->elements_end();
281 
282  for (; el!=end; ++el)
283  ne += (*el)->n_sub_elem();
284 
285  return ne;
286 }
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 225 of file mesh_base.C.

References libMesh::MeshBase::subdomain_ids().

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

226 {
227  // This requires an inspection on every processor
228  parallel_object_only();
229 
230  std::set<subdomain_id_type> ids;
231 
232  this->subdomain_ids (ids);
233 
234  return ids.size();
235 }
dof_id_type libMesh::MeshBase::n_unpartitioned_elem ( ) const
inlineinherited

Returns the number of elements owned by no processor.

Definition at line 289 of file mesh_base.h.

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

Referenced by libMesh::ParallelMesh::parallel_n_elem().

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

Returns the number of nodes owned by no processor.

Definition at line 203 of file mesh_base.h.

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

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

unique_id_type libMesh::MeshBase::next_unique_id ( )
inlineinherited

Returns the next unique id to be used.

Definition at line 216 of file mesh_base.h.

References libMesh::MeshBase::_next_unique_id.

216 { return _next_unique_id; }
const Node & libMesh::ParallelMesh::node ( const dof_id_type  i) const
virtualinherited

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

Implements libMesh::MeshBase.

Definition at line 229 of file parallel_mesh.C.

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

230 {
232  libmesh_assert_equal_to (_nodes[i]->id(), i);
233 
234  return (*_nodes[i]);
235 }
Node & libMesh::ParallelMesh::node ( const dof_id_type  i)
virtualinherited

Return a reference to the $ i^{th} $ node, which should be present in this processor's subset of the mesh data structure.

Implements libMesh::MeshBase.

Definition at line 241 of file parallel_mesh.C.

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

242 {
244  libmesh_assert_equal_to (_nodes[i]->id(), i);
245 
246  return (*_nodes[i]);
247 }
const Node * libMesh::ParallelMesh::node_ptr ( const dof_id_type  i) const
virtualinherited

Return a pointer to the $ i^{th} $ node, which should be present in this processor's subset of the mesh data structure.

Implements libMesh::MeshBase.

Definition at line 251 of file parallel_mesh.C.

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

252 {
254  libmesh_assert_equal_to (_nodes[i]->id(), i);
255 
256  return _nodes[i];
257 }
Node * libMesh::ParallelMesh::node_ptr ( const dof_id_type  i)
virtualinherited

Return a writeable pointer to the $ i^{th} $ node, which should be present in this processor's subset of the mesh data structure.

Implements libMesh::MeshBase.

Definition at line 262 of file parallel_mesh.C.

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

263 {
265  libmesh_assert_equal_to (_nodes[i]->id(), i);
266 
267  return _nodes[i];
268 }
ParallelMesh::node_iterator libMesh::ParallelMesh::nodes_begin ( )
virtualinherited

non-const Node iterator accessor functions.

Implements libMesh::MeshBase.

Definition at line 931 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_nodes.

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

932 {
933  Predicates::NotNull<node_iterator_imp> p;
934  return node_iterator(_nodes.begin(), _nodes.end(), p);
935 }
ParallelMesh::const_node_iterator libMesh::ParallelMesh::nodes_begin ( ) const
virtualinherited

const Node iterator accessor functions.

Implements libMesh::MeshBase.

Definition at line 971 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_nodes.

972 {
973  Predicates::NotNull<const_node_iterator_imp> p;
974  return const_node_iterator(_nodes.begin(), _nodes.end(), p);
975 }
ParallelMesh::node_iterator libMesh::ParallelMesh::nodes_end ( )
virtualinherited

Implements libMesh::MeshBase.

Definition at line 1011 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_nodes.

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

1012 {
1013  Predicates::NotNull<node_iterator_imp> p;
1014  return node_iterator(_nodes.end(), _nodes.end(), p);
1015 }
ParallelMesh::const_node_iterator libMesh::ParallelMesh::nodes_end ( ) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 1051 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_nodes.

1052 {
1053  Predicates::NotNull<const_node_iterator_imp> p;
1054  return const_node_iterator(_nodes.end(), _nodes.end(), p);
1055 }
ParallelMesh::element_iterator libMesh::ParallelMesh::not_active_elements_begin ( )
virtualinherited

Implements libMesh::MeshBase.

Definition at line 57 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

58 {
59  Predicates::NotActive<elem_iterator_imp> p;
60  return element_iterator(_elements.begin(), _elements.end(), p);
61 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::not_active_elements_begin ( ) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 281 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

282 {
283  Predicates::NotActive<const_elem_iterator_imp> p;
284  return const_element_iterator(_elements.begin(), _elements.end(), p);
285 }
ParallelMesh::element_iterator libMesh::ParallelMesh::not_active_elements_end ( )
virtualinherited

Implements libMesh::MeshBase.

Definition at line 504 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

505 {
506  Predicates::NotActive<elem_iterator_imp> p;
507  return element_iterator(_elements.end(), _elements.end(), p);
508 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::not_active_elements_end ( ) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 729 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

730 {
731  Predicates::NotActive<const_elem_iterator_imp> p;
732  return const_element_iterator(_elements.end(), _elements.end(), p);
733 }
ParallelMesh::element_iterator libMesh::ParallelMesh::not_ancestor_elements_begin ( )
virtualinherited

Implements libMesh::MeshBase.

Definition at line 77 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

78 {
79  Predicates::Ancestor<elem_iterator_imp> p;
80  return element_iterator(_elements.begin(), _elements.end(), p);
81 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::not_ancestor_elements_begin ( ) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 301 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

302 {
303  Predicates::Ancestor<const_elem_iterator_imp> p;
304  return const_element_iterator(_elements.begin(), _elements.end(), p);
305 }
ParallelMesh::element_iterator libMesh::ParallelMesh::not_ancestor_elements_end ( )
virtualinherited

Implements libMesh::MeshBase.

Definition at line 524 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

525 {
526  Predicates::Ancestor<elem_iterator_imp> p;
527  return element_iterator(_elements.end(), _elements.end(), p);
528 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::not_ancestor_elements_end ( ) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 749 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

750 {
751  Predicates::Ancestor<const_elem_iterator_imp> p;
752  return const_element_iterator(_elements.end(), _elements.end(), p);
753 }
ParallelMesh::element_iterator libMesh::ParallelMesh::not_level_elements_begin ( const unsigned int  level)
virtualinherited

Implements libMesh::MeshBase.

Definition at line 157 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

158 {
159  Predicates::NotLevel<elem_iterator_imp> p(level);
160  return element_iterator(_elements.begin(), _elements.end(), p);
161 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::not_level_elements_begin ( const unsigned int  level) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 381 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

382 {
383  Predicates::NotLevel<const_elem_iterator_imp> p(level);
384  return const_element_iterator(_elements.begin(), _elements.end(), p);
385 }
ParallelMesh::element_iterator libMesh::ParallelMesh::not_level_elements_end ( const unsigned int  level)
virtualinherited

Implements libMesh::MeshBase.

Definition at line 604 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

605 {
606  Predicates::NotLevel<elem_iterator_imp> p(level);
607  return element_iterator(_elements.end(), _elements.end(), p);
608 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::not_level_elements_end ( const unsigned int  level) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 829 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

830 {
831  Predicates::NotLevel<const_elem_iterator_imp> p(level);
832  return const_element_iterator(_elements.end(), _elements.end(), p);
833 }
ParallelMesh::element_iterator libMesh::ParallelMesh::not_local_elements_begin ( )
virtualinherited

Implements libMesh::MeshBase.

Definition at line 117 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

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

118 {
119  Predicates::NotLocal<elem_iterator_imp> p(this->processor_id());
120  return element_iterator(_elements.begin(), _elements.end(), p);
121 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::not_local_elements_begin ( ) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 341 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

342 {
343  Predicates::NotLocal<const_elem_iterator_imp> p(this->processor_id());
344  return const_element_iterator(_elements.begin(), _elements.end(), p);
345 }
ParallelMesh::element_iterator libMesh::ParallelMesh::not_local_elements_end ( )
virtualinherited

Implements libMesh::MeshBase.

Definition at line 564 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

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

565 {
566  Predicates::NotLocal<elem_iterator_imp> p(this->processor_id());
567  return element_iterator(_elements.end(), _elements.end(), p);
568 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::not_local_elements_end ( ) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 789 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements, and libMesh::ParallelObject::processor_id().

790 {
791  Predicates::NotLocal<const_elem_iterator_imp> p(this->processor_id());
792  return const_element_iterator(_elements.end(), _elements.end(), p);
793 }
ParallelMesh::element_iterator libMesh::ParallelMesh::not_subactive_elements_begin ( )
virtualinherited

Implements libMesh::MeshBase.

Definition at line 97 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

98 {
99  Predicates::NotSubActive<elem_iterator_imp> p;
100  return element_iterator(_elements.begin(), _elements.end(), p);
101 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::not_subactive_elements_begin ( ) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 321 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

322 {
323  Predicates::NotSubActive<const_elem_iterator_imp> p;
324  return const_element_iterator(_elements.begin(), _elements.end(), p);
325 }
ParallelMesh::element_iterator libMesh::ParallelMesh::not_subactive_elements_end ( )
virtualinherited

Implements libMesh::MeshBase.

Definition at line 544 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

545 {
546  Predicates::NotSubActive<elem_iterator_imp> p;
547  return element_iterator(_elements.end(), _elements.end(), p);
548 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::not_subactive_elements_end ( ) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 769 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

770 {
771  Predicates::NotSubActive<const_elem_iterator_imp> p;
772  return const_element_iterator(_elements.end(), _elements.end(), p);
773 }
dof_id_type libMesh::ParallelMesh::parallel_max_elem_id ( ) const
inherited

Definition at line 178 of file parallel_mesh.C.

References libMesh::ParallelMesh::_elements, libMesh::ParallelObject::comm(), and libMesh::Parallel::Communicator::max().

Referenced by libMesh::ParallelMesh::allgather(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::ParallelMesh::delete_remote_elements(), libMesh::ParallelMesh::libmesh_assert_valid_parallel_flags(), libMesh::ParallelMesh::renumber_nodes_and_elements(), and libMesh::ParallelMesh::update_parallel_id_counts().

179 {
180  // This function must be run on all processors at once
181  parallel_object_only();
182 
183  dof_id_type max_local = _elements.empty() ?
184  0 : _elements.rbegin()->first + 1;
185  this->comm().max(max_local);
186  return max_local;
187 }
dof_id_type libMesh::ParallelMesh::parallel_max_node_id ( ) const
inherited

Definition at line 204 of file parallel_mesh.C.

References libMesh::ParallelMesh::_nodes, libMesh::ParallelObject::comm(), and libMesh::Parallel::Communicator::max().

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

205 {
206  // This function must be run on all processors at once
207  parallel_object_only();
208 
209  dof_id_type max_local = _nodes.empty() ?
210  0 : _nodes.rbegin()->first + 1;
211  this->comm().max(max_local);
212  return max_local;
213 }
dof_id_type libMesh::ParallelMesh::parallel_n_elem ( ) const
virtualinherited

Returns the number of elements in the mesh. The parallel_n_elem() function returns a newly calculated parallel-synchronized value on distributed meshes, and so must be called in parallel only.

Implements libMesh::MeshBase.

Definition at line 165 of file parallel_mesh.C.

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

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

166 {
167  // This function must be run on all processors at once
168  parallel_object_only();
169 
170  dof_id_type n_local = this->n_local_elem();
171  this->comm().sum(n_local);
172  n_local += this->n_unpartitioned_elem();
173  return n_local;
174 }
dof_id_type libMesh::ParallelMesh::parallel_n_nodes ( ) const
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 parallel_n_nodes() function returns a newly calculated parallel-synchronized value on distributed meshes, and so must be called in parallel only.

Implements libMesh::MeshBase.

Definition at line 191 of file parallel_mesh.C.

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

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

192 {
193  // This function must be run on all processors at once
194  parallel_object_only();
195 
197  this->comm().sum(n_local);
198  n_local += this->n_unpartitioned_nodes();
199  return n_local;
200 }
void libMesh::MeshBase::partition ( const unsigned int  n_parts)
virtualinherited

Call the default partitioner (currently metis_partition()).

Definition at line 343 of file mesh_base.C.

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

344 {
345  // NULL partitioner means don't partition
346  // Non-serial meshes aren't ready for partitioning yet.
347  if(!skip_partitioning() &&
348  partitioner().get() &&
349  this->is_serial())
350  {
351  partitioner()->partition (*this, n_parts);
352  }
353  else
354  {
355  // Make sure locally cached partition count
356  this->recalculate_n_partitions();
357 
358  // Make sure any other locally cached data is correct
359  this->update_post_partitioning();
360  }
361 }
void libMesh::MeshBase::partition ( )
inlineinherited

Definition at line 514 of file mesh_base.h.

References libMesh::ParallelObject::n_processors().

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

515  { this->partition(this->n_processors()); }
virtual AutoPtr<Partitioner>& libMesh::MeshBase::partitioner ( )
inlinevirtualinherited
ParallelMesh::element_iterator libMesh::ParallelMesh::pid_elements_begin ( const processor_id_type  proc_id)
virtualinherited

Implements libMesh::MeshBase.

Definition at line 187 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

Referenced by libMesh::ParallelMesh::unpartitioned_elements_begin().

188 {
189  Predicates::PID<elem_iterator_imp> p(proc_id);
190  return element_iterator(_elements.begin(), _elements.end(), p);
191 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::pid_elements_begin ( const processor_id_type  proc_id) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 411 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

412 {
413  Predicates::PID<const_elem_iterator_imp> p(proc_id);
414  return const_element_iterator(_elements.begin(), _elements.end(), p);
415 }
ParallelMesh::element_iterator libMesh::ParallelMesh::pid_elements_end ( const processor_id_type  proc_id)
virtualinherited

Implements libMesh::MeshBase.

Definition at line 634 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

Referenced by libMesh::ParallelMesh::unpartitioned_elements_end().

635 {
636  Predicates::PID<elem_iterator_imp> p(proc_id);
637  return element_iterator(_elements.end(), _elements.end(), p);
638 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::pid_elements_end ( const processor_id_type  proc_id) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 858 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

859 {
860  Predicates::PID<const_elem_iterator_imp> p(proc_id);
861  return const_element_iterator(_elements.end(), _elements.end(), p);
862 }
ParallelMesh::node_iterator libMesh::ParallelMesh::pid_nodes_begin ( const processor_id_type  proc_id)
virtualinherited

Implements libMesh::MeshBase.

Definition at line 961 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_nodes.

962 {
963  Predicates::PID<node_iterator_imp> p(proc_id);
964  return node_iterator(_nodes.begin(), _nodes.end(), p);
965 }
ParallelMesh::const_node_iterator libMesh::ParallelMesh::pid_nodes_begin ( const processor_id_type  proc_id) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 1001 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_nodes.

1002 {
1003  Predicates::PID<const_node_iterator_imp> p(proc_id);
1004  return const_node_iterator(_nodes.begin(), _nodes.end(), p);
1005 }
ParallelMesh::node_iterator libMesh::ParallelMesh::pid_nodes_end ( const processor_id_type  proc_id)
virtualinherited

Implements libMesh::MeshBase.

Definition at line 1041 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_nodes.

1042 {
1043  Predicates::PID<node_iterator_imp> p(proc_id);
1044  return node_iterator(_nodes.end(), _nodes.end(), p);
1045 }
ParallelMesh::const_node_iterator libMesh::ParallelMesh::pid_nodes_end ( const processor_id_type  proc_id) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 1081 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_nodes.

1082 {
1083  Predicates::PID<const_node_iterator_imp> p(proc_id);
1084  return const_node_iterator(_nodes.end(), _nodes.end(), p);
1085 }
const Point & libMesh::ParallelMesh::point ( const dof_id_type  i) const
virtualinherited

Return a constant reference (for reading only) to the $ i^{th} $ point, which should be present in this processor's subset of the mesh data structure.

Implements libMesh::MeshBase.

Definition at line 217 of file parallel_mesh.C.

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

218 {
220  libmesh_assert_equal_to (_nodes[i]->id(), i);
221 
222  return (*_nodes[i]);
223 }
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. This should never be used in threaded or non-parallel_only code, and so is deprecated.

Definition at line 383 of file mesh_base.C.

References libMesh::MeshBase::_point_locator, libMesh::PointLocatorBase::build(), libMesh::Threads::in_threads, libMesh::libmesh_assert(), and libMeshEnums::TREE.

384 {
385  libmesh_deprecated();
386 
387  if (_point_locator.get() == NULL)
388  {
389  // PointLocator construction may not be safe within threads
391 
392  _point_locator.reset (PointLocatorBase::build(TREE, *this).release());
393  }
394 
395  return *_point_locator;
396 }
void libMesh::MeshBase::prepare_for_use ( const bool  skip_renumber_nodes_and_elements = false)
inherited

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

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

Definition at line 120 of file mesh_base.C.

References libMesh::MeshBase::_is_prepared, libMesh::MeshBase::_skip_renumber_nodes_and_elements, libMesh::MeshBase::allow_renumbering(), libMesh::MeshBase::assign_unique_ids(), libMesh::MeshBase::clear_point_locator(), libMesh::ParallelObject::comm(), libMesh::MeshBase::delete_remote_elements(), libMesh::dim, libMesh::MeshBase::find_neighbors(), libMesh::MeshBase::is_serial(), libMesh::libmesh_assert(), libMesh::Parallel::Communicator::max(), libMesh::MeshBase::mesh_dimension(), libMesh::MeshBase::partition(), libMesh::MeshBase::renumber_nodes_and_elements(), libMesh::MeshBase::set_mesh_dimension(), libMesh::MeshBase::update_parallel_id_counts(), and libMesh::Parallel::verify().

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

121 {
122  parallel_object_only();
123 
124  // A distributed mesh may have processors with no elements (or
125  // processors with no elements of higher dimension, if we ever
126  // support mixed-dimension meshes), but we want consistent
127  // mesh_dimension anyways.
128  libmesh_assert(this->comm().verify(this->is_serial()));
129 
130  if (!this->is_serial())
131  {
132  unsigned int dim = this->mesh_dimension();
133  this->comm().max(dim);
134  this->set_mesh_dimension(dim);
135  }
136 
137  // Renumber the nodes and elements so that they in contiguous
138  // blocks. By default, _skip_renumber_nodes_and_elements is false.
139  //
140  // We may currently change that by passing
141  // skip_renumber_nodes_and_elements==true to this function, but we
142  // should use the allow_renumbering() accessor instead.
143  //
144  // Instances where you if prepare_for_use() should not renumber the nodes
145  // and elements include reading in e.g. an xda/r or gmv file. In
146  // this case, the ordering of the nodes may depend on an accompanying
147  // solution, and the node ordering cannot be changed.
148 
149  if (skip_renumber_nodes_and_elements)
150  {
151  libmesh_deprecated();
152  this->allow_renumbering(false);
153  }
154 
155  // Mesh modification operations might not leave us with consistent
156  // id counts, but our partitioner might need that consistency.
159  else
161 
162  // Let all the elements find their neighbors
163  this->find_neighbors();
164 
165  // Partition the mesh.
166  this->partition();
167 
168  // If we're using ParallelMesh, we'll want it parallelized.
169  this->delete_remote_elements();
170 
171 #ifdef LIBMESH_ENABLE_UNIQUE_ID
172  // Assign DOF object unique ids
173  this->assign_unique_ids();
174 #endif
175 
178 
179  // Reset our PointLocator. This needs to happen any time the elements
180  // in the underlying elements in the mesh have changed, so we do it here.
181  this->clear_point_locator();
182 
183  // The mesh is now prepared for use.
184  _is_prepared = true;
185 }
void libMesh::MeshBase::print_info ( std::ostream &  os = libMesh::out) const
inherited

Prints relevant information about the mesh.

Definition at line 329 of file mesh_base.C.

References libMesh::MeshBase::get_info().

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

330 {
331  os << this->get_info()
332  << std::endl;
333 }
processor_id_type libMesh::ParallelObject::processor_id ( ) const
inlineinherited
Returns
the rank of this processor in the group.

Definition at line 98 of file parallel_object.h.

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

Referenced by libMesh::MetisPartitioner::_do_partition(), libMesh::EquationSystems::_read_impl(), libMesh::SerialMesh::active_local_elements_begin(), libMesh::ParallelMesh::active_local_elements_begin(), libMesh::SerialMesh::active_local_elements_end(), libMesh::ParallelMesh::active_local_elements_end(), libMesh::SerialMesh::active_local_subdomain_elements_begin(), libMesh::ParallelMesh::active_local_subdomain_elements_begin(), libMesh::SerialMesh::active_local_subdomain_elements_end(), libMesh::ParallelMesh::active_local_subdomain_elements_end(), libMesh::SerialMesh::active_not_local_elements_begin(), libMesh::ParallelMesh::active_not_local_elements_begin(), libMesh::SerialMesh::active_not_local_elements_end(), libMesh::ParallelMesh::active_not_local_elements_end(), libMesh::ParallelMesh::add_elem(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::ParallelMesh::add_node(), libMesh::UnstructuredMesh::all_second_order(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::ParmetisPartitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::DofMap::build_sparsity(), libMesh::ParallelMesh::clear(), libMesh::ExodusII_IO_Helper::close(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::compute_communication_map_parameters(), libMesh::Nemesis_IO_Helper::compute_internal_and_border_elems_and_internal_nodes(), libMesh::Nemesis_IO_Helper::compute_node_communication_maps(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::ExodusII_IO_Helper::create(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DofMap::end_dof(), libMesh::DofMap::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMap::first_dof(), libMesh::DofMap::first_old_dof(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::MeshBase::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), libMesh::MeshFunction::gradient(), libMesh::MeshFunction::hessian(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_discontinuous(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::SparsityPattern::Build::join(), libMesh::DofMap::last_dof(), libMesh::MeshTools::libmesh_assert_valid_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_procids< Node >(), libMesh::SerialMesh::local_elements_begin(), libMesh::ParallelMesh::local_elements_begin(), libMesh::SerialMesh::local_elements_end(), libMesh::ParallelMesh::local_elements_end(), libMesh::SerialMesh::local_level_elements_begin(), libMesh::ParallelMesh::local_level_elements_begin(), libMesh::SerialMesh::local_level_elements_end(), libMesh::ParallelMesh::local_level_elements_end(), libMesh::SerialMesh::local_nodes_begin(), libMesh::ParallelMesh::local_nodes_begin(), libMesh::SerialMesh::local_nodes_end(), libMesh::ParallelMesh::local_nodes_end(), libMesh::SerialMesh::local_not_level_elements_begin(), libMesh::ParallelMesh::local_not_level_elements_begin(), libMesh::SerialMesh::local_not_level_elements_end(), libMesh::ParallelMesh::local_not_level_elements_end(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::DofMap::n_local_dofs(), libMesh::System::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::SerialMesh::not_local_elements_begin(), libMesh::ParallelMesh::not_local_elements_begin(), libMesh::SerialMesh::not_local_elements_end(), libMesh::ParallelMesh::not_local_elements_end(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::MeshFunction::operator()(), libMesh::ParallelMesh::ParallelMesh(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::System::project_vector(), libMesh::Nemesis_IO_Helper::put_cmap_params(), libMesh::Nemesis_IO_Helper::put_elem_cmap(), libMesh::Nemesis_IO_Helper::put_elem_map(), libMesh::Nemesis_IO_Helper::put_loadbal_param(), libMesh::Nemesis_IO_Helper::put_node_cmap(), libMesh::Nemesis_IO_Helper::put_node_map(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::UnstructuredMesh::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::System::read_serialized_data(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::MeshData::read_xdr(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::BoundaryInfo::sync(), libMesh::MeshTools::total_weight(), libMesh::ParallelMesh::update_parallel_id_counts(), libMesh::MeshTools::weight(), libMesh::ExodusII_IO::write(), libMesh::CheckpointIO::write(), libMesh::XdrIO::write(), libMesh::UnstructuredMesh::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO_Helper::write_elements_discontinuous(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), libMesh::System::write_header(), libMesh::ExodusII_IO::write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates_discontinuous(), libMesh::UCDIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::System::write_serialized_data(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), and libMesh::ExodusII_IO_Helper::write_timestep().

99  { return libmesh_cast_int<processor_id_type>(_communicator.rank()); }
const Elem * libMesh::ParallelMesh::query_elem ( const dof_id_type  i) const
virtualinherited

Return a pointer to the $ i^{th} $ element, or NULL if no such element exists in this processor's mesh data structure.

Implements libMesh::MeshBase.

Definition at line 327 of file parallel_mesh.C.

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

328 {
329  std::map<dof_id_type, Elem*>::const_iterator it = _elements.find(i);
330  if (it != _elements.end().it)
331  {
332  const Elem* e = it->second;
333  libmesh_assert (!e || e->id() == i);
334  return e;
335  }
336 
337  return NULL;
338 }
Elem * libMesh::ParallelMesh::query_elem ( const dof_id_type  i)
virtualinherited

Return a writeable pointer to the $ i^{th} $ element, or NULL if no such element exists in this processor's mesh data structure.

Implements libMesh::MeshBase.

Definition at line 343 of file parallel_mesh.C.

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

344 {
345  std::map<dof_id_type, Elem*>::const_iterator it = _elements.find(i);
346  if (it != _elements.end().it)
347  {
348  Elem* e = _elements[i];
349  libmesh_assert (!e || e->id() == i);
350  return e;
351  }
352 
353  return NULL;
354 }
const Node * libMesh::ParallelMesh::query_node_ptr ( const dof_id_type  i) const
virtualinherited

Return a pointer to the $ i^{th} $ node, or NULL if no such node exists in this processor's mesh data structure.

Implements libMesh::MeshBase.

Definition at line 273 of file parallel_mesh.C.

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

274 {
275  std::map<dof_id_type, Node*>::const_iterator it = _nodes.find(i);
276  if (it != _nodes.end().it)
277  {
278  const Node* n = it->second;
279  libmesh_assert (!n || n->id() == i);
280  return n;
281  }
282 
283  return NULL;
284 }
Node * libMesh::ParallelMesh::query_node_ptr ( const dof_id_type  i)
virtualinherited

Return a writeable pointer to the $ i^{th} $ node, or NULL if no such node exists in this processor's mesh data structure.

Implements libMesh::MeshBase.

Definition at line 289 of file parallel_mesh.C.

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

290 {
291  std::map<dof_id_type, Node*>::const_iterator it = _nodes.find(i);
292  if (it != _nodes.end().it)
293  {
294  Node* n = it->second;
295  libmesh_assert (!n || n->id() == i);
296  return n;
297  }
298 
299  return NULL;
300 }
void libMesh::UnstructuredMesh::read ( const std::string &  name,
MeshData mesh_data = NULL,
bool  skip_renumber_nodes_and_elements = false 
)
virtualinherited

Reads the file specified by name. Attempts to figure out the proper method by the file extension. This is now the only way to read a mesh. The UnstructuredMesh then initializes its data structures and is ready for use.

In order to read the UNV and TetGen file types, you must also pass a separate pointer to the MeshData object you will use with this mesh, since these read methods expect it.

The skip_renumber_nodes_and_elements argument is now deprecated - to disallow renumbering, set MeshBase::allow_renumbering(false)

Implements libMesh::MeshBase.

Definition at line 482 of file unstructured_mesh.C.

References libMesh::MeshBase::allow_renumbering(), libMesh::XdrIO::binary(), libMesh::MeshCommunication::broadcast(), libMesh::err, libMesh::XdrIO::legacy(), libMesh::ParallelObject::n_processors(), libMesh::Quality::name(), libMesh::MeshBase::prepare_for_use(), libMesh::ParallelObject::processor_id(), libMesh::AbaqusIO::read(), libMesh::OFFIO::read(), libMesh::UCDIO::read(), libMesh::TetGenIO::read(), libMesh::UNVIO::read(), libMesh::Nemesis_IO::read(), libMesh::ExodusII_IO::read(), libMesh::GmshIO::read(), libMesh::GMVIO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::VTKIO::read(), libMesh::MatlabIO::read(), libMesh::LegacyXdrIO::read_mgf(), libMesh::START_LOG(), and libMesh::STOP_LOG().

485 {
486  // See if the file exists. Perform this check on all processors
487  // so that the code is terminated properly in the case that the
488  // file does not exist.
489 
490  // For Nemesis files, the name we try to read will have suffixes
491  // identifying processor rank
492  if (name.rfind(".nem") + 4 == name.size() ||
493  name.rfind(".n") + 2 == name.size())
494  {
495  std::ostringstream full_name;
496 
497  // Find the length of a string which represents the highest processor ID
498  full_name << (this->n_processors());
499  unsigned field_width = full_name.str().size();
500 
501  // reset the string stream
502  full_name.str("");
503 
504  // And build up the full filename
505  full_name << name
506  << '.' << this->n_processors()
507  << '.' << std::setfill('0') << std::setw(field_width) << this->processor_id();
508 
509  std::ifstream in (full_name.str().c_str());
510 
511  if (!in.good())
512  {
513  libMesh::err << "ERROR: cannot locate specified file:\n\t"
514  << full_name.str()
515  << std::endl;
516  libmesh_error();
517  }
518  }
519  else if(name.rfind(".cp")) {} // Do error checking in the reader
520  else
521  {
522  std::ifstream in (name.c_str());
523 
524  if (!in.good())
525  {
526  libMesh::err << "ERROR: cannot locate specified file:\n\t"
527  << name
528  << std::endl;
529  libmesh_error();
530  }
531  }
532 
533  // Set the skip_renumber_nodes_and_elements flag on all processors.
534  // This ensures that renumber_nodes_and_elements is *not* called
535  // during prepare_for_use() for certain types of mesh files.
536  // This is required in cases where there is an associated solution
537  // file which expects a certain ordering of the nodes.
538  if(name.rfind(".gmv")+4==name.size())
539  {
540  skip_renumber_nodes_and_elements = true;
541  }
542 
543  // Look for parallel formats first
544  if (is_parallel_file_format(name))
545  {
546  // no need to handle bz2 files here -- the Xdr class does that.
547  if ((name.rfind(".xda") < name.size()) ||
548  (name.rfind(".xdr") < name.size()))
549  {
550  XdrIO xdr_io(*this);
551 
552  // .xda* ==> bzip2/gzip/ASCII flavors
553  if (name.rfind(".xda") < name.size())
554  {
555  xdr_io.binary() = false;
556  xdr_io.read (name);
557  }
558  else // .xdr* ==> true binary XDR file
559  {
560  xdr_io.binary() = true;
561  xdr_io.read (name);
562  }
563 
564  // The xdr_io object gets constructed with legacy() == false.
565  // if legacy() == true then it means that a legacy file was detected and
566  // thus processor 0 performed the read. We therefore need to broadcast the
567  // mesh. Further, for this flavor of mesh solution data ordering is tied
568  // to the node ordering, so we better not reorder the nodes!
569  if (xdr_io.legacy())
570  {
571  this->allow_renumbering(false);
572  MeshCommunication().broadcast(*this);
573  }
574 
575  // libHilbert-enabled libMesh builds should construct files
576  // with a canonical node ordering, which libHilbert-enabled
577  // builds will be able to read in again regardless of any
578  // renumbering. So in that case we're free to renumber.
579  // However, if either the writer or the reader of this file
580  // don't have libHilbert, then we'll have to skip
581  // renumbering because we need the numbering to remain
582  // consistent with any solution file we read in next.
583 #ifdef LIBMESH_HAVE_LIBHILBERT
584  // if (!xdr_io.libhilbert_ordering())
585  // skip_renumber_nodes_and_elements = true;
586 #else
587  this->allow_renumbering(false);
588 #endif
589  }
590  else if (name.rfind(".nem") < name.size() ||
591  name.rfind(".n") < name.size())
592  Nemesis_IO(*this).read (name);
593  else if (name.rfind(".cp") < name.size())
594  {
595  if(name.rfind(".cpa") < name.size())
596  CheckpointIO(*this, false).read(name);
597  else
598  CheckpointIO(*this, true).read(name);
599  }
600  }
601 
602  // Serial mesh formats
603  else
604  {
605  START_LOG("read()", "Mesh");
606 
607  // Read the file based on extension. Only processor 0
608  // needs to read the mesh. It will then broadcast it and
609  // the other processors will pick it up
610  if (this->processor_id() == 0)
611  {
612  std::ostringstream pid_suffix;
613  pid_suffix << '_' << getpid();
614  // Nasty hack for reading/writing zipped files
615  std::string new_name = name;
616  if (name.size() - name.rfind(".bz2") == 4)
617  {
618 #ifdef LIBMESH_HAVE_BZIP
619  new_name.erase(new_name.end() - 4, new_name.end());
620  new_name += pid_suffix.str();
621  std::string system_string = "bunzip2 -f -k -c ";
622  system_string += name + " > " + new_name;
623  START_LOG("system(bunzip2)", "Mesh");
624  if (std::system(system_string.c_str()))
625  libmesh_file_error(system_string);
626  STOP_LOG("system(bunzip2)", "Mesh");
627 #else
628  libMesh::err << "ERROR: need bzip2/bunzip2 to open .bz2 file "
629  << name << std::endl;
630  libmesh_error();
631 #endif
632  }
633  else if (name.size() - name.rfind(".xz") == 3)
634  {
635 #ifdef LIBMESH_HAVE_XZ
636  new_name.erase(new_name.end() - 3, new_name.end());
637  new_name += pid_suffix.str();
638  std::string system_string = "xz -f -d -k -c ";
639  system_string += name + " > " + new_name;
640  START_LOG("system(xz -d)", "XdrIO");
641  if (std::system(system_string.c_str()))
642  libmesh_file_error(system_string);
643  STOP_LOG("system(xz -d)", "XdrIO");
644 #else
645  libMesh::err << "ERROR: need xz to open .xz file "
646  << name << std::endl;
647  libmesh_error();
648 #endif
649  }
650 
651  if (new_name.rfind(".mat") < new_name.size())
652  MatlabIO(*this).read(new_name);
653 
654  else if (new_name.rfind(".ucd") < new_name.size())
655  UCDIO(*this).read (new_name);
656 
657  else if ((new_name.rfind(".off") < new_name.size()) ||
658  (new_name.rfind(".ogl") < new_name.size()) ||
659  (new_name.rfind(".oogl") < new_name.size()))
660  OFFIO(*this).read (new_name);
661 
662  else if (new_name.rfind(".mgf") < new_name.size())
663  LegacyXdrIO(*this,true).read_mgf (new_name);
664 
665  else if (new_name.rfind(".unv") < new_name.size())
666  {
667  if (mesh_data == NULL)
668  {
669  libMesh::err << "Error! You must pass a "
670  << "valid MeshData pointer to "
671  << "read UNV files!" << std::endl;
672  libmesh_error();
673  }
674  UNVIO(*this, *mesh_data).read (new_name);
675  }
676 
677  else if ((new_name.rfind(".node") < new_name.size()) ||
678  (new_name.rfind(".ele") < new_name.size()))
679  TetGenIO(*this,mesh_data).read (new_name);
680 
681  else if (new_name.rfind(".exd") < new_name.size() ||
682  new_name.rfind(".e") < new_name.size())
683  ExodusII_IO(*this).read (new_name);
684 
685  else if (new_name.rfind(".msh") < new_name.size())
686  GmshIO(*this).read (new_name);
687 
688  else if (new_name.rfind(".gmv") < new_name.size())
689  GMVIO(*this).read (new_name);
690 
691  else if (new_name.rfind(".vtu") < new_name.size())
692  VTKIO(*this).read(new_name);
693 
694  else if (new_name.rfind(".inp") < new_name.size())
695  AbaqusIO(*this).read(new_name);
696 
697  else
698  {
699  libMesh::err << " ERROR: Unrecognized file extension: " << name
700  << "\n I understand the following:\n\n"
701  << " *.e -- Sandia's ExodusII format\n"
702  << " *.exd -- Sandia's ExodusII format\n"
703  << " *.gmv -- LANL's General Mesh Viewer format\n"
704  << " *.mat -- Matlab triangular ASCII file\n"
705  << " *.n -- Sandia's Nemesis format\n"
706  << " *.nem -- Sandia's Nemesis format\n"
707  << " *.off -- OOGL OFF surface format\n"
708  << " *.ucd -- AVS's ASCII UCD format\n"
709  << " *.unv -- I-deas Universal format\n"
710  << " *.vtu -- Paraview VTK format\n"
711  << " *.inp -- Abaqus .inp format\n"
712  << " *.xda -- libMesh ASCII format\n"
713  << " *.xdr -- libMesh binary format\n"
714  << " *.gz -- any above format gzipped\n"
715  << " *.bz2 -- any above format bzip2'ed\n"
716  << " *.xz -- any above format xzipped\n"
717  << " *.cpa -- libMesh Checkpoint ASCII format\n"
718  << " *.cpr -- libMesh Checkpoint binary format\n"
719 
720  << std::endl;
721  libmesh_error();
722  }
723 
724  // If we temporarily decompressed a file, remove the
725  // uncompressed version
726  if (name.size() - name.rfind(".bz2") == 4)
727  std::remove(new_name.c_str());
728  if (name.size() - name.rfind(".xz") == 3)
729  std::remove(new_name.c_str());
730  }
731 
732 
733  STOP_LOG("read()", "Mesh");
734 
735  // Send the mesh & bcs (which are now only on processor 0) to the other
736  // processors
737  MeshCommunication().broadcast (*this);
738  }
739 
740  if (skip_renumber_nodes_and_elements)
741  {
742  // Use MeshBase::allow_renumbering() yourself instead.
743  libmesh_deprecated();
744  this->allow_renumbering(false);
745  }
746 
747  // Done reading the mesh. Now prepare it for use.
748  this->prepare_for_use();
749 }
unsigned int libMesh::MeshBase::recalculate_n_partitions ( )
inherited

In a few (very rare) cases, the user may have manually tagged the elements with specific processor IDs by hand, without using a partitioner. In this case, the Mesh will not know that the total number of partitions, _n_parts, has changed, unless you call this function. This is an O(N active elements) calculation. The return value is the number of partitions, and _n_parts is also set by this function.

Definition at line 363 of file mesh_base.C.

References libMesh::MeshBase::_n_parts, libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), libMesh::ParallelObject::comm(), end, std::max(), and libMesh::Parallel::Communicator::max().

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

364 {
365  const_element_iterator el = this->active_elements_begin();
366  const const_element_iterator end = this->active_elements_end();
367 
368  unsigned int max_proc_id=0;
369 
370  for (; el!=end; ++el)
371  max_proc_id = std::max(max_proc_id, static_cast<unsigned int>((*el)->processor_id()));
372 
373  // The number of partitions is one more than the max processor ID.
374  _n_parts = max_proc_id+1;
375 
376  this->comm().max(_n_parts);
377 
378  return _n_parts;
379 }
void libMesh::ParallelMesh::redistribute ( )
virtualinherited

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

Reimplemented from libMesh::MeshBase.

Definition at line 710 of file parallel_mesh.C.

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

711 {
712  // If this is a truly parallel mesh, go through the redistribution/gather/delete remote steps
713  if (!this->is_serial())
714  {
715  // Construct a MeshCommunication object to actually redistribute the nodes
716  // and elements according to the partitioner, and then to re-gather the neighbors.
717  MeshCommunication mc;
718  mc.redistribute(*this);
719 
721 
722  // Is this necessary? If we are called from prepare_for_use(), this will be called
723  // anyway... but users can always call partition directly, in which case we do need
724  // to call delete_remote_elements()...
725  //
726  // Regardless of whether it's necessary, it isn't safe. We
727  // haven't communicated new node processor_ids yet, and we can't
728  // delete nodes until we do.
729  // this->delete_remote_elements();
730  }
731 }
template<typename T >
dof_id_type libMesh::ParallelMesh::renumber_dof_objects ( mapvector< T *, dof_id_type > &  objects)
inherited

Renumber a parallel objects container Returns the smallest globally unused id for that container.

Definition at line 843 of file parallel_mesh.C.

References libMesh::mapvector< Val, index_t >::begin(), libMesh::comm, libMesh::mapvector< Val, index_t >::end(), end, libMesh::mapvector< Val, index_t >::erase(), libMesh::DofObject::invalid_processor_id, libMesh::DofObject::invalid_unique_id, libMesh::libmesh_assert(), libMesh::n_processors(), libMesh::processor_id(), and libMesh::Parallel::verify().

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

844 {
845  // This function must be run on all processors at once
846  parallel_object_only();
847 
848  typedef typename mapvector<T*,dof_id_type>::veclike_iterator object_iterator;
849 
850  // In parallel we may not know what objects other processors have.
851  // Start by figuring out how many
852  dof_id_type unpartitioned_objects = 0;
853 
854  std::vector<dof_id_type>
855  ghost_objects_from_proc(this->n_processors(), 0);
856 
857  object_iterator it = objects.begin();
858  object_iterator end = objects.end();
859 
860  for (; it != end;)
861  {
862  T *obj = *it;
863 
864  // Remove any NULL container entries while we're here,
865  // being careful not to invalidate our iterator
866  if (!*it)
867  objects.erase(it++);
868  else
869  {
870  processor_id_type obj_procid = obj->processor_id();
871  if (obj_procid == DofObject::invalid_processor_id)
872  unpartitioned_objects++;
873  else
874  ghost_objects_from_proc[obj_procid]++;
875  ++it;
876  }
877  }
878 
879  std::vector<dof_id_type> objects_on_proc(this->n_processors(), 0);
880  this->comm().allgather(ghost_objects_from_proc[this->processor_id()],
881  objects_on_proc);
882 
883 #ifndef NDEBUG
884  libmesh_assert(this->comm().verify(unpartitioned_objects));
885  for (processor_id_type p=0; p != this->n_processors(); ++p)
886  libmesh_assert_less_equal (ghost_objects_from_proc[p], objects_on_proc[p]);
887 #endif
888 
889  // We'll renumber objects in blocks by processor id
890  std::vector<dof_id_type> first_object_on_proc(this->n_processors());
891  for (processor_id_type i=1; i != this->n_processors(); ++i)
892  first_object_on_proc[i] = first_object_on_proc[i-1] +
893  objects_on_proc[i-1];
894  dof_id_type next_id = first_object_on_proc[this->processor_id()];
895  dof_id_type first_free_id =
896  first_object_on_proc[this->n_processors()-1] +
897  objects_on_proc[this->n_processors()-1] +
898  unpartitioned_objects;
899 
900  // First set new local object ids and build request sets
901  // for non-local object ids
902 
903  // Request sets to send to each processor
904  std::vector<std::vector<dof_id_type> >
905  requested_ids(this->n_processors());
906 
907 #ifdef LIBMESH_ENABLE_UNIQUE_ID
908  std::vector<std::vector<unique_id_type> >
909  requested_unique_ids(this->n_processors());
910 #endif
911 
912  // We know how many objects live on each processor, so reseve() space for
913  // each.
914  for (processor_id_type p=0; p != this->n_processors(); ++p)
915  if (p != this->processor_id())
916  {
917  requested_ids[p].reserve(ghost_objects_from_proc[p]);
918 #ifdef LIBMESH_ENABLE_UNIQUE_ID
919  requested_unique_ids[p].reserve(ghost_objects_from_proc[p]);
920 #endif
921  }
922 
923  end = objects.end();
924  for (it = objects.begin(); it != end; ++it)
925  {
926  T *obj = *it;
927  if (obj->processor_id() == this->processor_id())
928  obj->set_id(next_id++);
929  else if (obj->processor_id() != DofObject::invalid_processor_id)
930  {
931  requested_ids[obj->processor_id()].push_back(obj->id());
932 #ifdef LIBMESH_ENABLE_UNIQUE_ID
933  // It's possible to have an invalid id for dofs not owned by this process.
934  // We'll assert that they match on the receiving end.
935  requested_unique_ids[obj->processor_id()].push_back(obj->valid_unique_id() ? obj-> unique_id() : DofObject::invalid_unique_id);
936 #endif
937  }
938  }
939 
940  // Next set ghost object ids from other processors
941  if (this->n_processors() > 1)
942  {
943  for (processor_id_type p=1; p != this->n_processors(); ++p)
944  {
945  // Trade my requests with processor procup and procdown
946  processor_id_type procup = (this->processor_id() + p) %
947  this->n_processors();
948  processor_id_type procdown = (this->n_processors() +
949  this->processor_id() - p) %
950  this->n_processors();
951  std::vector<dof_id_type> request_to_fill;
952  this->comm().send_receive(procup, requested_ids[procup],
953  procdown, request_to_fill);
954 
955 #ifdef LIBMESH_ENABLE_UNIQUE_ID
956  std::vector<unique_id_type> unique_request_to_fill;
957  this->comm().send_receive(procup, requested_unique_ids[procup],
958  procdown, unique_request_to_fill);
959  std::vector<unique_id_type> new_unique_ids(unique_request_to_fill.size());
960 #endif
961 
962  // Fill those requests
963  std::vector<dof_id_type> new_ids(request_to_fill.size());
964  for (std::size_t i=0; i != request_to_fill.size(); ++i)
965  {
966  T *obj = objects[request_to_fill[i]];
967  libmesh_assert(obj);
968  libmesh_assert_equal_to (obj->processor_id(), this->processor_id());
969  new_ids[i] = obj->id();
970 #ifdef LIBMESH_ENABLE_UNIQUE_ID
971  new_unique_ids[i] = obj->valid_unique_id() ? obj->unique_id() : DofObject::invalid_unique_id;
972 #endif
973 
974  libmesh_assert_greater_equal (new_ids[i],
975  first_object_on_proc[this->processor_id()]);
976  libmesh_assert_less (new_ids[i],
977  first_object_on_proc[this->processor_id()] +
978  objects_on_proc[this->processor_id()]);
979  }
980 
981  // Trade back the results
982  std::vector<dof_id_type> filled_request;
983  this->comm().send_receive(procdown, new_ids,
984  procup, filled_request);
985 
986 #ifdef LIBMESH_ENABLE_UNIQUE_ID
987  std::vector<unique_id_type> unique_filled_request;
988  this->comm().send_receive(procdown, new_unique_ids,
989  procup, unique_filled_request);
990 #endif
991 
992  // And copy the id changes we've now been informed of
993  for (std::size_t i=0; i != filled_request.size(); ++i)
994  {
995  T *obj = objects[requested_ids[procup][i]];
996  libmesh_assert (obj);
997  libmesh_assert_equal_to (obj->processor_id(), procup);
998  libmesh_assert_greater_equal (filled_request[i],
999  first_object_on_proc[procup]);
1000  libmesh_assert_less (filled_request[i],
1001  first_object_on_proc[procup] +
1002  objects_on_proc[procup]);
1003  obj->set_id(filled_request[i]);
1004 
1005 #ifdef LIBMESH_ENABLE_UNIQUE_ID
1006  if (!obj->valid_unique_id() && unique_filled_request[i] != DofObject::invalid_unique_id)
1007  obj->set_unique_id() = unique_filled_request[i];
1008 #endif
1009  }
1010  }
1011  }
1012 
1013  // Next set unpartitioned object ids
1014  next_id = 0;
1015  for (processor_id_type i=0; i != this->n_processors(); ++i)
1016  next_id += objects_on_proc[i];
1017  for (it = objects.begin(); it != end; ++it)
1018  {
1019  T *obj = *it;
1020  if (obj->processor_id() == DofObject::invalid_processor_id)
1021  obj->set_id(next_id++);
1022  }
1023 
1024  // Finally shuffle around objects so that container indices
1025  // match ids
1026  end = objects.end();
1027  for (it = objects.begin(); it != end;)
1028  {
1029  T *obj = *it;
1030  if (obj) // don't try shuffling already-NULL entries
1031  {
1032  T *next = objects[obj->id()];
1033  // If we have to move this object
1034  if (next != obj)
1035  {
1036  // NULL out its original position for now
1037  // (our shuffling may put another object there shortly)
1038  *it = NULL;
1039 
1040  // There may already be another object with this id that
1041  // needs to be moved itself
1042  while (next)
1043  {
1044  // We shouldn't be trying to give two objects the
1045  // same id
1046  libmesh_assert_not_equal_to (next->id(), obj->id());
1047  objects[obj->id()] = obj;
1048  obj = next;
1049  next = objects[obj->id()];
1050  }
1051  objects[obj->id()] = obj;
1052  }
1053  }
1054  // Remove any container entries that were left as NULL,
1055  // being careful not to invalidate our iterator
1056  if (!*it)
1057  objects.erase(it++);
1058  else
1059  ++it;
1060  }
1061 
1062  return first_free_id;
1063 }
void libMesh::ParallelMesh::renumber_elem ( dof_id_type  old_id,
dof_id_type  new_id 
)
virtualinherited

Changes the id of element old_id, both by changing elem(old_id)->id() and by moving elem(old_id) in the mesh's internal container. No element with the id new_id should already exist.

Implements libMesh::MeshBase.

Definition at line 484 of file parallel_mesh.C.

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

486 {
487  Elem *el = _elements[old_id];
488  libmesh_assert (el);
489  libmesh_assert_equal_to (el->id(), old_id);
490 
491  el->set_id(new_id);
492  libmesh_assert (!_elements[new_id]);
493  _elements[new_id] = el;
494  _elements.erase(old_id);
495 }
void libMesh::ParallelMesh::renumber_node ( dof_id_type  old_id,
dof_id_type  new_id 
)
virtualinherited

Changes the id of node old_id, both by changing node(old_id)->id() and by moving node(old_id) in the mesh's internal container. No element with the id new_id should already exist.

Implements libMesh::MeshBase.

Definition at line 645 of file parallel_mesh.C.

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

647 {
648  Node *nd = _nodes[old_id];
649  libmesh_assert (nd);
650  libmesh_assert_equal_to (nd->id(), old_id);
651 
652  nd->set_id(new_id);
653  libmesh_assert (!_nodes[new_id]);
654  _nodes[new_id] = nd;
655  _nodes.erase(old_id);
656 }
void libMesh::ParallelMesh::renumber_nodes_and_elements ( )
virtualinherited

Remove NULL elements from arrays

Implements libMesh::MeshBase.

Definition at line 1066 of file parallel_mesh.C.

References libMesh::ParallelMesh::_elements, libMesh::ParallelMesh::_n_elem, libMesh::ParallelMesh::_n_nodes, libMesh::ParallelMesh::_nodes, libMesh::MeshBase::_skip_renumber_nodes_and_elements, libMesh::MeshBase::boundary_info, libMesh::ParallelMesh::elements_begin(), libMesh::ParallelMesh::elements_end(), end, libMesh::DofObject::id(), libMesh::MeshTools::libmesh_assert_valid_elem_ids(), libMesh::ParallelMesh::libmesh_assert_valid_parallel_flags(), libMesh::ParallelMesh::libmesh_assert_valid_parallel_ids(), libMesh::ParallelMesh::max_elem_id(), libMesh::ParallelMesh::max_node_id(), libMesh::ParallelMesh::n_elem(), libMesh::ParallelMesh::n_nodes(), libMesh::Elem::n_nodes(), libMesh::Elem::node(), libMesh::ParallelMesh::parallel_max_elem_id(), libMesh::ParallelMesh::parallel_max_node_id(), libMesh::ParallelMesh::parallel_n_elem(), libMesh::ParallelMesh::parallel_n_nodes(), libMesh::ParallelMesh::renumber_dof_objects(), libMesh::START_LOG(), libMesh::STOP_LOG(), and libMesh::ParallelMesh::update_parallel_id_counts().

1067 {
1068  parallel_object_only();
1069 
1071  {
1072  this->update_parallel_id_counts();
1073  return;
1074  }
1075 
1076  START_LOG("renumber_nodes_and_elements()", "ParallelMesh");
1077 
1078 #ifdef DEBUG
1079 // Make sure our ids and flags are consistent
1082 #endif
1083 
1084  std::set<dof_id_type> used_nodes;
1085 
1086  // flag the nodes we need
1087  {
1088  element_iterator it = elements_begin();
1089  element_iterator end = elements_end();
1090 
1091  for (; it != end; ++it)
1092  {
1093  Elem *el = *it;
1094 
1095  for (unsigned int n=0; n != el->n_nodes(); ++n)
1096  used_nodes.insert(el->node(n));
1097  }
1098  }
1099 
1100  // Nodes not connected to any local elements, and NULL node entries
1101  // in our container, are deleted
1102  {
1103  node_iterator_imp it = _nodes.begin();
1104  node_iterator_imp end = _nodes.end();
1105 
1106  for (; it != end;)
1107  {
1108  Node *nd = *it;
1109  if (!nd)
1110  _nodes.erase(it++);
1111  else if (!used_nodes.count(nd->id()))
1112  {
1113  // remove any boundary information associated with
1114  // this node
1115  this->boundary_info->remove (nd);
1116 
1117  // delete the node
1118  delete nd;
1119 
1120  _nodes.erase(it++);
1121  }
1122  else
1123  ++it;
1124  }
1125  }
1126 
1127  // Finally renumber all the elements
1128  _n_elem = this->renumber_dof_objects (this->_elements);
1129 
1130  // and all the remaining nodes
1131  _n_nodes = this->renumber_dof_objects (this->_nodes);
1132 
1133  // And figure out what IDs we should use when adding new nodes and
1134  // new elements
1135  this->update_parallel_id_counts();
1136 
1137 // Make sure our caches are up to date and our
1138 // DofObjects are well packed
1139 #ifdef DEBUG
1140  libmesh_assert_equal_to (this->n_nodes(), this->parallel_n_nodes());
1141  libmesh_assert_equal_to (this->n_elem(), this->parallel_n_elem());
1142  const dof_id_type pmax_node_id = this->parallel_max_node_id();
1143  const dof_id_type pmax_elem_id = this->parallel_max_elem_id();
1144  libmesh_assert_equal_to (this->max_node_id(), pmax_node_id);
1145  libmesh_assert_equal_to (this->max_elem_id(), pmax_elem_id);
1146  libmesh_assert_equal_to (this->n_nodes(), this->max_node_id());
1147  libmesh_assert_equal_to (this->n_elem(), this->max_elem_id());
1148 
1149  // Make sure our ids and flags are consistent
1152 
1153 // And make sure we've made our numbering monotonic
1155 #endif
1156 
1157  STOP_LOG("renumber_nodes_and_elements()", "ParallelMesh");
1158 }
virtual void libMesh::ParallelMesh::reserve_elem ( const dof_id_type  ne)
inlinevirtualinherited

Reserves space for a known number of elements. Note that this method may or may not do anything, depending on the actual Mesh implementation. If you know the number of elements you will add and call this method before repeatedly calling add_point() the implementation will be more efficient.

Implements libMesh::MeshBase.

Definition at line 188 of file parallel_mesh.h.

188 { }
virtual void libMesh::ParallelMesh::reserve_nodes ( const dof_id_type  nn)
inlinevirtualinherited

Reserves space for a known number of nodes. Note that this method may or may not do anything, depending on the actual Mesh implementation. If you know the number of nodes you will add and call this method before repeatedly calling add_point() the implementation will be more efficient.

Implements libMesh::MeshBase.

Definition at line 184 of file parallel_mesh.h.

184 { }
unsigned int& libMesh::MeshBase::set_n_partitions ( )
inlineprotectedinherited

Returns a writeable reference to the number of partitions.

Definition at line 859 of file mesh_base.h.

References libMesh::MeshBase::_n_parts.

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

860  { return _n_parts; }
void libMesh::MeshBase::set_next_unique_id ( unique_id_type  id)
inlineinherited

Sets the next unique id to be used.

Definition at line 221 of file mesh_base.h.

References libMesh::MeshBase::_next_unique_id.

221 { _next_unique_id = id; }
std::map<subdomain_id_type, std::string>& libMesh::MeshBase::set_subdomain_name_map ( )
inlineinherited

Return a writeable reference to the whole subdomain name map

Definition at line 841 of file mesh_base.h.

References libMesh::MeshBase::_block_id_to_name.

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

842  { return _block_id_to_name; }
void libMesh::MeshBase::skip_partitioning ( bool  skip)
inlineinherited

If true is passed in then this mesh will no longer be (re)partitioned. It would probably be a bad idea to call this on a Serial Mesh before the first partitioning has happened... because no elements would get assigned to your processor pool.

Note that turning on skip_partitioning() can have adverse effects on your performance when using AMR... ie you could get large load imbalances.

However you might still want to use this if the communication and computation of the rebalance and repartition is too high for your application.

Definition at line 551 of file mesh_base.h.

References libMesh::MeshBase::_skip_partitioning.

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

551 { _skip_partitioning = skip; }
bool libMesh::MeshBase::skip_partitioning ( ) const
inlineinherited

Definition at line 552 of file mesh_base.h.

References libMesh::MeshBase::_skip_partitioning.

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

552 { return _skip_partitioning; }
unsigned int libMesh::MeshBase::spatial_dimension ( ) const
inlineinherited
AutoPtr< PointLocatorBase > libMesh::MeshBase::sub_point_locator ( ) const
inherited

returns a pointer to a subordinate PointLocatorBase object for this mesh, constructing a master PointLocator first if necessary. This should not be used in threaded or non-parallel_only code unless the master has already been constructed.

Definition at line 399 of file mesh_base.C.

References libMesh::MeshBase::_point_locator, libMesh::PointLocatorBase::build(), libMesh::Threads::in_threads, libMesh::libmesh_assert(), and libMeshEnums::TREE.

Referenced by libMesh::DofMap::create_dof_constraints(), libMesh::MeshFunction::init(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshRefinement::make_refinement_compatible(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), and libMesh::MeshRefinement::test_level_one().

400 {
401  if (_point_locator.get() == NULL)
402  {
403  // PointLocator construction may not be safe within threads
405 
406  _point_locator.reset (PointLocatorBase::build(TREE, *this).release());
407  }
408 
409  return PointLocatorBase::build(TREE, *this, _point_locator.get());
410 }
ParallelMesh::element_iterator libMesh::ParallelMesh::subactive_elements_begin ( )
virtualinherited

Implements libMesh::MeshBase.

Definition at line 87 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

88 {
89  Predicates::SubActive<elem_iterator_imp> p;
90  return element_iterator(_elements.begin(), _elements.end(), p);
91 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::subactive_elements_begin ( ) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 311 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

312 {
313  Predicates::SubActive<const_elem_iterator_imp> p;
314  return const_element_iterator(_elements.begin(), _elements.end(), p);
315 }
ParallelMesh::element_iterator libMesh::ParallelMesh::subactive_elements_end ( )
virtualinherited

Implements libMesh::MeshBase.

Definition at line 534 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

535 {
536  Predicates::SubActive<elem_iterator_imp> p;
537  return element_iterator(_elements.end(), _elements.end(), p);
538 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::subactive_elements_end ( ) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 759 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

760 {
761  Predicates::SubActive<const_elem_iterator_imp> p;
762  return const_element_iterator(_elements.end(), _elements.end(), p);
763 }
void libMesh::MeshBase::subdomain_ids ( std::set< subdomain_id_type > &  ids) const
inherited

Constructs a list of all subdomain identifiers 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 206 of file mesh_base.C.

References libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), libMesh::ParallelObject::comm(), end, and libMesh::Parallel::Communicator::set_union().

Referenced by libMesh::MeshBase::n_subdomains(), and libMesh::TecplotIO::TecplotIO().

207 {
208  // This requires an inspection on every processor
209  parallel_object_only();
210 
211  ids.clear();
212 
213  const_element_iterator el = this->active_elements_begin();
214  const const_element_iterator end = this->active_elements_end();
215 
216  for (; el!=end; ++el)
217  ids.insert((*el)->subdomain_id());
218 
219  // Some subdomains may only live on other processors
220  this->comm().set_union(ids);
221 }
std::string & libMesh::MeshBase::subdomain_name ( subdomain_id_type  id)
inherited

Returns a writable reference for getting/setting an optional name for a subdomain.

Definition at line 421 of file mesh_base.C.

References libMesh::MeshBase::_block_id_to_name.

Referenced by DMLibMeshSetSystem(), libMesh::ExodusII_IO::read(), libMesh::TecplotIO::write_binary(), and libMesh::ExodusII_IO_Helper::write_elements().

422 {
423  return _block_id_to_name[id];
424 }
const std::string & libMesh::MeshBase::subdomain_name ( subdomain_id_type  id) const
inherited

Definition at line 426 of file mesh_base.C.

References libMesh::MeshBase::_block_id_to_name.

427 {
428  // An empty string to return when no matching subdomain name is found
429  static const std::string empty;
430 
431  std::map<subdomain_id_type, std::string>::const_iterator iter = _block_id_to_name.find(id);
432  if (iter == _block_id_to_name.end())
433  return empty;
434  else
435  return iter->second;
436 }
ParallelMesh::element_iterator libMesh::ParallelMesh::type_elements_begin ( const ElemType  type)
virtualinherited

Implements libMesh::MeshBase.

Definition at line 197 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

198 {
199  Predicates::Type<elem_iterator_imp> p(type);
200  return element_iterator(_elements.begin(), _elements.end(), p);
201 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::type_elements_begin ( const ElemType  type) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 421 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

422 {
423  Predicates::Type<const_elem_iterator_imp> p(type);
424  return const_element_iterator(_elements.begin(), _elements.end(), p);
425 }
ParallelMesh::element_iterator libMesh::ParallelMesh::type_elements_end ( const ElemType  type)
virtualinherited

Implements libMesh::MeshBase.

Definition at line 644 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

645 {
646  Predicates::Type<elem_iterator_imp> p(type);
647  return element_iterator(_elements.end(), _elements.end(), p);
648 }
ParallelMesh::const_element_iterator libMesh::ParallelMesh::type_elements_end ( const ElemType  type) const
virtualinherited

Implements libMesh::MeshBase.

Definition at line 868 of file parallel_mesh_iterators.C.

References libMesh::ParallelMesh::_elements.

869 {
870  Predicates::Type<const_elem_iterator_imp> p(type);
871  return const_element_iterator(_elements.end(), _elements.end(), p);
872 }
ParallelMesh::element_iterator libMesh::ParallelMesh::unpartitioned_elements_begin ( )
virtualinherited
ParallelMesh::const_element_iterator libMesh::ParallelMesh::unpartitioned_elements_begin ( ) const
virtualinherited
ParallelMesh::element_iterator libMesh::ParallelMesh::unpartitioned_elements_end ( )
virtualinherited
ParallelMesh::const_element_iterator libMesh::ParallelMesh::unpartitioned_elements_end ( ) const
virtualinherited
void libMesh::ParallelMesh::update_parallel_id_counts ( )
virtualinherited

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

Implements libMesh::MeshBase.

Definition at line 133 of file parallel_mesh.C.

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

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

134 {
135  // This function must be run on all processors at once
136  parallel_object_only();
137 
138  _n_elem = this->parallel_n_elem();
139  _n_nodes = this->parallel_n_nodes();
142 
145  ((_max_elem_id-1) / (this->n_processors() + 1) + 1) *
146  (this->n_processors() + 1) + this->n_processors();
149  ((_max_elem_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
150  (this->n_processors() + 1) + this->processor_id();
151 
154  ((_max_node_id-1) / (this->n_processors() + 1) + 1) *
155  (this->n_processors() + 1) + this->n_processors();
158  ((_max_node_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
159  (this->n_processors() + 1) + this->processor_id();
160 }
void libMesh::ParallelMesh::update_post_partitioning ( )
virtualinherited

Recalculate cached data after elements and nodes have been repartitioned.

Reimplemented from libMesh::MeshBase.

Definition at line 735 of file parallel_mesh.C.

References libMesh::ParallelMesh::update_parallel_id_counts().

736 {
737  // this->recalculate_n_partitions();
738 
739  // Partitioning changes our numbers of unpartitioned objects
741 }
void libMesh::UnstructuredMesh::write ( const std::string &  name,
MeshData mesh_data = NULL 
)
virtualinherited

Write the file specified by name. Attempts to figure out the proper method by the file extension.

In order to write the UNV and TetGen file types, you must also pass a separate pointer to the MeshData object you have been using with this mesh, since these write methods expect it.

Implements libMesh::MeshBase.

Definition at line 753 of file unstructured_mesh.C.

References libMesh::Parallel::Communicator::barrier(), libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::err, libMesh::MeshBase::n_partitions(), libMesh::Quality::name(), libMesh::GMVIO::partitioning(), libMesh::ParallelObject::processor_id(), libMesh::START_LOG(), libMesh::STOP_LOG(), libMesh::FroIO::write(), libMesh::DivaIO::write(), libMesh::TecplotIO::write(), libMesh::MEDITIO::write(), libMesh::GMVIO::write(), libMesh::UCDIO::write(), libMesh::TetGenIO::write(), libMesh::UNVIO::write(), libMesh::Nemesis_IO::write(), libMesh::ExodusII_IO::write(), libMesh::GmshIO::write(), libMesh::XdrIO::write(), libMesh::VTKIO::write(), and libMesh::LegacyXdrIO::write_mgf().

755 {
756  // parallel formats are special -- they may choose to write
757  // separate files, let's not try to handle the zipping here.
758  if (is_parallel_file_format(name))
759  {
760  // no need to handle bz2 files here -- the Xdr class does that.
761  if (name.rfind(".xda") < name.size())
762  XdrIO(*this).write(name);
763 
764  else if (name.rfind(".xdr") < name.size())
765  XdrIO(*this,true).write(name);
766 
767  else if (name.rfind(".nem") < name.size() ||
768  name.rfind(".n") < name.size())
769  Nemesis_IO(*this).write(name);
770  }
771 
772  // serial file formats
773  else
774  {
775  START_LOG("write()", "Mesh");
776 
777  // Nasty hack for reading/writing zipped files
778  std::string new_name = name;
779  processor_id_type pid_0 = 0;
780  if (this->processor_id() == 0)
781  pid_0 = getpid();
782  this->comm().broadcast(pid_0);
783  std::ostringstream pid_suffix;
784  pid_suffix << '_' << pid_0;
785 
786  if (name.size() - name.rfind(".bz2") == 4)
787  {
788  new_name.erase(new_name.end() - 4, new_name.end());
789  new_name += pid_suffix.str();
790  }
791  else if (name.size() - name.rfind(".xz") == 3)
792  {
793  new_name.erase(new_name.end() - 3, new_name.end());
794  new_name += pid_suffix.str();
795  }
796 
797  // New scope so that io will close before we try to zip the file
798  {
799  // Write the file based on extension
800  if (new_name.rfind(".dat") < new_name.size())
801  TecplotIO(*this).write (new_name);
802 
803  else if (new_name.rfind(".plt") < new_name.size())
804  TecplotIO(*this,true).write (new_name);
805 
806  else if (new_name.rfind(".ucd") < new_name.size())
807  UCDIO (*this).write (new_name);
808 
809  else if (new_name.rfind(".gmv") < new_name.size())
810  if (this->n_partitions() > 1)
811  GMVIO(*this).write (new_name);
812  else
813  {
814  GMVIO io(*this);
815  io.partitioning() = false;
816  io.write (new_name);
817  }
818 
819  else if (new_name.rfind(".ugrid") < new_name.size())
820  DivaIO(*this).write(new_name);
821  else if (new_name.rfind(".exd") < new_name.size() ||
822  new_name.rfind(".e") < new_name.size())
823  ExodusII_IO(*this).write(new_name);
824  else if (new_name.rfind(".mgf") < new_name.size())
825  LegacyXdrIO(*this,true).write_mgf(new_name);
826 
827  else if (new_name.rfind(".unv") < new_name.size())
828  {
829  if (mesh_data == NULL)
830  {
831  libMesh::err << "Error! You must pass a "
832  << "valid MeshData pointer to "
833  << "write UNV files!" << std::endl;
834  libmesh_error();
835  }
836  UNVIO(*this, *mesh_data).write (new_name);
837  }
838 
839  else if (new_name.rfind(".mesh") < new_name.size())
840  MEDITIO(*this).write (new_name);
841 
842  else if (new_name.rfind(".poly") < new_name.size())
843  TetGenIO(*this).write (new_name);
844 
845  else if (new_name.rfind(".msh") < new_name.size())
846  GmshIO(*this).write (new_name);
847 
848  else if (new_name.rfind(".fro") < new_name.size())
849  FroIO(*this).write (new_name);
850 
851  else if (new_name.rfind(".vtu") < new_name.size())
852  VTKIO(*this).write (new_name);
853 
854  else
855  {
857  << " ERROR: Unrecognized file extension: " << name
858  << "\n I understand the following:\n\n"
859  << " *.dat -- Tecplot ASCII file\n"
860  << " *.e -- Sandia's ExodusII format\n"
861  << " *.exd -- Sandia's ExodusII format\n"
862  << " *.fro -- ACDL's surface triangulation file\n"
863  << " *.gmv -- LANL's GMV (General Mesh Viewer) format\n"
864  << " *.mesh -- MEdit mesh format\n"
865  << " *.mgf -- MGF binary mesh format\n"
866  << " *.msh -- GMSH ASCII file\n"
867  << " *.n -- Sandia's Nemesis format\n"
868  << " *.nem -- Sandia's Nemesis format\n"
869  << " *.plt -- Tecplot binary file\n"
870  << " *.poly -- TetGen ASCII file\n"
871  << " *.ucd -- AVS's ASCII UCD format\n"
872  << " *.ugrid -- Kelly's DIVA ASCII format\n"
873  << " *.unv -- I-deas Universal format\n"
874  << " *.vtu -- VTK (paraview-readable) format\n"
875  << " *.xda -- libMesh ASCII format\n"
876  << " *.xdr -- libMesh binary format,\n"
877  << std::endl
878  << "\n Exiting without writing output\n";
879  }
880  }
881 
882  // Nasty hack for reading/writing zipped files
883  if (name.size() - name.rfind(".bz2") == 4)
884  {
885  START_LOG("system(bzip2)", "Mesh");
886  if (this->processor_id() == 0)
887  {
888  std::string system_string = "bzip2 -f -c ";
889  system_string += new_name + " > " + name;
890  if (std::system(system_string.c_str()))
891  libmesh_file_error(system_string);
892  std::remove(new_name.c_str());
893  }
894  this->comm().barrier();
895  STOP_LOG("system(bzip2)", "Mesh");
896  }
897  if (name.size() - name.rfind(".xz") == 3)
898  {
899  START_LOG("system(xz)", "Mesh");
900  if (this->processor_id() == 0)
901  {
902  std::string system_string = "xz -f -c ";
903  system_string += new_name + " > " + name;
904  if (std::system(system_string.c_str()))
905  libmesh_file_error(system_string);
906  std::remove(new_name.c_str());
907  }
908  this->comm().barrier();
909  STOP_LOG("system(xz)", "Mesh");
910  }
911 
912  STOP_LOG("write()", "Mesh");
913  }
914 }
void libMesh::UnstructuredMesh::write ( const std::string &  name,
const std::vector< Number > &  values,
const std::vector< std::string > &  variable_names 
)
inherited

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

Definition at line 918 of file unstructured_mesh.C.

References libMesh::err, libMesh::MeshBase::n_subdomains(), libMesh::GMVIO::partitioning(), libMesh::START_LOG(), libMesh::STOP_LOG(), libMesh::TecplotIO::write_nodal_data(), libMesh::VTKIO::write_nodal_data(), and libMesh::GMVIO::write_nodal_data().

921 {
922  START_LOG("write()", "Mesh");
923 
924  // Write the file based on extension
925  if (name.rfind(".dat") < name.size())
926  TecplotIO(*this).write_nodal_data (name, v, vn);
927 
928  else if (name.rfind(".plt") <