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 316 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().

317 {
318  // This function is deprecated. It simply calls
319  // create_bounding_box() and converts the result to a
320  // MeshTools::BoundingBox.
321  libmesh_deprecated();
322  return MeshTools::create_bounding_box(mesh);
323 }
libMesh::BoundingBox create_bounding_box(const MeshBase &mesh)
Definition: mesh_tools.C:329
Sphere libMesh::MeshTools::bounding_sphere ( const MeshBase mesh)
Returns
A bounding sphere for mesh instead of a bounding box.

Definition at line 381 of file mesh_tools.C.

References create_bounding_box(), and libMesh::Real.

Referenced by weight().

382 {
384 
385  const Real diag = (bbox.second - bbox.first).norm();
386  const Point cent = (bbox.second + bbox.first)/2;
387 
388  return Sphere (cent, .5*diag);
389 }
A geometric object representing a sphere.
Definition: sphere.h:72
libMesh::BoundingBox create_bounding_box(const MeshBase &mesh)
Definition: mesh_tools.C:329
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 257 of file mesh_tools.C.

References libMesh::MeshBase::element_ptr_range(), 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().

259 {
260  nodes_to_elem_map.resize (mesh.n_nodes());
261 
262  for (const auto & elem : mesh.element_ptr_range())
263  for (auto & node : elem->node_ref_range())
264  {
265  libmesh_assert_less (node.id(), nodes_to_elem_map.size());
266  libmesh_assert_less (elem->id(), mesh.n_elem());
267 
268  nodes_to_elem_map[node.id()].push_back(elem->id());
269  }
270 }
virtual SimpleRange< element_iterator > element_ptr_range()=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 274 of file mesh_tools.C.

References libMesh::MeshBase::element_ptr_range(), and libMesh::MeshBase::n_nodes().

276 {
277  nodes_to_elem_map.resize (mesh.n_nodes());
278 
279  for (const auto & elem : mesh.element_ptr_range())
280  for (auto & node : elem->node_ref_range())
281  {
282  libmesh_assert_less (node.id(), nodes_to_elem_map.size());
283 
284  nodes_to_elem_map[node.id()].push_back(elem);
285  }
286 }
virtual SimpleRange< element_iterator > element_ptr_range()=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 1826 of file mesh_tools.C.

References libMesh::MeshBase::active_element_ptr_range(), libMesh::ParallelObject::comm(), libMesh::DofObject::id(), libMesh::DofObject::invalid_processor_id, libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshBase::local_node_ptr_range(), mesh, std::min(), libMesh::ParallelObject::n_processors(), new_proc_ids, libMesh::MeshBase::node_ptr_range(), 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().

1827 {
1828  // This function must be run on all processors at once
1829  libmesh_parallel_only(mesh.comm());
1830 
1831  // Fix all nodes' processor ids. Coarsening may have left us with
1832  // nodes which are no longer touched by any elements of the same
1833  // processor id, and for DofMap to work we need to fix that.
1834 
1835  // This is harder now that libMesh no longer requires a distributed
1836  // mesh to ghost all nodal neighbors: it is possible for two active
1837  // elements on two different processors to share the same node in
1838  // such a way that neither processor knows the others' element
1839  // exists!
1840 
1841  // We require all processors to agree on nodal processor ids before
1842  // going into this algorithm.
1843 #ifdef DEBUG
1845 #endif
1846 
1847  // We build up a set of compatible processor ids for each node
1848  proc_id_map_type new_proc_ids;
1849 
1850  for (auto & elem : mesh.active_element_ptr_range())
1851  {
1852  processor_id_type pid = elem->processor_id();
1853 
1854  for (auto & node : elem->node_ref_range())
1855  {
1856  const dof_id_type id = node.id();
1857  const proc_id_map_type::iterator it = new_proc_ids.find(id);
1858  if (it == new_proc_ids.end())
1859  new_proc_ids.insert(std::make_pair(id,pid));
1860  else
1861  it->second = std::min(it->second, pid);
1862  }
1863  }
1864 
1865  // Sort the new pids to push to each processor
1866  std::vector<std::vector<std::pair<dof_id_type, processor_id_type>>>
1867  ids_to_push(mesh.n_processors());
1868 
1869  for (const auto & node : mesh.node_ptr_range())
1870  {
1871  const dof_id_type id = node->id();
1872  const proc_id_map_type::iterator it = new_proc_ids.find(id);
1873  if (it == new_proc_ids.end())
1874  continue;
1875  const processor_id_type pid = it->second;
1876  if (node->processor_id() != DofObject::invalid_processor_id)
1877  ids_to_push[node->processor_id()].push_back(std::make_pair(id, pid));
1878  }
1879 
1880  // Push using non-blocking I/O
1881  std::vector<Parallel::Request> push_requests(mesh.n_processors());
1882 
1883  for (processor_id_type p=1; p != mesh.n_processors(); ++p)
1884  {
1885  const processor_id_type procup =
1886  cast_int<processor_id_type>
1887  ((mesh.comm().rank() + p) % mesh.comm().size());
1888 
1889  mesh.comm().send(procup, ids_to_push[procup], push_requests[procup]);
1890  }
1891 
1892  for (processor_id_type p=0; p != mesh.n_processors(); ++p)
1893  {
1894  const processor_id_type procdown =
1895  cast_int<processor_id_type>
1896  ((mesh.comm().size() + mesh.comm().rank() - p) %
1897  mesh.comm().size());
1898 
1899  std::vector<std::pair<dof_id_type, processor_id_type>>
1900  ids_to_pull;
1901 
1902  if (p)
1903  mesh.comm().receive(procdown, ids_to_pull);
1904  else
1905  ids_to_pull.swap(ids_to_push[procdown]);
1906 
1907  std::vector<std::pair<dof_id_type, processor_id_type>>::iterator
1908  pulled_ids_it = ids_to_pull.begin(),
1909  pulled_ids_end = ids_to_pull.end();
1910  for (; pulled_ids_it != pulled_ids_end; ++pulled_ids_it)
1911  {
1912  const dof_id_type id = pulled_ids_it->first;
1913  const processor_id_type pid = pulled_ids_it->second;
1914  const proc_id_map_type::iterator it = new_proc_ids.find(id);
1915  if (it == new_proc_ids.end())
1916  new_proc_ids.insert(std::make_pair(id,pid));
1917  else
1918  it->second = std::min(it->second, pid);
1919  }
1920  }
1921 
1922  // Now new_proc_ids is correct for every node we used to own. Let's
1923  // ask every other processor about the nodes they used to own. But
1924  // first we'll need to keep track of which nodes we used to own,
1925  // lest we get them confused with nodes we newly own.
1926  std::unordered_set<Node *> ex_local_nodes;
1927  for (auto & node : mesh.local_node_ptr_range())
1928  {
1929  const proc_id_map_type::iterator it = new_proc_ids.find(node->id());
1930  if (it != new_proc_ids.end() && it->second != mesh.processor_id())
1931  ex_local_nodes.insert(node);
1932  }
1933 
1934  // Let's finish with previous I/O before we start more.
1935  Parallel::wait(push_requests);
1936 
1937  SyncProcIdsFromMap sync(new_proc_ids, mesh);
1939  (mesh.comm(), mesh.nodes_begin(), mesh.nodes_end(), sync);
1940 
1941  // And finally let's update the nodes we used to own.
1942  for (std::unordered_set<Node *>::iterator
1943  n_it = ex_local_nodes.begin(),
1944  n_end = ex_local_nodes.end();
1945  n_it != n_end; ++n_it)
1946  {
1947  Node * node = *n_it;
1948  const dof_id_type id = node->id();
1949  const proc_id_map_type::iterator it = new_proc_ids.find(id);
1950  libmesh_assert(it != new_proc_ids.end());
1951  node->processor_id() = it->second;
1952  }
1953 
1954  // We should still have consistent nodal processor ids coming out of
1955  // this algorithm.
1956 #ifdef DEBUG
1957  MeshTools::libmesh_assert_valid_procids<Node>(mesh);
1958 #endif
1959 }
Status wait(Request &r)
Definition: parallel.h:564
A geometric point in (x,y,z) space associated with a DOF.
Definition: node.h:52
virtual SimpleRange< node_iterator > local_node_ptr_range()=0
unsigned int size() const
Definition: parallel.h:725
processor_id_type n_processors() const
uint8_t processor_id_type
Definition: id_types.h:99
virtual SimpleRange< element_iterator > active_element_ptr_range()=0
MeshBase & mesh
Definition: mesh_tools.C:1783
virtual node_iterator nodes_begin()=0
virtual SimpleRange< node_iterator > node_ptr_range()=0
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:1781
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:1555
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:723
dof_id_type id() const
Definition: dof_object.h:632
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:694
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 329 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().

