UnstructuredMesh Class Reference

#include <unstructured_mesh.h>

Inheritance diagram for UnstructuredMesh:

List of all members.

Public Types

typedef Predicates::multi_predicate Predicate

Public Member Functions

 UnstructuredMesh (unsigned int d)
virtual ~UnstructuredMesh ()
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 unsigned int 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< MeshBaseclone () const =0
virtual AutoPtr< Partitioner > & partitioner ()
virtual void clear ()
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
virtual unsigned int n_nodes () const =0
unsigned int n_nodes_on_proc (const unsigned int proc) const
unsigned int n_local_nodes () const
unsigned int n_unpartitioned_nodes () const
virtual unsigned int max_node_id () const =0
virtual void reserve_nodes (const unsigned int nn)=0
virtual unsigned int n_elem () const =0
virtual unsigned int max_elem_id () const =0
virtual void reserve_elem (const unsigned int ne)=0
virtual void update_parallel_id_counts ()=0
virtual unsigned int n_active_elem () const =0
unsigned int n_elem_on_proc (const unsigned int proc) const
unsigned int n_local_elem () const
unsigned int n_unpartitioned_elem () const
unsigned int n_active_elem_on_proc (const unsigned int proc) const
unsigned int n_active_local_elem () const
unsigned int n_sub_elem () const
unsigned int n_active_sub_elem () const
virtual const Pointpoint (const unsigned int i) const =0
virtual const Nodenode (const unsigned int i) const =0
virtual Nodenode (const unsigned int i)=0
virtual const Nodenode_ptr (const unsigned int i) const =0
virtual Node *& node_ptr (const unsigned int i)=0
virtual Elemelem (const unsigned int i) const =0
virtual Nodeadd_point (const Point &p, const unsigned int id=DofObject::invalid_id, const unsigned int proc_id=DofObject::invalid_processor_id)=0
virtual Nodeadd_node (Node *n)=0
virtual void delete_node (Node *n)=0
virtual void renumber_node (unsigned int old_id, unsigned int new_id)=0
virtual Elemadd_elem (Elem *e)=0
virtual Eleminsert_elem (Elem *e)=0
virtual void delete_elem (Elem *e)=0
virtual void renumber_elem (unsigned int old_id, unsigned int new_id)=0
virtual void renumber_nodes_and_elements ()=0
void prepare_for_use (const bool skip_renumber_nodes_and_elements=false)
void partition (const unsigned int n_parts=libMesh::n_processors())
unsigned int n_subdomains () const
unsigned int n_partitions () const
unsigned int n_processors () const
unsigned int processor_id () const
std::string get_info () const
void print_info (std::ostream &os=std::cout) const
unsigned int recalculate_n_partitions ()
const PointLocatorBasepoint_locator () const
void clear_point_locator ()
virtual element_iterator elements_begin ()=0
virtual const_element_iterator elements_begin () const =0
virtual element_iterator elements_end ()=0
virtual const_element_iterator elements_end () const =0
virtual element_iterator active_elements_begin ()=0
virtual const_element_iterator active_elements_begin () const =0
virtual element_iterator active_elements_end ()=0
virtual const_element_iterator active_elements_end () const =0
virtual element_iterator ancestor_elements_begin ()=0
virtual const_element_iterator ancestor_elements_begin () const =0
virtual element_iterator ancestor_elements_end ()=0
virtual const_element_iterator ancestor_elements_end () const =0
virtual element_iterator subactive_elements_begin ()=0
virtual const_element_iterator subactive_elements_begin () const =0
virtual element_iterator subactive_elements_end ()=0
virtual const_element_iterator subactive_elements_end () const =0
virtual element_iterator not_active_elements_begin ()=0
virtual const_element_iterator not_active_elements_begin () const =0
virtual element_iterator not_active_elements_end ()=0
virtual const_element_iterator not_active_elements_end () const =0
virtual element_iterator not_ancestor_elements_begin ()=0
virtual const_element_iterator not_ancestor_elements_begin () const =0
virtual element_iterator not_ancestor_elements_end ()=0
virtual const_element_iterator not_ancestor_elements_end () const =0
virtual element_iterator not_subactive_elements_begin ()=0
virtual const_element_iterator not_subactive_elements_begin () const =0
virtual element_iterator not_subactive_elements_end ()=0
virtual const_element_iterator not_subactive_elements_end () const =0
virtual element_iterator local_elements_begin ()=0
virtual const_element_iterator local_elements_begin () const =0
virtual element_iterator local_elements_end ()=0
virtual const_element_iterator local_elements_end () const =0
virtual element_iterator not_local_elements_begin ()=0
virtual const_element_iterator not_local_elements_begin () const =0
virtual element_iterator not_local_elements_end ()=0
virtual const_element_iterator not_local_elements_end () const =0
virtual element_iterator active_local_elements_begin ()=0
virtual const_element_iterator active_local_elements_begin () const =0
virtual element_iterator active_local_elements_end ()=0
virtual const_element_iterator active_local_elements_end () const =0
virtual element_iterator active_not_local_elements_begin ()=0
virtual const_element_iterator active_not_local_elements_begin () const =0
virtual element_iterator active_not_local_elements_end ()=0
virtual const_element_iterator active_not_local_elements_end () const =0
virtual element_iterator level_elements_begin (const unsigned int level)=0
virtual const_element_iterator level_elements_begin (const unsigned int level) const =0
virtual element_iterator level_elements_end (const unsigned int level)=0
virtual const_element_iterator level_elements_end (const unsigned int level) const =0
virtual element_iterator not_level_elements_begin (const unsigned int level)=0
virtual const_element_iterator not_level_elements_begin (const unsigned int level) const =0
virtual element_iterator not_level_elements_end (const unsigned int level)=0
virtual const_element_iterator not_level_elements_end (const unsigned int level) const =0
virtual element_iterator local_level_elements_begin (const unsigned int level)=0
virtual const_element_iterator local_level_elements_begin (const unsigned int level) const =0
virtual element_iterator local_level_elements_end (const unsigned int level)=0
virtual const_element_iterator local_level_elements_end (const unsigned int level) const =0
virtual element_iterator local_not_level_elements_begin (const unsigned int level)=0
virtual const_element_iterator local_not_level_elements_begin (const unsigned int level) const =0
virtual element_iterator local_not_level_elements_end (const unsigned int level)=0
virtual const_element_iterator local_not_level_elements_end (const unsigned int level) const =0
virtual element_iterator pid_elements_begin (const unsigned int proc_id)=0
virtual const_element_iterator pid_elements_begin (const unsigned int proc_id) const =0
virtual element_iterator pid_elements_end (const unsigned int proc_id)=0
virtual const_element_iterator pid_elements_end (const unsigned int proc_id) const =0
virtual element_iterator type_elements_begin (const ElemType type)=0
virtual const_element_iterator type_elements_begin (const ElemType type) const =0
virtual element_iterator type_elements_end (const ElemType type)=0
virtual const_element_iterator type_elements_end (const ElemType type) const =0
virtual element_iterator active_type_elements_begin (const ElemType type)=0
virtual const_element_iterator active_type_elements_begin (const ElemType type) const =0
virtual element_iterator active_type_elements_end (const ElemType type)=0
virtual const_element_iterator active_type_elements_end (const ElemType type) const =0
virtual element_iterator active_pid_elements_begin (const unsigned int proc_id)=0
virtual const_element_iterator active_pid_elements_begin (const unsigned int proc_id) const =0
virtual element_iterator active_pid_elements_end (const unsigned int proc_id)=0
virtual const_element_iterator active_pid_elements_end (const unsigned int proc_id) const =0
virtual element_iterator unpartitioned_elements_begin ()=0
virtual const_element_iterator unpartitioned_elements_begin () const =0
virtual element_iterator unpartitioned_elements_end ()=0
virtual const_element_iterator unpartitioned_elements_end () const =0
virtual element_iterator active_local_subdomain_elements_begin (const unsigned int subdomain_id)=0
virtual const_element_iterator active_local_subdomain_elements_begin (const unsigned int subdomain_id) const =0
virtual element_iterator active_local_subdomain_elements_end (const unsigned int subdomain_id)=0
virtual const_element_iterator active_local_subdomain_elements_end (const unsigned int subdomain_id) const =0
virtual node_iterator nodes_begin ()=0
virtual const_node_iterator nodes_begin () const =0
virtual node_iterator nodes_end ()=0
virtual const_node_iterator nodes_end () const =0
virtual node_iterator active_nodes_begin ()=0
virtual const_node_iterator active_nodes_begin () const =0
virtual node_iterator active_nodes_end ()=0
virtual const_node_iterator active_nodes_end () const =0
virtual node_iterator local_nodes_begin ()=0
virtual const_node_iterator local_nodes_begin () const =0
virtual node_iterator local_nodes_end ()=0
virtual const_node_iterator local_nodes_end () const =0
virtual node_iterator pid_nodes_begin (const unsigned int proc_id)=0
virtual const_node_iterator pid_nodes_begin (const unsigned int proc_id) const =0
virtual node_iterator pid_nodes_end (const unsigned int proc_id)=0
virtual const_node_iterator pid_nodes_end (const unsigned int proc_id) const =0

Public Attributes

AutoPtr< BoundaryInfoboundary_info

Protected Member Functions

unsigned int & set_n_partitions ()

Protected Attributes

unsigned int _n_parts
unsigned int _dim
bool _is_prepared
AutoPtr< PointLocatorBase_point_locator
AutoPtr< Partitioner_partitioner

Friends

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


Detailed Description

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

Definition at line 49 of file unstructured_mesh.h.


