libMesh::MeshTools Namespace Reference

Namespaces

 Generation
 
 Modification
 
 Private
 
 Subdivision
 Support functions for subdivision surface elements.
 

Classes

class  BoundingBox
 

Functions

void libmesh_assert_valid_boundary_ids (const MeshBase &mesh)
 
void libmesh_assert_valid_dof_ids (const MeshBase &mesh, unsigned int sysnum)
 
void libmesh_assert_valid_unique_ids (const MeshBase &mesh)
 
template<>
void libmesh_assert_topology_consistent_procids< Elem > (const MeshBase &mesh)
 
template<>
void libmesh_assert_parallel_consistent_procids< Elem > (const MeshBase &mesh)
 
template<>
void libmesh_assert_topology_consistent_procids< Node > (const MeshBase &mesh)
 
template<>
void libmesh_assert_parallel_consistent_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)
 
libMesh::BoundingBox create_bounding_box (const MeshBase &mesh)
 
Sphere bounding_sphere (const MeshBase &mesh)
 
libMesh::BoundingBox create_nodal_bounding_box (const MeshBase &mesh)
 
libMesh::BoundingBox create_local_bounding_box (const MeshBase &mesh)
 
BoundingBox processor_bounding_box (const MeshBase &mesh, const processor_id_type pid)
 
libMesh::BoundingBox create_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)
 
libMesh::BoundingBox create_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)
 
unsigned int paranoid_n_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, const 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_valid_amr_interior_parents (const MeshBase &mesh)
 
void libmesh_assert_connected_nodes (const MeshBase &mesh)
 
template<typename DofObjectSubclass >
void libmesh_assert_parallel_consistent_procids (const MeshBase &mesh)
 
template<typename DofObjectSubclass >
void libmesh_assert_topology_consistent_procids (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, bool assert_valid_remote_elems=true)
 

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

MeshTools::BoundingBox libMesh::MeshTools::bounding_box ( const MeshBase mesh)
Returns
Two points defining a cartesian box that bounds the mesh. The first entry in the pair is the minimum, the second is the maximum.
Deprecated:
Use create_bounding_box() instead.

Definition at line 329 of file mesh_tools.C.

References create_bounding_box().

Referenced by libMesh::TreeNode< N >::bounds_point(), libMesh::TreeNode< N >::create_bounding_box(), libMesh::TreeNode< N >::insert(), libMesh::TreeNode< N >::set_bounding_box(), and weight().

330 {
331  // This function is deprecated. It simply calls
332  // create_bounding_box() and converts the result to a
333  // MeshTools::BoundingBox.
334  libmesh_deprecated();
335  return MeshTools::create_bounding_box(mesh);
336 }
libMesh::BoundingBox create_bounding_box(const MeshBase &mesh)
Definition: mesh_tools.C:341
Sphere libMesh::MeshTools::bounding_sphere ( const MeshBase mesh)
Returns
A bounding sphere for mesh instead of a bounding box.

Definition at line 393 of file mesh_tools.C.

References create_bounding_box(), and libMesh::Real.

Referenced by weight().

394 {
396 
397  const Real diag = (bbox.second - bbox.first).norm();
398  const Point cent = (bbox.second + bbox.first)/2;
399 
400  return Sphere (cent, .5*diag);
401 }
A geometric object representing a sphere.
Definition: sphere.h:72
libMesh::BoundingBox create_bounding_box(const MeshBase &mesh)
Definition: mesh_tools.C:341
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
A geometric point in (x,y,z) space.
Definition: point.h:38
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 258 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(), libMesh::Tree< N >::Tree(), and weight().

260 {
261  nodes_to_elem_map.resize (mesh.n_nodes());
262 
265 
266  for (; el != end; ++el)
267  for (unsigned int n=0; n<(*el)->n_nodes(); n++)
268  {
269  libmesh_assert_less ((*el)->node_id(n), nodes_to_elem_map.size());
270  libmesh_assert_less ((*el)->id(), mesh.n_elem());
271 
272  nodes_to_elem_map[(*el)->node_id(n)].push_back((*el)->id());
273  }
274 }
IterBase * end
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
virtual dof_id_type n_nodes() const =0
virtual dof_id_type n_elem() const =0
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 278 of file mesh_tools.C.

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

280 {
281  nodes_to_elem_map.resize (mesh.n_nodes());
282 
285 
286  for (; el != end; ++el)
287  for (unsigned int n=0; n<(*el)->n_nodes(); n++)
288  {
289  libmesh_assert_less ((*el)->node_id(n), nodes_to_elem_map.size());
290 
291  nodes_to_elem_map[(*el)->node_id(n)].push_back(*el);
292  }
293 }
IterBase * end
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
virtual dof_id_type n_nodes() const =0
void libMesh::MeshTools::correct_node_proc_ids ( MeshBase mesh)

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

References libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), libMesh::ParallelObject::comm(), libMesh::DofObject::id(), libMesh::libmesh_assert(), libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshBase::local_nodes_begin(), libMesh::MeshBase::local_nodes_end(), mesh, std::min(), libMesh::Elem::n_nodes(), libMesh::ParallelObject::n_processors(), new_proc_ids, libMesh::Elem::node_ref(), libMesh::MeshBase::nodes_begin(), libMesh::MeshBase::nodes_end(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::Parallel::Communicator::rank(), libMesh::Parallel::Communicator::receive(), libMesh::Parallel::Communicator::send(), libMesh::Parallel::Communicator::size(), libMesh::Parallel::sync_dofobject_data_by_id(), and libMesh::Parallel::wait().

Referenced by libMesh::MeshCommunication::make_new_nodes_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), and weight().

1948 {
1949  // This function must be run on all processors at once
1950  libmesh_parallel_only(mesh.comm());
1951 
1952  // Fix all nodes' processor ids. Coarsening may have left us with
1953  // nodes which are no longer touched by any elements of the same
1954  // processor id, and for DofMap to work we need to fix that.
1955 
1956  // This is harder now that libMesh no longer requires a distributed
1957  // mesh to ghost all nodal neighbors: it is possible for two active
1958  // elements on two different processors to share the same node in
1959  // such a way that neither processor knows the others' element
1960  // exists!
1961 
1962  // We require all processors to agree on nodal processor ids before
1963  // going into this algorithm.
1964 #ifdef DEBUG
1966 #endif
1967 
1968  // We build up a set of compatible processor ids for each node
1969  proc_id_map_type new_proc_ids;
1970 
1972  const MeshBase::element_iterator e_end = mesh.active_elements_end();
1973  for (; e_it != e_end; ++e_it)
1974  {
1975  Elem * elem = *e_it;
1976  processor_id_type pid = elem->processor_id();
1977 
1978  for (unsigned int n=0; n != elem->n_nodes(); ++n)
1979  {
1980  const Node & node = elem->node_ref(n);
1981  const dof_id_type id = node.id();
1982  const proc_id_map_type::iterator it = new_proc_ids.find(id);
1983  if (it == new_proc_ids.end())
1984  new_proc_ids.insert(std::make_pair(id,pid));
1985  else
1986  it->second = std::min(it->second, pid);
1987  }
1988  }
1989 
1990  // Sort the new pids to push to each processor
1991  std::vector<std::vector<std::pair<dof_id_type, processor_id_type> > >
1992  ids_to_push(mesh.n_processors());
1993 
1995  n_it = mesh.nodes_begin(),
1996  n_end = mesh.nodes_end();
1997  n_it != n_end; ++n_it)
1998  {
1999  const Node * node = *n_it;
2000  const dof_id_type id = node->id();
2001  const proc_id_map_type::iterator it = new_proc_ids.find(id);
2002  if (it == new_proc_ids.end())
2003  continue;
2004  const processor_id_type pid = it->second;
2005  ids_to_push[node->processor_id()].push_back(std::make_pair(id, pid));
2006  }
2007 
2008  // Push using non-blocking I/O
2009  std::vector<Parallel::Request> push_requests(mesh.n_processors());
2010 
2011  for (processor_id_type p=1; p != mesh.n_processors(); ++p)
2012  {
2013  const processor_id_type procup =
2014  cast_int<processor_id_type>
2015  ((mesh.comm().rank() + p) % mesh.comm().size());
2016 
2017  mesh.comm().send(procup, ids_to_push[procup], push_requests[procup]);
2018  }
2019 
2020  for (processor_id_type p=0; p != mesh.n_processors(); ++p)
2021  {
2022  const processor_id_type procdown =
2023  cast_int<processor_id_type>
2024  ((mesh.comm().size() + mesh.comm().rank() - p) %
2025  mesh.comm().size());
2026 
2027  std::vector<std::pair<dof_id_type, processor_id_type> >
2028  ids_to_pull;
2029 
2030  if (p)
2031  mesh.comm().receive(procdown, ids_to_pull);
2032  else
2033  ids_to_pull.swap(ids_to_push[procdown]);
2034 
2035  std::vector<std::pair<dof_id_type, processor_id_type> >::iterator
2036  pulled_ids_it = ids_to_pull.begin(),
2037  pulled_ids_end = ids_to_pull.end();
2038  for (; pulled_ids_it != pulled_ids_end; ++pulled_ids_it)
2039  {
2040  const dof_id_type id = pulled_ids_it->first;
2041  const processor_id_type pid = pulled_ids_it->second;
2042  const proc_id_map_type::iterator it = new_proc_ids.find(id);
2043  if (it == new_proc_ids.end())
2044  new_proc_ids.insert(std::make_pair(id,pid));
2045  else
2046  it->second = std::min(it->second, pid);
2047  }
2048  }
2049 
2050  // Now new_proc_ids is correct for every node we used to own. Let's
2051  // ask every other processor about the nodes they used to own. But
2052  // first we'll need to keep track of which nodes we used to own,
2053  // lest we get them confused with nodes we newly own.
2054  LIBMESH_BEST_UNORDERED_SET<Node *> ex_local_nodes;
2056  n_it = mesh.local_nodes_begin(),
2057  n_end = mesh.local_nodes_end();
2058  n_it != n_end; ++n_it)
2059  {
2060  Node * node = *n_it;
2061  const proc_id_map_type::iterator it = new_proc_ids.find(node->id());
2062  if (it != new_proc_ids.end() && it->second != mesh.processor_id())
2063  ex_local_nodes.insert(node);
2064  }
2065 
2066  // Let's finish with previous I/O before we start more.
2067  Parallel::wait(push_requests);
2068 
2069  SyncProcIdsFromMap sync(new_proc_ids, mesh);
2071  (mesh.comm(), mesh.nodes_begin(), mesh.nodes_end(), sync);
2072 
2073  // And finally let's update the nodes we used to own.
2074  for (LIBMESH_BEST_UNORDERED_SET<Node *>::iterator
2075  n_it = ex_local_nodes.begin(),
2076  n_end = ex_local_nodes.end();
2077  n_it != n_end; ++n_it)
2078  {
2079  Node * node = *n_it;
2080  const dof_id_type id = node->id();
2081  const proc_id_map_type::iterator it = new_proc_ids.find(id);
2082  libmesh_assert(it != new_proc_ids.end());
2083  node->processor_id() = it->second;
2084  }
2085 
2086  // We should still have consistent nodal processor ids coming out of
2087  // this algorithm.
2088 #ifdef DEBUG
2089  MeshTools::libmesh_assert_valid_procids<Node>(mesh);
2090 #endif
2091 }
Status wait(Request &r)
Definition: parallel.h:561
A geometric point in (x,y,z) space associated with a DOF.
Definition: node.h:52
unsigned int size() const
Definition: parallel.h:722
processor_id_type n_processors() const
The base class for all geometric element types.
Definition: elem.h:86
uint8_t processor_id_type
Definition: id_types.h:99
MeshBase & mesh
Definition: mesh_tools.C:1904
libmesh_assert(j)
virtual unsigned int n_nodes() const =0
virtual node_iterator nodes_begin()=0
virtual node_iterator local_nodes_end()=0
const Node & node_ref(const unsigned int i) const
Definition: elem.h:1752
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const
const proc_id_map_type & new_proc_ids
Definition: mesh_tools.C:1902
void sync_dofobject_data_by_id(const Communicator &comm, const Iterator &range_begin, const Iterator &range_end, SyncFunctor &sync)
void libmesh_assert_parallel_consistent_procids< Node >(const MeshBase &mesh)
Definition: mesh_tools.C:1661
virtual element_iterator active_elements_begin()=0
virtual element_iterator active_elements_end()=0
virtual node_iterator local_nodes_begin()=0
virtual node_iterator nodes_end()=0
const Parallel::Communicator & comm() const
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
unsigned int rank() const
Definition: parallel.h:720
dof_id_type id() const
Definition: dof_object.h:624
long double min(long double a, double b)
processor_id_type processor_id() const
uint8_t dof_id_type
Definition: id_types.h:64
processor_id_type processor_id() const
Definition: dof_object.h:686
libMesh::BoundingBox libMesh::MeshTools::create_bounding_box ( const MeshBase mesh)

