#include <mesh.h>
Inherits ParallelMesh.
typedef Predicates::multi_predicate Predicate
Mesh (unsigned int d)
Mesh (const UnstructuredMesh &other_mesh)
~Mesh ()
virtual AutoPtr< MeshBase > clone () const
virtual void clear ()
virtual bool is_serial () const
template<typename T > void libmesh_assert_valid_parallel_object_ids (const mapvector< T * > &) const
void libmesh_assert_valid_parallel_ids () const
void libmesh_assert_valid_parallel_flags () const
template<typename T > unsigned int renumber_dof_objects (mapvector< T * > &)
virtual void renumber_nodes_and_elements ()
virtual void allgather ()
virtual void delete_remote_elements ()
virtual unsigned int n_nodes () const
virtual unsigned int max_node_id () const
virtual void reserve_nodes (const unsigned int)
virtual unsigned int n_elem () const
virtual unsigned int n_active_elem () const
virtual unsigned int max_elem_id () const
virtual void reserve_elem (const unsigned int)
virtual void update_parallel_id_counts ()
unsigned int parallel_n_nodes () const
unsigned int parallel_max_node_id () const
unsigned int parallel_n_elem () const
unsigned int parallel_max_elem_id () const
virtual const Point & point (const unsigned int i) const
virtual const Node & node (const unsigned int i) const
virtual Node & node (const unsigned int i)
virtual const Node * node_ptr (const unsigned int i) const
virtual Node *& node_ptr (const unsigned int i)
virtual Elem * elem (const unsigned int i) const
virtual Node * add_point (const Point &p, const unsigned int id=DofObject::invalid_id, const unsigned int proc_id=DofObject::invalid_processor_id)
virtual Node * add_node (Node *n)
virtual Node * insert_node (Node *n)
virtual void delete_node (Node *n)
virtual void renumber_node (unsigned int old_id, unsigned int new_id)
virtual Elem * add_elem (Elem *e)
virtual Elem * insert_elem (Elem *e)
virtual void delete_elem (Elem *e)
virtual void renumber_elem (unsigned int old_id, unsigned int new_id)
element_iterator elements_begin ()
const_element_iterator elements_begin () const
element_iterator elements_end ()
const_element_iterator elements_end () const
element_iterator active_elements_begin ()
const_element_iterator active_elements_begin () const
element_iterator active_elements_end ()
const_element_iterator active_elements_end () const
element_iterator ancestor_elements_begin ()
const_element_iterator ancestor_elements_begin () const
element_iterator ancestor_elements_end ()
const_element_iterator ancestor_elements_end () const
element_iterator subactive_elements_begin ()
const_element_iterator subactive_elements_begin () const
element_iterator subactive_elements_end ()
const_element_iterator subactive_elements_end () const
element_iterator not_active_elements_begin ()
const_element_iterator not_active_elements_begin () const
element_iterator not_active_elements_end ()
const_element_iterator not_active_elements_end () const
element_iterator not_ancestor_elements_begin ()
const_element_iterator not_ancestor_elements_begin () const
element_iterator not_ancestor_elements_end ()
const_element_iterator not_ancestor_elements_end () const
element_iterator not_subactive_elements_begin ()
const_element_iterator not_subactive_elements_begin () const
element_iterator not_subactive_elements_end ()
const_element_iterator not_subactive_elements_end () const
element_iterator local_elements_begin ()
const_element_iterator local_elements_begin () const
element_iterator local_elements_end ()
const_element_iterator local_elements_end () const
element_iterator not_local_elements_begin ()
const_element_iterator not_local_elements_begin () const
element_iterator not_local_elements_end ()
const_element_iterator not_local_elements_end () const
element_iterator active_local_elements_begin ()
const_element_iterator active_local_elements_begin () const
element_iterator active_local_elements_end ()
const_element_iterator active_local_elements_end () const
element_iterator active_not_local_elements_begin ()
const_element_iterator active_not_local_elements_begin () const
element_iterator active_not_local_elements_end ()
const_element_iterator active_not_local_elements_end () const
element_iterator level_elements_begin (const unsigned int level)
const_element_iterator level_elements_begin (const unsigned int level) const
element_iterator level_elements_end (const unsigned int level)
const_element_iterator level_elements_end (const unsigned int level) const
element_iterator not_level_elements_begin (const unsigned int level)
const_element_iterator not_level_elements_begin (const unsigned int level) const
element_iterator not_level_elements_end (const unsigned int level)
const_element_iterator not_level_elements_end (const unsigned int level) const
element_iterator local_level_elements_begin (const unsigned int level)
const_element_iterator local_level_elements_begin (const unsigned int level) const
element_iterator local_level_elements_end (const unsigned int level)
const_element_iterator local_level_elements_end (const unsigned int level) const
element_iterator local_not_level_elements_begin (const unsigned int level)
const_element_iterator local_not_level_elements_begin (const unsigned int level) const
element_iterator local_not_level_elements_end (const unsigned int level)
const_element_iterator local_not_level_elements_end (const unsigned int level) const
element_iterator pid_elements_begin (const unsigned int proc_id)
const_element_iterator pid_elements_begin (const unsigned int proc_id) const
element_iterator pid_elements_end (const unsigned int proc_id)
const_element_iterator pid_elements_end (const unsigned int proc_id) const
element_iterator type_elements_begin (const ElemType type)
const_element_iterator type_elements_begin (const ElemType type) const
element_iterator type_elements_end (const ElemType type)
const_element_iterator type_elements_end (const ElemType type) const
element_iterator active_type_elements_begin (const ElemType type)
const_element_iterator active_type_elements_begin (const ElemType type) const
element_iterator active_type_elements_end (const ElemType type)
const_element_iterator active_type_elements_end (const ElemType type) const
element_iterator active_pid_elements_begin (const unsigned int proc_id)
const_element_iterator active_pid_elements_begin (const unsigned int proc_id) const
element_iterator active_pid_elements_end (const unsigned int proc_id)
const_element_iterator active_pid_elements_end (const unsigned int proc_id) const
element_iterator unpartitioned_elements_begin ()
const_element_iterator unpartitioned_elements_begin () const
element_iterator unpartitioned_elements_end ()
const_element_iterator unpartitioned_elements_end () const
element_iterator active_local_subdomain_elements_begin (const unsigned int subdomain_id)
const_element_iterator active_local_subdomain_elements_begin (const unsigned int subdomain_id) const
element_iterator active_local_subdomain_elements_end (const unsigned int subdomain_id)
const_element_iterator active_local_subdomain_elements_end (const unsigned int subdomain_id) const
node_iterator nodes_begin ()
const_node_iterator nodes_begin () const
node_iterator nodes_end ()
const_node_iterator nodes_end () const
node_iterator active_nodes_begin ()
const_node_iterator active_nodes_begin () const
node_iterator active_nodes_end ()
const_node_iterator active_nodes_end () const
node_iterator local_nodes_begin ()
const_node_iterator local_nodes_begin () const
node_iterator local_nodes_end ()
const_node_iterator local_nodes_end () const
node_iterator pid_nodes_begin (const unsigned int proc_id)
const_node_iterator pid_nodes_begin (const unsigned int proc_id) const
node_iterator pid_nodes_end (const unsigned int proc_id)
const_node_iterator pid_nodes_end (const unsigned int proc_id) const
void read (const std::string &name, MeshData *mesh_data=NULL, bool skip_renumber_nodes_and_elements=false)
void write (const std::string &name, MeshData *mesh_data=NULL)
void write (const std::string &name, const std::vector< Number > &values, const std::vector< std::string > &variable_names)
virtual void all_first_order ()
virtual void all_second_order (const bool full_ordered=true)
void create_pid_mesh (UnstructuredMesh &pid_mesh, const 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< Partitioner > & partitioner ()
bool is_prepared () const
unsigned int mesh_dimension () const
void set_mesh_dimension (unsigned int d)
unsigned int spatial_dimension () const
unsigned int n_nodes_on_proc (const unsigned int proc) const
unsigned int n_local_nodes () const
unsigned int n_unpartitioned_nodes () const
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
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 PointLocatorBase & point_locator () const
void clear_point_locator ()
unsigned int & set_n_subdomains ()
AutoPtr< BoundaryInfo > boundary_info
unsigned int & set_n_partitions ()
mapvector< Node * > _nodes
mapvector< Elem * > _elements
bool _is_serial
unsigned int _n_nodes
unsigned int _n_elem
unsigned int _max_node_id
unsigned int _max_elem_id
unsigned int _next_free_local_node_id
unsigned int _next_free_local_elem_id
unsigned int _next_free_unpartitioned_node_id
unsigned int _next_free_unpartitioned_elem_id
unsigned int _n_sbd
unsigned int _n_parts
unsigned int _dim
bool _is_prepared
AutoPtr< PointLocatorBase > _point_locator
AutoPtr< Partitioner > _partitioner
void MeshTools::Private::fix_broken_node_and_element_numbering (ParallelMesh &)
class Partitioner
class BoundaryInfo
std::ostream & operator<< (std::ostream &os, const MeshBase &m)
The Mesh class is a thin wrapper, around the SerialMesh class by default.
Definition at line 45 of file mesh.h.
Definition at line 496 of file mesh_base.h.
Definition at line 54 of file mesh.h.
: DefaultMesh(d) {}
Definition at line 60 of file mesh.h.
: DefaultMesh(other_mesh) {}
Definition at line 65 of file mesh.h.
{}
Implements MeshBase.
Definition at line 46 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::Active<elem_iterator_imp> p;
return element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 261 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::Active<const_elem_iterator_imp> p;
return const_element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 473 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::Active<elem_iterator_imp> p;
return element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 688 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::Active<const_elem_iterator_imp> p;
return const_element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 126 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
Referenced by ParallelMesh::n_active_elem().
{
Predicates::ActiveLocal<elem_iterator_imp> p;
return element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 340 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::ActiveLocal<const_elem_iterator_imp> p;
return const_element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 553 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
Referenced by ParallelMesh::n_active_elem().
{
Predicates::ActiveLocal<elem_iterator_imp> p;
return element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 768 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::ActiveLocal<const_elem_iterator_imp> p;
return const_element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 235 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::ActiveLocalSubdomain<elem_iterator_imp> p(subdomain_id);
return element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 449 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::ActiveLocalSubdomain<const_elem_iterator_imp> p(subdomain_id);
return const_element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 662 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::ActiveLocalSubdomain<elem_iterator_imp> p(subdomain_id);
return element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 876 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::ActiveLocalSubdomain<const_elem_iterator_imp> p(subdomain_id);
return const_element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 900 of file parallel_mesh_iterators.C.
References ParallelMesh::_nodes, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::Active<node_iterator_imp> p;
return node_iterator(_nodes.begin(), _nodes.end(), p);
}
Implements MeshBase.
Definition at line 940 of file parallel_mesh_iterators.C.
References ParallelMesh::_nodes, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::Active<const_node_iterator_imp> p;
return const_node_iterator(_nodes.begin(), _nodes.end(), p);
}
Implements MeshBase.
Definition at line 980 of file parallel_mesh_iterators.C.
References ParallelMesh::_nodes, and mapvector< Val >::end().
{
Predicates::Active<node_iterator_imp> p;
return node_iterator(_nodes.end(), _nodes.end(), p);
}
Implements MeshBase.
Definition at line 1020 of file parallel_mesh_iterators.C.
References ParallelMesh::_nodes, and mapvector< Val >::end().
{
Predicates::Active<const_node_iterator_imp> p;
return const_node_iterator(_nodes.end(), _nodes.end(), p);
}
Implements MeshBase.
Definition at line 136 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::ActiveNotLocal<elem_iterator_imp> p;
return element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 350 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::ActiveNotLocal<const_elem_iterator_imp> p;
return const_element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 563 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::ActiveNotLocal<elem_iterator_imp> p;
return element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 778 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::ActiveNotLocal<const_elem_iterator_imp> p;
return const_element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 430 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::ActivePID<const_elem_iterator_imp> p(proc_id);
return const_element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 216 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
Referenced by ParallelMesh::n_active_elem().
{
Predicates::ActivePID<elem_iterator_imp> p(proc_id);
return element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 643 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
Referenced by ParallelMesh::n_active_elem().
{
Predicates::ActivePID<elem_iterator_imp> p(proc_id);
return element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 857 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::ActivePID<const_elem_iterator_imp> p(proc_id);
return const_element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 206 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::ActiveType<elem_iterator_imp> p(type);
return element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 420 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::ActiveType<const_elem_iterator_imp> p(type);
return const_element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 633 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::ActiveType<elem_iterator_imp> p(type);
return element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 847 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::ActiveType<const_elem_iterator_imp> p(type);
return const_element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 225 of file parallel_mesh.C.
References ParallelMesh::_elements, ParallelMesh::_max_elem_id, ParallelMesh::_n_elem, ParallelMesh::_next_free_local_elem_id, ParallelMesh::_next_free_unpartitioned_elem_id, DofObject::id(), DofObject::invalid_processor_id, ParallelMesh::is_serial(), std::max(), MeshBase::n_processors(), libMesh::processor_id(), DofObject::processor_id(), DofObject::set_id(), and DofObject::valid_id().
Referenced by Nemesis_IO::read(), and BoundaryInfo::sync().
{
// Don't try to add NULLs!
libmesh_assert(e);
const unsigned int elem_procid = e->processor_id();
if (!e->valid_id())
{
// Use the unpartitioned ids for unpartitioned elems,
// in serial, and temporarily for ghost elems
unsigned int *next_id = &_next_free_unpartitioned_elem_id;
if (elem_procid == libMesh::processor_id() &&
!this->is_serial())
next_id = &_next_free_local_elem_id;
e->set_id (*next_id);
*next_id += libMesh::n_processors() + 1;
}
else
{
if (_next_free_unpartitioned_elem_id <= e->id())
_next_free_unpartitioned_elem_id += libMesh::n_processors() + 1;
if (_next_free_local_elem_id <= e->id())
_next_free_local_elem_id += libMesh::n_processors() + 1;
}
// Don't try to overwrite existing elems
libmesh_assert (!_elements[e->id()]);
_elements[e->id()] = e;
// Make the cached elem data more accurate
_n_elem++;
_max_elem_id = std::max(_max_elem_id, e->id()+1);
// Unpartitioned elems should be added on every processor
// And shouldn't be added in the same batch as ghost elems
// But we might be just adding on processor 0 to
// broadcast later
#if 0
#ifdef DEBUG
if (elem_procid == DofObject::invalid_processor_id)
{
unsigned int elem_id = e->id();
Parallel::max(elem_id);
libmesh_assert(elem_id == e->id());
}
#endif
#endif
return e;
}
Implements MeshBase.
Definition at line 353 of file parallel_mesh.C.
References ParallelMesh::_max_node_id, ParallelMesh::_n_nodes, ParallelMesh::_next_free_local_node_id, ParallelMesh::_next_free_unpartitioned_node_id, ParallelMesh::_nodes, DofObject::id(), DofObject::invalid_processor_id, ParallelMesh::is_serial(), std::max(), MeshBase::n_processors(), libMesh::processor_id(), DofObject::processor_id(), DofObject::set_id(), and DofObject::valid_id().
Referenced by ParallelMesh::add_point().
{
// Don't try to add NULLs!
libmesh_assert(n);
const unsigned int node_procid = n->processor_id();
if (!n->valid_id())
{
// Use the unpartitioned ids for unpartitioned nodes,
// in serial, and temporarily for ghost nodes
unsigned int *next_id = &_next_free_unpartitioned_node_id;
if (node_procid == libMesh::processor_id() &&
!this->is_serial())
next_id = &_next_free_local_node_id;
n->set_id (*next_id);
*next_id += libMesh::n_processors() + 1;
}
else
{
if (_next_free_unpartitioned_node_id <= n->id())
_next_free_unpartitioned_node_id += libMesh::n_processors() + 1;
if (_next_free_local_node_id <= n->id())
_next_free_local_node_id += libMesh::n_processors() + 1;
}
// Don't try to overwrite existing nodes
libmesh_assert (!_nodes[n->id()]);
_nodes[n->id()] = n;
// Make the cached elem data more accurate
_n_nodes++;
_max_node_id = std::max(_max_node_id, n->id()+1);
// Unpartitioned nodes should be added on every processor
// And shouldn't be added in the same batch as ghost nodes
// But we might be just adding on processor 0 to
// broadcast later
#if 0
#ifdef DEBUG
if (node_procid == DofObject::invalid_processor_id)
{
unsigned int node_id = n->id();
Parallel::max(node_id);
libmesh_assert(node_id == n->id());
}
#endif
#endif
return n;
}
Implements MeshBase.
Definition at line 329 of file parallel_mesh.C.
References ParallelMesh::_nodes, ParallelMesh::add_node(), Node::build(), DofObject::id(), and DofObject::processor_id().
Referenced by Nemesis_IO::read(), and BoundaryInfo::sync().
{
if (_nodes.count(id))
{
Node *n = _nodes[id];
libmesh_assert (n);
libmesh_assert (n->id() == id);
*n = p;
n->processor_id() = proc_id;
return n;
}
Node* n = Node::build(p, id).release();
n->processor_id() = proc_id;
return ParallelMesh::add_node(n);
}
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().
{
/*
* when the mesh is not prepared,
* at least renumber the nodes and
* elements, so that the node ids
* are correct
*/
if (!this->_is_prepared)
this->renumber_nodes_and_elements ();
START_LOG('all_first_order()', 'Mesh');
const_element_iterator endit = elements_end();
for (const_element_iterator it = elements_begin();
it != endit; ++it)
{
Elem* so_elem = *it;
libmesh_assert (so_elem != NULL);
/*
* build the first-order equivalent, add to
* the new_elements list.
*/
Elem *newparent = so_elem->parent();
Elem* lo_elem = Elem::build
(Elem::first_order_equivalent_type
(so_elem->type()), newparent).release();
#ifdef LIBMESH_ENABLE_AMR
/*
* Add this element to it's parent if it has one
*/
if (newparent)
newparent->add_child(lo_elem);
/*
* Reset the parent links of any child elements
*/
if (so_elem->has_children())
{
for (unsigned int c=0; c != so_elem->n_children(); ++c)
so_elem->child(c)->set_parent(lo_elem);
}
/*
* Copy as much data to the new element as makes sense
*/
lo_elem->set_p_level(so_elem->p_level());
lo_elem->set_refinement_flag(so_elem->refinement_flag());
lo_elem->set_p_refinement_flag(so_elem->p_refinement_flag());
#endif
libmesh_assert (lo_elem->n_vertices() == so_elem->n_vertices());
/*
* By definition the vertices of the linear and
* second order element are identically numbered.
* transfer these.
*/
for (unsigned int v=0; v < so_elem->n_vertices(); v++)
lo_elem->set_node(v) = so_elem->get_node(v);
libmesh_assert (lo_elem->n_sides() == so_elem->n_sides());
for (unsigned int s=0; s<so_elem->n_sides(); s++)
{
const short int boundary_id =
this->boundary_info->boundary_id (so_elem, s);
if (boundary_id != this->boundary_info->invalid_id)
this->boundary_info->add_side (lo_elem, s, boundary_id);
}
/*
* The new first-order element is ready.
* Inserting it into the mesh will replace and delete
* the second-order element.
*/
lo_elem->set_id(so_elem->id());
lo_elem->processor_id() = so_elem->processor_id();
lo_elem->subdomain_id() = so_elem->subdomain_id();
this->insert_elem(lo_elem);
}
STOP_LOG('all_first_order()', 'Mesh');
// delete or renumber nodes, etc
this->prepare_for_use();
}
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(), MeshCommunication::make_nodes_parallel_consistent(), 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().
{
// This function must be run on all processors at once
parallel_only();
/*
* when the mesh is not prepared,
* at least renumber the nodes and
* elements, so that the node ids
* are correct
*/
if (!this->_is_prepared)
this->renumber_nodes_and_elements ();
/*
* If the mesh is empty
* then we have nothing to do
*/
if (!this->n_elem())
return;
/*
* If the mesh is already second order
* then we have nothing to do.
* We have to test for this in a round-about way to avoid
* a bug on distributed parallel meshes with more processors
* than elements.
*/
bool already_second_order = false;
if (this->elements_begin() != this->elements_end() &&
(*(this->elements_begin()))->default_order() != FIRST)
already_second_order = true;
Parallel::max(already_second_order);
if (already_second_order)
return;
START_LOG('all_second_order()', 'Mesh');
/*
* this map helps in identifying second order
* nodes. Namely, a second-order node:
* - edge node
* - face node
* - bubble node
* is uniquely defined through a set of adjacent
* vertices. This set of adjacent vertices is
* used to identify already added higher-order
* nodes. We are safe to use node id's since we
* make sure that these are correctly numbered.
*/
std::map<std::vector<unsigned int>, Node*> adj_vertices_to_so_nodes;
/*
* for speed-up of the
add_point() method, we
* can reserve memory. Guess the number of additional
* nodes for different dimensions
*/
switch (this->mesh_dimension())
{
case 1:
/*
* in 1D, there can only be order-increase from Edge2
* to Edge3. Something like 1/2 of n_nodes() have
* to be added
*/
this->reserve_nodes(static_cast<unsigned int>(1.5*this->n_nodes()));
break;
case 2:
/*
* in 2D, either refine from Tri3 to Tri6 (double the nodes)
* or from Quad4 to Quad8 (again, double) or Quad9 (2.25 that much)
*/
this->reserve_nodes(static_cast<unsigned int>(2*this->n_nodes()));
break;
case 3:
/*
* in 3D, either refine from Tet4 to Tet10 (factor = 2.5) up to
* Hex8 to Hex27 (something > 3). Since in 3D there _are_ already
* quite some nodes, and since we do not want to overburden the memory by
* a too conservative guess, use the lower bound
*/
this->reserve_nodes(static_cast<unsigned int>(2.5*this->n_nodes()));
break;
default:
// Hm?
libmesh_error();
}
/*
* form a vector that will hold the node id's of
* the vertices that are adjacent to the son-th
* second-order node. Pull this outside of the
* loop so that silly compilers don't repeatedly
* create and destroy the vector.
*/
std::vector<unsigned int> adjacent_vertices_ids;
const_element_iterator endit = elements_end();
for (const_element_iterator it = elements_begin();
it != endit; ++it)
{
// the linear-order element
Elem* lo_elem = *it;
libmesh_assert (lo_elem != NULL);
// make sure it is linear order
if (lo_elem->default_order() != FIRST)
{
std::cerr << 'ERROR: This is not a linear element: type='
<< lo_elem->type() << std::endl;
libmesh_error();
}
// this does _not_ work for refined elements
libmesh_assert (lo_elem->level () == 0);
/*
* build the second-order equivalent, add to
* the new_elements list. Note that this here
* is the only point where
full_ordered
* is necessary. The remaining code works well
* for either type of seconrd-order equivalent, e.g.
* Hex20 or Hex27, as equivalents for Hex8
*/
Elem* so_elem =
Elem::build (Elem::second_order_equivalent_type(lo_elem->type(),
full_ordered) ).release();
libmesh_assert (lo_elem->n_vertices() == so_elem->n_vertices());
/*
* By definition the vertices of the linear and
* second order element are identically numbered.
* transfer these.
*/
for (unsigned int v=0; v < lo_elem->n_vertices(); v++)
so_elem->set_node(v) = lo_elem->get_node(v);
/*
* Now handle the additional mid-side nodes. This
* is simply handled through a map that remembers
* the already-added nodes. This map maps the global
* ids of the vertices (that uniquely define this
* higher-order node) to the new node.
* Notation: son = second-order node
*/
const unsigned int son_begin = so_elem->n_vertices();
const unsigned int son_end = so_elem->n_nodes();
for (unsigned int son=son_begin; son<son_end; son++)
{
const unsigned int n_adjacent_vertices =
so_elem->n_second_order_adjacent_vertices(son);
adjacent_vertices_ids.resize(n_adjacent_vertices);
for (unsigned int v=0; v<n_adjacent_vertices; v++)
adjacent_vertices_ids[v] =
so_elem->node( so_elem->second_order_adjacent_vertex(son,v) );
/*
*
adjacent_vertices_ids is now in order of the current
* side. sort it, so that comparisons with the
*
adjacent_vertices_ids created through other elements'
* sides can match
*/
std::sort(adjacent_vertices_ids.begin(),
adjacent_vertices_ids.end());
// does this set of vertices already has a mid-node added?
std::pair<std::map<std::vector<unsigned int>, Node*>::iterator,
std::map<std::vector<unsigned int>, Node*>::iterator>
pos = adj_vertices_to_so_nodes.equal_range (adjacent_vertices_ids);
// no, not added yet
if (pos.first == pos.second)
{
/*
* for this set of vertices, there is no
* second_order node yet. Add it.
*
* compute the location of the new node as
* the average over the adjacent vertices.
*/
Point new_location = this->point(adjacent_vertices_ids[0]);
for (unsigned int v=1; v<n_adjacent_vertices; v++)
new_location += this->point(adjacent_vertices_ids[v]);
new_location /= static_cast<Real>(n_adjacent_vertices);
/* Add the new point to the mesh, giving it a globally
* well-defined processor id.
*/
Node* so_node = this->add_point
(new_location, DofObject::invalid_id,
this->node(adjacent_vertices_ids[0]).processor_id());
/*
* insert the new node with its defining vertex
* set into the map, and relocate pos to this
* new entry, so that the so_elem can use
*
pos for inserting the node
*/
adj_vertices_to_so_nodes.insert(pos.first,
std::make_pair(adjacent_vertices_ids,
so_node));
so_elem->set_node(son) = so_node;
}
// yes, already added.
else
{
libmesh_assert (pos.first->second != NULL);
so_elem->set_node(son) = pos.first->second;
}
}
libmesh_assert (lo_elem->n_sides() == so_elem->n_sides());
for (unsigned int s=0; s<lo_elem->n_sides(); s++)
{
const short int boundary_id =
this->boundary_info->boundary_id (lo_elem, s);
if (boundary_id != this->boundary_info->invalid_id)
this->boundary_info->add_side (so_elem, s, boundary_id);
}
/*
* The new second-order element is ready.
* Inserting it into the mesh will replace and delete
* the first-order element.
*/
so_elem->set_id(lo_elem->id());
so_elem->processor_id() = lo_elem->processor_id();
so_elem->subdomain_id() = lo_elem->subdomain_id();
this->insert_elem(so_elem);
}
// we can clear the map
adj_vertices_to_so_nodes.clear();
STOP_LOG('all_second_order()', 'Mesh');
// In a ParallelMesh our ghost node processor ids may be bad and
// the ids of nodes touching remote elements may be inconsistent.
// Fix them.
if (!this->is_serial())
{
LocationMap<Node> loc_map;
MeshCommunication().make_nodes_parallel_consistent
(*this, loc_map);
}
// renumber nodes, elements etc
this->prepare_for_use();
}
Reimplemented from MeshBase.
Definition at line 936 of file parallel_mesh.C.
References ParallelMesh::_is_serial, MeshCommunication::allgather(), MeshTools::libmesh_assert_valid_neighbors(), ParallelMesh::libmesh_assert_valid_parallel_flags(), ParallelMesh::libmesh_assert_valid_parallel_ids(), ParallelMesh::max_elem_id(), ParallelMesh::max_node_id(), ParallelMesh::n_elem(), ParallelMesh::n_nodes(), ParallelMesh::parallel_max_elem_id(), ParallelMesh::parallel_max_node_id(), ParallelMesh::parallel_n_elem(), and ParallelMesh::parallel_n_nodes().
Referenced by ParallelMesh::renumber_dof_objects().
{
if (_is_serial)
return;
_is_serial = true;
MeshCommunication().allgather(*this);
// Make sure our caches are up to date and our
// DofObjects are well packed
#ifdef DEBUG
libmesh_assert(this->n_nodes() == this->parallel_n_nodes());
libmesh_assert(this->n_elem() == this->parallel_n_elem());
libmesh_assert(this->max_node_id() == this->parallel_max_node_id());
libmesh_assert(this->max_elem_id() == this->parallel_max_elem_id());
libmesh_assert(this->n_nodes() == this->max_node_id());
libmesh_assert(this->n_elem() == this->max_elem_id());
// Make sure our neighbor links are all fine
MeshTools::libmesh_assert_valid_neighbors(*this);
// Make sure our ids and flags are consistent
this->libmesh_assert_valid_parallel_ids();
this->libmesh_assert_valid_parallel_flags();
#endif
}
Implements MeshBase.
Definition at line 66 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::Ancestor<elem_iterator_imp> p;
return element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 280 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::Ancestor<const_elem_iterator_imp> p;
return const_element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 708 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::Ancestor<const_elem_iterator_imp> p;
return const_element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 493 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::Ancestor<elem_iterator_imp> p;
return element_iterator(_elements.end(), _elements.end(), p);
}
Reimplemented from MeshBase.
Definition at line 466 of file parallel_mesh.C.
References ParallelMesh::_elements, ParallelMesh::_is_serial, ParallelMesh::_max_elem_id, ParallelMesh::_max_node_id, ParallelMesh::_n_elem, ParallelMesh::_n_nodes, ParallelMesh::_next_free_local_elem_id, ParallelMesh::_next_free_local_node_id, ParallelMesh::_next_free_unpartitioned_elem_id, ParallelMesh::_next_free_unpartitioned_node_id, ParallelMesh::_nodes, mapvector< Val >::begin(), mapvector< Val >::end(), MeshBase::n_processors(), and MeshBase::processor_id().
Referenced by BoundaryInfo::sync(), BoundaryMesh::~BoundaryMesh(), and ParallelMesh::~ParallelMesh().
{
// Call parent clear function
MeshBase::clear();
// Clear our elements and nodes
{
elem_iterator_imp it = _elements.begin();
const elem_iterator_imp end = _elements.end();
// There is no need to remove the elements from
// the BoundaryInfo data structure since we
// already cleared it.
for (; it != end; ++it)
delete *it;
_elements.clear();
}
// clear the nodes data structure
{
node_iterator_imp it = _nodes.begin();
node_iterator_imp end = _nodes.end();
// There is no need to remove the nodes from
// the BoundaryInfo data structure since we
// already cleared it.
for (; it != end; ++it)
delete *it;
_nodes.clear();
}
// We're no longer distributed if we were before
_is_serial = true;
// Correct our caches
_n_nodes = 0;
_n_elem = 0;
_max_node_id = 0;
_max_elem_id = 0;
_next_free_local_node_id = libMesh::processor_id();
_next_free_local_elem_id = libMesh::processor_id();
_next_free_unpartitioned_node_id = libMesh::n_processors();
_next_free_unpartitioned_elem_id = libMesh::n_processors();
}
Definition at line 277 of file mesh_base.C.
References MeshBase::_point_locator, and AutoPtr< Tp >::reset().
Referenced by MeshBase::clear(), and MeshBase::prepare_for_use().
{
_point_locator.reset(NULL);
}
Implements MeshBase.
Definition at line 80 of file parallel_mesh.h.
References ParallelMesh::ParallelMesh().
{ return AutoPtr<MeshBase>(new ParallelMesh(*this)); }
Implements MeshBase.
Definition at line 937 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().
{
START_LOG ('contract()', 'Mesh');
// Flag indicating if this call actually changes the mesh
bool mesh_changed = false;
element_iterator in = elements_begin();
element_iterator out = elements_begin();
const element_iterator end = elements_end();
#ifdef DEBUG
for ( ; in != end; ++in)
if (*in != NULL)
{
Elem* elem = *in;
libmesh_assert(elem->active() || elem->subactive() || elem->ancestor());
}
in = elements_begin();
#endif
// Loop over the elements.
for ( ; in != end; ++in)
if (*in != NULL)
{
Elem* elem = *in;
// Delete all the subactive ones
if (elem->subactive())
{
// No level-0 element should be subactive.
// Note that we CAN'T test elem->level(), as that
// touches elem->parent()->dim(), and elem->parent()
// might have already been deleted!
libmesh_assert (elem->parent() != NULL);
// Delete the element
// This just sets a pointer to NULL, and doesn't
// invalidate any iterators
this->delete_elem(elem);
// the mesh has certainly changed
mesh_changed = true;
}
else
{
// Compress all the active ones
if (elem->active())
elem->contract();
else
libmesh_assert (elem->ancestor());
}
}
// Strip any newly-created NULL voids out of the element array
this->renumber_nodes_and_elements();
STOP_LOG ('contract()', 'Mesh');
return mesh_changed;
}
Definition at line 94 of file unstructured_mesh.C.
References MeshBase::_dim, MeshBase::_is_prepared, MeshBase::_n_parts, MeshBase::_n_sbd, 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().
{
// We're assuming our subclass data needs no copy
libmesh_assert(_n_sbd == other_mesh._n_sbd);
libmesh_assert(_n_parts == other_mesh._n_parts);
libmesh_assert(_dim == other_mesh._dim);
libmesh_assert(_is_prepared == other_mesh._is_prepared);
//Copy in Nodes
{
//Preallocate Memory if necessary
this->reserve_nodes(other_mesh.n_nodes());
const_node_iterator it = other_mesh.nodes_begin();
const_node_iterator end = other_mesh.nodes_end();
for (; it != end; ++it)
{
Node *oldn = *it;
// Add new nodes in old node Point locations
Node *newn = this->add_point(*oldn);
// And start them off in the same subdomain
newn->processor_id() = oldn->processor_id();
}
}
//Copy in Elements
{
//Preallocate Memory if necessary
this->reserve_elem(other_mesh.n_elem());
// Loop over the elements
MeshBase::const_element_iterator it = other_mesh.elements_begin();
const MeshBase::const_element_iterator end = other_mesh.elements_end();
// FIXME: Where do we set element IDs??
for (; it != end; ++it)
{
//Look at the old element
Elem *old = *it;
//Build a new element
Elem *newparent = old->parent() ?
this->elem(old->parent()->id()) : NULL;
AutoPtr<Elem> ap = Elem::build(old->type(), newparent);
Elem * elem = ap.release();
#ifdef LIBMESH_ENABLE_AMR
//Create the parent's child pointers if necessary
if (newparent)
{
// Make sure we have space for those child pointers
newparent->add_child(elem);
// We'd better be adding these in the correct order
libmesh_assert (newparent->which_child_am_i(elem) ==
old->parent()->which_child_am_i(old));
}
// Copy the refinement flags
elem->set_refinement_flag(old->refinement_flag());
elem->set_p_refinement_flag(old->p_refinement_flag());
#endif // #ifdef LIBMESH_ENABLE_AMR
//Assign all the nodes
for(unsigned int i=0;i<elem->n_nodes();i++)
elem->set_node(i) = &this->node(old->node(i));
//Hold onto it
this->add_elem(elem);
// And start it off in the same subdomain
elem->processor_id() = old->processor_id();
}
}
//Finally prepare the Mesh for use
this->prepare_for_use();
}
Definition at line 810 of file unstructured_mesh.C.
References MeshBase::active_pid_elements_begin(), MeshBase::active_pid_elements_end(), UnstructuredMesh::create_submesh(), and MeshBase::n_processors().
{
// Issue a warning if the number the number of processors
// currently available is less that that requested for
// partitioning. This is not necessarily an error since
// you may run on one processor and still partition the
// mesh into several partitions.
#ifdef DEBUG
if (this->n_processors() < pid)
{
std::cout << 'WARNING: You are creating a '
<< 'mesh for a processor id (='
<< pid
<< ') greater than '
<< 'the number of processors available for '
<< 'the calculation. (='
<< libMesh::n_processors()
<< ').'
<< std::endl;
}
#endif
// Create iterators to loop over the list of elements
// const_active_pid_elem_iterator it(this->elements_begin(), pid);
// const const_active_pid_elem_iterator it_end(this->elements_end(), pid);
const_element_iterator it = this->active_pid_elements_begin(pid);
const const_element_iterator it_end = this->active_pid_elements_end(pid);
this->create_submesh (pid_mesh, it, it_end);
}
Definition at line 850 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 UnstructuredMesh::create_pid_mesh().
{
// Just in case the subdomain_mesh already has some information
// in it, get rid of it.
new_mesh.clear();
// Fail if (*this == new_mesh), we cannot create a submesh inside ourself!
// This may happen if the user accidently passes the original mesh into
// this function! We will check this by making sure we did not just
// clear ourself.
libmesh_assert (this->n_nodes() != 0);
libmesh_assert (this->n_elem() != 0);
// How the nodes on this mesh will be renumbered to nodes
// on the new_mesh.
std::vector<unsigned int> new_node_numbers (this->n_nodes());
std::fill (new_node_numbers.begin(),
new_node_numbers.end(),
libMesh::invalid_uint);
// the number of nodes on the new mesh, will be incremented
unsigned int n_new_nodes = 0;
unsigned int n_new_elem = 0;
for (; it != it_end; ++it)
{
// increment the new element counter
n_new_elem++;
const Elem* old_elem = *it;
// Add an equivalent element type to the new_mesh
Elem* new_elem =
new_mesh.add_elem (Elem::build(old_elem->type()).release());
libmesh_assert (new_elem != NULL);
// Loop over the nodes on this element.
for (unsigned int n=0; n<old_elem->n_nodes(); n++)
{
libmesh_assert (old_elem->node(n) < new_node_numbers.size());
if (new_node_numbers[old_elem->node(n)] == libMesh::invalid_uint)
{
new_node_numbers[old_elem->node(n)] = n_new_nodes;
// Add this node to the new mesh
new_mesh.add_point (old_elem->point(n));
// Increment the new node counter
n_new_nodes++;
}
// Define this element's connectivity on the new mesh
libmesh_assert (new_node_numbers[old_elem->node(n)] < new_mesh.n_nodes());
new_elem->set_node(n) = new_mesh.node_ptr (new_node_numbers[old_elem->node(n)]);
}
// Copy ids for this element
new_elem->subdomain_id() = old_elem->subdomain_id();
new_elem->processor_id() = old_elem->processor_id();
// Maybe add boundary conditions for this element
for (unsigned int s=0; s<old_elem->n_sides(); s++)
if (old_elem->neighbor(s) == NULL)
if (this->boundary_info->boundary_id (old_elem, s) !=
this->boundary_info->invalid_id)
new_mesh.boundary_info->add_side (new_elem,
s,
this->boundary_info->boundary_id (old_elem, s));
} // end loop over elements
// Prepare the new_mesh for use
new_mesh.prepare_for_use();
}
Implements MeshBase.
Definition at line 292 of file parallel_mesh.C.
References ParallelMesh::_elements, MeshBase::boundary_info, and DofObject::id().
Referenced by MeshCommunication::delete_remote_elements(), and ParallelMesh::insert_elem().
{
libmesh_assert (e);
// Delete the element from the BoundaryInfo object
this->boundary_info->remove(e);
// But not yet from the container; we might invalidate
// an iterator that way!
//_elements.erase(e->id());
// Instead, we set it to NULL for now
_elements[e->id()] = NULL;
// delete the element
delete e;
}
Implements MeshBase.
Definition at line 434 of file parallel_mesh.C.
References ParallelMesh::_nodes, MeshBase::boundary_info, mapvector< Val >::erase(), and DofObject::id().
{
libmesh_assert (n != NULL);
libmesh_assert (_nodes[n->id()] != NULL);
// Delete the node from the BoundaryInfo object
this->boundary_info->remove(n);
// And from the container
_nodes.erase(n->id());
// delete the node
delete n;
}
Reimplemented from MeshBase.
Definition at line 902 of file parallel_mesh.C.
References ParallelMesh::_is_serial, MeshCommunication::delete_remote_elements(), MeshTools::libmesh_assert_valid_elem_ids(), MeshTools::libmesh_assert_valid_neighbors(), ParallelMesh::libmesh_assert_valid_parallel_flags(), ParallelMesh::libmesh_assert_valid_parallel_ids(), ParallelMesh::max_elem_id(), ParallelMesh::max_node_id(), ParallelMesh::n_elem(), ParallelMesh::n_nodes(), ParallelMesh::parallel_max_elem_id(), ParallelMesh::parallel_max_node_id(), ParallelMesh::parallel_n_elem(), and ParallelMesh::parallel_n_nodes().
Referenced by Nemesis_IO::read().
{
#ifdef DEBUG
// Make sure our neighbor links are all fine
MeshTools::libmesh_assert_valid_neighbors(*this);
#endif
_is_serial = false;
MeshCommunication().delete_remote_elements(*this);
#ifdef DEBUG
// Make sure our caches are up to date and our
// DofObjects are well packed
libmesh_assert(this->n_nodes() == this->parallel_n_nodes());
libmesh_assert(this->n_elem() == this->parallel_n_elem());
libmesh_assert(this->max_node_id() == this->parallel_max_node_id());
libmesh_assert(this->max_elem_id() == this->parallel_max_elem_id());
libmesh_assert(this->n_nodes() == this->max_node_id());
libmesh_assert(this->n_elem() == this->max_elem_id());
// Make sure our neighbor links are all fine
MeshTools::libmesh_assert_valid_neighbors(*this);
// Make sure our ids and flags are consistent
this->libmesh_assert_valid_parallel_ids();
this->libmesh_assert_valid_parallel_flags();
// And make sure our numbering is still monotonic
MeshTools::libmesh_assert_valid_elem_ids(*this);
#endif
}
Implements MeshBase.
Definition at line 214 of file parallel_mesh.C.
References ParallelMesh::_elements.
Referenced by ParallelMesh::libmesh_assert_valid_parallel_flags(), ParallelMesh::renumber_elem(), and ParallelMesh::renumber_nodes_and_elements().
{
// libmesh_assert (_elements[i] != NULL);
libmesh_assert (_elements[i] == NULL || _elements[i]->id() == i);
return _elements[i];
}
Implements MeshBase.
Definition at line 36 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
Referenced by ParallelMesh::renumber_nodes_and_elements().
{
Predicates::NotNull<elem_iterator_imp> p;
return element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 251 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::NotNull<const_elem_iterator_imp> p;
return const_element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 678 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::NotNull<const_elem_iterator_imp> p;
return const_element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 463 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
Referenced by ParallelMesh::renumber_nodes_and_elements().
{
Predicates::NotNull<elem_iterator_imp> p;
return element_iterator(_elements.end(), _elements.end(), p);
}
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 186 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(), Elem::subactive(), and GMVIO::write().
Referenced by MeshCommunication::allgather().
{
// We might actually want to run this on an empty mesh
// (e.g. the boundary mesh for a nonexistant bcid!)
// libmesh_assert(this->n_nodes() != 0);
// libmesh_assert(this->n_elem() != 0);
// This function must be run on all processors at once
parallel_only();
START_LOG('find_neighbors()', 'Mesh');
const element_iterator el_end = this->elements_end();
//TODO:[BSK] This should be removed later?!
if (reset_current_list)
for (element_iterator el = this->elements_begin(); el != el_end; ++el)
{
Elem* elem = *el;
for (unsigned int s=0; s<elem->n_neighbors(); s++)
if (elem->neighbor(s) != remote_elem ||
reset_remote_elements)
elem->set_neighbor(s,NULL);
}
// Find neighboring elements by first finding elements
// with identical side keys and then check to see if they
// are neighbors
{
// data structures -- Use the hash_multimap if available
typedef unsigned int key_type;
typedef std::pair<Elem*, unsigned char> val_type;
typedef std::pair<key_type, val_type> key_val_pair;
#if defined(LIBMESH_HAVE_UNORDERED_MAP)
typedef std::unordered_multimap<key_type, val_type> map_type;
#elif defined(LIBMESH_HAVE_TR1_UNORDERED_MAP)
typedef std::tr1::unordered_multimap<key_type, val_type> map_type;
#elif defined(LIBMESH_HAVE_HASH_MAP)
typedef std::hash_multimap<key_type, val_type> map_type;
#elif defined(LIBMESH_HAVE_EXT_HASH_MAP)
# if (__GNUC__ == 3) && (__GNUC_MINOR__ == 0) // gcc 3.0
typedef std::hash_multimap<key_type, val_type> map_type;
# elif (__GNUC__ >= 3) // gcc 3.1 & newer
typedef __gnu_cxx::hash_multimap<key_type, val_type> map_type;
# else
// XLC and who knows what other compilers get here.
// Try the most standard thing we can:
typedef std::multimap<key_type, val_type> map_type;
# endif
#else
typedef std::multimap<key_type, val_type> map_type;
#endif
// A map from side keys to corresponding elements & side numbers
map_type side_to_elem_map;
for (element_iterator el = this->elements_begin(); el != el_end; ++el)
{
Elem* element = *el;
for (unsigned int ms=0; ms<element->n_neighbors(); ms++)
{
next_side:
// If we haven't yet found a neighbor on this side, try.
// Even if we think our neighbor is remote, that
// information may be out of date.
if (element->neighbor(ms) == NULL ||
element->neighbor(ms) == remote_elem)
{
// Get the key for the side of this element
const unsigned int key = element->key(ms);
// Look for elements that have an identical side key
std::pair <map_type::iterator, map_type::iterator>
bounds = side_to_elem_map.equal_range(key);
// May be multiple keys, check all the possible
// elements which _might_ be neighbors.
if (bounds.first != bounds.second)
{
// Get the side for this element
const AutoPtr<DofObject> my_side(element->side(ms));
// Look at all the entries with an equivalent key
while (bounds.first != bounds.second)
{
// Get the potential element
Elem* neighbor = bounds.first->second.first;
// Get the side for the neighboring element
const unsigned int ns = bounds.first->second.second;
const AutoPtr<DofObject> their_side(neighbor->side(ns));
//libmesh_assert (my_side.get() != NULL);
//libmesh_assert (their_side.get() != NULL);
// If found a match with my side
//
// We need special tests here for 1D:
// since parents and children have an equal
// side (i.e. a node), we need to check
// ns != ms, and we also check level() to
// avoid setting our neighbor pointer to
// any of our neighbor's descendants
if( (*my_side == *their_side) &&
(element->level() == neighbor->level()) &&
((_dim != 1) || (ns != ms)) )
{
// So share a side. Is this a mixed pair
// of subactive and active/ancestor
// elements?
// If not, then we're neighbors.
// If so, then the subactive's neighbor is
if (element->subactive() ==
neighbor->subactive())
{
// an element is only subactive if it has
// been coarsened but not deleted
element->set_neighbor (ms,neighbor);
neighbor->set_neighbor(ns,element);
}
else if (element->subactive())
{
element->set_neighbor(ms,neighbor);
}
else if (neighbor->subactive())
{
neighbor->set_neighbor(ns,element);
}
side_to_elem_map.erase (bounds.first);
// get out of this nested crap
goto next_side;
}
++bounds.first;
}
}
// didn't find a match...
// Build the map entry for this element
key_val_pair kvp;
kvp.first = key;
kvp.second.first = element;
kvp.second.second = ms;
// use the lower bound as a hint for
// where to put it.
#if defined(LIBMESH_HAVE_UNORDERED_MAP) || defined(LIBMESH_HAVE_TR1_UNORDERED_MAP) || defined(LIBMESH_HAVE_HASH_MAP) || defined(LIBMESH_HAVE_EXT_HASH_MAP)
side_to_elem_map.insert (kvp);
#else
side_to_elem_map.insert (bounds.first,kvp);
#endif
}
}
}
}
#ifdef LIBMESH_ENABLE_AMR
const unsigned int n_levels = MeshTools::n_levels(*this);
for (unsigned int level = 1; level < n_levels; ++level)
{
element_iterator end = this->level_elements_end(level);
for (element_iterator el = this->level_elements_begin(level);
el != end; ++el)
{
Elem* elem = *el;
libmesh_assert(elem);
libmesh_assert(elem->parent());
for (unsigned int s=0; s < elem->n_neighbors(); s++)
if (elem->neighbor(s) == NULL)
// This currently leads to an infinite loop in ex10?
// if (elem->neighbor(s) == NULL ||
// (elem->neighbor(s) == remote_elem &&
// parent->is_child_on_side(parent->which_child_am_i(elem), s)))
{
Elem *neigh = elem->parent()->neighbor(s);
// If neigh was refined and had non-subactive children
// made remote earlier, then a non-subactive elem should
// actually have one of those remote children as a
// neighbor
if (neigh && (neigh->ancestor()) && (!elem->subactive()))
{
#ifdef DEBUG
// Let's make sure that 'had children made remote'
// situation is actually the case
libmesh_assert(neigh->has_children());
bool neigh_has_remote_children = false;
for (unsigned int c = 0; c != neigh->n_children(); ++c)
{
if (neigh->child(c) == remote_elem)
neigh_has_remote_children = true;
}
libmesh_assert(neigh_has_remote_children);
// And let's double-check that we don't have
// a remote_elem neighboring a local element
libmesh_assert(elem->processor_id() !=
libMesh::processor_id());
#endif // DEBUG
neigh = const_cast<RemoteElem*>(remote_elem);
}
elem->set_neighbor(s, neigh);
#ifdef DEBUG
if (neigh != NULL && neigh != remote_elem)
// We ignore subactive elements here because
// we don't care about neighbors of subactive element.
if ((!neigh->active()) && (!elem->subactive()))
{
std::cerr << 'On processor ' << libMesh::processor_id()
<< std::endl;
std::cerr << 'Bad element ID = ' << elem->id()
<< ', Side ' << s << ', Bad neighbor ID = ' << neigh->id() << std::endl;
std::cerr << 'Bad element proc_ID = ' << elem->processor_id()
<< ', Bad neighbor proc_ID = ' << neigh->processor_id() << std::endl;
std::cerr << 'Bad element size = ' << elem->hmin()
<< ', Bad neighbor size = ' << neigh->hmin() << std::endl;
std::cerr << 'Bad element center = ' << elem->centroid()
<< ', Bad neighbor center = ' << neigh->centroid() << std::endl;
std::cerr << 'ERROR: '
<< (elem->active()?'Active':'Ancestor')
<< ' Element at level '
<< elem->level() << std::endl;
std::cerr << 'with '
<< (elem->parent()->active()?'active':
(elem->parent()->subactive()?'subactive':'ancestor'))
<< ' parent share '
<< (neigh->subactive()?'subactive':'ancestor')
<< ' neighbor at level ' << neigh->level()
<< std::endl;
GMVIO(*this).write ('bad_mesh.gmv');
libmesh_error();
}
#endif // DEBUG
}
}
}
#endif // AMR
#ifdef DEBUG
MeshTools::libmesh_assert_valid_neighbors(*this);
#endif
STOP_LOG('find_neighbors()', 'Mesh');
}
Definition at line 203 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().
{
std::ostringstream out;
out << ' Mesh Information:' << '
<< ' mesh_dimension()=' << this->mesh_dimension() << '
<< ' spatial_dimension()=' << this->spatial_dimension() << '
<< ' n_nodes()=' << this->n_nodes() << '
<< ' n_local_nodes()=' << this->n_local_nodes() << '
<< ' n_elem()=' << this->n_elem() << '
<< ' n_local_elem()=' << this->n_local_elem() << '
#ifdef LIBMESH_ENABLE_AMR
<< ' n_active_elem()=' << this->n_active_elem() << '
#endif
<< ' n_subdomains()=' << this->n_subdomains() << '
<< ' n_processors()=' << this->n_processors() << '
<< ' processor_id()=' << this->processor_id() << ';
return out.str();
}
Implements MeshBase.
Definition at line 280 of file parallel_mesh.C.
References ParallelMesh::_elements, ParallelMesh::delete_elem(), and DofObject::id().
{
if (_elements[e->id()])
this->delete_elem(_elements[e->id()]);
_elements[e->id()] = e;
return e;
}
Definition at line 408 of file parallel_mesh.C.
References ParallelMesh::_nodes, and DofObject::id().
{
// If we already have this node we cannot
// simply delete it, because we may have elements
// which are attached to its address.
//
// Instead, call the Node = Point assignment operator
// to overwrite the spatial coordinates (but keep its
// address), delete the provided node, and return the
// address of the one we already had.
if (_nodes.count(n->id()))
{
Node *my_n = _nodes[n->id()];
*my_n = static_cast<Point>(*n);
delete n;
n = my_n;
}
else
_nodes[n->id()] = n;
return n;
}
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().
{ return _is_prepared; }
Reimplemented from MeshBase.
Definition at line 97 of file parallel_mesh.h.
References ParallelMesh::_is_serial.
Referenced by ParallelMesh::add_elem(), ParallelMesh::add_node(), MeshCommunication::allgather(), and MeshCommunication::delete_remote_elements().
{ return _is_serial; }
Implements MeshBase.
Definition at line 146 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
Referenced by MeshCommunication::delete_remote_elements().
{
Predicates::Level<elem_iterator_imp> p(level);
return element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 360 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::Level<const_elem_iterator_imp> p(level);
return const_element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 573 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
Referenced by MeshCommunication::delete_remote_elements().
{
Predicates::Level<elem_iterator_imp> p(level);
return element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 788 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::Level<const_elem_iterator_imp> p(level);
return const_element_iterator(_elements.end(), _elements.end(), p);
}
Definition at line 562 of file parallel_mesh.C.
References ParallelMesh::_elements, ParallelMesh::elem(), libMesh::invalid_uint, std::min(), Elem::p_refinement_flag(), ParallelMesh::parallel_max_elem_id(), and Elem::refinement_flag().
Referenced by ParallelMesh::allgather(), ParallelMesh::delete_remote_elements(), and ParallelMesh::renumber_nodes_and_elements().
{
#ifdef LIBMESH_ENABLE_AMR
// This function must be run on all processors at once
parallel_only();
unsigned int pmax_elem_id = this->parallel_max_elem_id();
for (unsigned int i=0; i != pmax_elem_id; ++i)
{
Elem* elem = _elements[i]; // Returns NULL if there's no map entry
unsigned int refinement_flag = elem ?
static_cast<unsigned int> (elem->refinement_flag()) : libMesh::invalid_uint;
unsigned int p_refinement_flag = elem ?
static_cast<unsigned int> (elem->p_refinement_flag()) : libMesh::invalid_uint;
unsigned int min_rflag = refinement_flag;
Parallel::min(min_rflag);
// All processors with this element should agree on flag
libmesh_assert (!elem || min_rflag == refinement_flag);
unsigned int min_pflag = p_refinement_flag;
// All processors with this element should agree on flag
libmesh_assert (!elem || min_pflag == p_refinement_flag);
}
#endif // LIBMESH_ENABLE_AMR
}
Definition at line 554 of file parallel_mesh.C.
References ParallelMesh::_elements, ParallelMesh::_nodes, and ParallelMesh::libmesh_assert_valid_parallel_object_ids().
Referenced by MeshRefinement::_refine_elements(), ParallelMesh::allgather(), InfElemBuilder::build_inf_elem(), ParallelMesh::delete_remote_elements(), MeshRefinement::refine_and_coarsen_elements(), and ParallelMesh::renumber_nodes_and_elements().
{
this->libmesh_assert_valid_parallel_object_ids (this->_elements);
this->libmesh_assert_valid_parallel_object_ids (this->_nodes);
}
Definition at line 519 of file parallel_mesh.C.
References DofObject::invalid_id, DofObject::invalid_processor_id, std::min(), and libMesh::processor_id().
Referenced by ParallelMesh::libmesh_assert_valid_parallel_ids().
{
// This function must be run on all processors at once
parallel_only();
unsigned int pmax_elem_id = this->parallel_max_elem_id();
for (unsigned int i=0; i != pmax_elem_id; ++i)
{
T* obj = objects[i]; // Returns NULL if there's no map entry
unsigned int dofid = obj && obj->valid_id() ?
obj->id() : DofObject::invalid_id;
// Local lookups by id should return the requested object
libmesh_assert(!obj || obj->id() == i);
unsigned int min_dofid = dofid;
Parallel::min(min_dofid);
// All processors with an object should agree on id
libmesh_assert (!obj || dofid == min_dofid);
unsigned int procid = obj && obj->valid_processor_id() ?
obj->processor_id() : DofObject::invalid_processor_id;
unsigned int min_procid = procid;
Parallel::min(min_procid);
// All processors with an object should agree on processor id
libmesh_assert (!obj || procid == min_procid);
// I should own any object another processor thinks I do
libmesh_assert (min_procid != libMesh::processor_id() || obj);
}
}
Implements MeshBase.
Definition at line 106 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
Referenced by MeshCommunication::delete_remote_elements().
{
Predicates::Local<elem_iterator_imp> p;
return element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 320 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::Local<const_elem_iterator_imp> p;
return const_element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 533 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
Referenced by MeshCommunication::delete_remote_elements().
{
Predicates::Local<elem_iterator_imp> p;
return element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 748 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::Local<const_elem_iterator_imp> p;
return const_element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 166 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::LocalLevel<elem_iterator_imp> p(level);
return element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 380 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::LocalLevel<const_elem_iterator_imp> p(level);
return const_element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 593 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::LocalLevel<elem_iterator_imp> p(level);
return element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 808 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::LocalLevel<const_elem_iterator_imp> p(level);
return const_element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 910 of file parallel_mesh_iterators.C.
References ParallelMesh::_nodes, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::Local<node_iterator_imp> p;
return node_iterator(_nodes.begin(), _nodes.end(), p);
}
Implements MeshBase.
Definition at line 950 of file parallel_mesh_iterators.C.
References ParallelMesh::_nodes, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::Local<const_node_iterator_imp> p;
return const_node_iterator(_nodes.begin(), _nodes.end(), p);
}
Implements MeshBase.
Definition at line 990 of file parallel_mesh_iterators.C.
References ParallelMesh::_nodes, and mapvector< Val >::end().
{
Predicates::Local<node_iterator_imp> p;
return node_iterator(_nodes.end(), _nodes.end(), p);
}
Implements MeshBase.
Definition at line 1030 of file parallel_mesh_iterators.C.
References ParallelMesh::_nodes, and mapvector< Val >::end().
{
Predicates::Local<const_node_iterator_imp> p;
return const_node_iterator(_nodes.end(), _nodes.end(), p);
}
Implements MeshBase.
Definition at line 176 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::LocalNotLevel<elem_iterator_imp> p(level);
return element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 390 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::LocalNotLevel<const_elem_iterator_imp> p(level);
return const_element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 603 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::LocalNotLevel<elem_iterator_imp> p(level);
return element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 818 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::LocalNotLevel<const_elem_iterator_imp> p(level);
return const_element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 156 of file parallel_mesh.h.
References ParallelMesh::_max_elem_id.
Referenced by ParallelMesh::allgather(), ParallelMesh::delete_remote_elements(), MeshCommunication::delete_remote_elements(), ParallelMesh::ParallelMesh(), and ParallelMesh::renumber_nodes_and_elements().
{ return _max_elem_id; }
Implements MeshBase.
Definition at line 152 of file parallel_mesh.h.
References ParallelMesh::_max_node_id.
Referenced by ParallelMesh::allgather(), ParallelMesh::delete_remote_elements(), MeshCommunication::delete_remote_elements(), ParallelMesh::ParallelMesh(), and ParallelMesh::renumber_nodes_and_elements().
{ return _max_node_id; }
Definition at line 140 of file mesh_base.h.
References MeshBase::_dim.
Referenced by ExactSolution::_compute_error(), UniformRefinementEstimator::_estimate_error(), HPCoarsenTest::add_projection(), UnstructuredMesh::all_second_order(), MeshTools::Generation::build_cube(), EquationSystems::build_discontinuous_solution_vector(), EquationSystems::build_solution_vector(), System::calculate_norm(), DofMap::create_dof_constraints(), MeshTools::Modification::distort(), JumpErrorEstimator::estimate_error(), ExactErrorEstimator::estimate_error(), MeshRefinement::flag_elements_by_elem_fraction(), MeshRefinement::flag_elements_by_nelem_target(), MeshBase::get_info(), MeshFunction::gradient(), MeshFunction::hessian(), PointLocatorTree::init(), LaplaceMeshSmoother::init(), System::ProjectVector::operator()(), PatchRecoveryErrorEstimator::EstimateError::operator()(), MeshFunction::operator()(), Nemesis_IO::read(), ExodusII_IO::read(), System::read_header(), GmshIO::read_mesh(), OFFIO::read_stream(), MatlabIO::read_stream(), MeshTools::Modification::rotate(), HPCoarsenTest::select_refinement(), MeshTools::Modification::smooth(), DofMap::use_coupled_neighbor_dofs(), PostscriptIO::write(), TecplotIO::write_ascii(), GMVIO::write_ascii_old_impl(), TecplotIO::write_binary(), GMVIO::write_discontinuous_gmv(), EnsightIO::write_scalar_ascii(), GnuPlotIO::write_solution(), DivaIO::write_stream(), and EnsightIO::write_vector_ascii().
{ return static_cast<unsigned int>(_dim); }
Implements MeshBase.
Definition at line 881 of file parallel_mesh.C.
References ParallelMesh::active_local_elements_begin(), ParallelMesh::active_local_elements_end(), ParallelMesh::active_pid_elements_begin(), ParallelMesh::active_pid_elements_end(), and DofObject::invalid_processor_id.
{
parallel_only();
// Get local active elements first
unsigned int active_elements =
static_cast<unsigned int>(std::distance (this->active_local_elements_begin(),
this->active_local_elements_end()));
Parallel::sum(active_elements);
// Then add unpartitioned active elements, which should exist on
// every processor
active_elements +=
static_cast<unsigned int>(std::distance
(this->active_pid_elements_begin(DofObject::invalid_processor_id),
this->active_pid_elements_end(DofObject::invalid_processor_id)));
return active_elements;
}
Definition at line 164 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().
{
libmesh_assert (proc_id < libMesh::n_processors());
return static_cast<unsigned int>(std::distance (this->active_pid_elements_begin(proc_id),
this->active_pid_elements_end (proc_id)));
}
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().
{ return this->n_active_elem_on_proc (libMesh::processor_id()); }
Definition at line 188 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().
{
unsigned int ne=0;
const_element_iterator el = this->active_elements_begin();
const const_element_iterator end = this->active_elements_end();
for (; el!=end; ++el)
ne += (*el)->n_sub_elem();
return ne;
}
Implements MeshBase.
Definition at line 154 of file parallel_mesh.h.
References ParallelMesh::_n_elem.
Referenced by ParallelMesh::allgather(), ParallelMesh::delete_remote_elements(), ParallelMesh::ParallelMesh(), Nemesis_IO::read(), and ParallelMesh::renumber_nodes_and_elements().
{ return _n_elem; }
Definition at line 151 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().
{
// We're either counting a processor's elements or unpartitioned
// elements
libmesh_assert (proc_id < libMesh::n_processors() ||
proc_id == DofObject::invalid_processor_id);
return static_cast<unsigned int>(std::distance (this->pid_elements_begin(proc_id),
this->pid_elements_end (proc_id)));
}
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().
{ return this->n_elem_on_proc (libMesh::processor_id()); }
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().
{ return this->n_nodes_on_proc (libMesh::processor_id()); }
Implements MeshBase.
Definition at line 151 of file parallel_mesh.h.
References ParallelMesh::_n_nodes.
Referenced by ParallelMesh::allgather(), ParallelMesh::delete_remote_elements(), ParallelMesh::ParallelMesh(), Nemesis_IO::read(), ParallelMesh::renumber_nodes_and_elements(), and BoundaryInfo::sync().
{ return _n_nodes; }
Definition at line 138 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().
{
// We're either counting a processor's nodes or unpartitioned
// nodes
libmesh_assert (proc_id < libMesh::n_processors() ||
proc_id == DofObject::invalid_processor_id);
return static_cast<unsigned int>(std::distance (this->pid_nodes_begin(proc_id),
this->pid_nodes_end (proc_id)));
}
Definition at line 429 of file mesh_base.h.
References MeshBase::_n_parts.
Referenced by Partitioner::set_node_processor_ids(), BoundaryInfo::sync(), UnstructuredMesh::write(), GMVIO::write_ascii_new_impl(), and GMVIO::write_ascii_old_impl().
{ return _n_parts; }
Definition at line 436 of file mesh_base.h.
Referenced by ParallelMesh::add_elem(), ParallelMesh::add_node(), ParallelMesh::clear(), UnstructuredMesh::create_pid_mesh(), MeshBase::get_info(), ParallelMesh::renumber_dof_objects(), ParallelMesh::renumber_nodes_and_elements(), and GMVIO::write_discontinuous_gmv().
{ return libMesh::n_processors(); }
Definition at line 173 of file mesh_base.C.
References MeshBase::elements_begin(), and MeshBase::elements_end().
{
unsigned int ne=0;
const_element_iterator el = this->elements_begin();
const const_element_iterator end = this->elements_end();
for (; el!=end; ++el)
ne += (*el)->n_sub_elem();
return ne;
}
Definition at line 420 of file mesh_base.h.
References MeshBase::_n_sbd.
Referenced by MeshBase::get_info(), BoundaryInfo::sync(), XdrIO::write(), and UnstructuredMesh::write().
{ return _n_sbd; }
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().
{ return this->n_elem_on_proc (DofObject::invalid_processor_id); }
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().
{ return this->n_nodes_on_proc (DofObject::invalid_processor_id); }
Implements MeshBase.
Definition at line 170 of file parallel_mesh.C.
References ParallelMesh::_nodes.
Referenced by ParallelMesh::renumber_node(), and ParallelMesh::renumber_nodes_and_elements().
{
libmesh_assert (_nodes[i] != NULL);
libmesh_assert (_nodes[i]->id() == i);
return (*_nodes[i]);
}
Implements MeshBase.
Definition at line 182 of file parallel_mesh.C.
References ParallelMesh::_nodes.
{
libmesh_assert (_nodes[i] != NULL);
libmesh_assert (_nodes[i]->id() == i);
return (*_nodes[i]);
}
Implements MeshBase.
Definition at line 192 of file parallel_mesh.C.
References ParallelMesh::_nodes.
Referenced by Nemesis_IO::read(), and BoundaryInfo::sync().
{
// libmesh_assert (_nodes[i] != NULL);
libmesh_assert (_nodes[i] == NULL || _nodes[i]->id() == i);
return _nodes[i];
}
Implements MeshBase.
Definition at line 203 of file parallel_mesh.C.
References ParallelMesh::_nodes.
{
// libmesh_assert (_nodes[i] != NULL);
libmesh_assert (_nodes[i] == NULL || _nodes[i]->id() == i);
return _nodes[i];
}
Implements MeshBase.
Definition at line 930 of file parallel_mesh_iterators.C.
References ParallelMesh::_nodes, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::NotNull<const_node_iterator_imp> p;
return const_node_iterator(_nodes.begin(), _nodes.end(), p);
}
Implements MeshBase.
Definition at line 890 of file parallel_mesh_iterators.C.
References ParallelMesh::_nodes, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::NotNull<node_iterator_imp> p;
return node_iterator(_nodes.begin(), _nodes.end(), p);
}
Implements MeshBase.
Definition at line 1010 of file parallel_mesh_iterators.C.
References ParallelMesh::_nodes, and mapvector< Val >::end().
{
Predicates::NotNull<const_node_iterator_imp> p;
return const_node_iterator(_nodes.end(), _nodes.end(), p);
}
Implements MeshBase.
Definition at line 970 of file parallel_mesh_iterators.C.
References ParallelMesh::_nodes, and mapvector< Val >::end().
{
Predicates::NotNull<node_iterator_imp> p;
return node_iterator(_nodes.end(), _nodes.end(), p);
}
Implements MeshBase.
Definition at line 56 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::NotActive<elem_iterator_imp> p;
return element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 270 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::NotActive<const_elem_iterator_imp> p;
return const_element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 483 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::NotActive<elem_iterator_imp> p;
return element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 698 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::NotActive<const_elem_iterator_imp> p;
return const_element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 76 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::Ancestor<elem_iterator_imp> p;
return element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 290 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::Ancestor<const_elem_iterator_imp> p;
return const_element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 718 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::Ancestor<const_elem_iterator_imp> p;
return const_element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 503 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::Ancestor<elem_iterator_imp> p;
return element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 370 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::NotLevel<const_elem_iterator_imp> p(level);
return const_element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 156 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::NotLevel<elem_iterator_imp> p(level);
return element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 583 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::NotLevel<elem_iterator_imp> p(level);
return element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 798 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::NotLevel<const_elem_iterator_imp> p(level);
return const_element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 116 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
Referenced by MeshCommunication::delete_remote_elements().
{
Predicates::NotLocal<elem_iterator_imp> p;
return element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 330 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::NotLocal<const_elem_iterator_imp> p;
return const_element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 543 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
Referenced by MeshCommunication::delete_remote_elements().
{
Predicates::NotLocal<elem_iterator_imp> p;
return element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 758 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::NotLocal<const_elem_iterator_imp> p;
return const_element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 96 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::NotSubActive<elem_iterator_imp> p;
return element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 310 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::NotSubActive<const_elem_iterator_imp> p;
return const_element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 523 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::NotSubActive<elem_iterator_imp> p;
return element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 738 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::NotSubActive<const_elem_iterator_imp> p;
return const_element_iterator(_elements.end(), _elements.end(), p);
}
Definition at line 119 of file parallel_mesh.C.
References ParallelMesh::_elements, and std::max().
Referenced by ParallelMesh::allgather(), ParallelMesh::delete_remote_elements(), ParallelMesh::libmesh_assert_valid_parallel_flags(), and ParallelMesh::renumber_nodes_and_elements().
{
// This function must be run on all processors at once
parallel_only();
unsigned int max_local = _elements.empty() ?
0 : _elements.rbegin()->first + 1;
Parallel::max(max_local);
return max_local;
}
Definition at line 145 of file parallel_mesh.C.
References ParallelMesh::_nodes, and std::max().
Referenced by ParallelMesh::allgather(), ParallelMesh::delete_remote_elements(), and ParallelMesh::renumber_nodes_and_elements().
{
// This function must be run on all processors at once
parallel_only();
unsigned int max_local = _nodes.empty() ?
0 : _nodes.rbegin()->first + 1;
Parallel::max(max_local);
return max_local;
}
Definition at line 106 of file parallel_mesh.C.
References MeshBase::n_local_elem(), and MeshBase::n_unpartitioned_elem().
Referenced by ParallelMesh::allgather(), ParallelMesh::delete_remote_elements(), Nemesis_IO::read(), and ParallelMesh::renumber_nodes_and_elements().
{
// This function must be run on all processors at once
parallel_only();
unsigned int n_local = this->n_local_elem();
Parallel::sum(n_local);
n_local += this->n_unpartitioned_elem();
return n_local;
}
Definition at line 132 of file parallel_mesh.C.
References MeshBase::n_local_nodes(), and MeshBase::n_unpartitioned_nodes().
Referenced by ParallelMesh::allgather(), ParallelMesh::delete_remote_elements(), Nemesis_IO::read(), and ParallelMesh::renumber_nodes_and_elements().
{
// This function must be run on all processors at once
parallel_only();
unsigned int n_local = this->n_local_nodes();
Parallel::sum(n_local);
n_local += this->n_unpartitioned_nodes();
return n_local;
}
Definition at line 241 of file mesh_base.C.
References MeshBase::partitioner().
Referenced by MeshBase::prepare_for_use().
{
if (partitioner().get()) // 'NULL' means don't partition
partitioner()->partition (*this, n_parts);
}
Definition at line 103 of file mesh_base.h.
References MeshBase::_partitioner.
Referenced by UniformRefinementEstimator::_estimate_error(), MeshBase::partition(), and BoundaryInfo::sync().
{ return _partitioner; }
Implements MeshBase.
Definition at line 400 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::PID<const_elem_iterator_imp> p(proc_id);
return const_element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 186 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
Referenced by ParallelMesh::unpartitioned_elements_begin().
{
Predicates::PID<elem_iterator_imp> p(proc_id);
return element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 827 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::PID<const_elem_iterator_imp> p(proc_id);
return const_element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 613 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
Referenced by ParallelMesh::unpartitioned_elements_end().
{
Predicates::PID<elem_iterator_imp> p(proc_id);
return element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 920 of file parallel_mesh_iterators.C.
References ParallelMesh::_nodes, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::PID<node_iterator_imp> p(proc_id);
return node_iterator(_nodes.begin(), _nodes.end(), p);
}
Implements MeshBase.
Definition at line 960 of file parallel_mesh_iterators.C.
References ParallelMesh::_nodes, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::PID<const_node_iterator_imp> p(proc_id);
return const_node_iterator(_nodes.begin(), _nodes.end(), p);
}
Implements MeshBase.
Definition at line 1000 of file parallel_mesh_iterators.C.
References ParallelMesh::_nodes, and mapvector< Val >::end().
{
Predicates::PID<node_iterator_imp> p(proc_id);
return node_iterator(_nodes.end(), _nodes.end(), p);
}
Implements MeshBase.
Definition at line 1040 of file parallel_mesh_iterators.C.
References ParallelMesh::_nodes, and mapvector< Val >::end().
{
Predicates::PID<const_node_iterator_imp> p(proc_id);
return const_node_iterator(_nodes.end(), _nodes.end(), p);
}
Implements MeshBase.
Definition at line 158 of file parallel_mesh.C.
References ParallelMesh::_nodes.
{
libmesh_assert (_nodes[i] != NULL);
libmesh_assert (_nodes[i]->id() == i);
return (*_nodes[i]);
}
Definition at line 267 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().
{
if (_point_locator.get() == NULL)
_point_locator.reset (PointLocatorBase::build(TREE, *this).release());
return *_point_locator;
}
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 81 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 UnstructuredMesh::all_first_order(), UnstructuredMesh::all_second_order(), MeshTools::Modification::all_tri(), MeshTools::Generation::build_cube(), InfElemBuilder::build_inf_elem(), MeshRefinement::coarsen_elements(), Triangle::copy_tri_to_mesh(), UnstructuredMesh::create_submesh(), MeshTools::Modification::flatten(), UnstructuredMesh::read(), GMVIO::read(), MeshRefinement::refine_and_coarsen_elements(), MeshRefinement::refine_elements(), BoundaryInfo::sync(), MeshRefinement::uniformly_coarsen(), and MeshRefinement::uniformly_refine().
{
// Renumber the nodes and elements so that they in contiguous
// blocks. By default, skip_renumber_nodes_and_elements is false,
// however we may skip this step by passing
// skip_renumber_nodes_and_elements==true to this function.
//
// Instances where you if prepare_for_use() should not renumber the nodes
// and elements include reading in e.g. an xda/r or gmv file. In
// this case, the ordering of the nodes may depend on an accompanying
// solution, and the node ordering cannot be changed.
if(!skip_renumber_nodes_and_elements)
this->renumber_nodes_and_elements();
// Let all the elements find their neighbors
this->find_neighbors();
// Partition the mesh.
this->partition();
// If we're using ParallelMesh, we'll want it parallelized.
this->delete_remote_elements();
if(!skip_renumber_nodes_and_elements)
this->renumber_nodes_and_elements();
// Reset our PointLocator. This needs to happen any time the elements
// in the underlying elements in the mesh have changed, so we do it here.
this->clear_point_locator();
// The mesh is now prepared for use.
_is_prepared = true;
}
Definition at line 225 of file mesh_base.C.
References MeshBase::get_info().
Referenced by InfElemBuilder::build_inf_elem(), and operator<<().
{
os << this->get_info()
<< std::endl;
}
Definition at line 442 of file mesh_base.h.
Referenced by UnstructuredMesh::all_second_order(), EquationSystems::build_discontinuous_solution_vector(), ParallelMesh::clear(), DofMap::compute_sparsity(), UnstructuredMesh::find_neighbors(), MeshBase::get_info(), SparsityPattern::Build::operator()(), MeshData::read_xdr(), ParallelMesh::renumber_dof_objects(), ParallelMesh::renumber_nodes_and_elements(), GMVIO::write_discontinuous_gmv(), and System::write_header().
{ return libMesh::processor_id(); }
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 465 of file unstructured_mesh.C.
References XdrIO::binary(), MeshCommunication::broadcast(), XdrIO::legacy(), Quality::name(), MeshBase::prepare_for_use(), libMesh::processor_id(), VTKIO::read(), GMVIO::read(), GmshIO::read(), ExodusII_IO::read(), TetGenIO::read(), UNVIO::read(), OFFIO::read(), UCDIO::read(), MatlabIO::read(), XdrIO::read(), and LegacyXdrIO::read_mgf().
{
// See if the file exists. Perform this check on all processors
// so that the code is terminated properly in the case that the
// file does not exist.
{
std::ifstream in (name.c_str());
if (!in.good())
{
std::cerr << 'ERROR: cannot locate specified file:t'
<< name
<< std::endl;
libmesh_error();
}
}
// Set the skip_renumber_nodes_and_elements flag on all processors.
// This ensures that renumber_nodes_and_elements is *not* called
// during prepare_for_use() for certain types of mesh files.
// This is required in cases where there is an associated solution
// file which expects a certain ordering of the nodes.
if(name.rfind('.gmv')+4==name.size())
{
skip_renumber_nodes_and_elements = true;
}
// Look for parallel formats first
if (is_parallel_file_format(name))
{
// no need to handling bz2 files here -- the Xdr class does that.
if ((name.rfind('.xda') < name.size()) ||
(name.rfind('.xdr') < name.size()))
{
XdrIO xdr_io(*this);
// .xda* ==> bzip2/gzip/ASCII flavors
if (name.rfind('.xda') < name.size())
{
xdr_io.binary() = false;
xdr_io.read (name);
}
else // .xdr* ==> true binary XDR file
{
xdr_io.binary() = true;
xdr_io.read (name);
}
// The xdr_io object gets constructed with legacy() == false.
// if legacy() == true then it means that a legacy file was detected and
// thus processor 0 performed the read. We therefore need to broadcast the
// mesh. Further, for this flavor of mesh solution data ordering is tied
// to the node ordering, so we better not reorder the nodes!
if (xdr_io.legacy())
{
skip_renumber_nodes_and_elements = true;
MeshCommunication().broadcast(*this);
}
}
}
// Serial mesh formats
else
{
START_LOG('read()', 'Mesh');
// Read the file based on extension. Only processor 0
// needs to read the mesh. It will then broadcast it and
// the other processors will pick it up
if (libMesh::processor_id() == 0)
{
// Nasty hack for reading/writing zipped files
std::string new_name = name;
if (name.size() - name.rfind('.bz2') == 4)
{
new_name.erase(new_name.end() - 4, new_name.end());
std::string system_string = 'bunzip2 -f -k ';
system_string += name;
START_LOG('system(bunzip2)', 'Mesh');
if (std::system(system_string.c_str()))
libmesh_file_error(system_string);
STOP_LOG('system(bunzip2)', 'Mesh');
}
if (new_name.rfind('.mat') < new_name.size())
MatlabIO(*this).read(new_name);
else if (new_name.rfind('.ucd') < new_name.size())
UCDIO(*this).read (new_name);
else if ((new_name.rfind('.off') < new_name.size()) ||
(new_name.rfind('.ogl') < new_name.size()) ||
(new_name.rfind('.oogl') < new_name.size()))
OFFIO(*this).read (new_name);
else if (new_name.rfind('.mgf') < new_name.size())
LegacyXdrIO(*this,true).read_mgf (new_name);
else if (new_name.rfind('.unv') < new_name.size())
{
if (mesh_data == NULL)
{
std::cerr << 'Error! You must pass a '
<< 'valid MeshData pointer to '
<< 'read UNV files!' << std::endl;
libmesh_error();
}
UNVIO(*this, *mesh_data).read (new_name);
}
else if ((new_name.rfind('.node') < new_name.size()) ||
(new_name.rfind('.ele') < new_name.size()))
TetGenIO(*this,mesh_data).read (new_name);
else if (new_name.rfind('.exd') < new_name.size() ||
new_name.rfind('.e') < new_name.size())
ExodusII_IO(*this).read (new_name);
else if (new_name.rfind('.msh') < new_name.size())
GmshIO(*this).read (new_name);
else if (new_name.rfind('.gmv') < new_name.size())
GMVIO(*this).read (new_name);
else if (new_name.rfind('.vtu') < new_name.size())
VTKIO(*this).read(new_name);
else
{
std::cerr << ' ERROR: Unrecognized file extension: ' << name
<< ' I understand the following:n'
<< ' *.e -- Sandia's ExodusII format
<< ' *.exd -- Sandia's ExodusII format
<< ' *.gmv -- LANL's General Mesh Viewer format
<< ' *.mat -- Matlab triangular ASCII file
<< ' *.off -- OOGL OFF surface format
<< ' *.ucd -- AVS's ASCII UCD format
<< ' *.unv -- I-deas Universal format
<< ' *.vtu -- Paraview VTK format
<< ' *.xda -- libMesh ASCII format
<< ' *.xdr -- libMesh binary format
<< ' *.gz -- any above format gzipped
<< ' *.bz2 -- any above format bzip2'ed
<< std::endl;
libmesh_error();
}
// If we temporarily decompressed a .bz2 file, remove the
// uncompressed version
if (name.size() - name.rfind('.bz2') == 4)
std::remove(new_name.c_str());
}
STOP_LOG('read()', 'Mesh');
// Send the mesh & bcs (which are now only on processor 0) to the other
// processors
MeshCommunication().broadcast (*this);
}
// Done reading the mesh. Now prepare it for use.
this->prepare_for_use(skip_renumber_nodes_and_elements);
}
Definition at line 249 of file mesh_base.C.
References MeshBase::_n_parts, MeshBase::active_elements_begin(), MeshBase::active_elements_end(), and std::max().
{
const_element_iterator el = this->active_elements_begin();
const const_element_iterator end = this->active_elements_end();
unsigned int max_proc_id=0;
for (; el!=end; ++el)
max_proc_id = std::max(max_proc_id, static_cast<unsigned int>((*el)->processor_id()));
// The number of partitions is one more than the max processor ID.
_n_parts = max_proc_id+1;
return _n_parts;
}
Definition at line 595 of file parallel_mesh.C.
References ParallelMesh::allgather(), mapvector< Val >::begin(), mapvector< Val >::end(), mapvector< Val >::erase(), DofObject::invalid_processor_id, std::max(), MeshBase::n_processors(), libMesh::n_processors(), MeshBase::processor_id(), and libMesh::processor_id().
Referenced by ParallelMesh::renumber_nodes_and_elements().
{
// This function must be run on all processors at once
parallel_only();
typedef typename mapvector<T*>::veclike_iterator object_iterator;
// In parallel we may not know what objects other processors have.
// Start by figuring out how many
unsigned int unpartitioned_objects = 0;
std::vector<unsigned int>
ghost_objects_from_proc(libMesh::n_processors(), 0);
object_iterator it = objects.begin();
object_iterator end = objects.end();
for (; it != end;)
{
T *obj = *it;
// Remove any NULL container entries while we're here,
// being careful not to invalidate our iterator
if (!*it)
objects.erase(it++);
else
{
unsigned int obj_procid = obj->processor_id();
if (obj_procid == DofObject::invalid_processor_id)
unpartitioned_objects++;
else
ghost_objects_from_proc[obj_procid]++;
++it;
}
}
std::vector<unsigned int> objects_on_proc(libMesh::n_processors(), 0);
Parallel::allgather(ghost_objects_from_proc[libMesh::processor_id()],
objects_on_proc);
#ifndef NDEBUG
unsigned int global_unpartitioned_objects = unpartitioned_objects;
Parallel::max(global_unpartitioned_objects);
libmesh_assert(global_unpartitioned_objects == unpartitioned_objects);
for (unsigned int p=0; p != libMesh::n_processors(); ++p)
libmesh_assert(ghost_objects_from_proc[p] <= objects_on_proc[p]);
#endif
// We'll renumber objects in blocks by processor id
std::vector<unsigned int> first_object_on_proc(libMesh::n_processors());
for (unsigned int i=1; i != libMesh::n_processors(); ++i)
first_object_on_proc[i] = first_object_on_proc[i-1] +
objects_on_proc[i-1];
unsigned int next_id = first_object_on_proc[libMesh::processor_id()];
unsigned int first_free_id =
first_object_on_proc[libMesh::n_processors()-1] +
objects_on_proc[libMesh::n_processors()-1] +
unpartitioned_objects;
// First set new local object ids and build request sets
// for non-local object ids
// Request sets to send to each processor
std::vector<std::vector<unsigned int> >
requested_ids(libMesh::n_processors());
// We know how many objects live on each processor, so reseve() space for
// each.
for (unsigned int p=0; p != libMesh::n_processors(); ++p)
if (p != libMesh::processor_id())
requested_ids[p].reserve(ghost_objects_from_proc[p]);
end = objects.end();
for (it = objects.begin(); it != end; ++it)
{
T *obj = *it;
if (obj->processor_id() == libMesh::processor_id())
obj->set_id(next_id++);
else if (obj->processor_id() != DofObject::invalid_processor_id)
requested_ids[obj->processor_id()].push_back(obj->id());
}
// Next set ghost object ids from other processors
if (libMesh::n_processors() > 1)
{
for (unsigned int p=1; p != libMesh::n_processors(); ++p)
{
// Trade my requests with processor procup and procdown
unsigned int procup = (libMesh::processor_id() + p) %
libMesh::n_processors();
unsigned int procdown = (libMesh::n_processors() +
libMesh::processor_id() - p) %
libMesh::n_processors();
std::vector<unsigned int> request_to_fill;
Parallel::send_receive(procup, requested_ids[procup],
procdown, request_to_fill);
// Fill those requests
std::vector<unsigned int> new_ids(request_to_fill.size());
for (unsigned int i=0; i != request_to_fill.size(); ++i)
{
T *obj = objects[request_to_fill[i]];
libmesh_assert(obj);
libmesh_assert(obj->processor_id() == libMesh::processor_id());
new_ids[i] = obj->id();
libmesh_assert(new_ids[i] >=
first_object_on_proc[libMesh::processor_id()]);
libmesh_assert(new_ids[i] <
first_object_on_proc[libMesh::processor_id()] +
objects_on_proc[libMesh::processor_id()]);
}
// Trade back the results
std::vector<unsigned int> filled_request;
Parallel::send_receive(procdown, new_ids,
procup, filled_request);
// And copy the id changes we've now been informed of
for (unsigned int i=0; i != filled_request.size(); ++i)
{
T *obj = objects[requested_ids[procup][i]];
libmesh_assert (obj);
libmesh_assert (obj->processor_id() == procup);
libmesh_assert(filled_request[i] >=
first_object_on_proc[procup]);
libmesh_assert(filled_request[i] <
first_object_on_proc[procup] +
objects_on_proc[procup]);
obj->set_id(filled_request[i]);
}
}
}
// Next set unpartitioned object ids
next_id = 0;
for (unsigned int i=0; i != libMesh::n_processors(); ++i)
next_id += objects_on_proc[i];
for (it = objects.begin(); it != end; ++it)
{
T *obj = *it;
if (obj->processor_id() == DofObject::invalid_processor_id)
obj->set_id(next_id++);
}
// Finally shuffle around objects so that container indices
// match ids
end = objects.end();
for (it = objects.begin(); it != end;)
{
T *obj = *it;
if (obj) // don't try shuffling already-NULL entries
{
T *next = objects[obj->id()];
// If we have to move this object
if (next != obj)
{
// NULL out its original position for now
// (our shuffling may put another object there shortly)
*it = NULL;
// There may already be another object with this id that
// needs to be moved itself
while (next)
{
// We shouldn't be trying to give two objects the
// same id
libmesh_assert (next->id() != obj->id());
objects[obj->id()] = obj;
obj = next;
next = objects[obj->id()];
}
objects[obj->id()] = obj;
}
}
// Remove any container entries that were left as NULL,
// being careful not to invalidate our iterator
if (!*it)
objects.erase(it++);
else
++it;
}
return first_free_id;
}
Implements MeshBase.
Definition at line 314 of file parallel_mesh.C.
References ParallelMesh::_elements, ParallelMesh::elem(), mapvector< Val >::erase(), DofObject::id(), and DofObject::set_id().
{
Elem *elem = _elements[old_id];
libmesh_assert (elem);
libmesh_assert (elem->id() == old_id);
elem->set_id(new_id);
libmesh_assert (!_elements[new_id]);
_elements[new_id] = elem;
_elements.erase(old_id);
}
Implements MeshBase.
Definition at line 451 of file parallel_mesh.C.
References ParallelMesh::_nodes, mapvector< Val >::erase(), DofObject::id(), ParallelMesh::node(), and DofObject::set_id().
{
Node *node = _nodes[old_id];
libmesh_assert (node);
libmesh_assert (node->id() == old_id);
node->set_id(new_id);
libmesh_assert (!_nodes[new_id]);
_nodes[new_id] = node;
_nodes.erase(old_id);
}
Implements MeshBase.
Definition at line 781 of file parallel_mesh.C.
References ParallelMesh::_elements, ParallelMesh::_max_elem_id, ParallelMesh::_max_node_id, ParallelMesh::_n_elem, ParallelMesh::_n_nodes, ParallelMesh::_next_free_local_elem_id, ParallelMesh::_next_free_local_node_id, ParallelMesh::_next_free_unpartitioned_elem_id, ParallelMesh::_next_free_unpartitioned_node_id, ParallelMesh::_nodes, mapvector< Val >::begin(), MeshBase::boundary_info, ParallelMesh::elem(), ParallelMesh::elements_begin(), ParallelMesh::elements_end(), mapvector< Val >::end(), mapvector< Val >::erase(), DofObject::id(), MeshTools::libmesh_assert_valid_elem_ids(), ParallelMesh::libmesh_assert_valid_parallel_flags(), ParallelMesh::libmesh_assert_valid_parallel_ids(), ParallelMesh::max_elem_id(), ParallelMesh::max_node_id(), ParallelMesh::n_elem(), ParallelMesh::n_nodes(), Elem::n_nodes(), MeshBase::n_processors(), ParallelMesh::node(), Elem::node(), ParallelMesh::parallel_max_elem_id(), ParallelMesh::parallel_max_node_id(), ParallelMesh::parallel_n_elem(), ParallelMesh::parallel_n_nodes(), MeshBase::processor_id(), and ParallelMesh::renumber_dof_objects().
Referenced by MeshCommunication::delete_remote_elements().
{
START_LOG('renumber_nodes_and_elements()', 'ParallelMesh');
#ifdef DEBUG
// Make sure our ids and flags are consistent
this->libmesh_assert_valid_parallel_ids();
this->libmesh_assert_valid_parallel_flags();
#endif
std::set<unsigned int> used_nodes;
// flag the nodes we need
{
element_iterator it = elements_begin();
element_iterator end = elements_end();
for (; it != end; ++it)
{
Elem *elem = *it;
for (unsigned int n=0; n != elem->n_nodes(); ++n)
used_nodes.insert(elem->node(n));
}
}
// Nodes not connected to any local elements are deleted
{
node_iterator_imp it = _nodes.begin();
node_iterator_imp end = _nodes.end();
for (; it != end;)
{
Node *node = *it;
if (!used_nodes.count(node->id()))
{
// remove any boundary information associated with
// this node
this->boundary_info->remove (node);
// delete the node
delete node;
_nodes.erase(it++);
}
else
++it;
}
}
// Finally renumber all the elements
_n_elem = this->renumber_dof_objects (this->_elements);
_max_elem_id = _n_elem;
_next_free_local_elem_id = _n_elem;
// and all the remaining nodes
_n_nodes = this->renumber_dof_objects (this->_nodes);
_max_node_id = _n_nodes;
_next_free_local_node_id = _n_nodes;
// And figure out what IDs we should use when adding new nodes and
// new elements
unsigned int cycle = libMesh::n_processors()+1;
unsigned int offset = _next_free_local_elem_id % cycle;
if (offset)
_next_free_local_elem_id += cycle - offset;
_next_free_unpartitioned_elem_id = _next_free_local_elem_id +
libMesh::n_processors();
_next_free_local_elem_id += libMesh::processor_id();
offset = _next_free_local_node_id % cycle;
if (offset)
_next_free_local_node_id += cycle - offset;
_next_free_unpartitioned_node_id = _next_free_local_node_id +
libMesh::n_processors();
_next_free_local_node_id += libMesh::processor_id();
// Make sure our caches are up to date and our
// DofObjects are well packed
#ifdef DEBUG
libmesh_assert(this->n_nodes() == this->parallel_n_nodes());
libmesh_assert(this->n_elem() == this->parallel_n_elem());
libmesh_assert(this->max_node_id() == this->parallel_max_node_id());
libmesh_assert(this->max_elem_id() == this->parallel_max_elem_id());
libmesh_assert(this->n_nodes() == this->max_node_id());
libmesh_assert(this->n_elem() == this->max_elem_id());
// Make sure our ids and flags are consistent
this->libmesh_assert_valid_parallel_ids();
this->libmesh_assert_valid_parallel_flags();
// And make sure we've made our numbering monotonic
MeshTools::libmesh_assert_valid_elem_ids(*this);
#endif
STOP_LOG('renumber_nodes_and_elements()', 'ParallelMesh');
}
Implements MeshBase.
Definition at line 157 of file parallel_mesh.h.
{ }
Implements MeshBase.
Definition at line 153 of file parallel_mesh.h.
Referenced by BoundaryInfo::sync().
{ }
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().
{ libmesh_assert(!this->n_elem()); _dim = d; }
Definition at line 685 of file mesh_base.h.
References MeshBase::_n_parts.
Referenced by Partitioner::partition(), Partitioner::repartition(), and BoundaryInfo::sync().
{ return _n_parts; }
Definition at line 671 of file mesh_base.h.
References MeshBase::_n_sbd.
Referenced by BoundaryInfo::sync().
{ return _n_sbd; }
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().
{ return static_cast<unsigned int>(LIBMESH_DIM); }
Implements MeshBase.
Definition at line 86 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::SubActive<elem_iterator_imp> p;
return element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 300 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::SubActive<const_elem_iterator_imp> p;
return const_element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 513 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::SubActive<elem_iterator_imp> p;
return element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 728 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::SubActive<const_elem_iterator_imp> p;
return const_element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 410 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::Type<const_elem_iterator_imp> p(type);
return const_element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 196 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, mapvector< Val >::begin(), and mapvector< Val >::end().
{
Predicates::Type<elem_iterator_imp> p(type);
return element_iterator(_elements.begin(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 623 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::Type<elem_iterator_imp> p(type);
return element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 837 of file parallel_mesh_iterators.C.
References ParallelMesh::_elements, and mapvector< Val >::end().
{
Predicates::Type<const_elem_iterator_imp> p(type);
return const_element_iterator(_elements.end(), _elements.end(), p);
}
Implements MeshBase.
Definition at line 440 of file parallel_mesh_iterators.C.
References DofObject::invalid_processor_id, and ParallelMesh::pid_elements_begin().
{
return this->pid_elements_begin(DofObject::invalid_processor_id);
}
Implements MeshBase.
Definition at line 226 of file parallel_mesh_iterators.C.
References DofObject::invalid_processor_id, and ParallelMesh::pid_elements_begin().
Referenced by MeshCommunication::delete_remote_elements().
{
return this->pid_elements_begin(DofObject::invalid_processor_id);
}
Implements MeshBase.
Definition at line 653 of file parallel_mesh_iterators.C.
References DofObject::invalid_processor_id, and ParallelMesh::pid_elements_end().
Referenced by MeshCommunication::delete_remote_elements().
{
return this->pid_elements_end(DofObject::invalid_processor_id);
}
Implements MeshBase.
Definition at line 867 of file parallel_mesh_iterators.C.
References DofObject::invalid_processor_id, and ParallelMesh::pid_elements_end().
{
return this->pid_elements_end(DofObject::invalid_processor_id);
}
Implements MeshBase.
Definition at line 81 of file parallel_mesh.C.
References ParallelMesh::_elements, ParallelMesh::_max_elem_id, ParallelMesh::_max_node_id, ParallelMesh::_n_elem, ParallelMesh::_n_nodes, ParallelMesh::_nodes, std::max(), MeshBase::n_local_elem(), MeshBase::n_local_nodes(), MeshBase::n_unpartitioned_elem(), and MeshBase::n_unpartitioned_nodes().
{
// This function must be run on all processors at once
parallel_only();
_n_elem = this->n_local_elem();
Parallel::sum(_n_elem);
_n_elem += this->n_unpartitioned_elem();
_max_elem_id = _elements.empty() ?
0 : _elements.rbegin()->first + 1;
Parallel::max(_max_elem_id);
_n_nodes = this->n_local_nodes();
Parallel::sum(_n_nodes);
_n_nodes += this->n_unpartitioned_nodes();
_max_node_id = _nodes.empty() ?
0 : _nodes.rbegin()->first + 1;
Parallel::max(_max_node_id);
}
Definition at line 764 of file unstructured_mesh.C.
References MeshBase::n_subdomains(), GMVIO::partitioning(), MeshOutput< MT >::write_nodal_data(), GMVIO::write_nodal_data(), and TecplotIO::write_nodal_data().
{
START_LOG('write()', 'Mesh');
// Write the file based on extension
if (name.rfind('.dat') < name.size())
TecplotIO(*this).write_nodal_data (name, v, vn);
else if (name.rfind('.plt') < name.size())
TecplotIO(*this,true).write_nodal_data (name, v, vn);
else if (name.rfind('.gmv') < name.size())
{
if (n_subdomains() > 1)
GMVIO(*this).write_nodal_data (name, v, vn);
else
{
GMVIO io(*this);
io.partitioning() = false;
io.write_nodal_data (name, v, vn);
}
}
else if (name.rfind('.pvtu') < name.size())
{
VTKIO(*this).write_nodal_data (name, v, vn);
}
else
{
std::cerr << ' ERROR: Unrecognized file extension: ' << name
<< ' I understand the following:n'
<< ' *.dat -- Tecplot ASCII file
<< ' *.gmv -- LANL's GMV (General Mesh Viewer) format
<< ' *.plt -- Tecplot binary file
<< ' *.pvtu -- Paraview VTK file
<< 'Exiting without writing output;
}
STOP_LOG('write()', 'Mesh');
}
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 637 of file unstructured_mesh.C.
References MeshBase::n_partitions(), Quality::name(), GMVIO::partitioning(), libMesh::processor_id(), VTKIO::write(), FroIO::write(), GmshIO::write(), TetGenIO::write(), MEDITIO::write(), UNVIO::write(), ExodusII_IO::write(), DivaIO::write(), GMVIO::write(), UCDIO::write(), TecplotIO::write(), XdrIO::write(), and LegacyXdrIO::write_mgf().
{
// parallel formats are special -- they may choose to write
// separate files, let's not try to handle the zipping here.
if (is_parallel_file_format(name))
{
// no need to handling bz2 files here -- the Xdr class does that.
if (name.rfind('.xda') < name.size())
XdrIO(*this).write(name);
else if (name.rfind('.xdr') < name.size())
XdrIO(*this,true).write(name);
}
// serial file formats
else
{
START_LOG('write()', 'Mesh');
// Nasty hack for reading/writing zipped files
std::string new_name = name;
if (name.size() - name.rfind('.bz2') == 4)
new_name.erase(new_name.end() - 4, new_name.end());
// New scope so that io will close before we try to zip the file
{
// Write the file based on extension
if (new_name.rfind('.dat') < new_name.size())
TecplotIO(*this).write (new_name);
else if (new_name.rfind('.plt') < new_name.size())
TecplotIO(*this,true).write (new_name);
else if (new_name.rfind('.ucd') < new_name.size())
UCDIO (*this).write (new_name);
else if (new_name.rfind('.gmv') < new_name.size())
if (this->n_partitions() > 1)
GMVIO(*this).write (new_name);
else
{
GMVIO io(*this);
io.partitioning() = false;
io.write (new_name);
}
else if (new_name.rfind('.ugrid') < new_name.size())
DivaIO(*this).write(new_name);
else if (new_name.rfind('.exd') < new_name.size() ||
new_name.rfind('.e') < new_name.size())
ExodusII_IO(*this).write(new_name);
else if (new_name.rfind('.mgf') < new_name.size())
LegacyXdrIO(*this,true).write_mgf(new_name);
else if (new_name.rfind('.unv') < new_name.size())
{
if (mesh_data == NULL)
{
std::cerr << 'Error! You must pass a '
<< 'valid MeshData pointer to '
<< 'write UNV files!' << std::endl;
libmesh_error();
}
UNVIO(*this, *mesh_data).write (new_name);
}
else if (new_name.rfind('.mesh') < new_name.size())
MEDITIO(*this).write (new_name);
else if (new_name.rfind('.poly') < new_name.size())
TetGenIO(*this).write (new_name);
else if (new_name.rfind('.msh') < new_name.size())
GmshIO(*this).write (new_name);
else if (new_name.rfind('.fro') < new_name.size())
FroIO(*this).write (new_name);
else if (new_name.rfind('.vtu') < new_name.size())
VTKIO(*this).write (new_name);
else
{
std::cerr << ' ERROR: Unrecognized file extension: ' << name
<< ' I understand the following:n'
<< ' *.dat -- Tecplot ASCII file
<< ' *.e -- Sandia's ExodusII format
<< ' *.exd -- Sandia's ExodusII format
<< ' *.fro -- ACDL's surface triangulation file
<< ' *.gmv -- LANL's GMV (General Mesh Viewer) format
<< ' *.mesh -- MEdit mesh format
<< ' *.mgf -- MGF binary mesh format
<< ' *.msh -- GMSH ASCII file
<< ' *.plt -- Tecplot binary file
<< ' *.poly -- TetGen ASCII file
<< ' *.ucd -- AVS's ASCII UCD format
<< ' *.ugrid -- Kelly's DIVA ASCII format
<< ' *.unv -- I-deas Universal format
<< ' *.xda -- libMesh ASCII format
<< ' *.xdr -- libMesh binary format,
<< std::endl
<< 'Exiting without writing output;
}
}
// Nasty hack for reading/writing zipped files
if (name.size() - name.rfind('.bz2') == 4)
{
START_LOG('system(bzip2)', 'Mesh');
if (libMesh::processor_id() == 0)
{
std::string system_string = 'bzip2 -f ';
system_string += new_name;
if (std::system(system_string.c_str()))
libmesh_file_error(system_string);
}
Parallel::barrier();
STOP_LOG('system(bzip2)', 'Mesh');
}
STOP_LOG('write()', 'Mesh');
}
}
Definition at line 746 of file mesh_base.h.
Definition at line 232 of file mesh_base.C.
{
m.print_info(os);
return os;
}
Definition at line 740 of file mesh_base.h.
Definition at line 712 of file mesh_base.h.
Referenced by UnstructuredMesh::copy_nodes_and_elements(), UnstructuredMesh::find_neighbors(), MeshBase::mesh_dimension(), MeshBase::MeshBase(), and MeshBase::set_mesh_dimension().
Definition at line 375 of file parallel_mesh.h.
Referenced by ParallelMesh::active_elements_begin(), ParallelMesh::active_elements_end(), ParallelMesh::active_local_elements_begin(), ParallelMesh::active_local_elements_end(), ParallelMesh::active_local_subdomain_elements_begin(), ParallelMesh::active_local_subdomain_elements_end(), ParallelMesh::active_not_local_elements_begin(), ParallelMesh::active_not_local_elements_end(), ParallelMesh::active_pid_elements_begin(), ParallelMesh::active_pid_elements_end(), ParallelMesh::active_type_elements_begin(), ParallelMesh::active_type_elements_end(), ParallelMesh::add_elem(), ParallelMesh::ancestor_elements_begin(), ParallelMesh::ancestor_elements_end(), ParallelMesh::clear(), ParallelMesh::delete_elem(), ParallelMesh::elem(), ParallelMesh::elements_begin(), ParallelMesh::elements_end(), MeshTools::Private::fix_broken_node_and_element_numbering(), ParallelMesh::insert_elem(), ParallelMesh::level_elements_begin(), ParallelMesh::level_elements_end(), ParallelMesh::libmesh_assert_valid_parallel_flags(), ParallelMesh::libmesh_assert_valid_parallel_ids(), ParallelMesh::local_elements_begin(), ParallelMesh::local_elements_end(), ParallelMesh::local_level_elements_begin(), ParallelMesh::local_level_elements_end(), ParallelMesh::local_not_level_elements_begin(), ParallelMesh::local_not_level_elements_end(), ParallelMesh::not_active_elements_begin(), ParallelMesh::not_active_elements_end(), ParallelMesh::not_ancestor_elements_begin(), ParallelMesh::not_ancestor_elements_end(), ParallelMesh::not_level_elements_begin(), ParallelMesh::not_level_elements_end(), ParallelMesh::not_local_elements_begin(), ParallelMesh::not_local_elements_end(), ParallelMesh::not_subactive_elements_begin(), ParallelMesh::not_subactive_elements_end(), ParallelMesh::parallel_max_elem_id(), ParallelMesh::pid_elements_begin(), ParallelMesh::pid_elements_end(), ParallelMesh::renumber_elem(), ParallelMesh::renumber_nodes_and_elements(), ParallelMesh::subactive_elements_begin(), ParallelMesh::subactive_elements_end(), ParallelMesh::type_elements_begin(), ParallelMesh::type_elements_end(), and ParallelMesh::update_parallel_id_counts().
Definition at line 717 of file mesh_base.h.
Referenced by UnstructuredMesh::all_first_order(), UnstructuredMesh::all_second_order(), MeshBase::clear(), UnstructuredMesh::copy_nodes_and_elements(), MeshBase::is_prepared(), and MeshBase::prepare_for_use().
Definition at line 380 of file parallel_mesh.h.
Referenced by ParallelMesh::allgather(), ParallelMesh::clear(), ParallelMesh::delete_remote_elements(), and ParallelMesh::is_serial().
Definition at line 385 of file parallel_mesh.h.
Referenced by ParallelMesh::add_elem(), ParallelMesh::clear(), ParallelMesh::max_elem_id(), ParallelMesh::ParallelMesh(), ParallelMesh::renumber_nodes_and_elements(), and ParallelMesh::update_parallel_id_counts().
Definition at line 385 of file parallel_mesh.h.
Referenced by ParallelMesh::add_node(), ParallelMesh::clear(), ParallelMesh::max_node_id(), ParallelMesh::ParallelMesh(), ParallelMesh::renumber_nodes_and_elements(), and ParallelMesh::update_parallel_id_counts().
Definition at line 385 of file parallel_mesh.h.
Referenced by ParallelMesh::add_elem(), ParallelMesh::clear(), ParallelMesh::n_elem(), ParallelMesh::ParallelMesh(), ParallelMesh::renumber_nodes_and_elements(), and ParallelMesh::update_parallel_id_counts().
Definition at line 385 of file parallel_mesh.h.
Referenced by ParallelMesh::add_node(), ParallelMesh::clear(), ParallelMesh::n_nodes(), ParallelMesh::ParallelMesh(), ParallelMesh::renumber_nodes_and_elements(), and ParallelMesh::update_parallel_id_counts().
Definition at line 707 of file mesh_base.h.
Referenced by MeshBase::clear(), UnstructuredMesh::copy_nodes_and_elements(), MeshBase::n_partitions(), MeshBase::recalculate_n_partitions(), and MeshBase::set_n_partitions().
Definition at line 696 of file mesh_base.h.
Referenced by MeshBase::clear(), UnstructuredMesh::copy_nodes_and_elements(), MeshBase::n_subdomains(), and MeshBase::set_n_subdomains().
Definition at line 391 of file parallel_mesh.h.
Referenced by ParallelMesh::add_elem(), ParallelMesh::clear(), and ParallelMesh::renumber_nodes_and_elements().
Definition at line 391 of file parallel_mesh.h.
Referenced by ParallelMesh::add_node(), ParallelMesh::clear(), and ParallelMesh::renumber_nodes_and_elements().
Definition at line 393 of file parallel_mesh.h.
Referenced by ParallelMesh::add_elem(), ParallelMesh::clear(), and ParallelMesh::renumber_nodes_and_elements().
Definition at line 393 of file parallel_mesh.h.
Referenced by ParallelMesh::add_node(), ParallelMesh::clear(), and ParallelMesh::renumber_nodes_and_elements().
Definition at line 370 of file parallel_mesh.h.
Referenced by ParallelMesh::active_nodes_begin(), ParallelMesh::active_nodes_end(), ParallelMesh::add_node(), ParallelMesh::add_point(), ParallelMesh::clear(), ParallelMesh::delete_node(), MeshTools::Private::fix_broken_node_and_element_numbering(), ParallelMesh::insert_node(), ParallelMesh::libmesh_assert_valid_parallel_ids(), ParallelMesh::local_nodes_begin(), ParallelMesh::local_nodes_end(), ParallelMesh::node(), ParallelMesh::node_ptr(), ParallelMesh::nodes_begin(), ParallelMesh::nodes_end(), ParallelMesh::parallel_max_node_id(), ParallelMesh::pid_nodes_begin(), ParallelMesh::pid_nodes_end(), ParallelMesh::point(), ParallelMesh::renumber_node(), ParallelMesh::renumber_nodes_and_elements(), and ParallelMesh::update_parallel_id_counts().
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 734 of file mesh_base.h.
Referenced by ParallelMesh::ParallelMesh(), MeshBase::partitioner(), and SerialMesh::SerialMesh().
Definition at line 726 of file mesh_base.h.
Referenced by MeshBase::clear_point_locator(), and MeshBase::point_locator().
Definition at line 98 of file mesh_base.h.
Referenced by MeshRefinement::_coarsen_elements(), UnstructuredMesh::all_first_order(), UnstructuredMesh::all_second_order(), MeshTools::Modification::all_tri(), MeshCommunication::allgather(), MeshCommunication::broadcast(), MeshTools::Generation::build_cube(), MeshTools::Generation::build_delaunay_square(), MeshTools::Modification::change_boundary_id(), MeshBase::clear(), FEBase::compute_periodic_constraints(), UnstructuredMesh::create_submesh(), SerialMesh::delete_elem(), ParallelMesh::delete_elem(), SerialMesh::delete_node(), ParallelMesh::delete_node(), MeshTools::Modification::flatten(), ExodusII_IO_Helper::initialize(), ExodusII_IO::read(), LegacyXdrIO::read_mesh(), GmshIO::read_mesh(), SerialMesh::renumber_nodes_and_elements(), ParallelMesh::renumber_nodes_and_elements(), XdrIO::write(), FroIO::write(), LegacyXdrIO::write_mesh(), ExodusII_IO_Helper::write_nodesets(), XdrIO::write_serialized_bcs(), ExodusII_IO_Helper::write_sidesets(), LegacyXdrIO::write_soln(), and DivaIO::write_stream().
Generated automatically by Doxygen for libMesh from the source code.