330 {
331  // This function must be run on all processors at once
332  libmesh_parallel_only(mesh.comm());
333 
334  FindBBox find_bbox;
335 
336  // Start with any unpartitioned elements we know about locally
337  Threads::parallel_reduce (ConstElemRange (mesh.pid_elements_begin(DofObject::invalid_processor_id),
338  mesh.pid_elements_end(DofObject::invalid_processor_id)),
339  find_bbox);
340 
341  // And combine with our local elements
342  find_bbox.bbox().union_with(MeshTools::create_local_bounding_box(mesh));
343 
344  // Compare the bounding boxes across processors
345  mesh.comm().min(find_bbox.min());
346  mesh.comm().max(find_bbox.max());
347 
348  return find_bbox.bbox();
349 }
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:394
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 394 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().

395 {
396  FindBBox find_bbox;
397 
399  mesh.local_elements_end()),
400  find_bbox);
401 
402  return find_bbox.bbox();
403 }
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 354 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().

355 {
356  // This function must be run on all processors at once
357  libmesh_parallel_only(mesh.comm());
358 
359  FindBBox find_bbox;
360 
361  // Start with any unpartitioned nodes we know about locally
362  Threads::parallel_reduce (ConstNodeRange (mesh.pid_nodes_begin(DofObject::invalid_processor_id),
363  mesh.pid_nodes_end(DofObject::invalid_processor_id)),
364  find_bbox);
365 
366  // Add our local nodes
368  mesh.local_nodes_end()),
369  find_bbox);
370 
371  // Compare the bounding boxes across processors
372  mesh.comm().min(find_bbox.min());
373  mesh.comm().max(find_bbox.max());
374 
375  return find_bbox.bbox();
376 }
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 420 of file mesh_tools.C.

References libMesh::ParallelObject::comm(), 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().

422 {
423  // This can only be run in parallel, with consistent arguments.
424  libmesh_parallel_only(mesh.comm());
425  libmesh_assert(mesh.comm().verify(pid));
426 
427  libmesh_assert_less (pid, mesh.n_processors());
428 
429  FindBBox find_bbox;
430 
432  mesh.pid_elements_end(pid)),
433  find_bbox);
434 
435  // Compare the bounding boxes across processors
436  mesh.comm().min(find_bbox.min());
437  mesh.comm().max(find_bbox.max());
438 
439  return find_bbox.bbox();
440 }
processor_id_type n_processors() const
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
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 472 of file mesh_tools.C.

References libMesh::MeshBase::active_local_subdomain_elements_begin(), libMesh::MeshBase::active_local_subdomain_elements_end(), libMesh::ParallelObject::comm(), 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().

474 {
475  // This can only be run in parallel, with consistent arguments.
476  libmesh_parallel_only(mesh.comm());
477  libmesh_assert(mesh.comm().verify(sid));
478 
479  FindBBox find_bbox;
480 
484  find_bbox);
485 
486  // Compare the bounding boxes across processors
487  mesh.comm().min(find_bbox.min());
488  mesh.comm().max(find_bbox.max());
489 
490  return find_bbox.bbox();
491 }
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
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 510 of file mesh_tools.C.

References libMesh::MeshBase::element_ptr_range().

Referenced by weight().

512 {
513  // Loop over the the elements. If the current element type isn't in
514  // the vector, insert it.
515  for (const auto & elem : mesh.element_ptr_range())
516  if (!std::count(et.begin(), et.end(), elem->type()))
517  et.push_back(elem->type());
518 }
virtual SimpleRange< element_iterator > element_ptr_range()=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 290 of file mesh_tools.C.

References libMesh::MeshBase::active_element_ptr_range(), libmesh_nullptr, libMesh::MeshBase::max_node_id(), and side.

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

292 {
293  // Resize the vector which holds boundary nodes and fill with false.
294  on_boundary.resize(mesh.max_node_id());
295  std::fill(on_boundary.begin(),
296  on_boundary.end(),
297  false);
298 
299  // Loop over elements, find those on boundary, and
300  // mark them as true in on_boundary.
301  for (const auto & elem : mesh.active_element_ptr_range())
302  for (auto s : elem->side_index_range())
303  if (elem->neighbor_ptr(s) == libmesh_nullptr) // on the boundary
304  {
305  std::unique_ptr<const Elem> side = elem->build_side_ptr(s);
306 
307  for (auto & node : side->node_ref_range())
308  on_boundary[node.id()] = true;
309  }
310 }
unsigned short int side
Definition: xdr_io.C:49
virtual dof_id_type max_node_id() const =0
const class libmesh_nullptr_t libmesh_nullptr
virtual SimpleRange< element_iterator > active_element_ptr_range()=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 873 of file mesh_tools.C.

References libMesh::MeshBase::active_local_element_ptr_range(), 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, and libMesh::Elem::which_neighbor_am_i().

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