The same functionality as the deprecated MeshTools::bounding_box().

Returns
The non-deprecated libMesh::BoundingBox type.

Definition at line 341 of file mesh_tools.C.

References libMesh::ParallelObject::comm(), create_local_bounding_box(), libMesh::DofObject::invalid_processor_id, libMesh::Parallel::Communicator::max(), libMesh::Parallel::Communicator::min(), libMesh::Threads::parallel_reduce(), libMesh::MeshBase::pid_elements_begin(), and libMesh::MeshBase::pid_elements_end().

Referenced by bounding_box(), bounding_sphere(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::PointLocatorTree::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::MetisPartitioner::partition_range(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::TreeNode< N >::refine(), libMesh::Tree< N >::Tree(), weight(), and libMesh::PostscriptIO::write().

342 {
343  // This function must be run on all processors at once
344  libmesh_parallel_only(mesh.comm());
345 
346  FindBBox find_bbox;
347 
348  // Start with any unpartitioned elements we know about locally
349  Threads::parallel_reduce (ConstElemRange (mesh.pid_elements_begin(DofObject::invalid_processor_id),
350  mesh.pid_elements_end(DofObject::invalid_processor_id)),
351  find_bbox);
352 
353  // And combine with our local elements
354  find_bbox.bbox().union_with(MeshTools::create_local_bounding_box(mesh));
355 
356  // Compare the bounding boxes across processors
357  mesh.comm().min(find_bbox.min());
358  mesh.comm().max(find_bbox.max());
359 
360  return find_bbox.bbox();
361 }
Utility class for defining generic ranges for threading.
Definition: stored_range.h:52
libMesh::BoundingBox create_local_bounding_box(const MeshBase &mesh)
Definition: mesh_tools.C:406
virtual element_iterator pid_elements_begin(processor_id_type proc_id)=0
const Parallel::Communicator & comm() const
void parallel_reduce(const Range &range, Body &body)
Definition: threads_none.h:101
virtual element_iterator pid_elements_end(processor_id_type proc_id)=0
libMesh::BoundingBox libMesh::MeshTools::create_local_bounding_box ( const MeshBase mesh)
Returns
Two points defining a cartesian box that bounds the elements belonging to the local processor.

Unlike the other bounding box creation functions, this does not need to be run in parallel, because this is the only function we can guarantee can be resolved with only local information.

Definition at line 406 of file mesh_tools.C.

References libMesh::MeshBase::local_elements_begin(), libMesh::MeshBase::local_elements_end(), and libMesh::Threads::parallel_reduce().

Referenced by create_bounding_box(), and weight().

407 {
408  FindBBox find_bbox;
409 
411  mesh.local_elements_end()),
412  find_bbox);
413 
414  return find_bbox.bbox();
415 }
virtual element_iterator local_elements_begin()=0
Utility class for defining generic ranges for threading.
Definition: stored_range.h:52
virtual element_iterator local_elements_end()=0
void parallel_reduce(const Range &range, Body &body)
Definition: threads_none.h:101
libMesh::BoundingBox libMesh::MeshTools::create_nodal_bounding_box ( const MeshBase mesh)
Returns
Two points defining a cartesian box that bounds the nodes of the mesh.

In the case of curved elements, this box might not bound the elements of the mesh.

Definition at line 366 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::MeshCommunication::assign_global_indices(), libMesh::MeshCommunication::check_for_duplicate_global_indices(), and weight().

367 {
368  // This function must be run on all processors at once
369  libmesh_parallel_only(mesh.comm());
370 
371  FindBBox find_bbox;
372 
373  // Start with any unpartitioned nodes we know about locally
374  Threads::parallel_reduce (ConstNodeRange (mesh.pid_nodes_begin(DofObject::invalid_processor_id),
375  mesh.pid_nodes_end(DofObject::invalid_processor_id)),
376  find_bbox);
377 
378  // Add our local nodes
380  mesh.local_nodes_end()),
381  find_bbox);
382 
383  // Compare the bounding boxes across processors
384  mesh.comm().min(find_bbox.min());
385  mesh.comm().max(find_bbox.max());
386 
387  return find_bbox.bbox();
388 }
virtual node_iterator pid_nodes_end(processor_id_type proc_id)=0
Utility class for defining generic ranges for threading.
Definition: stored_range.h:52
virtual node_iterator local_nodes_end()=0
virtual node_iterator local_nodes_begin()=0
const Parallel::Communicator & comm() const
void parallel_reduce(const Range &range, Body &body)
Definition: threads_none.h:101
virtual node_iterator pid_nodes_begin(processor_id_type proc_id)=0
libMesh::BoundingBox libMesh::MeshTools::create_processor_bounding_box ( const MeshBase mesh,
const processor_id_type  pid 
)

The same functionality as the deprecated MeshTools::processor_bounding_box().

Returns
The non-deprecated libMesh::BoundingBox type.

Definition at line 430 of file mesh_tools.C.

References libMesh::ParallelObject::comm(), libMesh::libmesh_assert(), libMesh::Parallel::Communicator::max(), libMesh::Parallel::Communicator::min(), libMesh::ParallelObject::n_processors(), libMesh::Threads::parallel_reduce(), libMesh::MeshBase::pid_elements_begin(), libMesh::MeshBase::pid_elements_end(), and libMesh::Parallel::Communicator::verify().

Referenced by processor_bounding_box(), processor_bounding_sphere(), and weight().

432 {
433  // This can only be run in parallel, with consistent arguments.
434  libmesh_parallel_only(mesh.comm());
435  libmesh_assert(mesh.comm().verify(pid));
436 
437  libmesh_assert_less (pid, mesh.n_processors());
438 
439  FindBBox find_bbox;
440 
442  mesh.pid_elements_end(pid)),
443  find_bbox);
444 
445  // Compare the bounding boxes across processors
446  mesh.comm().min(find_bbox.min());
447  mesh.comm().max(find_bbox.max());
448 
449  return find_bbox.bbox();
450 }
processor_id_type n_processors() const
Utility class for defining generic ranges for threading.
Definition: stored_range.h:52
libmesh_assert(j)
virtual element_iterator pid_elements_begin(processor_id_type proc_id)=0
const Parallel::Communicator & comm() const
void parallel_reduce(const Range &range, Body &body)
Definition: threads_none.h:101
virtual element_iterator pid_elements_end(processor_id_type proc_id)=0
libMesh::BoundingBox libMesh::MeshTools::create_subdomain_bounding_box ( const MeshBase mesh,
const subdomain_id_type  sid 
)

The same functionality as the deprecated MeshTools::subdomain_bounding_box().

Returns
The non-deprecated libMesh::BoundingBox type.

Definition at line 480 of file mesh_tools.C.

References libMesh::MeshBase::active_local_subdomain_elements_begin(), libMesh::MeshBase::active_local_subdomain_elements_end(), libMesh::ParallelObject::comm(), libMesh::libmesh_assert(), libMesh::Parallel::Communicator::max(), libMesh::Parallel::Communicator::min(), libMesh::Threads::parallel_reduce(), and libMesh::Parallel::Communicator::verify().

Referenced by subdomain_bounding_box(), subdomain_bounding_sphere(), and weight().

482 {
483  // This can only be run in parallel, with consistent arguments.
484  libmesh_parallel_only(mesh.comm());
485  libmesh_assert(mesh.comm().verify(sid));
486 
487  FindBBox find_bbox;
488 
492  find_bbox);
493 
494  // Compare the bounding boxes across processors
495  mesh.comm().min(find_bbox.min());
496  mesh.comm().max(find_bbox.max());
497 
498  return find_bbox.bbox();
499 }
Utility class for defining generic ranges for threading.
Definition: stored_range.h:52
virtual element_iterator active_local_subdomain_elements_end(subdomain_id_type subdomain_id)=0
libmesh_assert(j)
virtual element_iterator active_local_subdomain_elements_begin(subdomain_id_type subdomain_id)=0
const Parallel::Communicator & comm() const
void parallel_reduce(const Range &range, Body &body)
Definition: threads_none.h:101
void libMesh::MeshTools::elem_types ( const MeshBase mesh,
std::vector< ElemType > &  et 
)

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

Definition at line 518 of file mesh_tools.C.

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

Referenced by weight().

520 {
523 
524  // Automatically get the first type
525  et.push_back((*el)->type()); ++el;
526 
527  // Loop over the rest of the elements.
528  // If the current element type isn't in the
529  // vector, insert it.
530  for (; el != end; ++el)
531  if (!std::count(et.begin(), et.end(), (*el)->type()))
532  et.push_back((*el)->type());
533 }
IterBase * end
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
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 297 of file mesh_tools.C.

References libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), libMesh::Elem::build_side_ptr(), end, libmesh_nullptr, libMesh::MeshBase::max_node_id(), libMesh::Elem::n_neighbors(), libMesh::Elem::neighbor_ptr(), and side.

