$extrastylesheet
libMesh::MeshTools Namespace Reference

Namespaces

namespace  Generation
namespace  Modification
namespace  Private
namespace  Subdivision

Classes

class  BoundingBox

Functions

void libmesh_assert_valid_dof_ids (const MeshBase &mesh)
template<>
void libmesh_assert_valid_procids< Elem > (const MeshBase &mesh)
template<>
void libmesh_assert_valid_procids< Node > (const MeshBase &mesh)
dof_id_type total_weight (const MeshBase &mesh)
dof_id_type weight (const MeshBase &mesh, const processor_id_type pid)
dof_id_type weight (const MeshBase &mesh)
void build_nodes_to_elem_map (const MeshBase &mesh, std::vector< std::vector< dof_id_type > > &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 processor_id_type pid)
Sphere processor_bounding_sphere (const MeshBase &mesh, const processor_id_type 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)
dof_id_type n_elem_of_type (const MeshBase &mesh, const ElemType type)
dof_id_type n_active_elem_of_type (const MeshBase &mesh, const ElemType type)
dof_id_type 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< dof_id_type > &not_subactive_node_ids)
dof_id_type n_elem (const MeshBase::const_element_iterator &begin, const MeshBase::const_element_iterator &end)
dof_id_type 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< dof_id_type, std::vector< dof_id_type > > &hanging_nodes)
void correct_node_proc_ids (MeshBase &)
void libmesh_assert_no_links_to_elem (const MeshBase &mesh, const Elem *bad_elem)
void libmesh_assert_equal_n_systems (const MeshBase &mesh)
void libmesh_assert_old_dof_objects (const MeshBase &mesh)
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_amr_elem_ids (const MeshBase &mesh)
void libmesh_assert_connected_nodes (const MeshBase &mesh)
template<typename DofObjectSubclass >
void libmesh_assert_valid_procids (const MeshBase &mesh)
void libmesh_assert_valid_refinement_flags (const MeshBase &mesh)
void libmesh_assert_valid_refinement_tree (const MeshBase &mesh)
void libmesh_assert_valid_neighbors (const MeshBase &mesh)

Detailed Description

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:
Benjamin S. Kirk
Date:
2004

Function Documentation

Returns:
two points defining a cartesian box that bounds the mesh. The first entry in the pair is the mininum, the second is the maximim.

Definition at line 416 of file mesh_tools.C.

References libMesh::ParallelObject::comm(), libMesh::DofObject::invalid_processor_id, libMesh::MeshBase::local_nodes_begin(), libMesh::MeshBase::local_nodes_end(), libMesh::Parallel::Communicator::max(), libMesh::Parallel::Communicator::min(), libMesh::Threads::parallel_reduce(), libMesh::MeshBase::pid_nodes_begin(), and libMesh::MeshBase::pid_nodes_end().

Referenced by libMesh::MetisPartitioner::_do_partition(), libMesh::MeshCommunication::assign_global_indices(), bounding_sphere(), libMesh::TreeNode< N >::bounds_point(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::TreeNode< N >::create_bounding_box(), libMesh::PointLocatorTree::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::TreeNode< N >::insert(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::TreeNode< N >::set_bounding_box(), libMesh::Tree< N >::Tree(), and libMesh::PostscriptIO::write().

{
  // This function must be run on all processors at once
  libmesh_parallel_only(mesh.comm());

  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
  mesh.comm().min(find_bbox.min());
  mesh.comm().max(find_bbox.max());

  return find_bbox.bbox();
}

Same, but returns a sphere instead of a box.

Definition at line 442 of file mesh_tools.C.

References bounding_box(), and libMesh::Real.

{
  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);
}
void libMesh::MeshTools::build_nodes_to_elem_map ( const MeshBase mesh,
std::vector< std::vector< dof_id_type > > &  nodes_to_elem_map 
)

After calling this function the input vector nodes_to_elem_map will contain the node to element connectivity. That is to say nodes_to_elem_map[i][j] is the global number of $ j^{th} $ element connected to node i.

Definition at line 349 of file mesh_tools.C.

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

Referenced by libMesh::MeshTools::Subdivision::prepare_subdivision_mesh(), libMesh::VariationalMeshSmoother::readgr(), and libMesh::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_less ((*el)->node(n), nodes_to_elem_map.size());
        libmesh_assert_less ((*el)->id(), mesh.n_elem());

        nodes_to_elem_map[(*el)->node(n)].push_back((*el)->id());
      }
}
void libMesh::MeshTools::build_nodes_to_elem_map ( const MeshBase mesh,
std::vector< std::vector< const Elem * > > &  nodes_to_elem_map 
)