875 {
876  // Loop through all the elements
877  for (auto & elem : mesh.active_local_element_ptr_range())
878  if (elem->type() == QUAD4)
879  for (auto s : elem->side_index_range())
880  {
881  // Loop over the sides looking for sides that have hanging nodes
882  // This code is inspired by compute_proj_constraints()
883  const Elem * neigh = elem->neighbor_ptr(s);
884 
885  // If not a boundary side
886  if (neigh != libmesh_nullptr)
887  {
888  // Is there a coarser element next to this one?
889  if (neigh->level() < elem->level())
890  {
891  const Elem * ancestor = elem;
892  while (neigh->level() < ancestor->level())
893  ancestor = ancestor->parent();
894  unsigned int s_neigh = neigh->which_neighbor_am_i(ancestor);
895  libmesh_assert_less (s_neigh, neigh->n_neighbors());
896 
897  // Couple of helper uints...
898  unsigned int local_node1=0;
899  unsigned int local_node2=0;
900 
901  bool found_in_neighbor = false;
902 
903  // Find the two vertices that make up this side
904  while (!elem->is_node_on_side(local_node1++,s)) { }
905  local_node1--;
906 
907  // Start looking for the second one with the next node
908  local_node2=local_node1+1;
909 
910  // Find the other one
911  while (!elem->is_node_on_side(local_node2++,s)) { }
912  local_node2--;
913 
914  //Pull out their global ids:
915  dof_id_type node1 = elem->node_id(local_node1);
916  dof_id_type node2 = elem->node_id(local_node2);
917 
918  // Now find which node is present in the neighbor
919  // FIXME This assumes a level one rule!
920  // The _other_ one is the hanging node
921 
922  // First look for the first one
923  // FIXME could be streamlined a bit
924  for (unsigned int n=0;n<neigh->n_sides();n++)
925  if (neigh->node_id(n) == node1)
926  found_in_neighbor=true;
927 
928  dof_id_type hanging_node=0;
929 
930  if (!found_in_neighbor)
931  hanging_node=node1;
932  else // If it wasn't node1 then it must be node2!
933  hanging_node=node2;
934 
935  // Reset these for reuse
936  local_node1=0;
937  local_node2=0;
938 
939  // Find the first node that makes up the side in the neighbor (these should be the parent nodes)
940  while (!neigh->is_node_on_side(local_node1++,s_neigh)) { }
941  local_node1--;
942 
943  local_node2=local_node1+1;
944 
945  // Find the second node...
946  while (!neigh->is_node_on_side(local_node2++,s_neigh)) { }
947  local_node2--;
948 
949  // Save them if we haven't already found the parents for this one
950  if (hanging_nodes[hanging_node].size()<2)
951  {
952  hanging_nodes[hanging_node].push_back(neigh->node_id(local_node1));
953  hanging_nodes[hanging_node].push_back(neigh->node_id(local_node2));
954  }
955  }
956  }
957  }
958 }
virtual bool is_node_on_side(const unsigned int n, const unsigned int s) const =0
const Elem * parent() const
Definition: elem.h:2347
unsigned int which_neighbor_am_i(const Elem *e) const
Definition: elem.h:2182
The base class for all geometric element types.
Definition: elem.h:90
unsigned int n_neighbors() const
Definition: elem.h:614
const class libmesh_nullptr_t libmesh_nullptr
const Elem * neighbor_ptr(unsigned int i) const
Definition: elem.h:1968
virtual SimpleRange< element_iterator > active_local_element_ptr_range()=0
virtual unsigned int n_sides() const =0
unsigned int level() const
Definition: elem.h:2389
dof_id_type node_id(const unsigned int i) const
Definition: elem.h:1832
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 699 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_nullptr, libMesh::Elem::local_node(), libMesh::Elem::n_edges(), n_nodes, 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().

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

References libMesh::MeshBase::element_ptr_range().

Referenced by weight().

647 {
648  for (const auto & elem : mesh.element_ptr_range())
649  if (!elem->subactive())
650  for (auto & n : elem->node_ref_range())
651  not_subactive_node_ids.insert(n.id());
652 }
virtual SimpleRange< element_iterator > element_ptr_range()=0
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 1169 of file mesh_tools.C.

References libMesh::MeshBase::element_ptr_range(), and libMesh::MeshBase::node_ptr_range().

Referenced by weight().

1170 {
1171  LOG_SCOPE("libmesh_assert_connected_nodes()", "MeshTools");
1172 
1173  std::set<const Node *> used_nodes;
1174 
1175  for (const auto & elem : mesh.element_ptr_range())
1176  {
1177  libmesh_assert (elem);
1178 
1179  for (auto & n : elem->node_ref_range())
1180  used_nodes.insert(&n);
1181  }
1182 
1183  for (const auto & node : mesh.node_ptr_range())
1184  {
1185  libmesh_assert(node);
1186  libmesh_assert(used_nodes.count(node));
1187  }
1188 }
virtual SimpleRange< element_iterator > element_ptr_range()=0
virtual SimpleRange< node_iterator > node_ptr_range()=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 963 of file mesh_tools.C.

References libMesh::MeshBase::element_ptr_range(), libMesh::invalid_uint, and libMesh::MeshBase::node_ptr_range().

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

964 {
965  LOG_SCOPE("libmesh_assert_equal_n_systems()", "MeshTools");
966 
967  unsigned int n_sys = libMesh::invalid_uint;
968 
969  for (const auto & elem : mesh.element_ptr_range())
970  {
971  if (n_sys == libMesh::invalid_uint)
972  n_sys = elem->n_systems();
973  else
974  libmesh_assert_equal_to (elem->n_systems(), n_sys);
975  }
976 
977  for (const auto & node : mesh.node_ptr_range())
978  {
979  if (n_sys == libMesh::invalid_uint)
980  n_sys = node->n_systems();
981  else
982  libmesh_assert_equal_to (node->n_systems(), n_sys);
983  }
984 }
const unsigned int invalid_uint
Definition: libmesh.h:184
virtual SimpleRange< element_iterator > element_ptr_range()=0
virtual SimpleRange< node_iterator > node_ptr_range()=0
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 1070 of file mesh_tools.C.

References libMesh::MeshBase::element_ptr_range().

Referenced by weight().

1072 {
1073  for (const auto & elem : mesh.element_ptr_range())
1074  {
1075  libmesh_assert (elem);
1076  libmesh_assert_not_equal_to (elem->parent(), bad_elem);
1077  for (auto n : elem->neighbor_ptr_range())
1078  libmesh_assert_not_equal_to (n, bad_elem);
1079 
1080 #ifdef LIBMESH_ENABLE_AMR
1081  if (elem->has_children())
1082  for (auto & child : elem->child_ref_range())
1083  libmesh_assert_not_equal_to (&child, bad_elem);
1084 #endif
1085  }
1086 }
virtual SimpleRange< element_iterator > element_ptr_range()=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 989 of file mesh_tools.C.

References libMesh::MeshBase::element_ptr_range(), libMesh::Elem::INACTIVE, and libMesh::Elem::JUST_REFINED.

Referenced by weight().

990 {
991  LOG_SCOPE("libmesh_assert_old_dof_objects()", "MeshTools");
992 
993  for (const auto & elem : mesh.element_ptr_range())
994  {
995  if (elem->refinement_flag() == Elem::JUST_REFINED ||
996  elem->refinement_flag() == Elem::INACTIVE)
997  continue;
998 
999  if (elem->has_dofs())
1000  libmesh_assert(elem->old_dof_object);
1001 
1002  for (auto & node : elem->node_ref_range())
1003  if (node.has_dofs())
1004  libmesh_assert(node.old_dof_object);
1005  }
1006 }
virtual SimpleRange< element_iterator > element_ptr_range()=0
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 1466 of file mesh_tools.C.

References libMesh::ParallelObject::comm(), 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().

1467 {
1468  LOG_SCOPE("libmesh_assert_parallel_consistent_procids()", "MeshTools");
1469 
1470  if (mesh.n_processors() == 1)
1471  return;
1472 
1473  libmesh_parallel_only(mesh.comm());
1474 
1475  // We want this test to be valid even when called even after nodes
1476  // have been added asynchronously but before they're renumbered
1477  dof_id_type parallel_max_elem_id = mesh.max_elem_id();
1478  mesh.comm().max(parallel_max_elem_id);
1479 
1480  // Check processor ids for consistency between processors
1481 
1482  for (dof_id_type i=0; i != parallel_max_elem_id; ++i)
1483  {
1484  const Elem * elem = mesh.query_elem_ptr(i);
1485 
1486  processor_id_type min_id =
1487  elem ? elem->processor_id() :
1489  mesh.comm().min(min_id);
1490 
1491  processor_id_type max_id =
1492  elem ? elem->processor_id() :
1494  mesh.comm().max(max_id);
1495 
1496  if (elem)
1497  {
1498  libmesh_assert_equal_to (min_id, elem->processor_id());
1499  libmesh_assert_equal_to (max_id, elem->processor_id());
1500  }
1501 
1502  if (min_id == mesh.processor_id())
1503  libmesh_assert(elem);
1504  }
1505 }
processor_id_type n_processors() const
The base class for all geometric element types.
Definition: elem.h:90
uint8_t processor_id_type
Definition: id_types.h:99
long double max(long double a, double b)
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:694