Referenced by libMesh::MeshTools::Modification::distort(), libMesh::VariationalMeshSmoother::readgr(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::MeshTools::Modification::smooth(), and weight().

299 {
300  // Resize the vector which holds boundary nodes and fill with false.
301  on_boundary.resize(mesh.max_node_id());
302  std::fill(on_boundary.begin(),
303  on_boundary.end(),
304  false);
305 
306  // Loop over elements, find those on boundary, and
307  // mark them as true in on_boundary.
310 
311  for (; el != end; ++el)
312  {
313  const Elem * elem = *el;
314 
315  for (unsigned int s=0; s<elem->n_neighbors(); s++)
316  if (elem->neighbor_ptr(s) == libmesh_nullptr) // on the boundary
317  {
318  const UniquePtr<const Elem> side = elem->build_side_ptr(s);
319 
320  for (unsigned int n=0; n<side->n_nodes(); n++)
321  on_boundary[side->node_id(n)] = true;
322  }
323  }
324 }
virtual UniquePtr< Elem > build_side_ptr(const unsigned int i, bool proxy=true)=0
virtual unsigned int n_neighbors() const
Definition: elem.h:557
unsigned short int side
Definition: xdr_io.C:49
virtual dof_id_type max_node_id() const =0
The base class for all geometric element types.
Definition: elem.h:86
const class libmesh_nullptr_t libmesh_nullptr
IterBase * end
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
const Elem * neighbor_ptr(unsigned int i) const
Definition: elem.h:1821
virtual element_iterator active_elements_begin()=0
virtual element_iterator active_elements_end()=0
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 897 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_nullptr, libMesh::Elem::n_neighbors(), libMesh::Elem::n_sides(), libMesh::Elem::neighbor_ptr(), libMesh::Elem::node_id(), libMesh::Elem::parent(), libMesh::QUAD4, libMesh::Elem::type(), and libMesh::Elem::which_neighbor_am_i().

Referenced by libMesh::VariationalMeshSmoother::smooth(), and weight().

899 {
902 
903  //Loop through all the elements
904  for (; it != end; ++it)
905  {
906  //Save it off for easier access
907  const Elem * elem = (*it);
908 
909  //Right now this only works for quad4's
910  //libmesh_assert_equal_to (elem->type(), QUAD4);
911  if (elem->type() == QUAD4)
912  {
913  //Loop over the sides looking for sides that have hanging nodes
914  //This code is inspired by compute_proj_constraints()
915  for (unsigned int s=0; s<elem->n_sides(); s++)
916  {
917  //If not a boundary node
918  if (elem->neighbor_ptr(s) != libmesh_nullptr)
919  {
920  // Get pointers to the element's neighbor.
921  const Elem * neigh = elem->neighbor_ptr(s);
922 
923  //Is there a coarser element next to this one?
924  if (neigh->level() < elem->level())
925  {
926  const Elem * ancestor = elem;
927  while (neigh->level() < ancestor->level())
928  ancestor = ancestor->parent();
929  unsigned int s_neigh = neigh->which_neighbor_am_i(ancestor);
930  libmesh_assert_less (s_neigh, neigh->n_neighbors());
931 
932  //Couple of helper uints...
933  unsigned int local_node1=0;
934  unsigned int local_node2=0;
935 
936  bool found_in_neighbor = false;
937 
938  // Find the two vertices that make up this side
939  while (!elem->is_node_on_side(local_node1++,s)) { }
940  local_node1--;
941 
942  // Start looking for the second one with the next node
943  local_node2=local_node1+1;
944 
945  // Find the other one
946  while (!elem->is_node_on_side(local_node2++,s)) { }
947  local_node2--;
948 
949  //Pull out their global ids:
950  dof_id_type node1 = elem->node_id(local_node1);
951  dof_id_type node2 = elem->node_id(local_node2);
952 
953  //Now find which node is present in the neighbor
954  //FIXME This assumes a level one rule!
955  //The _other_ one is the hanging node
956 
957  //First look for the first one
958  //FIXME could be streamlined a bit
959  for (unsigned int n=0;n<neigh->n_sides();n++)
960  {
961  if (neigh->node_id(n) == node1)
962  found_in_neighbor=true;
963  }
964 
965  dof_id_type hanging_node=0;
966 
967  if (!found_in_neighbor)
968  hanging_node=node1;
969  else // If it wasn't node1 then it must be node2!
970  hanging_node=node2;
971 
972  // Reset these for reuse
973  local_node1=0;
974  local_node2=0;
975 
976  // Find the first node that makes up the side in the neighbor (these should be the parent nodes)
977  while (!neigh->is_node_on_side(local_node1++,s_neigh)) { }
978  local_node1--;
979 
980  local_node2=local_node1+1;
981 
982  //Find the second node...
983  while (!neigh->is_node_on_side(local_node2++,s_neigh)) { }
984  local_node2--;
985 
986  //Save them if we haven't already found the parents for this one
987  if (hanging_nodes[hanging_node].size()<2)
988  {
989  hanging_nodes[hanging_node].push_back(neigh->node_id(local_node1));
990  hanging_nodes[hanging_node].push_back(neigh->node_id(local_node2));
991  }
992  }
993  }
994  }
995  }
996  }
997 }
virtual bool is_node_on_side(const unsigned int n, const unsigned int s) const =0
virtual ElemType type() const =0
virtual unsigned int n_neighbors() const
Definition: elem.h:557
const Elem * parent() const
Definition: elem.h:2148
unsigned int which_neighbor_am_i(const Elem *e) const
Definition: elem.h:1983
The base class for all geometric element types.
Definition: elem.h:86
const class libmesh_nullptr_t libmesh_nullptr
IterBase * end
const Elem * neighbor_ptr(unsigned int i) const
Definition: elem.h:1821
virtual element_iterator active_local_elements_begin()=0
virtual unsigned int n_sides() const =0
unsigned int level() const
Definition: elem.h:2190
dof_id_type node_id(const unsigned int i) const
Definition: elem.h:1689
virtual element_iterator active_local_elements_end()=0
uint8_t dof_id_type
Definition: id_types.h:64
void libMesh::MeshTools::find_nodal_neighbors ( const MeshBase mesh,
const Node n,
const 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 727 of file mesh_tools.C.

References libMesh::Elem::active(), libMesh::EDGE2, libMesh::EDGE3, libMesh::EDGE4, libMesh::Utility::enum_to_string(), libMesh::DofObject::id(), libMesh::invalid_uint, libMesh::Elem::is_node_on_edge(), libMesh::libmesh_assert(), libmesh_nullptr, libMesh::Elem::local_node(), libMesh::Elem::n_edges(), libMesh::Elem::n_nodes(), libMesh::Elem::node_id(), libMesh::Elem::node_ptr(), and libMesh::Elem::type().

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

731 {
732  // We'll refer back to the Node ID several times
733  dof_id_type global_id = node.id();
734 
735  // We'll construct a std::set<const Node *> for more efficient
736  // searching while finding the nodal neighbors, and return it to the
737  // user in a std::vector.
738  std::set<const Node *> neighbor_set;
739 
740  // Iterators to iterate through the elements that include this node
741  std::vector<const Elem *>::const_iterator
742  el = nodes_to_elem_map[global_id].begin(),
743  end_el = nodes_to_elem_map[global_id].end();
744 
745  // Look through the elements that contain this node
746  // find the local node id... then find the side that
747  // node lives on in the element
748  // next, look for the _other_ node on that side
749  // That other node is a "nodal_neighbor"... save it
750  for (; el != end_el; ++el)
751  {
752  // Grab an Elem pointer to use in the subsequent loop
753  const Elem * elem = *el;
754 
755  // We only care about active elements...
756  if (elem->active())
757  {
758  // Which local node number is global_id?
759  unsigned local_node_number = elem->local_node(global_id);
760 
761  // Make sure it was found
762  libmesh_assert_not_equal_to(local_node_number, libMesh::invalid_uint);
763 
764  // If this element has no edges, the edge-based algorithm below doesn't make sense.
765  if (elem->n_edges() == 0)
766  {
767  switch (elem->type())
768  {
769  case EDGE2:
770  {
771  switch (local_node_number)
772  {
773  case 0:
774  // The other node is a nodal neighbor
775  neighbor_set.insert(elem->node_ptr(1));
776  break;
777 
778  case 1:
779  // The other node is a nodal neighbor
780  neighbor_set.insert(elem->node_ptr(0));
781  break;
782 
783  default:
784  libmesh_error_msg("Invalid local node number: " << local_node_number << " found." << std::endl);
785  }
786  break;
787  }
788 
789  case EDGE3:
790  {
791  switch (local_node_number)
792  {
793  // The outside nodes have node 2 as a neighbor
794  case 0:
795  case 1:
796  neighbor_set.insert(elem->node_ptr(2));
797  break;
798 
799  // The middle node has the outer nodes as neighbors
800  case 2:
801  neighbor_set.insert(elem->node_ptr(0));
802  neighbor_set.insert(elem->node_ptr(1));
803  break;
804 
805  default:
806  libmesh_error_msg("Invalid local node number: " << local_node_number << " found." << std::endl);
807  }
808  break;
809  }
810 
811  case EDGE4:
812  {
813  switch (local_node_number)
814  {
815  case 0:
816  // The left-middle node is a nodal neighbor
817  neighbor_set.insert(elem->node_ptr(2));
818  break;
819 
820  case 1:
821  // The right-middle node is a nodal neighbor
822  neighbor_set.insert(elem->node_ptr(3));
823  break;
824 
825  // The left-middle node
826  case 2:
827  neighbor_set.insert(elem->node_ptr(0));
828  neighbor_set.insert(elem->node_ptr(3));
829  break;
830 
831  // The right-middle node
832  case 3:
833  neighbor_set.insert(elem->node_ptr(1));
834  neighbor_set.insert(elem->node_ptr(2));
835  break;
836 
837  default:
838  libmesh_error_msg("Invalid local node number: " << local_node_number << " found." << std::endl);
839  }
840  break;
841  }
842 
843  default:
844  libmesh_error_msg("Unrecognized ElemType: " << Utility::enum_to_string(elem->type()) << std::endl);
845  }
846  }
847 
848  // Index of the current edge
849  unsigned current_edge = 0;
850 
851  while (current_edge < elem->n_edges())
852  {
853  // Find the edge the node is on
854  bool found_edge = false;
855  for (; current_edge<elem->n_edges(); ++current_edge)
856  if (elem->is_node_on_edge(local_node_number, current_edge))
857  {
858  found_edge = true;
859  break;
860  }
861 
862  // Did we find one?
863  if (found_edge)
864  {
865  const Node * node_to_save = libmesh_nullptr;
866 
867  // Find another node in this element on this edge
868  for (unsigned other_node_this_edge = 0; other_node_this_edge<elem->n_nodes(); other_node_this_edge++)
869  if ( (elem->is_node_on_edge(other_node_this_edge, current_edge)) && // On the current edge
870  (elem->node_id(other_node_this_edge) != global_id)) // But not the original node
871  {
872  // We've found a nodal neighbor! Save a pointer to it..
873  node_to_save = elem->node_ptr(other_node_this_edge);
874  break;
875  }
876 
877  // Make sure we found something
878  libmesh_assert(node_to_save != libmesh_nullptr);
879 
880  neighbor_set.insert(node_to_save);
881  }
882 
883  // Keep looking for edges, node may be on more than one edge
884  current_edge++;
885  }
886  } // if (elem->active())
887  } // for
888 
889  // Assign the entries from the set to the vector. Note: this
890  // replaces any existing contents in neighbors and modifies its size
891  // accordingly.
892  neighbors.assign(neighbor_set.begin(), neighbor_set.end());
893 }
virtual bool is_node_on_edge(const unsigned int n, const unsigned int e) const =0
A geometric point in (x,y,z) space associated with a DOF.
Definition: node.h:52
bool active() const
Definition: elem.h:2059
const unsigned int invalid_uint
Definition: libmesh.h:184
virtual ElemType type() const =0
virtual unsigned int n_edges() const =0
The base class for all geometric element types.
Definition: elem.h:86
const class libmesh_nullptr_t libmesh_nullptr
libmesh_assert(j)
virtual unsigned int n_nodes() const =0
const Node * node_ptr(const unsigned int i) const
Definition: elem.h:1730
std::string enum_to_string(const T e)
dof_id_type node_id(const unsigned int i) const
Definition: elem.h:1689
unsigned int local_node(const dof_id_type i) const
Definition: elem.h:1710
uint8_t dof_id_type
Definition: id_types.h:64
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 668 of file mesh_tools.C.

References libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::Elem::n_nodes(), libMesh::Elem::node_id(), and libMesh::Elem::subactive().

Referenced by weight().

670 {
672  const MeshBase::const_element_iterator end_el = mesh.elements_end();
673  for ( ; el != end_el; ++el)
674  {
675  const Elem * elem = (*el);
676  if (!elem->subactive())
677  for (unsigned int n=0; n<elem->n_nodes(); ++n)
678  not_subactive_node_ids.insert(elem->node_id(n));
679  }
680 }
bool subactive() const
Definition: elem.h:2077
The base class for all geometric element types.
Definition: elem.h:86
virtual unsigned int n_nodes() const =0
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
dof_id_type node_id(const unsigned int i) const
Definition: elem.h:1689
void libMesh::MeshTools::libmesh_assert_connected_nodes ( const MeshBase mesh)

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

This will fail in the most general case. When DistributedMesh 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 1246 of file mesh_tools.C.

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

Referenced by weight().

1247 {
1248  LOG_SCOPE("libmesh_assert_connected_nodes()", "MeshTools");
1249 
1250  std::set<const Node *> used_nodes;
1251 
1252  const MeshBase::const_element_iterator el_end =
1253  mesh.elements_end();
1255  mesh.elements_begin(); el != el_end; ++el)
1256  {
1257  const Elem * elem = *el;
1258  libmesh_assert (elem);
1259 
1260  for (unsigned int n=0; n<elem->n_nodes(); ++n)
1261  used_nodes.insert(elem->node_ptr(n));
1262  }
1263 
1264  const MeshBase::const_node_iterator node_end = mesh.nodes_end();
1265 
1266  for (MeshBase::const_node_iterator node_it = mesh.nodes_begin();
1267  node_it != node_end; ++node_it)
1268  {
1269  Node * node = *node_it;
1270  libmesh_assert(node);
1271  libmesh_assert(used_nodes.count(node));
1272  }
1273 }
A geometric point in (x,y,z) space associated with a DOF.
Definition: node.h:52
The base class for all geometric element types.
Definition: elem.h:86
libmesh_assert(j)
virtual unsigned int n_nodes() const =0
virtual node_iterator nodes_begin()=0
virtual element_iterator elements_begin()=0
const Node * node_ptr(const unsigned int i) const
Definition: elem.h:1730
virtual element_iterator elements_end()=0
virtual node_iterator nodes_end()=0
void libMesh::MeshTools::libmesh_assert_equal_n_systems ( const MeshBase mesh)

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

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

Referenced by libMesh::MeshCommunication::redistribute(), and weight().

1003 {
1004  LOG_SCOPE("libmesh_assert_equal_n_systems()", "MeshTools");
1005 
1007  mesh.elements_begin();
1008  const MeshBase::const_element_iterator el_end =
1009  mesh.elements_end();
1010  if (el == el_end)
1011  return;
1012 
1013  const unsigned int n_sys = (*el)->n_systems();
1014 
1015  for (; el != el_end; ++el)
1016  {
1017  const Elem * elem = *el;
1018  libmesh_assert_equal_to (elem->n_systems(), n_sys);
1019  }
1020 
1022  mesh.nodes_begin();
1023  const MeshBase::const_node_iterator node_end =
1024  mesh.nodes_end();
1025 
1026  if (node_it == node_end)
1027  return;
1028 
1029  for (; node_it != node_end; ++node_it)
1030  {
1031  const Node * node = *node_it;
1032  libmesh_assert_equal_to (node->n_systems(), n_sys);
1033  }
1034 }
A geometric point in (x,y,z) space associated with a DOF.
Definition: node.h:52
The base class for all geometric element types.
Definition: elem.h:86
virtual node_iterator nodes_begin()=0
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
virtual node_iterator nodes_end()=0
unsigned int n_systems() const
Definition: dof_object.h:718
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 1132 of file mesh_tools.C.

References libMesh::Elem::child_ptr(), 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_ptr(), and libMesh::Elem::parent().

Referenced by weight().

1134 {
1135  const MeshBase::const_element_iterator el_end =
1136  mesh.elements_end();
1138  mesh.elements_begin(); el != el_end; ++el)
1139  {
1140  const Elem * elem = *el;
1141  libmesh_assert (elem);
1142  libmesh_assert_not_equal_to (elem->parent(), bad_elem);
1143  for (unsigned int n=0; n != elem->n_neighbors(); ++n)
1144  libmesh_assert_not_equal_to (elem->neighbor_ptr(n), bad_elem);
1145 #ifdef LIBMESH_ENABLE_AMR
1146  if (elem->has_children())
1147  for (unsigned int c=0; c != elem->n_children(); ++c)
1148  libmesh_assert_not_equal_to (elem->child_ptr(c), bad_elem);
1149 #endif
1150  }
1151 }
bool has_children() const
Definition: elem.h:2097
virtual unsigned int n_neighbors() const
Definition: elem.h:557
const Elem * parent() const
Definition: elem.h:2148
The base class for all geometric element types.
Definition: elem.h:86
libmesh_assert(j)
const Elem * neighbor_ptr(unsigned int i) const
Definition: elem.h:1821
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
const Elem * child_ptr(unsigned int i) const
Definition: elem.h:2247
virtual unsigned int n_children() const =0
void libMesh::MeshTools::libmesh_assert_old_dof_objects ( const MeshBase mesh)

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

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