Member Typedef Documentation

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

Definition at line 495 of file mesh_base.h.


Constructor & Destructor Documentation

UnstructuredMesh::UnstructuredMesh ( unsigned int  d  ) 

Constructor. Requires the dimension and optionally a processor id. Note that proc_id should always be provided for multiprocessor applications.

Definition at line 85 of file unstructured_mesh.C.

References libMesh::initialized().

00085                                                   :
00086   MeshBase (d)
00087 {
00088   libmesh_assert (libMesh::initialized());
00089 }

UnstructuredMesh::~UnstructuredMesh (  )  [virtual]

Destructor.

Definition at line 176 of file unstructured_mesh.C.

References libMesh::closed().

00177 {
00178 //  this->clear ();  // Nothing to clear at this level
00179   
00180   libmesh_assert (!libMesh::closed());
00181 }


Member Function Documentation

virtual const_element_iterator MeshBase::active_elements_begin (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::active_elements_begin (  )  [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

Referenced by SFCPartitioner::_do_partition(), MetisPartitioner::_do_partition(), LinearPartitioner::_do_partition(), DofMap::add_neighbors_to_send_list(), ParmetisPartitioner::assign_partitioning(), EquationSystems::build_discontinuous_solution_vector(), InfElemBuilder::build_inf_elem(), DofMap::compute_sparsity(), MeshTools::correct_node_proc_ids(), MeshTools::Modification::distort(), MeshRefinement::eliminate_unrefined_patches(), PointLocatorTree::enable_out_of_mesh_mode(), LocationMap< T >::fill(), MeshTools::find_boundary_nodes(), MeshRefinement::flag_elements_by_elem_fraction(), MeshRefinement::flag_elements_by_error_fraction(), MeshRefinement::flag_elements_by_error_tolerance(), MeshRefinement::flag_elements_by_mean_stddev(), MeshRefinement::flag_elements_by_nelem_target(), MeshTools::Modification::flatten(), PointLocatorList::init(), LaplaceMeshSmoother::init(), ParmetisPartitioner::initialize(), DofMap::invalidate_dofs(), MeshTools::libmesh_assert_valid_elem_ids(), MeshRefinement::limit_level_mismatch_at_edge(), MeshRefinement::limit_level_mismatch_at_node(), MeshRefinement::make_coarsening_compatible(), MeshCommunication::make_elems_parallel_consistent(), MeshRefinement::make_refinement_compatible(), FEMSystem::mesh_position_set(), MeshBase::n_active_sub_elem(), MeshBase::n_subdomains(), PointLocatorTree::operator()(), System::read_legacy_data(), GmshIO::read_mesh(), VariationalMeshSmoother::readgr(), MeshBase::recalculate_n_partitions(), DofMap::reinit(), Partitioner::set_node_processor_ids(), Partitioner::set_parent_processor_ids(), LaplaceMeshSmoother::smooth(), BoundaryInfo::sync(), Tree< N >::Tree(), MeshRefinement::uniformly_coarsen(), MeshRefinement::uniformly_p_coarsen(), MeshRefinement::uniformly_p_refine(), MeshRefinement::uniformly_refine(), TetGenIO::write(), PostscriptIO::write(), FroIO::write(), TecplotIO::write_ascii(), MEDITIO::write_ascii(), GMVIO::write_ascii_new_impl(), GMVIO::write_ascii_old_impl(), TecplotIO::write_binary(), GMVIO::write_discontinuous_gmv(), GmshIO::write_mesh(), GmshIO::write_post(), and GnuPlotIO::write_solution().

virtual const_element_iterator MeshBase::active_elements_end (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::active_elements_end (  )  [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

Referenced by SFCPartitioner::_do_partition(), MetisPartitioner::_do_partition(), LinearPartitioner::_do_partition(), DofMap::add_neighbors_to_send_list(), ParmetisPartitioner::assign_partitioning(), EquationSystems::build_discontinuous_solution_vector(), InfElemBuilder::build_inf_elem(), DofMap::compute_sparsity(), MeshTools::correct_node_proc_ids(), MeshTools::Modification::distort(), MeshRefinement::eliminate_unrefined_patches(), PointLocatorTree::enable_out_of_mesh_mode(), LocationMap< T >::fill(), MeshTools::find_boundary_nodes(), MeshRefinement::flag_elements_by_elem_fraction(), MeshRefinement::flag_elements_by_error_fraction(), MeshRefinement::flag_elements_by_error_tolerance(), MeshRefinement::flag_elements_by_mean_stddev(), MeshRefinement::flag_elements_by_nelem_target(), MeshTools::Modification::flatten(), PointLocatorList::init(), LaplaceMeshSmoother::init(), ParmetisPartitioner::initialize(), DofMap::invalidate_dofs(), MeshTools::libmesh_assert_valid_elem_ids(), MeshRefinement::limit_level_mismatch_at_edge(), MeshRefinement::limit_level_mismatch_at_node(), MeshRefinement::make_coarsening_compatible(), MeshCommunication::make_elems_parallel_consistent(), MeshRefinement::make_refinement_compatible(), FEMSystem::mesh_position_set(), MeshBase::n_active_sub_elem(), MeshBase::n_subdomains(), PointLocatorTree::operator()(), System::read_legacy_data(), GmshIO::read_mesh(), VariationalMeshSmoother::readgr(), MeshBase::recalculate_n_partitions(), DofMap::reinit(), Partitioner::set_node_processor_ids(), Partitioner::set_parent_processor_ids(), LaplaceMeshSmoother::smooth(), BoundaryInfo::sync(), Tree< N >::Tree(), MeshRefinement::uniformly_coarsen(), MeshRefinement::uniformly_p_coarsen(), MeshRefinement::uniformly_p_refine(), MeshRefinement::uniformly_refine(), TetGenIO::write(), PostscriptIO::write(), FroIO::write(), TecplotIO::write_ascii(), MEDITIO::write_ascii(), GMVIO::write_ascii_new_impl(), GMVIO::write_ascii_old_impl(), TecplotIO::write_binary(), GMVIO::write_discontinuous_gmv(), GmshIO::write_mesh(), GmshIO::write_post(), and GnuPlotIO::write_solution().

virtual const_element_iterator MeshBase::active_local_elements_begin (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual const_element_iterator MeshBase::active_local_elements_end (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual const_element_iterator MeshBase::active_local_subdomain_elements_begin ( const unsigned int  subdomain_id  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::active_local_subdomain_elements_begin ( const unsigned int  subdomain_id  )  [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual const_element_iterator MeshBase::active_local_subdomain_elements_end ( const unsigned int  subdomain_id  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::active_local_subdomain_elements_end ( const unsigned int  subdomain_id  )  [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual const_node_iterator MeshBase::active_nodes_begin (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual node_iterator MeshBase::active_nodes_begin (  )  [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual const_node_iterator MeshBase::active_nodes_end (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual node_iterator MeshBase::active_nodes_end (  )  [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual const_element_iterator MeshBase::active_not_local_elements_begin (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::active_not_local_elements_begin (  )  [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual const_element_iterator MeshBase::active_not_local_elements_end (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::active_not_local_elements_end (  )  [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual const_element_iterator MeshBase::active_pid_elements_begin ( const unsigned int  proc_id  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::active_pid_elements_begin ( const unsigned int  proc_id  )  [pure virtual, inherited]

virtual const_element_iterator MeshBase::active_pid_elements_end ( const unsigned int  proc_id  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::active_pid_elements_end ( const unsigned int  proc_id  )  [pure virtual, inherited]

virtual const_element_iterator MeshBase::active_type_elements_begin ( const ElemType  type  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::active_type_elements_begin ( const ElemType  type  )  [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

Referenced by MeshTools::n_active_elem_of_type().

virtual const_element_iterator MeshBase::active_type_elements_end ( const ElemType  type  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::active_type_elements_end ( const ElemType  type  )  [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

Referenced by MeshTools::n_active_elem_of_type().

virtual Node* MeshBase::add_node ( Node n  )  [pure virtual, inherited]

Add Node n to the end of the vertex array.

Implemented in ParallelMesh, and SerialMesh.

virtual Node* MeshBase::add_point ( const Point p,
const unsigned int  id = DofObject::invalid_id,
const unsigned int  proc_id = DofObject::invalid_processor_id 
) [pure virtual, inherited]

void UnstructuredMesh::all_first_order (  )  [virtual]

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

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

Definition at line 233 of file mesh_modification.C.

References MeshBase::_is_prepared, Elem::add_child(), MeshBase::boundary_info, Elem::build(), Elem::child(), MeshBase::elements_begin(), MeshBase::elements_end(), Elem::first_order_equivalent_type(), Elem::get_node(), Elem::has_children(), DofObject::id(), MeshBase::insert_elem(), Elem::n_children(), Elem::n_sides(), Elem::n_vertices(), Elem::p_level(), Elem::p_refinement_flag(), Elem::parent(), MeshBase::prepare_for_use(), DofObject::processor_id(), Elem::refinement_flag(), MeshBase::renumber_nodes_and_elements(), DofObject::set_id(), Elem::set_node(), Elem::set_p_level(), Elem::set_p_refinement_flag(), Elem::set_parent(), Elem::set_refinement_flag(), Elem::subdomain_id(), and Elem::type().

00234 {
00235   /*
00236    * when the mesh is not prepared,
00237    * at least renumber the nodes and 
00238    * elements, so that the node ids
00239    * are correct
00240    */
00241   if (!this->_is_prepared)
00242     this->renumber_nodes_and_elements ();
00243 
00244   START_LOG("all_first_order()", "Mesh");
00245 
00251   const_element_iterator endit = elements_end();
00252   for (const_element_iterator it = elements_begin();
00253        it != endit; ++it)
00254     {
00255       Elem* so_elem = *it;
00256 
00257       libmesh_assert (so_elem != NULL);
00258 
00259       /*
00260        * build the first-order equivalent, add to
00261        * the new_elements list.
00262        */
00263       Elem *newparent = so_elem->parent();
00264       Elem* lo_elem = Elem::build
00265         (Elem::first_order_equivalent_type
00266           (so_elem->type()), newparent).release();
00267 
00268 #ifdef LIBMESH_ENABLE_AMR
00269       /*
00270        * Add this element to it's parent if it has one
00271        */
00272       if (newparent)
00273         newparent->add_child(lo_elem);
00274 
00275       /*
00276        * Reset the parent links of any child elements
00277        */
00278       if (so_elem->has_children())
00279         {
00280           for (unsigned int c=0; c != so_elem->n_children(); ++c)
00281             so_elem->child(c)->set_parent(lo_elem);
00282         }
00283 
00284       /*
00285        * Copy as much data to the new element as makes sense
00286        */
00287       lo_elem->set_p_level(so_elem->p_level());
00288       lo_elem->set_refinement_flag(so_elem->refinement_flag());
00289       lo_elem->set_p_refinement_flag(so_elem->p_refinement_flag());
00290 #endif
00291 
00292       libmesh_assert (lo_elem->n_vertices() == so_elem->n_vertices());
00293 
00294       /*
00295        * By definition the vertices of the linear and
00296        * second order element are identically numbered.
00297        * transfer these.
00298        */
00299       for (unsigned int v=0; v < so_elem->n_vertices(); v++)
00300         lo_elem->set_node(v) = so_elem->get_node(v);
00301 
00308       libmesh_assert (lo_elem->n_sides() == so_elem->n_sides());
00309         
00310       for (unsigned int s=0; s<so_elem->n_sides(); s++)
00311         {
00312           const short int boundary_id =
00313             this->boundary_info->boundary_id (so_elem, s);
00314             
00315           if (boundary_id != this->boundary_info->invalid_id)
00316             this->boundary_info->add_side (lo_elem, s, boundary_id);
00317         }
00318 
00319       /*
00320        * The new first-order element is ready.
00321        * Inserting it into the mesh will replace and delete
00322        * the second-order element.
00323        */
00324       lo_elem->set_id(so_elem->id());
00325       lo_elem->processor_id() = so_elem->processor_id();
00326       lo_elem->subdomain_id() = so_elem->subdomain_id();
00327       this->insert_elem(lo_elem);
00328     }
00329 
00330   STOP_LOG("all_first_order()", "Mesh");
00331 
00332   // delete or renumber nodes, etc
00333   this->prepare_for_use();
00334 }

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

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

Implements MeshBase.

Definition at line 338 of file mesh_modification.C.

References MeshBase::_is_prepared, MeshBase::add_point(), MeshBase::boundary_info, Elem::build(), Elem::default_order(), MeshBase::elements_begin(), MeshBase::elements_end(), libMeshEnums::FIRST, Elem::get_node(), DofObject::id(), MeshBase::insert_elem(), DofObject::invalid_id, MeshBase::is_serial(), Elem::level(), std::max(), MeshBase::mesh_dimension(), MeshBase::n_elem(), MeshBase::n_nodes(), Elem::n_sides(), Elem::n_vertices(), MeshBase::node(), MeshBase::point(), MeshBase::prepare_for_use(), DofObject::processor_id(), MeshBase::processor_id(), MeshBase::renumber_nodes_and_elements(), MeshBase::reserve_nodes(), Elem::second_order_equivalent_type(), Elem::subdomain_id(), and Elem::type().

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

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

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

Gathers all elements and nodes of the mesh onto every processor

Reimplemented in ParallelMesh.

Definition at line 128 of file mesh_base.h.

Referenced by EquationSystems::allgather().

00128 {}

virtual const_element_iterator MeshBase::ancestor_elements_begin (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::ancestor_elements_begin (  )  [pure virtual, inherited]

virtual const_element_iterator MeshBase::ancestor_elements_end (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::ancestor_elements_end (  )  [pure virtual, inherited]

void MeshBase::clear (  )  [virtual, inherited]

Deletes all the data that are currently stored.

Reimplemented in ParallelMesh, and SerialMesh.

Definition at line 116 of file mesh_base.C.

References MeshBase::_is_prepared, MeshBase::_n_parts, MeshBase::boundary_info, and MeshBase::clear_point_locator().

Referenced by MeshTools::Generation::build_cube(), MeshTools::Generation::build_delaunay_square(), Triangle::copy_tri_to_mesh(), create_submesh(), VTKIO::read(), ExodusII_IO::read(), LegacyXdrIO::read_ascii(), LegacyXdrIO::read_binary(), LegacyXdrIO::read_mesh(), GmshIO::read_mesh(), OFFIO::read_stream(), MatlabIO::read_stream(), TriangleInterface::triangulate(), and MeshBase::~MeshBase().

00117 {
00118   // Reset the number of partitions
00119   _n_parts = 1;
00120 
00121   // Reset the _is_prepared flag
00122   _is_prepared = false;
00123 
00124   // Clear boundary information
00125   this->boundary_info->clear();
00126 
00127   // Clear our point locator.
00128   this->clear_point_locator();
00129 }

void MeshBase::clear_point_locator (  )  [inherited]

Releases the current PointLocator object.

Definition at line 295 of file mesh_base.C.

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

Referenced by MeshBase::clear(), and MeshBase::prepare_for_use().

00296 {
00297   _point_locator.reset(NULL);
00298 }

virtual AutoPtr<MeshBase> MeshBase::clone (  )  const [pure virtual, inherited]

Virtual "copy constructor"

Implemented in ParallelMesh, and SerialMesh.

Referenced by ErrorVector::plot_error().

bool UnstructuredMesh::contract (  )  [virtual]

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

Implements MeshBase.

Definition at line 936 of file unstructured_mesh.C.

References Elem::active(), Elem::ancestor(), Elem::contract(), MeshBase::delete_elem(), MeshBase::elem(), MeshBase::elements_begin(), MeshBase::elements_end(), Elem::parent(), MeshBase::renumber_nodes_and_elements(), and Elem::subactive().

00937 {
00938   START_LOG ("contract()", "Mesh");
00939 
00940   // Flag indicating if this call actually changes the mesh
00941   bool mesh_changed = false;
00942 
00943   element_iterator in        = elements_begin();
00944   element_iterator out       = elements_begin();
00945   const element_iterator end = elements_end();
00946 
00947 #ifdef DEBUG
00948   for ( ; in != end; ++in)
00949     if (*in != NULL)
00950       {
00951         Elem* elem = *in;
00952         libmesh_assert(elem->active() || elem->subactive() || elem->ancestor());
00953       }
00954   in = elements_begin();
00955 #endif
00956   
00957   // Loop over the elements.   
00958   for ( ; in != end; ++in)
00959     if (*in != NULL)
00960       {
00961         Elem* elem = *in;
00962 
00963         // Delete all the subactive ones
00964         if (elem->subactive())
00965           {
00966             // No level-0 element should be subactive.
00967             // Note that we CAN'T test elem->level(), as that 
00968             // touches elem->parent()->dim(), and elem->parent()
00969             // might have already been deleted!
00970             libmesh_assert (elem->parent() != NULL);
00971 
00972             // Delete the element
00973             // This just sets a pointer to NULL, and doesn't
00974             // invalidate any iterators
00975             this->delete_elem(elem);
00976             
00977             // the mesh has certainly changed
00978             mesh_changed = true;
00979           }
00980         else
00981           {
00982             // Compress all the active ones
00983             if (elem->active())
00984               elem->contract();
00985             else
00986               libmesh_assert (elem->ancestor());
00987           }
00988       }
00989 
00990   // Strip any newly-created NULL voids out of the element array
00991   this->renumber_nodes_and_elements();
00992 
00993   STOP_LOG ("contract()", "Mesh");
00994   
00995   return mesh_changed;
00996 }

void UnstructuredMesh::copy_nodes_and_elements ( const UnstructuredMesh other_mesh  )  [virtual]

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

Definition at line 94 of file unstructured_mesh.C.

References MeshBase::_dim, MeshBase::_is_prepared, MeshBase::_n_parts, Elem::add_child(), Elem::build(), MeshBase::elements_begin(), MeshBase::elements_end(), DofObject::id(), MeshBase::n_elem(), MeshBase::n_nodes(), Elem::node(), MeshBase::nodes_begin(), MeshBase::nodes_end(), Elem::p_refinement_flag(), Elem::parent(), DofObject::processor_id(), Elem::refinement_flag(), Elem::type(), and Elem::which_child_am_i().

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

00095 {
00096   // We're assuming our subclass data needs no copy
00097   libmesh_assert(_n_parts == other_mesh._n_parts);
00098   libmesh_assert(_dim == other_mesh._dim);
00099   libmesh_assert(_is_prepared == other_mesh._is_prepared);
00100 
00101   //Copy in Nodes
00102   {
00103     //Preallocate Memory if necessary
00104     this->reserve_nodes(other_mesh.n_nodes());
00105     
00106     const_node_iterator it = other_mesh.nodes_begin();
00107     const_node_iterator end = other_mesh.nodes_end();
00108 
00109     for (; it != end; ++it)
00110       {
00111         Node *oldn = *it;
00112 
00113         // Add new nodes in old node Point locations
00114         Node *newn = this->add_point(*oldn);
00115 
00116         // And start them off in the same subdomain
00117         newn->processor_id() = oldn->processor_id();
00118       }
00119   }
00120   
00121   //Copy in Elements
00122   {
00123     //Preallocate Memory if necessary
00124     this->reserve_elem(other_mesh.n_elem());
00125     
00126     // Loop over the elements
00127     MeshBase::const_element_iterator it = other_mesh.elements_begin();
00128     const MeshBase::const_element_iterator end = other_mesh.elements_end();
00129 
00130     // FIXME: Where do we set element IDs??
00131     for (; it != end; ++it)
00132     {
00133       //Look at the old element
00134       Elem *old = *it;
00135       //Build a new element
00136       Elem *newparent = old->parent() ?
00137           this->elem(old->parent()->id()) : NULL;
00138       AutoPtr<Elem> ap = Elem::build(old->type(), newparent);
00139       Elem * elem = ap.release();
00140 
00141 #ifdef LIBMESH_ENABLE_AMR
00142       //Create the parent's child pointers if necessary
00143       if (newparent)
00144         {
00145           // Make sure we have space for those child pointers
00146           newparent->add_child(elem);
00147 
00148           // We'd better be adding these in the correct order
00149           libmesh_assert (newparent->which_child_am_i(elem) ==
00150                   old->parent()->which_child_am_i(old));
00151         }
00152       
00153       // Copy the refinement flags
00154       elem->set_refinement_flag(old->refinement_flag());
00155       elem->set_p_refinement_flag(old->p_refinement_flag());
00156 #endif // #ifdef LIBMESH_ENABLE_AMR
00157 
00158       //Assign all the nodes
00159       for(unsigned int i=0;i<elem->n_nodes();i++)
00160         elem->set_node(i) = &this->node(old->node(i));
00161       
00162       //Hold onto it
00163       this->add_elem(elem);
00164 
00165       // And start it off in the same subdomain
00166       elem->processor_id() = old->processor_id();
00167     }
00168   }
00169   
00170   //Finally prepare the Mesh for use
00171   this->prepare_for_use();
00172 }

void UnstructuredMesh::create_pid_mesh ( UnstructuredMesh pid_mesh,
const unsigned int  pid 
) const

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

Definition at line 809 of file unstructured_mesh.C.

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

00811 {
00812 
00813   // Issue a warning if the number the number of processors
00814   // currently available is less that that requested for
00815   // partitioning.  This is not necessarily an error since
00816   // you may run on one processor and still partition the
00817   // mesh into several partitions.
00818 #ifdef DEBUG
00819   if (this->n_processors() < pid)
00820     {
00821       std::cout << "WARNING:  You are creating a "
00822                 << "mesh for a processor id (="
00823                 << pid
00824                 << ") greater than "
00825                 << "the number of processors available for "
00826                 << "the calculation. (="
00827                 << libMesh::n_processors()
00828                 << ")."
00829                 << std::endl;
00830     }
00831 #endif
00832   
00833   // Create iterators to loop over the list of elements
00834 //   const_active_pid_elem_iterator       it(this->elements_begin(),   pid);
00835 //   const const_active_pid_elem_iterator it_end(this->elements_end(), pid);
00836 
00837   const_element_iterator       it     = this->active_pid_elements_begin(pid);
00838   const const_element_iterator it_end = this->active_pid_elements_end(pid);
00839     
00840   this->create_submesh (pid_mesh, it, it_end);
00841 }

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

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

Definition at line 849 of file unstructured_mesh.C.

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

Referenced by create_pid_mesh().

00852 {
00853   // Just in case the subdomain_mesh already has some information
00854   // in it, get rid of it.
00855   new_mesh.clear();
00856 
00857   // Fail if (*this == new_mesh), we cannot create a submesh inside ourself!
00858   // This may happen if the user accidently passes the original mesh into
00859   // this function!  We will check this by making sure we did not just
00860   // clear ourself.
00861   libmesh_assert (this->n_nodes() != 0);
00862   libmesh_assert (this->n_elem()  != 0); 
00863 
00864   // How the nodes on this mesh will be renumbered to nodes
00865   // on the new_mesh.  
00866   std::vector<unsigned int> new_node_numbers (this->n_nodes());
00867 
00868   std::fill (new_node_numbers.begin(),
00869              new_node_numbers.end(),
00870              libMesh::invalid_uint);
00871 
00872   
00873   
00874   // the number of nodes on the new mesh, will be incremented
00875   unsigned int n_new_nodes = 0;
00876   unsigned int n_new_elem  = 0;
00877     
00878   for (; it != it_end; ++it)
00879     {
00880       // increment the new element counter
00881       n_new_elem++;
00882         
00883       const Elem* old_elem = *it;
00884 
00885       // Add an equivalent element type to the new_mesh
00886       Elem* new_elem = 
00887         new_mesh.add_elem (Elem::build(old_elem->type()).release());
00888 
00889       libmesh_assert (new_elem != NULL);
00890         
00891       // Loop over the nodes on this element.  
00892       for (unsigned int n=0; n<old_elem->n_nodes(); n++)
00893         {
00894           libmesh_assert (old_elem->node(n) < new_node_numbers.size());
00895 
00896           if (new_node_numbers[old_elem->node(n)] == libMesh::invalid_uint)
00897             {
00898               new_node_numbers[old_elem->node(n)] = n_new_nodes;
00899 
00900               // Add this node to the new mesh
00901               new_mesh.add_point (old_elem->point(n));
00902 
00903               // Increment the new node counter
00904               n_new_nodes++;
00905             }
00906 
00907           // Define this element's connectivity on the new mesh
00908           libmesh_assert (new_node_numbers[old_elem->node(n)] < new_mesh.n_nodes());
00909             
00910           new_elem->set_node(n) = new_mesh.node_ptr (new_node_numbers[old_elem->node(n)]);
00911         }
00912 
00913       // Copy ids for this element
00914       new_elem->subdomain_id() = old_elem->subdomain_id();
00915       new_elem->processor_id() = old_elem->processor_id();
00916       
00917       // Maybe add boundary conditions for this element
00918       for (unsigned int s=0; s<old_elem->n_sides(); s++)
00919         if (old_elem->neighbor(s) == NULL)
00920           if (this->boundary_info->boundary_id (old_elem, s) !=
00921               this->boundary_info->invalid_id)
00922             new_mesh.boundary_info->add_side (new_elem,
00923                                              s,
00924                                              this->boundary_info->boundary_id (old_elem, s));
00925     } // end loop over elements
00926   
00927 
00928   // Prepare the new_mesh for use
00929   new_mesh.prepare_for_use();
00930   
00931 }

virtual void MeshBase::delete_elem ( Elem e  )  [pure virtual, inherited]

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.

Implemented in ParallelMesh, and SerialMesh.

Referenced by MeshTools::Modification::all_tri(), MeshTools::Generation::build_cube(), contract(), MeshTools::Modification::flatten(), and TetGenMeshInterface::pointset_convexhull().

virtual void MeshBase::delete_node ( Node n  )  [pure virtual, inherited]

Removes the Node n from the mesh.

Implemented in ParallelMesh, and SerialMesh.

virtual void 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 ParallelMesh.

Definition at line 135 of file mesh_base.h.

Referenced by EquationSystems::init(), and MeshBase::prepare_for_use().

00135 {}

virtual const_element_iterator MeshBase::elements_begin (  )  const [pure virtual, inherited]

const Elem iterator accessor functions.

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::elements_begin (  )  [pure virtual, inherited]

Elem iterator accessor functions. These must be defined in Concrete base classes.

Implemented in ParallelMesh, and SerialMesh.

Referenced by EquationSystems::_add_system_to_nodes_and_elems(), MeshRefinement::_coarsen_elements(), MeshRefinement::_refine_elements(), MeshRefinement::add_p_to_h_refinement(), VariationalMeshSmoother::adjust_adapt_data(), all_first_order(), all_second_order(), MeshTools::Modification::all_tri(), EquationSystems::allgather(), MeshData::assign(), MeshCommunication::assign_global_indices(), MeshTools::Generation::build_cube(), MeshTools::Generation::build_delaunay_square(), MeshTools::build_nodes_to_elem_map(), MeshRefinement::clean_refinement_flags(), MeshRefinement::coarsen_elements(), CentroidPartitioner::compute_centroids(), contract(), copy_nodes_and_elements(), DofMap::create_dof_constraints(), DofMap::distribute_dofs(), MeshTools::elem_types(), UNVIO::element_out(), find_neighbors(), MeshTools::Modification::flatten(), MeshTools::get_not_subactive_node_ids(), EquationSystems::init(), MeshTools::libmesh_assert_no_links_to_elem(), MeshTools::libmesh_assert_valid_neighbors(), MeshTools::libmesh_assert_valid_node_pointers(), MeshTools::libmesh_assert_valid_refinement_flags(), MeshRefinement::make_coarsening_compatible(), MeshRefinement::make_flags_parallel_consistent(), MeshBase::n_sub_elem(), TetGenMeshInterface::pointset_convexhull(), MeshRefinement::refine_and_coarsen_elements(), MeshRefinement::refine_elements(), EquationSystems::reinit(), DofMap::reinit(), Partitioner::set_node_processor_ids(), Partitioner::single_partition(), MeshRefinement::switch_h_to_p_refinement(), MeshTools::total_weight(), TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole(), and LegacyXdrIO::write_mesh().

virtual const_element_iterator MeshBase::elements_end (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::elements_end (  )  [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

Referenced by EquationSystems::_add_system_to_nodes_and_elems(), MeshRefinement::_coarsen_elements(), MeshRefinement::_refine_elements(), MeshRefinement::add_p_to_h_refinement(), VariationalMeshSmoother::adjust_adapt_data(), all_first_order(), all_second_order(), MeshTools::Modification::all_tri(), EquationSystems::allgather(), MeshData::assign(), MeshCommunication::assign_global_indices(), MeshTools::Generation::build_cube(), MeshTools::Generation::build_delaunay_square(), MeshTools::build_nodes_to_elem_map(), MeshRefinement::clean_refinement_flags(), MeshRefinement::coarsen_elements(), CentroidPartitioner::compute_centroids(), contract(), copy_nodes_and_elements(), DofMap::create_dof_constraints(), DofMap::distribute_dofs(), MeshTools::elem_types(), UNVIO::element_out(), find_neighbors(), MeshTools::Modification::flatten(), MeshTools::get_not_subactive_node_ids(), EquationSystems::init(), MeshTools::libmesh_assert_no_links_to_elem(), MeshTools::libmesh_assert_valid_neighbors(), MeshTools::libmesh_assert_valid_node_pointers(), MeshTools::libmesh_assert_valid_refinement_flags(), MeshRefinement::make_coarsening_compatible(), MeshRefinement::make_flags_parallel_consistent(), MeshBase::n_sub_elem(), TetGenMeshInterface::pointset_convexhull(), MeshRefinement::refine_and_coarsen_elements(), MeshRefinement::refine_elements(), EquationSystems::reinit(), DofMap::reinit(), Partitioner::set_node_processor_ids(), Partitioner::single_partition(), MeshRefinement::switch_h_to_p_refinement(), MeshTools::total_weight(), TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole(), and LegacyXdrIO::write_mesh().

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

Other functions from MeshBase requiring re-definition.

Here we look at all of the child elements.

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 be out of date - 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 MeshBase.

Definition at line 185 of file unstructured_mesh.C.

References MeshBase::_dim, Elem::active(), Elem::ancestor(), Elem::centroid(), Elem::child(), MeshBase::elem(), MeshBase::elements_begin(), MeshBase::elements_end(), Elem::has_children(), Elem::hmin(), DofObject::id(), Elem::key(), Elem::level(), MeshBase::level_elements_begin(), MeshBase::level_elements_end(), MeshTools::libmesh_assert_valid_neighbors(), Elem::n_children(), MeshTools::n_levels(), Elem::n_neighbors(), Elem::neighbor(), Elem::parent(), MeshBase::processor_id(), DofObject::processor_id(), remote_elem, Elem::set_neighbor(), Elem::side(), and Elem::subactive().

Referenced by MeshCommunication::allgather().

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

std::string MeshBase::get_info (  )  const [inherited]

Returns:
a string containing relevant information about the mesh.

Definition at line 221 of file mesh_base.C.

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

Referenced by MeshBase::print_info().

00222 {
00223   std::ostringstream out;
00224 
00225   out << " Mesh Information:"                                  << '\n'
00226       << "  mesh_dimension()="    << this->mesh_dimension()    << '\n'
00227       << "  spatial_dimension()=" << this->spatial_dimension() << '\n'
00228       << "  n_nodes()="           << this->n_nodes()           << '\n'
00229       << "    n_local_nodes()="   << this->n_local_nodes()     << '\n'
00230       << "  n_elem()="            << this->n_elem()            << '\n'
00231       << "    n_local_elem()="    << this->n_local_elem()      << '\n'
00232 #ifdef LIBMESH_ENABLE_AMR
00233       << "    n_active_elem()="   << this->n_active_elem()     << '\n'
00234 #endif
00235       << "  n_subdomains()="      << this->n_subdomains()      << '\n'
00236       << "  n_processors()="      << this->n_processors()      << '\n'
00237       << "  processor_id()="      << this->processor_id()      << '\n';
00238 
00239   return out.str();
00240 }

virtual Elem* MeshBase::insert_elem ( Elem e  )  [pure virtual, inherited]

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

Implemented in ParallelMesh, and SerialMesh.

Referenced by all_first_order(), and all_second_order().

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

References MeshBase::_is_prepared.

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

00115   { return _is_prepared; }

virtual const_element_iterator MeshBase::level_elements_begin ( const unsigned int  level  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::level_elements_begin ( const unsigned int  level  )  [pure virtual, inherited]

virtual const_element_iterator MeshBase::level_elements_end ( const unsigned int  level  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::level_elements_end ( const unsigned int  level  )  [pure virtual, inherited]

virtual const_element_iterator MeshBase::local_elements_begin (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual const_element_iterator MeshBase::local_elements_end (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual const_element_iterator MeshBase::local_level_elements_begin ( const unsigned int  level  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::local_level_elements_begin ( const unsigned int  level  )  [pure virtual, inherited]

virtual const_element_iterator MeshBase::local_level_elements_end ( const unsigned int  level  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::local_level_elements_end ( const unsigned int  level  )  [pure virtual, inherited]

virtual const_node_iterator MeshBase::local_nodes_begin (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual const_node_iterator MeshBase::local_nodes_end (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual const_element_iterator MeshBase::local_not_level_elements_begin ( const unsigned int  level  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::local_not_level_elements_begin ( const unsigned int  level  )  [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual const_element_iterator MeshBase::local_not_level_elements_end ( const unsigned int  level  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::local_not_level_elements_end ( const unsigned int  level  )  [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual unsigned int MeshBase::max_elem_id (  )  const [pure virtual, inherited]

virtual unsigned int MeshBase::max_node_id (  )  const [pure virtual, inherited]

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

unsigned int MeshBase::n_active_elem_on_proc ( const unsigned int  proc  )  const [inherited]

Returns the number of active elements on processor proc.

Definition at line 182 of file mesh_base.C.

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

Referenced by MeshBase::n_active_local_elem().

00183 {
00184   libmesh_assert (proc_id < libMesh::n_processors());
00185   return static_cast<unsigned int>(std::distance (this->active_pid_elements_begin(proc_id),
00186                                                   this->active_pid_elements_end  (proc_id)));
00187 }

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

Returns the number of active elements on the local processor.

Definition at line 253 of file mesh_base.h.

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

Referenced by ParmetisPartitioner::assign_partitioning(), ParmetisPartitioner::build_graph(), and ParmetisPartitioner::initialize().

00254   { return this->n_active_elem_on_proc (libMesh::processor_id()); }

unsigned int MeshBase::n_active_sub_elem (  )  const [inherited]

Same, but only counts active elements.

Definition at line 206 of file mesh_base.C.

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

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

00207 {
00208   unsigned int ne=0;
00209 
00210   const_element_iterator       el  = this->active_elements_begin();
00211   const const_element_iterator end = this->active_elements_end(); 
00212 
00213   for (; el!=end; ++el)
00214     ne += (*el)->n_sub_elem(); 
00215 
00216   return ne;
00217 }

unsigned int MeshBase::n_elem_on_proc ( const unsigned int  proc  )  const [inherited]

Returns the number of elements on processor proc.

Definition at line 169 of file mesh_base.C.

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

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

00170 {
00171   // We're either counting a processor's elements or unpartitioned
00172   // elements
00173   libmesh_assert (proc_id < libMesh::n_processors() ||
00174           proc_id == DofObject::invalid_processor_id);
00175   
00176   return static_cast<unsigned int>(std::distance (this->pid_elements_begin(proc_id),
00177                                                   this->pid_elements_end  (proc_id)));
00178 }

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

Returns the number of elements on the local processor.

Definition at line 236 of file mesh_base.h.

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

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

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

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

Returns the number of nodes on the local processor.

Definition at line 172 of file mesh_base.h.

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

Referenced by MeshBase::get_info(), ParallelMesh::parallel_n_nodes(), and ParallelMesh::update_parallel_id_counts().

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

virtual unsigned int MeshBase::n_nodes (  )  const [pure virtual, inherited]

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.

Implemented in ParallelMesh, and SerialMesh.

Referenced by all_second_order(), MeshCommunication::assign_global_indices(), MeshTools::Generation::build_cube(), MeshTools::Generation::build_delaunay_square(), MeshTools::build_nodes_to_elem_map(), EquationSystems::build_solution_vector(), copy_nodes_and_elements(), create_submesh(), MeshTools::Modification::distort(), MeshTools::find_boundary_nodes(), MeshBase::get_info(), TetGenMeshInterface::get_node_index(), LaplaceMeshSmoother::init(), ExodusII_IO_Helper::initialize(), TreeNode< N >::insert(), MeshRefinement::limit_level_mismatch_at_node(), VTKIO::nodes_to_vtk(), ParallelMesh::ParallelMesh(), TetGenMeshInterface::pointset_convexhull(), ExodusII_IO::read(), MeshTools::Modification::rotate(), MeshTools::Modification::scale(), VariationalMeshSmoother::smooth(), LaplaceMeshSmoother::smooth(), MeshTools::Modification::smooth(), VTKIO::solution_to_vtk(), MeshTools::subdomain_bounding_box(), BoundaryInfo::sync(), VTKIO::system_vectors_to_vtk(), TreeNode< N >::transform_nodes_to_elements(), MeshTools::Modification::translate(), MeshData::translate(), TriangleInterface::triangulate(), TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole(), TetGenMeshInterface::triangulate_pointset(), XdrIO::write(), TetGenIO::write(), FroIO::write(), TecplotIO::write_ascii(), MEDITIO::write_ascii(), GMVIO::write_ascii_new_impl(), GMVIO::write_ascii_old_impl(), TecplotIO::write_binary(), UNVIO::write_implementation(), GmshIO::write_mesh(), GmshIO::write_post(), XdrIO::write_serialized_nodes(), LegacyXdrIO::write_soln(), DivaIO::write_stream(), and VariationalMeshSmoother::writegr().

unsigned int MeshBase::n_nodes_on_proc ( const unsigned int  proc  )  const [inherited]

Returns the number of nodes on processor proc.

Definition at line 156 of file mesh_base.C.

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

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

00157 {
00158   // We're either counting a processor's nodes or unpartitioned
00159   // nodes
00160   libmesh_assert (proc_id < libMesh::n_processors() ||
00161           proc_id == DofObject::invalid_processor_id);
00162   
00163   return static_cast<unsigned int>(std::distance (this->pid_nodes_begin(proc_id),
00164                                                   this->pid_nodes_end  (proc_id)));
00165 }

unsigned int 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 428 of file mesh_base.h.

References MeshBase::_n_parts.

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

00429   { return _n_parts; }

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

unsigned int 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 191 of file mesh_base.C.

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

00192 {
00193   unsigned int ne=0;
00194 
00195   const_element_iterator       el  = this->elements_begin();
00196   const const_element_iterator end = this->elements_end(); 
00197 
00198   for (; el!=end; ++el)
00199     ne += (*el)->n_sub_elem(); 
00200 
00201   return ne;
00202 }

unsigned int 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 133 of file mesh_base.C.

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

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

00134 {
00135   // This requires an inspection on every processor
00136   parallel_only();
00137 
00138   const_element_iterator       el  = this->active_elements_begin();
00139   const const_element_iterator end = this->active_elements_end(); 
00140 
00141   std::set<unsigned int> subdomain_ids;
00142   
00143   for (; el!=end; ++el)
00144     subdomain_ids.insert((*el)->subdomain_id());
00145 
00146   // Some subdomains may only live on other processors
00147   Parallel::set_union(subdomain_ids, 0);
00148 
00149   unsigned int n_sbd_ids = subdomain_ids.size();
00150   Parallel::broadcast(n_sbd_ids);
00151 
00152   return n_sbd_ids;
00153 }

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

Returns the number of elements owned by no processor.

Definition at line 242 of file mesh_base.h.

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

Referenced by ParallelMesh::parallel_n_elem(), and ParallelMesh::update_parallel_id_counts().

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

Returns the number of nodes owned by no processor.

Definition at line 178 of file mesh_base.h.

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

Referenced by ParallelMesh::parallel_n_nodes(), and ParallelMesh::update_parallel_id_counts().

virtual Node& MeshBase::node ( const unsigned int  i  )  [pure virtual, inherited]

Return a reference to the $ i^{th} $ node.

Implemented in ParallelMesh, and SerialMesh.

virtual Node* & MeshBase::node_ptr ( const unsigned int  i  )  [pure virtual, inherited]

Return a pointer to the $ i^{th} $ node.

Implemented in ParallelMesh, and SerialMesh.

virtual const_node_iterator MeshBase::nodes_begin (  )  const [pure virtual, inherited]

const Node iterator accessor functions.

Implemented in ParallelMesh, and SerialMesh.

virtual const_node_iterator MeshBase::nodes_end (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual const_element_iterator MeshBase::not_active_elements_begin (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::not_active_elements_begin (  )  [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

Referenced by Partitioner::set_node_processor_ids().

virtual const_element_iterator MeshBase::not_active_elements_end (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::not_active_elements_end (  )  [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

Referenced by Partitioner::set_node_processor_ids().

virtual const_element_iterator MeshBase::not_ancestor_elements_begin (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::not_ancestor_elements_begin (  )  [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual const_element_iterator MeshBase::not_ancestor_elements_end (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::not_ancestor_elements_end (  )  [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual const_element_iterator MeshBase::not_level_elements_begin ( const unsigned int  level  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::not_level_elements_begin ( const unsigned int  level  )  [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual const_element_iterator MeshBase::not_level_elements_end ( const unsigned int  level  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::not_level_elements_end ( const unsigned int  level  )  [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual const_element_iterator MeshBase::not_local_elements_begin (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::not_local_elements_begin (  )  [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual const_element_iterator MeshBase::not_local_elements_end (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::not_local_elements_end (  )  [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual const_element_iterator MeshBase::not_subactive_elements_begin (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::not_subactive_elements_begin (  )  [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual const_element_iterator MeshBase::not_subactive_elements_end (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::not_subactive_elements_end (  )  [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

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

Call the default partitioner (currently metis_partition()).

Definition at line 259 of file mesh_base.C.

References MeshBase::partitioner().

Referenced by MeshBase::prepare_for_use().

00260 {
00261   if (partitioner().get()) // "NULL" means don't partition
00262     partitioner()->partition (*this, n_parts);
00263 }

virtual AutoPtr<Partitioner>& MeshBase::partitioner (  )  [inline, virtual, inherited]

A partitioner to use at each prepare_for_use()

Definition at line 103 of file mesh_base.h.

References MeshBase::_partitioner.

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

00103 { return _partitioner; }

virtual const_element_iterator MeshBase::pid_elements_begin ( const unsigned int  proc_id  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::pid_elements_begin ( const unsigned int  proc_id  )  [pure virtual, inherited]

virtual const_element_iterator MeshBase::pid_elements_end ( const unsigned int  proc_id  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::pid_elements_end ( const unsigned int  proc_id  )  [pure virtual, inherited]

virtual const_node_iterator MeshBase::pid_nodes_begin ( const unsigned int  proc_id  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual node_iterator MeshBase::pid_nodes_begin ( const unsigned int  proc_id  )  [pure virtual, inherited]

virtual const_node_iterator MeshBase::pid_nodes_end ( const unsigned int  proc_id  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual node_iterator MeshBase::pid_nodes_end ( const unsigned int  proc_id  )  [pure virtual, inherited]

const PointLocatorBase & MeshBase::point_locator (  )  const [inherited]

returns a reference to a PointLocatorBase object for this mesh.

Definition at line 285 of file mesh_base.C.

References MeshBase::_point_locator, PointLocatorBase::build(), AutoPtr< Tp >::get(), AutoPtr< Tp >::release(), AutoPtr< Tp >::reset(), and MeshEnums::TREE.

Referenced by PeriodicBoundaries::neighbor().

00286 {
00287   if (_point_locator.get() == NULL)
00288     _point_locator.reset (PointLocatorBase::build(TREE, *this).release());
00289 
00290   return *_point_locator;
00291 }

void 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 read_xda_file boolean flag is true when prepare_for_use is called from Mesh::read after reading an xda file. It prevents the renumbering of nodes and elements. In general, leave this at the default value of false.

Definition at line 80 of file mesh_base.C.

References MeshBase::_is_prepared, MeshBase::clear_point_locator(), MeshBase::delete_remote_elements(), MeshBase::find_neighbors(), MeshBase::partition(), and MeshBase::renumber_nodes_and_elements().

Referenced by all_first_order(), all_second_order(), MeshTools::Modification::all_tri(), MeshTools::Generation::build_cube(), InfElemBuilder::build_inf_elem(), MeshRefinement::coarsen_elements(), Triangle::copy_tri_to_mesh(), create_submesh(), MeshTools::Modification::flatten(), read(), MeshRefinement::refine_and_coarsen_elements(), MeshRefinement::refine_elements(), BoundaryInfo::sync(), MeshRefinement::uniformly_coarsen(), and MeshRefinement::uniformly_refine().

00081 {  
00082   // Renumber the nodes and elements so that they in contiguous
00083   // blocks.  By default, skip_renumber_nodes_and_elements is false,
00084   // however we may skip this step by passing
00085   // skip_renumber_nodes_and_elements==true to this function.
00086   //
00087   // Instances where you if prepare_for_use() should not renumber the nodes
00088   // and elements include reading in e.g. an xda/r or gmv file. In
00089   // this case, the ordering of the nodes may depend on an accompanying
00090   // solution, and the node ordering cannot be changed.
00091   if(!skip_renumber_nodes_and_elements)
00092     this->renumber_nodes_and_elements();
00093   
00094   // Let all the elements find their neighbors
00095   this->find_neighbors();
00096 
00097   // Partition the mesh.
00098   this->partition();
00099   
00100   // If we're using ParallelMesh, we'll want it parallelized.
00101   this->delete_remote_elements();
00102 
00103   if(!skip_renumber_nodes_and_elements)
00104     this->renumber_nodes_and_elements();
00105 
00106   // Reset our PointLocator.  This needs to happen any time the elements
00107   // in the underlying elements in the mesh have changed, so we do it here.
00108   this->clear_point_locator();
00109 
00110   // The mesh is now prepared for use.
00111   _is_prepared = true;
00112 }

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

Prints relevant information about the mesh.

Definition at line 243 of file mesh_base.C.

References MeshBase::get_info().

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

00244 {
00245   os << this->get_info()
00246      << std::endl;
00247 }

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

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.

Implements MeshBase.

Definition at line 464 of file unstructured_mesh.C.

References XdrIO::binary(), is_parallel_file_format(), XdrIO::legacy(), MeshBase::prepare_for_use(), libMesh::processor_id(), and XdrIO::read().

00467 {
00468   // See if the file exists.  Perform this check on all processors
00469   // so that the code is terminated properly in the case that the
00470   // file does not exist.
00471   {
00472     std::ifstream in (name.c_str());
00473     
00474     if (!in.good())
00475       {
00476         std::cerr << "ERROR: cannot locate specified file:\n\t"
00477                   << name
00478                   << std::endl;
00479         libmesh_error();
00480       }
00481   }
00482 
00483   // Set the skip_renumber_nodes_and_elements flag on all processors.
00484   // This ensures that renumber_nodes_and_elements is *not* called
00485   // during prepare_for_use() for certain types of mesh files.
00486   // This is required in cases where there is an associated solution
00487   // file which expects a certain ordering of the nodes.
00488   if(name.rfind(".gmv")+4==name.size())
00489     {
00490       skip_renumber_nodes_and_elements =  true;
00491     }
00492   
00493   // Look for parallel formats first
00494   if (is_parallel_file_format(name))
00495     {      
00496       // no need to handling bz2 files here -- the Xdr class does that.
00497       if ((name.rfind(".xda") < name.size()) ||
00498           (name.rfind(".xdr") < name.size()))
00499         {
00500           XdrIO xdr_io(*this);
00501 
00502           // .xda* ==> bzip2/gzip/ASCII flavors
00503           if (name.rfind(".xda") < name.size())
00504             {
00505               xdr_io.binary() = false;
00506               xdr_io.read (name);
00507             }
00508           else // .xdr* ==> true binary XDR file
00509             {
00510               xdr_io.binary() = true;
00511               xdr_io.read (name);
00512             }
00513 
00514           // The xdr_io object gets constructed with legacy() == false.
00515           // if legacy() == true then it means that a legacy file was detected and
00516           // thus processor 0 performed the read. We therefore need to broadcast the
00517           // mesh.  Further, for this flavor of mesh solution data ordering is tied
00518           // to the node ordering, so we better not reorder the nodes!
00519           if (xdr_io.legacy())
00520             {
00521               skip_renumber_nodes_and_elements = true;
00522               MeshCommunication().broadcast(*this);
00523             }
00524         }      
00525     }
00526 
00527   // Serial mesh formats
00528   else
00529     {
00530       START_LOG("read()", "Mesh");  
00531   
00532       // Read the file based on extension.  Only processor 0
00533       // needs to read the mesh.  It will then broadcast it and
00534       // the other processors will pick it up
00535       if (libMesh::processor_id() == 0)
00536         {
00537           // Nasty hack for reading/writing zipped files
00538           std::string new_name = name;
00539           if (name.size() - name.rfind(".bz2") == 4)
00540             {
00541               new_name.erase(new_name.end() - 4, new_name.end());
00542               std::string system_string = "bunzip2 -f -k ";
00543               system_string += name;
00544               START_LOG("system(bunzip2)", "Mesh");
00545               if (std::system(system_string.c_str()))
00546                 libmesh_file_error(system_string);
00547               STOP_LOG("system(bunzip2)", "Mesh");
00548             }
00549 
00550           if (new_name.rfind(".mat") < new_name.size())
00551             MatlabIO(*this).read(new_name);
00552           
00553           else if (new_name.rfind(".ucd") < new_name.size())
00554             UCDIO(*this).read (new_name);
00555           
00556           else if ((new_name.rfind(".off")  < new_name.size()) ||
00557                    (new_name.rfind(".ogl")  < new_name.size()) ||
00558                    (new_name.rfind(".oogl") < new_name.size()))
00559             OFFIO(*this).read (new_name);
00560      
00561           else if (new_name.rfind(".mgf") < new_name.size())
00562             LegacyXdrIO(*this,true).read_mgf (new_name);
00563       
00564           else if (new_name.rfind(".unv") < new_name.size())
00565             {
00566               if (mesh_data == NULL)
00567                 {
00568                   std::cerr << "Error! You must pass a "
00569                             << "valid MeshData pointer to "
00570                             << "read UNV files!" << std::endl;
00571                   libmesh_error();
00572                 }
00573               UNVIO(*this, *mesh_data).read (new_name);
00574             }
00575       
00576           else if ((new_name.rfind(".node")  < new_name.size()) ||
00577                    (new_name.rfind(".ele")   < new_name.size()))
00578             TetGenIO(*this,mesh_data).read (new_name);
00579 
00580           else if (new_name.rfind(".exd") < new_name.size() ||
00581                    new_name.rfind(".e") < new_name.size())
00582             ExodusII_IO(*this).read (new_name);
00583           
00584           else if (new_name.rfind(".msh") < new_name.size())
00585             GmshIO(*this).read (new_name);
00586 
00587           else if (new_name.rfind(".gmv") < new_name.size())
00588             GMVIO(*this).read (new_name);
00589 
00590           else if (new_name.rfind(".vtu") < new_name.size())
00591             VTKIO(*this).read(new_name);
00592       
00593           else
00594             {
00595               std::cerr << " ERROR: Unrecognized file extension: " << name
00596                         << "\n   I understand the following:\n\n"
00597                         << "     *.e    -- Sandia's ExodusII format\n"
00598                         << "     *.exd  -- Sandia's ExodusII format\n"
00599                         << "     *.gmv  -- LANL's General Mesh Viewer format\n"
00600                         << "     *.mat  -- Matlab triangular ASCII file\n"
00601                         << "     *.off  -- OOGL OFF surface format\n"
00602                         << "     *.ucd  -- AVS's ASCII UCD format\n"
00603                         << "     *.unv  -- I-deas Universal format\n"
00604                         << "     *.vtu  -- Paraview VTK format\n"
00605                         << "     *.xda  -- libMesh ASCII format\n"
00606                         << "     *.xdr  -- libMesh binary format\n"
00607                         << "     *.gz   -- any above format gzipped\n"
00608                         << "     *.bz2  -- any above format bzip2'ed\n"
00609 
00610                         << std::endl;
00611               libmesh_error();    
00612             }    
00613           
00614           // If we temporarily decompressed a .bz2 file, remove the
00615           // uncompressed version
00616           if (name.size() - name.rfind(".bz2") == 4)
00617             std::remove(new_name.c_str());
00618         }
00619       
00620   
00621       STOP_LOG("read()", "Mesh");
00622 
00623       // Send the mesh & bcs (which are now only on processor 0) to the other
00624       // processors
00625       MeshCommunication().broadcast (*this);
00626     }
00627 
00628   
00629   // Done reading the mesh.  Now prepare it for use.
00630   this->prepare_for_use(skip_renumber_nodes_and_elements);
00631 
00632 }

unsigned int 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 267 of file mesh_base.C.

References MeshBase::_n_parts, MeshBase::active_elements_begin(), MeshBase::active_elements_end(), and std::max().

00268 {
00269   const_element_iterator       el  = this->active_elements_begin();
00270   const const_element_iterator end = this->active_elements_end(); 
00271 
00272   unsigned int max_proc_id=0;
00273   
00274   for (; el!=end; ++el)
00275     max_proc_id = std::max(max_proc_id, static_cast<unsigned int>((*el)->processor_id()));
00276 
00277   // The number of partitions is one more than the max processor ID.
00278   _n_parts = max_proc_id+1;
00279 
00280   return _n_parts;
00281 }

virtual void MeshBase::renumber_elem ( unsigned int  old_id,
unsigned int  new_id 
) [pure virtual, inherited]

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.

Implemented in ParallelMesh, and SerialMesh.

Referenced by MeshCommunication::make_elems_parallel_consistent().

virtual void MeshBase::renumber_node ( unsigned int  old_id,
unsigned int  new_id 
) [pure virtual, inherited]

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.

Implemented in ParallelMesh, and SerialMesh.

Referenced by MeshCommunication::make_node_ids_parallel_consistent().

virtual void MeshBase::renumber_nodes_and_elements (  )  [pure virtual, inherited]

After partitoning a mesh it is useful to renumber the nodes and elements so that they lie in contiguous blocks on the processors. This method does just that.

Implemented in ParallelMesh, and SerialMesh.

Referenced by all_first_order(), all_second_order(), contract(), and MeshBase::prepare_for_use().

virtual void MeshBase::reserve_elem ( const unsigned int  ne  )  [pure virtual, inherited]

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.

Implemented in ParallelMesh, and SerialMesh.

Referenced by MeshTools::Generation::build_cube(), XdrIO::read(), ExodusII_IO::read(), LegacyXdrIO::read_mesh(), and GmshIO::read_mesh().

virtual void MeshBase::reserve_nodes ( const unsigned int  nn  )  [pure virtual, inherited]

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.

Implemented in ParallelMesh, and SerialMesh.

Referenced by all_second_order(), MeshTools::Generation::build_cube(), XdrIO::read(), ExodusII_IO::read(), LegacyXdrIO::read_mesh(), and GmshIO::read_mesh().

void MeshBase::set_mesh_dimension ( unsigned int  d  )  [inline, inherited]

Resets the logical dimension of the mesh. Should only be called on an empty mesh.

Definition at line 147 of file mesh_base.h.

References MeshBase::_dim, and MeshBase::n_elem().

Referenced by MeshTools::Generation::build_cube(), MeshTools::Generation::build_delaunay_square(), Triangle::copy_tri_to_mesh(), and TriangleInterface::triangulate().

00148   { libmesh_assert(!this->n_elem()); _dim = d; }

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

Returns a writeable reference to the number of partitions.

Definition at line 677 of file mesh_base.h.

References MeshBase::_n_parts.

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

00678   { return _n_parts; }

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

Returns the spatial dimension of the mesh. Note that this is defined at compile time in the header libmesh_common.h.

Definition at line 154 of file mesh_base.h.

Referenced by MeshBase::get_info(), ExodusII_IO_Helper::initialize(), UNVIO::node_out(), LegacyXdrIO::read_mesh(), MeshTools::Modification::scale(), MeshTools::subdomain_bounding_box(), and LegacyXdrIO::write_mesh().

00155   { return static_cast<unsigned int>(LIBMESH_DIM); }

virtual const_element_iterator MeshBase::subactive_elements_begin (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::subactive_elements_begin (  )  [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

Referenced by Partitioner::set_node_processor_ids().

virtual const_element_iterator MeshBase::subactive_elements_end (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::subactive_elements_end (  )  [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

Referenced by Partitioner::set_node_processor_ids().

virtual const_element_iterator MeshBase::type_elements_begin ( const ElemType  type  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::type_elements_begin ( const ElemType  type  )  [pure virtual, inherited]

virtual const_element_iterator MeshBase::type_elements_end ( const ElemType  type  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual element_iterator MeshBase::type_elements_end ( const ElemType  type  )  [pure virtual, inherited]

virtual const_element_iterator MeshBase::unpartitioned_elements_begin (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual const_element_iterator MeshBase::unpartitioned_elements_end (  )  const [pure virtual, inherited]

Implemented in ParallelMesh, and SerialMesh.

virtual void MeshBase::update_parallel_id_counts (  )  [pure virtual, inherited]

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

Implemented in ParallelMesh, and SerialMesh.

Referenced by MeshRefinement::_coarsen_elements(), and MeshRefinement::_refine_elements().

void UnstructuredMesh::write ( const std::string &  name,
const std::vector< Number > &  values,
const std::vector< std::string > &  variable_names 
)

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

Definition at line 763 of file unstructured_mesh.C.

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

00766 {
00767   START_LOG("write()", "Mesh");
00768 
00769   // Write the file based on extension
00770   if (name.rfind(".dat") < name.size())
00771     TecplotIO(*this).write_nodal_data (name, v, vn);
00772   
00773   else if (name.rfind(".plt") < name.size())
00774     TecplotIO(*this,true).write_nodal_data (name, v, vn);
00775   
00776   else if (name.rfind(".gmv") < name.size())
00777     {
00778       if (n_subdomains() > 1)
00779         GMVIO(*this).write_nodal_data (name, v, vn);
00780       else
00781         {
00782           GMVIO io(*this);
00783           io.partitioning() = false;
00784           io.write_nodal_data (name, v, vn);
00785         }
00786     }    
00787   else if (name.rfind(".pvtu") < name.size())
00788     {
00789       VTKIO(*this).write_nodal_data (name, v, vn);
00790     }
00791   else
00792     {
00793       std::cerr << " ERROR: Unrecognized file extension: " << name
00794                 << "\n   I understand the following:\n\n"
00795                 << "     *.dat  -- Tecplot ASCII file\n"
00796                 << "     *.gmv  -- LANL's GMV (General Mesh Viewer) format\n"
00797                 << "     *.plt  -- Tecplot binary file\n"
00798                 << "     *.pvtu -- Paraview VTK file\n"
00799                 << "\n Exiting without writing output\n";
00800     }
00801 
00802   STOP_LOG("write()", "Mesh");
00803 }

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

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

Definition at line 636 of file unstructured_mesh.C.

References is_parallel_file_format(), MeshBase::n_partitions(), GMVIO::partitioning(), libMesh::processor_id(), and GMVIO::write().

00638 {
00639   // parallel formats are special -- they may choose to write
00640   // separate files, let's not try to handle the zipping here.
00641   if (is_parallel_file_format(name))
00642     {   
00643       // no need to handling bz2 files here -- the Xdr class does that.
00644       if (name.rfind(".xda") < name.size())
00645         XdrIO(*this).write(name);
00646         
00647       else if (name.rfind(".xdr") < name.size())
00648         XdrIO(*this,true).write(name);
00649     }
00650 
00651   // serial file formats
00652   else
00653     {
00654       START_LOG("write()", "Mesh");
00655 
00656       // Nasty hack for reading/writing zipped files
00657       std::string new_name = name;
00658       if (name.size() - name.rfind(".bz2") == 4)
00659         new_name.erase(new_name.end() - 4, new_name.end());
00660   
00661       // New scope so that io will close before we try to zip the file
00662       {
00663         // Write the file based on extension
00664         if (new_name.rfind(".dat") < new_name.size())
00665           TecplotIO(*this).write (new_name);
00666         
00667         else if (new_name.rfind(".plt") < new_name.size())
00668           TecplotIO(*this,true).write (new_name);
00669         
00670         else if (new_name.rfind(".ucd") < new_name.size())
00671           UCDIO (*this).write (new_name);
00672         
00673         else if (new_name.rfind(".gmv") < new_name.size())
00674           if (this->n_partitions() > 1)
00675             GMVIO(*this).write (new_name);
00676           else
00677             {
00678               GMVIO io(*this);
00679               io.partitioning() = false;
00680               io.write (new_name);
00681             }
00682         
00683         else if (new_name.rfind(".ugrid") < new_name.size())
00684           DivaIO(*this).write(new_name);
00685         else if (new_name.rfind(".exd") < new_name.size() ||
00686                  new_name.rfind(".e") < new_name.size())
00687           ExodusII_IO(*this).write(new_name);
00688         else if (new_name.rfind(".mgf")  < new_name.size())
00689           LegacyXdrIO(*this,true).write_mgf(new_name);
00690         
00691         else if (new_name.rfind(".unv") < new_name.size())
00692           {
00693             if (mesh_data == NULL)
00694               {
00695                 std::cerr << "Error! You must pass a "
00696                           << "valid MeshData pointer to "
00697                           << "write UNV files!" << std::endl;
00698                 libmesh_error();
00699               }
00700             UNVIO(*this, *mesh_data).write (new_name);
00701           }
00702         
00703         else if (new_name.rfind(".mesh") < new_name.size())
00704           MEDITIO(*this).write (new_name);
00705         
00706         else if (new_name.rfind(".poly") < new_name.size())
00707           TetGenIO(*this).write (new_name);
00708         
00709         else if (new_name.rfind(".msh") < new_name.size())
00710           GmshIO(*this).write (new_name);
00711         
00712         else if (new_name.rfind(".fro") < new_name.size())
00713           FroIO(*this).write (new_name);
00714         
00715         else if (new_name.rfind(".vtu") < new_name.size())
00716           VTKIO(*this).write (new_name);
00717         
00718         else
00719           {
00720             std::cerr << " ERROR: Unrecognized file extension: " << name
00721                       << "\n   I understand the following:\n\n"
00722                       << "     *.dat   -- Tecplot ASCII file\n"
00723                       << "     *.e     -- Sandia's ExodusII format\n"
00724                       << "     *.exd   -- Sandia's ExodusII format\n"
00725                       << "     *.fro   -- ACDL's surface triangulation file\n"
00726                       << "     *.gmv   -- LANL's GMV (General Mesh Viewer) format\n"
00727                       << "     *.mesh  -- MEdit mesh format\n"
00728                       << "     *.mgf   -- MGF binary mesh format\n"
00729                       << "     *.msh   -- GMSH ASCII file\n"
00730                       << "     *.plt   -- Tecplot binary file\n"
00731                       << "     *.poly  -- TetGen ASCII file\n"
00732                       << "     *.ucd   -- AVS's ASCII UCD format\n"
00733                       << "     *.ugrid -- Kelly's DIVA ASCII format\n"
00734                       << "     *.unv   -- I-deas Universal format\n"
00735                       << "     *.xda   -- libMesh ASCII format\n"
00736                       << "     *.xdr   -- libMesh binary format,\n"
00737                       << std::endl
00738                       << "\n Exiting without writing output\n";
00739           }    
00740       }
00741   
00742       // Nasty hack for reading/writing zipped files
00743       if (name.size() - name.rfind(".bz2") == 4)
00744         {
00745           START_LOG("system(bzip2)", "Mesh");
00746           if (libMesh::processor_id() == 0)
00747             {
00748               std::string system_string = "bzip2 -f ";
00749               system_string += new_name;
00750               if (std::system(system_string.c_str()))
00751                 libmesh_file_error(system_string);
00752             }
00753           Parallel::barrier();
00754           STOP_LOG("system(bzip2)", "Mesh");
00755         }
00756       
00757       STOP_LOG("write()", "Mesh");
00758     }  
00759 }


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 728 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; std::cout << mesh << std::endl;

Definition at line 250 of file mesh_base.C.

00251 {
00252   m.print_info(os);
00253   return os;
00254 }

friend class Partitioner [friend, inherited]

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

Definition at line 722 of file mesh_base.h.


Member Data Documentation

unsigned int MeshBase::_dim [protected, inherited]

The logical dimension of the mesh.

Definition at line 694 of file mesh_base.h.

Referenced by copy_nodes_and_elements(), find_neighbors(), MeshBase::mesh_dimension(), MeshBase::MeshBase(), and MeshBase::set_mesh_dimension().

bool MeshBase::_is_prepared [protected, inherited]

Flag indicating if the mesh has been prepared for use.

Definition at line 699 of file mesh_base.h.

Referenced by all_first_order(), all_second_order(), MeshBase::clear(), copy_nodes_and_elements(), MeshBase::is_prepared(), and MeshBase::prepare_for_use().

unsigned int 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 689 of file mesh_base.h.

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

AutoPtr<Partitioner> MeshBase::_partitioner [protected, inherited]

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

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

AutoPtr<PointLocatorBase> MeshBase::_point_locator [mutable, protected, inherited]

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

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


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

Site Created By: libMesh Developers
Last modified: November 25 2009 03:45:07.

Hosted By:
SourceForge.net Logo