Definition at line 1555 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::max_node_id(), mesh, std::min(), libMesh::Parallel::Communicator::min(), libMesh::ParallelObject::n_processors(), libMesh::Elem::node_ref_range(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), and libMesh::MeshBase::query_node_ptr().

Referenced by correct_node_proc_ids().

1556 {
1557  LOG_SCOPE("libmesh_assert_parallel_consistent_procids()", "MeshTools");
1558 
1559  if (mesh.n_processors() == 1)
1560  return;
1561 
1562  libmesh_parallel_only(mesh.comm());
1563 
1564  // We want this test to be valid even when called even after nodes
1565  // have been added asynchronously but before they're renumbered
1566  dof_id_type parallel_max_node_id = mesh.max_node_id();
1567  mesh.comm().max(parallel_max_node_id);
1568 
1569  std::vector<bool> node_touched_by_anyone(parallel_max_node_id, false);
1570 
1571  const MeshBase::const_element_iterator el_end =
1572  mesh.local_elements_end();
1574  mesh.local_elements_begin(); el != el_end; ++el)
1575  {
1576  const Elem * elem = *el;
1577  libmesh_assert (elem);
1578 
1579  for (auto & node : elem->node_ref_range())
1580  {
1581  dof_id_type nodeid = node.id();
1582  node_touched_by_anyone[nodeid] = true;
1583  }
1584  }
1585  mesh.comm().max(node_touched_by_anyone);
1586 
1587  // Check processor ids for consistency between processors
1588  // on any node an element touches
1589  for (dof_id_type i=0; i != parallel_max_node_id; ++i)
1590  {
1591  if (!node_touched_by_anyone[i])
1592  continue;
1593 
1594  const Node * node = mesh.query_node_ptr(i);
1595 
1596  processor_id_type min_id =
1597  node ? node->processor_id() :
1599  mesh.comm().min(min_id);
1600 
1601  processor_id_type max_id =
1602  node ? node->processor_id() :
1604  mesh.comm().max(max_id);
1605 
1606  if (node)
1607  {
1608  libmesh_assert_equal_to (min_id, node->processor_id());
1609  libmesh_assert_equal_to (max_id, node->processor_id());
1610  }
1611 
1612  if (min_id == mesh.processor_id())
1613  libmesh_assert(node);
1614  }
1615 }
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:90
uint8_t processor_id_type
Definition: id_types.h:99
long double max(long double a, double b)
virtual const Node * query_node_ptr(const dof_id_type i) const =0
virtual element_iterator local_elements_end()=0
SimpleRange< NodeRefIter > node_ref_range()
Definition: elem.h:2048
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:694
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 1422 of file mesh_tools.C.

References libMesh::Elem::child_ref_range(), libMesh::MeshBase::element_ptr_range(), libMesh::Elem::has_children(), libMesh::libmesh_ignore(), mesh, libMesh::Elem::parent(), libMesh::DofObject::processor_id(), and libMesh::remote_elem.

1423 {
1424  LOG_SCOPE("libmesh_assert_topology_consistent_procids()", "MeshTools");
1425 
1426  // This parameter is not used when !LIBMESH_ENABLE_AMR
1427  libmesh_ignore(mesh);
1428 
1429  // If we're adaptively refining, check processor ids for consistency
1430  // between parents and children.
1431 #ifdef LIBMESH_ENABLE_AMR
1432 
1433  // Ancestor elements we won't worry about, but subactive and active
1434  // elements ought to have parents with consistent processor ids
1435  for (const auto & elem : mesh.element_ptr_range())
1436  {
1437  libmesh_assert(elem);
1438 
1439  if (!elem->active() && !elem->subactive())
1440  continue;
1441 
1442  const Elem * parent = elem->parent();
1443 
1444  if (parent)
1445  {
1446  libmesh_assert(parent->has_children());
1447  processor_id_type parent_procid = parent->processor_id();
1448  bool matching_child_id = false;
1449  // If we've got a remote_elem then we don't know whether
1450  // it's responsible for the parent's processor id; all
1451  // we can do is assume it is and let its processor fail
1452  // an assert if there's something wrong.
1453  for (auto & child : parent->child_ref_range())
1454  if (&child == remote_elem ||
1455  child.processor_id() == parent_procid)
1456  matching_child_id = true;
1457  libmesh_assert(matching_child_id);
1458  }
1459  }
1460 #endif
1461 }
bool has_children() const
Definition: elem.h:2296
const Elem * parent() const
Definition: elem.h:2347
The base class for all geometric element types.
Definition: elem.h:90
uint8_t processor_id_type
Definition: id_types.h:99
SimpleRange< ChildRefIter > child_ref_range()
Definition: elem.h:1700
virtual SimpleRange< element_iterator > element_ptr_range()=0
void libmesh_ignore(const T &)
processor_id_type processor_id() const
Definition: dof_object.h:694
const RemoteElem * remote_elem
Definition: remote_elem.C:57

Definition at line 1510 of file mesh_tools.C.

References libMesh::ParallelObject::comm(), libMesh::MeshBase::local_elements_begin(), libMesh::MeshBase::local_elements_end(), libMesh::MeshBase::local_node_ptr_range(), libMesh::Parallel::Communicator::max(), libMesh::MeshBase::max_node_id(), mesh, libMesh::ParallelObject::n_processors(), and libMesh::Elem::node_ref_range().

1511 {
1512  LOG_SCOPE("libmesh_assert_topology_consistent_procids()", "MeshTools");
1513 
1514  if (mesh.n_processors() == 1)
1515  return;
1516 
1517  libmesh_parallel_only(mesh.comm());
1518 
1519  // We want this test to be valid even when called even after nodes
1520  // have been added asynchronously but before they're renumbered
1521  dof_id_type parallel_max_node_id = mesh.max_node_id();
1522  mesh.comm().max(parallel_max_node_id);
1523 
1524  std::vector<bool> node_touched_by_me(parallel_max_node_id, false);
1525 
1526  const MeshBase::const_element_iterator el_end =
1527  mesh.local_elements_end();
1529  mesh.local_elements_begin(); el != el_end; ++el)
1530  {
1531  const Elem * elem = *el;
1532  libmesh_assert (elem);
1533 
1534  for (auto & node : elem->node_ref_range())
1535  {
1536  dof_id_type nodeid = node.id();
1537  node_touched_by_me[nodeid] = true;
1538  }
1539  }
1540  std::vector<bool> node_touched_by_anyone(node_touched_by_me);
1541  mesh.comm().max(node_touched_by_anyone);
1542 
1543  for (const auto & node : mesh.local_node_ptr_range())
1544  {
1545  libmesh_assert(node);
1546  dof_id_type nodeid = node->id();
1547  libmesh_assert(!node_touched_by_anyone[nodeid] ||
1548  node_touched_by_me[nodeid]);
1549  }
1550 }
virtual SimpleRange< node_iterator > local_node_ptr_range()=0
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:90
virtual element_iterator local_elements_end()=0
SimpleRange< NodeRefIter > node_ref_range()
Definition: elem.h:2048
const Parallel::Communicator & comm() const
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 1113 of file mesh_tools.C.