Referenced by weight().

1040 {
1041  LOG_SCOPE("libmesh_assert_old_dof_objects()", "MeshTools");
1042 
1044  mesh.elements_begin();
1045  const MeshBase::const_element_iterator el_end =
1046  mesh.elements_end();
1047 
1048  for (; el != el_end; ++el)
1049  {
1050  const Elem * elem = *el;
1051 
1052  if (elem->refinement_flag() == Elem::JUST_REFINED ||
1053  elem->refinement_flag() == Elem::INACTIVE)
1054  continue;
1055 
1056  if (elem->has_dofs())
1058 
1059  for (unsigned int n=0; n != elem->n_nodes(); ++n)
1060  {
1061  const Node & node = elem->node_ref(n);
1062  if (node.has_dofs())
1064  }
1065  }
1066 }
bool has_dofs(const unsigned int s=libMesh::invalid_uint) const
Definition: dof_object.h:847
A geometric point in (x,y,z) space associated with a DOF.
Definition: node.h:52
The base class for all geometric element types.
Definition: elem.h:86
libmesh_assert(j)
virtual unsigned int n_nodes() const =0
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
const Node & node_ref(const unsigned int i) const
Definition: elem.h:1752
DofObject * old_dof_object
Definition: dof_object.h:89
RefinementState refinement_flag() const
Definition: elem.h:2304
template<typename DofObjectSubclass >
void libMesh::MeshTools::libmesh_assert_parallel_consistent_procids ( const MeshBase mesh)

A function for verifying that processor assignment is parallel consistent (every processor agrees on the processor id of each dof object it can see)

Referenced by weight().

Definition at line 1567 of file mesh_tools.C.

References libMesh::ParallelObject::comm(), libMesh::libmesh_assert(), std::max(), libMesh::Parallel::Communicator::max(), libMesh::MeshBase::max_elem_id(), mesh, std::min(), libMesh::Parallel::Communicator::min(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), and libMesh::MeshBase::query_elem_ptr().

1568 {
1569  LOG_SCOPE("libmesh_assert_parallel_consistent_procids()", "MeshTools");
1570 
1571  if (mesh.n_processors() == 1)
1572  return;
1573 
1574  libmesh_parallel_only(mesh.comm());
1575 
1576  // We want this test to be valid even when called even after nodes
1577  // have been added asynchronously but before they're renumbered
1578  dof_id_type parallel_max_elem_id = mesh.max_elem_id();
1579  mesh.comm().max(parallel_max_elem_id);
1580 
1581  // Check processor ids for consistency between processors
1582 
1583  for (dof_id_type i=0; i != parallel_max_elem_id; ++i)
1584  {
1585  const Elem * elem = mesh.query_elem_ptr(i);
1586 
1587  processor_id_type min_id =
1588  elem ? elem->processor_id() :
1590  mesh.comm().min(min_id);
1591 
1592  processor_id_type max_id =
1593  elem ? elem->processor_id() :
1595  mesh.comm().max(max_id);
1596 
1597  if (elem)
1598  {
1599  libmesh_assert_equal_to (min_id, elem->processor_id());
1600  libmesh_assert_equal_to (max_id, elem->processor_id());
1601  }
1602 
1603  if (min_id == mesh.processor_id())
1604  libmesh_assert(elem);
1605  }
1606 }
processor_id_type n_processors() const
The base class for all geometric element types.
Definition: elem.h:86
uint8_t processor_id_type
Definition: id_types.h:99
long double max(long double a, double b)
libmesh_assert(j)
virtual dof_id_type max_elem_id() const =0
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
const Parallel::Communicator & comm() const
long double min(long double a, double b)
processor_id_type processor_id() const
uint8_t dof_id_type
Definition: id_types.h:64
processor_id_type processor_id() const
Definition: dof_object.h:686

Definition at line 1661 of file mesh_tools.C.

References libMesh::ParallelObject::comm(), libMesh::DofObject::id(), libMesh::libmesh_assert(), libMesh::MeshBase::local_elements_begin(), libMesh::MeshBase::local_elements_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::Elem::node_ref(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), and libMesh::MeshBase::query_node_ptr().

Referenced by correct_node_proc_ids().

1662 {
1663  LOG_SCOPE("libmesh_assert_parallel_consistent_procids()", "MeshTools");
1664 
1665  if (mesh.n_processors() == 1)
1666  return;
1667 
1668  libmesh_parallel_only(mesh.comm());
1669 
1670  // We want this test to be valid even when called even after nodes
1671  // have been added asynchronously but before they're renumbered
1672  dof_id_type parallel_max_node_id = mesh.max_node_id();
1673  mesh.comm().max(parallel_max_node_id);
1674 
1675  std::vector<bool> node_touched_by_anyone(parallel_max_node_id, false);
1676 
1677  const MeshBase::const_element_iterator el_end =
1678  mesh.local_elements_end();
1680  mesh.local_elements_begin(); el != el_end; ++el)
1681  {
1682  const Elem * elem = *el;
1683  libmesh_assert (elem);
1684 
1685  for (unsigned int i=0; i != elem->n_nodes(); ++i)
1686  {
1687  const Node & node = elem->node_ref(i);
1688  dof_id_type nodeid = node.id();
1689  node_touched_by_anyone[nodeid] = true;
1690  }
1691  }
1692  mesh.comm().max(node_touched_by_anyone);
1693 
1694  // Check processor ids for consistency between processors
1695  // on any node an element touches
1696  for (dof_id_type i=0; i != parallel_max_node_id; ++i)
1697  {
1698  if (!node_touched_by_anyone[i])
1699  continue;
1700 
1701  const Node * node = mesh.query_node_ptr(i);
1702 
1703  processor_id_type min_id =
1704  node ? node->processor_id() :
1706  mesh.comm().min(min_id);
1707 
1708  processor_id_type max_id =
1709  node ? node->processor_id() :
1711  mesh.comm().max(max_id);
1712 
1713  if (node)
1714  {
1715  libmesh_assert_equal_to (min_id, node->processor_id());
1716  libmesh_assert_equal_to (max_id, node->processor_id());
1717  }
1718 
1719  if (min_id == mesh.processor_id())
1720  libmesh_assert(node);
1721  }
1722 }
A geometric point in (x,y,z) space associated with a DOF.
Definition: node.h:52
virtual element_iterator local_elements_begin()=0
processor_id_type n_processors() const
virtual dof_id_type max_node_id() const =0
The base class for all geometric element types.
Definition: elem.h:86
uint8_t processor_id_type
Definition: id_types.h:99
long double max(long double a, double b)
libmesh_assert(j)
virtual unsigned int n_nodes() const =0
virtual const Node * query_node_ptr(const dof_id_type i) const =0
virtual element_iterator local_elements_end()=0
const Node & node_ref(const unsigned int i) const
Definition: elem.h:1752
const Parallel::Communicator & comm() const
dof_id_type id() const
Definition: dof_object.h:624
long double min(long double a, double b)
processor_id_type processor_id() const
uint8_t dof_id_type
Definition: id_types.h:64
processor_id_type processor_id() const
Definition: dof_object.h:686
template<typename DofObjectSubclass >
void libMesh::MeshTools::libmesh_assert_topology_consistent_procids ( const MeshBase mesh)

A function for verifying that processor assignment is topologically 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).

Referenced by weight().

Definition at line 1513 of file mesh_tools.C.

References libMesh::Elem::active(), libMesh::Elem::child_ptr(), libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::Elem::has_children(), libMesh::libmesh_assert(), libMesh::libmesh_ignore(), mesh, libMesh::Elem::n_children(), libMesh::Elem::parent(), libMesh::DofObject::processor_id(), libMesh::remote_elem, and libMesh::Elem::subactive().

1514 {
1515  LOG_SCOPE("libmesh_assert_topology_consistent_procids()", "MeshTools");
1516 
1517  // This parameter is not used when !LIBMESH_ENABLE_AMR
1518  libmesh_ignore(mesh);
1519 
1520  // If we're adaptively refining, check processor ids for consistency
1521  // between parents and children.
1522 #ifdef LIBMESH_ENABLE_AMR
1523 
1524  // Ancestor elements we won't worry about, but subactive and active
1525  // elements ought to have parents with consistent processor ids
1526 
1527  const MeshBase::const_element_iterator el_end =
1528  mesh.elements_end();
1530  mesh.elements_begin(); el != el_end; ++el)
1531  {
1532  const Elem * elem = *el;
1533  libmesh_assert(elem);
1534 
1535  if (!elem->active() && !elem->subactive())
1536  continue;
1537 
1538  const Elem * parent = elem->parent();
1539 
1540  if (parent)
1541  {
1542  libmesh_assert(parent->has_children());
1543  processor_id_type parent_procid = parent->processor_id();
1544  bool matching_child_id = false;
1545  for (unsigned int c = 0; c != parent->n_children(); ++c)
1546  {
1547  const Elem * child = parent->child_ptr(c);
1548  libmesh_assert(child);
1549 
1550  // If we've got a remote_elem then we don't know whether
1551  // it's responsible for the parent's processor id; all
1552  // we can do is assume it is and let its processor fail
1553  // an assert if there's something wrong.
1554  if (child == remote_elem ||
1555  child->processor_id() == parent_procid)
1556  matching_child_id = true;
1557  }
1558  libmesh_assert(matching_child_id);
1559  }
1560  }
1561 #endif
1562 }
bool has_children() const
Definition: elem.h:2097
bool subactive() const
Definition: elem.h:2077
bool active() const
Definition: elem.h:2059
const Elem * parent() const
Definition: elem.h:2148
The base class for all geometric element types.
Definition: elem.h:86
uint8_t processor_id_type
Definition: id_types.h:99
libmesh_assert(j)
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
const Elem * child_ptr(unsigned int i) const
Definition: elem.h:2247
virtual unsigned int n_children() const =0
void libmesh_ignore(const T &)
processor_id_type processor_id() const
Definition: dof_object.h:686
const RemoteElem * remote_elem
Definition: remote_elem.C:57

