libMesh::SerialMesh Class Reference

#include <serial_mesh.h>

Inheritance diagram for libMesh::SerialMesh:

List of all members.

Public Types

typedef Predicates::multi_predicate Predicate

Public Member Functions

 SerialMesh (unsigned int dim=1)
 SerialMesh (const UnstructuredMesh &other_mesh)
 SerialMesh (const SerialMesh &other_mesh)
virtual AutoPtr< MeshBaseclone () const
virtual ~SerialMesh ()
virtual void clear ()
virtual void renumber_nodes_and_elements ()
virtual dof_id_type n_nodes () const
virtual dof_id_type parallel_n_nodes () const
virtual dof_id_type max_node_id () const
virtual void reserve_nodes (const dof_id_type nn)
virtual dof_id_type n_elem () const
virtual dof_id_type parallel_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 ne)
virtual void update_parallel_id_counts ()
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 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 ()
void stitch_meshes (SerialMesh &other_mesh, boundary_id_type this_mesh_boundary, boundary_id_type other_mesh_boundary, Real tol=TOLERANCE, bool clear_stitched_boundary_ids=false, bool verbose=true)
element_iterator elements_begin ()
element_iterator elements_end ()
element_iterator active_elements_begin ()
element_iterator active_elements_end ()
element_iterator ancestor_elements_begin ()
element_iterator ancestor_elements_end ()
element_iterator subactive_elements_begin ()
element_iterator subactive_elements_end ()
element_iterator not_active_elements_begin ()
element_iterator not_active_elements_end ()
element_iterator not_ancestor_elements_begin ()
element_iterator not_ancestor_elements_end ()
element_iterator not_subactive_elements_begin ()
element_iterator not_subactive_elements_end ()
element_iterator local_elements_begin ()
element_iterator local_elements_end ()
element_iterator not_local_elements_begin ()
element_iterator not_local_elements_end ()
element_iterator active_local_elements_begin ()
element_iterator active_local_elements_end ()
element_iterator active_not_local_elements_begin ()
element_iterator active_not_local_elements_end ()
element_iterator level_elements_begin (const unsigned int level)
element_iterator level_elements_end (const unsigned int level)
element_iterator not_level_elements_begin (const unsigned int level)
element_iterator not_level_elements_end (const unsigned int level)
element_iterator local_level_elements_begin (const unsigned int level)
element_iterator local_level_elements_end (const unsigned int level)
element_iterator local_not_level_elements_begin (const unsigned int level)
element_iterator local_not_level_elements_end (const unsigned int level)
element_iterator pid_elements_begin (const processor_id_type proc_id)
element_iterator pid_elements_end (const processor_id_type proc_id)
element_iterator type_elements_begin (const ElemType type)
element_iterator type_elements_end (const ElemType type)
element_iterator active_type_elements_begin (const ElemType type)
element_iterator active_type_elements_end (const ElemType type)
element_iterator active_pid_elements_begin (const processor_id_type proc_id)
element_iterator active_pid_elements_end (const processor_id_type proc_id)
element_iterator unpartitioned_elements_begin ()
element_iterator unpartitioned_elements_end ()
element_iterator active_local_subdomain_elements_begin (const subdomain_id_type subdomain_id)
element_iterator active_local_subdomain_elements_end (const subdomain_id_type subdomain_id)
element_iterator active_subdomain_elements_begin (const subdomain_id_type subdomain_id)
element_iterator active_subdomain_elements_end (const subdomain_id_type subdomain_id)
const_element_iterator elements_begin () const
const_element_iterator elements_end () const
const_element_iterator active_elements_begin () const
const_element_iterator active_elements_end () const
const_element_iterator ancestor_elements_begin () const
const_element_iterator ancestor_elements_end () const
const_element_iterator subactive_elements_begin () const
const_element_iterator subactive_elements_end () const
const_element_iterator not_active_elements_begin () const
const_element_iterator not_active_elements_end () const
const_element_iterator not_ancestor_elements_begin () const
const_element_iterator not_ancestor_elements_end () const
const_element_iterator not_subactive_elements_begin () const
const_element_iterator not_subactive_elements_end () const
const_element_iterator local_elements_begin () const
const_element_iterator local_elements_end () const
const_element_iterator not_local_elements_begin () const
const_element_iterator not_local_elements_end () const
const_element_iterator active_local_elements_begin () const
const_element_iterator active_local_elements_end () const
const_element_iterator active_not_local_elements_begin () const
const_element_iterator active_not_local_elements_end () const
const_element_iterator level_elements_begin (const unsigned int level) const
const_element_iterator level_elements_end (const unsigned int level) const
const_element_iterator not_level_elements_begin (const unsigned int level) const
const_element_iterator not_level_elements_end (const unsigned int level) const
const_element_iterator local_level_elements_begin (const unsigned int level) const
const_element_iterator local_level_elements_end (const unsigned int level) const
const_element_iterator local_not_level_elements_begin (const unsigned int level) const
const_element_iterator local_not_level_elements_end (const unsigned int level) const
const_element_iterator pid_elements_begin (const processor_id_type proc_id) const
const_element_iterator pid_elements_end (const processor_id_type proc_id) const
const_element_iterator type_elements_begin (const ElemType type) const
const_element_iterator type_elements_end (const ElemType type) const
const_element_iterator active_type_elements_begin (const ElemType type) const
const_element_iterator active_type_elements_end (const ElemType type) const
const_element_iterator active_pid_elements_begin (const processor_id_type proc_id) const
const_element_iterator active_pid_elements_end (const processor_id_type proc_id) const
const_element_iterator unpartitioned_elements_begin () const
const_element_iterator unpartitioned_elements_end () const
const_element_iterator active_local_subdomain_elements_begin (const subdomain_id_type subdomain_id) const
const_element_iterator active_local_subdomain_elements_end (const subdomain_id_type subdomain_id) const
const_element_iterator active_subdomain_elements_begin (const subdomain_id_type subdomain_id) const
const_element_iterator active_subdomain_elements_end (const subdomain_id_type subdomain_id) const
node_iterator nodes_begin ()
node_iterator nodes_end ()
node_iterator active_nodes_begin ()
node_iterator active_nodes_end ()
node_iterator local_nodes_begin ()
node_iterator local_nodes_end ()
node_iterator pid_nodes_begin (const processor_id_type proc_id)
node_iterator pid_nodes_end (const processor_id_type proc_id)
const_node_iterator nodes_begin () const
const_node_iterator nodes_end () const
const_node_iterator active_nodes_begin () const
const_node_iterator active_nodes_end () const
const_node_iterator local_nodes_begin () const
const_node_iterator local_nodes_end () const
const_node_iterator pid_nodes_begin (const processor_id_type proc_id) const
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
virtual bool is_serial () const
virtual void allgather ()
virtual void delete_remote_elements ()
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
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=libMesh::n_processors())
virtual void redistribute ()
virtual void update_post_partitioning ()
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
processor_id_type n_processors () const
processor_id_type processor_id () 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 ()
virtual void libmesh_assert_valid_parallel_ids () const
std::string & subdomain_name (subdomain_id_type id)
const std::string & subdomain_name (subdomain_id_type id) const
subdomain_id_type get_id_by_name (const std::string &name) const

Public Attributes

AutoPtr< BoundaryInfoboundary_info

Protected Member Functions

unsigned int & set_n_partitions ()

Protected Attributes

std::vector< Node * > _nodes
std::vector< Elem * > _elements
unsigned int _n_parts
unsigned int _dim
bool _is_prepared
AutoPtr< PointLocatorBase_point_locator
AutoPtr< Partitioner_partitioner
bool _skip_partitioning
bool _skip_renumber_nodes_and_elements
std::map< subdomain_id_type,
std::string > 
_block_id_to_name

Private Types

typedef std::vector< Elem * >
::iterator 
elem_iterator_imp
typedef std::vector< Elem * >
::const_iterator 
const_elem_iterator_imp
typedef std::vector< Node * >
::iterator 
node_iterator_imp
typedef std::vector< Node * >
::const_iterator 
const_node_iterator_imp

Friends

class Partitioner
class BoundaryInfo
std::ostream & operator<< (std::ostream &os, const MeshBase &m)

Detailed Description

The SerialMesh class is derived from the MeshBase class, and currently represents the default Mesh implementation. Most methods for this class are found in MeshBase, and most implementation details are found in UnstructuredMesh.

Definition at line 47 of file serial_mesh.h.


Member Typedef Documentation

typedef std::vector<Elem*>::const_iterator libMesh::SerialMesh::const_elem_iterator_imp [private]

Definition at line 363 of file serial_mesh.h.

typedef std::vector<Node*>::const_iterator libMesh::SerialMesh::const_node_iterator_imp [private]

Definition at line 370 of file serial_mesh.h.

typedef std::vector<Elem*>::iterator libMesh::SerialMesh::elem_iterator_imp [private]

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

Definition at line 362 of file serial_mesh.h.

typedef std::vector<Node*>::iterator libMesh::SerialMesh::node_iterator_imp [private]

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

Definition at line 369 of file serial_mesh.h.

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

Definition at line 610 of file mesh_base.h.


Constructor & Destructor Documentation

libMesh::SerialMesh::SerialMesh ( unsigned int  dim = 1  )  [explicit]

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

Definition at line 35 of file serial_mesh.C.

References libMesh::MeshBase::_partitioner.

Referenced by clone().

00035                                       :
00036   UnstructuredMesh (d)
00037 {
00038   _partitioner = AutoPtr<Partitioner>(new MetisPartitioner());
00039 }

libMesh::SerialMesh::SerialMesh ( const UnstructuredMesh other_mesh  ) 

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

Definition at line 59 of file serial_mesh.C.

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

00059                                                           :
00060   UnstructuredMesh (other_mesh)
00061 {
00062   this->copy_nodes_and_elements(other_mesh);
00063   *this->boundary_info = *other_mesh.boundary_info;
00064 }

libMesh::SerialMesh::SerialMesh ( const SerialMesh other_mesh  ) 

Copy-constructor, possibly specialized for a serial mesh.

Definition at line 51 of file serial_mesh.C.

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

00051                                                     :
00052   UnstructuredMesh (other_mesh)
00053 {
00054   this->copy_nodes_and_elements(other_mesh);
00055   *this->boundary_info = *other_mesh.boundary_info;
00056 }

libMesh::SerialMesh::~SerialMesh (  )  [virtual]

Destructor.

Definition at line 42 of file serial_mesh.C.

References clear().

00043 {
00044   this->clear();  // Free nodes and elements
00045 }


Member Function Documentation