The same, except element pointers are returned instead of indices.

Definition at line 369 of file mesh_tools.C.

References libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), end, and libMesh::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_less ((*el)->node(n), nodes_to_elem_map.size());

        nodes_to_elem_map[(*el)->node(n)].push_back(*el);
      }
}

Changes the processor ids on each node so be the same as the id of the lowest element touching that node.

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 889 of file mesh_tools.C.

References libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), libMesh::ParallelObject::comm(), libMesh::Elem::get_node(), libMesh::DofObject::invalid_processor_id, libMesh::DofObject::invalidate_processor_id(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::Elem::n_nodes(), and libMesh::DofObject::processor_id().

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

{
  // This function must be run on all processors at once
  libmesh_parallel_only(mesh.comm());

  // 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;
      processor_id_type 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);
}
void libMesh::MeshTools::elem_types ( const MeshBase mesh,
std::vector< ElemType > &  et 
)

Return a vector of all element types for the mesh. Implemented in terms of element_iterators.

Definition at line 522 of file mesh_tools.C.

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

Referenced by libMesh::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());
}
void libMesh::MeshTools::find_boundary_nodes ( const MeshBase mesh,
std::vector< bool > &  on_boundary 
)

Calling this function on a 2D mesh will convert all the elements to triangles. QUAD4s will be converted to TRI3s, QUAD8s and QUAD9s will be converted to TRI6s. Fills the vector "on_boundary" with flags that tell whether each node is on the domain boundary (true)) or not (false).

Definition at line 388 of file mesh_tools.C.

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

Referenced by libMesh::MeshTools::Modification::distort(), libMesh::VariationalMeshSmoother::readgr(), libMesh::LaplaceMeshSmoother::smooth(), and libMesh::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 UniquePtr<Elem> side((*el)->build_side(s));

          for (unsigned int n=0; n<side->n_nodes(); n++)
            on_boundary[side->node(n)] = true;
        }
}
void libMesh::MeshTools::find_hanging_nodes_and_parents ( const MeshBase mesh,
std::map< dof_id_type, std::vector< dof_id_type > > &  hanging_nodes 
)

Given a mesh hanging_nodes will be filled with an associative array keyed off the global id of all the hanging nodes in the mesh. It will hold an array of the parents of the node (meaning the two nodes to either side of it that make up the side the hanging node is on.

Definition at line 786 of file mesh_tools.C.

References libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), end, libMesh::Elem::is_node_on_side(), libMesh::Elem::level(), libMesh::Elem::n_neighbors(), libMesh::Elem::n_sides(), libMesh::Elem::neighbor(), libMesh::Elem::node(), libMesh::Elem::parent(), libMesh::QUAD4, libMesh::Elem::type(), and libMesh::Elem::which_neighbor_am_i().

Referenced by libMesh::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_equal_to (elem->type(), QUAD4);
      if(elem->type() == 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_less (s_neigh, neigh->n_neighbors());

                      //Couple of helper uints...
                      unsigned int local_node1=0;
                      unsigned int local_node2=0;

                      bool found_in_neighbor = false;

                      //Find the two vertices that make up this side
                      while(!elem->is_node_on_side(local_node1++,s)) { }
                      local_node1--;

                      //Start looking for the second one with the next node
                      local_node2=local_node1+1;

                      //Find the other one
                      while(!elem->is_node_on_side(local_node2++,s)) { }
                      local_node2--;

                      //Pull out their global ids:
                      dof_id_type node1 = elem->node(local_node1);
                      dof_id_type node2 = elem->node(local_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;
                        }

                      dof_id_type hanging_node=0;

                      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
                      local_node1=0;
                      local_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(local_node1++,s_neigh)) { }
                      local_node1--;

                      local_node2=local_node1+1;

                      //Find the second node...
                      while(!neigh->is_node_on_side(local_node2++,s_neigh)) { }
                      local_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(local_node1));
                          hanging_nodes[hanging_node].push_back(neigh->node(local_node2));
                        }
                    }
                }
            }
        }
    }
}
void libMesh::MeshTools::find_nodal_neighbors ( const MeshBase mesh,
const Node n,
std::vector< std::vector< const Elem * > > &  nodes_to_elem_map,
std::vector< const Node * > &  neighbors 
)