Definition at line 1611 of file mesh_tools.C.

References libMesh::ParallelObject::comm(), libMesh::DofObject::id(), libMesh::libmesh_assert(), libMesh::MeshBase::local_elements_begin(), libMesh::MeshBase::local_elements_end(), libMesh::MeshBase::local_nodes_begin(), libMesh::MeshBase::local_nodes_end(), libMesh::Parallel::Communicator::max(), libMesh::MeshBase::max_node_id(), mesh, libMesh::Elem::n_nodes(), libMesh::ParallelObject::n_processors(), and libMesh::Elem::node_ref().

1612 {
1613  LOG_SCOPE("libmesh_assert_topology_consistent_procids()", "MeshTools");
1614 
1615  if (mesh.n_processors() == 1)
1616  return;
1617 
1618  libmesh_parallel_only(mesh.comm());
1619 
1620  // We want this test to be valid even when called even after nodes
1621  // have been added asynchronously but before they're renumbered
1622  dof_id_type parallel_max_node_id = mesh.max_node_id();
1623  mesh.comm().max(parallel_max_node_id);
1624 
1625  std::vector<bool> node_touched_by_me(parallel_max_node_id, false);
1626 
1627  const MeshBase::const_element_iterator el_end =
1628  mesh.local_elements_end();
1630  mesh.local_elements_begin(); el != el_end; ++el)
1631  {
1632  const Elem * elem = *el;
1633  libmesh_assert (elem);
1634 
1635  for (unsigned int i=0; i != elem->n_nodes(); ++i)
1636  {
1637  const Node & node = elem->node_ref(i);
1638  dof_id_type nodeid = node.id();
1639  node_touched_by_me[nodeid] = true;
1640  }
1641  }
1642  std::vector<bool> node_touched_by_anyone(node_touched_by_me);
1643  mesh.comm().max(node_touched_by_anyone);
1644 
1645  const MeshBase::const_node_iterator nd_end = mesh.local_nodes_end();
1647  nd != nd_end; ++nd)
1648  {
1649  const Node * node = *nd;
1650  libmesh_assert(node);
1651 
1652  dof_id_type nodeid = node->id();
1653  libmesh_assert(!node_touched_by_anyone[nodeid] ||
1654  node_touched_by_me[nodeid]);
1655  }
1656 }
A geometric point in (x,y,z) space associated with a DOF.
Definition: node.h:52
virtual element_iterator local_elements_begin()=0
processor_id_type n_processors() const
virtual dof_id_type max_node_id() const =0
The base class for all geometric element types.
Definition: elem.h:86
libmesh_assert(j)
virtual unsigned int n_nodes() const =0
virtual node_iterator local_nodes_end()=0
virtual element_iterator local_elements_end()=0
const Node & node_ref(const unsigned int i) const
Definition: elem.h:1752
virtual node_iterator local_nodes_begin()=0
const Parallel::Communicator & comm() const
dof_id_type id() const
Definition: dof_object.h:624
uint8_t dof_id_type
Definition: id_types.h:64
void libMesh::MeshTools::libmesh_assert_valid_amr_elem_ids ( const MeshBase mesh)

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

Definition at line 1182 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(), and weight().

1183 {
1184  LOG_SCOPE("libmesh_assert_valid_amr_elem_ids()", "MeshTools");
1185 
1186  const MeshBase::const_element_iterator el_end =
1187  mesh.elements_end();
1189  mesh.elements_begin(); el != el_end; ++el)
1190  {
1191  const Elem * elem = *el;
1192  libmesh_assert (elem);
1193 
1194  const Elem * parent = elem->parent();
1195 
1196  if (parent)
1197  {
1198  libmesh_assert_greater_equal (elem->id(), parent->id());
1199  libmesh_assert_greater_equal (elem->processor_id(), parent->processor_id());
1200  }
1201  }
1202 }
const Elem * parent() const
Definition: elem.h:2148
The base class for all geometric element types.
Definition: elem.h:86
libmesh_assert(j)
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
dof_id_type id() const
Definition: dof_object.h:624
processor_id_type processor_id() const
Definition: dof_object.h:686
void libMesh::MeshTools::libmesh_assert_valid_amr_interior_parents ( const MeshBase mesh)

A function for verifying that any interior_parent pointers on elements are consistent with AMR (parents' interior_parents are interior_parents' parents)

Definition at line 1206 of file mesh_tools.C.

References libMesh::Elem::dim(), libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::Elem::interior_parent(), libMesh::Elem::level(), libMesh::libmesh_assert(), libMesh::Elem::parent(), libMesh::remote_elem, and libMesh::Elem::top_parent().

Referenced by libMesh::UnstructuredMesh::find_neighbors(), and weight().

1207 {
1208  LOG_SCOPE("libmesh_assert_valid_amr_interior_parents()", "MeshTools");
1209 
1210  const MeshBase::const_element_iterator el_end =
1211  mesh.elements_end();
1213  mesh.elements_begin(); el != el_end; ++el)
1214  {
1215  const Elem * elem = *el;
1216  libmesh_assert (elem);
1217 
1218  // We can skip to the next element if we're full-dimension
1219  // and therefore don't have any interior parents
1220  if (elem->dim() >= LIBMESH_DIM)
1221  continue;
1222 
1223  const Elem * ip = elem->interior_parent();
1224 
1225  const Elem * parent = elem->parent();
1226 
1227  if (ip && (ip != remote_elem) && parent)
1228  {
1229  libmesh_assert_equal_to (ip->top_parent(),
1230  elem->top_parent()->interior_parent());
1231 
1232  if (ip->level() == elem->level())
1233  libmesh_assert_equal_to (ip->parent(),
1234  parent->interior_parent());
1235  else
1236  {
1237  libmesh_assert_less (ip->level(), elem->level());
1238  libmesh_assert_equal_to (ip, parent->interior_parent());
1239  }
1240  }
1241  }
1242 }
const Elem * parent() const
Definition: elem.h:2148
const Elem * interior_parent() const
Definition: elem.C:941
The base class for all geometric element types.
Definition: elem.h:86
libmesh_assert(j)
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
virtual unsigned int dim() const =0
unsigned int level() const
Definition: elem.h:2190
const Elem * top_parent() const
Definition: elem.h:2172
const RemoteElem * remote_elem
Definition: remote_elem.C:57
void libMesh::MeshTools::libmesh_assert_valid_boundary_ids ( const MeshBase mesh)

A function for verifying that boundary condition ids match across processors.

Definition at line 1279 of file mesh_tools.C.

References libMesh::ParallelObject::comm(), libMesh::MeshBase::get_boundary_info(), libMesh::BoundaryInfo::invalid_id, libMesh::libmesh_assert(), libmesh_nullptr, libMesh::Parallel::Communicator::max(), libMesh::MeshBase::max_elem_id(), libMesh::Elem::n_edges(), n_nodes, libMesh::Elem::n_nodes(), libMesh::ParallelObject::n_processors(), libMesh::Elem::n_sides(), libMesh::Elem::node_ptr(), libMesh::MeshBase::query_elem_ptr(), and libMesh::Parallel::Communicator::semiverify().

Referenced by libMesh::DofMap::create_dof_constraints(), libMesh::MeshCommunication::gather(), libMesh::MeshBase::prepare_for_use(), and weight().

1280 {
1281  LOG_SCOPE("libmesh_assert_valid_boundary_ids()", "MeshTools");
1282 
1283  if (mesh.n_processors() == 1)
1284  return;
1285 
1286  libmesh_parallel_only(mesh.comm());
1287 
1288  const BoundaryInfo & boundary_info = mesh.get_boundary_info();
1289 
1290  dof_id_type pmax_elem_id = mesh.max_elem_id();
1291  mesh.comm().max(pmax_elem_id);
1292 
1293  for (dof_id_type i=0; i != pmax_elem_id; ++i)
1294  {
1295  const Elem * elem = mesh.query_elem_ptr(i);
1296  const unsigned int my_n_nodes = elem ? elem->n_nodes() : 0;
1297  const unsigned int my_n_edges = elem ? elem->n_edges() : 0;
1298  const unsigned int my_n_sides = elem ? elem->n_sides() : 0;
1299  unsigned int n_nodes = my_n_nodes,
1300  n_edges = my_n_edges,
1301  n_sides = my_n_sides;
1302 
1303  mesh.comm().max(n_nodes);
1304  mesh.comm().max(n_edges);
1305  mesh.comm().max(n_sides);
1306 
1307  if (elem)
1308  {
1309  libmesh_assert_equal_to(my_n_nodes, n_nodes);
1310  libmesh_assert_equal_to(my_n_edges, n_edges);
1311  libmesh_assert_equal_to(my_n_sides, n_sides);
1312  }
1313 
1314  // Let's test all IDs on the element with one communication
1315  // rather than n_nodes + n_edges + n_sides communications, to
1316  // cut down on latency in dbg modes.
1317  std::vector<boundary_id_type> all_bcids;
1318 
1319  for (unsigned int n=0; n != n_nodes; ++n)
1320  {
1321  std::vector<boundary_id_type> bcids;
1322  if (elem)
1323  {
1324  boundary_info.boundary_ids(elem->node_ptr(n), bcids);
1325 
1326  // Ordering of boundary ids shouldn't matter
1327  std::sort(bcids.begin(), bcids.end());
1328  }
1329 // libmesh_assert(mesh.comm().semiverify
1330 // (elem ? &bcids : libmesh_nullptr));
1331 
1332  all_bcids.insert(all_bcids.end(), bcids.begin(),
1333  bcids.end());
1334  // Separator
1335  all_bcids.push_back(BoundaryInfo::invalid_id);
1336  }
1337 
1338  for (unsigned short e=0; e != n_edges; ++e)
1339  {
1340  std::vector<boundary_id_type> bcids;
1341 
1342  if (elem)
1343  {
1344  boundary_info.edge_boundary_ids(elem, e, bcids);
1345 
1346  // Ordering of boundary ids shouldn't matter
1347  std::sort(bcids.begin(), bcids.end());
1348  }
1349 
1350 // libmesh_assert(mesh.comm().semiverify
1351 // (elem ? &bcids : libmesh_nullptr));
1352 
1353  all_bcids.insert(all_bcids.end(), bcids.begin(),
1354  bcids.end());
1355  // Separator
1356  all_bcids.push_back(BoundaryInfo::invalid_id);
1357 
1358  if (elem)
1359  {
1360  boundary_info.raw_edge_boundary_ids(elem, e, bcids);
1361 
1362  // Ordering of boundary ids shouldn't matter
1363  std::sort(bcids.begin(), bcids.end());
1364 
1365  all_bcids.insert(all_bcids.end(), bcids.begin(),
1366  bcids.end());
1367  // Separator
1368  all_bcids.push_back(BoundaryInfo::invalid_id);
1369  }
1370 
1371 // libmesh_assert(mesh.comm().semiverify
1372 // (elem ? &bcids : libmesh_nullptr));
1373  }
1374 
1375  for (unsigned short s=0; s != n_sides; ++s)
1376  {
1377  std::vector<boundary_id_type> bcids;
1378 
1379  if (elem)
1380  {
1381  boundary_info.boundary_ids(elem, s, bcids);
1382 
1383  // Ordering of boundary ids shouldn't matter
1384  std::sort(bcids.begin(), bcids.end());
1385 
1386  all_bcids.insert(all_bcids.end(), bcids.begin(),
1387  bcids.end());
1388  // Separator
1389  all_bcids.push_back(BoundaryInfo::invalid_id);
1390  }
1391 
1392 // libmesh_assert(mesh.comm().semiverify
1393 // (elem ? &bcids : libmesh_nullptr));
1394 
1395  if (elem)
1396  {
1397  boundary_info.raw_boundary_ids(elem, s, bcids);
1398 
1399  // Ordering of boundary ids shouldn't matter
1400  std::sort(bcids.begin(), bcids.end());
1401 
1402  all_bcids.insert(all_bcids.end(), bcids.begin(),
1403  bcids.end());
1404  // Separator
1405  all_bcids.push_back(BoundaryInfo::invalid_id);
1406  }
1407 
1408 // libmesh_assert(mesh.comm().semiverify
1409 // (elem ? &bcids : libmesh_nullptr));
1410  }
1411 
1412  for (unsigned short sf=0; sf != 2; ++sf)
1413  {
1414  std::vector<boundary_id_type> bcids;
1415 
1416  if (elem)
1417  {
1418  boundary_info.shellface_boundary_ids(elem, sf, bcids);
1419 
1420  // Ordering of boundary ids shouldn't matter
1421  std::sort(bcids.begin(), bcids.end());
1422 
1423  all_bcids.insert(all_bcids.end(), bcids.begin(),
1424  bcids.end());
1425  // Separator
1426  all_bcids.push_back(BoundaryInfo::invalid_id);
1427  }
1428 
1429 // libmesh_assert(mesh.comm().semiverify
1430 // (elem ? &bcids : libmesh_nullptr));
1431 
1432  if (elem)
1433  {
1434  boundary_info.raw_shellface_boundary_ids(elem, sf, bcids);
1435 
1436  // Ordering of boundary ids shouldn't matter
1437  std::sort(bcids.begin(), bcids.end());
1438 
1439  all_bcids.insert(all_bcids.end(), bcids.begin(),
1440  bcids.end());
1441  // Separator
1442  all_bcids.push_back(BoundaryInfo::invalid_id);
1443  }
1444 
1445 // libmesh_assert(mesh.comm().semiverify
1446 // (elem ? &bcids : libmesh_nullptr));
1447  }
1448 
1450  (elem ? &all_bcids : libmesh_nullptr));
1451  }
1452 }
const BoundaryInfo & get_boundary_info() const
Definition: mesh_base.h:114
virtual unsigned int n_edges() const =0
processor_id_type n_processors() const
The base class for all geometric element types.
Definition: elem.h:86
const class libmesh_nullptr_t libmesh_nullptr
libmesh_assert(j)
virtual unsigned int n_nodes() const =0
virtual dof_id_type max_elem_id() const =0
const dof_id_type n_nodes
Definition: tecplot_io.C:67
const Node * node_ptr(const unsigned int i) const
Definition: elem.h:1730
Used by the Mesh to keep track of boundary nodes and elements.
Definition: boundary_info.h:56
virtual unsigned int n_sides() const =0
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
const Parallel::Communicator & comm() const
uint8_t dof_id_type
Definition: id_types.h:64
void libMesh::MeshTools::libmesh_assert_valid_dof_ids ( const MeshBase mesh,
unsigned int  sysnum = libMesh::invalid_uint 
)

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