References libMesh::MeshBase::element_ptr_range(), libMesh::DofObject::id(), libMesh::Elem::parent(), and libMesh::DofObject::processor_id().

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

1114 {
1115  LOG_SCOPE("libmesh_assert_valid_amr_elem_ids()", "MeshTools");
1116 
1117  for (const auto & elem : mesh.element_ptr_range())
1118  {
1119  libmesh_assert (elem);
1120 
1121  const Elem * parent = elem->parent();
1122 
1123  if (parent)
1124  {
1125  libmesh_assert_greater_equal (elem->id(), parent->id());
1126  libmesh_assert_greater_equal (elem->processor_id(), parent->processor_id());
1127  }
1128  }
1129 }
const Elem * parent() const
Definition: elem.h:2347
The base class for all geometric element types.
Definition: elem.h:90
virtual SimpleRange< element_iterator > element_ptr_range()=0
dof_id_type id() const
Definition: dof_object.h:632
processor_id_type processor_id() const
Definition: dof_object.h:694
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 1133 of file mesh_tools.C.

References libMesh::MeshBase::element_ptr_range(), libMesh::Elem::interior_parent(), libMesh::Elem::level(), libMesh::Elem::parent(), libMesh::remote_elem, and libMesh::Elem::top_parent().

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

1134 {
1135  LOG_SCOPE("libmesh_assert_valid_amr_interior_parents()", "MeshTools");
1136 
1137  for (const auto & elem : mesh.element_ptr_range())
1138  {
1139  libmesh_assert (elem);
1140 
1141  // We can skip to the next element if we're full-dimension
1142  // and therefore don't have any interior parents
1143  if (elem->dim() >= LIBMESH_DIM)
1144  continue;
1145 
1146  const Elem * ip = elem->interior_parent();
1147 
1148  const Elem * parent = elem->parent();
1149 
1150  if (ip && (ip != remote_elem) && parent)
1151  {
1152  libmesh_assert_equal_to (ip->top_parent(),
1153  elem->top_parent()->interior_parent());
1154 
1155  if (ip->level() == elem->level())
1156  libmesh_assert_equal_to (ip->parent(),
1157  parent->interior_parent());
1158  else
1159  {
1160  libmesh_assert_less (ip->level(), elem->level());
1161  libmesh_assert_equal_to (ip, parent->interior_parent());
1162  }
1163  }
1164  }
1165 }
const Elem * parent() const
Definition: elem.h:2347
const Elem * interior_parent() const
Definition: elem.C:843
The base class for all geometric element types.
Definition: elem.h:90
virtual SimpleRange< element_iterator > element_ptr_range()=0
unsigned int level() const
Definition: elem.h:2389
const Elem * top_parent() const
Definition: elem.h:2371
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 1194 of file mesh_tools.C.

References libMesh::ParallelObject::comm(), libMesh::MeshBase::get_boundary_info(), libMesh::BoundaryInfo::invalid_id, 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().

1195 {
1196  LOG_SCOPE("libmesh_assert_valid_boundary_ids()", "MeshTools");
1197 
1198  if (mesh.n_processors() == 1)
1199  return;
1200 
1201  libmesh_parallel_only(mesh.comm());
1202 
1203  const BoundaryInfo & boundary_info = mesh.get_boundary_info();
1204 
1205  dof_id_type pmax_elem_id = mesh.max_elem_id();
1206  mesh.comm().max(pmax_elem_id);
1207 
1208  for (dof_id_type i=0; i != pmax_elem_id; ++i)
1209  {
1210  const Elem * elem = mesh.query_elem_ptr(i);
1211  const unsigned int my_n_nodes = elem ? elem->n_nodes() : 0;
1212  const unsigned int my_n_edges = elem ? elem->n_edges() : 0;
1213  const unsigned int my_n_sides = elem ? elem->n_sides() : 0;
1214  unsigned int
1215  n_nodes = my_n_nodes,
1216  n_edges = my_n_edges,
1217  n_sides = my_n_sides;
1218 
1219  mesh.comm().max(n_nodes);
1220  mesh.comm().max(n_edges);
1221  mesh.comm().max(n_sides);
1222 
1223  if (elem)
1224  {
1225  libmesh_assert_equal_to(my_n_nodes, n_nodes);
1226  libmesh_assert_equal_to(my_n_edges, n_edges);
1227  libmesh_assert_equal_to(my_n_sides, n_sides);
1228  }
1229 
1230  // Let's test all IDs on the element with one communication
1231  // rather than n_nodes + n_edges + n_sides communications, to
1232  // cut down on latency in dbg modes.
1233  std::vector<boundary_id_type> all_bcids;
1234 
1235  for (unsigned int n=0; n != n_nodes; ++n)
1236  {
1237  std::vector<boundary_id_type> bcids;
1238  if (elem)
1239  {
1240  boundary_info.boundary_ids(elem->node_ptr(n), bcids);
1241 
1242  // Ordering of boundary ids shouldn't matter
1243  std::sort(bcids.begin(), bcids.end());
1244  }
1245  // libmesh_assert(mesh.comm().semiverify (elem ? &bcids : libmesh_nullptr));
1246 
1247  all_bcids.insert(all_bcids.end(), bcids.begin(),
1248  bcids.end());
1249  // Separator
1250  all_bcids.push_back(BoundaryInfo::invalid_id);
1251  }
1252 
1253  for (unsigned short e=0; e != n_edges; ++e)
1254  {
1255  std::vector<boundary_id_type> bcids;
1256 
1257  if (elem)
1258  {
1259  boundary_info.edge_boundary_ids(elem, e, bcids);
1260 
1261  // Ordering of boundary ids shouldn't matter
1262  std::sort(bcids.begin(), bcids.end());
1263  }
1264 
1265  // libmesh_assert(mesh.comm().semiverify (elem ? &bcids : libmesh_nullptr));
1266 
1267  all_bcids.insert(all_bcids.end(), bcids.begin(),
1268  bcids.end());
1269  // Separator
1270  all_bcids.push_back(BoundaryInfo::invalid_id);
1271 
1272  if (elem)
1273  {
1274  boundary_info.raw_edge_boundary_ids(elem, e, bcids);
1275 
1276  // Ordering of boundary ids shouldn't matter
1277  std::sort(bcids.begin(), bcids.end());
1278 
1279  all_bcids.insert(all_bcids.end(), bcids.begin(),
1280  bcids.end());
1281  // Separator
1282  all_bcids.push_back(BoundaryInfo::invalid_id);
1283  }
1284 
1285  // libmesh_assert(mesh.comm().semiverify (elem ? &bcids : libmesh_nullptr));
1286  }
1287 
1288  for (unsigned short s=0; s != n_sides; ++s)
1289  {
1290  std::vector<boundary_id_type> bcids;
1291 
1292  if (elem)
1293  {
1294  boundary_info.boundary_ids(elem, s, bcids);
1295 
1296  // Ordering of boundary ids shouldn't matter
1297  std::sort(bcids.begin(), bcids.end());
1298 
1299  all_bcids.insert(all_bcids.end(), bcids.begin(),
1300  bcids.end());
1301  // Separator
1302  all_bcids.push_back(BoundaryInfo::invalid_id);
1303  }
1304 
1305  // libmesh_assert(mesh.comm().semiverify (elem ? &bcids : libmesh_nullptr));
1306 
1307  if (elem)
1308  {
1309  boundary_info.raw_boundary_ids(elem, s, bcids);
1310 
1311  // Ordering of boundary ids shouldn't matter
1312  std::sort(bcids.begin(), bcids.end());
1313 
1314  all_bcids.insert(all_bcids.end(), bcids.begin(),
1315  bcids.end());
1316  // Separator
1317  all_bcids.push_back(BoundaryInfo::invalid_id);
1318  }
1319 
1320  // libmesh_assert(mesh.comm().semiverify (elem ? &bcids : libmesh_nullptr));
1321  }
1322 
1323  for (unsigned short sf=0; sf != 2; ++sf)
1324  {
1325  std::vector<boundary_id_type> bcids;
1326 
1327  if (elem)
1328  {
1329  boundary_info.shellface_boundary_ids(elem, sf, bcids);
1330 
1331  // Ordering of boundary ids shouldn't matter
1332  std::sort(bcids.begin(), bcids.end());
1333 
1334  all_bcids.insert(all_bcids.end(), bcids.begin(),
1335  bcids.end());
1336  // Separator
1337  all_bcids.push_back(BoundaryInfo::invalid_id);
1338  }
1339 
1340  // libmesh_assert(mesh.comm().semiverify (elem ? &bcids : libmesh_nullptr));
1341 
1342  if (elem)
1343  {
1344  boundary_info.raw_shellface_boundary_ids(elem, sf, bcids);
1345 
1346  // Ordering of boundary ids shouldn't matter
1347  std::sort(bcids.begin(), bcids.end());
1348 
1349  all_bcids.insert(all_bcids.end(), bcids.begin(),
1350  bcids.end());
1351  // Separator
1352  all_bcids.push_back(BoundaryInfo::invalid_id);
1353  }
1354 
1355  // libmesh_assert(mesh.comm().semiverify (elem ? &bcids : libmesh_nullptr));
1356  }
1357 
1358  libmesh_assert(mesh.comm().semiverify
1359  (elem ? &all_bcids : libmesh_nullptr));
1360  }
1361 }
const BoundaryInfo & get_boundary_info() const
Definition: mesh_base.h:118
virtual unsigned int n_edges() const =0
processor_id_type n_processors() const
The base class for all geometric element types.
Definition: elem.h:90
const class libmesh_nullptr_t libmesh_nullptr
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:1875
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 1363 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().