Given a mesh and a node in the mesh, the vector will be filled with every node directly attached to the given one.

Definition at line 704 of file mesh_tools.C.

References libMesh::Elem::active(), libMesh::Elem::get_node(), libMesh::DofObject::id(), libMesh::invalid_uint, libMesh::Elem::is_node_on_edge(), libMesh::libmesh_assert(), libMesh::Elem::local_node(), libMesh::Elem::n_edges(), libMesh::Elem::n_nodes(), and libMesh::Elem::node().

Referenced by libMesh::MeshTools::Subdivision::prepare_subdivision_mesh(), and libMesh::VariationalMeshSmoother::readgr().

{
  // We'll refer back to the Node ID several times
  dof_id_type global_id = node.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();

  // 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)
    {
      // Grab an Elem pointer to use in the subsequent loop
      const Elem* elem = *el;

      // We only care about active elements...
      if (elem->active())
        {
          // Which local node number is global_id?
          unsigned local_node_number = elem->local_node(global_id);

          // Make sure it was found
          libmesh_assert_not_equal_to(local_node_number, libMesh::invalid_uint);

          // Index of the current edge
          unsigned current_edge = 0;

          while (current_edge < elem->n_edges())
            {
              // Find the edge the node is on
              bool found_edge = false;
              for (; current_edge<elem->n_edges(); ++current_edge)
                if ( elem->is_node_on_edge(local_node_number, current_edge) )
                  {
                    found_edge = true;
                    break;
                  }

              // Did we find one?
              if (found_edge)
                {
                  Node* node_to_save = NULL;

                  // Find another node in this element on this edge
                  for (unsigned other_node_this_edge = 0; other_node_this_edge<elem->n_nodes(); other_node_this_edge++)
                    if ( (elem->is_node_on_edge(other_node_this_edge, current_edge)) && // On the current edge
                         (elem->node(other_node_this_edge) != global_id))               // But not the original node
                      {
                        // We've found a nodal neighbor!  Save a pointer to it..
                        node_to_save = elem->get_node(other_node_this_edge);
                        break;
                      }

                  // Make sure we found something
                  libmesh_assert(node_to_save != NULL);

                  // 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 already have it, add it to the vector
                  if (result == neighbors.end())
                    neighbors.push_back(node_to_save);
                }

              // Keep looking for edges, node may be on more than one edge
              current_edge++;
            }
        }
    }
}
void libMesh::MeshTools::get_not_subactive_node_ids ( const MeshBase mesh,
std::set< dof_id_type > &  not_subactive_node_ids 
)

Builds a set of node IDs for nodes which belong to non-subactive elements. Non-subactive elements are those which are either active or inactive. This is useful for determining which nodes should be written to a data file, and is used by the XDA mesh writing methods.

Definition at line 645 of file mesh_tools.C.

References libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::Elem::n_nodes(), libMesh::Elem::node(), and libMesh::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)
    {
      const Elem* elem = (*el);
      if(!elem->subactive())
        for (unsigned int n=0; n<elem->n_nodes(); ++n)
          not_subactive_node_ids.insert(elem->node(n));
    }
}

A function for verifying that all nodes are connected to at least one element.

This will fail in the most general case. When ParallelMesh and NodeConstraints are enabled, we expect the possibility that a processor will be given remote nodes to satisfy node constraints without also being given the remote elements connected to those nodes.

Definition at line 1121 of file mesh_tools.C.

References libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::Elem::get_node(), libMesh::libmesh_assert(), libMesh::Elem::n_nodes(), libMesh::MeshBase::nodes_begin(), and libMesh::MeshBase::nodes_end().

{
  std::set<const Node*> used_nodes;

  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);

      for (unsigned int n=0; n<elem->n_nodes(); ++n)
        used_nodes.insert(elem->get_node(n));
    }

  const MeshBase::const_node_iterator node_end = mesh.nodes_end();

  for (MeshBase::const_node_iterator node_it = mesh.nodes_begin();
       node_it != node_end; ++node_it)
    {
      Node *node = *node_it;
      libmesh_assert(node);
      libmesh_assert(used_nodes.count(node));
    }
}

A function for testing that all DofObjects within a mesh have the same n_systems count

Definition at line 936 of file mesh_tools.C.

References libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::DofObject::n_systems(), libMesh::MeshBase::nodes_begin(), and libMesh::MeshBase::nodes_end().