Verify a particular system by specifying that system's number, or verify all systems at once by leaving sysnum unspecified.

Definition at line 1454 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_ptr(), and libMesh::MeshBase::query_node_ptr().

Referenced by libMesh::DofMap::distribute_dofs(), and weight().

1455 {
1456  LOG_SCOPE("libmesh_assert_valid_dof_ids()", "MeshTools");
1457 
1458  if (mesh.n_processors() == 1)
1459  return;
1460 
1461  libmesh_parallel_only(mesh.comm());
1462 
1463  dof_id_type pmax_elem_id = mesh.max_elem_id();
1464  mesh.comm().max(pmax_elem_id);
1465 
1466  for (dof_id_type i=0; i != pmax_elem_id; ++i)
1467  assert_semiverify_dofobj(mesh.comm(),
1468  mesh.query_elem_ptr(i),
1469  sysnum);
1470 
1471  dof_id_type pmax_node_id = mesh.max_node_id();
1472  mesh.comm().max(pmax_node_id);
1473 
1474  for (dof_id_type i=0; i != pmax_node_id; ++i)
1475  assert_semiverify_dofobj(mesh.comm(),
1476  mesh.query_node_ptr(i),
1477  sysnum);
1478 }
processor_id_type n_processors() const
virtual dof_id_type max_node_id() const =0
virtual dof_id_type max_elem_id() const =0
virtual const Node * query_node_ptr(const dof_id_type i) const =0
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
const Parallel::Communicator & comm() const
uint8_t dof_id_type
Definition: id_types.h:64
void libMesh::MeshTools::libmesh_assert_valid_elem_ids ( const MeshBase mesh)

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

Definition at line 1155 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::DistributedMesh::renumber_nodes_and_elements(), and weight().

1156 {
1157  LOG_SCOPE("libmesh_assert_valid_elem_ids()", "MeshTools");
1158 
1159  processor_id_type lastprocid = 0;
1160  dof_id_type lastelemid = 0;
1161 
1162  const MeshBase::const_element_iterator el_end =
1163  mesh.active_elements_end();
1165  mesh.active_elements_begin(); el != el_end; ++el)
1166  {
1167  const Elem * elem = *el;
1168  libmesh_assert (elem);
1169  processor_id_type elemprocid = elem->processor_id();
1170  dof_id_type elemid = elem->id();
1171 
1172  libmesh_assert_greater_equal (elemid, lastelemid);
1173  libmesh_assert_greater_equal (elemprocid, lastprocid);
1174 
1175  lastelemid = elemid;
1176  lastprocid = elemprocid;
1177  }
1178 }
The base class for all geometric element types.
Definition: elem.h:86
uint8_t processor_id_type
Definition: id_types.h:99
libmesh_assert(j)
virtual element_iterator active_elements_begin()=0
virtual element_iterator active_elements_end()=0
dof_id_type id() const
Definition: dof_object.h:624
uint8_t dof_id_type
Definition: id_types.h:64
processor_id_type processor_id() const
Definition: dof_object.h:686
void libMesh::MeshTools::libmesh_assert_valid_neighbors ( const MeshBase mesh,
bool  assert_valid_remote_elems = true 
)

A function for verifying that neighbor connectivity is correct (each element is a neighbor of or descendant of a neighbor of its neighbors) and consistent (each neighbor link goes to either the same neighbor or to a RemoteElem on each processor)

If assert_valid_remote_elems is set to false, then no error will be thrown for neighbor links where a remote_elem should exist but NULL exists instead.

Definition at line 1825 of file mesh_tools.C.

References libMesh::ParallelObject::comm(), libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::DofObject::id(), libMesh::DofObject::invalid_id, libMesh::libmesh_assert(), libMesh::Elem::libmesh_assert_valid_neighbors(), libmesh_nullptr, libMesh::Parallel::Communicator::max(), libMesh::MeshBase::max_elem_id(), mesh, libMesh::Elem::n_neighbors(), libMesh::ParallelObject::n_processors(), libMesh::Elem::neighbor_ptr(), new_proc_ids, libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::MeshBase::query_elem_ptr(), libMesh::remote_elem, and libMesh::Parallel::Communicator::semiverify().

Referenced by libMesh::MeshRefinement::_smooth_flags(), libMesh::DistributedMesh::allgather(), libMesh::DistributedMesh::delete_remote_elements(), libMesh::UnstructuredMesh::find_neighbors(), and libmesh_assert_valid_procids().

1827 {
1828  LOG_SCOPE("libmesh_assert_valid_neighbors()", "MeshTools");
1829 
1830  const MeshBase::const_element_iterator el_end = mesh.elements_end();
1832  el != el_end; ++el)
1833  {
1834  const Elem * elem = *el;
1835  libmesh_assert (elem);
1837  }
1838 
1839  if (mesh.n_processors() == 1)
1840  return;
1841 
1842  libmesh_parallel_only(mesh.comm());
1843 
1844  dof_id_type pmax_elem_id = mesh.max_elem_id();
1845  mesh.comm().max(pmax_elem_id);
1846 
1847  for (dof_id_type i=0; i != pmax_elem_id; ++i)
1848  {
1849  const Elem * elem = mesh.query_elem_ptr(i);
1850 
1851  const unsigned int my_n_neigh = elem ? elem->n_neighbors() : 0;
1852  unsigned int n_neigh = my_n_neigh;
1853  mesh.comm().max(n_neigh);
1854  if (elem)
1855  libmesh_assert_equal_to (my_n_neigh, n_neigh);
1856 
1857  for (unsigned int n = 0; n != n_neigh; ++n)
1858  {
1859  dof_id_type my_neighbor = DofObject::invalid_id;
1860  dof_id_type * p_my_neighbor = libmesh_nullptr;
1861 
1862  // If we have a non-remote_elem neighbor link, then we can
1863  // verify it.
1864  if (elem && elem->neighbor_ptr(n) != remote_elem)
1865  {
1866  p_my_neighbor = &my_neighbor;
1867  if (elem->neighbor_ptr(n))
1868  my_neighbor = elem->neighbor_ptr(n)->id();
1869 
1870  // But wait - if we haven't set remote_elem links yet then
1871  // some NULL links on ghost elements might be
1872  // future-remote_elem links, so we can't verify those.
1873  if (!assert_valid_remote_elems &&
1874  !elem->neighbor_ptr(n) &&
1875  elem->processor_id() != mesh.processor_id())
1876  p_my_neighbor = libmesh_nullptr;
1877  }
1878  libmesh_assert(mesh.comm().semiverify(p_my_neighbor));
1879  }
1880  }
1881 }
virtual unsigned int n_neighbors() const
Definition: elem.h:557
processor_id_type n_processors() const
The base class for all geometric element types.
Definition: elem.h:86
const class libmesh_nullptr_t libmesh_nullptr
libmesh_assert(j)
const Elem * neighbor_ptr(unsigned int i) const
Definition: elem.h:1821
virtual element_iterator elements_begin()=0
virtual dof_id_type max_elem_id() const =0
virtual element_iterator elements_end()=0
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
const Parallel::Communicator & comm() const
dof_id_type id() const
Definition: dof_object.h:624
void libmesh_assert_valid_neighbors() const
Definition: elem.C:1127
processor_id_type processor_id() const
uint8_t dof_id_type
Definition: id_types.h:64
processor_id_type processor_id() const
Definition: dof_object.h:686
const RemoteElem * remote_elem
Definition: remote_elem.C:57
void libMesh::MeshTools::libmesh_assert_valid_node_pointers ( const MeshBase mesh)

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

Definition at line 1073 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_ptr(), libMesh::Elem::parent(), and libMesh::remote_elem.

Referenced by weight().

1074 {
1075  LOG_SCOPE("libmesh_assert_valid_node_pointers()", "MeshTools");
1076 
1077  const MeshBase::const_element_iterator el_end =
1078  mesh.elements_end();
1080  mesh.elements_begin(); el != el_end; ++el)
1081  {
1082  const Elem * elem = *el;
1083  libmesh_assert (elem);
1084  while (elem)
1085  {
1087  for (unsigned int n=0; n != elem->n_neighbors(); ++n)
1088  if (elem->neighbor_ptr(n) &&
1089  elem->neighbor_ptr(n) != remote_elem)
1091 
1092  libmesh_assert_not_equal_to (elem->parent(), remote_elem);
1093  elem = elem->parent();
1094  }
1095  }
1096 }
virtual unsigned int n_neighbors() const
Definition: elem.h:557
const Elem * parent() const
Definition: elem.h:2148
The base class for all geometric element types.
Definition: elem.h:86
libmesh_assert(j)
const Elem * neighbor_ptr(unsigned int i) const
Definition: elem.h:1821
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
void libmesh_assert_valid_node_pointers() const
Definition: elem.C:1115
const RemoteElem * remote_elem
Definition: remote_elem.C:57
template<typename DofObjectSubclass >
void libMesh::MeshTools::libmesh_assert_valid_procids ( const MeshBase mesh)

A function for verifying that processor assignment is both parallel and topologically consistent.

Definition at line 493 of file mesh_tools.h.

References libmesh_assert_valid_neighbors(), libmesh_assert_valid_refinement_flags(), libmesh_assert_valid_refinement_tree(), and mesh.

493  {
494  libmesh_assert_parallel_consistent_procids<DofObjectSubclass>(mesh);
495  libmesh_assert_topology_consistent_procids<DofObjectSubclass>(mesh);
496 }
MeshBase & mesh
void libMesh::MeshTools::libmesh_assert_valid_refinement_flags ( const MeshBase mesh)

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