SerialMesh::const_element_iterator libMesh::SerialMesh::active_elements_begin (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 270 of file serial_mesh_iterators.C.

References _elements.

00271 {
00272   Predicates::Active<const_elem_iterator_imp> p;
00273   return const_element_iterator(_elements.begin(), _elements.end(), p);
00274 }

SerialMesh::element_iterator libMesh::SerialMesh::active_elements_begin (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 47 of file serial_mesh_iterators.C.

References _elements.

Referenced by n_active_elem().

00048 {
00049   Predicates::Active<elem_iterator_imp> p;
00050   return element_iterator(_elements.begin(), _elements.end(), p);
00051 }

SerialMesh::const_element_iterator libMesh::SerialMesh::active_elements_end (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 720 of file serial_mesh_iterators.C.

References _elements.

00721 {
00722   Predicates::Active<const_elem_iterator_imp> p;
00723   return const_element_iterator(_elements.end(), _elements.end(), p);
00724 }

SerialMesh::element_iterator libMesh::SerialMesh::active_elements_end (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 493 of file serial_mesh_iterators.C.

References _elements.

Referenced by n_active_elem().

00494 {
00495   Predicates::Active<elem_iterator_imp> p;
00496   return element_iterator(_elements.end(), _elements.end(), p);
00497 }

SerialMesh::const_element_iterator libMesh::SerialMesh::active_local_elements_begin (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 350 of file serial_mesh_iterators.C.

References _elements.

00351 {
00352   Predicates::ActiveLocal<const_elem_iterator_imp> p;
00353   return const_element_iterator(_elements.begin(), _elements.end(), p);
00354 }

SerialMesh::element_iterator libMesh::SerialMesh::active_local_elements_begin (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 127 of file serial_mesh_iterators.C.

References _elements.

00128 {
00129   Predicates::ActiveLocal<elem_iterator_imp> p;
00130   return element_iterator(_elements.begin(), _elements.end(), p);
00131 }

SerialMesh::const_element_iterator libMesh::SerialMesh::active_local_elements_end (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 800 of file serial_mesh_iterators.C.

References _elements.

00801 {
00802   Predicates::ActiveLocal<const_elem_iterator_imp> p;
00803   return const_element_iterator(_elements.end(), _elements.end(), p);
00804 }

SerialMesh::element_iterator libMesh::SerialMesh::active_local_elements_end (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 573 of file serial_mesh_iterators.C.

References _elements.

00574 {
00575   Predicates::ActiveLocal<elem_iterator_imp> p;
00576   return element_iterator(_elements.end(), _elements.end(), p);
00577 }

SerialMesh::const_element_iterator libMesh::SerialMesh::active_local_subdomain_elements_begin ( const subdomain_id_type  subdomain_id  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 459 of file serial_mesh_iterators.C.

References _elements.

00460 {
00461   Predicates::ActiveLocalSubdomain<const_elem_iterator_imp> p(subdomain_id);
00462   return const_element_iterator(_elements.begin(), _elements.end(), p);
00463 }

SerialMesh::element_iterator libMesh::SerialMesh::active_local_subdomain_elements_begin ( const subdomain_id_type  subdomain_id  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 236 of file serial_mesh_iterators.C.

References _elements.

00237 {
00238   Predicates::ActiveLocalSubdomain<elem_iterator_imp> p(subdomain_id);
00239   return element_iterator(_elements.begin(), _elements.end(), p);
00240 }

SerialMesh::const_element_iterator libMesh::SerialMesh::active_local_subdomain_elements_end ( const subdomain_id_type  subdomain_id  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 909 of file serial_mesh_iterators.C.

References _elements.

00910 {
00911   Predicates::ActiveLocalSubdomain<const_elem_iterator_imp> p(subdomain_id);
00912   return const_element_iterator(_elements.end(), _elements.end(), p);
00913 }

SerialMesh::element_iterator libMesh::SerialMesh::active_local_subdomain_elements_end ( const subdomain_id_type  subdomain_id  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 682 of file serial_mesh_iterators.C.

References _elements.

00683 {
00684   Predicates::ActiveLocalSubdomain<elem_iterator_imp> p(subdomain_id);
00685   return element_iterator(_elements.end(), _elements.end(), p);
00686 }

SerialMesh::const_node_iterator libMesh::SerialMesh::active_nodes_begin (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 982 of file serial_mesh_iterators.C.

References _nodes.

00983 {
00984   Predicates::Active<const_node_iterator_imp> p;
00985   return const_node_iterator(_nodes.begin(), _nodes.end(), p);
00986 }

SerialMesh::node_iterator libMesh::SerialMesh::active_nodes_begin (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 942 of file serial_mesh_iterators.C.

References _nodes.

00943 {
00944   Predicates::Active<node_iterator_imp> p;
00945   return node_iterator(_nodes.begin(), _nodes.end(), p);
00946 }

SerialMesh::const_node_iterator libMesh::SerialMesh::active_nodes_end (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 1062 of file serial_mesh_iterators.C.

References _nodes.

01063 {
01064   Predicates::Active<const_node_iterator_imp> p;
01065   return const_node_iterator(_nodes.end(), _nodes.end(), p);
01066 }

SerialMesh::node_iterator libMesh::SerialMesh::active_nodes_end (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 1022 of file serial_mesh_iterators.C.

References _nodes.

01023 {
01024   Predicates::Active<node_iterator_imp> p;
01025   return node_iterator(_nodes.end(), _nodes.end(), p);
01026 }

SerialMesh::const_element_iterator libMesh::SerialMesh::active_not_local_elements_begin (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 360 of file serial_mesh_iterators.C.

References _elements.

00361 {
00362   Predicates::ActiveNotLocal<const_elem_iterator_imp> p;
00363   return const_element_iterator(_elements.begin(), _elements.end(), p);
00364 }

SerialMesh::element_iterator libMesh::SerialMesh::active_not_local_elements_begin (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 137 of file serial_mesh_iterators.C.

References _elements.

00138 {
00139   Predicates::ActiveNotLocal<elem_iterator_imp> p;
00140   return element_iterator(_elements.begin(), _elements.end(), p);
00141 }

SerialMesh::const_element_iterator libMesh::SerialMesh::active_not_local_elements_end (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 810 of file serial_mesh_iterators.C.

References _elements.

00811 {
00812   Predicates::ActiveNotLocal<const_elem_iterator_imp> p;
00813   return const_element_iterator(_elements.end(), _elements.end(), p);
00814 }

SerialMesh::element_iterator libMesh::SerialMesh::active_not_local_elements_end (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 583 of file serial_mesh_iterators.C.

References _elements.

00584 {
00585   Predicates::ActiveNotLocal<elem_iterator_imp> p;
00586   return element_iterator(_elements.end(), _elements.end(), p);
00587 }

SerialMesh::const_element_iterator libMesh::SerialMesh::active_pid_elements_begin ( const processor_id_type  proc_id  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 440 of file serial_mesh_iterators.C.

References _elements.

00441 {
00442   Predicates::ActivePID<const_elem_iterator_imp> p(proc_id);
00443   return const_element_iterator(_elements.begin(), _elements.end(), p);
00444 }

SerialMesh::element_iterator libMesh::SerialMesh::active_pid_elements_begin ( const processor_id_type  proc_id  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 217 of file serial_mesh_iterators.C.

References _elements.

00218 {
00219   Predicates::ActivePID<elem_iterator_imp> p(proc_id);
00220   return element_iterator(_elements.begin(), _elements.end(), p);
00221 }

SerialMesh::const_element_iterator libMesh::SerialMesh::active_pid_elements_end ( const processor_id_type  proc_id  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 890 of file serial_mesh_iterators.C.

References _elements.

00891 {
00892   Predicates::ActivePID<const_elem_iterator_imp> p(proc_id);
00893   return const_element_iterator(_elements.end(), _elements.end(), p);
00894 }

SerialMesh::element_iterator libMesh::SerialMesh::active_pid_elements_end ( const processor_id_type  proc_id  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 663 of file serial_mesh_iterators.C.

References _elements.

00664 {
00665   Predicates::ActivePID<elem_iterator_imp> p(proc_id);
00666   return element_iterator(_elements.end(), _elements.end(), p);
00667 }

SerialMesh::const_element_iterator libMesh::SerialMesh::active_subdomain_elements_begin ( const subdomain_id_type  subdomain_id  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 469 of file serial_mesh_iterators.C.

References _elements.

00470 {
00471   Predicates::ActiveSubdomain<const_elem_iterator_imp> p(subdomain_id);
00472   return const_element_iterator(_elements.begin(), _elements.end(), p);
00473 }

SerialMesh::element_iterator libMesh::SerialMesh::active_subdomain_elements_begin ( const subdomain_id_type  subdomain_id  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 246 of file serial_mesh_iterators.C.

References _elements.

00247 {
00248   Predicates::ActiveSubdomain<elem_iterator_imp> p(subdomain_id);
00249   return element_iterator(_elements.begin(), _elements.end(), p);
00250 }

SerialMesh::const_element_iterator libMesh::SerialMesh::active_subdomain_elements_end ( const subdomain_id_type  subdomain_id  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 919 of file serial_mesh_iterators.C.

References _elements.

00920 {
00921   Predicates::ActiveSubdomain<const_elem_iterator_imp> p(subdomain_id);
00922   return const_element_iterator(_elements.end(), _elements.end(), p);
00923 }

SerialMesh::element_iterator libMesh::SerialMesh::active_subdomain_elements_end ( const subdomain_id_type  subdomain_id  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 692 of file serial_mesh_iterators.C.

References _elements.

00693 {
00694   Predicates::ActiveSubdomain<elem_iterator_imp> p(subdomain_id);
00695   return element_iterator(_elements.end(), _elements.end(), p);
00696 }

SerialMesh::const_element_iterator libMesh::SerialMesh::active_type_elements_begin ( const ElemType  type  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 430 of file serial_mesh_iterators.C.

References _elements.

00431 {
00432   Predicates::ActiveType<const_elem_iterator_imp> p(type);
00433   return const_element_iterator(_elements.begin(), _elements.end(), p);
00434 }

SerialMesh::element_iterator libMesh::SerialMesh::active_type_elements_begin ( const ElemType  type  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 207 of file serial_mesh_iterators.C.

References _elements.

00208 {
00209   Predicates::ActiveType<elem_iterator_imp> p(type);
00210   return element_iterator(_elements.begin(), _elements.end(), p);
00211 }

SerialMesh::const_element_iterator libMesh::SerialMesh::active_type_elements_end ( const ElemType  type  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 880 of file serial_mesh_iterators.C.

References _elements.

00881 {
00882   Predicates::ActiveType<const_elem_iterator_imp> p(type);
00883   return const_element_iterator(_elements.end(), _elements.end(), p);
00884 }

SerialMesh::element_iterator libMesh::SerialMesh::active_type_elements_end ( const ElemType  type  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 653 of file serial_mesh_iterators.C.

References _elements.

00654 {
00655   Predicates::ActiveType<elem_iterator_imp> p(type);
00656   return element_iterator(_elements.end(), _elements.end(), p);
00657 }

Elem * libMesh::SerialMesh::add_elem ( Elem e  )  [virtual]

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

Implements libMesh::MeshBase.

Definition at line 212 of file serial_mesh.C.

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

00213 {
00214   libmesh_assert(e);
00215 
00216   // We no longer merely append elements with SerialMesh
00217 
00218   // If the user requests a valid id that doesn't correspond to an
00219   // existing element, let's give them that id, resizing the elements
00220   // container if necessary.
00221   if (!e->valid_id())
00222     e->set_id (_elements.size());
00223 
00224   const dof_id_type id = e->id();
00225 
00226   if (id < _elements.size())
00227     {
00228       // Overwriting existing elements is still probably a mistake.
00229       libmesh_assert(!_elements[id]);
00230     }
00231   else
00232     {
00233       _elements.resize(id+1, NULL);
00234     }
00235 
00236   _elements[id] = e;
00237 
00238   return e;
00239 }

Node * libMesh::SerialMesh::add_node ( Node n  )  [virtual]

Add Node n to the end of the vertex array.

Implements libMesh::MeshBase.

Definition at line 366 of file serial_mesh.C.

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

00367 {
00368   libmesh_assert(n);
00369   // We only append points with SerialMesh
00370   libmesh_assert(!n->valid_id() || n->id() == _nodes.size());
00371 
00372   n->set_id (_nodes.size());
00373 
00374   _nodes.push_back(n);
00375 
00376   return n;
00377 }

Node * libMesh::SerialMesh::add_point ( const Point p,
const dof_id_type  id = DofObject::invalid_id,
const processor_id_type  proc_id = DofObject::invalid_processor_id 
) [virtual]

functions for adding /deleting nodes elements.

Implements libMesh::MeshBase.

Definition at line 319 of file serial_mesh.C.

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

00322 {
00323 //   // We only append points with SerialMesh
00324 //   libmesh_assert(id == DofObject::invalid_id || id == _nodes.size());
00325 //   Node *n = Node::build(p, _nodes.size()).release();
00326 //   n->processor_id() = proc_id;
00327 //   _nodes.push_back (n);
00328 
00329   Node *n = NULL;
00330 
00331   // If the user requests a valid id, either
00332   // provide the existing node or resize the container
00333   // to fit the new node.
00334   if (id != DofObject::invalid_id)
00335     if (id < _nodes.size())
00336       n = _nodes[id];
00337     else
00338       _nodes.resize(id+1);
00339   else
00340     _nodes.push_back (static_cast<Node*>(NULL));
00341 
00342   // if the node already exists, then assign new (x,y,z) values
00343   if (n)
00344     *n = p;
00345   // otherwise build a new node, put it in the right spot, and return
00346   // a valid pointer.
00347   else
00348     {
00349       n = Node::build(p, (id == DofObject::invalid_id) ? _nodes.size()-1 : id).release();
00350       n->processor_id() = proc_id;
00351 
00352       if (id == DofObject::invalid_id)
00353         _nodes.back() = n;
00354       else
00355         _nodes[id] = n;
00356     }
00357 
00358   // better not pass back a NULL pointer.
00359   libmesh_assert (n);
00360 
00361   return n;
00362 }

void libMesh::UnstructuredMesh::all_first_order (  )  [virtual, inherited]

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::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::Elem::subdomain_id(), libMesh::Elem::type(), and libMesh::Elem::which_child_am_i().

00255 {
00256   /*
00257    * when the mesh is not prepared,
00258    * at least renumber the nodes and
00259    * elements, so that the node ids
00260    * are correct
00261    */
00262   if (!this->_is_prepared)
00263     this->renumber_nodes_and_elements ();
00264 
00265   START_LOG("all_first_order()", "Mesh");
00266 
00270   std::vector<bool> node_touched_by_me(this->max_node_id(), false);
00271 
00277   element_iterator endit = elements_end();
00278   for (element_iterator it = elements_begin();
00279        it != endit; ++it)
00280     {
00281       Elem* so_elem = *it;
00282 
00283       libmesh_assert(so_elem);
00284 
00285       /*
00286        * build the first-order equivalent, add to
00287        * the new_elements list.
00288        */
00289       Elem* lo_elem = Elem::build
00290         (Elem::first_order_equivalent_type
00291           (so_elem->type()), so_elem->parent()).release();
00292 
00293       for (unsigned int s=0; s != so_elem->n_sides(); ++s)
00294         if (so_elem->neighbor(s) == remote_elem)
00295           lo_elem->set_neighbor(s, const_cast<RemoteElem*>(remote_elem));
00296 
00297 #ifdef LIBMESH_ENABLE_AMR
00298       /*
00299        * Reset the parent links of any child elements
00300        */
00301       if (so_elem->has_children())
00302         for (unsigned int c=0; c != so_elem->n_children(); ++c)
00303           {
00304             so_elem->child(c)->set_parent(lo_elem);
00305             lo_elem->add_child(so_elem->child(c), c);
00306           }
00307 
00308       /*
00309        * Reset the child link of any parent element
00310        */
00311       if (so_elem->parent())
00312         {
00313           unsigned int c =
00314             so_elem->parent()->which_child_am_i(so_elem);
00315           lo_elem->parent()->replace_child(lo_elem, c);
00316         }
00317 
00318       /*
00319        * Copy as much data to the new element as makes sense
00320        */
00321       lo_elem->set_p_level(so_elem->p_level());
00322       lo_elem->set_refinement_flag(so_elem->refinement_flag());
00323       lo_elem->set_p_refinement_flag(so_elem->p_refinement_flag());
00324 #endif
00325 
00326       libmesh_assert_equal_to (lo_elem->n_vertices(), so_elem->n_vertices());
00327 
00328       /*
00329        * By definition the vertices of the linear and
00330        * second order element are identically numbered.
00331        * transfer these.
00332        */
00333       for (unsigned int v=0; v < so_elem->n_vertices(); v++)
00334         {
00335           lo_elem->set_node(v) = so_elem->get_node(v);
00336           node_touched_by_me[lo_elem->node(v)] = true;
00337         }
00338 
00345       libmesh_assert_equal_to (lo_elem->n_sides(), so_elem->n_sides());
00346 
00347       for (unsigned int s=0; s<so_elem->n_sides(); s++)
00348         {
00349           const std::vector<boundary_id_type> boundary_ids =
00350             this->boundary_info->raw_boundary_ids (so_elem, s);
00351 
00352           this->boundary_info->add_side (lo_elem, s, boundary_ids);
00353         }
00354 
00355       /*
00356        * The new first-order element is ready.
00357        * Inserting it into the mesh will replace and delete
00358        * the second-order element.
00359        */
00360       lo_elem->set_id(so_elem->id());
00361       lo_elem->processor_id() = so_elem->processor_id();
00362       lo_elem->subdomain_id() = so_elem->subdomain_id();
00363       this->insert_elem(lo_elem);
00364     }
00365 
00366   const MeshBase::node_iterator nd_end = this->nodes_end();
00367   MeshBase::node_iterator nd = this->nodes_begin();
00368     while (nd != nd_end)
00369     {
00370       Node *the_node = *nd;
00371       ++nd;
00372       if (!node_touched_by_me[the_node->id()])
00373         this->delete_node(the_node);
00374     }
00375 
00376   STOP_LOG("all_first_order()", "Mesh");
00377 
00378   // On hanging nodes that used to also be second order nodes, we
00379   // might now have an invalid nodal processor_id()
00380   Partitioner::set_node_processor_ids(*this);
00381 
00382   // delete or renumber nodes, etc
00383   this->prepare_for_use(/*skip_renumber =*/ false);
00384 }

void libMesh::UnstructuredMesh::all_second_order ( const bool  full_ordered = true  )  [virtual, inherited]

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::CommWorld, 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::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::DofObject::processor_id(), libMesh::MeshBase::processor_id(), libMesh::Real, libMesh::AutoPtr< Tp >::release(), libMesh::remote_elem, libMesh::MeshBase::renumber_nodes_and_elements(), libMesh::MeshBase::reserve_nodes(), libMesh::Elem::second_order_equivalent_type(), libMesh::Elem::subdomain_id(), and libMesh::Elem::type().

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

00389 {
00390   // This function must be run on all processors at once
00391   parallel_only();
00392 
00393   /*
00394    * when the mesh is not prepared,
00395    * at least renumber the nodes and
00396    * elements, so that the node ids
00397    * are correct
00398    */
00399   if (!this->_is_prepared)
00400     this->renumber_nodes_and_elements ();
00401 
00402   /*
00403    * If the mesh is empty
00404    * then we have nothing to do
00405    */
00406   if (!this->n_elem())
00407     return;
00408 
00409   /*
00410    * If the mesh is already second order
00411    * then we have nothing to do.
00412    * We have to test for this in a round-about way to avoid
00413    * a bug on distributed parallel meshes with more processors
00414    * than elements.
00415    */
00416   bool already_second_order = false;
00417   if (this->elements_begin() != this->elements_end() &&
00418       (*(this->elements_begin()))->default_order() != FIRST)
00419     already_second_order = true;
00420   CommWorld.max(already_second_order);
00421   if (already_second_order)
00422     return;
00423 
00424   START_LOG("all_second_order()", "Mesh");
00425 
00426   /*
00427    * this map helps in identifying second order
00428    * nodes.  Namely, a second-order node:
00429    * - edge node
00430    * - face node
00431    * - bubble node
00432    * is uniquely defined through a set of adjacent
00433    * vertices.  This set of adjacent vertices is
00434    * used to identify already added higher-order
00435    * nodes.  We are safe to use node id's since we
00436    * make sure that these are correctly numbered.
00437    */
00438   std::map<std::vector<dof_id_type>, Node*> adj_vertices_to_so_nodes;
00439 
00440   /*
00441    * for speed-up of the \p add_point() method, we
00442    * can reserve memory.  Guess the number of additional
00443    * nodes for different dimensions
00444    */
00445   switch (this->mesh_dimension())
00446   {
00447     case 1:
00448       /*
00449        * in 1D, there can only be order-increase from Edge2
00450        * to Edge3.  Something like 1/2 of n_nodes() have
00451        * to be added
00452        */
00453       this->reserve_nodes(static_cast<unsigned int>
00454                           (1.5*static_cast<double>(this->n_nodes())));
00455       break;
00456 
00457     case 2:
00458       /*
00459        * in 2D, either refine from Tri3 to Tri6 (double the nodes)
00460        * or from Quad4 to Quad8 (again, double) or Quad9 (2.25 that much)
00461        */
00462       this->reserve_nodes(static_cast<unsigned int>
00463                           (2*static_cast<double>(this->n_nodes())));
00464       break;
00465 
00466 
00467     case 3:
00468       /*
00469        * in 3D, either refine from Tet4 to Tet10 (factor = 2.5) up to
00470        * Hex8 to Hex27 (something  > 3).  Since in 3D there _are_ already
00471        * quite some nodes, and since we do not want to overburden the memory by
00472        * a too conservative guess, use the lower bound
00473        */
00474       this->reserve_nodes(static_cast<unsigned int>
00475                           (2.5*static_cast<double>(this->n_nodes())));
00476       break;
00477 
00478     default:
00479       // Hm?
00480       libmesh_error();
00481   }
00482 
00483 
00484 
00485   /*
00486    * form a vector that will hold the node id's of
00487    * the vertices that are adjacent to the son-th
00488    * second-order node.  Pull this outside of the
00489    * loop so that silly compilers don't repeatedly
00490    * create and destroy the vector.
00491    */
00492   std::vector<dof_id_type> adjacent_vertices_ids;
00493 
00500   const_element_iterator endit = elements_end();
00501   for (const_element_iterator it = elements_begin();
00502        it != endit; ++it)
00503     {
00504       // the linear-order element
00505       const Elem* lo_elem = *it;
00506 
00507       libmesh_assert(lo_elem);
00508 
00509       // make sure it is linear order
00510       if (lo_elem->default_order() != FIRST)
00511         {
00512           libMesh::err << "ERROR: This is not a linear element: type="
00513                         << lo_elem->type() << std::endl;
00514           libmesh_error();
00515         }
00516 
00517       // this does _not_ work for refined elements
00518       libmesh_assert_equal_to (lo_elem->level (), 0);
00519 
00520       /*
00521        * build the second-order equivalent, add to
00522        * the new_elements list.  Note that this here
00523        * is the only point where \p full_ordered
00524        * is necessary.  The remaining code works well
00525        * for either type of seconrd-order equivalent, e.g.
00526        * Hex20 or Hex27, as equivalents for Hex8
00527        */
00528       Elem* so_elem =
00529         Elem::build (Elem::second_order_equivalent_type(lo_elem->type(),
00530                                                         full_ordered) ).release();
00531 
00532       libmesh_assert_equal_to (lo_elem->n_vertices(), so_elem->n_vertices());
00533 
00534 
00535       /*
00536        * By definition the vertices of the linear and
00537        * second order element are identically numbered.
00538        * transfer these.
00539        */
00540       for (unsigned int v=0; v < lo_elem->n_vertices(); v++)
00541         so_elem->set_node(v) = lo_elem->get_node(v);
00542 
00543       /*
00544        * Now handle the additional mid-side nodes.  This
00545        * is simply handled through a map that remembers
00546        * the already-added nodes.  This map maps the global
00547        * ids of the vertices (that uniquely define this
00548        * higher-order node) to the new node.
00549        * Notation: son = second-order node
00550        */
00551       const unsigned int son_begin = so_elem->n_vertices();
00552       const unsigned int son_end   = so_elem->n_nodes();
00553 
00554 
00555       for (unsigned int son=son_begin; son<son_end; son++)
00556         {
00557           const unsigned int n_adjacent_vertices =
00558             so_elem->n_second_order_adjacent_vertices(son);
00559 
00560           adjacent_vertices_ids.resize(n_adjacent_vertices);
00561 
00562           for (unsigned int v=0; v<n_adjacent_vertices; v++)
00563             adjacent_vertices_ids[v] =
00564               so_elem->node( so_elem->second_order_adjacent_vertex(son,v) );
00565 
00566           /*
00567            * \p adjacent_vertices_ids is now in order of the current
00568            * side.  sort it, so that comparisons  with the
00569            * \p adjacent_vertices_ids created through other elements'
00570            * sides can match
00571            */
00572           std::sort(adjacent_vertices_ids.begin(),
00573                     adjacent_vertices_ids.end());
00574 
00575 
00576           // does this set of vertices already has a mid-node added?
00577           std::pair<std::map<std::vector<dof_id_type>, Node*>::iterator,
00578                     std::map<std::vector<dof_id_type>, Node*>::iterator>
00579             pos = adj_vertices_to_so_nodes.equal_range (adjacent_vertices_ids);
00580 
00581           // no, not added yet
00582           if (pos.first == pos.second)
00583             {
00584               /*
00585                * for this set of vertices, there is no
00586                * second_order node yet.  Add it.
00587                *
00588                * compute the location of the new node as
00589                * the average over the adjacent vertices.
00590                */
00591               Point new_location = this->point(adjacent_vertices_ids[0]);
00592               for (unsigned int v=1; v<n_adjacent_vertices; v++)
00593                 new_location += this->point(adjacent_vertices_ids[v]);
00594 
00595               new_location /= static_cast<Real>(n_adjacent_vertices);
00596 
00597               /* Add the new point to the mesh, giving it a globally
00598                * well-defined processor id.
00599                */
00600               Node* so_node = this->add_point
00601                 (new_location, DofObject::invalid_id,
00602                 this->node(adjacent_vertices_ids[0]).processor_id());
00603 
00604               /*
00605                * insert the new node with its defining vertex
00606                * set into the map, and relocate pos to this
00607                * new entry, so that the so_elem can use
00608                * \p pos for inserting the node
00609                */
00610               adj_vertices_to_so_nodes.insert(pos.first,
00611                                               std::make_pair(adjacent_vertices_ids,
00612                                                              so_node));
00613 
00614               so_elem->set_node(son) = so_node;
00615             }
00616           // yes, already added.
00617           else
00618             {
00619               libmesh_assert(pos.first->second);
00620 
00621               so_elem->set_node(son) = pos.first->second;
00622             }
00623         }
00624 
00625 
00637       libmesh_assert_equal_to (lo_elem->n_sides(), so_elem->n_sides());
00638 
00639       for (unsigned int s=0; s<lo_elem->n_sides(); s++)
00640         {
00641           const std::vector<boundary_id_type> boundary_ids =
00642             this->boundary_info->raw_boundary_ids (lo_elem, s);
00643 
00644           this->boundary_info->add_side (so_elem, s, boundary_ids);
00645 
00646           if (lo_elem->neighbor(s) == remote_elem)
00647             so_elem->set_neighbor(s, const_cast<RemoteElem*>(remote_elem));
00648         }
00649 
00650       /*
00651        * The new second-order element is ready.
00652        * Inserting it into the mesh will replace and delete
00653        * the first-order element.
00654        */
00655       so_elem->set_id(lo_elem->id());
00656       so_elem->processor_id() = lo_elem->processor_id();
00657       so_elem->subdomain_id() = lo_elem->subdomain_id();
00658       this->insert_elem(so_elem);
00659     }
00660 
00661   // we can clear the map
00662   adj_vertices_to_so_nodes.clear();
00663 
00664 
00665   STOP_LOG("all_second_order()", "Mesh");
00666 
00667   // In a ParallelMesh our ghost node processor ids may be bad and
00668   // the ids of nodes touching remote elements may be inconsistent.
00669   // Fix them.
00670   if (!this->is_serial())
00671     {
00672       LocationMap<Node> loc_map;
00673       MeshCommunication().make_nodes_parallel_consistent
00674         (*this, loc_map);
00675     }
00676 
00677   // renumber nodes, elements etc
00678   this->prepare_for_use(/*skip_renumber =*/ false);
00679 }

virtual void libMesh::MeshBase::allgather (  )  [inline, virtual, inherited]

Gathers all elements and nodes of the mesh onto every processor

Reimplemented in libMesh::ParallelMesh.

Definition at line 129 of file mesh_base.h.

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

00129 {}

bool libMesh::MeshBase::allow_renumbering (  )  const [inline, inherited]
void libMesh::MeshBase::allow_renumbering ( bool  allow  )  [inline, inherited]

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

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

SerialMesh::const_element_iterator libMesh::SerialMesh::ancestor_elements_begin (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 290 of file serial_mesh_iterators.C.

References _elements.

00291 {
00292   Predicates::Ancestor<const_elem_iterator_imp> p;
00293   return const_element_iterator(_elements.begin(), _elements.end(), p);
00294 }

SerialMesh::element_iterator libMesh::SerialMesh::ancestor_elements_begin (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 67 of file serial_mesh_iterators.C.

References _elements.

00068 {
00069   Predicates::Ancestor<elem_iterator_imp> p;
00070   return element_iterator(_elements.begin(), _elements.end(), p);
00071 }

SerialMesh::const_element_iterator libMesh::SerialMesh::ancestor_elements_end (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 740 of file serial_mesh_iterators.C.

References _elements.

00741 {
00742   Predicates::Ancestor<const_elem_iterator_imp> p;
00743   return const_element_iterator(_elements.end(), _elements.end(), p);
00744 }

SerialMesh::element_iterator libMesh::SerialMesh::ancestor_elements_end (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 513 of file serial_mesh_iterators.C.

References _elements.

00514 {
00515   Predicates::Ancestor<elem_iterator_imp> p;
00516   return element_iterator(_elements.end(), _elements.end(), p);
00517 }

void libMesh::SerialMesh::clear (  )  [virtual]

Clear all internal data.

Reimplemented from libMesh::MeshBase.

Definition at line 435 of file serial_mesh.C.

References _elements, _nodes, and end.

Referenced by ~SerialMesh().

00436 {
00437   // Call parent clear function
00438   MeshBase::clear();
00439 
00440 
00441   // Clear our elements and nodes
00442   {
00443     std::vector<Elem*>::iterator       it  = _elements.begin();
00444     const std::vector<Elem*>::iterator end = _elements.end();
00445 
00446     // There is no need to remove the elements from
00447     // the BoundaryInfo data structure since we
00448     // already cleared it.
00449     for (; it != end; ++it)
00450       delete *it;
00451 
00452     _elements.clear();
00453   }
00454 
00455   // clear the nodes data structure
00456   {
00457     std::vector<Node*>::iterator       it  = _nodes.begin();
00458     const std::vector<Node*>::iterator end = _nodes.end();
00459 
00460     // There is no need to remove the nodes from
00461     // the BoundaryInfo data structure since we
00462     // already cleared it.
00463     for (; it != end; ++it)
00464       delete *it;
00465 
00466     _nodes.clear();
00467   }
00468 }

void libMesh::MeshBase::clear_point_locator (  )  [inherited]

Releases the current PointLocator object.

Definition at line 379 of file mesh_base.C.

References libMesh::MeshBase::_point_locator, and libMesh::AutoPtr< Tp >::reset().

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

00380 {
00381   _point_locator.reset(NULL);
00382 }

virtual AutoPtr<MeshBase> libMesh::SerialMesh::clone (  )  const [inline, virtual]

Virtual copy-constructor, creates a copy of this mesh

Implements libMesh::MeshBase.

Definition at line 74 of file serial_mesh.h.

References SerialMesh().

00075     { return AutoPtr<MeshBase>(new SerialMesh(*this)); }

bool libMesh::UnstructuredMesh::contract (  )  [virtual, inherited]

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 1064 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::Elem::parent(), libMesh::MeshBase::renumber_nodes_and_elements(), and libMesh::Elem::subactive().

01065 {
01066   START_LOG ("contract()", "Mesh");
01067 
01068   // Flag indicating if this call actually changes the mesh
01069   bool mesh_changed = false;
01070 
01071   element_iterator in        = elements_begin();
01072   const element_iterator end = elements_end();
01073 
01074 #ifdef DEBUG
01075   for ( ; in != end; ++in)
01076     if (*in != NULL)
01077       {
01078         Elem* el = *in;
01079         libmesh_assert(el->active() || el->subactive() || el->ancestor());
01080       }
01081   in = elements_begin();
01082 #endif
01083 
01084   // Loop over the elements.
01085   for ( ; in != end; ++in)
01086     if (*in != NULL)
01087       {
01088         Elem* el = *in;
01089 
01090         // Delete all the subactive ones
01091         if (el->subactive())
01092           {
01093             // No level-0 element should be subactive.
01094             // Note that we CAN'T test elem->level(), as that
01095             // touches elem->parent()->dim(), and elem->parent()
01096             // might have already been deleted!
01097             libmesh_assert(el->parent());
01098 
01099             // Delete the element
01100             // This just sets a pointer to NULL, and doesn't
01101             // invalidate any iterators
01102             this->delete_elem(el);
01103 
01104             // the mesh has certainly changed
01105             mesh_changed = true;
01106           }
01107         else
01108           {
01109             // Compress all the active ones
01110             if (el->active())
01111               el->contract();
01112             else
01113               libmesh_assert (el->ancestor());
01114           }
01115       }
01116 
01117   // Strip any newly-created NULL voids out of the element array
01118   this->renumber_nodes_and_elements();
01119 
01120   // FIXME: Need to understand why deleting subactive children
01121   // invalidates the point locator.  For now we will clear it explicitly
01122   this->clear_point_locator();
01123 
01124   STOP_LOG ("contract()", "Mesh");
01125 
01126   return mesh_changed;
01127 }

void libMesh::UnstructuredMesh::copy_nodes_and_elements ( const UnstructuredMesh other_mesh  )  [virtual, inherited]

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

Definition at line 90 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::AutoPtr< Tp >::release(), 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(), SerialMesh(), and stitch_meshes().

00091 {
00092   // We're assuming our subclass data needs no copy
00093   libmesh_assert_equal_to (_n_parts, other_mesh._n_parts);
00094   libmesh_assert_equal_to (_dim, other_mesh._dim);
00095   libmesh_assert_equal_to (_is_prepared, other_mesh._is_prepared);
00096 
00097   // We're assuming the other mesh has proper element number ordering,
00098   // so that we add parents before their children.
00099 #ifdef DEBUG
00100   MeshTools::libmesh_assert_valid_amr_elem_ids(other_mesh);
00101 #endif
00102 
00103   //Copy in Nodes
00104   {
00105     //Preallocate Memory if necessary
00106     this->reserve_nodes(other_mesh.n_nodes());
00107 
00108     const_node_iterator it = other_mesh.nodes_begin();
00109     const_node_iterator end = other_mesh.nodes_end();
00110 
00111     for (; it != end; ++it)
00112       {
00113         const Node *oldn = *it;
00114 
00115         // Add new nodes in old node Point locations
00116         /*Node *newn =*/ this->add_point(*oldn, oldn->id(), oldn->processor_id());
00117 
00118         // And start them off in the same subdomain
00119 //        newn->processor_id() = oldn->processor_id();
00120       }
00121   }
00122 
00123   //Copy in Elements
00124   {
00125     //Preallocate Memory if necessary
00126     this->reserve_elem(other_mesh.n_elem());
00127 
00128     // Loop over the elements
00129     MeshBase::const_element_iterator it = other_mesh.elements_begin();
00130     const MeshBase::const_element_iterator end = other_mesh.elements_end();
00131 
00132     // FIXME: Where do we set element IDs??
00133     for (; it != end; ++it)
00134     {
00135       //Look at the old element
00136       const Elem *old = *it;
00137       //Build a new element
00138       Elem *newparent = old->parent() ?
00139           this->elem(old->parent()->id()) : NULL;
00140       AutoPtr<Elem> ap = Elem::build(old->type(), newparent);
00141       Elem * el = ap.release();
00142 
00143       el->subdomain_id() = old->subdomain_id();
00144 
00145       for (unsigned int s=0; s != old->n_sides(); ++s)
00146         if (old->neighbor(s) == remote_elem)
00147           el->set_neighbor(s, const_cast<RemoteElem*>(remote_elem));
00148 
00149 #ifdef LIBMESH_ENABLE_AMR
00150       if (old->has_children())
00151         for (unsigned int c=0; c != old->n_children(); ++c)
00152           if (old->child(c) == remote_elem)
00153             el->add_child(const_cast<RemoteElem*>(remote_elem), c);
00154 
00155       //Create the parent's child pointers if necessary
00156       if (newparent)
00157         {
00158           unsigned int oldc = old->parent()->which_child_am_i(old);
00159           newparent->add_child(el, oldc);
00160         }
00161 
00162       // Copy the refinement flags
00163       el->set_refinement_flag(old->refinement_flag());
00164       el->set_p_refinement_flag(old->p_refinement_flag());
00165 #endif // #ifdef LIBMESH_ENABLE_AMR
00166 
00167       //Assign all the nodes
00168       for(unsigned int i=0;i<el->n_nodes();i++)
00169         el->set_node(i) = &this->node(old->node(i));
00170 
00171       // And start it off in the same subdomain
00172       el->processor_id() = old->processor_id();
00173 
00174       // Give it the same id
00175       el->set_id(old->id());
00176 
00177       //Hold onto it
00178       this->add_elem(el);
00179     }
00180   }
00181 
00182   //Finally prepare the new Mesh for use.  Keep the same numbering and
00183   //partitioning but also the same renumbering and partitioning
00184   //policies as our source mesh.
00185   this->allow_renumbering(false);
00186   this->skip_partitioning(true);
00187   this->prepare_for_use();
00188   this->allow_renumbering(other_mesh.allow_renumbering());
00189   this->skip_partitioning(other_mesh.skip_partitioning());
00190 }

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

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

00932 {
00933 
00934   // Issue a warning if the number the number of processors
00935   // currently available is less that that requested for
00936   // partitioning.  This is not necessarily an error since
00937   // you may run on one processor and still partition the
00938   // mesh into several partitions.
00939 #ifdef DEBUG
00940   if (this->n_processors() < pid)
00941     {
00942       libMesh::out << "WARNING:  You are creating a "
00943                     << "mesh for a processor id (="
00944                     << pid
00945                     << ") greater than "
00946                     << "the number of processors available for "
00947                     << "the calculation. (="
00948                     << libMesh::n_processors()
00949                     << ")."
00950                     << std::endl;
00951     }
00952 #endif
00953 
00954   // Create iterators to loop over the list of elements
00955 //   const_active_pid_elem_iterator       it(this->elements_begin(),   pid);
00956 //   const const_active_pid_elem_iterator it_end(this->elements_end(), pid);
00957 
00958   const_element_iterator       it     = this->active_pid_elements_begin(pid);
00959   const const_element_iterator it_end = this->active_pid_elements_end(pid);
00960 
00961   this->create_submesh (pid_mesh, it, it_end);
00962 }

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 970 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::invalid_uint, libMesh::MeshBase::n_elem(), libMesh::Elem::n_nodes(), libMesh::MeshBase::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().

00973 {
00974   // Just in case the subdomain_mesh already has some information
00975   // in it, get rid of it.
00976   new_mesh.clear();
00977 
00978   // Fail if (*this == new_mesh), we cannot create a submesh inside ourself!
00979   // This may happen if the user accidently passes the original mesh into
00980   // this function!  We will check this by making sure we did not just
00981   // clear ourself.
00982   libmesh_assert_not_equal_to (this->n_nodes(), 0);
00983   libmesh_assert_not_equal_to (this->n_elem(), 0);
00984 
00985   // How the nodes on this mesh will be renumbered to nodes
00986   // on the new_mesh.
00987   std::vector<dof_id_type> new_node_numbers (this->n_nodes());
00988 
00989   std::fill (new_node_numbers.begin(),
00990              new_node_numbers.end(),
00991              libMesh::invalid_uint);
00992 
00993 
00994 
00995   // the number of nodes on the new mesh, will be incremented
00996   dof_id_type n_new_nodes = 0;
00997   dof_id_type n_new_elem  = 0;
00998 
00999   for (; it != it_end; ++it)
01000     {
01001       // increment the new element counter
01002       n_new_elem++;
01003 
01004       const Elem* old_elem = *it;
01005 
01006       // Add an equivalent element type to the new_mesh
01007       Elem* new_elem =
01008         new_mesh.add_elem (Elem::build(old_elem->type()).release());
01009 
01010       libmesh_assert(new_elem);
01011 
01012       // Loop over the nodes on this element.
01013       for (unsigned int n=0; n<old_elem->n_nodes(); n++)
01014         {
01015           libmesh_assert_less (old_elem->node(n), new_node_numbers.size());
01016 
01017           if (new_node_numbers[old_elem->node(n)] == libMesh::invalid_uint)
01018             {
01019               new_node_numbers[old_elem->node(n)] = n_new_nodes;
01020 
01021               // Add this node to the new mesh
01022               new_mesh.add_point (old_elem->point(n));
01023 
01024               // Increment the new node counter
01025               n_new_nodes++;
01026             }
01027 
01028           // Define this element's connectivity on the new mesh
01029           libmesh_assert_less (new_node_numbers[old_elem->node(n)], new_mesh.n_nodes());
01030 
01031           new_elem->set_node(n) = new_mesh.node_ptr (new_node_numbers[old_elem->node(n)]);
01032         }
01033 
01034       // Copy ids for this element
01035       new_elem->subdomain_id() = old_elem->subdomain_id();
01036       new_elem->processor_id() = old_elem->processor_id();
01037 
01038       // Maybe add boundary conditions for this element
01039       for (unsigned int s=0; s<old_elem->n_sides(); s++)
01040 // We're supporting boundary ids on internal sides now
01041 //      if (old_elem->neighbor(s) == NULL)
01042           {
01043             const std::vector<boundary_id_type>& bc_ids = this->boundary_info->boundary_ids(old_elem, s);
01044             for (std::vector<boundary_id_type>::const_iterator id_it=bc_ids.begin(); id_it!=bc_ids.end(); ++id_it)
01045               {
01046                 const boundary_id_type bc_id = *id_it;
01047                 if (bc_id != this->boundary_info->invalid_id)
01048                 new_mesh.boundary_info->add_side (new_elem,
01049                                                   s,
01050                                                   bc_id);
01051               }
01052           }
01053     } // end loop over elements
01054 
01055 
01056   // Prepare the new_mesh for use
01057   new_mesh.prepare_for_use(/*skip_renumber =*/false);
01058 
01059 }

void libMesh::SerialMesh::delete_elem ( Elem e  )  [virtual]

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 262 of file serial_mesh.C.

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

Referenced by insert_elem().

00263 {
00264   libmesh_assert(e);
00265 
00266   // Initialize an iterator to eventually point to the element we want to delete
00267   std::vector<Elem*>::iterator pos = _elements.end();
00268 
00269   // In many cases, e->id() gives us a clue as to where e
00270   // is located in the _elements vector.  Try that first
00271   // before trying the O(n_elem) search.
00272   libmesh_assert_less (e->id(), _elements.size());
00273 
00274   if (_elements[e->id()] == e)
00275     {
00276       // We found it!
00277       pos = _elements.begin();
00278       std::advance(pos, e->id());
00279     }
00280 
00281   else
00282     {
00283       // This search is O(n_elem)
00284       pos = std::find (_elements.begin(),
00285                        _elements.end(),
00286                        e);
00287     }
00288 
00289   // Huh? Element not in the vector?
00290   libmesh_assert (pos != _elements.end());
00291 
00292   // Remove the element from the BoundaryInfo object
00293   this->boundary_info->remove(e);
00294 
00295   // delete the element
00296   delete e;
00297 
00298   // explicitly NULL the pointer
00299   *pos = NULL;
00300 }

void libMesh::SerialMesh::delete_node ( Node n  )  [virtual]

Removes the Node n from the mesh.

Implements libMesh::MeshBase.

Definition at line 381 of file serial_mesh.C.

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

Referenced by stitch_meshes().

00382 {
00383   libmesh_assert(n);
00384   libmesh_assert_less (n->id(), _nodes.size());
00385 
00386   // Initialize an iterator to eventually point to the element we want
00387   // to delete
00388   std::vector<Node*>::iterator pos;
00389 
00390   // In many cases, e->id() gives us a clue as to where e
00391   // is located in the _elements vector.  Try that first
00392   // before trying the O(n_elem) search.
00393   if (_nodes[n->id()] == n)
00394     {
00395       pos = _nodes.begin();
00396       std::advance(pos, n->id());
00397     }
00398   else
00399     {
00400       pos = std::find (_nodes.begin(),
00401                        _nodes.end(),
00402                        n);
00403     }
00404 
00405   // Huh? Node not in the vector?
00406   libmesh_assert (pos != _nodes.end());
00407 
00408   // Delete the node from the BoundaryInfo object
00409   this->boundary_info->remove(n);
00410 
00411   // delete the node
00412   delete n;
00413 
00414   // explicitly NULL the pointer
00415   *pos = NULL;
00416 }

virtual void libMesh::MeshBase::delete_remote_elements (  )  [inline, virtual, inherited]

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

Reimplemented in libMesh::ParallelMesh.

Definition at line 136 of file mesh_base.h.

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

00136 {}

Elem * libMesh::SerialMesh::elem ( const dof_id_type  i  )  [virtual]

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 174 of file serial_mesh.C.

References _elements, and n_elem().

00175 {
00176   libmesh_assert_less (i, this->n_elem());
00177   libmesh_assert(_elements[i]);
00178   libmesh_assert_equal_to (_elements[i]->id(), i); // This will change soon
00179 
00180   return _elements[i];
00181 }

const Elem * libMesh::SerialMesh::elem ( const dof_id_type  i  )  const [virtual]

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 162 of file serial_mesh.C.

References _elements, and n_elem().

Referenced by stitch_meshes().

00163 {
00164   libmesh_assert_less (i, this->n_elem());
00165   libmesh_assert(_elements[i]);
00166   libmesh_assert_equal_to (_elements[i]->id(), i); // This will change soon
00167 
00168   return _elements[i];
00169 }

SerialMesh::const_element_iterator libMesh::SerialMesh::elements_begin (  )  const [virtual]

const Elem iterator accessor functions.

Implements libMesh::MeshBase.

Definition at line 260 of file serial_mesh_iterators.C.

References _elements.

00261 {
00262   Predicates::NotNull<const_elem_iterator_imp> p;
00263   return const_element_iterator(_elements.begin(), _elements.end(), p);
00264 }

SerialMesh::element_iterator libMesh::SerialMesh::elements_begin (  )  [virtual]

Elem iterator accessor functions.

Implements libMesh::MeshBase.

Definition at line 37 of file serial_mesh_iterators.C.

References _elements.

Referenced by stitch_meshes().

00038 {
00039   Predicates::NotNull<elem_iterator_imp> p;
00040   return element_iterator(_elements.begin(), _elements.end(), p);
00041 }

SerialMesh::const_element_iterator libMesh::SerialMesh::elements_end (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 710 of file serial_mesh_iterators.C.

References _elements.

00711 {
00712   Predicates::NotNull<const_elem_iterator_imp> p;
00713   return const_element_iterator(_elements.end(), _elements.end(), p);
00714 }

SerialMesh::element_iterator libMesh::SerialMesh::elements_end (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 483 of file serial_mesh_iterators.C.

References _elements.

Referenced by stitch_meshes().

00484 {
00485   Predicates::NotNull<elem_iterator_imp> p;
00486   return element_iterator(_elements.end(), _elements.end(), p);
00487 }

void libMesh::UnstructuredMesh::find_neighbors ( const bool  reset_remote_elements = false,
const bool  reset_current_list = true 
) [virtual, inherited]

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 205 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::MeshTools::libmesh_assert_valid_neighbors(), libMesh::Elem::n_children(), libMesh::MeshTools::n_levels(), libMesh::Elem::n_neighbors(), libMesh::Elem::neighbor(), libMesh::Elem::parent(), libMesh::MeshBase::processor_id(), libMesh::DofObject::processor_id(), libMesh::remote_elem, libMesh::Elem::set_neighbor(), libMesh::Elem::side(), libMesh::Elem::subactive(), and libMesh::Elem::which_child_am_i().

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

00207 {
00208   // We might actually want to run this on an empty mesh
00209   // (e.g. the boundary mesh for a nonexistant bcid!)
00210   // libmesh_assert_not_equal_to (this->n_nodes(), 0);
00211   // libmesh_assert_not_equal_to (this->n_elem(), 0);
00212 
00213   // This function must be run on all processors at once
00214   parallel_only();
00215 
00216   START_LOG("find_neighbors()", "Mesh");
00217 
00218   const element_iterator el_end = this->elements_end();
00219 
00220   //TODO:[BSK] This should be removed later?!
00221   if (reset_current_list)
00222     for (element_iterator el = this->elements_begin(); el != el_end; ++el)
00223       {
00224         Elem* e = *el;
00225         for (unsigned int s=0; s<e->n_neighbors(); s++)
00226           if (e->neighbor(s) != remote_elem ||
00227               reset_remote_elements)
00228             e->set_neighbor(s,NULL);
00229       }
00230 
00231   // Find neighboring elements by first finding elements
00232   // with identical side keys and then check to see if they
00233   // are neighbors
00234   {
00235     // data structures -- Use the hash_multimap if available
00236     typedef unsigned int                    key_type;
00237     typedef std::pair<Elem*, unsigned char> val_type;
00238     typedef std::pair<key_type, val_type>   key_val_pair;
00239 
00240     typedef LIBMESH_BEST_UNORDERED_MULTIMAP<key_type, val_type> map_type;
00241 
00242     // A map from side keys to corresponding elements & side numbers
00243     map_type side_to_elem_map;
00244 
00245 
00246 
00247     for (element_iterator el = this->elements_begin(); el != el_end; ++el)
00248       {
00249         Elem* element = *el;
00250 
00251         for (unsigned int ms=0; ms<element->n_neighbors(); ms++)
00252           {
00253           next_side:
00254             // If we haven't yet found a neighbor on this side, try.
00255             // Even if we think our neighbor is remote, that
00256             // information may be out of date.
00257             if (element->neighbor(ms) == NULL ||
00258                 element->neighbor(ms) == remote_elem)
00259               {
00260                 // Get the key for the side of this element
00261                 const unsigned int key = element->key(ms);
00262 
00263                 // Look for elements that have an identical side key
00264                 std::pair <map_type::iterator, map_type::iterator>
00265                   bounds = side_to_elem_map.equal_range(key);
00266 
00267                 // May be multiple keys, check all the possible
00268                 // elements which _might_ be neighbors.
00269                 if (bounds.first != bounds.second)
00270                   {
00271                     // Get the side for this element
00272                     const AutoPtr<Elem> my_side(element->side(ms));
00273 
00274                     // Look at all the entries with an equivalent key
00275                     while (bounds.first != bounds.second)
00276                       {
00277                         // Get the potential element
00278                         Elem* neighbor = bounds.first->second.first;
00279 
00280                         // Get the side for the neighboring element
00281                         const unsigned int ns = bounds.first->second.second;
00282                         const AutoPtr<Elem> their_side(neighbor->side(ns));
00283                         //libmesh_assert(my_side.get());
00284                         //libmesh_assert(their_side.get());
00285 
00286                         // If found a match with my side
00287                         //
00288                         // We need special tests here for 1D:
00289                         // since parents and children have an equal
00290                         // side (i.e. a node), we need to check
00291                         // ns != ms, and we also check level() to
00292                         // avoid setting our neighbor pointer to
00293                         // any of our neighbor's descendants
00294                         if( (*my_side == *their_side) &&
00295                             (element->level() == neighbor->level()) &&
00296                             ((_dim != 1) || (ns != ms)) )
00297                           {
00298                             // So share a side.  Is this a mixed pair
00299                             // of subactive and active/ancestor
00300                             // elements?
00301                             // If not, then we're neighbors.
00302                             // If so, then the subactive's neighbor is
00303 
00304                               if (element->subactive() ==
00305                                   neighbor->subactive())
00306                               {
00307                               // an element is only subactive if it has
00308                               // been coarsened but not deleted
00309                                 element->set_neighbor (ms,neighbor);
00310                                 neighbor->set_neighbor(ns,element);
00311                               }
00312                               else if (element->subactive())
00313                               {
00314                                 element->set_neighbor(ms,neighbor);
00315                               }
00316                               else if (neighbor->subactive())
00317                               {
00318                                 neighbor->set_neighbor(ns,element);
00319                               }
00320                               side_to_elem_map.erase (bounds.first);
00321 
00322                               // get out of this nested crap
00323                               goto next_side;
00324                           }
00325 
00326                         ++bounds.first;
00327                       }
00328                   }
00329 
00330                 // didn't find a match...
00331                 // Build the map entry for this element
00332                 key_val_pair kvp;
00333 
00334                 kvp.first         = key;
00335                 kvp.second.first  = element;
00336                 kvp.second.second = ms;
00337 
00338                 // use the lower bound as a hint for
00339                 // where to put it.
00340 #if defined(LIBMESH_HAVE_UNORDERED_MAP) || defined(LIBMESH_HAVE_TR1_UNORDERED_MAP) || defined(LIBMESH_HAVE_HASH_MAP) || defined(LIBMESH_HAVE_EXT_HASH_MAP)
00341                 side_to_elem_map.insert (kvp);
00342 #else
00343                 side_to_elem_map.insert (bounds.first,kvp);
00344 #endif
00345               }
00346           }
00347       }
00348   }
00349 
00350 #ifdef LIBMESH_ENABLE_AMR
00351 
00372   const unsigned int n_levels = MeshTools::n_levels(*this);
00373   for (unsigned int level = 1; level < n_levels; ++level)
00374     {
00375       element_iterator end = this->level_elements_end(level);
00376       for (element_iterator el = this->level_elements_begin(level);
00377            el != end; ++el)
00378         {
00379           Elem* current_elem = *el;
00380           libmesh_assert(current_elem);
00381           Elem* parent = current_elem->parent();
00382           libmesh_assert(parent);
00383           const unsigned int my_child_num = parent->which_child_am_i(current_elem);
00384 
00385           for (unsigned int s=0; s < current_elem->n_neighbors(); s++)
00386             {
00387               if (current_elem->neighbor(s) == NULL ||
00388                   (current_elem->neighbor(s) == remote_elem &&
00389                    parent->is_child_on_side(my_child_num, s)))
00390                 {
00391                   Elem *neigh = parent->neighbor(s);
00392 
00393                   // If neigh was refined and had non-subactive children
00394                   // made remote earlier, then a non-subactive elem should
00395                   // actually have one of those remote children as a
00396                   // neighbor
00397                   if (neigh && (neigh->ancestor()) && (!current_elem->subactive()))
00398                     {
00399 #ifdef DEBUG
00400                       // Let's make sure that "had children made remote"
00401                       // situation is actually the case
00402                       libmesh_assert(neigh->has_children());
00403                       bool neigh_has_remote_children = false;
00404                       for (unsigned int c = 0; c != neigh->n_children(); ++c)
00405                         {
00406                           if (neigh->child(c) == remote_elem)
00407                             neigh_has_remote_children = true;
00408                         }
00409                       libmesh_assert(neigh_has_remote_children);
00410 
00411                       // And let's double-check that we don't have
00412                       // a remote_elem neighboring a local element
00413                       libmesh_assert_not_equal_to (current_elem->processor_id(),
00414                                                   libMesh::processor_id());
00415 #endif // DEBUG
00416                       neigh = const_cast<RemoteElem*>(remote_elem);
00417                     }
00418 
00419                   current_elem->set_neighbor(s, neigh);
00420 #ifdef DEBUG
00421                   if (neigh != NULL && neigh != remote_elem)
00422                     // We ignore subactive elements here because
00423                     // we don't care about neighbors of subactive element.
00424                     if ((!neigh->active()) && (!current_elem->subactive()))
00425                       {
00426                         libMesh::err << "On processor " << libMesh::processor_id()
00427                                       << std::endl;
00428                         libMesh::err << "Bad element ID = " << current_elem->id()
00429                           << ", Side " << s << ", Bad neighbor ID = " << neigh->id() << std::endl;
00430                         libMesh::err << "Bad element proc_ID = " << current_elem->processor_id()
00431                           << ", Bad neighbor proc_ID = " << neigh->processor_id() << std::endl;
00432                         libMesh::err << "Bad element size = " << current_elem->hmin()
00433                           << ", Bad neighbor size = " << neigh->hmin() << std::endl;
00434                         libMesh::err << "Bad element center = " << current_elem->centroid()
00435                           << ", Bad neighbor center = " << neigh->centroid() << std::endl;
00436                         libMesh::err << "ERROR: "
00437                           << (current_elem->active()?"Active":"Ancestor")
00438                           << " Element at level "
00439                           << current_elem->level() << std::endl;
00440                         libMesh::err << "with "
00441                           << (parent->active()?"active":
00442                               (parent->subactive()?"subactive":"ancestor"))
00443                           << " parent share "
00444                           << (neigh->subactive()?"subactive":"ancestor")
00445                           << " neighbor at level " << neigh->level()
00446                           << std::endl;
00447                         GMVIO(*this).write ("bad_mesh.gmv");
00448                         libmesh_error();
00449                       }
00450 #endif // DEBUG
00451                 }
00452             }
00453         }
00454     }
00455 
00456 #endif // AMR
00457 
00458 
00459 #ifdef DEBUG
00460 MeshTools::libmesh_assert_valid_neighbors(*this);
00461 #endif
00462 
00463   STOP_LOG("find_neighbors()", "Mesh");
00464 }

void libMesh::SerialMesh::fix_broken_node_and_element_numbering (  )  [virtual]

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

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

Implements libMesh::MeshBase.

Definition at line 631 of file serial_mesh.C.

References _elements, and _nodes.

00632 {
00633    // Nodes first
00634   for (dof_id_type n=0; n<this->_nodes.size(); n++)
00635     if (this->_nodes[n] != NULL)
00636       this->_nodes[n]->set_id() = n;
00637 
00638   // Elements next
00639   for (dof_id_type e=0; e<this->_elements.size(); e++)
00640     if (this->_elements[e] != NULL)
00641       this->_elements[e]->set_id() = e;
00642 }

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

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

00407 {
00408   // This function is searching the *values* of the map (linear search)
00409   // We might want to make this more efficient...
00410   std::map<subdomain_id_type, std::string>::const_iterator
00411     iter = _block_id_to_name.begin(),
00412     end_iter = _block_id_to_name.end();
00413 
00414   for ( ; iter != end_iter; ++iter)
00415     {
00416       if (iter->second == name)
00417         return iter->first;
00418     }
00419 
00420   libMesh::err << "Block '" << name << "' does not exist in mesh" << std::endl;
00421   libmesh_error();
00422 }

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

Definition at line 270 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::MeshBase::n_processors(), libMesh::MeshBase::n_subdomains(), libMesh::n_threads(), libMesh::MeshBase::processor_id(), and libMesh::MeshBase::spatial_dimension().

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

00271 {
00272   std::ostringstream oss;
00273 
00274   oss << " Mesh Information:"                                  << '\n'
00275       << "  mesh_dimension()="    << this->mesh_dimension()    << '\n'
00276       << "  spatial_dimension()=" << this->spatial_dimension() << '\n'
00277       << "  n_nodes()="           << this->n_nodes()           << '\n'
00278       << "    n_local_nodes()="   << this->n_local_nodes()     << '\n'
00279       << "  n_elem()="            << this->n_elem()            << '\n'
00280       << "    n_local_elem()="    << this->n_local_elem()      << '\n'
00281 #ifdef LIBMESH_ENABLE_AMR
00282       << "    n_active_elem()="   << this->n_active_elem()     << '\n'
00283 #endif
00284       << "  n_subdomains()="      << this->n_subdomains()      << '\n'
00285       << "  n_partitions()="      << this->n_partitions()      << '\n'
00286       << "  n_processors()="      << libMesh::n_processors()   << '\n'
00287       << "  n_threads()="         << libMesh::n_threads()      << '\n'
00288       << "  processor_id()="      << this->processor_id()      << '\n';
00289 
00290   return oss.str();
00291 }

Elem * libMesh::SerialMesh::insert_elem ( Elem e  )  [virtual]

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

Implements libMesh::MeshBase.

Definition at line 243 of file serial_mesh.C.

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

00244 {
00245   dof_id_type eid = e->id();
00246   libmesh_assert_less (eid, _elements.size());
00247   Elem *oldelem = _elements[eid];
00248 
00249   if (oldelem)
00250     {
00251       libmesh_assert_equal_to (oldelem->id(), eid);
00252       this->delete_elem(oldelem);
00253     }
00254 
00255   _elements[e->id()] = e;
00256 
00257   return e;
00258 }

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

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

00116   { return _is_prepared; }

SerialMesh::const_element_iterator libMesh::SerialMesh::level_elements_begin ( const unsigned int  level  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 370 of file serial_mesh_iterators.C.

References _elements.

00371 {
00372   Predicates::Level<const_elem_iterator_imp> p(level);
00373   return const_element_iterator(_elements.begin(), _elements.end(), p);
00374 }

SerialMesh::element_iterator libMesh::SerialMesh::level_elements_begin ( const unsigned int  level  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 147 of file serial_mesh_iterators.C.

References _elements.

00148 {
00149   Predicates::Level<elem_iterator_imp> p(level);
00150   return element_iterator(_elements.begin(), _elements.end(), p);
00151 }

SerialMesh::const_element_iterator libMesh::SerialMesh::level_elements_end ( const unsigned int  level  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 820 of file serial_mesh_iterators.C.

References _elements.

00821 {
00822   Predicates::Level<const_elem_iterator_imp> p(level);
00823   return const_element_iterator(_elements.end(), _elements.end(), p);
00824 }

SerialMesh::element_iterator libMesh::SerialMesh::level_elements_end ( const unsigned int  level  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 593 of file serial_mesh_iterators.C.

References _elements.

00594 {
00595   Predicates::Level<elem_iterator_imp> p(level);
00596   return element_iterator(_elements.end(), _elements.end(), p);
00597 }

virtual void libMesh::MeshBase::libmesh_assert_valid_parallel_ids (  )  const [inline, virtual, inherited]

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

Reimplemented in libMesh::ParallelMesh.

Definition at line 670 of file mesh_base.h.

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

00670 {}

SerialMesh::const_element_iterator libMesh::SerialMesh::local_elements_begin (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 330 of file serial_mesh_iterators.C.

References _elements.

00331 {
00332   Predicates::Local<const_elem_iterator_imp> p;
00333   return const_element_iterator(_elements.begin(), _elements.end(), p);
00334 }

SerialMesh::element_iterator libMesh::SerialMesh::local_elements_begin (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 107 of file serial_mesh_iterators.C.

References _elements.

00108 {
00109   Predicates::Local<elem_iterator_imp> p;
00110   return element_iterator(_elements.begin(), _elements.end(), p);
00111 }

SerialMesh::const_element_iterator libMesh::SerialMesh::local_elements_end (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 780 of file serial_mesh_iterators.C.

References _elements.

00781 {
00782   Predicates::Local<const_elem_iterator_imp> p;
00783   return const_element_iterator(_elements.end(), _elements.end(), p);
00784 }

SerialMesh::element_iterator libMesh::SerialMesh::local_elements_end (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 553 of file serial_mesh_iterators.C.

References _elements.

00554 {
00555   Predicates::Local<elem_iterator_imp> p;
00556   return element_iterator(_elements.end(), _elements.end(), p);
00557 }

SerialMesh::const_element_iterator libMesh::SerialMesh::local_level_elements_begin ( const unsigned int  level  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 390 of file serial_mesh_iterators.C.

References _elements.

00391 {
00392   Predicates::LocalLevel<const_elem_iterator_imp> p(level);
00393   return const_element_iterator(_elements.begin(), _elements.end(), p);
00394 }

SerialMesh::element_iterator libMesh::SerialMesh::local_level_elements_begin ( const unsigned int  level  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 167 of file serial_mesh_iterators.C.

References _elements.

00168 {
00169   Predicates::LocalLevel<elem_iterator_imp> p(level);
00170   return element_iterator(_elements.begin(), _elements.end(), p);
00171 }

SerialMesh::const_element_iterator libMesh::SerialMesh::local_level_elements_end ( const unsigned int  level  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 840 of file serial_mesh_iterators.C.

References _elements.

00841 {
00842   Predicates::LocalLevel<const_elem_iterator_imp> p(level);
00843   return const_element_iterator(_elements.end(), _elements.end(), p);
00844 }

SerialMesh::element_iterator libMesh::SerialMesh::local_level_elements_end ( const unsigned int  level  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 613 of file serial_mesh_iterators.C.

References _elements.

00614 {
00615   Predicates::LocalLevel<elem_iterator_imp> p(level);
00616   return element_iterator(_elements.end(), _elements.end(), p);
00617 }

SerialMesh::const_node_iterator libMesh::SerialMesh::local_nodes_begin (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 992 of file serial_mesh_iterators.C.

References _nodes.

00993 {
00994   Predicates::Local<const_node_iterator_imp> p;
00995   return const_node_iterator(_nodes.begin(), _nodes.end(), p);
00996 }

SerialMesh::node_iterator libMesh::SerialMesh::local_nodes_begin (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 952 of file serial_mesh_iterators.C.

References _nodes.

00953 {
00954   Predicates::Local<node_iterator_imp> p;
00955   return node_iterator(_nodes.begin(), _nodes.end(), p);
00956 }

SerialMesh::const_node_iterator libMesh::SerialMesh::local_nodes_end (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 1072 of file serial_mesh_iterators.C.

References _nodes.

01073 {
01074   Predicates::Local<const_node_iterator_imp> p;
01075   return const_node_iterator(_nodes.end(), _nodes.end(), p);
01076 }

SerialMesh::node_iterator libMesh::SerialMesh::local_nodes_end (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 1032 of file serial_mesh_iterators.C.

References _nodes.

01033 {
01034   Predicates::Local<node_iterator_imp> p;
01035   return node_iterator(_nodes.end(), _nodes.end(), p);
01036 }

SerialMesh::const_element_iterator libMesh::SerialMesh::local_not_level_elements_begin ( const unsigned int  level  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 400 of file serial_mesh_iterators.C.

References _elements.

00401 {
00402   Predicates::LocalNotLevel<const_elem_iterator_imp> p(level);
00403   return const_element_iterator(_elements.begin(), _elements.end(), p);
00404 }

SerialMesh::element_iterator libMesh::SerialMesh::local_not_level_elements_begin ( const unsigned int  level  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 177 of file serial_mesh_iterators.C.

References _elements.

00178 {
00179   Predicates::LocalNotLevel<elem_iterator_imp> p(level);
00180   return element_iterator(_elements.begin(), _elements.end(), p);
00181 }

SerialMesh::const_element_iterator libMesh::SerialMesh::local_not_level_elements_end ( const unsigned int  level  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 850 of file serial_mesh_iterators.C.

References _elements.

00851 {
00852   Predicates::LocalNotLevel<const_elem_iterator_imp> p(level);
00853   return const_element_iterator(_elements.end(), _elements.end(), p);
00854 }

SerialMesh::element_iterator libMesh::SerialMesh::local_not_level_elements_end ( const unsigned int  level  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 623 of file serial_mesh_iterators.C.

References _elements.

00624 {
00625   Predicates::LocalNotLevel<elem_iterator_imp> p(level);
00626   return element_iterator(_elements.end(), _elements.end(), p);
00627 }

virtual dof_id_type libMesh::SerialMesh::max_elem_id (  )  const [inline, virtual]

Returns a number greater than or equal to the maximum element id in the mesh.

Implements libMesh::MeshBase.

Definition at line 112 of file serial_mesh.h.

References _elements.

00113   { return libmesh_cast_int<dof_id_type>(_elements.size()); }

virtual dof_id_type libMesh::SerialMesh::max_node_id (  )  const [inline, virtual]

Returns a number greater than or equal to the maximum node id in the mesh.

Implements libMesh::MeshBase.

Definition at line 98 of file serial_mesh.h.

References _nodes.

00099   { return libmesh_cast_int<dof_id_type>(_nodes.size()); }

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

Definition at line 144 of file mesh_base.h.

References libMesh::MeshBase::_dim.

Referenced by libMesh::ExactSolution::_compute_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::ExactErrorEstimator::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::PointLocatorTree::init(), libMesh::LaplaceMeshSmoother::init(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_discontinuous(), libMesh::FEInterface::n_vec_dim(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::BoundaryProjectSolution::operator()(), libMesh::ProjectSolution::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::MeshFunction::operator()(), libMesh::MeshBase::prepare_for_use(), libMesh::VTKIO::read(), libMesh::Nemesis_IO::read(), libMesh::GMVIO::read(), libMesh::ExodusII_IO::read(), libMesh::System::read_header(), libMesh::UNVIO::read_implementation(), libMesh::LegacyXdrIO::read_mesh(), libMesh::GmshIO::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::EnsightIO::write_scalar_ascii(), libMesh::GnuPlotIO::write_solution(), libMesh::DivaIO::write_stream(), and libMesh::EnsightIO::write_vector_ascii().

00145   { return static_cast<unsigned int>(_dim); }

dof_id_type libMesh::SerialMesh::n_active_elem (  )  const [virtual]

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

Implements libMesh::MeshBase.

Definition at line 914 of file serial_mesh.C.

References active_elements_begin(), and active_elements_end().

00915 {
00916   return static_cast<dof_id_type>(std::distance (this->active_elements_begin(),
00917                                                  this->active_elements_end()));
00918 }

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

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

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

00232 {
00233   libmesh_assert_less (proc_id, libMesh::n_processors());
00234   return static_cast<dof_id_type>(std::distance (this->active_pid_elements_begin(proc_id),
00235                                                  this->active_pid_elements_end  (proc_id)));
00236 }

dof_id_type libMesh::MeshBase::n_active_local_elem (  )  const [inline, inherited]
dof_id_type libMesh::MeshBase::n_active_sub_elem (  )  const [inherited]

Same, but only counts active elements.

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

00256 {
00257   dof_id_type ne=0;
00258 
00259   const_element_iterator       el  = this->active_elements_begin();
00260   const const_element_iterator end = this->active_elements_end();
00261 
00262   for (; el!=end; ++el)
00263     ne += (*el)->n_sub_elem();
00264 
00265   return ne;
00266 }

virtual dof_id_type libMesh::SerialMesh::n_elem (  )  const [inline, virtual]

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 104 of file serial_mesh.h.

References _elements.

Referenced by elem(), query_elem(), and stitch_meshes().

00105   { return libmesh_cast_int<dof_id_type>(_elements.size()); }

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

References libMesh::DofObject::invalid_processor_id, libMesh::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().

00219 {
00220   // We're either counting a processor's elements or unpartitioned
00221   // elements
00222   libmesh_assert (proc_id < libMesh::n_processors() ||
00223           proc_id == DofObject::invalid_processor_id);
00224 
00225   return static_cast<dof_id_type>(std::distance (this->pid_elements_begin(proc_id),
00226                                                  this->pid_elements_end  (proc_id)));
00227 }

dof_id_type libMesh::MeshBase::n_local_elem (  )  const [inline, inherited]

Returns the number of elements on the local processor.

Definition at line 260 of file mesh_base.h.

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

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

00261   { return this->n_elem_on_proc (libMesh::processor_id()); }

dof_id_type libMesh::MeshBase::n_local_nodes (  )  const [inline, inherited]

Returns the number of nodes on the local processor.

Definition at line 186 of file mesh_base.h.

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

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

00187   { return this->n_nodes_on_proc (libMesh::processor_id()); }

virtual dof_id_type libMesh::SerialMesh::n_nodes (  )  const [inline, virtual]

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 92 of file serial_mesh.h.

References _nodes.

Referenced by node(), node_ptr(), point(), query_node_ptr(), and stitch_meshes().

00093   { return libmesh_cast_int<dof_id_type>(_nodes.size()); }

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

References libMesh::DofObject::invalid_processor_id, libMesh::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().

00206 {
00207   // We're either counting a processor's nodes or unpartitioned
00208   // nodes
00209   libmesh_assert (proc_id < libMesh::n_processors() ||
00210           proc_id == DofObject::invalid_processor_id);
00211 
00212   return static_cast<dof_id_type>(std::distance (this->pid_nodes_begin(proc_id),
00213                                                  this->pid_nodes_end  (proc_id)));
00214 }

unsigned int libMesh::MeshBase::n_partitions (  )  const [inline, inherited]

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

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

00544   { return _n_parts; }

processor_id_type libMesh::MeshBase::n_processors (  )  const [inline, inherited]
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 240 of file mesh_base.C.

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

00241 {
00242   dof_id_type ne=0;
00243 
00244   const_element_iterator       el  = this->elements_begin();
00245   const const_element_iterator end = this->elements_end();
00246 
00247   for (; el!=end; ++el)
00248     ne += (*el)->n_sub_elem();
00249 
00250   return ne;
00251 }

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

References libMesh::MeshBase::subdomain_ids().

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

00191 {
00192   // This requires an inspection on every processor
00193   parallel_only();
00194 
00195   std::set<subdomain_id_type> ids;
00196 
00197   this->subdomain_ids (ids);
00198 
00199   return ids.size();
00200 }

dof_id_type libMesh::MeshBase::n_unpartitioned_elem (  )  const [inline, inherited]

Returns the number of elements owned by no processor.

Definition at line 266 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 [inline, inherited]

Returns the number of nodes owned by no processor.

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

Node & libMesh::SerialMesh::node ( const dof_id_type  i  )  [virtual]

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 93 of file serial_mesh.C.

References _nodes, n_nodes(), and libMesh::out.

00094 {
00095   if (i >= this->n_nodes())
00096     {
00097       libMesh::out << " i=" << i
00098                     << ", n_nodes()=" << this->n_nodes()
00099                     << std::endl;
00100       libmesh_error();
00101     }
00102 
00103   libmesh_assert_less (i, this->n_nodes());
00104   libmesh_assert(_nodes[i]);
00105   libmesh_assert_equal_to (_nodes[i]->id(), i); // This will change soon
00106 
00107   return (*_nodes[i]);
00108 }

const Node & libMesh::SerialMesh::node ( const dof_id_type  i  )  const [virtual]

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 80 of file serial_mesh.C.

References _nodes, and n_nodes().

Referenced by stitch_meshes().

00081 {
00082   libmesh_assert_less (i, this->n_nodes());
00083   libmesh_assert(_nodes[i]);
00084   libmesh_assert_equal_to (_nodes[i]->id(), i); // This will change soon
00085 
00086   return (*_nodes[i]);
00087 }

Node * libMesh::SerialMesh::node_ptr ( const dof_id_type  i  )  [virtual]

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 124 of file serial_mesh.C.

References _nodes, and n_nodes().

00125 {
00126   libmesh_assert_less (i, this->n_nodes());
00127   libmesh_assert(_nodes[i]);
00128   libmesh_assert_equal_to (_nodes[i]->id(), i); // This will change soon
00129 
00130   return _nodes[i];
00131 }

const Node * libMesh::SerialMesh::node_ptr ( const dof_id_type  i  )  const [virtual]

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 112 of file serial_mesh.C.

References _nodes, and n_nodes().

Referenced by stitch_meshes().

00113 {
00114   libmesh_assert_less (i, this->n_nodes());
00115   libmesh_assert(_nodes[i]);
00116   libmesh_assert_equal_to (_nodes[i]->id(), i); // This will change soon
00117 
00118   return _nodes[i];
00119 }

SerialMesh::const_node_iterator libMesh::SerialMesh::nodes_begin (  )  const [virtual]

const Node iterator accessor functions.

Implements libMesh::MeshBase.

Definition at line 972 of file serial_mesh_iterators.C.

References _nodes.

00973 {
00974   Predicates::NotNull<const_node_iterator_imp> p;
00975   return const_node_iterator(_nodes.begin(), _nodes.end(), p);
00976 }

SerialMesh::node_iterator libMesh::SerialMesh::nodes_begin (  )  [virtual]

non-const Node iterator accessor functions.

Implements libMesh::MeshBase.

Definition at line 932 of file serial_mesh_iterators.C.

References _nodes.

Referenced by stitch_meshes().

00933 {
00934   Predicates::NotNull<node_iterator_imp> p;
00935   return node_iterator(_nodes.begin(), _nodes.end(), p);
00936 }

SerialMesh::const_node_iterator libMesh::SerialMesh::nodes_end (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 1052 of file serial_mesh_iterators.C.

References _nodes.

01053 {
01054   Predicates::NotNull<const_node_iterator_imp> p;
01055   return const_node_iterator(_nodes.end(), _nodes.end(), p);
01056 }

SerialMesh::node_iterator libMesh::SerialMesh::nodes_end (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 1012 of file serial_mesh_iterators.C.

References _nodes.

Referenced by stitch_meshes().

01013 {
01014   Predicates::NotNull<node_iterator_imp> p;
01015   return node_iterator(_nodes.end(), _nodes.end(), p);
01016 }

SerialMesh::const_element_iterator libMesh::SerialMesh::not_active_elements_begin (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 280 of file serial_mesh_iterators.C.

References _elements.

00281 {
00282   Predicates::NotActive<const_elem_iterator_imp> p;
00283   return const_element_iterator(_elements.begin(), _elements.end(), p);
00284 }

SerialMesh::element_iterator libMesh::SerialMesh::not_active_elements_begin (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 57 of file serial_mesh_iterators.C.

References _elements.

00058 {
00059   Predicates::NotActive<elem_iterator_imp> p;
00060   return element_iterator(_elements.begin(), _elements.end(), p);
00061 }

SerialMesh::const_element_iterator libMesh::SerialMesh::not_active_elements_end (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 730 of file serial_mesh_iterators.C.

References _elements.

00731 {
00732   Predicates::NotActive<const_elem_iterator_imp> p;
00733   return const_element_iterator(_elements.end(), _elements.end(), p);
00734 }

SerialMesh::element_iterator libMesh::SerialMesh::not_active_elements_end (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 503 of file serial_mesh_iterators.C.

References _elements.

00504 {
00505   Predicates::NotActive<elem_iterator_imp> p;
00506   return element_iterator(_elements.end(), _elements.end(), p);
00507 }

SerialMesh::const_element_iterator libMesh::SerialMesh::not_ancestor_elements_begin (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 300 of file serial_mesh_iterators.C.

References _elements.

00301 {
00302   Predicates::Ancestor<const_elem_iterator_imp> p;
00303   return const_element_iterator(_elements.begin(), _elements.end(), p);
00304 }

SerialMesh::element_iterator libMesh::SerialMesh::not_ancestor_elements_begin (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 77 of file serial_mesh_iterators.C.

References _elements.

00078 {
00079   Predicates::Ancestor<elem_iterator_imp> p;
00080   return element_iterator(_elements.begin(), _elements.end(), p);
00081 }

SerialMesh::const_element_iterator libMesh::SerialMesh::not_ancestor_elements_end (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 750 of file serial_mesh_iterators.C.

References _elements.

00751 {
00752   Predicates::Ancestor<const_elem_iterator_imp> p;
00753   return const_element_iterator(_elements.end(), _elements.end(), p);
00754 }

SerialMesh::element_iterator libMesh::SerialMesh::not_ancestor_elements_end (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 523 of file serial_mesh_iterators.C.

References _elements.

00524 {
00525   Predicates::Ancestor<elem_iterator_imp> p;
00526   return element_iterator(_elements.end(), _elements.end(), p);
00527 }

SerialMesh::const_element_iterator libMesh::SerialMesh::not_level_elements_begin ( const unsigned int  level  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 380 of file serial_mesh_iterators.C.

References _elements.

00381 {
00382   Predicates::NotLevel<const_elem_iterator_imp> p(level);
00383   return const_element_iterator(_elements.begin(), _elements.end(), p);
00384 }

SerialMesh::element_iterator libMesh::SerialMesh::not_level_elements_begin ( const unsigned int  level  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 157 of file serial_mesh_iterators.C.

References _elements.

00158 {
00159   Predicates::NotLevel<elem_iterator_imp> p(level);
00160   return element_iterator(_elements.begin(), _elements.end(), p);
00161 }

SerialMesh::const_element_iterator libMesh::SerialMesh::not_level_elements_end ( const unsigned int  level  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 830 of file serial_mesh_iterators.C.

References _elements.

00831 {
00832   Predicates::NotLevel<const_elem_iterator_imp> p(level);
00833   return const_element_iterator(_elements.end(), _elements.end(), p);
00834 }

SerialMesh::element_iterator libMesh::SerialMesh::not_level_elements_end ( const unsigned int  level  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 603 of file serial_mesh_iterators.C.

References _elements.

00604 {
00605   Predicates::NotLevel<elem_iterator_imp> p(level);
00606   return element_iterator(_elements.end(), _elements.end(), p);
00607 }

SerialMesh::const_element_iterator libMesh::SerialMesh::not_local_elements_begin (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 340 of file serial_mesh_iterators.C.

References _elements.

00341 {
00342   Predicates::NotLocal<const_elem_iterator_imp> p;
00343   return const_element_iterator(_elements.begin(), _elements.end(), p);
00344 }

SerialMesh::element_iterator libMesh::SerialMesh::not_local_elements_begin (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 117 of file serial_mesh_iterators.C.

References _elements.

00118 {
00119   Predicates::NotLocal<elem_iterator_imp> p;
00120   return element_iterator(_elements.begin(), _elements.end(), p);
00121 }

SerialMesh::const_element_iterator libMesh::SerialMesh::not_local_elements_end (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 790 of file serial_mesh_iterators.C.

References _elements.

00791 {
00792   Predicates::NotLocal<const_elem_iterator_imp> p;
00793   return const_element_iterator(_elements.end(), _elements.end(), p);
00794 }

SerialMesh::element_iterator libMesh::SerialMesh::not_local_elements_end (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 563 of file serial_mesh_iterators.C.

References _elements.

00564 {
00565   Predicates::NotLocal<elem_iterator_imp> p;
00566   return element_iterator(_elements.end(), _elements.end(), p);
00567 }

SerialMesh::const_element_iterator libMesh::SerialMesh::not_subactive_elements_begin (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 320 of file serial_mesh_iterators.C.

References _elements.

00321 {
00322   Predicates::NotSubActive<const_elem_iterator_imp> p;
00323   return const_element_iterator(_elements.begin(), _elements.end(), p);
00324 }

SerialMesh::element_iterator libMesh::SerialMesh::not_subactive_elements_begin (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 97 of file serial_mesh_iterators.C.

References _elements.

00098 {
00099   Predicates::NotSubActive<elem_iterator_imp> p;
00100   return element_iterator(_elements.begin(), _elements.end(), p);
00101 }

SerialMesh::const_element_iterator libMesh::SerialMesh::not_subactive_elements_end (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 770 of file serial_mesh_iterators.C.

References _elements.

00771 {
00772   Predicates::NotSubActive<const_elem_iterator_imp> p;
00773   return const_element_iterator(_elements.end(), _elements.end(), p);
00774 }

SerialMesh::element_iterator libMesh::SerialMesh::not_subactive_elements_end (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 543 of file serial_mesh_iterators.C.

References _elements.

00544 {
00545   Predicates::NotSubActive<elem_iterator_imp> p;
00546   return element_iterator(_elements.end(), _elements.end(), p);
00547 }

virtual dof_id_type libMesh::SerialMesh::parallel_n_elem (  )  const [inline, virtual]

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 107 of file serial_mesh.h.

References _elements.

00108   { return libmesh_cast_int<dof_id_type>(_elements.size()); }

virtual dof_id_type libMesh::SerialMesh::parallel_n_nodes (  )  const [inline, virtual]

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 95 of file serial_mesh.h.

References _nodes.

00096   { return libmesh_cast_int<dof_id_type>(_nodes.size()); }

void libMesh::MeshBase::partition ( const unsigned int  n_parts = libMesh::n_processors()  )  [virtual, inherited]

Call the default partitioner (currently metis_partition()).

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

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

00309 {
00310   // NULL partitioner means don't partition
00311   // Non-serial meshes aren't ready for partitioning yet.
00312   if(!skip_partitioning() && 
00313      partitioner().get() && 
00314      this->is_serial())
00315   {
00316     partitioner()->partition (*this, n_parts);
00317   }
00318   else
00319   {
00320     // Make sure locally cached partition count
00321     this->recalculate_n_partitions();
00322 
00323     // Make sure any other locally cached data is correct
00324     this->update_post_partitioning();
00325   }
00326 }

virtual AutoPtr<Partitioner>& libMesh::MeshBase::partitioner (  )  [inline, virtual, inherited]
SerialMesh::const_element_iterator libMesh::SerialMesh::pid_elements_begin ( const processor_id_type  proc_id  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 410 of file serial_mesh_iterators.C.

References _elements.

00411 {
00412   Predicates::PID<const_elem_iterator_imp> p(proc_id);
00413   return const_element_iterator(_elements.begin(), _elements.end(), p);
00414 }

SerialMesh::element_iterator libMesh::SerialMesh::pid_elements_begin ( const processor_id_type  proc_id  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 187 of file serial_mesh_iterators.C.

References _elements.

Referenced by unpartitioned_elements_begin().

00188 {
00189   Predicates::PID<elem_iterator_imp> p(proc_id);
00190   return element_iterator(_elements.begin(), _elements.end(), p);
00191 }

SerialMesh::const_element_iterator libMesh::SerialMesh::pid_elements_end ( const processor_id_type  proc_id  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 860 of file serial_mesh_iterators.C.

References _elements.

00861 {
00862   Predicates::PID<const_elem_iterator_imp> p(proc_id);
00863   return const_element_iterator(_elements.end(), _elements.end(), p);
00864 }

SerialMesh::element_iterator libMesh::SerialMesh::pid_elements_end ( const processor_id_type  proc_id  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 633 of file serial_mesh_iterators.C.

References _elements.

Referenced by unpartitioned_elements_end().

00634 {
00635   Predicates::PID<elem_iterator_imp> p(proc_id);
00636   return element_iterator(_elements.end(), _elements.end(), p);
00637 }

SerialMesh::const_node_iterator libMesh::SerialMesh::pid_nodes_begin ( const processor_id_type  proc_id  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 1002 of file serial_mesh_iterators.C.

References _nodes.

01003 {
01004   Predicates::PID<const_node_iterator_imp> p(proc_id);
01005   return const_node_iterator(_nodes.begin(), _nodes.end(), p);
01006 }

SerialMesh::node_iterator libMesh::SerialMesh::pid_nodes_begin ( const processor_id_type  proc_id  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 962 of file serial_mesh_iterators.C.

References _nodes.

00963 {
00964   Predicates::PID<node_iterator_imp> p(proc_id);
00965   return node_iterator(_nodes.begin(), _nodes.end(), p);
00966 }

SerialMesh::const_node_iterator libMesh::SerialMesh::pid_nodes_end ( const processor_id_type  proc_id  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 1082 of file serial_mesh_iterators.C.

References _nodes.

01083 {
01084   Predicates::PID<const_node_iterator_imp> p(proc_id);
01085   return const_node_iterator(_nodes.end(), _nodes.end(), p);
01086 }

SerialMesh::node_iterator libMesh::SerialMesh::pid_nodes_end ( const processor_id_type  proc_id  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 1042 of file serial_mesh_iterators.C.

References _nodes.

01043 {
01044   Predicates::PID<node_iterator_imp> p(proc_id);
01045   return node_iterator(_nodes.end(), _nodes.end(), p);
01046 }

const Point & libMesh::SerialMesh::point ( const dof_id_type  i  )  const [virtual]

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 67 of file serial_mesh.C.

References _nodes, and n_nodes().

00068 {
00069   libmesh_assert_less (i, this->n_nodes());
00070   libmesh_assert(_nodes[i]);
00071   libmesh_assert_equal_to (_nodes[i]->id(), i); // This will change soon
00072 
00073   return (*_nodes[i]);
00074 }

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

References libMesh::MeshBase::_point_locator, libMesh::PointLocatorBase::build(), libMesh::AutoPtr< Tp >::get(), libMesh::Threads::in_threads, libMesh::AutoPtr< Tp >::reset(), and libMeshEnums::TREE.

00349 {
00350   libmesh_deprecated();
00351 
00352   if (_point_locator.get() == NULL)
00353     {
00354       // PointLocator construction may not be safe within threads
00355       libmesh_assert(!Threads::in_threads);
00356 
00357       _point_locator.reset (PointLocatorBase::build(TREE, *this).release());
00358     }
00359 
00360   return *_point_locator;
00361 }

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

References libMesh::MeshBase::_is_prepared, libMesh::MeshBase::_skip_renumber_nodes_and_elements, libMesh::MeshBase::allow_renumbering(), libMesh::MeshBase::clear_point_locator(), libMesh::CommWorld, libMesh::MeshBase::delete_remote_elements(), libMesh::MeshBase::find_neighbors(), libMesh::MeshBase::is_serial(), 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::Communicator::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::UnstructuredMesh::read(), libMesh::GMVIO::read(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::MeshRefinement::refine_elements(), stitch_meshes(), libMesh::BoundaryInfo::sync(), libMesh::MeshRefinement::uniformly_coarsen(), and libMesh::MeshRefinement::uniformly_refine().

00091 {
00092   parallel_only();
00093 
00094   // A distributed mesh may have processors with no elements (or
00095   // processors with no elements of higher dimension, if we ever
00096   // support mixed-dimension meshes), but we want consistent
00097   // mesh_dimension anyways.
00098   libmesh_assert(CommWorld.verify(this->is_serial()));
00099 
00100   if (!this->is_serial())
00101     {
00102       unsigned int dim = this->mesh_dimension();
00103       CommWorld.max(dim);
00104       this->set_mesh_dimension(dim);
00105     }
00106 
00107   // Renumber the nodes and elements so that they in contiguous
00108   // blocks.  By default, _skip_renumber_nodes_and_elements is false.
00109   //
00110   // We may currently change that by passing
00111   // skip_renumber_nodes_and_elements==true to this function, but we
00112   // should use the allow_renumbering() accessor instead.
00113   //
00114   // Instances where you if prepare_for_use() should not renumber the nodes
00115   // and elements include reading in e.g. an xda/r or gmv file. In
00116   // this case, the ordering of the nodes may depend on an accompanying
00117   // solution, and the node ordering cannot be changed.
00118 
00119   if (skip_renumber_nodes_and_elements)
00120     {
00121       libmesh_deprecated();
00122       this->allow_renumbering(false);
00123     }
00124 
00125   // Mesh modification operations might not leave us with consistent
00126   // id counts, but our partitioner might need that consistency.
00127   if(!_skip_renumber_nodes_and_elements)
00128     this->renumber_nodes_and_elements();
00129   else
00130     this->update_parallel_id_counts();
00131 
00132   // Let all the elements find their neighbors
00133   this->find_neighbors();
00134 
00135   // Partition the mesh.
00136   this->partition();
00137 
00138   // If we're using ParallelMesh, we'll want it parallelized.
00139   this->delete_remote_elements();
00140 
00141   if(!_skip_renumber_nodes_and_elements)
00142     this->renumber_nodes_and_elements();
00143 
00144   // Reset our PointLocator.  This needs to happen any time the elements
00145   // in the underlying elements in the mesh have changed, so we do it here.
00146   this->clear_point_locator();
00147 
00148   // The mesh is now prepared for use.
00149   _is_prepared = true;
00150 }

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

Prints relevant information about the mesh.

Definition at line 294 of file mesh_base.C.

References libMesh::MeshBase::get_info().

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

00295 {
00296   os << this->get_info()
00297      << std::endl;
00298 }

Elem * libMesh::SerialMesh::query_elem ( const dof_id_type  i  )  [virtual]

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 199 of file serial_mesh.C.

References _elements, and n_elem().

00200 {
00201   if (i >= this->n_elem())
00202     return NULL;
00203   libmesh_assert (_elements[i] == NULL ||
00204                   _elements[i]->id() == i); // This will change soon
00205 
00206   return _elements[i];
00207 }

const Elem * libMesh::SerialMesh::query_elem ( const dof_id_type  i  )  const [virtual]

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 186 of file serial_mesh.C.

References _elements, and n_elem().

00187 {
00188   if (i >= this->n_elem())
00189     return NULL;
00190   libmesh_assert (_elements[i] == NULL ||
00191                   _elements[i]->id() == i); // This will change soon
00192 
00193   return _elements[i];
00194 }

Node * libMesh::SerialMesh::query_node_ptr ( const dof_id_type  i  )  [virtual]

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 149 of file serial_mesh.C.

References _nodes, and n_nodes().

00150 {
00151   if (i >= this->n_nodes())
00152     return NULL;
00153   libmesh_assert (_nodes[i] == NULL ||
00154                   _nodes[i]->id() == i); // This will change soon
00155 
00156   return _nodes[i];
00157 }

const Node * libMesh::SerialMesh::query_node_ptr ( const dof_id_type  i  )  const [virtual]

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 136 of file serial_mesh.C.

References _nodes, and n_nodes().

00137 {
00138   if (i >= this->n_nodes())
00139     return NULL;
00140   libmesh_assert (_nodes[i] == NULL ||
00141                   _nodes[i]->id() == i); // This will change soon
00142 
00143   return _nodes[i];
00144 }

void libMesh::UnstructuredMesh::read ( const std::string &  name,
MeshData mesh_data = NULL,
bool  skip_renumber_nodes_and_elements = false 
) [virtual, inherited]

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

References libMesh::MeshBase::allow_renumbering(), libMesh::XdrIO::binary(), libMesh::err, libMesh::XdrIO::legacy(), libMesh::MeshBase::n_processors(), libMesh::MeshBase::prepare_for_use(), libMesh::processor_id(), libMesh::MeshBase::processor_id(), and libMesh::XdrIO::read().

00471 {
00472   // See if the file exists.  Perform this check on all processors
00473   // so that the code is terminated properly in the case that the
00474   // file does not exist.
00475 
00476   // For Nemesis files, the name we try to read will have suffixes
00477   // identifying processor rank
00478   if (name.rfind(".nem") + 4 == name.size() ||
00479       name.rfind(".n") + 2 == name.size())
00480     {
00481       std::ostringstream full_name;
00482       full_name << name << '.' << libMesh::n_processors() << '.' << libMesh::processor_id();
00483 
00484       std::ifstream in (full_name.str().c_str());
00485 
00486       if (!in.good())
00487         {
00488           libMesh::err << "ERROR: cannot locate specified file:\n\t"
00489                         << full_name.str()
00490                         << std::endl;
00491           libmesh_error();
00492         }
00493     }
00494   else
00495     {
00496       std::ifstream in (name.c_str());
00497 
00498       if (!in.good())
00499         {
00500           libMesh::err << "ERROR: cannot locate specified file:\n\t"
00501                         << name
00502                         << std::endl;
00503           libmesh_error();
00504         }
00505     }
00506 
00507   // Set the skip_renumber_nodes_and_elements flag on all processors.
00508   // This ensures that renumber_nodes_and_elements is *not* called
00509   // during prepare_for_use() for certain types of mesh files.
00510   // This is required in cases where there is an associated solution
00511   // file which expects a certain ordering of the nodes.
00512   if(name.rfind(".gmv")+4==name.size())
00513     {
00514       skip_renumber_nodes_and_elements =  true;
00515     }
00516 
00517   // Look for parallel formats first
00518   if (is_parallel_file_format(name))
00519     {
00520       // no need to handle bz2 files here -- the Xdr class does that.
00521       if ((name.rfind(".xda") < name.size()) ||
00522           (name.rfind(".xdr") < name.size()))
00523         {
00524           XdrIO xdr_io(*this);
00525 
00526           // .xda* ==> bzip2/gzip/ASCII flavors
00527           if (name.rfind(".xda") < name.size())
00528             {
00529               xdr_io.binary() = false;
00530               xdr_io.read (name);
00531             }
00532           else // .xdr* ==> true binary XDR file
00533             {
00534               xdr_io.binary() = true;
00535               xdr_io.read (name);
00536             }
00537 
00538           // The xdr_io object gets constructed with legacy() == false.
00539           // if legacy() == true then it means that a legacy file was detected and
00540           // thus processor 0 performed the read. We therefore need to broadcast the
00541           // mesh.  Further, for this flavor of mesh solution data ordering is tied
00542           // to the node ordering, so we better not reorder the nodes!
00543           if (xdr_io.legacy())
00544             {
00545               this->allow_renumbering(false);
00546               MeshCommunication().broadcast(*this);
00547             }
00548 
00549           // libHilbert-enabled libMesh builds should construct files
00550           // with a canonical node ordering, which libHilbert-enabled
00551           // builds will be able to read in again regardless of any
00552           // renumbering.  So in that case we're free to renumber.
00553           // However, if either the writer or the reader of this file
00554           // don't have libHilbert, then we'll have to skip
00555           // renumbering because we need the numbering to remain
00556           // consistent with any solution file we read in next.
00557 #ifdef LIBMESH_HAVE_LIBHILBERT
00558           // if (!xdr_io.libhilbert_ordering())
00559           //   skip_renumber_nodes_and_elements = true;
00560 #else
00561           this->allow_renumbering(false);
00562 #endif
00563         }
00564       else if (name.rfind(".nem") < name.size() ||
00565                name.rfind(".n")   < name.size())
00566         Nemesis_IO(*this).read (name);
00567 
00568     }
00569 
00570   // Serial mesh formats
00571   else
00572     {
00573       START_LOG("read()", "Mesh");
00574 
00575       // Read the file based on extension.  Only processor 0
00576       // needs to read the mesh.  It will then broadcast it and
00577       // the other processors will pick it up
00578       if (libMesh::processor_id() == 0)
00579         {
00580           std::ostringstream pid_suffix;
00581           pid_suffix << '_' << getpid();
00582           // Nasty hack for reading/writing zipped files
00583           std::string new_name = name;
00584           if (name.size() - name.rfind(".bz2") == 4)
00585             {
00586 #ifdef LIBMESH_HAVE_BZIP
00587               new_name.erase(new_name.end() - 4, new_name.end());
00588               new_name += pid_suffix.str();
00589               std::string system_string = "bunzip2 -f -k -c ";
00590               system_string += name + " > " + new_name;
00591               START_LOG("system(bunzip2)", "Mesh");
00592               if (std::system(system_string.c_str()))
00593                 libmesh_file_error(system_string);
00594               STOP_LOG("system(bunzip2)", "Mesh");
00595 #else
00596               libMesh::err << "ERROR: need bzip2/bunzip2 to open .bz2 file "
00597                            << name << std::endl;
00598               libmesh_error();
00599 #endif
00600             }
00601           else if (name.size() - name.rfind(".xz") == 3)
00602             {
00603 #ifdef LIBMESH_HAVE_XZ
00604               new_name.erase(new_name.end() - 3, new_name.end());
00605               new_name += pid_suffix.str();
00606               std::string system_string = "xz -f -d -k -c ";
00607               system_string += name + " > " + new_name;
00608               START_LOG("system(xz -d)", "XdrIO");
00609               if (std::system(system_string.c_str()))
00610                 libmesh_file_error(system_string);
00611               STOP_LOG("system(xz -d)", "XdrIO");
00612 #else
00613               libMesh::err << "ERROR: need xz to open .xz file "
00614                            << name << std::endl;
00615               libmesh_error();
00616 #endif
00617             }
00618 
00619           if (new_name.rfind(".mat") < new_name.size())
00620             MatlabIO(*this).read(new_name);
00621 
00622           else if (new_name.rfind(".ucd") < new_name.size())
00623             UCDIO(*this).read (new_name);
00624 
00625           else if ((new_name.rfind(".off")  < new_name.size()) ||
00626                    (new_name.rfind(".ogl")  < new_name.size()) ||
00627                    (new_name.rfind(".oogl") < new_name.size()))
00628             OFFIO(*this).read (new_name);
00629 
00630           else if (new_name.rfind(".mgf") < new_name.size())
00631             LegacyXdrIO(*this,true).read_mgf (new_name);
00632 
00633           else if (new_name.rfind(".unv") < new_name.size())
00634             {
00635               if (mesh_data == NULL)
00636                 {
00637                   libMesh::err << "Error! You must pass a "
00638                                 << "valid MeshData pointer to "
00639                                 << "read UNV files!" << std::endl;
00640                   libmesh_error();
00641                 }
00642               UNVIO(*this, *mesh_data).read (new_name);
00643             }
00644 
00645           else if ((new_name.rfind(".node")  < new_name.size()) ||
00646                    (new_name.rfind(".ele")   < new_name.size()))
00647             TetGenIO(*this,mesh_data).read (new_name);
00648 
00649           else if (new_name.rfind(".exd") < new_name.size() ||
00650                    new_name.rfind(".e") < new_name.size())
00651             ExodusII_IO(*this).read (new_name);
00652 
00653           else if (new_name.rfind(".msh") < new_name.size())
00654             GmshIO(*this).read (new_name);
00655 
00656           else if (new_name.rfind(".gmv") < new_name.size())
00657             GMVIO(*this).read (new_name);
00658 
00659           else if (new_name.rfind(".vtu") < new_name.size())
00660             VTKIO(*this).read(new_name);
00661 
00662           else if (new_name.rfind(".inp") < new_name.size())
00663             AbaqusIO(*this).read(new_name);
00664 
00665           else
00666             {
00667               libMesh::err << " ERROR: Unrecognized file extension: " << name
00668                             << "\n   I understand the following:\n\n"
00669                             << "     *.e    -- Sandia's ExodusII format\n"
00670                         << "     *.exd  -- Sandia's ExodusII format\n"
00671                         << "     *.gmv  -- LANL's General Mesh Viewer format\n"
00672                         << "     *.mat  -- Matlab triangular ASCII file\n"
00673                         << "     *.n    -- Sandia's Nemesis format\n"
00674                         << "     *.nem  -- Sandia's Nemesis format\n"
00675                         << "     *.off  -- OOGL OFF surface format\n"
00676                         << "     *.ucd  -- AVS's ASCII UCD format\n"
00677                         << "     *.unv  -- I-deas Universal format\n"
00678                         << "     *.vtu  -- Paraview VTK format\n"
00679                         << "     *.inp  -- Abaqus .inp format\n"
00680                         << "     *.xda  -- libMesh ASCII format\n"
00681                         << "     *.xdr  -- libMesh binary format\n"
00682                         << "     *.gz   -- any above format gzipped\n"
00683                         << "     *.bz2  -- any above format bzip2'ed\n"
00684                         << "     *.xz   -- any above format xzipped\n"
00685 
00686                         << std::endl;
00687               libmesh_error();
00688             }
00689 
00690           // If we temporarily decompressed a file, remove the
00691           // uncompressed version
00692           if (name.size() - name.rfind(".bz2") == 4)
00693             std::remove(new_name.c_str());
00694           if (name.size() - name.rfind(".xz") == 3)
00695             std::remove(new_name.c_str());
00696         }
00697 
00698 
00699       STOP_LOG("read()", "Mesh");
00700 
00701       // Send the mesh & bcs (which are now only on processor 0) to the other
00702       // processors
00703       MeshCommunication().broadcast (*this);
00704     }
00705 
00706   if (skip_renumber_nodes_and_elements)
00707     {
00708       // Use MeshBase::allow_renumbering() yourself instead.
00709       libmesh_deprecated();
00710       this->allow_renumbering(false);
00711     }
00712 
00713   // Done reading the mesh.  Now prepare it for use.
00714   this->prepare_for_use();
00715 }

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

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

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

00329 {
00330   const_element_iterator       el  = this->active_elements_begin();
00331   const const_element_iterator end = this->active_elements_end();
00332 
00333   unsigned int max_proc_id=0;
00334 
00335   for (; el!=end; ++el)
00336     max_proc_id = std::max(max_proc_id, static_cast<unsigned int>((*el)->processor_id()));
00337 
00338   // The number of partitions is one more than the max processor ID.
00339   _n_parts = max_proc_id+1;
00340 
00341   CommWorld.max(_n_parts);
00342 
00343   return _n_parts;
00344 }

virtual void libMesh::MeshBase::redistribute (  )  [inline, virtual, inherited]

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

Reimplemented in libMesh::ParallelMesh.

Definition at line 487 of file mesh_base.h.

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

00487 {}

void libMesh::SerialMesh::renumber_elem ( dof_id_type  old_id,
dof_id_type  new_id 
) [virtual]

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 304 of file serial_mesh.C.

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

00306 {
00307   // This doesn't get used in serial yet
00308   Elem *el = _elements[old_id];
00309   libmesh_assert (el);
00310 
00311   el->set_id(new_id);
00312   libmesh_assert (!_elements[new_id]);
00313   _elements[new_id] = el;
00314   _elements[old_id] = NULL;
00315 }

void libMesh::SerialMesh::renumber_node ( dof_id_type  old_id,
dof_id_type  new_id 
) [virtual]

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 420 of file serial_mesh.C.

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

00422 {
00423   // This doesn't get used in serial yet
00424   Node *nd = _nodes[old_id];
00425   libmesh_assert (nd);
00426 
00427   nd->set_id(new_id);
00428   libmesh_assert (!_nodes[new_id]);
00429   _nodes[new_id] = nd;
00430   _nodes[old_id] = NULL;
00431 }

void libMesh::SerialMesh::renumber_nodes_and_elements (  )  [virtual]

Remove NULL elements from arrays

Implements libMesh::MeshBase.

Definition at line 472 of file serial_mesh.C.

References _elements, _nodes, libMesh::MeshBase::_skip_renumber_nodes_and_elements, libMesh::MeshBase::boundary_info, end, libMesh::Elem::get_node(), libMesh::Elem::n_nodes(), libMesh::Elem::node(), libMesh::DofObject::set_id(), and swap().

00473 {
00474 
00475   START_LOG("renumber_nodes_and_elem()", "Mesh");
00476 
00477   // node and element id counters
00478   dof_id_type next_free_elem = 0;
00479   dof_id_type next_free_node = 0;
00480 
00481   // Will hold the set of nodes that are currently connected to elements
00482   LIBMESH_BEST_UNORDERED_SET<Node*> connected_nodes;
00483 
00484   // Loop over the elements.  Note that there may
00485   // be NULLs in the _elements vector from the coarsening
00486   // process.  Pack the elements in to a contiguous array
00487   // and then trim any excess.
00488   {
00489     std::vector<Elem*>::iterator in        = _elements.begin();
00490     std::vector<Elem*>::iterator out_iter  = _elements.begin();
00491     const std::vector<Elem*>::iterator end = _elements.end();
00492 
00493     for (; in != end; ++in)
00494       if (*in != NULL)
00495         {
00496           Elem* el = *in;
00497 
00498           *out_iter = *in;
00499           ++out_iter;
00500 
00501           // Increment the element counter
00502           el->set_id (next_free_elem++);
00503 
00504           if(_skip_renumber_nodes_and_elements)
00505           {
00506             // Add this elements nodes to the connected list
00507             for (unsigned int n=0; n<el->n_nodes(); n++)
00508               connected_nodes.insert(el->get_node(n));
00509           }
00510           else  // We DO want node renumbering
00511           {
00512             // Loop over this element's nodes.  Number them,
00513             // if they have not been numbered already.  Also,
00514             // position them in the _nodes vector so that they
00515             // are packed contiguously from the beginning.
00516             for (unsigned int n=0; n<el->n_nodes(); n++)
00517               if (el->node(n) == next_free_node)     // don't need to process
00518                 next_free_node++;                      // [(src == dst) below]
00519             
00520               else if (el->node(n) > next_free_node) // need to process
00521               {
00522                 // The source and destination indices
00523                 // for this node
00524                 const dof_id_type src_idx = el->node(n);
00525                 const dof_id_type dst_idx = next_free_node++;
00526                 
00527                 // ensure we want to swap a valid nodes
00528                 libmesh_assert(_nodes[src_idx]);
00529                 
00530                 // Swap the source and destination nodes
00531                 std::swap(_nodes[src_idx],
00532                           _nodes[dst_idx] );
00533                 
00534                 // Set proper indices where that makes sense
00535                 if (_nodes[src_idx] != NULL)
00536                   _nodes[src_idx]->set_id (src_idx);
00537                 _nodes[dst_idx]->set_id (dst_idx);
00538               }
00539           }
00540         }
00541 
00542     // Erase any additional storage. These elements have been
00543     // copied into NULL voids by the procedure above, and are
00544     // thus repeated and unnecessary.
00545     _elements.erase (out_iter, end);
00546   }
00547   
00548 
00549   if(_skip_renumber_nodes_and_elements)
00550   {
00551     // Loop over the nodes.  Note that there may
00552     // be NULLs in the _nodes vector from the coarsening
00553     // process.  Pack the nodes in to a contiguous array
00554     // and then trim any excess.
00555     
00556     std::vector<Node*>::iterator in        = _nodes.begin();
00557     std::vector<Node*>::iterator out_iter  = _nodes.begin();
00558     const std::vector<Node*>::iterator end = _nodes.end();
00559 
00560     for (; in != end; ++in)
00561       if (*in != NULL)
00562       {
00563         // This is a reference so that if we change the pointer it will change in the vector
00564         Node* & nd = *in;
00565         
00566         // If this node is still connected to an elem, put it in the list
00567         if(connected_nodes.find(nd) != connected_nodes.end())
00568         {
00569           *out_iter = nd;
00570           ++out_iter;
00571 
00572           // Increment the node counter
00573           nd->set_id (next_free_node++);
00574         }
00575         else // This node is orphaned, delete it!
00576         {
00577           this->boundary_info->remove (nd);
00578 
00579           // delete the node
00580           delete nd;
00581           nd = NULL;
00582         }  
00583       }
00584 
00585     // Erase any additional storage.  Whatever was
00586     _nodes.erase (out_iter, end);
00587   }
00588   else // We really DO want node renumbering
00589   {
00590     // Any nodes in the vector >= _nodes[next_free_node]
00591     // are not connected to any elements and may be deleted
00592     // if desired.
00593 
00594     // (This code block will erase the unused nodes)
00595     // Now, delete the unused nodes
00596     {
00597       std::vector<Node*>::iterator nd        = _nodes.begin();
00598       const std::vector<Node*>::iterator end = _nodes.end();
00599 
00600       std::advance (nd, next_free_node);
00601 
00602       for (std::vector<Node*>::iterator it=nd;
00603            it != end; ++it)
00604       {
00605         // Mesh modification code might have already deleted some
00606         // nodes
00607         if (*it == NULL)
00608           continue;
00609 
00610         // remove any boundary information associated with
00611         // this node
00612         this->boundary_info->remove (*it);
00613 
00614         // delete the node
00615         delete *it;
00616         *it = NULL;
00617       }
00618 
00619       _nodes.erase (nd, end);
00620     }
00621   }
00622 
00623   libmesh_assert_equal_to (next_free_elem, _elements.size());
00624   libmesh_assert_equal_to (next_free_node, _nodes.size());
00625 
00626   STOP_LOG("renumber_nodes_and_elem()", "Mesh");
00627 }

virtual void libMesh::SerialMesh::reserve_elem ( const dof_id_type  ne  )  [inline, virtual]

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 115 of file serial_mesh.h.

References _elements.

00115 { _elements.reserve (ne); }

virtual void libMesh::SerialMesh::reserve_nodes ( const dof_id_type  nn  )  [inline, virtual]

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 101 of file serial_mesh.h.

References _nodes.

00102   { _nodes.reserve (nn); }

unsigned int& libMesh::MeshBase::set_n_partitions (  )  [inline, protected, inherited]

Returns a writeable reference to the number of partitions.

Definition at line 825 of file mesh_base.h.

References libMesh::MeshBase::_n_parts.

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

00826   { return _n_parts; }

bool libMesh::MeshBase::skip_partitioning (  )  const [inline, inherited]

Definition at line 517 of file mesh_base.h.

References libMesh::MeshBase::_skip_partitioning.

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

00517 { return _skip_partitioning; }

void libMesh::MeshBase::skip_partitioning ( bool  skip  )  [inline, inherited]

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

References libMesh::MeshBase::_skip_partitioning.

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

00516 { _skip_partitioning = skip; }

unsigned int libMesh::MeshBase::spatial_dimension (  )  const [inline, inherited]
void libMesh::SerialMesh::stitch_meshes ( SerialMesh other_mesh,
boundary_id_type  this_mesh_boundary,
boundary_id_type  other_mesh_boundary,
Real  tol = TOLERANCE,
bool  clear_stitched_boundary_ids = false,
bool  verbose = true 
)

Stitch other_mesh to this mesh so that this mesh is the union of the two meshes. this_mesh_boundary and other_mesh_boundary are used to specify a dim-1 dimensional surface on which we seek to merge any "overlapping" nodes, where we use the parameter tol to determine whether or not nodes are overlapping. If clear_stitched_boundary_ids==true, this function clears boundary_info IDs in this mesh associated this_mesh_boundary and other_mesh_boundary.

Definition at line 645 of file serial_mesh.C.

References bc_id, libMesh::MeshBase::boundary_info, libMesh::Elem::build_side(), libMesh::Elem::contains_point(), libMesh::UnstructuredMesh::copy_nodes_and_elements(), delete_node(), elem(), elem_id, elements_begin(), elements_end(), libMesh::DofObject::id(), libMesh::BoundaryInfo::invalid_id, libMesh::Elem::local_node(), n_elem(), n_nodes(), libMesh::Elem::n_sides(), libMesh::Elem::neighbor(), node(), node_ptr(), nodes_begin(), nodes_end(), libMesh::out, libMesh::MeshBase::prepare_for_use(), libMesh::Real, libMesh::DofObject::set_id(), libMesh::Elem::set_node(), and side.

00651 {
00652   std::map<dof_id_type, dof_id_type> node_to_node_map;
00653   std::map<dof_id_type, std::vector<dof_id_type> > node_to_elems_map;
00654   
00655   if( (this_mesh_boundary_id  != BoundaryInfo::invalid_id) &&
00656       (other_mesh_boundary_id != BoundaryInfo::invalid_id) )
00657   {
00658     std::set<dof_id_type> this_boundary_node_ids;
00659     MeshBase::element_iterator elem_it  = this->elements_begin();
00660     MeshBase::element_iterator elem_end = this->elements_end();
00661     for ( ; elem_it != elem_end; ++elem_it)
00662     {
00663       Elem *el = *elem_it;
00664       
00665       // Now check whether elem has a face on the specified boundary
00666       for (unsigned int side_id=0; side_id<el->n_sides(); side_id++)
00667         if (el->neighbor(side_id) == NULL)
00668         {
00669           boundary_id_type bc_id = this->boundary_info->boundary_id (el, side_id);
00670           
00671           if(bc_id == this_mesh_boundary_id)
00672           {
00673             AutoPtr<Elem> side (el->build_side(side_id));
00674             for (unsigned int node_id=0; node_id<side->n_nodes(); node_id++)
00675             {
00676               this_boundary_node_ids.insert( side->node(node_id) );
00677             }
00678           }
00679         }
00680     }
00681 
00682     std::set<dof_id_type> other_boundary_node_ids;
00683     elem_it  = other_mesh.elements_begin();
00684     elem_end = other_mesh.elements_end();
00685     for ( ; elem_it != elem_end; ++elem_it)
00686     {
00687       Elem *el = *elem_it;
00688       
00689       // Now check whether elem has a face on the specified boundary
00690       for (unsigned int side_id=0; side_id<el->n_sides(); side_id++)
00691         if (el->neighbor(side_id) == NULL)
00692         {
00693           boundary_id_type bc_id = other_mesh.boundary_info->boundary_id (el, side_id);
00694           
00695           if(bc_id == other_mesh_boundary_id)
00696           {
00697             AutoPtr<Elem> side (el->build_side(side_id));
00698             for (unsigned int node_id=0; node_id<side->n_nodes(); node_id++)
00699             {
00700               other_boundary_node_ids.insert( side->node(node_id) );
00701             }
00702           }
00703         }
00704     }
00705     
00706     std::set<dof_id_type>::iterator set_it     = this_boundary_node_ids.begin();
00707     std::set<dof_id_type>::iterator set_it_end = this_boundary_node_ids.end();
00708     for( ; set_it != set_it_end; ++set_it)
00709     {
00710       dof_id_type this_node_id = *set_it;
00711       Node& this_node = this->node(this_node_id);
00712       
00713       bool found_matching_nodes = false;
00714       
00715       std::set<dof_id_type>::iterator other_set_it     = other_boundary_node_ids.begin();
00716       std::set<dof_id_type>::iterator other_set_it_end = other_boundary_node_ids.end();
00717       for( ; other_set_it != other_set_it_end; ++other_set_it)
00718       {
00719         dof_id_type other_node_id = *other_set_it;
00720         Node& other_node = other_mesh.node(other_node_id);
00721         
00722         Real node_distance = (this_node - other_node).size();
00723         
00724         if(node_distance < tol)
00725         {
00726           // Make sure we didn't already find a matching node!
00727           if(found_matching_nodes)
00728           {
00729             libMesh::out << "Error: Found multiple matching nodes in stitch_meshes" << std::endl;
00730             libmesh_error();
00731           }
00732           
00733           node_to_node_map[this_node_id] = other_node_id;
00734           
00735           // Build a vector of all the elements in other_mesh that contain other_node
00736           std::vector<dof_id_type> other_elem_ids;
00737           MeshBase::element_iterator other_elem_it  = other_mesh.elements_begin();
00738           MeshBase::element_iterator other_elem_end = other_mesh.elements_end();
00739           for (; other_elem_it != other_elem_end; ++other_elem_it)
00740           {
00741             Elem *el = *other_elem_it;
00742             
00743             if(el->contains_point(other_node))
00744               other_elem_ids.push_back(el->id());
00745           }
00746           
00747           node_to_elems_map[this_node_id] = other_elem_ids;
00748           
00749           found_matching_nodes = true;
00750         }
00751       }
00752     }
00753     
00754     if(verbose)
00755     {
00756       libMesh::out << "In SerialMesh::stitch_meshes:" << std::endl
00757                    << "This mesh has " << this_boundary_node_ids.size() << " nodes on specified boundary" << std::endl 
00758                    << "Other mesh has " << other_boundary_node_ids.size() << " nodes on specified boundary" << std::endl
00759                    << "Found " << node_to_node_map.size() << " matching nodes." << std::endl << std::endl;
00760     }
00761   }
00762   else
00763   {
00764     if(verbose)
00765     {
00766       libMesh::out << "Skip node merging in SerialMesh::stitch_meshes:" << std::endl;
00767     }
00768   }
00769   
00770 
00771   
00772   dof_id_type node_delta = this->n_nodes();
00773   dof_id_type elem_delta = this->n_elem();
00774   
00775   // need to increment node and element IDs of other_mesh before copying to this mesh
00776   MeshBase::node_iterator node_it  = other_mesh.nodes_begin();
00777   MeshBase::node_iterator node_end = other_mesh.nodes_end();
00778   for (; node_it != node_end; ++node_it)
00779   {
00780     Node *nd = *node_it;
00781     dof_id_type new_id = nd->id() + node_delta;
00782     nd->set_id(new_id);
00783   }
00784   
00785   MeshBase::element_iterator elem_it  = other_mesh.elements_begin();
00786   MeshBase::element_iterator elem_end = other_mesh.elements_end();
00787   for (; elem_it != elem_end; ++elem_it)
00788   {
00789     Elem *el = *elem_it;
00790     dof_id_type new_id = el->id() + elem_delta;
00791     el->set_id(new_id);
00792   }
00793   
00794   // Also, increment the node_to_node_map and node_to_elems_map
00795   std::map<dof_id_type, dof_id_type>::iterator node_map_it     = node_to_node_map.begin();
00796   std::map<dof_id_type, dof_id_type>::iterator node_map_it_end = node_to_node_map.end();
00797   for( ; node_map_it != node_map_it_end; ++node_map_it)
00798   {
00799     node_map_it->second += node_delta;
00800   }
00801   std::map<dof_id_type, std::vector<dof_id_type> >::iterator elem_map_it     = node_to_elems_map.begin();
00802   std::map<dof_id_type, std::vector<dof_id_type> >::iterator elem_map_it_end = node_to_elems_map.end();
00803   for( ; elem_map_it != elem_map_it_end; ++elem_map_it)
00804   {
00805     dof_id_type n_elems = elem_map_it->second.size();
00806     for(dof_id_type i=0; i<n_elems; i++)
00807     {
00808       (elem_map_it->second)[i] += elem_delta;
00809     }
00810   }
00811   
00812   // Copy mesh data
00813   this->copy_nodes_and_elements(other_mesh);
00814   
00815   // then decrement node and element IDs of mesh_i to return to original state
00816   node_it  = other_mesh.nodes_begin();
00817   node_end = other_mesh.nodes_end();
00818   for (; node_it != node_end; ++node_it)
00819   {
00820     Node *nd = *node_it;
00821     dof_id_type new_id = nd->id() - node_delta;
00822     nd->set_id(new_id);
00823   }
00824   
00825   elem_it  = other_mesh.elements_begin();
00826   elem_end = other_mesh.elements_end();
00827   for (; elem_it != elem_end; ++elem_it)
00828   {
00829     Elem *el = *elem_it;
00830     
00831     // First copy boundary info to the stitched mesh
00832     for (unsigned int side_id=0; side_id<el->n_sides(); side_id++)
00833       if (el->neighbor(side_id) == NULL)
00834       {
00835         boundary_id_type bc_id = other_mesh.boundary_info->boundary_id (el, side_id);
00836         
00837         if(bc_id != BoundaryInfo::invalid_id)
00838         {
00839           this->boundary_info->add_side(el->id(), side_id, bc_id);
00840         }
00841       }
00842     
00843     // Then decrement
00844     dof_id_type new_id = el->id() - elem_delta;
00845     el->set_id(new_id);
00846   }
00847   
00848   // Finally, we need to "merge" the overlapping nodes
00849   // We do this by iterating over node_to_elems_map and updating
00850   // the elements so that they "point" to the nodes that came
00851   // from this mesh, rather than from other_mesh.
00852   // Then we iterate over node_to_node_map and delete the
00853   // duplicate nodes that came from other_mesh.
00854   elem_map_it     = node_to_elems_map.begin();
00855   elem_map_it_end = node_to_elems_map.end();
00856   for( ; elem_map_it != elem_map_it_end; ++elem_map_it)
00857   {
00858     dof_id_type target_node_id = elem_map_it->first;
00859     dof_id_type other_node_id = node_to_node_map[target_node_id];
00860     Node& target_node = this->node(target_node_id);
00861     
00862     dof_id_type n_elems = elem_map_it->second.size();
00863     for(unsigned int i=0; i<n_elems; i++)
00864     {
00865       dof_id_type elem_id = elem_map_it->second[i];
00866       Elem* el = this->elem(elem_id);
00867       
00868       // find the local node index that we want to update
00869       unsigned int local_node_index = el->local_node(other_node_id);
00870       
00871       el->set_node(local_node_index) = &target_node;
00872     }
00873   }
00874   
00875   node_map_it     = node_to_node_map.begin();
00876   node_map_it_end = node_to_node_map.end();
00877   for( ; node_map_it != node_map_it_end; ++node_map_it)
00878   {
00879     dof_id_type node_id = node_map_it->second;
00880     this->delete_node( this->node_ptr(node_id) );
00881   }
00882   
00883   this->prepare_for_use( /*skip_renumber_nodes_and_elements= */ false);
00884 
00885   // After the stitching, we may want to clear boundary IDs from element
00886   // faces that are now internal to the mesh
00887   if(clear_stitched_boundary_ids)
00888   {
00889     elem_it  = this->elements_begin();
00890     elem_end = this->elements_end();
00891     for (; elem_it != elem_end; ++elem_it)
00892     {
00893       Elem *el = *elem_it;
00894       
00895       for (unsigned int side_id=0; side_id<el->n_sides(); side_id++)
00896       {
00897         if (el->neighbor(side_id) != NULL)
00898         {
00899           boundary_id_type bc_id = this->boundary_info->boundary_id (el, side_id);
00900           
00901           if( (bc_id == this_mesh_boundary_id)  ||
00902               (bc_id == other_mesh_boundary_id) )
00903           {
00904             this->boundary_info->remove_side(el, side_id);
00905           }
00906         }
00907       }
00908     }
00909   }
00910 
00911 }

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

References libMesh::MeshBase::_point_locator, libMesh::PointLocatorBase::build(), libMesh::AutoPtr< Tp >::get(), libMesh::Threads::in_threads, libMesh::AutoPtr< Tp >::reset(), 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(), and libMesh::System::point_value().

00365 {
00366   if (_point_locator.get() == NULL)
00367     {
00368       // PointLocator construction may not be safe within threads
00369       libmesh_assert(!Threads::in_threads);
00370 
00371       _point_locator.reset (PointLocatorBase::build(TREE, *this).release());
00372     }
00373 
00374   return PointLocatorBase::build(TREE, *this, _point_locator.get());
00375 }

SerialMesh::const_element_iterator libMesh::SerialMesh::subactive_elements_begin (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 310 of file serial_mesh_iterators.C.

References _elements.

00311 {
00312   Predicates::SubActive<const_elem_iterator_imp> p;
00313   return const_element_iterator(_elements.begin(), _elements.end(), p);
00314 }

SerialMesh::element_iterator libMesh::SerialMesh::subactive_elements_begin (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 87 of file serial_mesh_iterators.C.

References _elements.

00088 {
00089   Predicates::SubActive<elem_iterator_imp> p;
00090   return element_iterator(_elements.begin(), _elements.end(), p);
00091 }

SerialMesh::const_element_iterator libMesh::SerialMesh::subactive_elements_end (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 760 of file serial_mesh_iterators.C.

References _elements.

00761 {
00762   Predicates::SubActive<const_elem_iterator_imp> p;
00763   return const_element_iterator(_elements.end(), _elements.end(), p);
00764 }

SerialMesh::element_iterator libMesh::SerialMesh::subactive_elements_end (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 533 of file serial_mesh_iterators.C.

References _elements.

00534 {
00535   Predicates::SubActive<elem_iterator_imp> p;
00536   return element_iterator(_elements.end(), _elements.end(), p);
00537 }

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

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

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

00172 {
00173   // This requires an inspection on every processor
00174   parallel_only();
00175 
00176   ids.clear();
00177   
00178   const_element_iterator       el  = this->active_elements_begin();
00179   const const_element_iterator end = this->active_elements_end();
00180 
00181   for (; el!=end; ++el)
00182     ids.insert((*el)->subdomain_id());
00183 
00184   // Some subdomains may only live on other processors
00185   CommWorld.set_union(ids);
00186 }

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

Definition at line 391 of file mesh_base.C.

References libMesh::MeshBase::_block_id_to_name.

00392 {
00393   // An empty string to return when no matching subdomain name is found
00394   static const std::string empty;
00395 
00396   std::map<subdomain_id_type, std::string>::const_iterator iter = _block_id_to_name.find(id);
00397   if (iter == _block_id_to_name.end())
00398     return empty;
00399   else
00400     return iter->second;
00401 }

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

00387 {
00388   return _block_id_to_name[id];
00389 }

SerialMesh::const_element_iterator libMesh::SerialMesh::type_elements_begin ( const ElemType  type  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 420 of file serial_mesh_iterators.C.

References _elements.

00421 {
00422   Predicates::Type<const_elem_iterator_imp> p(type);
00423   return const_element_iterator(_elements.begin(), _elements.end(), p);
00424 }

SerialMesh::element_iterator libMesh::SerialMesh::type_elements_begin ( const ElemType  type  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 197 of file serial_mesh_iterators.C.

References _elements.

00198 {
00199   Predicates::Type<elem_iterator_imp> p(type);
00200   return element_iterator(_elements.begin(), _elements.end(), p);
00201 }

SerialMesh::const_element_iterator libMesh::SerialMesh::type_elements_end ( const ElemType  type  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 870 of file serial_mesh_iterators.C.

References _elements.

00871 {
00872   Predicates::Type<const_elem_iterator_imp> p(type);
00873   return const_element_iterator(_elements.end(), _elements.end(), p);
00874 }

SerialMesh::element_iterator libMesh::SerialMesh::type_elements_end ( const ElemType  type  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 643 of file serial_mesh_iterators.C.

References _elements.

00644 {
00645   Predicates::Type<elem_iterator_imp> p(type);
00646   return element_iterator(_elements.end(), _elements.end(), p);
00647 }

SerialMesh::const_element_iterator libMesh::SerialMesh::unpartitioned_elements_begin (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 450 of file serial_mesh_iterators.C.

References libMesh::DofObject::invalid_processor_id, and pid_elements_begin().

00451 {
00452   return this->pid_elements_begin(DofObject::invalid_processor_id);
00453 }

SerialMesh::element_iterator libMesh::SerialMesh::unpartitioned_elements_begin (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 227 of file serial_mesh_iterators.C.

References libMesh::DofObject::invalid_processor_id, and pid_elements_begin().

00228 {
00229   return this->pid_elements_begin(DofObject::invalid_processor_id);
00230 }

SerialMesh::const_element_iterator libMesh::SerialMesh::unpartitioned_elements_end (  )  const [virtual]

Implements libMesh::MeshBase.

Definition at line 900 of file serial_mesh_iterators.C.

References libMesh::DofObject::invalid_processor_id, and pid_elements_end().

00901 {
00902   return this->pid_elements_end(DofObject::invalid_processor_id);
00903 }

SerialMesh::element_iterator libMesh::SerialMesh::unpartitioned_elements_end (  )  [virtual]

Implements libMesh::MeshBase.

Definition at line 673 of file serial_mesh_iterators.C.

References libMesh::DofObject::invalid_processor_id, and pid_elements_end().

00674 {
00675   return this->pid_elements_end(DofObject::invalid_processor_id);
00676 }

virtual void libMesh::SerialMesh::update_parallel_id_counts (  )  [inline, virtual]

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

Implements libMesh::MeshBase.

Definition at line 118 of file serial_mesh.h.

00118 {}

virtual void libMesh::MeshBase::update_post_partitioning (  )  [inline, virtual, inherited]

Recalculate any cached data after elements and nodes have been repartitioned.

Reimplemented in libMesh::ParallelMesh.

Definition at line 493 of file mesh_base.h.

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

00493 {}

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

References libMesh::err, libMesh::MeshBase::n_subdomains(), libMesh::GMVIO::partitioning(), and libMesh::GMVIO::write_nodal_data().

00886 {
00887   START_LOG("write()", "Mesh");
00888 
00889   // Write the file based on extension
00890   if (name.rfind(".dat") < name.size())
00891     TecplotIO(*this).write_nodal_data (name, v, vn);
00892 
00893   else if (name.rfind(".plt") < name.size())
00894     TecplotIO(*this,true).write_nodal_data (name, v, vn);
00895 
00896   else if (name.rfind(".gmv") < name.size())
00897     {
00898       if (n_subdomains() > 1)
00899         GMVIO(*this).write_nodal_data (name, v, vn);
00900       else
00901         {
00902           GMVIO io(*this);
00903           io.partitioning() = false;
00904           io.write_nodal_data (name, v, vn);
00905         }
00906     }
00907   else if (name.rfind(".pvtu") < name.size())
00908     {
00909       VTKIO(*this).write_nodal_data (name, v, vn);
00910     }
00911   else
00912     {
00913       libMesh::err
00914         << " ERROR: Unrecognized file extension: " << name
00915         << "\n   I understand the following:\n\n"
00916         << "     *.dat  -- Tecplot ASCII file\n"
00917         << "     *.gmv  -- LANL's GMV (General Mesh Viewer) format\n"
00918         << "     *.plt  -- Tecplot binary file\n"
00919         << "     *.pvtu -- Paraview VTK file\n"
00920         << "\n Exiting without writing output\n";
00921     }
00922 
00923   STOP_LOG("write()", "Mesh");
00924 }

void libMesh::UnstructuredMesh::write ( const std::string &  name,
MeshData mesh_data = NULL 
) [virtual, inherited]

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

References libMesh::Parallel::Communicator::barrier(), libMesh::Parallel::Communicator::broadcast(), libMesh::CommWorld, libMesh::err, libMesh::MeshBase::n_partitions(), libMesh::GMVIO::partitioning(), libMesh::processor_id(), and libMesh::GMVIO::write().

00721 {
00722   // parallel formats are special -- they may choose to write
00723   // separate files, let's not try to handle the zipping here.
00724   if (is_parallel_file_format(name))
00725     {
00726       // no need to handle bz2 files here -- the Xdr class does that.
00727       if (name.rfind(".xda") < name.size())
00728         XdrIO(*this).write(name);
00729 
00730       else if (name.rfind(".xdr") < name.size())
00731         XdrIO(*this,true).write(name);
00732 
00733       else if (name.rfind(".nem") < name.size() ||
00734                name.rfind(".n")   < name.size())
00735         Nemesis_IO(*this).write(name);
00736     }
00737 
00738   // serial file formats
00739   else
00740     {
00741       START_LOG("write()", "Mesh");
00742 
00743       // Nasty hack for reading/writing zipped files
00744       std::string new_name = name;
00745       processor_id_type pid_0 = 0;
00746       if (libMesh::processor_id() == 0)
00747         pid_0 = getpid();
00748       CommWorld.broadcast(pid_0);
00749       std::ostringstream pid_suffix;
00750       pid_suffix << '_' << pid_0;
00751 
00752       if (name.size() - name.rfind(".bz2") == 4)
00753         {
00754           new_name.erase(new_name.end() - 4, new_name.end());
00755           new_name += pid_suffix.str();
00756         }
00757       else if (name.size() - name.rfind(".xz") == 3)
00758         {
00759           new_name.erase(new_name.end() - 3, new_name.end());
00760           new_name += pid_suffix.str();
00761         }
00762 
00763       // New scope so that io will close before we try to zip the file
00764       {
00765         // Write the file based on extension
00766         if (new_name.rfind(".dat") < new_name.size())
00767           TecplotIO(*this).write (new_name);
00768 
00769         else if (new_name.rfind(".plt") < new_name.size())
00770           TecplotIO(*this,true).write (new_name);
00771 
00772         else if (new_name.rfind(".ucd") < new_name.size())
00773           UCDIO (*this).write (new_name);
00774 
00775         else if (new_name.rfind(".gmv") < new_name.size())
00776           if (this->n_partitions() > 1)
00777             GMVIO(*this).write (new_name);
00778           else
00779             {
00780               GMVIO io(*this);
00781               io.partitioning() = false;
00782               io.write (new_name);
00783             }
00784 
00785         else if (new_name.rfind(".ugrid") < new_name.size())
00786           DivaIO(*this).write(new_name);
00787         else if (new_name.rfind(".exd") < new_name.size() ||
00788                  new_name.rfind(".e") < new_name.size())
00789           ExodusII_IO(*this).write(new_name);
00790         else if (new_name.rfind(".mgf")  < new_name.size())
00791           LegacyXdrIO(*this,true).write_mgf(new_name);
00792 
00793         else if (new_name.rfind(".unv") < new_name.size())
00794           {
00795             if (mesh_data == NULL)
00796               {
00797                 libMesh::err << "Error! You must pass a "
00798                               << "valid MeshData pointer to "
00799                               << "write UNV files!" << std::endl;
00800                 libmesh_error();
00801               }
00802             UNVIO(*this, *mesh_data).write (new_name);
00803           }
00804 
00805         else if (new_name.rfind(".mesh") < new_name.size())
00806           MEDITIO(*this).write (new_name);
00807 
00808         else if (new_name.rfind(".poly") < new_name.size())
00809           TetGenIO(*this).write (new_name);
00810 
00811         else if (new_name.rfind(".msh") < new_name.size())
00812           GmshIO(*this).write (new_name);
00813 
00814         else if (new_name.rfind(".fro") < new_name.size())
00815           FroIO(*this).write (new_name);
00816 
00817         else if (new_name.rfind(".vtu") < new_name.size())
00818           VTKIO(*this).write (new_name);
00819 
00820         else
00821           {
00822             libMesh::err
00823               << " ERROR: Unrecognized file extension: " << name
00824               << "\n   I understand the following:\n\n"
00825               << "     *.dat   -- Tecplot ASCII file\n"
00826               << "     *.e     -- Sandia's ExodusII format\n"
00827               << "     *.exd   -- Sandia's ExodusII format\n"
00828               << "     *.fro   -- ACDL's surface triangulation file\n"
00829               << "     *.gmv   -- LANL's GMV (General Mesh Viewer) format\n"
00830               << "     *.mesh  -- MEdit mesh format\n"
00831               << "     *.mgf   -- MGF binary mesh format\n"
00832               << "     *.msh   -- GMSH ASCII file\n"
00833               << "     *.n     -- Sandia's Nemesis format\n"
00834               << "     *.nem   -- Sandia's Nemesis format\n"
00835               << "     *.plt   -- Tecplot binary file\n"
00836               << "     *.poly  -- TetGen ASCII file\n"
00837               << "     *.ucd   -- AVS's ASCII UCD format\n"
00838               << "     *.ugrid -- Kelly's DIVA ASCII format\n"
00839               << "     *.unv   -- I-deas Universal format\n"
00840               << "     *.xda   -- libMesh ASCII format\n"
00841               << "     *.xdr   -- libMesh binary format,\n"
00842               << std::endl
00843               << "\n Exiting without writing output\n";
00844           }
00845       }
00846 
00847       // Nasty hack for reading/writing zipped files
00848       if (name.size() - name.rfind(".bz2") == 4)
00849         {
00850           START_LOG("system(bzip2)", "Mesh");
00851           if (libMesh::processor_id() == 0)
00852             {
00853               std::string system_string = "bzip2 -f -c ";
00854               system_string += new_name + " > " + name;
00855               if (std::system(system_string.c_str()))
00856                 libmesh_file_error(system_string);
00857               std::remove(new_name.c_str());
00858             }
00859           CommWorld.barrier();
00860           STOP_LOG("system(bzip2)", "Mesh");
00861         }
00862       if (name.size() - name.rfind(".xz") == 3)
00863         {
00864           START_LOG("system(xz)", "Mesh");
00865           if (libMesh::processor_id() == 0)
00866             {
00867               std::string system_string = "xz -f -c ";
00868               system_string += new_name + " > " + name;
00869               if (std::system(system_string.c_str()))
00870                 libmesh_file_error(system_string);
00871               std::remove(new_name.c_str());
00872             }
00873           CommWorld.barrier();
00874           STOP_LOG("system(xz)", "Mesh");
00875         }
00876 
00877       STOP_LOG("write()", "Mesh");
00878     }
00879 }


Friends And Related Function Documentation

friend class BoundaryInfo [friend, inherited]

Make the BoundaryInfo class a friend so that it can create and interact with BoundaryMesh.

Definition at line 895 of file mesh_base.h.

std::ostream& operator<< ( std::ostream &  os,
const MeshBase m 
) [friend, inherited]

Equivalent to calling print_info() above, but now you can write: Mesh mesh; libMesh::out << mesh << std::endl;

friend class Partitioner [friend, inherited]

The partitioner class is a friend so that it can set the number of partitions.

Definition at line 889 of file mesh_base.h.


Member Data Documentation

std::map<subdomain_id_type, std::string> libMesh::MeshBase::_block_id_to_name [protected, inherited]

This structure maintains the mapping of named blocks for file formats that support named blocks. Currently this is only implemented for ExodusII

Definition at line 883 of file mesh_base.h.

Referenced by libMesh::MeshBase::get_id_by_name(), and libMesh::MeshBase::subdomain_name().

std::vector<Elem*> libMesh::SerialMesh::_elements [protected]
unsigned int libMesh::MeshBase::_n_parts [protected, inherited]

The number of partitions the mesh has. This is set by the partitioners, and may not be changed directly by the user. **NOTE** The number of partitions *need not* equal libMesh::n_processors(), consider for example the case where you simply want to partition a mesh on one processor and view the result in GMV.

Definition at line 837 of file mesh_base.h.

Referenced by libMesh::MeshBase::clear(), libMesh::UnstructuredMesh::copy_nodes_and_elements(), libMesh::MeshBase::n_partitions(), libMesh::MeshBase::recalculate_n_partitions(), and libMesh::MeshBase::set_n_partitions().

A partitioner to use at each prepare_for_use().

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

Definition at line 864 of file mesh_base.h.

Referenced by libMesh::MeshBase::MeshBase(), libMesh::ParallelMesh::ParallelMesh(), libMesh::MeshBase::partitioner(), and SerialMesh().

A PointLocator class for this mesh. This will not actually be built unless needed. Further, since we want our point_locator() method to be const (yet do the dynamic allocating) this needs to be mutable. Since the PointLocatorBase::build() member is used, and it operates on a constant reference to the mesh, this is OK.

Definition at line 856 of file mesh_base.h.

Referenced by libMesh::MeshBase::clear_point_locator(), libMesh::MeshBase::point_locator(), and libMesh::MeshBase::sub_point_locator().

bool libMesh::MeshBase::_skip_partitioning [protected, inherited]

If this is true then no partitioning should be done.

Definition at line 869 of file mesh_base.h.

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

If this is true then renumbering will be kept to a miniumum.

This is set when prepare_for_use() is called.

Definition at line 876 of file mesh_base.h.

Referenced by libMesh::MeshBase::allow_renumbering(), libMesh::MeshBase::prepare_for_use(), renumber_nodes_and_elements(), and libMesh::ParallelMesh::renumber_nodes_and_elements().

This class holds the boundary information. It can store nodes, edges, and faces with a corresponding id that facilitates setting boundary conditions.

Definition at line 99 of file mesh_base.h.

Referenced by libMesh::MeshRefinement::_coarsen_elements(), libMesh::UnstructuredMesh::all_first_order(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::AbaqusIO::assign_boundary_node_ids(), libMesh::AbaqusIO::assign_sideset_ids(), libMesh::MeshTools::Generation::build_cube(), libMesh::MeshTools::Generation::build_delaunay_square(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::MeshTools::Modification::change_boundary_id(), libMesh::MeshBase::clear(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::FEGenericBase< OutputType >::compute_periodic_constraints(), libMesh::FEAbstract::compute_periodic_node_constraints(), libMesh::UnstructuredMesh::create_submesh(), delete_elem(), libMesh::ParallelMesh::delete_elem(), delete_node(), libMesh::ParallelMesh::delete_node(), libMesh::MeshTools::Modification::flatten(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_discontinuous(), libMesh::BoundaryProjectSolution::operator()(), libMesh::Parallel::pack(), libMesh::Parallel::packable_size(), libMesh::ParallelMesh::ParallelMesh(), libMesh::Nemesis_IO::read(), libMesh::ExodusII_IO::read(), libMesh::AbaqusIO::read(), libMesh::LegacyXdrIO::read_mesh(), libMesh::GmshIO::read_mesh(), renumber_nodes_and_elements(), libMesh::ParallelMesh::renumber_nodes_and_elements(), SerialMesh(), stitch_meshes(), libMesh::Elem::topological_neighbor(), libMesh::Parallel::unpack(), libMesh::XdrIO::write(), libMesh::FroIO::write(), libMesh::LegacyXdrIO::write_mesh(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::XdrIO::write_serialized_bcs(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::LegacyXdrIO::write_soln(), and libMesh::DivaIO::write_stream().


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

Site Created By: libMesh Developers
Last modified: February 05 2013 19:55:38 UTC

Hosted By:
SourceForge.net Logo