{
  MeshBase::const_element_iterator el =
    mesh.elements_begin();
  const MeshBase::const_element_iterator el_end =
    mesh.elements_end();
  if (el == el_end)
    return;

  const unsigned int n_sys = (*el)->n_systems();

  for (; el != el_end; ++el)
    {
      const Elem *elem = *el;
      libmesh_assert_equal_to (elem->n_systems(), n_sys);
    }

  MeshBase::const_node_iterator node_it =
    mesh.nodes_begin();
  const MeshBase::const_node_iterator node_end =
    mesh.nodes_end();

  if (node_it == node_end)
    return;

  for (; node_it != node_end; ++node_it)
    {
      const Node *node = *node_it;
      libmesh_assert_equal_to (node->n_systems(), n_sys);
    }
}
void libMesh::MeshTools::libmesh_assert_no_links_to_elem ( const MeshBase mesh,
const Elem bad_elem 
)

A function for verifying that an element has been cut off from the rest of the mesh

Definition at line 1051 of file mesh_tools.C.

References libMesh::Elem::child(), libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::Elem::has_children(), libMesh::libmesh_assert(), libMesh::Elem::n_children(), libMesh::Elem::n_neighbors(), libMesh::Elem::neighbor(), and libMesh::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_not_equal_to (elem->parent(), bad_elem);
      for (unsigned int n=0; n != elem->n_neighbors(); ++n)
        libmesh_assert_not_equal_to (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_not_equal_to (elem->child(c), bad_elem);
#endif
    }
}

A function for testing that all non-recently-created DofObjects within a mesh have old_dof_object data. This is not expected to be true at all points within a simulation code.

Definition at line 971 of file mesh_tools.C.

References libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::Elem::get_node(), libMesh::DofObject::has_dofs(), libMesh::Elem::INACTIVE, libMesh::Elem::JUST_REFINED, libMesh::libmesh_assert(), libMesh::Elem::n_nodes(), libMesh::DofObject::old_dof_object, and libMesh::Elem::refinement_flag().

{
  MeshBase::const_element_iterator el =
    mesh.elements_begin();
  const MeshBase::const_element_iterator el_end =
    mesh.elements_end();

  for (; el != el_end; ++el)
    {
      const Elem *elem = *el;

      if (elem->refinement_flag() == Elem::JUST_REFINED ||
          elem->refinement_flag() == Elem::INACTIVE)
        continue;

      if (elem->has_dofs())
        libmesh_assert(elem->old_dof_object);

      for (unsigned int n=0; n != elem->n_nodes(); ++n)
        {
          const Node *node = elem->get_node(n);
          if (node->has_dofs())
            libmesh_assert(elem->get_node(n)->old_dof_object);
        }
    }
}

A function for verifying that ids of elements are correctly sorted for AMR (parents have lower ids than children)

Definition at line 1099 of file mesh_tools.C.

References libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::DofObject::id(), libMesh::libmesh_assert(), libMesh::Elem::parent(), and libMesh::DofObject::processor_id().

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

{
  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);

      const Elem* parent = elem->parent();

      if (parent)
        {
          libmesh_assert_greater_equal (elem->id(), parent->id());
          libmesh_assert_greater_equal (elem->processor_id(), parent->processor_id());
        }
    }
}

A function for verifying that degree of freedom indexing matches across processors.

Definition at line 1152 of file mesh_tools.C.

References libMesh::ParallelObject::comm(), libMesh::Parallel::Communicator::max(), libMesh::MeshBase::max_elem_id(), libMesh::MeshBase::max_node_id(), libMesh::ParallelObject::n_processors(), libMesh::MeshBase::query_elem(), and libMesh::MeshBase::query_node_ptr().

Referenced by libMesh::DofMap::distribute_dofs().

{
  if (mesh.n_processors() == 1)
    return;

  libmesh_parallel_only(mesh.comm());

  dof_id_type pmax_elem_id = mesh.max_elem_id();
  mesh.comm().max(pmax_elem_id);

  for (dof_id_type i=0; i != pmax_elem_id; ++i)
    assert_semiverify_dofobj(mesh.comm(),
                             mesh.query_elem(i));

  dof_id_type pmax_node_id = mesh.max_node_id();
  mesh.comm().max(pmax_node_id);

  for (dof_id_type i=0; i != pmax_node_id; ++i)
    assert_semiverify_dofobj(mesh.comm(),
                             mesh.query_node_ptr(i));
}