Definition at line 1731 of file mesh_tools.C.

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

Referenced by libmesh_assert_valid_procids().

1732 {
1733  LOG_SCOPE("libmesh_assert_valid_refinement_flags()", "MeshTools");
1734 
1735  libmesh_parallel_only(mesh.comm());
1736  if (mesh.n_processors() == 1)
1737  return;
1738 
1739  dof_id_type pmax_elem_id = mesh.max_elem_id();
1740  mesh.comm().max(pmax_elem_id);
1741 
1742  std::vector<unsigned char> my_elem_h_state(pmax_elem_id, 255);
1743  std::vector<unsigned char> my_elem_p_state(pmax_elem_id, 255);
1744 
1745  const MeshBase::const_element_iterator el_end =
1746  mesh.elements_end();
1748  mesh.elements_begin(); el != el_end; ++el)
1749  {
1750  const Elem * elem = *el;
1751  libmesh_assert (elem);
1752  dof_id_type elemid = elem->id();
1753 
1754  my_elem_h_state[elemid] =
1755  static_cast<unsigned char>(elem->refinement_flag());
1756 
1757  my_elem_p_state[elemid] =
1758  static_cast<unsigned char>(elem->p_refinement_flag());
1759  }
1760  std::vector<unsigned char> min_elem_h_state(my_elem_h_state);
1761  mesh.comm().min(min_elem_h_state);
1762 
1763  std::vector<unsigned char> min_elem_p_state(my_elem_p_state);
1764  mesh.comm().min(min_elem_p_state);
1765 
1766  for (dof_id_type i=0; i!= pmax_elem_id; ++i)
1767  {
1768  libmesh_assert(my_elem_h_state[i] == 255 ||
1769  my_elem_h_state[i] == min_elem_h_state[i]);
1770  libmesh_assert(my_elem_p_state[i] == 255 ||
1771  my_elem_p_state[i] == min_elem_p_state[i]);
1772  }
1773 }
processor_id_type n_processors() const
The base class for all geometric element types.
Definition: elem.h:86
libmesh_assert(j)
virtual element_iterator elements_begin()=0
virtual dof_id_type max_elem_id() const =0
virtual element_iterator elements_end()=0
RefinementState p_refinement_flag() const
Definition: elem.h:2320
const Parallel::Communicator & comm() const
RefinementState refinement_flag() const
Definition: elem.h:2304
dof_id_type id() const
Definition: dof_object.h:624
uint8_t dof_id_type
Definition: id_types.h:64
void libMesh::MeshTools::libmesh_assert_valid_refinement_tree ( const MeshBase mesh)

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

Definition at line 1783 of file mesh_tools.C.

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

Referenced by libMesh::MeshCommunication::delete_remote_elements(), libMesh::DistributedMesh::delete_remote_elements(), libmesh_assert_valid_procids(), and libMesh::MeshCommunication::redistribute().

1784 {
1785  LOG_SCOPE("libmesh_assert_valid_refinement_tree()", "MeshTools");
1786 
1787  const MeshBase::const_element_iterator el_end =
1788  mesh.elements_end();
1790  mesh.elements_begin(); el != el_end; ++el)
1791  {
1792  const Elem * elem = *el;
1793  libmesh_assert(elem);
1794  if (elem->has_children())
1795  for (unsigned int n=0; n != elem->n_children(); ++n)
1796  {
1797  libmesh_assert(elem->child_ptr(n));
1798  if (elem->child_ptr(n) != remote_elem)
1799  libmesh_assert_equal_to (elem->child_ptr(n)->parent(), elem);
1800  }
1801  if (elem->active())
1802  {
1803  libmesh_assert(!elem->ancestor());
1804  libmesh_assert(!elem->subactive());
1805  }
1806  else if (elem->ancestor())
1807  {
1808  libmesh_assert(!elem->subactive());
1809  }
1810  else
1811  libmesh_assert(elem->subactive());
1812 
1813  if (elem->p_refinement_flag() == Elem::JUST_REFINED)
1814  libmesh_assert_greater(elem->p_level(), 0);
1815  }
1816 }
bool ancestor() const
Definition: elem.C:1569
bool has_children() const
Definition: elem.h:2097
bool subactive() const
Definition: elem.h:2077
bool active() const
Definition: elem.h:2059
unsigned int p_level() const
Definition: elem.h:2224
const Elem * parent() const
Definition: elem.h:2148
The base class for all geometric element types.
Definition: elem.h:86
libmesh_assert(j)
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
const Elem * child_ptr(unsigned int i) const
Definition: elem.h:2247
RefinementState p_refinement_flag() const
Definition: elem.h:2320
virtual unsigned int n_children() const =0
const RemoteElem * remote_elem
Definition: remote_elem.C:57
void libMesh::MeshTools::libmesh_assert_valid_remote_elems ( const MeshBase mesh)

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

Definition at line 1099 of file mesh_tools.C.

References libMesh::Elem::active(), libMesh::Elem::child_ptr(), libMesh::Elem::has_children(), libMesh::libmesh_assert(), libMesh::MeshBase::local_elements_begin(), libMesh::MeshBase::local_elements_end(), libMesh::Elem::n_children(), libMesh::Elem::n_neighbors(), libMesh::Elem::neighbor_ptr(), libMesh::Elem::parent(), and libMesh::remote_elem.

Referenced by libMesh::Partitioner::partition(), and weight().

1100 {
1101  LOG_SCOPE("libmesh_assert_valid_remote_elems()", "MeshTools");
1102 
1103  const MeshBase::const_element_iterator el_end =
1104  mesh.local_elements_end();
1106  mesh.local_elements_begin(); el != el_end; ++el)
1107  {
1108  const Elem * elem = *el;
1109  libmesh_assert (elem);
1110 
1111  // We currently don't allow active_local_elements to have
1112  // remote_elem neighbors
1113  if (elem->active())
1114  for (unsigned int n=0; n != elem->n_neighbors(); ++n)
1115  libmesh_assert_not_equal_to (elem->neighbor_ptr(n), remote_elem);
1116 
1117 #ifdef LIBMESH_ENABLE_AMR
1118  const Elem * parent = elem->parent();
1119  if (parent)
1120  libmesh_assert_not_equal_to (parent, remote_elem);
1121 
1122  // We can only be strict about active elements' subactive
1123  // children
1124  if (elem->active() && elem->has_children())
1125  for (unsigned int c=0; c != elem->n_children(); ++c)
1126  libmesh_assert_not_equal_to (elem->child_ptr(c), remote_elem);
1127 #endif
1128  }
1129 }
bool has_children() const
Definition: elem.h:2097
bool active() const
Definition: elem.h:2059
virtual unsigned int n_neighbors() const
Definition: elem.h:557
virtual element_iterator local_elements_begin()=0
const Elem * parent() const
Definition: elem.h:2148
The base class for all geometric element types.
Definition: elem.h:86
libmesh_assert(j)
const Elem * neighbor_ptr(unsigned int i) const
Definition: elem.h:1821
const Elem * child_ptr(unsigned int i) const
Definition: elem.h:2247
virtual element_iterator local_elements_end()=0
virtual unsigned int n_children() const =0
const RemoteElem * remote_elem
Definition: remote_elem.C:57
void libMesh::MeshTools::libmesh_assert_valid_unique_ids ( const MeshBase mesh)

A function for verifying that unique ids match across processors.

FIXME: we ought to check for uniqueness too.

Definition at line 1482 of file mesh_tools.C.

References libMesh::ParallelObject::comm(), libMesh::libmesh_assert(), libmesh_nullptr, libMesh::Parallel::Communicator::max(), libMesh::MeshBase::max_elem_id(), libMesh::MeshBase::max_node_id(), libMesh::MeshBase::query_elem_ptr(), libMesh::MeshBase::query_node_ptr(), libMesh::Parallel::Communicator::semiverify(), and libMesh::DofObject::unique_id().

Referenced by libMesh::MeshBase::prepare_for_use(), and weight().

1483 {
1484  LOG_SCOPE("libmesh_assert_valid_unique_ids()", "MeshTools");
1485 
1486  libmesh_parallel_only(mesh.comm());
1487 
1488  dof_id_type pmax_elem_id = mesh.max_elem_id();
1489  mesh.comm().max(pmax_elem_id);
1490 
1491  for (dof_id_type i=0; i != pmax_elem_id; ++i)
1492  {
1493  const Elem * elem = mesh.query_elem_ptr(i);
1494  const unique_id_type unique_id = elem ? elem->unique_id() : 0;
1495  const unique_id_type * uid_ptr = elem ? &unique_id : libmesh_nullptr;
1496  libmesh_assert(mesh.comm().semiverify(uid_ptr));
1497  }
1498 
1499  dof_id_type pmax_node_id = mesh.max_node_id();
1500  mesh.comm().max(pmax_node_id);
1501 
1502  for (dof_id_type i=0; i != pmax_node_id; ++i)
1503  {
1504  const Node * node = mesh.query_node_ptr(i);
1505  const unique_id_type unique_id = node ? node->unique_id() : 0;
1506  const unique_id_type * uid_ptr = node ? &unique_id : libmesh_nullptr;
1507  libmesh_assert(mesh.comm().semiverify(uid_ptr));
1508  }
1509 }
A geometric point in (x,y,z) space associated with a DOF.
Definition: node.h:52
virtual dof_id_type max_node_id() const =0
The base class for all geometric element types.
Definition: elem.h:86
const class libmesh_nullptr_t libmesh_nullptr
libmesh_assert(j)
virtual dof_id_type max_elem_id() const =0
virtual const Node * query_node_ptr(const dof_id_type i) const =0
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
const Parallel::Communicator & comm() const
unique_id_type unique_id() const
Definition: dof_object.h:641
uint8_t unique_id_type
Definition: id_types.h:79
uint8_t dof_id_type
Definition: id_types.h:64
unsigned int libMesh::MeshTools::max_level ( const MeshBase mesh)
dof_id_type libMesh::MeshTools::n_active_elem_of_type ( const MeshBase mesh,
const ElemType  type 
)
Returns
The number of active elements of type type.

Implemented in terms of active_type_element_iterators.

Definition at line 546 of file mesh_tools.C.

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

Referenced by weight().

548 {
549  return static_cast<dof_id_type>(std::distance(mesh.active_type_elements_begin(type),
550  mesh.active_type_elements_end (type)));
551 }
virtual element_iterator active_type_elements_end(ElemType type)=0
virtual element_iterator active_type_elements_begin(ElemType type)=0
uint8_t dof_id_type
Definition: id_types.h:64
unsigned int libMesh::MeshTools::n_active_levels ( const MeshBase mesh)
Returns
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 taking the max in parallel.

Definition at line 585 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 weight(), and libMesh::XdrIO::write_serialized_connectivity().

586 {
587  libmesh_parallel_only(mesh.comm());
588 
589  unsigned int nl = MeshTools::n_active_local_levels(mesh);
590 
593  const MeshBase::const_element_iterator end_el =
595 
596  for ( ; el != end_el; ++el)
597  if ((*el)->active())
598  nl = std::max((*el)->level() + 1, nl);
599 
600  mesh.comm().max(nl);
601  return nl;
602 }
unsigned int n_active_local_levels(const MeshBase &mesh)
Definition: mesh_tools.C:570
virtual element_iterator unpartitioned_elements_begin()=0
long double max(long double a, double b)
const Parallel::Communicator & comm() const
virtual element_iterator unpartitioned_elements_end()=0
unsigned int libMesh::MeshTools::n_active_local_levels ( const MeshBase mesh)
Returns
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 570 of file mesh_tools.C.

References libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), and std::max().

Referenced by n_active_levels(), and weight().

571 {
572  unsigned int nl = 0;
573 
576 
577  for ( ; el != end_el; ++el)
578  nl = std::max((*el)->level() + 1, nl);
579 
580  return nl;
581 }
long double max(long double a, double b)
virtual element_iterator active_local_elements_begin()=0
virtual element_iterator active_local_elements_end()=0
dof_id_type libMesh::MeshTools::n_elem_of_type ( const MeshBase mesh,
const ElemType  type 
)
Returns
The number of elements of type type.

Implemented in terms of type_element_iterators.

Definition at line 537 of file mesh_tools.C.

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

Referenced by weight().