1364 {
1365  LOG_SCOPE("libmesh_assert_valid_dof_ids()", "MeshTools");
1366 
1367  if (mesh.n_processors() == 1)
1368  return;
1369 
1370  libmesh_parallel_only(mesh.comm());
1371 
1372  dof_id_type pmax_elem_id = mesh.max_elem_id();
1373  mesh.comm().max(pmax_elem_id);
1374 
1375  for (dof_id_type i=0; i != pmax_elem_id; ++i)
1376  assert_semiverify_dofobj(mesh.comm(),
1377  mesh.query_elem_ptr(i),
1378  sysnum);
1379 
1380  dof_id_type pmax_node_id = mesh.max_node_id();
1381  mesh.comm().max(pmax_node_id);
1382 
1383  for (dof_id_type i=0; i != pmax_node_id; ++i)
1384  assert_semiverify_dofobj(mesh.comm(),
1385  mesh.query_node_ptr(i),
1386  sysnum);
1387 }
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 1090 of file mesh_tools.C.

References libMesh::MeshBase::active_element_ptr_range().

Referenced by libMesh::DistributedMesh::renumber_nodes_and_elements(), and weight().

1091 {
1092  LOG_SCOPE("libmesh_assert_valid_elem_ids()", "MeshTools");
1093 
1094  processor_id_type lastprocid = 0;
1095  dof_id_type lastelemid = 0;
1096 
1097  for (const auto & elem : mesh.active_element_ptr_range())
1098  {
1099  libmesh_assert (elem);
1100  processor_id_type elemprocid = elem->processor_id();
1101  dof_id_type elemid = elem->id();
1102 
1103  libmesh_assert_greater_equal (elemid, lastelemid);
1104  libmesh_assert_greater_equal (elemprocid, lastprocid);
1105 
1106  lastelemid = elemid;
1107  lastprocid = elemprocid;
1108  }
1109 }
uint8_t processor_id_type
Definition: id_types.h:99
virtual SimpleRange< element_iterator > active_element_ptr_range()=0
uint8_t dof_id_type
Definition: id_types.h:64
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 1707 of file mesh_tools.C.

References libMesh::ParallelObject::comm(), libMesh::MeshBase::element_ptr_range(), libMesh::DofObject::id(), libMesh::DofObject::invalid_id, 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().

1709 {
1710  LOG_SCOPE("libmesh_assert_valid_neighbors()", "MeshTools");
1711 
1712  for (const auto & elem : mesh.element_ptr_range())
1713  {
1714  libmesh_assert (elem);
1715  elem->libmesh_assert_valid_neighbors();
1716  }
1717 
1718  if (mesh.n_processors() == 1)
1719  return;
1720 
1721  libmesh_parallel_only(mesh.comm());
1722 
1723  dof_id_type pmax_elem_id = mesh.max_elem_id();
1724  mesh.comm().max(pmax_elem_id);
1725 
1726  for (dof_id_type i=0; i != pmax_elem_id; ++i)
1727  {
1728  const Elem * elem = mesh.query_elem_ptr(i);
1729 
1730  const unsigned int my_n_neigh = elem ? elem->n_neighbors() : 0;
1731  unsigned int n_neigh = my_n_neigh;
1732  mesh.comm().max(n_neigh);
1733  if (elem)
1734  libmesh_assert_equal_to (my_n_neigh, n_neigh);
1735 
1736  for (unsigned int n = 0; n != n_neigh; ++n)
1737  {
1738  dof_id_type my_neighbor = DofObject::invalid_id;
1739  dof_id_type * p_my_neighbor = libmesh_nullptr;
1740 
1741  // If we have a non-remote_elem neighbor link, then we can
1742  // verify it.
1743  if (elem && elem->neighbor_ptr(n) != remote_elem)
1744  {
1745  p_my_neighbor = &my_neighbor;
1746  if (elem->neighbor_ptr(n))
1747  my_neighbor = elem->neighbor_ptr(n)->id();
1748 
1749  // But wait - if we haven't set remote_elem links yet then
1750  // some NULL links on ghost elements might be
1751  // future-remote_elem links, so we can't verify those.
1752  if (!assert_valid_remote_elems &&
1753  !elem->neighbor_ptr(n) &&
1754  elem->processor_id() != mesh.processor_id())
1755  p_my_neighbor = libmesh_nullptr;
1756  }
1757  libmesh_assert(mesh.comm().semiverify(p_my_neighbor));
1758  }
1759  }
1760 }
processor_id_type n_processors() const
The base class for all geometric element types.
Definition: elem.h:90
unsigned int n_neighbors() const
Definition: elem.h:614
const class libmesh_nullptr_t libmesh_nullptr
const Elem * neighbor_ptr(unsigned int i) const
Definition: elem.h:1968
virtual dof_id_type max_elem_id() const =0
virtual SimpleRange< element_iterator > element_ptr_range()=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:632
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:694
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 1013 of file mesh_tools.C.