A function for verifying that ids and processor assignment of elements are correctly sorted (monotone increasing)

Definition at line 1074 of file mesh_tools.C.

References libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), libMesh::DofObject::id(), libMesh::libmesh_assert(), and libMesh::DofObject::processor_id().

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

{
  processor_id_type lastprocid = 0;
  dof_id_type 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);
      processor_id_type elemprocid = elem->processor_id();
      dof_id_type elemid = elem->id();

      libmesh_assert_greater_equal (elemid, lastelemid);
      libmesh_assert_greater_equal (elemprocid, lastprocid);

      lastelemid = elemid;
      lastprocid = elemprocid;
    }
}

A function for verifying that neighbor connectivity is correct (each element is a neighbor of or descendant of a neighbor of its neighbors)

Definition at line 1420 of file mesh_tools.C.

References libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::libmesh_assert(), and libMesh::Elem::libmesh_assert_valid_neighbors().

Referenced by libMesh::ParallelMesh::allgather(), libMesh::ParallelMesh::delete_remote_elements(), and libMesh::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();
    }
}

A function for walking across the mesh to try and ferret out invalidated or misassigned pointers

Definition at line 1003 of file mesh_tools.C.

References libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::libmesh_assert(), libMesh::Elem::libmesh_assert_valid_node_pointers(), libMesh::Elem::n_neighbors(), libMesh::Elem::neighbor(), libMesh::Elem::parent(), and libMesh::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_not_equal_to (elem->parent(), remote_elem);
          elem = elem->parent();
        }
    }
}
template<typename DofObjectSubclass >
void libMesh::MeshTools::libmesh_assert_valid_procids ( const MeshBase &  mesh)

A function for verifying that processor assignment is self-consistent on nodes (each node part of an active element on its processor) or elements (each parent has the processor id of one of its children), and verifying that assignment is consistent (every processor agrees on the processor id of each dof object it can see)

template<>
void libMesh::MeshTools::libmesh_assert_valid_procids< Elem > ( const MeshBase mesh)

Definition at line 1175 of file mesh_tools.C.

References libMesh::Elem::active(), libMesh::Elem::child(), libMesh::ParallelObject::comm(), libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::Elem::has_children(), libMesh::libmesh_assert(), std::max(), libMesh::Parallel::Communicator::max(), libMesh::MeshBase::max_elem_id(), mesh, std::min(), libMesh::Parallel::Communicator::min(), libMesh::Elem::n_children(), libMesh::ParallelObject::n_processors(), libMesh::Elem::parent(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::MeshBase::query_elem(), libMesh::remote_elem, and libMesh::Elem::subactive().

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

{
  if (mesh.n_processors() == 1)
    return;

  libmesh_parallel_only(mesh.comm());

  // We want this test to be valid even when called even after nodes
  // have been added asynchonously but before they're renumbered
  dof_id_type parallel_max_elem_id = mesh.max_elem_id();
  mesh.comm().max(parallel_max_elem_id);

  // Check processor ids for consistency between processors

  for (dof_id_type i=0; i != parallel_max_elem_id; ++i)
    {
      const Elem *elem = mesh.query_elem(i);

      processor_id_type min_id =
        elem ? elem->processor_id() :
        std::numeric_limits<processor_id_type>::max();
      mesh.comm().min(min_id);

      processor_id_type max_id =
        elem ? elem->processor_id() :
        std::numeric_limits<processor_id_type>::min();
      mesh.comm().max(max_id);

      if (elem)
        {
          libmesh_assert_equal_to (min_id, elem->processor_id());
          libmesh_assert_equal_to (max_id, elem->processor_id());
        }

      if (min_id == mesh.processor_id())
        libmesh_assert(elem);
    }

  // If we're adaptively refining, check processor ids for consistency
  // between parents and children.
#ifdef LIBMESH_ENABLE_AMR

  // Ancestor elements we won't worry about, but subactive and active
  // elements ought to have parents with consistent processor ids

  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);

      if (!elem->active() && !elem->subactive())
        continue;

      const Elem *parent = elem->parent();

      if (parent)
        {
          libmesh_assert(parent->has_children());
          processor_id_type parent_procid = parent->processor_id();
          bool matching_child_id = false;
          for (unsigned int c = 0; c != parent->n_children(); ++c)
            {
              const Elem* child = parent->child(c);
              libmesh_assert(child);

              // If we've got a remote_elem then we don't know whether
              // it's responsible for the parent's processor id; all
              // we can do is assume it is and let its processor fail
              // an assert if there's something wrong.
              if (child == remote_elem ||
                  child->processor_id() == parent_procid)
                matching_child_id = true;
            }
          libmesh_assert(matching_child_id);
        }
    }