539 {
540  return static_cast<dof_id_type>(std::distance(mesh.type_elements_begin(type),
541  mesh.type_elements_end (type)));
542 }
virtual element_iterator type_elements_end(ElemType type)=0
virtual element_iterator type_elements_begin(ElemType type)=0
uint8_t dof_id_type
Definition: id_types.h:64
unsigned int libMesh::MeshTools::n_levels ( const MeshBase mesh)
Returns
The number of levels of refinement in the mesh.

Implemented by looping over all the local elements and unpartitioned elements and finding the maximum level, then summing in parallel.

Definition at line 621 of file mesh_tools.C.

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

Referenced by libMesh::MeshCommunication::broadcast(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::MeshCommunication::gather(), libMesh::MeshTools::Modification::smooth(), and weight().

622 {
623  libmesh_parallel_only(mesh.comm());
624 
625  unsigned int nl = MeshTools::n_local_levels(mesh);
626 
629  const MeshBase::const_element_iterator end_el =
631 
632  for ( ; el != end_el; ++el)
633  nl = std::max((*el)->level() + 1, nl);
634 
635  mesh.comm().max(nl);
636 
637  // n_levels() is only valid and should only be called in cases where
638  // the mesh is validly distributed (or serialized). Let's run an
639  // expensive test in debug mode to make sure this is such a case.
640 #ifdef DEBUG
641  const unsigned int paranoid_nl = MeshTools::paranoid_n_levels(mesh);
642  libmesh_assert_equal_to(nl, paranoid_nl);
643 #endif
644  return nl;
645 }
virtual element_iterator unpartitioned_elements_begin()=0
unsigned int n_local_levels(const MeshBase &mesh)
Definition: mesh_tools.C:606
long double max(long double a, double b)
unsigned int paranoid_n_levels(const MeshBase &mesh)
Definition: mesh_tools.C:649
const Parallel::Communicator & comm() const
virtual element_iterator unpartitioned_elements_end()=0
unsigned int libMesh::MeshTools::n_local_levels ( const MeshBase mesh)
Returns
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 606 of file mesh_tools.C.

References libMesh::MeshBase::local_elements_begin(), libMesh::MeshBase::local_elements_end(), and std::max().

Referenced by n_levels(), and weight().

607 {
608  unsigned int nl = 0;
609 
612 
613  for ( ; el != end_el; ++el)
614  nl = std::max((*el)->level() + 1, nl);
615 
616  return nl;
617 }
virtual element_iterator local_elements_begin()=0
long double max(long double a, double b)
virtual element_iterator local_elements_end()=0
dof_id_type libMesh::MeshTools::n_nodes ( const MeshBase::const_node_iterator begin,
const MeshBase::const_node_iterator end 
)

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

Definition at line 692 of file mesh_tools.C.

Referenced by weight().

694 {
695  return cast_int<dof_id_type>(std::distance(begin, end));
696 }
dof_id_type libMesh::MeshTools::n_non_subactive_elem_of_type_at_level ( const MeshBase mesh,
const ElemType  type,
const unsigned int  level 
)
Returns
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 computes the std::distance between them.

Definition at line 553 of file mesh_tools.C.

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

Referenced by weight().

556 {
557  dof_id_type cnt = 0;
558  // iterate over the elements of the specified type
561 
562  for (; el!=end; ++el)
563  if (((*el)->level() == level) && !(*el)->subactive())
564  cnt++;
565 
566  return cnt;
567 }
IterBase * end
virtual element_iterator type_elements_end(ElemType type)=0
virtual element_iterator type_elements_begin(ElemType type)=0
uint8_t dof_id_type
Definition: id_types.h:64
unsigned int libMesh::MeshTools::n_p_levels ( const MeshBase mesh)
Returns
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 700 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 weight(), and libMesh::XdrIO::write().

701 {
702  libmesh_parallel_only(mesh.comm());
703 
704  unsigned int max_p_level = 0;
705 
706  // first my local elements
708  el = mesh.local_elements_begin(),
709  end_el = mesh.local_elements_end();
710 
711  for ( ; el != end_el; ++el)
712  max_p_level = std::max((*el)->p_level(), max_p_level);
713 
714  // then any unpartitioned objects
715  el = mesh.unpartitioned_elements_begin();
716  end_el = mesh.unpartitioned_elements_end();
717 
718  for ( ; el != end_el; ++el)
719  max_p_level = std::max((*el)->p_level(), max_p_level);
720 
721  mesh.comm().max(max_p_level);
722  return max_p_level + 1;
723 }
virtual element_iterator local_elements_begin()=0
virtual element_iterator unpartitioned_elements_begin()=0
long double max(long double a, double b)
virtual element_iterator local_elements_end()=0
const Parallel::Communicator & comm() const
virtual element_iterator unpartitioned_elements_end()=0
unsigned int libMesh::MeshTools::paranoid_n_levels ( const MeshBase mesh)
Returns
The number of levels of refinement in the mesh, even if that mesh is not currently properly distributed or properly serialized.

Implemented by looping over all elements and finding the maximum level, then summing in parallel. This is much slower than n_levels() but will return correct values even when the mesh is in an inconsistent parallel state.

Definition at line 649 of file mesh_tools.C.

References libMesh::ParallelObject::comm(), libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), std::max(), and libMesh::Parallel::Communicator::max().

Referenced by libMesh::MeshCommunication::broadcast(), n_levels(), and weight().

650 {
651  libmesh_parallel_only(mesh.comm());
652 
654  mesh.elements_begin();
655  const MeshBase::const_element_iterator end_el =
656  mesh.elements_end();
657 
658  unsigned int nl = 0;
659  for ( ; el != end_el; ++el)
660  nl = std::max((*el)->level() + 1, nl);
661 
662  mesh.comm().max(nl);
663  return nl;
664 }
long double max(long double a, double b)
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
const Parallel::Communicator & comm() const
MeshTools::BoundingBox libMesh::MeshTools::processor_bounding_box ( const MeshBase mesh,
const processor_id_type  pid 
)
Returns
Two points defining a cartesian box that bounds the elements belonging to processor pid.
Deprecated:
Use create_processor_bounding_box() instead.

Definition at line 420 of file mesh_tools.C.

References create_processor_bounding_box().

Referenced by weight().

422 {
423  libmesh_deprecated();
425 }
libMesh::BoundingBox create_processor_bounding_box(const MeshBase &mesh, const processor_id_type pid)
Definition: mesh_tools.C:430
Sphere libMesh::MeshTools::processor_bounding_sphere ( const MeshBase mesh,
const processor_id_type  pid 
)
Returns
A processor bounding sphere instead of a processor bounding box.

Definition at line 455 of file mesh_tools.C.

References create_processor_bounding_box(), and libMesh::Real.

Referenced by weight().

457 {
458  libMesh::BoundingBox bbox =
460 
461  const Real diag = (bbox.second - bbox.first).norm();
462  const Point cent = (bbox.second + bbox.first)/2;
463 
464  return Sphere (cent, .5*diag);
465 }
A geometric object representing a sphere.
Definition: sphere.h:72
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
libMesh::BoundingBox create_processor_bounding_box(const MeshBase &mesh, const processor_id_type pid)
Definition: mesh_tools.C:430
A geometric point in (x,y,z) space.
Definition: point.h:38
MeshTools::BoundingBox libMesh::MeshTools::subdomain_bounding_box ( const MeshBase mesh,
const subdomain_id_type  sid 
)
Returns
Two points defining a Cartesian box that bounds the elements belonging to subdomain sid.
Deprecated:
Use create_subdomain_bounding_box() instead.

Definition at line 470 of file mesh_tools.C.

References create_subdomain_bounding_box().

Referenced by weight().

472 {
473  libmesh_deprecated();
475 }
libMesh::BoundingBox create_subdomain_bounding_box(const MeshBase &mesh, const subdomain_id_type sid)
Definition: mesh_tools.C:480
Sphere libMesh::MeshTools::subdomain_bounding_sphere ( const MeshBase mesh,
const subdomain_id_type  sid 
)
Returns
A subdomain bounding sphere instead of a subdomain bounding box.

Definition at line 504 of file mesh_tools.C.

References create_subdomain_bounding_box(), and libMesh::Real.

Referenced by weight().

506 {
507  libMesh::BoundingBox bbox =
509 
510  const Real diag = (bbox.second - bbox.first).norm();
511  const Point cent = (bbox.second + bbox.first)/2;
512 
513  return Sphere (cent, .5*diag);
514 }
A geometric object representing a sphere.
Definition: sphere.h:72
libMesh::BoundingBox create_subdomain_bounding_box(const MeshBase &mesh, const subdomain_id_type sid)
Definition: mesh_tools.C:480
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
A geometric point in (x,y,z) space.
Definition: point.h:38
dof_id_type libMesh::MeshTools::total_weight ( const MeshBase mesh)
Returns
The sum over all the elements 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 223 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::MeshTools::BoundingBox::BoundingBox().

224 {
225  if (!mesh.is_serial())
226  {
227  libmesh_parallel_only(mesh.comm());
229  mesh.comm().sum(weight);
230  dof_id_type unpartitioned_weight =
231  MeshTools::weight (mesh, DofObject::invalid_processor_id);
232  return weight + unpartitioned_weight;
233  }
234 
235  SumElemWeight sew;
236 
238  mesh.elements_end()),
239  sew);
240  return sew.weight();
241 
242 }
virtual bool is_serial() const
Definition: mesh_base.h:137
Utility class for defining generic ranges for threading.
Definition: stored_range.h:52
virtual element_iterator elements_begin()=0
dof_id_type weight(const MeshBase &mesh, const processor_id_type pid)
Definition: mesh_tools.C:246
virtual element_iterator elements_end()=0
const Parallel::Communicator & comm() const
void parallel_reduce(const Range &range, Body &body)
Definition: threads_none.h:101
processor_id_type processor_id() const
uint8_t dof_id_type
Definition: id_types.h:64
dof_id_type libMesh::MeshTools::weight ( const MeshBase mesh,
const processor_id_type  pid 
)
Returns
The sum over all the elements 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 246 of file mesh_tools.C.

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

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

247 {
248  SumElemWeight sew;
249 
251  mesh.pid_elements_end(pid)),
252  sew);
253  return sew.weight();
254 }
Utility class for defining generic ranges for threading.
Definition: stored_range.h:52
virtual element_iterator pid_elements_begin(processor_id_type proc_id)=0
void parallel_reduce(const Range &range, Body &body)
Definition: threads_none.h:101
virtual element_iterator pid_elements_end(processor_id_type proc_id)=0
dof_id_type libMesh::MeshTools::weight ( const MeshBase mesh)
inline

Definition at line 101 of file mesh_tools.h.

References bounding_box(), bounding_sphere(), build_nodes_to_elem_map(), correct_node_proc_ids(), create_bounding_box(), create_local_bounding_box(), create_nodal_bounding_box(), create_processor_bounding_box(), create_subdomain_bounding_box(), elem_types(), end, find_boundary_nodes(), find_hanging_nodes_and_parents(), find_nodal_neighbors(), get_not_subactive_node_ids(), libMesh::invalid_uint, libmesh_assert_connected_nodes(), libmesh_assert_equal_n_systems(), libmesh_assert_no_links_to_elem(), libmesh_assert_old_dof_objects(), libmesh_assert_parallel_consistent_procids(), libmesh_assert_topology_consistent_procids(), libmesh_assert_valid_amr_elem_ids(), libmesh_assert_valid_amr_interior_parents(), libmesh_assert_valid_boundary_ids(), libmesh_assert_valid_dof_ids(), libmesh_assert_valid_elem_ids(), libmesh_assert_valid_node_pointers(), libmesh_assert_valid_remote_elems(), libmesh_assert_valid_unique_ids(), max_level(), n_active_elem_of_type(), n_active_levels(), n_active_local_levels(), n_elem(), n_elem_of_type(), n_levels(), n_local_levels(), n_nodes(), n_non_subactive_elem_of_type_at_level(), n_p_levels(), paranoid_n_levels(), processor_bounding_box(), processor_bounding_sphere(), libMesh::ParallelObject::processor_id(), subdomain_bounding_box(), subdomain_bounding_sphere(), and weight().

102 { return MeshTools::weight (mesh, mesh.processor_id()); }
dof_id_type weight(const MeshBase &mesh)
Definition: mesh_tools.h:101
MeshBase & mesh