References libMesh::MeshBase::element_ptr_range(), and libMesh::remote_elem.

Referenced by weight().

1014 {
1015  LOG_SCOPE("libmesh_assert_valid_node_pointers()", "MeshTools");
1016 
1017  // Here we specifically do not want "auto &" because we need to
1018  // reseat the (temporary) pointer variable in the loop below,
1019  // without modifying the original.
1020  for (const Elem * elem : mesh.element_ptr_range())
1021  {
1022  libmesh_assert (elem);
1023  while (elem)
1024  {
1025  elem->libmesh_assert_valid_node_pointers();
1026  for (auto n : elem->neighbor_ptr_range())
1027  if (n && n != remote_elem)
1028  n->libmesh_assert_valid_node_pointers();
1029 
1030  libmesh_assert_not_equal_to (elem->parent(), remote_elem);
1031  elem = elem->parent();
1032  }
1033  }
1034 }
The base class for all geometric element types.
Definition: elem.h:90
virtual SimpleRange< element_iterator > element_ptr_range()=0
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 501 of file mesh_tools.h.

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

501  {
502  libmesh_assert_parallel_consistent_procids<DofObjectSubclass>(mesh);
503  libmesh_assert_topology_consistent_procids<DofObjectSubclass>(mesh);
504 }
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 1624 of file mesh_tools.C.

References libMesh::ParallelObject::comm(), libMesh::MeshBase::element_ptr_range(), libMesh::Parallel::Communicator::max(), libMesh::MeshBase::max_elem_id(), libMesh::Parallel::Communicator::min(), and libMesh::ParallelObject::n_processors().

Referenced by libmesh_assert_valid_procids().

1625 {
1626  LOG_SCOPE("libmesh_assert_valid_refinement_flags()", "MeshTools");
1627 
1628  libmesh_parallel_only(mesh.comm());
1629  if (mesh.n_processors() == 1)
1630  return;
1631 
1632  dof_id_type pmax_elem_id = mesh.max_elem_id();
1633  mesh.comm().max(pmax_elem_id);
1634 
1635  std::vector<unsigned char> my_elem_h_state(pmax_elem_id, 255);
1636  std::vector<unsigned char> my_elem_p_state(pmax_elem_id, 255);
1637 
1638  for (const auto & elem : mesh.element_ptr_range())
1639  {
1640  libmesh_assert (elem);
1641  dof_id_type elemid = elem->id();
1642 
1643  my_elem_h_state[elemid] =
1644  static_cast<unsigned char>(elem->refinement_flag());
1645 
1646  my_elem_p_state[elemid] =
1647  static_cast<unsigned char>(elem->p_refinement_flag());
1648  }
1649  std::vector<unsigned char> min_elem_h_state(my_elem_h_state);
1650  mesh.comm().min(min_elem_h_state);
1651 
1652  std::vector<unsigned char> min_elem_p_state(my_elem_p_state);
1653  mesh.comm().min(min_elem_p_state);
1654 
1655  for (dof_id_type i=0; i!= pmax_elem_id; ++i)
1656  {
1657  libmesh_assert(my_elem_h_state[i] == 255 ||
1658  my_elem_h_state[i] == min_elem_h_state[i]);
1659  libmesh_assert(my_elem_p_state[i] == 255 ||
1660  my_elem_p_state[i] == min_elem_p_state[i]);
1661  }
1662 }
processor_id_type n_processors() const
virtual dof_id_type max_elem_id() const =0
virtual SimpleRange< element_iterator > element_ptr_range()=0
const Parallel::Communicator & comm() const
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 1672 of file mesh_tools.C.

References libMesh::MeshBase::element_ptr_range(), libMesh::Elem::JUST_REFINED, and libMesh::remote_elem.

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

1673 {
1674  LOG_SCOPE("libmesh_assert_valid_refinement_tree()", "MeshTools");
1675 
1676  for (const auto & elem : mesh.element_ptr_range())
1677  {
1678  libmesh_assert(elem);
1679  if (elem->has_children())
1680  for (auto & child : elem->child_ref_range())
1681  if (&child != remote_elem)
1682  libmesh_assert_equal_to (child.parent(), elem);
1683  if (elem->active())
1684  {
1685  libmesh_assert(!elem->ancestor());
1686  libmesh_assert(!elem->subactive());
1687  }
1688  else if (elem->ancestor())
1689  {
1690  libmesh_assert(!elem->subactive());
1691  }
1692  else
1693  libmesh_assert(elem->subactive());
1694 
1695  if (elem->p_refinement_flag() == Elem::JUST_REFINED)
1696  libmesh_assert_greater(elem->p_level(), 0);
1697  }
1698 }
virtual SimpleRange< element_iterator > element_ptr_range()=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 1037 of file mesh_tools.C.

References libMesh::Elem::active(), libMesh::Elem::child_ref_range(), libMesh::Elem::has_children(), libMesh::MeshBase::local_elements_begin(), libMesh::MeshBase::local_elements_end(), libMesh::Elem::neighbor_ptr_range(), libMesh::Elem::parent(), and libMesh::remote_elem.

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

1038 {
1039  LOG_SCOPE("libmesh_assert_valid_remote_elems()", "MeshTools");
1040 
1041  const MeshBase::const_element_iterator el_end =
1042  mesh.local_elements_end();
1044  mesh.local_elements_begin(); el != el_end; ++el)
1045  {
1046  const Elem * elem = *el;
1047  libmesh_assert (elem);
1048 
1049  // We currently don't allow active_local_elements to have
1050  // remote_elem neighbors
1051  if (elem->active())
1052  for (auto n : elem->neighbor_ptr_range())
1053  libmesh_assert_not_equal_to (n, remote_elem);
1054 
1055 #ifdef LIBMESH_ENABLE_AMR
1056  const Elem * parent = elem->parent();
1057  if (parent)
1058  libmesh_assert_not_equal_to (parent, remote_elem);
1059 
1060  // We can only be strict about active elements' subactive
1061  // children
1062  if (elem->active() && elem->has_children())
1063  for (auto & child : elem->child_ref_range())
1064  libmesh_assert_not_equal_to (&child, remote_elem);
1065 #endif
1066  }
1067 }
bool has_children() const
Definition: elem.h:2296
bool active() const
Definition: elem.h:2258
virtual element_iterator local_elements_begin()=0
const Elem * parent() const
Definition: elem.h:2347
The base class for all geometric element types.
Definition: elem.h:90
SimpleRange< ChildRefIter > child_ref_range()
Definition: elem.h:1700
virtual element_iterator local_elements_end()=0
SimpleRange< NeighborPtrIter > neighbor_ptr_range()
Definition: elem.h:2856
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 1391 of file mesh_tools.C.

References libMesh::ParallelObject::comm(), 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().