#endif
}
template<>
void libMesh::MeshTools::libmesh_assert_valid_procids< Node > ( const MeshBase mesh)

Definition at line 1260 of file mesh_tools.C.

References libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libMesh::ParallelObject::comm(), libMesh::Elem::get_node(), libMesh::DofObject::id(), libMesh::libmesh_assert(), libMesh::MeshBase::local_nodes_begin(), libMesh::MeshBase::local_nodes_end(), std::max(), libMesh::Parallel::Communicator::max(), libMesh::MeshBase::max_node_id(), mesh, std::min(), libMesh::Parallel::Communicator::min(), libMesh::Elem::n_nodes(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), and libMesh::MeshBase::query_node_ptr().

Referenced by libMesh::MeshRefinement::_coarsen_elements(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), and libMesh::Partitioner::set_node_processor_ids().

{
  if (mesh.n_processors() == 1)
    return;

  libmesh_parallel_only(mesh.comm());

  // We want this test to be valid even when called even after nodes
  // have been added asynchonously but before they're renumbered
  dof_id_type parallel_max_node_id = mesh.max_node_id();
  mesh.comm().max(parallel_max_node_id);

  // Check processor ids for consistency between processors

  for (dof_id_type i=0; i != parallel_max_node_id; ++i)
    {
      const Node *node = mesh.query_node_ptr(i);

      processor_id_type min_id =
        node ? node->processor_id() :
        std::numeric_limits<processor_id_type>::max();
      mesh.comm().min(min_id);

      processor_id_type max_id =
        node ? node->processor_id() :
        std::numeric_limits<processor_id_type>::min();
      mesh.comm().max(max_id);

      if (node)
        {
          libmesh_assert_equal_to (min_id, node->processor_id());
          libmesh_assert_equal_to (max_id, node->processor_id());
        }

      if (min_id == mesh.processor_id())
        libmesh_assert(node);
    }

  std::vector<bool> node_touched_by_me(parallel_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);
          dof_id_type nodeid = node->id();
          node_touched_by_me[nodeid] = true;
        }
    }
  std::vector<bool> node_touched_by_anyone(node_touched_by_me);
  mesh.comm().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);

      dof_id_type nodeid = node->id();
      libmesh_assert(!node_touched_by_anyone[nodeid] ||
                     node_touched_by_me[nodeid]);
    }
}

A function for verifying that refinement flags on elements are consistent between processors

Definition at line 1336 of file mesh_tools.C.

References libMesh::ParallelObject::comm(), libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::DofObject::id(), libMesh::libmesh_assert(), libMesh::MeshBase::max_elem_id(), libMesh::Parallel::Communicator::min(), libMesh::ParallelObject::n_processors(), libMesh::Elem::p_refinement_flag(), and libMesh::Elem::refinement_flag().

{
  libmesh_parallel_only(mesh.comm());
  if (mesh.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);
      dof_id_type 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);
  mesh.comm().min(min_elem_h_state);

  std::vector<unsigned char> min_elem_p_state(my_elem_p_state);
  mesh.comm().min(min_elem_p_state);

  for (dof_id_type 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]);
    }
}

A function for verifying that elements on this processor have valid descendants and consistent active flags.

Definition at line 1383 of file mesh_tools.C.

References libMesh::Elem::active(), libMesh::Elem::ancestor(), libMesh::Elem::child(), libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::Elem::has_children(), libMesh::libmesh_assert(), libMesh::Elem::n_children(), libMesh::Elem::parent(), libMesh::remote_elem, and libMesh::Elem::subactive().

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

{
  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);
      if (elem->has_children())
        for (unsigned int n=0; n != elem->n_children(); ++n)
          {
            libmesh_assert(elem->child(n));
            if (elem->child(n) != remote_elem)
              libmesh_assert_equal_to (elem->child(n)->parent(), elem);
          }
      if (elem->active())
        {
          libmesh_assert(!elem->ancestor());
          libmesh_assert(!elem->subactive());
        }
      else if (elem->ancestor())
        {
          libmesh_assert(!elem->subactive());
        }
      else
        libmesh_assert(elem->subactive());
    }
}

