namespace Generation
namespace Modification
namespace Private
unsigned int total_weight (const MeshBase &mesh)
unsigned int weight (const MeshBase &mesh, const unsigned int pid=libMesh::processor_id())
void build_nodes_to_elem_map (const MeshBase &mesh, std::vector< std::vector< unsigned int > > &nodes_to_elem_map)
void build_nodes_to_elem_map (const MeshBase &mesh, std::vector< std::vector< const Elem * > > &nodes_to_elem_map)
void find_boundary_nodes (const MeshBase &mesh, std::vector< bool > &on_boundary)
BoundingBox bounding_box (const MeshBase &mesh)
Sphere bounding_sphere (const MeshBase &mesh)
BoundingBox processor_bounding_box (const MeshBase &mesh, const unsigned int pid)
Sphere processor_bounding_sphere (const MeshBase &mesh, const unsigned int pid)
BoundingBox subdomain_bounding_box (const MeshBase &mesh, const subdomain_id_type sid)
Sphere subdomain_bounding_sphere (const MeshBase &mesh, const subdomain_id_type sid)
void elem_types (const MeshBase &mesh, std::vector< ElemType > &et)
unsigned int n_elem_of_type (const MeshBase &mesh, const ElemType type)
unsigned int n_active_elem_of_type (const MeshBase &mesh, const ElemType type)
unsigned int n_non_subactive_elem_of_type_at_level (const MeshBase &mesh, const ElemType type, const unsigned int level)
unsigned int n_levels (const MeshBase &mesh)
unsigned int n_local_levels (const MeshBase &mesh)
unsigned int n_active_levels (const MeshBase &mesh)
unsigned int n_active_local_levels (const MeshBase &mesh)
unsigned int n_p_levels (const MeshBase &mesh)
void get_not_subactive_node_ids (const MeshBase &mesh, std::set< unsigned int > ¬_subactive_node_ids)
unsigned int n_elem (const MeshBase::const_element_iterator &begin, const MeshBase::const_element_iterator &end)
unsigned int n_nodes (const MeshBase::const_node_iterator &begin, const MeshBase::const_node_iterator &end)
unsigned int max_level (const MeshBase &mesh)
void find_nodal_neighbors (const MeshBase &mesh, const Node &n, std::vector< std::vector< const Elem * > > &nodes_to_elem_map, std::vector< const Node * > &neighbors)
void find_hanging_nodes_and_parents (const MeshBase &mesh, std::map< unsigned int, std::vector< unsigned int > > &hanging_nodes)
void correct_node_proc_ids (MeshBase &, LocationMap< Node > &)
void libmesh_assert_no_links_to_elem (const MeshBase &mesh, const Elem *bad_elem)
void libmesh_assert_valid_node_pointers (const MeshBase &mesh)
void libmesh_assert_valid_remote_elems (const MeshBase &mesh)
void libmesh_assert_valid_elem_ids (const MeshBase &mesh)
void libmesh_assert_valid_node_procids (const MeshBase &mesh)
void libmesh_assert_valid_refinement_flags (const MeshBase &mesh)
void libmesh_assert_valid_neighbors (const MeshBase &mesh)
Utility functions for operations on a Mesh object. Here is where useful functions for interfacing with a Mesh should be defined. In general this namespace should be used to prevent the Mesh class from becoming too cluttered.
Author:
Date:
Version:
Revision:
Add the triangulation routines to the MeshTools::Generation namespace.
Definition at line 273 of file mesh_tools.C.
References DofObject::invalid_processor_id, MeshBase::local_nodes_begin(), MeshBase::local_nodes_end(), std::max(), std::min(), Threads::parallel_reduce(), MeshBase::pid_nodes_begin(), and MeshBase::pid_nodes_end().
Referenced by MetisPartitioner::_do_partition(), MeshCommunication::assign_global_indices(), bounding_sphere(), TreeNode< N >::bounds_point(), InfElemBuilder::build_inf_elem(), TreeNode< N >::create_bounding_box(), PointLocatorTree::init(), ParmetisPartitioner::initialize(), TreeNode< N >::insert(), Partitioner::partition_unpartitioned_elements(), TreeNode< N >::set_bounding_box(), Tree< N >::Tree(), and PostscriptIO::write().
{
// This function must be run on all processors at once
parallel_only();
FindBBox find_bbox;
Threads::parallel_reduce (ConstNodeRange (mesh.local_nodes_begin(),
mesh.local_nodes_end()),
find_bbox);
// and the unpartitioned nodes
Threads::parallel_reduce (ConstNodeRange (mesh.pid_nodes_begin(DofObject::invalid_processor_id),
mesh.pid_nodes_end(DofObject::invalid_processor_id)),
find_bbox);
// Compare the bounding boxes across processors
Parallel::min(find_bbox.min());
Parallel::max(find_bbox.max());
return find_bbox.bbox();
}
Definition at line 299 of file mesh_tools.C.
References bounding_box().
{
BoundingBox bbox = bounding_box(mesh);
const Real diag = (bbox.second - bbox.first).size();
const Point cent = (bbox.second + bbox.first)/2.;
return Sphere (cent, .5*diag);
}
Definition at line 226 of file mesh_tools.C.
References MeshBase::elements_begin(), MeshBase::elements_end(), and MeshBase::n_nodes().
{
nodes_to_elem_map.resize (mesh.n_nodes());
MeshBase::const_element_iterator el = mesh.elements_begin();
const MeshBase::const_element_iterator end = mesh.elements_end();
for (; el != end; ++el)
for (unsigned int n=0; n<(*el)->n_nodes(); n++)
{
libmesh_assert ((*el)->node(n) < nodes_to_elem_map.size());
nodes_to_elem_map[(*el)->node(n)].push_back(*el);
}
}
Definition at line 206 of file mesh_tools.C.
References MeshBase::elements_begin(), MeshBase::elements_end(), MeshBase::n_elem(), and MeshBase::n_nodes().
Referenced by VariationalMeshSmoother::readgr(), and Tree< N >::Tree().
{
nodes_to_elem_map.resize (mesh.n_nodes());
MeshBase::const_element_iterator el = mesh.elements_begin();
const MeshBase::const_element_iterator end = mesh.elements_end();
for (; el != end; ++el)
for (unsigned int n=0; n<(*el)->n_nodes(); n++)
{
libmesh_assert ((*el)->node(n) < nodes_to_elem_map.size());
libmesh_assert ((*el)->id() < mesh.n_elem());
nodes_to_elem_map[(*el)->node(n)].push_back((*el)->id());
}
}
This corrects 'orphaned' processor ids that may occur from element coarsening.
On a distributed mesh, this function must be called in parallel to sync everyone's corrected processor ids on ghost nodes.
Definition at line 746 of file mesh_tools.C.
References MeshBase::active_elements_begin(), MeshBase::active_elements_end(), LocationMap< T >::empty(), Elem::get_node(), DofObject::invalid_processor_id, DofObject::invalidate_processor_id(), MeshCommunication::make_node_proc_ids_parallel_consistent(), Elem::n_nodes(), MeshBase::nodes_begin(), MeshBase::nodes_end(), and DofObject::processor_id().
Referenced by MeshCommunication::make_nodes_parallel_consistent().
{
// This function must be run on all processors at once
parallel_only();
// We'll need the new_nodes_map to answer other processors'
// requests. It should never be empty unless we don't have any
// nodes.
libmesh_assert(mesh.nodes_begin() == mesh.nodes_end() ||
!loc_map.empty());
// Fix all nodes' processor ids. Coarsening may have left us with
// nodes which are no longer touched by any elements of the same
// processor id, and for DofMap to work we need to fix that.
// In the first pass, invalidate processor ids for nodes on active
// elements. We avoid touching subactive-only nodes.
MeshBase::element_iterator e_it = mesh.active_elements_begin();
const MeshBase::element_iterator e_end = mesh.active_elements_end();
for (; e_it != e_end; ++e_it)
{
Elem *elem = *e_it;
for (unsigned int n=0; n != elem->n_nodes(); ++n)
{
Node *node = elem->get_node(n);
node->invalidate_processor_id();
}
}
// In the second pass, find the lowest processor ids on active
// elements touching each node, and set the node processor id.
for (e_it = mesh.active_elements_begin(); e_it != e_end; ++e_it)
{
Elem *elem = *e_it;
unsigned int proc_id = elem->processor_id();
for (unsigned int n=0; n != elem->n_nodes(); ++n)
{
Node *node = elem->get_node(n);
if (node->processor_id() == DofObject::invalid_processor_id ||
node->processor_id() > proc_id)
node->processor_id() = proc_id;
}
}
// Those two passes will correct every node that touches a local
// element, but we can't be sure about nodes touching remote
// elements. Fix those now.
MeshCommunication().make_node_proc_ids_parallel_consistent
(mesh, loc_map);
}
Definition at line 379 of file mesh_tools.C.
References MeshBase::elements_begin(), and MeshBase::elements_end().
Referenced by LegacyXdrIO::write_mesh().
{
MeshBase::const_element_iterator el = mesh.elements_begin();
const MeshBase::const_element_iterator end = mesh.elements_end();
// Automatically get the first type
et.push_back((*el)->type()); ++el;
// Loop over the rest of the elements.
// If the current element type isn't in the
// vector, insert it.
for (; el != end; ++el)
if (!std::count(et.begin(), et.end(), (*el)->type()))
et.push_back((*el)->type());
}
Definition at line 245 of file mesh_tools.C.
References MeshBase::active_elements_begin(), MeshBase::active_elements_end(), and MeshBase::n_nodes().
Referenced by MeshTools::Modification::distort(), VariationalMeshSmoother::readgr(), LaplaceMeshSmoother::smooth(), and MeshTools::Modification::smooth().
{
// Resize the vector which holds boundary nodes and fill with false.
on_boundary.resize(mesh.n_nodes());
std::fill(on_boundary.begin(),
on_boundary.end(),
false);
// Loop over elements, find those on boundary, and
// mark them as true in on_boundary.
MeshBase::const_element_iterator el = mesh.active_elements_begin();
const MeshBase::const_element_iterator end = mesh.active_elements_end();
for (; el != end; ++el)
for (unsigned int s=0; s<(*el)->n_neighbors(); s++)
if ((*el)->neighbor(s) == NULL) // on the boundary
{
const AutoPtr<Elem> side((*el)->build_side(s));
for (unsigned int n=0; n<side->n_nodes(); n++)
on_boundary[side->node(n)] = true;
}
}
Definition at line 642 of file mesh_tools.C.
References MeshBase::active_local_elements_begin(), MeshBase::active_local_elements_end(), Elem::is_node_on_side(), Elem::level(), Elem::n_sides(), Elem::neighbor(), Elem::node(), Elem::parent(), libMeshEnums::QUAD4, Elem::type(), and Elem::which_neighbor_am_i().
Referenced by VariationalMeshSmoother::smooth().
{
MeshBase::const_element_iterator it = mesh.active_local_elements_begin();
const MeshBase::const_element_iterator end = mesh.active_local_elements_end();
//Loop through all the elements
for (; it != end; ++it)
{
//Save it off for easier access
const Elem* elem = (*it);
//Right now this only works for quad4's
//libmesh_assert(elem->type() == libMeshEnums::QUAD4);
if(elem->type() == libMeshEnums::QUAD4)
{
//Loop over the sides looking for sides that have hanging nodes
//This code is inspired by compute_proj_constraints()
for (unsigned int s=0; s<elem->n_sides(); s++)
{
//If not a boundary node
if (elem->neighbor(s) != NULL)
{
// Get pointers to the element's neighbor.
const Elem* neigh = elem->neighbor(s);
//Is there a coarser element next to this one?
if (neigh->level() < elem->level())
{
const Elem *ancestor = elem;
while (neigh->level() < ancestor->level())
ancestor = ancestor->parent();
unsigned int s_neigh = neigh->which_neighbor_am_i(ancestor);
libmesh_assert (s_neigh < neigh->n_neighbors());
//Couple of helper uints...
unsigned int node1=0;
unsigned int node2=0;
unsigned int hanging_node=0;
bool found_in_neighbor = false;
//Find the two vertices that make up this side
while(!elem->is_node_on_side(node1++,s)) { }
node1--;
//Start looking for the second one with the next node
node2=node1+1;
//Find the other one
while(!elem->is_node_on_side(node2++,s)) { }
node2--;
//Pull out their global ids:
node1 = elem->node(node1);
node2 = elem->node(node2);
//Now find which node is present in the neighbor
//FIXME This assumes a level one rule!
//The _other_ one is the hanging node
//First look for the first one
//FIXME could be streamlined a bit
for(unsigned int n=0;n<neigh->n_sides();n++)
{
if(neigh->node(n) == node1)
found_in_neighbor=true;
}
if(!found_in_neighbor)
hanging_node=node1;
else //If it wasn't node1 then it must be node2!
hanging_node=node2;
//Reset these for reuse
node1=0;
node2=0;
//Find the first node that makes up the side in the neighbor (these should be the parent nodes)
while(!neigh->is_node_on_side(node1++,s_neigh)) { }
node1--;
node2=node1+1;
//Find the second node...
while(!neigh->is_node_on_side(node2++,s_neigh)) { }
node2--;
//Save them if we haven't already found the parents for this one
if(hanging_nodes[hanging_node].size()<2)
{
hanging_nodes[hanging_node].push_back(neigh->node(node1));
hanging_nodes[hanging_node].push_back(neigh->node(node2));
}
}
}
}
}
}
}
Definition at line 561 of file mesh_tools.C.
References DofObject::id().
Referenced by VariationalMeshSmoother::readgr().
{
unsigned int global_id = n.id();
//Iterators to iterate through the elements that include this node
std::vector<const Elem*>::const_iterator el = nodes_to_elem_map[global_id].begin();
std::vector<const Elem*>::const_iterator end_el = nodes_to_elem_map[global_id].end();
unsigned int n_ed=0; // Number of edges on the element
unsigned int ed=0; // Current edge
unsigned int l_n=0; // Local node number
unsigned int o_n=0; // Other node on this edge
//Assume we find a edge... then prove ourselves wrong...
bool found_edge=true;
Node * node_to_save = NULL;
//Look through the elements that contain this node
//find the local node id... then find the side that
//node lives on in the element
//next, look for the _other_ node on that side
//That other node is a 'nodal_neighbor'... save it
for(;el != end_el;el++)
{
//We only care about active elements...
if((*el)->active())
{
n_ed=(*el)->n_edges();
//Find the local node id
while(global_id != (*el)->node(l_n++)) { }
l_n--; //Hmmm... take the last one back off
while(ed<n_ed)
{
//Find the edge the node is on
while(found_edge && !(*el)->is_node_on_edge(l_n,ed++))
{
//This only happens if all the edges have already been found
if(ed>=n_ed)
found_edge=false;
}
//Did we find one?
if(found_edge)
{
ed--; //Take the last one back off again
//Now find the other node on that edge
while(!(*el)->is_node_on_edge(o_n++,ed) || global_id==(*el)->node(o_n-1)) { }
o_n--;
//We've found one! Save it..
node_to_save=(*el)->get_node(o_n);
//Search to see if we've already found this one
std::vector<const Node*>::const_iterator result = std::find(neighbors.begin(),neighbors.end(),node_to_save);
//If we didn't find it and add it to the vector
if(result == neighbors.end())
neighbors.push_back(node_to_save);
}
//Reset to look for another
o_n=0;
//Keep looking for edges, node may be on more than one edge
ed++;
}
//Reset to get ready for the next element
l_n=ed=0;
found_edge=true;
}
}
}
Definition at line 502 of file mesh_tools.C.
References MeshBase::elements_begin(), MeshBase::elements_end(), Elem::n_nodes(), Elem::node(), and Elem::subactive().
{
MeshBase::const_element_iterator el = mesh.elements_begin();
const MeshBase::const_element_iterator end_el = mesh.elements_end();
for( ; el != end_el; ++el)
{
Elem* elem = (*el);
if(!elem->subactive())
for (unsigned int n=0; n<elem->n_nodes(); ++n)
not_subactive_node_ids.insert(elem->node(n));
}
}
Definition at line 849 of file mesh_tools.C.
References Elem::child(), MeshBase::elements_begin(), MeshBase::elements_end(), Elem::has_children(), Elem::n_children(), Elem::n_neighbors(), Elem::neighbor(), and Elem::parent().
{
const MeshBase::const_element_iterator el_end =
mesh.elements_end();
for (MeshBase::const_element_iterator el =
mesh.elements_begin(); el != el_end; ++el)
{
const Elem* elem = *el;
libmesh_assert (elem);
libmesh_assert (elem->parent() != bad_elem);
for (unsigned int n=0; n != elem->n_neighbors(); ++n)
libmesh_assert(elem->neighbor(n) != bad_elem);
#ifdef LIBMESH_ENABLE_AMR
if (elem->has_children())
for (unsigned int c=0; c != elem->n_children(); ++c)
libmesh_assert(elem->child(c) != bad_elem);
#endif
}
}
Definition at line 872 of file mesh_tools.C.
References MeshBase::active_elements_begin(), MeshBase::active_elements_end(), DofObject::id(), and DofObject::processor_id().
Referenced by ParallelMesh::delete_remote_elements(), and ParallelMesh::renumber_nodes_and_elements().
{
unsigned int lastprocid = 0;
unsigned int lastelemid = 0;
const MeshBase::const_element_iterator el_end =
mesh.active_elements_end();
for (MeshBase::const_element_iterator el =
mesh.active_elements_begin(); el != el_end; ++el)
{
const Elem* elem = *el;
libmesh_assert (elem);
unsigned int elemprocid = elem->processor_id();
unsigned int elemid = elem->id();
libmesh_assert(elemid >= lastelemid);
libmesh_assert(elemprocid >= lastprocid);
lastelemid = elemid;
lastprocid = elemprocid;
}
}
Definition at line 986 of file mesh_tools.C.
References MeshBase::elements_begin(), MeshBase::elements_end(), and Elem::libmesh_assert_valid_neighbors().
Referenced by ParallelMesh::allgather(), ParallelMesh::delete_remote_elements(), and UnstructuredMesh::find_neighbors().
{
const MeshBase::const_element_iterator el_end = mesh.elements_end();
for (MeshBase::const_element_iterator el = mesh.elements_begin();
el != el_end; ++el)
{
const Elem* elem = *el;
libmesh_assert (elem);
elem->libmesh_assert_valid_neighbors();
}
}
Definition at line 801 of file mesh_tools.C.
References MeshBase::elements_begin(), MeshBase::elements_end(), Elem::libmesh_assert_valid_node_pointers(), Elem::n_neighbors(), Elem::neighbor(), Elem::parent(), and remote_elem.
{
const MeshBase::const_element_iterator el_end =
mesh.elements_end();
for (MeshBase::const_element_iterator el =
mesh.elements_begin(); el != el_end; ++el)
{
const Elem* elem = *el;
libmesh_assert (elem);
while (elem)
{
elem->libmesh_assert_valid_node_pointers();
for (unsigned int n=0; n != elem->n_neighbors(); ++n)
if (elem->neighbor(n) &&
elem->neighbor(n) != remote_elem)
elem->neighbor(n)->libmesh_assert_valid_node_pointers();
libmesh_assert (elem->parent() != remote_elem);
elem = elem->parent();
}
}
}
Definition at line 897 of file mesh_tools.C.
References MeshBase::active_local_elements_begin(), MeshBase::active_local_elements_end(), Elem::get_node(), DofObject::id(), MeshBase::local_nodes_begin(), MeshBase::local_nodes_end(), std::max(), MeshBase::max_node_id(), Elem::n_nodes(), and libMesh::n_processors().
Referenced by MeshRefinement::_coarsen_elements(), DofMap::distribute_local_dofs_node_major(), and DofMap::distribute_local_dofs_var_major().
{
parallel_only();
if (libMesh::n_processors() == 1)
return;
libmesh_assert(Parallel::verify(mesh.max_node_id()));
std::vector<bool> node_touched_by_me(mesh.max_node_id(), false);
const MeshBase::const_element_iterator el_end =
mesh.active_local_elements_end();
for (MeshBase::const_element_iterator el =
mesh.active_local_elements_begin(); el != el_end; ++el)
{
const Elem* elem = *el;
libmesh_assert (elem);
for (unsigned int i=0; i != elem->n_nodes(); ++i)
{
const Node *node = elem->get_node(i);
unsigned int nodeid = node->id();
node_touched_by_me[nodeid] = true;
}
}
std::vector<bool> node_touched_by_anyone(node_touched_by_me);
Parallel::max(node_touched_by_anyone);
const MeshBase::const_node_iterator nd_end = mesh.local_nodes_end();
for (MeshBase::const_node_iterator nd = mesh.local_nodes_begin();
nd != nd_end; ++nd)
{
const Node *node = *nd;
libmesh_assert(node);
unsigned int nodeid = node->id();
libmesh_assert(!node_touched_by_anyone[nodeid] ||
node_touched_by_me[nodeid]);
}
}
Definition at line 940 of file mesh_tools.C.
References MeshBase::elements_begin(), MeshBase::elements_end(), DofObject::id(), MeshBase::max_elem_id(), std::min(), libMesh::n_processors(), Elem::p_refinement_flag(), and Elem::refinement_flag().
{
parallel_only();
if (libMesh::n_processors() == 1)
return;
std::vector<unsigned char> my_elem_h_state(mesh.max_elem_id(), 255);
std::vector<unsigned char> my_elem_p_state(mesh.max_elem_id(), 255);
const MeshBase::const_element_iterator el_end =
mesh.elements_end();
for (MeshBase::const_element_iterator el =
mesh.elements_begin(); el != el_end; ++el)
{
const Elem* elem = *el;
libmesh_assert (elem);
unsigned int elemid = elem->id();
my_elem_h_state[elemid] =
static_cast<unsigned char>(elem->refinement_flag());
my_elem_p_state[elemid] =
static_cast<unsigned char>(elem->p_refinement_flag());
}
std::vector<unsigned char> min_elem_h_state(my_elem_h_state);
Parallel::min(min_elem_h_state);
std::vector<unsigned char> min_elem_p_state(my_elem_p_state);
Parallel::min(min_elem_p_state);
for (unsigned int i=0; i!= mesh.max_elem_id(); ++i)
{
libmesh_assert(my_elem_h_state[i] == 255 ||
my_elem_h_state[i] == min_elem_h_state[i]);
libmesh_assert(my_elem_p_state[i] == 255 ||
my_elem_p_state[i] == min_elem_p_state[i]);
}
}
Definition at line 825 of file mesh_tools.C.
References Elem::child(), MeshBase::local_elements_begin(), MeshBase::local_elements_end(), Elem::n_children(), Elem::n_neighbors(), Elem::neighbor(), Elem::parent(), and remote_elem.
{
const MeshBase::const_element_iterator el_end =
mesh.local_elements_end();
for (MeshBase::const_element_iterator el =
mesh.local_elements_begin(); el != el_end; ++el)
{
const Elem* elem = *el;
libmesh_assert (elem);
for (unsigned int n=0; n != elem->n_neighbors(); ++n)
libmesh_assert (elem->neighbor(n) != remote_elem);
#ifdef LIBMESH_ENABLE_AMR
const Elem* parent = elem->parent();
if (parent)
{
libmesh_assert (parent != remote_elem);
for (unsigned int c=0; c != elem->n_children(); ++c)
libmesh_assert (parent->child(c) != remote_elem);
}
#endif
}
}
Referenced by MeshRefinement::make_coarsening_compatible(), n_active_local_levels(), and n_local_levels().
Definition at line 407 of file mesh_tools.C.
References MeshBase::active_type_elements_begin(), and MeshBase::active_type_elements_end().
Referenced by DivaIO::write_stream().
{
return static_cast<unsigned int>(std::distance(mesh.active_type_elements_begin(type),
mesh.active_type_elements_end (type)));
}
Definition at line 446 of file mesh_tools.C.
References std::max(), n_active_local_levels(), MeshBase::unpartitioned_elements_begin(), and MeshBase::unpartitioned_elements_end().
Referenced by XdrIO::write_serialized_connectivity().
{
parallel_only();
unsigned int nl = MeshTools::n_active_local_levels(mesh);
MeshBase::const_element_iterator el =
mesh.unpartitioned_elements_begin();
const MeshBase::const_element_iterator end_el =
mesh.unpartitioned_elements_end();
for( ; el != end_el; ++el)
if ((*el)->active())
nl = std::max((*el)->level() + 1, nl);
Parallel::max(nl);
return nl;
}
Definition at line 431 of file mesh_tools.C.
References MeshBase::active_local_elements_begin(), MeshBase::active_local_elements_end(), std::max(), and max_level().
Referenced by n_active_levels().
{
unsigned int max_level = 0;
MeshBase::const_element_iterator el = mesh.active_local_elements_begin();
const MeshBase::const_element_iterator end_el = mesh.active_local_elements_end();
for( ; el != end_el; ++el)
max_level = std::max((*el)->level(), max_level);
return max_level + 1;
}
Definition at line 518 of file mesh_tools.C.
Referenced by SFCPartitioner::_do_partition(), CentroidPartitioner::_do_partition(), Partitioner::partition_unpartitioned_elements(), XdrIO::read(), XdrIO::read_serialized_connectivity(), System::read_serialized_vector(), MeshData::read_tetgen(), MeshData::read_xdr(), Partitioner::set_node_processor_ids(), Partitioner::set_parent_processor_ids(), XdrIO::write(), XdrIO::write_serialized_connectivity(), System::write_serialized_vector(), and MeshData::write_xdr().
{
return std::distance(begin, end);
}
Definition at line 398 of file mesh_tools.C.
References MeshBase::type_elements_begin(), and MeshBase::type_elements_end().
{
return static_cast<unsigned int>(std::distance(mesh.type_elements_begin(type),
mesh.type_elements_end (type)));
}
Definition at line 482 of file mesh_tools.C.
References std::max(), n_local_levels(), MeshBase::unpartitioned_elements_begin(), and MeshBase::unpartitioned_elements_end().
Referenced by MeshCommunication::delete_remote_elements(), UnstructuredMesh::find_neighbors(), LegacyXdrIO::read_mesh(), MeshTools::Modification::smooth(), and LegacyXdrIO::write_mesh().
{
parallel_only();
unsigned int nl = MeshTools::n_local_levels(mesh);
MeshBase::const_element_iterator el =
mesh.unpartitioned_elements_begin();
const MeshBase::const_element_iterator end_el =
mesh.unpartitioned_elements_end();
for( ; el != end_el; ++el)
nl = std::max((*el)->level() + 1, nl);
Parallel::max(nl);
return nl;
}
Definition at line 467 of file mesh_tools.C.
References MeshBase::local_elements_begin(), MeshBase::local_elements_end(), std::max(), and max_level().
Referenced by n_levels().
{
unsigned int max_level = 0;
MeshBase::const_element_iterator el = mesh.local_elements_begin();
const MeshBase::const_element_iterator end_el = mesh.local_elements_end();
for( ; el != end_el; ++el)
max_level = std::max((*el)->level(), max_level);
return max_level + 1;
}
Definition at line 526 of file mesh_tools.C.
Referenced by FEBase::coarsened_dof_values(), InfFE< Dim, T_radial, T_map >::compute_node_indices_fast(), DofMap::constrain_p_dofs(), DofMap::distribute_local_dofs_node_major(), DofMap::distribute_local_dofs_var_major(), DofMap::dof_indices(), FE< Dim, T >::dofs_on_edge(), FE< Dim, T >::dofs_on_side(), FEMContext::elem_position_get(), FEMContext::elem_position_set(), UNVIO::element_in(), TetGenIO::element_in(), SideEdge< EdgeType, ParentType >::get_node(), Side< SideType, ParentType >::get_node(), FE< Dim, T >::nodal_soln(), SideEdge< EdgeType, ParentType >::node(), Side< SideType, ParentType >::node(), DofMap::old_dof_indices(), System::ProjectVector::operator()(), SideEdge< EdgeType, ParentType >::point(), Side< SideType, ParentType >::point(), XdrIO::read(), XdrIO::read_serialized_nodes(), System::read_serialized_vector(), MeshData::read_tetgen(), HPCoarsenTest::select_refinement(), SideEdge< EdgeType, ParentType >::set_node(), Side< SideType, ParentType >::set_node(), VTKIO::solution_to_vtk(), XdrIO::write(), XdrIO::write_serialized_connectivity(), XdrIO::write_serialized_nodes(), and System::write_serialized_vector().
{
return std::distance(begin, end);
}
TODO: Replace all of the n_xxx_elem() functions like this with a single function which takes a range of iterators and returns the std::distance between them.
Definition at line 414 of file mesh_tools.C.
References MeshBase::type_elements_begin(), and MeshBase::type_elements_end().
Referenced by LegacyXdrIO::write_mesh().
{
unsigned int cnt = 0;
// iterate over the elements of the specified type
MeshBase::const_element_iterator el = mesh.type_elements_begin(type);
const MeshBase::const_element_iterator end = mesh.type_elements_end(type);
for(; el!=end; ++el)
if( ((*el)->level() == level) && !(*el)->subactive())
cnt++;
return cnt;
}
Definition at line 534 of file mesh_tools.C.
References MeshBase::local_elements_begin(), MeshBase::local_elements_end(), std::max(), MeshBase::unpartitioned_elements_begin(), and MeshBase::unpartitioned_elements_end().
Referenced by XdrIO::write().
{
parallel_only();
unsigned int max_p_level = 0;
// first my local elements
MeshBase::const_element_iterator
el = mesh.local_elements_begin(),
end_el = mesh.local_elements_end();
for( ; el != end_el; ++el)
max_p_level = std::max((*el)->p_level(), max_p_level);
// then any unpartitioned objects
el = mesh.unpartitioned_elements_begin();
end_el = mesh.unpartitioned_elements_end();
for( ; el != end_el; ++el)
max_p_level = std::max((*el)->p_level(), max_p_level);
Parallel::max(max_p_level);
return max_p_level + 1;
}
Definition at line 312 of file mesh_tools.C.
References libMesh::n_processors(), Threads::parallel_reduce(), MeshBase::pid_elements_begin(), and MeshBase::pid_elements_end().
Referenced by processor_bounding_sphere().
{
libmesh_assert (pid < libMesh::n_processors());
FindBBox find_bbox;
Threads::parallel_reduce (ConstElemRange (mesh.pid_elements_begin(pid),
mesh.pid_elements_end(pid)),
find_bbox);
return find_bbox.bbox();
}
Definition at line 329 of file mesh_tools.C.
References processor_bounding_box().
{
BoundingBox bbox = processor_bounding_box(mesh,pid);
const Real diag = (bbox.second - bbox.first).size();
const Point cent = (bbox.second + bbox.first)/2.;
return Sphere (cent, .5*diag);
}
Definition at line 343 of file mesh_tools.C.
References MeshBase::elem(), std::max(), std::min(), MeshBase::n_elem(), Elem::n_nodes(), MeshBase::n_nodes(), Elem::node(), MeshBase::point(), MeshBase::spatial_dimension(), and Elem::subdomain_id().
Referenced by subdomain_bounding_sphere().
{
libmesh_assert (mesh.n_nodes() != 0);
Point min( 1.e30, 1.e30, 1.e30);
Point max(-1.e30, -1.e30, -1.e30);
for (unsigned int e=0; e<mesh.n_elem(); e++)
if (mesh.elem(e)->subdomain_id() == sid)
for (unsigned int n=0; n<mesh.elem(e)->n_nodes(); n++)
for (unsigned int i=0; i<mesh.spatial_dimension(); i++)
{
min(i) = std::min(min(i), mesh.point(mesh.elem(e)->node(n))(i));
max(i) = std::max(max(i), mesh.point(mesh.elem(e)->node(n))(i));
}
return BoundingBox (min, max);
}
Definition at line 366 of file mesh_tools.C.
References subdomain_bounding_box().
{
BoundingBox bbox = subdomain_bounding_box(mesh,sid);
const Real diag = (bbox.second - bbox.first).size();
const Point cent = (bbox.second + bbox.first)/2.;
return Sphere (cent, .5*diag);
}
Definition at line 171 of file mesh_tools.C.
References MeshBase::elements_begin(), MeshBase::elements_end(), DofObject::invalid_processor_id, MeshBase::is_serial(), Threads::parallel_reduce(), libMesh::processor_id(), and weight().
Referenced by LegacyXdrIO::write_mesh().
{
if (!mesh.is_serial())
{
parallel_only();
unsigned int weight = MeshTools::weight (mesh, libMesh::processor_id());
Parallel::sum(weight);
unsigned int unpartitioned_weight =
MeshTools::weight (mesh, DofObject::invalid_processor_id);
return weight + unpartitioned_weight;
}
SumElemWeight sew;
Threads::parallel_reduce (ConstElemRange (mesh.elements_begin(),
mesh.elements_end()),
sew);
return sew.weight();
}
Definition at line 194 of file mesh_tools.C.
References Threads::parallel_reduce(), MeshBase::pid_elements_begin(), and MeshBase::pid_elements_end().
Referenced by QGrundmann_Moller::gm_rule(), InfFE< Dim, T_radial, T_map >::init_shape_functions(), FEXYZ< Dim >::init_shape_functions(), FE< Dim, T >::init_shape_functions(), MeshTools::Modification::smooth(), and total_weight().
{
SumElemWeight sew;
Threads::parallel_reduce (ConstElemRange (mesh.pid_elements_begin(pid),
mesh.pid_elements_end(pid)),
sew);
return sew.weight();
}
Generated automatically by Doxygen for libMesh from the source code.