1392 {
1393  LOG_SCOPE("libmesh_assert_valid_unique_ids()", "MeshTools");
1394 
1395  libmesh_parallel_only(mesh.comm());
1396 
1397  dof_id_type pmax_elem_id = mesh.max_elem_id();
1398  mesh.comm().max(pmax_elem_id);
1399 
1400  for (dof_id_type i=0; i != pmax_elem_id; ++i)
1401  {
1402  const Elem * elem = mesh.query_elem_ptr(i);
1403  const unique_id_type unique_id = elem ? elem->unique_id() : 0;
1404  const unique_id_type * uid_ptr = elem ? &unique_id : libmesh_nullptr;
1405  libmesh_assert(mesh.comm().semiverify(uid_ptr));
1406  }
1407 
1408  dof_id_type pmax_node_id = mesh.max_node_id();
1409  mesh.comm().max(pmax_node_id);
1410 
1411  for (dof_id_type i=0; i != pmax_node_id; ++i)
1412  {
1413  const Node * node = mesh.query_node_ptr(i);
1414  const unique_id_type unique_id = node ? node->unique_id() : 0;
1415  const unique_id_type * uid_ptr = node ? &unique_id : libmesh_nullptr;
1416  libmesh_assert(mesh.comm().semiverify(uid_ptr));
1417  }
1418 }
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:90
const class libmesh_nullptr_t libmesh_nullptr
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:649
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 531 of file mesh_tools.C.

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

Referenced by weight().

533 {
534  return static_cast<dof_id_type>(std::distance(mesh.active_type_elements_begin(type),
535  mesh.active_type_elements_end (type)));
536 }
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 567 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().

568 {
569  libmesh_parallel_only(mesh.comm());
570 
571  unsigned int nl = MeshTools::n_active_local_levels(mesh);
572 
575  const MeshBase::const_element_iterator end_el =
577 
578  for ( ; el != end_el; ++el)
579  if ((*el)->active())
580  nl = std::max((*el)->level() + 1, nl);
581 
582  mesh.comm().max(nl);
583  return nl;
584 }
unsigned int n_active_local_levels(const MeshBase &mesh)
Definition: mesh_tools.C:555
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 555 of file mesh_tools.C.

References libMesh::MeshBase::active_local_element_ptr_range(), and std::max().

Referenced by n_active_levels(), and weight().

556 {
557  unsigned int nl = 0;
558 
559  for (auto & elem : mesh.active_local_element_ptr_range())
560  nl = std::max(elem->level() + 1, nl);
561 
562  return nl;
563 }
long double max(long double a, double b)
virtual SimpleRange< element_iterator > active_local_element_ptr_range()=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 522 of file mesh_tools.C.

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

Referenced by weight().

524 {
525  return static_cast<dof_id_type>(std::distance(mesh.type_elements_begin(type),
526  mesh.type_elements_end (type)));
527 }
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 603 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().

604 {
605  libmesh_parallel_only(mesh.comm());
606 
607  unsigned int nl = MeshTools::n_local_levels(mesh);
608 
611  const MeshBase::const_element_iterator end_el =
613 
614  for ( ; el != end_el; ++el)
615  nl = std::max((*el)->level() + 1, nl);
616 
617  mesh.comm().max(nl);
618 
619  // n_levels() is only valid and should only be called in cases where
620  // the mesh is validly distributed (or serialized). Let's run an
621  // expensive test in debug mode to make sure this is such a case.
622 #ifdef DEBUG
623  const unsigned int paranoid_nl = MeshTools::paranoid_n_levels(mesh);
624  libmesh_assert_equal_to(nl, paranoid_nl);
625 #endif
626  return nl;
627 }
virtual element_iterator unpartitioned_elements_begin()=0
unsigned int n_local_levels(const MeshBase &mesh)
Definition: mesh_tools.C:588
long double max(long double a, double b)
unsigned int paranoid_n_levels(const MeshBase &mesh)
Definition: mesh_tools.C:631
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 588 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().

589 {
590  unsigned int nl = 0;
591 
594 
595  for ( ; el != end_el; ++el)
596  nl = std::max((*el)->level() + 1, nl);
597 
598  return nl;
599 }
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 664 of file mesh_tools.C.

Referenced by weight().

666 {
667  return cast_int<dof_id_type>(std::distance(begin, end));
668 }
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 538 of file mesh_tools.C.

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

Referenced by weight().

541 {
542  dof_id_type cnt = 0;
543  // iterate over the elements of the specified type
546 
547  for (; el!=end; ++el)
548  if (((*el)->level() == level) && !(*el)->subactive())
549  cnt++;
550 
551  return cnt;
552 }
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 672 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().

673 {
674  libmesh_parallel_only(mesh.comm());
675 
676  unsigned int max_p_level = 0;
677 
678  // first my local elements
680  el = mesh.local_elements_begin(),
681  end_el = mesh.local_elements_end();
682 
683  for ( ; el != end_el; ++el)
684  max_p_level = std::max((*el)->p_level(), max_p_level);
685 
686  // then any unpartitioned objects
687  el = mesh.unpartitioned_elements_begin();
688  end_el = mesh.unpartitioned_elements_end();
689 
690  for ( ; el != end_el; ++el)
691  max_p_level = std::max((*el)->p_level(), max_p_level);
692 
693  mesh.comm().max(max_p_level);
694  return max_p_level + 1;
695 }
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 631 of file mesh_tools.C.

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

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

632 {
633  libmesh_parallel_only(mesh.comm());
634 
635  unsigned int nl = 0;
636  for (const auto & elem : mesh.element_ptr_range())
637  nl = std::max(elem->level() + 1, nl);
638 
639  mesh.comm().max(nl);
640  return nl;
641 }
long double max(long double a, double b)
virtual SimpleRange< element_iterator > element_ptr_range()=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 409 of file mesh_tools.C.

References create_processor_bounding_box().

Referenced by weight().

411 {
412  libmesh_deprecated();
414 }
libMesh::BoundingBox create_processor_bounding_box(const MeshBase &mesh, const processor_id_type pid)
Definition: mesh_tools.C:420
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 445 of file mesh_tools.C.

References create_processor_bounding_box(), and libMesh::Real.

Referenced by weight().

447 {
448  libMesh::BoundingBox bbox =
450 
451  const Real diag = (bbox.second - bbox.first).norm();
452  const Point cent = (bbox.second + bbox.first)/2;
453 
454  return Sphere (cent, .5*diag);
455 }
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:420
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 461 of file mesh_tools.C.

References create_subdomain_bounding_box().

Referenced by weight().

463 {
464  libmesh_deprecated();
466 }
libMesh::BoundingBox create_subdomain_bounding_box(const MeshBase &mesh, const subdomain_id_type sid)
Definition: mesh_tools.C:472
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 496 of file mesh_tools.C.

References create_subdomain_bounding_box(), and libMesh::Real.

Referenced by weight().

498 {
499  libMesh::BoundingBox bbox =
501 
502  const Real diag = (bbox.second - bbox.first).norm();
503  const Point cent = (bbox.second + bbox.first)/2;
504 
505  return Sphere (cent, .5*diag);
506 }
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:472
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 222 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().

223 {
224  if (!mesh.is_serial())
225  {
226  libmesh_parallel_only(mesh.comm());
228  mesh.comm().sum(weight);
229  dof_id_type unpartitioned_weight =
230  MeshTools::weight (mesh, DofObject::invalid_processor_id);
231  return weight + unpartitioned_weight;
232  }
233 
234  SumElemWeight sew;
235 
237  mesh.elements_end()),
238  sew);
239  return sew.weight();
240 
241 }
virtual bool is_serial() const
Definition: mesh_base.h:141
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:245
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 245 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().

246 {
247  SumElemWeight sew;
248 
250  mesh.pid_elements_end(pid)),
251  sew);
252  return sew.weight();
253 }
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 103 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().

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