A function for verifying that active local elements' neighbors are never remote elements

Definition at line 1027 of file mesh_tools.C.

References libMesh::Elem::child(), libMesh::libmesh_assert(), libMesh::MeshBase::local_elements_begin(), libMesh::MeshBase::local_elements_end(), libMesh::Elem::n_children(), libMesh::Elem::n_neighbors(), libMesh::Elem::neighbor(), libMesh::Elem::parent(), and libMesh::remote_elem.

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

{
  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_not_equal_to (elem->neighbor(n), remote_elem);
#ifdef LIBMESH_ENABLE_AMR
      const Elem* parent = elem->parent();
      if (parent)
        {
          libmesh_assert_not_equal_to (parent, remote_elem);
          for (unsigned int c=0; c != elem->n_children(); ++c)
            libmesh_assert_not_equal_to (parent->child(c), remote_elem);
        }
#endif
    }
}

Return the number of active elements of type type. Implemented in terms of active_type_element_iterators.

Definition at line 550 of file mesh_tools.C.

References libMesh::MeshBase::active_type_elements_begin(), and libMesh::MeshBase::active_type_elements_end().

Referenced by libMesh::DivaIO::write_stream().

{
  return static_cast<dof_id_type>(std::distance(mesh.active_type_elements_begin(type),
                                                mesh.active_type_elements_end  (type)));
}
unsigned int libMesh::MeshTools::n_active_levels ( const MeshBase mesh)

Return the number of levels of refinement in the active mesh. Implemented by looping over all the active local elements and finding the maximum level, then maxxing in parallel.

Definition at line 589 of file mesh_tools.C.

References libMesh::ParallelObject::comm(), std::max(), libMesh::Parallel::Communicator::max(), n_active_local_levels(), libMesh::MeshBase::unpartitioned_elements_begin(), and libMesh::MeshBase::unpartitioned_elements_end().

Referenced by libMesh::CheckpointIO::read_connectivity(), libMesh::CheckpointIO::write_connectivity(), and libMesh::XdrIO::write_serialized_connectivity().

{
  libmesh_parallel_only(mesh.comm());

  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);

  mesh.comm().max(nl);
  return nl;
}
unsigned int libMesh::MeshTools::n_active_local_levels ( const MeshBase mesh)

Return the number of levels of refinement in the active local mesh. Implemented by looping over all the active local elements and finding the maximum level.

Definition at line 574 of file mesh_tools.C.

References libMesh::MeshBase::active_local_elements_begin(), libMesh::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;
}

Return the number of elements of type type. Implemented in terms of type_element_iterators.

Definition at line 541 of file mesh_tools.C.

References libMesh::MeshBase::type_elements_begin(), and libMesh::MeshBase::type_elements_end().

{
  return static_cast<dof_id_type>(std::distance(mesh.type_elements_begin(type),
                                                mesh.type_elements_end  (type)));
}
unsigned int libMesh::MeshTools::n_levels ( const MeshBase mesh)

Return the number of levels of refinement in the mesh. Implemented by looping over all the local elements and finding the maximum level, then summing in parallel.

Definition at line 625 of file mesh_tools.C.

References libMesh::ParallelObject::comm(), std::max(), libMesh::Parallel::Communicator::max(), n_local_levels(), libMesh::MeshBase::unpartitioned_elements_begin(), and libMesh::MeshBase::unpartitioned_elements_end().

Referenced by libMesh::MeshCommunication::delete_remote_elements(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::LegacyXdrIO::read_mesh(), libMesh::MeshTools::Modification::smooth(), and libMesh::LegacyXdrIO::write_mesh().

{
  libmesh_parallel_only(mesh.comm());

  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);

  mesh.comm().max(nl);
  return nl;
}
unsigned int libMesh::MeshTools::n_local_levels ( const MeshBase mesh)

Return the number of levels of refinement in the local mesh. Implemented by looping over all the local elements and finding the maximum level.

Definition at line 610 of file mesh_tools.C.

References libMesh::MeshBase::local_elements_begin(), libMesh::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;
}

Count up the number of nodes of a specific type (as defined by an iterator range).

Definition at line 669 of file mesh_tools.C.

{
  return cast_int<dof_id_type>(std::distance(begin, end));
}
dof_id_type libMesh::MeshTools::n_non_subactive_elem_of_type_at_level ( const MeshBase mesh,
const ElemType  type,
const unsigned int  level 
)

Return the number of elements of type type at the specified refinement level.

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 557 of file mesh_tools.C.

References end, libMesh::MeshBase::type_elements_begin(), and libMesh::MeshBase::type_elements_end().

Referenced by libMesh::LegacyXdrIO::write_mesh().

{
  dof_id_type 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;
}
unsigned int libMesh::MeshTools::n_p_levels ( const MeshBase mesh)

Return the number of p-levels of refinement in the mesh. Implemented by looping over all the local elements and finding the maximum p-level, then summing in parallel.

Definition at line 677 of file mesh_tools.C.

References libMesh::ParallelObject::comm(), libMesh::MeshBase::local_elements_begin(), libMesh::MeshBase::local_elements_end(), std::max(), libMesh::Parallel::Communicator::max(), libMesh::MeshBase::unpartitioned_elements_begin(), and libMesh::MeshBase::unpartitioned_elements_end().

Referenced by libMesh::XdrIO::write().

{
  libmesh_parallel_only(mesh.comm());

  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);

  mesh.comm().max(max_p_level);
  return max_p_level + 1;
}
Returns:
two points defining a cartesian box that bounds the elements belonging to processor pid.

Definition at line 455 of file mesh_tools.C.

References libMesh::ParallelObject::n_processors(), libMesh::Threads::parallel_reduce(), libMesh::MeshBase::pid_elements_begin(), and libMesh::MeshBase::pid_elements_end().

Referenced by processor_bounding_sphere().

{
  libmesh_assert_less (pid, mesh.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();
}

Same, but returns a sphere instead of a box.

Definition at line 472 of file mesh_tools.C.

References processor_bounding_box(), and libMesh::Real.

{
  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);
}
Returns:
two points defining a Cartesian box that bounds the elements belonging to subdomain sid.

Definition at line 486 of file mesh_tools.C.

References libMesh::MeshBase::elem(), std::max(), std::min(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::Elem::n_nodes(), libMesh::Elem::node(), libMesh::MeshBase::point(), libMesh::MeshBase::spatial_dimension(), and libMesh::Elem::subdomain_id().

Referenced by subdomain_bounding_sphere().

{
  libmesh_assert_not_equal_to (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);
}

Same, but returns a sphere instead of a box.

Definition at line 509 of file mesh_tools.C.

References libMesh::Real, and 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);
}

This function returns the sum over all the elemenents of the number of nodes per element. This can be useful for partitioning hybrid meshes. A feasible load balancing scheme is to keep the weight per processor as uniform as possible.

Definition at line 314 of file mesh_tools.C.

References libMesh::ParallelObject::comm(), libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::DofObject::invalid_processor_id, libMesh::MeshBase::is_serial(), libMesh::Threads::parallel_reduce(), libMesh::ParallelObject::processor_id(), libMesh::Parallel::Communicator::sum(), and weight().

Referenced by libMesh::LegacyXdrIO::write_mesh().

{
  if (!mesh.is_serial())
    {
      libmesh_parallel_only(mesh.comm());
      dof_id_type weight = MeshTools::weight (mesh, mesh.processor_id());
      mesh.comm().sum(weight);
      dof_id_type 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();

}

This function returns the sum over all the elemenents on processor pid of nodes per element. This can be useful for partitioning hybrid meshes. A feasible load balancing scheme is to keep the weight per processor as uniform as possible.

Definition at line 337 of file mesh_tools.C.

References libMesh::Threads::parallel_reduce(), libMesh::MeshBase::pid_elements_begin(), and libMesh::MeshBase::pid_elements_end().

Referenced by libMesh::QGrundmann_Moller::gm_rule(), libMesh::QGrid::init_2D(), libMesh::QGrid::init_3D(), libMesh::FE< Dim, T >::init_shape_functions(), libMesh::InfFE< Dim, T_radial, T_map >::init_shape_functions(), libMesh::FEXYZ< Dim >::init_shape_functions(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::MeshTools::Modification::smooth(), total_weight(), and weight().

{
  SumElemWeight sew;

  Threads::parallel_reduce (ConstElemRange (mesh.pid_elements_begin(pid),
                                            mesh.pid_elements_end(pid)),
                            sew);
  return sew.weight();
}
dof_id_type libMesh::MeshTools::weight ( const MeshBase &  mesh) [inline]

Definition at line 134 of file mesh_tools.h.

References libMesh::ParallelObject::processor_id(), and weight().

{ return MeshTools::weight (mesh, mesh.processor_id()); }