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)
 
Sphere bounding_sphere (const MeshBase &mesh)
 
BoundingBox processor_bounding_box (const MeshBase &mesh, const processor_id_type pid)
 
Sphere processor_bounding_sphere (const MeshBase &mesh, const processor_id_type pid)
 
BoundingBox subdomain_bounding_box (const MeshBase &mesh, const subdomain_id_type sid)
 
Sphere subdomain_bounding_sphere (const MeshBase &mesh, const subdomain_id_type sid)
 
void elem_types (const MeshBase &mesh, std::vector< ElemType > &et)
 
dof_id_type n_elem_of_type (const MeshBase &mesh, const ElemType type)
 
dof_id_type n_active_elem_of_type (const MeshBase &mesh, const ElemType type)
 
dof_id_type n_non_subactive_elem_of_type_at_level (const MeshBase &mesh, const ElemType type, const unsigned int level)
 
unsigned int n_levels (const MeshBase &mesh)
 
unsigned int n_local_levels (const MeshBase &mesh)
 
unsigned int n_active_levels (const MeshBase &mesh)
 
unsigned int n_active_local_levels (const MeshBase &mesh)
 
unsigned int n_p_levels (const MeshBase &mesh)
 
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 mininum, the second is the maximim.

Definition at line 358 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(), bounding_sphere(), libMesh::TreeNode< N >::bounds_point(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::MeshCommunication::check_for_duplicate_global_indices(), libMesh::TreeNode< N >::create_bounding_box(), libMesh::PointLocatorTree::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::TreeNode< N >::insert(), libMesh::MetisPartitioner::partition_range(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::TreeNode< N >::set_bounding_box(), libMesh::Tree< N >::Tree(), weight(), and libMesh::PostscriptIO::write().

359 {
360  // This function must be run on all processors at once
361  libmesh_parallel_only(mesh.comm());
362 
363  FindBBox find_bbox;
364 
366  mesh.local_nodes_end()),
367  find_bbox);
368 
369  // and the unpartitioned nodes
370  Threads::parallel_reduce (ConstNodeRange (mesh.pid_nodes_begin(DofObject::invalid_processor_id),
371  mesh.pid_nodes_end(DofObject::invalid_processor_id)),
372  find_bbox);
373 
374  // Compare the bounding boxes across processors
375  mesh.comm().min(find_bbox.min());
376  mesh.comm().max(find_bbox.max());
377 
378  return find_bbox.bbox();
379 }
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
Sphere libMesh::MeshTools::bounding_sphere ( const MeshBase mesh)

Same, but returns a sphere instead of a box.

Definition at line 384 of file mesh_tools.C.

References bounding_box(), and libMesh::Real.

Referenced by weight().

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

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

Referenced by libMesh::MeshTools::Subdivision::prepare_subdivision_mesh(), libMesh::VariationalMeshSmoother::readgr(), libMesh::Tree< N >::Tree(), and weight().

289 {
290  nodes_to_elem_map.resize (mesh.n_nodes());
291 
294 
295  for (; el != end; ++el)
296  for (unsigned int n=0; n<(*el)->n_nodes(); n++)
297  {
298  libmesh_assert_less ((*el)->node_id(n), nodes_to_elem_map.size());
299  libmesh_assert_less ((*el)->id(), mesh.n_elem());
300 
301  nodes_to_elem_map[(*el)->node_id(n)].push_back((*el)->id());
302  }
303 }
IterBase * end
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
virtual dof_id_type n_nodes() const =0
virtual dof_id_type n_elem() const =0
void libMesh::MeshTools::build_nodes_to_elem_map ( const MeshBase mesh,
std::vector< std::vector< const Elem * > > &  nodes_to_elem_map 
)

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

Definition at line 307 of file mesh_tools.C.

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

309 {
310  nodes_to_elem_map.resize (mesh.n_nodes());
311 
314 
315  for (; el != end; ++el)
316  for (unsigned int n=0; n<(*el)->n_nodes(); n++)
317  {
318  libmesh_assert_less ((*el)->node_id(n), nodes_to_elem_map.size());
319 
320  nodes_to_elem_map[(*el)->node_id(n)].push_back(*el);
321  }
322 }
IterBase * end
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
virtual dof_id_type n_nodes() const =0
void libMesh::MeshTools::correct_node_proc_ids ( MeshBase mesh)

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

This corrects "orphaned" processor ids that may occur from element coarsening.

On a distributed mesh, this function must be called in parallel to sync everyone's corrected processor ids on ghost nodes.

Definition at line 1806 of file mesh_tools.C.

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

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

1807 {
1808  // This function must be run on all processors at once
1809  libmesh_parallel_only(mesh.comm());
1810 
1811  // Fix all nodes' processor ids. Coarsening may have left us with
1812  // nodes which are no longer touched by any elements of the same
1813  // processor id, and for DofMap to work we need to fix that.
1814 
1815  // This is harder now that libMesh no longer requires a distributed
1816  // mesh to ghost all nodal neighbors: it is possible for two active
1817  // elements on two different processors to share the same node in
1818  // such a way that neither processor knows the others' element
1819  // exists!
1820 
1821  // We require all processors to agree on nodal processor ids before
1822  // going into this algorithm.
1823 #ifdef DEBUG
1825 #endif
1826 
1827  // We build up a set of compatible processor ids for each node
1828  proc_id_map_type new_proc_ids;
1829 
1831  const MeshBase::element_iterator e_end = mesh.active_elements_end();
1832  for (; e_it != e_end; ++e_it)
1833  {
1834  Elem * elem = *e_it;
1835  processor_id_type pid = elem->processor_id();
1836 
1837  for (unsigned int n=0; n != elem->n_nodes(); ++n)
1838  {
1839  const Node & node = elem->node_ref(n);
1840  const dof_id_type id = node.id();
1841  const proc_id_map_type::iterator it = new_proc_ids.find(id);
1842  if (it == new_proc_ids.end())
1843  new_proc_ids.insert(std::make_pair(id,pid));
1844  else
1845  it->second = std::min(it->second, pid);
1846  }
1847  }
1848 
1849  // Sort the new pids to push to each processor
1850  std::vector<std::vector<std::pair<dof_id_type, processor_id_type> > >
1851  ids_to_push(mesh.n_processors());
1852 
1853  for (MeshBase::const_node_iterator n_it = mesh.nodes_begin(),
1854  n_end = mesh.nodes_end(); n_it != n_end; ++n_it)
1855  {
1856  const Node *node = *n_it;
1857  const dof_id_type id = node->id();
1858  const proc_id_map_type::iterator it = new_proc_ids.find(id);
1859  if (it == new_proc_ids.end())
1860  continue;
1861  const processor_id_type pid = it->second;
1862  ids_to_push[node->processor_id()].push_back(std::make_pair(id, pid));
1863  }
1864 
1865  // Push using non-blocking I/O
1866  std::vector<Parallel::Request> push_requests(mesh.n_processors());
1867 
1868  for (processor_id_type p=1; p != mesh.n_processors(); ++p)
1869  {
1870  const processor_id_type procup =
1871  cast_int<processor_id_type>
1872  ((mesh.comm().rank() + p) % mesh.comm().size());
1873 
1874  mesh.comm().send(procup, ids_to_push[procup], push_requests[procup]);
1875  }
1876 
1877  for (processor_id_type p=0; p != mesh.n_processors(); ++p)
1878  {
1879  const processor_id_type procdown =
1880  cast_int<processor_id_type>
1881  ((mesh.comm().size() + mesh.comm().rank() - p) %
1882  mesh.comm().size());
1883 
1884  std::vector<std::pair<dof_id_type, processor_id_type> >
1885  ids_to_pull;
1886 
1887  if (p)
1888  mesh.comm().receive(procdown, ids_to_pull);
1889  else
1890  ids_to_pull.swap(ids_to_push[procdown]);
1891 
1892  std::vector<std::pair<dof_id_type, processor_id_type> >::iterator
1893  pulled_ids_it = ids_to_pull.begin(),
1894  pulled_ids_end = ids_to_pull.end();
1895  for (; pulled_ids_it != pulled_ids_end; ++pulled_ids_it)
1896  {
1897  const dof_id_type id = pulled_ids_it->first;
1898  const processor_id_type pid = pulled_ids_it->second;
1899  const proc_id_map_type::iterator it = new_proc_ids.find(id);
1900  if (it == new_proc_ids.end())
1901  new_proc_ids.insert(std::make_pair(id,pid));
1902  else
1903  it->second = std::min(it->second, pid);
1904  }
1905  }
1906 
1907  // Now new_proc_ids is correct for every node we used to own. Let's
1908  // ask every other processor about the nodes they used to own. But
1909  // first we'll need to keep track of which nodes we used to own,
1910  // lest we get them confused with nodes we newly own.
1911  LIBMESH_BEST_UNORDERED_SET<Node *> ex_local_nodes;
1912  for (MeshBase::node_iterator n_it = mesh.local_nodes_begin(),
1913  n_end = mesh.local_nodes_end(); n_it != n_end; ++n_it)
1914  {
1915  Node *node = *n_it;
1916  const proc_id_map_type::iterator it = new_proc_ids.find(node->id());
1917  if (it != new_proc_ids.end() && it->second != mesh.processor_id())
1918  ex_local_nodes.insert(node);
1919  }
1920 
1921  // Let's finish with previous I/O before we start more.
1922  Parallel::wait(push_requests);
1923 
1924  SyncProcIdsFromMap sync(new_proc_ids, mesh);
1926  (mesh.comm(), mesh.nodes_begin(), mesh.nodes_end(), sync);
1927 
1928  // And finally let's update the nodes we used to own.
1929  for (LIBMESH_BEST_UNORDERED_SET<Node *>::iterator n_it = ex_local_nodes.begin(),
1930  n_end = ex_local_nodes.end(); n_it != n_end; ++n_it)
1931  {
1932  Node *node = *n_it;
1933  const dof_id_type id = node->id();
1934  const proc_id_map_type::iterator it = new_proc_ids.find(id);
1935  libmesh_assert(it != new_proc_ids.end());
1936  node->processor_id() = it->second;
1937  }
1938 
1939  // We should still have consistent nodal processor ids coming out of
1940  // this algorithm.
1941 #ifdef DEBUG
1942  MeshTools::libmesh_assert_valid_procids<Node>(mesh);
1943 #endif
1944 }
Status wait(Request &r)
Definition: parallel.h:519
A geometric point in (x,y,z) space associated with a DOF.
Definition: node.h:52
unsigned int size() const
Definition: parallel.h:679
processor_id_type n_processors() const
The base class for all geometric element types.
Definition: elem.h:86
uint8_t processor_id_type
Definition: id_types.h:99
MeshBase & mesh
Definition: mesh_tools.C:1763
libmesh_assert(j)
virtual unsigned int n_nodes() const =0
virtual node_iterator nodes_begin()=0
virtual node_iterator local_nodes_end()=0
const Node & node_ref(const unsigned int i) const
Definition: elem.h:1680
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:1761
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:1528
virtual element_iterator active_elements_begin()=0
virtual element_iterator active_elements_end()=0
virtual node_iterator local_nodes_begin()=0
virtual node_iterator nodes_end()=0
const Parallel::Communicator & comm() const
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
unsigned int rank() const
Definition: parallel.h:677
dof_id_type id() const
Definition: dof_object.h:624
long double min(long double a, double b)
processor_id_type processor_id() const
uint8_t dof_id_type
Definition: id_types.h:64
processor_id_type processor_id() const
Definition: dof_object.h:686
void libMesh::MeshTools::elem_types ( const MeshBase mesh,
std::vector< ElemType > &  et 
)

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

Definition at line 465 of file mesh_tools.C.

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

Referenced by weight().

467 {
470 
471  // Automatically get the first type
472  et.push_back((*el)->type()); ++el;
473 
474  // Loop over the rest of the elements.
475  // If the current element type isn't in the
476  // vector, insert it.
477  for (; el != end; ++el)
478  if (!std::count(et.begin(), et.end(), (*el)->type()))
479  et.push_back((*el)->type());
480 }
IterBase * end
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
void libMesh::MeshTools::find_boundary_nodes ( const MeshBase mesh,
std::vector< bool > &  on_boundary 
)

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

Definition at line 326 of file mesh_tools.C.

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

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

328 {
329  // Resize the vector which holds boundary nodes and fill with false.
330  on_boundary.resize(mesh.max_node_id());
331  std::fill(on_boundary.begin(),
332  on_boundary.end(),
333  false);
334 
335  // Loop over elements, find those on boundary, and
336  // mark them as true in on_boundary.
339 
340  for (; el != end; ++el)
341  {
342  const Elem * elem = *el;
343 
344  for (unsigned int s=0; s<elem->n_neighbors(); s++)
345  if (elem->neighbor_ptr(s) == libmesh_nullptr) // on the boundary
346  {
347  const UniquePtr<const Elem> side = elem->build_side_ptr(s);
348 
349  for (unsigned int n=0; n<side->n_nodes(); n++)
350  on_boundary[side->node_id(n)] = true;
351  }
352  }
353 }
virtual UniquePtr< Elem > build_side_ptr(const unsigned int i, bool proxy=true)=0
virtual unsigned int n_neighbors() const
Definition: elem.h:530
unsigned short int side
Definition: xdr_io.C:49
virtual dof_id_type max_node_id() const =0
The base class for all geometric element types.
Definition: elem.h:86
const class libmesh_nullptr_t libmesh_nullptr
IterBase * end
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
const Elem * neighbor_ptr(unsigned int i) const
Definition: elem.h:1749
virtual element_iterator active_elements_begin()=0
virtual element_iterator active_elements_end()=0
void libMesh::MeshTools::find_hanging_nodes_and_parents ( const MeshBase mesh,
std::map< dof_id_type, std::vector< dof_id_type > > &  hanging_nodes 
)

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

Definition at line 844 of file mesh_tools.C.

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

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

846 {
849 
850  //Loop through all the elements
851  for (; it != end; ++it)
852  {
853  //Save it off for easier access
854  const Elem * elem = (*it);
855 
856  //Right now this only works for quad4's
857  //libmesh_assert_equal_to (elem->type(), QUAD4);
858  if(elem->type() == QUAD4)
859  {
860  //Loop over the sides looking for sides that have hanging nodes
861  //This code is inspired by compute_proj_constraints()
862  for (unsigned int s=0; s<elem->n_sides(); s++)
863  {
864  //If not a boundary node
865  if (elem->neighbor_ptr(s) != libmesh_nullptr)
866  {
867  // Get pointers to the element's neighbor.
868  const Elem * neigh = elem->neighbor_ptr(s);
869 
870  //Is there a coarser element next to this one?
871  if (neigh->level() < elem->level())
872  {
873  const Elem * ancestor = elem;
874  while (neigh->level() < ancestor->level())
875  ancestor = ancestor->parent();
876  unsigned int s_neigh = neigh->which_neighbor_am_i(ancestor);
877  libmesh_assert_less (s_neigh, neigh->n_neighbors());
878 
879  //Couple of helper uints...
880  unsigned int local_node1=0;
881  unsigned int local_node2=0;
882 
883  bool found_in_neighbor = false;
884 
885  //Find the two vertices that make up this side
886  while(!elem->is_node_on_side(local_node1++,s)) { }
887  local_node1--;
888 
889  //Start looking for the second one with the next node
890  local_node2=local_node1+1;
891 
892  //Find the other one
893  while(!elem->is_node_on_side(local_node2++,s)) { }
894  local_node2--;
895 
896  //Pull out their global ids:
897  dof_id_type node1 = elem->node_id(local_node1);
898  dof_id_type node2 = elem->node_id(local_node2);
899 
900  //Now find which node is present in the neighbor
901  //FIXME This assumes a level one rule!
902  //The _other_ one is the hanging node
903 
904  //First look for the first one
905  //FIXME could be streamlined a bit
906  for(unsigned int n=0;n<neigh->n_sides();n++)
907  {
908  if(neigh->node_id(n) == node1)
909  found_in_neighbor=true;
910  }
911 
912  dof_id_type hanging_node=0;
913 
914  if(!found_in_neighbor)
915  hanging_node=node1;
916  else //If it wasn't node1 then it must be node2!
917  hanging_node=node2;
918 
919  //Reset these for reuse
920  local_node1=0;
921  local_node2=0;
922 
923  //Find the first node that makes up the side in the neighbor (these should be the parent nodes)
924  while(!neigh->is_node_on_side(local_node1++,s_neigh)) { }
925  local_node1--;
926 
927  local_node2=local_node1+1;
928 
929  //Find the second node...
930  while(!neigh->is_node_on_side(local_node2++,s_neigh)) { }
931  local_node2--;
932 
933  //Save them if we haven't already found the parents for this one
934  if(hanging_nodes[hanging_node].size()<2)
935  {
936  hanging_nodes[hanging_node].push_back(neigh->node_id(local_node1));
937  hanging_nodes[hanging_node].push_back(neigh->node_id(local_node2));
938  }
939  }
940  }
941  }
942  }
943  }
944 }
virtual bool is_node_on_side(const unsigned int n, const unsigned int s) const =0
virtual ElemType type() const =0
virtual unsigned int n_neighbors() const
Definition: elem.h:530
const Elem * parent() const
Definition: elem.h:2073
unsigned int which_neighbor_am_i(const Elem *e) const
Definition: elem.h:1911
The base class for all geometric element types.
Definition: elem.h:86
const class libmesh_nullptr_t libmesh_nullptr
IterBase * end
const Elem * neighbor_ptr(unsigned int i) const
Definition: elem.h:1749
virtual element_iterator active_local_elements_begin()=0
virtual unsigned int n_sides() const =0
unsigned int level() const
Definition: elem.h:2115
dof_id_type node_id(const unsigned int i) const
Definition: elem.h:1617
virtual element_iterator active_local_elements_end()=0
uint8_t dof_id_type
Definition: id_types.h:64
void libMesh::MeshTools::find_nodal_neighbors ( const MeshBase mesh,
const Node n,
const std::vector< std::vector< const Elem * > > &  nodes_to_elem_map,
std::vector< const Node * > &  neighbors 
)

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

Definition at line 674 of file mesh_tools.C.

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

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

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

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

Referenced by weight().

617 {
619  const MeshBase::const_element_iterator end_el = mesh.elements_end();
620  for( ; el != end_el; ++el)
621  {
622  const Elem * elem = (*el);
623  if(!elem->subactive())
624  for (unsigned int n=0; n<elem->n_nodes(); ++n)
625  not_subactive_node_ids.insert(elem->node_id(n));
626  }
627 }
bool subactive() const
Definition: elem.h:2002
The base class for all geometric element types.
Definition: elem.h:86
virtual unsigned int n_nodes() const =0
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
dof_id_type node_id(const unsigned int i) const
Definition: elem.h:1617
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 1179 of file mesh_tools.C.

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

Referenced by weight().

1180 {
1181  std::set<const Node *> used_nodes;
1182 
1183  const MeshBase::const_element_iterator el_end =
1184  mesh.elements_end();
1186  mesh.elements_begin(); el != el_end; ++el)
1187  {
1188  const Elem * elem = *el;
1189  libmesh_assert (elem);
1190 
1191  for (unsigned int n=0; n<elem->n_nodes(); ++n)
1192  used_nodes.insert(elem->node_ptr(n));
1193  }
1194 
1195  const MeshBase::const_node_iterator node_end = mesh.nodes_end();
1196 
1197  for (MeshBase::const_node_iterator node_it = mesh.nodes_begin();
1198  node_it != node_end; ++node_it)
1199  {
1200  Node * node = *node_it;
1201  libmesh_assert(node);
1202  libmesh_assert(used_nodes.count(node));
1203  }
1204 }
A geometric point in (x,y,z) space associated with a DOF.
Definition: node.h:52
The base class for all geometric element types.
Definition: elem.h:86
libmesh_assert(j)
virtual unsigned int n_nodes() const =0
virtual node_iterator nodes_begin()=0
virtual element_iterator elements_begin()=0
const Node * node_ptr(const unsigned int i) const
Definition: elem.h:1658
virtual element_iterator elements_end()=0
virtual node_iterator nodes_end()=0
void libMesh::MeshTools::libmesh_assert_equal_n_systems ( const MeshBase mesh)

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

Definition at line 949 of file mesh_tools.C.

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

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

950 {
952  mesh.elements_begin();
953  const MeshBase::const_element_iterator el_end =
954  mesh.elements_end();
955  if (el == el_end)
956  return;
957 
958  const unsigned int n_sys = (*el)->n_systems();
959 
960  for (; el != el_end; ++el)
961  {
962  const Elem * elem = *el;
963  libmesh_assert_equal_to (elem->n_systems(), n_sys);
964  }
965 
967  mesh.nodes_begin();
968  const MeshBase::const_node_iterator node_end =
969  mesh.nodes_end();
970 
971  if (node_it == node_end)
972  return;
973 
974  for (; node_it != node_end; ++node_it)
975  {
976  const Node * node = *node_it;
977  libmesh_assert_equal_to (node->n_systems(), n_sys);
978  }
979 }
A geometric point in (x,y,z) space associated with a DOF.
Definition: node.h:52
The base class for all geometric element types.
Definition: elem.h:86
virtual node_iterator nodes_begin()=0
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
virtual node_iterator nodes_end()=0
unsigned int n_systems() const
Definition: dof_object.h:718
void libMesh::MeshTools::libmesh_assert_no_links_to_elem ( const MeshBase mesh,
const Elem bad_elem 
)

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

Definition at line 1071 of file mesh_tools.C.

References libMesh::Elem::child_ptr(), libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::Elem::has_children(), libMesh::libmesh_assert(), libMesh::Elem::n_children(), libMesh::Elem::n_neighbors(), libMesh::Elem::neighbor_ptr(), and libMesh::Elem::parent().

Referenced by weight().

1073 {
1074  const MeshBase::const_element_iterator el_end =
1075  mesh.elements_end();
1077  mesh.elements_begin(); el != el_end; ++el)
1078  {
1079  const Elem * elem = *el;
1080  libmesh_assert (elem);
1081  libmesh_assert_not_equal_to (elem->parent(), bad_elem);
1082  for (unsigned int n=0; n != elem->n_neighbors(); ++n)
1083  libmesh_assert_not_equal_to (elem->neighbor_ptr(n), bad_elem);
1084 #ifdef LIBMESH_ENABLE_AMR
1085  if (elem->has_children())
1086  for (unsigned int c=0; c != elem->n_children(); ++c)
1087  libmesh_assert_not_equal_to (elem->child_ptr(c), bad_elem);
1088 #endif
1089  }
1090 }
bool has_children() const
Definition: elem.h:2022
virtual unsigned int n_neighbors() const
Definition: elem.h:530
const Elem * parent() const
Definition: elem.h:2073
The base class for all geometric element types.
Definition: elem.h:86
libmesh_assert(j)
const Elem * neighbor_ptr(unsigned int i) const
Definition: elem.h:1749
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
const Elem * child_ptr(unsigned int i) const
Definition: elem.h:2163
virtual unsigned int n_children() const =0
void libMesh::MeshTools::libmesh_assert_old_dof_objects ( const MeshBase mesh)

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

Definition at line 984 of file mesh_tools.C.

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

Referenced by weight().

985 {
987  mesh.elements_begin();
988  const MeshBase::const_element_iterator el_end =
989  mesh.elements_end();
990 
991  for (; el != el_end; ++el)
992  {
993  const Elem * elem = *el;
994 
995  if (elem->refinement_flag() == Elem::JUST_REFINED ||
996  elem->refinement_flag() == Elem::INACTIVE)
997  continue;
998 
999  if (elem->has_dofs())
1001 
1002  for (unsigned int n=0; n != elem->n_nodes(); ++n)
1003  {
1004  const Node & node = elem->node_ref(n);
1005  if (node.has_dofs())
1007  }
1008  }
1009 }
bool has_dofs(const unsigned int s=libMesh::invalid_uint) const
Definition: dof_object.h:847
A geometric point in (x,y,z) space associated with a DOF.
Definition: node.h:52
The base class for all geometric element types.
Definition: elem.h:86
libmesh_assert(j)
virtual unsigned int n_nodes() const =0
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
const Node & node_ref(const unsigned int i) const
Definition: elem.h:1680
DofObject * old_dof_object
Definition: dof_object.h:89
RefinementState refinement_flag() const
Definition: elem.h:2220
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 1438 of file mesh_tools.C.

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

1439 {
1440  if (mesh.n_processors() == 1)
1441  return;
1442 
1443  libmesh_parallel_only(mesh.comm());
1444 
1445  // We want this test to be valid even when called even after nodes
1446  // have been added asynchonously but before they're renumbered
1447  dof_id_type parallel_max_elem_id = mesh.max_elem_id();
1448  mesh.comm().max(parallel_max_elem_id);
1449 
1450  // Check processor ids for consistency between processors
1451 
1452  for (dof_id_type i=0; i != parallel_max_elem_id; ++i)
1453  {
1454  const Elem * elem = mesh.query_elem_ptr(i);
1455 
1456  processor_id_type min_id =
1457  elem ? elem->processor_id() :
1459  mesh.comm().min(min_id);
1460 
1461  processor_id_type max_id =
1462  elem ? elem->processor_id() :
1464  mesh.comm().max(max_id);
1465 
1466  if (elem)
1467  {
1468  libmesh_assert_equal_to (min_id, elem->processor_id());
1469  libmesh_assert_equal_to (max_id, elem->processor_id());
1470  }
1471 
1472  if (min_id == mesh.processor_id())
1473  libmesh_assert(elem);
1474  }
1475 }
processor_id_type n_processors() const
The base class for all geometric element types.
Definition: elem.h:86
uint8_t processor_id_type
Definition: id_types.h:99
long double max(long double a, double b)
libmesh_assert(j)
virtual dof_id_type max_elem_id() const =0
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
const Parallel::Communicator & comm() const
long double min(long double a, double b)
processor_id_type processor_id() const
uint8_t dof_id_type
Definition: id_types.h:64
processor_id_type processor_id() const
Definition: dof_object.h:686

Definition at line 1528 of file mesh_tools.C.

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

Referenced by correct_node_proc_ids().

1529 {
1530  if (mesh.n_processors() == 1)
1531  return;
1532 
1533  libmesh_parallel_only(mesh.comm());
1534 
1535  // We want this test to be valid even when called even after nodes
1536  // have been added asynchonously but before they're renumbered
1537  dof_id_type parallel_max_node_id = mesh.max_node_id();
1538  mesh.comm().max(parallel_max_node_id);
1539 
1540  std::vector<bool> node_touched_by_anyone(parallel_max_node_id, false);
1541 
1542  const MeshBase::const_element_iterator el_end =
1543  mesh.local_elements_end();
1545  mesh.local_elements_begin(); el != el_end; ++el)
1546  {
1547  const Elem * elem = *el;
1548  libmesh_assert (elem);
1549 
1550  for (unsigned int i=0; i != elem->n_nodes(); ++i)
1551  {
1552  const Node & node = elem->node_ref(i);
1553  dof_id_type nodeid = node.id();
1554  node_touched_by_anyone[nodeid] = true;
1555  }
1556  }
1557  mesh.comm().max(node_touched_by_anyone);
1558 
1559  // Check processor ids for consistency between processors
1560  // on any node an element touches
1561  for (dof_id_type i=0; i != parallel_max_node_id; ++i)
1562  {
1563  if (!node_touched_by_anyone[i])
1564  continue;
1565 
1566  const Node * node = mesh.query_node_ptr(i);
1567 
1568  processor_id_type min_id =
1569  node ? node->processor_id() :
1571  mesh.comm().min(min_id);
1572 
1573  processor_id_type max_id =
1574  node ? node->processor_id() :
1576  mesh.comm().max(max_id);
1577 
1578  if (node)
1579  {
1580  libmesh_assert_equal_to (min_id, node->processor_id());
1581  libmesh_assert_equal_to (max_id, node->processor_id());
1582  }
1583 
1584  if (min_id == mesh.processor_id())
1585  libmesh_assert(node);
1586  }
1587 }
A geometric point in (x,y,z) space associated with a DOF.
Definition: node.h:52
virtual element_iterator local_elements_begin()=0
processor_id_type n_processors() const
virtual dof_id_type max_node_id() const =0
The base class for all geometric element types.
Definition: elem.h:86
uint8_t processor_id_type
Definition: id_types.h:99
long double max(long double a, double b)
libmesh_assert(j)
virtual unsigned int n_nodes() const =0
virtual const Node * query_node_ptr(const dof_id_type i) const =0
virtual element_iterator local_elements_end()=0
const Node & node_ref(const unsigned int i) const
Definition: elem.h:1680
const Parallel::Communicator & comm() const
dof_id_type id() const
Definition: dof_object.h:624
long double min(long double a, double b)
processor_id_type processor_id() const
uint8_t dof_id_type
Definition: id_types.h:64
processor_id_type processor_id() const
Definition: dof_object.h:686
template<typename DofObjectSubclass >
void libMesh::MeshTools::libmesh_assert_topology_consistent_procids ( const MeshBase mesh)

A function for verifying that processor assignment is topologically consistent on nodes (each node part of an active element on its processor) or elements (each parent has the processor id of one of its children).

Referenced by weight().

Definition at line 1389 of file mesh_tools.C.

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

1390 {
1391  // If we're adaptively refining, check processor ids for consistency
1392  // between parents and children.
1393 #ifdef LIBMESH_ENABLE_AMR
1394 
1395  // Ancestor elements we won't worry about, but subactive and active
1396  // elements ought to have parents with consistent processor ids
1397 
1398  const MeshBase::const_element_iterator el_end =
1399  mesh.elements_end();
1401  mesh.elements_begin(); el != el_end; ++el)
1402  {
1403  const Elem * elem = *el;
1404  libmesh_assert(elem);
1405 
1406  if (!elem->active() && !elem->subactive())
1407  continue;
1408 
1409  const Elem * parent = elem->parent();
1410 
1411  if (parent)
1412  {
1413  libmesh_assert(parent->has_children());
1414  processor_id_type parent_procid = parent->processor_id();
1415  bool matching_child_id = false;
1416  for (unsigned int c = 0; c != parent->n_children(); ++c)
1417  {
1418  const Elem * child = parent->child_ptr(c);
1419  libmesh_assert(child);
1420 
1421  // If we've got a remote_elem then we don't know whether
1422  // it's responsible for the parent's processor id; all
1423  // we can do is assume it is and let its processor fail
1424  // an assert if there's something wrong.
1425  if (child == remote_elem ||
1426  child->processor_id() == parent_procid)
1427  matching_child_id = true;
1428  }
1429  libmesh_assert(matching_child_id);
1430  }
1431  }
1432 #endif
1433 }
bool has_children() const
Definition: elem.h:2022
bool subactive() const
Definition: elem.h:2002
bool active() const
Definition: elem.h:1984
const Elem * parent() const
Definition: elem.h:2073
The base class for all geometric element types.
Definition: elem.h:86
uint8_t processor_id_type
Definition: id_types.h:99
libmesh_assert(j)
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
const Elem * child_ptr(unsigned int i) const
Definition: elem.h:2163
virtual unsigned int n_children() const =0
processor_id_type processor_id() const
Definition: dof_object.h:686
const RemoteElem * remote_elem
Definition: remote_elem.C:57

Definition at line 1480 of file mesh_tools.C.

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

1481 {
1482  if (mesh.n_processors() == 1)
1483  return;
1484 
1485  libmesh_parallel_only(mesh.comm());
1486 
1487  // We want this test to be valid even when called even after nodes
1488  // have been added asynchonously but before they're renumbered
1489  dof_id_type parallel_max_node_id = mesh.max_node_id();
1490  mesh.comm().max(parallel_max_node_id);
1491 
1492  std::vector<bool> node_touched_by_me(parallel_max_node_id, false);
1493 
1494  const MeshBase::const_element_iterator el_end =
1495  mesh.local_elements_end();
1497  mesh.local_elements_begin(); el != el_end; ++el)
1498  {
1499  const Elem * elem = *el;
1500  libmesh_assert (elem);
1501 
1502  for (unsigned int i=0; i != elem->n_nodes(); ++i)
1503  {
1504  const Node & node = elem->node_ref(i);
1505  dof_id_type nodeid = node.id();
1506  node_touched_by_me[nodeid] = true;
1507  }
1508  }
1509  std::vector<bool> node_touched_by_anyone(node_touched_by_me);
1510  mesh.comm().max(node_touched_by_anyone);
1511 
1512  const MeshBase::const_node_iterator nd_end = mesh.local_nodes_end();
1514  nd != nd_end; ++nd)
1515  {
1516  const Node * node = *nd;
1517  libmesh_assert(node);
1518 
1519  dof_id_type nodeid = node->id();
1520  libmesh_assert(!node_touched_by_anyone[nodeid] ||
1521  node_touched_by_me[nodeid]);
1522  }
1523 }
A geometric point in (x,y,z) space associated with a DOF.
Definition: node.h:52
virtual element_iterator local_elements_begin()=0
processor_id_type n_processors() const
virtual dof_id_type max_node_id() const =0
The base class for all geometric element types.
Definition: elem.h:86
libmesh_assert(j)
virtual unsigned int n_nodes() const =0
virtual node_iterator local_nodes_end()=0
virtual element_iterator local_elements_end()=0
const Node & node_ref(const unsigned int i) const
Definition: elem.h:1680
virtual node_iterator local_nodes_begin()=0
const Parallel::Communicator & comm() const
dof_id_type id() const
Definition: dof_object.h:624
uint8_t dof_id_type
Definition: id_types.h:64
void libMesh::MeshTools::libmesh_assert_valid_amr_elem_ids ( const MeshBase mesh)

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

Definition at line 1119 of file mesh_tools.C.

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

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

1120 {
1121  const MeshBase::const_element_iterator el_end =
1122  mesh.elements_end();
1124  mesh.elements_begin(); el != el_end; ++el)
1125  {
1126  const Elem * elem = *el;
1127  libmesh_assert (elem);
1128 
1129  const Elem * parent = elem->parent();
1130 
1131  if (parent)
1132  {
1133  libmesh_assert_greater_equal (elem->id(), parent->id());
1134  libmesh_assert_greater_equal (elem->processor_id(), parent->processor_id());
1135  }
1136  }
1137 }
const Elem * parent() const
Definition: elem.h:2073
The base class for all geometric element types.
Definition: elem.h:86
libmesh_assert(j)
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
dof_id_type id() const
Definition: dof_object.h:624
processor_id_type processor_id() const
Definition: dof_object.h:686
void libMesh::MeshTools::libmesh_assert_valid_amr_interior_parents ( const MeshBase mesh)

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

Definition at line 1141 of file mesh_tools.C.

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

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

1142 {
1143  const MeshBase::const_element_iterator el_end =
1144  mesh.elements_end();
1146  mesh.elements_begin(); el != el_end; ++el)
1147  {
1148  const Elem * elem = *el;
1149  libmesh_assert (elem);
1150 
1151  // We can skip to the next element if we're full-dimension
1152  // and therefore don't have any interior parents
1153  if (elem->dim() >= LIBMESH_DIM)
1154  continue;
1155 
1156  const Elem * ip = elem->interior_parent();
1157 
1158  const Elem * parent = elem->parent();
1159 
1160  if (ip && (ip != remote_elem) && parent)
1161  {
1162  libmesh_assert_equal_to (ip->top_parent(),
1163  elem->top_parent()->interior_parent());
1164 
1165  if (ip->level() == elem->level())
1166  libmesh_assert_equal_to (ip->parent(),
1167  parent->interior_parent());
1168  else
1169  {
1170  libmesh_assert_less (ip->level(), elem->level());
1171  libmesh_assert_equal_to (ip, parent->interior_parent());
1172  }
1173  }
1174  }
1175 }
const Elem * parent() const
Definition: elem.h:2073
const Elem * interior_parent() const
Definition: elem.C:940
The base class for all geometric element types.
Definition: elem.h:86
libmesh_assert(j)
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
virtual unsigned int dim() const =0
unsigned int level() const
Definition: elem.h:2115
const Elem * top_parent() const
Definition: elem.h:2097
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 1210 of file mesh_tools.C.

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

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

1211 {
1212  if (mesh.n_processors() == 1)
1213  return;
1214 
1215  libmesh_parallel_only(mesh.comm());
1216 
1217  const BoundaryInfo & boundary_info = mesh.get_boundary_info();
1218 
1219  dof_id_type pmax_elem_id = mesh.max_elem_id();
1220  mesh.comm().max(pmax_elem_id);
1221 
1222  for (dof_id_type i=0; i != pmax_elem_id; ++i)
1223  {
1224  const Elem *elem = mesh.query_elem_ptr(i);
1225  unsigned int n_nodes = elem ? elem->n_nodes() : 0;
1226  unsigned int n_edges = elem ? elem->n_edges() : 0;
1227  unsigned int n_sides = elem ? elem->n_sides() : 0;
1229  (elem ? &n_nodes : libmesh_nullptr));
1231  (elem ? &n_edges : libmesh_nullptr));
1233  (elem ? &n_sides : libmesh_nullptr));
1234  mesh.comm().max(n_nodes);
1235  mesh.comm().max(n_edges);
1236  mesh.comm().max(n_sides);
1237  for (unsigned int n=0; n != n_nodes; ++n)
1238  {
1239  std::vector<boundary_id_type> bcids;
1240  if (elem)
1241  {
1242  boundary_info.boundary_ids(elem->node_ptr(n), bcids);
1243 
1244  // Ordering of boundary ids shouldn't matter
1245  std::sort(bcids.begin(), bcids.end());
1246  }
1248  (elem ? &bcids : libmesh_nullptr));
1249  }
1250 
1251  for (unsigned short e=0; e != n_edges; ++e)
1252  {
1253  std::vector<boundary_id_type> bcids;
1254 
1255  if (elem)
1256  {
1257  boundary_info.edge_boundary_ids(elem, e, bcids);
1258 
1259  // Ordering of boundary ids shouldn't matter
1260  std::sort(bcids.begin(), bcids.end());
1261  }
1262 
1264  (elem ? &bcids : libmesh_nullptr));
1265 
1266  if (elem)
1267  {
1268  boundary_info.raw_edge_boundary_ids(elem, e, bcids);
1269 
1270  // Ordering of boundary ids shouldn't matter
1271  std::sort(bcids.begin(), bcids.end());
1272  }
1273 
1275  (elem ? &bcids : libmesh_nullptr));
1276  }
1277 
1278  for (unsigned short s=0; s != n_sides; ++s)
1279  {
1280  std::vector<boundary_id_type> bcids;
1281 
1282  if (elem)
1283  {
1284  boundary_info.boundary_ids(elem, s, bcids);
1285 
1286  // Ordering of boundary ids shouldn't matter
1287  std::sort(bcids.begin(), bcids.end());
1288  }
1289 
1291  (elem ? &bcids : libmesh_nullptr));
1292 
1293  if (elem)
1294  {
1295  boundary_info.raw_boundary_ids(elem, s, bcids);
1296 
1297  // Ordering of boundary ids shouldn't matter
1298  std::sort(bcids.begin(), bcids.end());
1299  }
1300 
1302  (elem ? &bcids : libmesh_nullptr));
1303  }
1304 
1305  for (unsigned short sf=0; sf != 2; ++sf)
1306  {
1307  std::vector<boundary_id_type> bcids;
1308 
1309  if (elem)
1310  {
1311  boundary_info.shellface_boundary_ids(elem, sf, bcids);
1312 
1313  // Ordering of boundary ids shouldn't matter
1314  std::sort(bcids.begin(), bcids.end());
1315  }
1316 
1318  (elem ? &bcids : libmesh_nullptr));
1319 
1320  if (elem)
1321  {
1322  boundary_info.raw_shellface_boundary_ids(elem, sf, bcids);
1323 
1324  // Ordering of boundary ids shouldn't matter
1325  std::sort(bcids.begin(), bcids.end());
1326  }
1327 
1329  (elem ? &bcids : libmesh_nullptr));
1330  }
1331  }
1332 }
const BoundaryInfo & get_boundary_info() const
Definition: mesh_base.h:111
virtual unsigned int n_edges() const =0
processor_id_type n_processors() const
The base class for all geometric element types.
Definition: elem.h:86
const class libmesh_nullptr_t libmesh_nullptr
libmesh_assert(j)
virtual unsigned int n_nodes() const =0
virtual dof_id_type max_elem_id() const =0
const dof_id_type n_nodes
Definition: tecplot_io.C:67
const Node * node_ptr(const unsigned int i) const
Definition: elem.h:1658
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 1334 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().

1335 {
1336  if (mesh.n_processors() == 1)
1337  return;
1338 
1339  libmesh_parallel_only(mesh.comm());
1340 
1341  dof_id_type pmax_elem_id = mesh.max_elem_id();
1342  mesh.comm().max(pmax_elem_id);
1343 
1344  for (dof_id_type i=0; i != pmax_elem_id; ++i)
1345  assert_semiverify_dofobj(mesh.comm(),
1346  mesh.query_elem_ptr(i),
1347  sysnum);
1348 
1349  dof_id_type pmax_node_id = mesh.max_node_id();
1350  mesh.comm().max(pmax_node_id);
1351 
1352  for (dof_id_type i=0; i != pmax_node_id; ++i)
1353  assert_semiverify_dofobj(mesh.comm(),
1354  mesh.query_node_ptr(i),
1355  sysnum);
1356 }
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 1094 of file mesh_tools.C.

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

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

1095 {
1096  processor_id_type lastprocid = 0;
1097  dof_id_type lastelemid = 0;
1098 
1099  const MeshBase::const_element_iterator el_end =
1100  mesh.active_elements_end();
1102  mesh.active_elements_begin(); el != el_end; ++el)
1103  {
1104  const Elem * elem = *el;
1105  libmesh_assert (elem);
1106  processor_id_type elemprocid = elem->processor_id();
1107  dof_id_type elemid = elem->id();
1108 
1109  libmesh_assert_greater_equal (elemid, lastelemid);
1110  libmesh_assert_greater_equal (elemprocid, lastprocid);
1111 
1112  lastelemid = elemid;
1113  lastprocid = elemprocid;
1114  }
1115 }
The base class for all geometric element types.
Definition: elem.h:86
uint8_t processor_id_type
Definition: id_types.h:99
libmesh_assert(j)
virtual element_iterator active_elements_begin()=0
virtual element_iterator active_elements_end()=0
dof_id_type id() const
Definition: dof_object.h:624
uint8_t dof_id_type
Definition: id_types.h:64
processor_id_type processor_id() const
Definition: dof_object.h:686
void libMesh::MeshTools::libmesh_assert_valid_neighbors ( const MeshBase mesh,
bool  assert_valid_remote_elems = true 
)

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

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

Definition at line 1686 of file mesh_tools.C.

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

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

1688 {
1689  const MeshBase::const_element_iterator el_end = mesh.elements_end();
1691  el != el_end; ++el)
1692  {
1693  const Elem * elem = *el;
1694  libmesh_assert (elem);
1696  }
1697 
1698  if (mesh.n_processors() == 1)
1699  return;
1700 
1701  libmesh_parallel_only(mesh.comm());
1702 
1703  dof_id_type pmax_elem_id = mesh.max_elem_id();
1704  mesh.comm().max(pmax_elem_id);
1705 
1706  for (dof_id_type i=0; i != pmax_elem_id; ++i)
1707  {
1708  const Elem * elem = mesh.query_elem_ptr(i);
1709 
1710  const unsigned int my_n_neigh = elem ? elem->n_neighbors() : 0;
1711  unsigned int n_neigh = my_n_neigh;
1712  mesh.comm().max(n_neigh);
1713  if (elem)
1714  libmesh_assert_equal_to (my_n_neigh, n_neigh);
1715 
1716  for (unsigned int n = 0; n != n_neigh; ++n)
1717  {
1718  dof_id_type my_neighbor = DofObject::invalid_id;
1719  dof_id_type * p_my_neighbor = libmesh_nullptr;
1720 
1721  // If we have a non-remote_elem neighbor link, then we can
1722  // verify it.
1723  if (elem && elem->neighbor_ptr(n) != remote_elem)
1724  {
1725  p_my_neighbor = &my_neighbor;
1726  if (elem->neighbor_ptr(n))
1727  my_neighbor = elem->neighbor_ptr(n)->id();
1728 
1729  // But wait - if we haven't set remote_elem links yet then
1730  // some NULL links on ghost elements might be
1731  // future-remote_elem links, so we can't verify those.
1732  if (!assert_valid_remote_elems &&
1733  !elem->neighbor_ptr(n) &&
1734  elem->processor_id() != mesh.processor_id())
1735  p_my_neighbor = libmesh_nullptr;
1736  }
1737  libmesh_assert(mesh.comm().semiverify(p_my_neighbor));
1738  }
1739  }
1740 }
virtual unsigned int n_neighbors() const
Definition: elem.h:530
processor_id_type n_processors() const
The base class for all geometric element types.
Definition: elem.h:86
const class libmesh_nullptr_t libmesh_nullptr
libmesh_assert(j)
const Elem * neighbor_ptr(unsigned int i) const
Definition: elem.h:1749
virtual element_iterator elements_begin()=0
virtual dof_id_type max_elem_id() const =0
virtual element_iterator elements_end()=0
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
const Parallel::Communicator & comm() const
dof_id_type id() const
Definition: dof_object.h:624
void libmesh_assert_valid_neighbors() const
Definition: elem.C:1126
processor_id_type processor_id() const
uint8_t dof_id_type
Definition: id_types.h:64
processor_id_type processor_id() const
Definition: dof_object.h:686
const RemoteElem * remote_elem
Definition: remote_elem.C:57
void libMesh::MeshTools::libmesh_assert_valid_node_pointers ( const MeshBase mesh)

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

Definition at line 1016 of file mesh_tools.C.

References libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::libmesh_assert(), libMesh::Elem::libmesh_assert_valid_node_pointers(), libMesh::Elem::n_neighbors(), libMesh::Elem::neighbor_ptr(), libMesh::Elem::parent(), and libMesh::remote_elem.

Referenced by weight().

1017 {
1018  const MeshBase::const_element_iterator el_end =
1019  mesh.elements_end();
1021  mesh.elements_begin(); el != el_end; ++el)
1022  {
1023  const Elem * elem = *el;
1024  libmesh_assert (elem);
1025  while (elem)
1026  {
1028  for (unsigned int n=0; n != elem->n_neighbors(); ++n)
1029  if (elem->neighbor_ptr(n) &&
1030  elem->neighbor_ptr(n) != remote_elem)
1032 
1033  libmesh_assert_not_equal_to (elem->parent(), remote_elem);
1034  elem = elem->parent();
1035  }
1036  }
1037 }
virtual unsigned int n_neighbors() const
Definition: elem.h:530
const Elem * parent() const
Definition: elem.h:2073
The base class for all geometric element types.
Definition: elem.h:86
libmesh_assert(j)
const Elem * neighbor_ptr(unsigned int i) const
Definition: elem.h:1749
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
void libmesh_assert_valid_node_pointers() const
Definition: elem.C:1114
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 428 of file mesh_tools.h.

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

428  {
429  libmesh_assert_parallel_consistent_procids<DofObjectSubclass>(mesh);
430  libmesh_assert_topology_consistent_procids<DofObjectSubclass>(mesh);
431 }
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 1596 of file mesh_tools.C.

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

Referenced by libmesh_assert_valid_procids().

1597 {
1598  libmesh_parallel_only(mesh.comm());
1599  if (mesh.n_processors() == 1)
1600  return;
1601 
1602  dof_id_type pmax_elem_id = mesh.max_elem_id();
1603  mesh.comm().max(pmax_elem_id);
1604 
1605  std::vector<unsigned char> my_elem_h_state(pmax_elem_id, 255);
1606  std::vector<unsigned char> my_elem_p_state(pmax_elem_id, 255);
1607 
1608  const MeshBase::const_element_iterator el_end =
1609  mesh.elements_end();
1611  mesh.elements_begin(); el != el_end; ++el)
1612  {
1613  const Elem * elem = *el;
1614  libmesh_assert (elem);
1615  dof_id_type elemid = elem->id();
1616 
1617  my_elem_h_state[elemid] =
1618  static_cast<unsigned char>(elem->refinement_flag());
1619 
1620  my_elem_p_state[elemid] =
1621  static_cast<unsigned char>(elem->p_refinement_flag());
1622  }
1623  std::vector<unsigned char> min_elem_h_state(my_elem_h_state);
1624  mesh.comm().min(min_elem_h_state);
1625 
1626  std::vector<unsigned char> min_elem_p_state(my_elem_p_state);
1627  mesh.comm().min(min_elem_p_state);
1628 
1629  for (dof_id_type i=0; i!= pmax_elem_id; ++i)
1630  {
1631  libmesh_assert(my_elem_h_state[i] == 255 ||
1632  my_elem_h_state[i] == min_elem_h_state[i]);
1633  libmesh_assert(my_elem_p_state[i] == 255 ||
1634  my_elem_p_state[i] == min_elem_p_state[i]);
1635  }
1636 }
processor_id_type n_processors() const
The base class for all geometric element types.
Definition: elem.h:86
libmesh_assert(j)
virtual element_iterator elements_begin()=0
virtual dof_id_type max_elem_id() const =0
virtual element_iterator elements_end()=0
RefinementState p_refinement_flag() const
Definition: elem.h:2236
const Parallel::Communicator & comm() const
RefinementState refinement_flag() const
Definition: elem.h:2220
dof_id_type id() const
Definition: dof_object.h:624
uint8_t dof_id_type
Definition: id_types.h:64
void libMesh::MeshTools::libmesh_assert_valid_refinement_tree ( const MeshBase mesh)

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

Definition at line 1646 of file mesh_tools.C.

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

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

1647 {
1648  const MeshBase::const_element_iterator el_end =
1649  mesh.elements_end();
1651  mesh.elements_begin(); el != el_end; ++el)
1652  {
1653  const Elem * elem = *el;
1654  libmesh_assert(elem);
1655  if (elem->has_children())
1656  for (unsigned int n=0; n != elem->n_children(); ++n)
1657  {
1658  libmesh_assert(elem->child_ptr(n));
1659  if (elem->child_ptr(n) != remote_elem)
1660  libmesh_assert_equal_to (elem->child_ptr(n)->parent(), elem);
1661  }
1662  if (elem->active())
1663  {
1664  libmesh_assert(!elem->ancestor());
1665  libmesh_assert(!elem->subactive());
1666  }
1667  else if (elem->ancestor())
1668  {
1669  libmesh_assert(!elem->subactive());
1670  }
1671  else
1672  libmesh_assert(elem->subactive());
1673 
1674  if (elem->p_refinement_flag() == Elem::JUST_REFINED)
1675  libmesh_assert_greater(elem->p_level(), 0);
1676  }
1677 }
bool ancestor() const
Definition: elem.C:1473
bool has_children() const
Definition: elem.h:2022
bool subactive() const
Definition: elem.h:2002
bool active() const
Definition: elem.h:1984
unsigned int p_level() const
Definition: elem.h:2149
const Elem * parent() const
Definition: elem.h:2073
The base class for all geometric element types.
Definition: elem.h:86
libmesh_assert(j)
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
const Elem * child_ptr(unsigned int i) const
Definition: elem.h:2163
RefinementState p_refinement_flag() const
Definition: elem.h:2236
virtual unsigned int n_children() const =0
const RemoteElem * remote_elem
Definition: remote_elem.C:57
void libMesh::MeshTools::libmesh_assert_valid_remote_elems ( const MeshBase mesh)

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

Definition at line 1040 of file mesh_tools.C.

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

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

1041 {
1042  const MeshBase::const_element_iterator el_end =
1043  mesh.local_elements_end();
1045  mesh.local_elements_begin(); el != el_end; ++el)
1046  {
1047  const Elem * elem = *el;
1048  libmesh_assert (elem);
1049 
1050  // We currently don't allow active_local_elements to have
1051  // remote_elem neighbors
1052  if (elem->active())
1053  for (unsigned int n=0; n != elem->n_neighbors(); ++n)
1054  libmesh_assert_not_equal_to (elem->neighbor_ptr(n), remote_elem);
1055 
1056 #ifdef LIBMESH_ENABLE_AMR
1057  const Elem * parent = elem->parent();
1058  if (parent)
1059  libmesh_assert_not_equal_to (parent, remote_elem);
1060 
1061  // We can only be strict about active elements' subactive
1062  // children
1063  if (elem->active() && elem->has_children())
1064  for (unsigned int c=0; c != elem->n_children(); ++c)
1065  libmesh_assert_not_equal_to (elem->child_ptr(c), remote_elem);
1066 #endif
1067  }
1068 }
bool has_children() const
Definition: elem.h:2022
bool active() const
Definition: elem.h:1984
virtual unsigned int n_neighbors() const
Definition: elem.h:530
virtual element_iterator local_elements_begin()=0
const Elem * parent() const
Definition: elem.h:2073
The base class for all geometric element types.
Definition: elem.h:86
libmesh_assert(j)
const Elem * neighbor_ptr(unsigned int i) const
Definition: elem.h:1749
const Elem * child_ptr(unsigned int i) const
Definition: elem.h:2163
virtual element_iterator local_elements_end()=0
virtual unsigned int n_children() const =0
const RemoteElem * remote_elem
Definition: remote_elem.C:57
void libMesh::MeshTools::libmesh_assert_valid_unique_ids ( const MeshBase mesh)

A function for verifying that unique ids match across processors.

FIXME: we ought to check for uniqueness too.

Definition at line 1360 of file mesh_tools.C.

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

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

1361 {
1362  libmesh_parallel_only(mesh.comm());
1363 
1364  dof_id_type pmax_elem_id = mesh.max_elem_id();
1365  mesh.comm().max(pmax_elem_id);
1366 
1367  for (dof_id_type i=0; i != pmax_elem_id; ++i)
1368  {
1369  const Elem *elem = mesh.query_elem_ptr(i);
1370  const unique_id_type unique_id = elem ? elem->unique_id() : 0;
1371  const unique_id_type * uid_ptr = elem ? &unique_id : libmesh_nullptr;
1372  libmesh_assert(mesh.comm().semiverify(uid_ptr));
1373  }
1374 
1375  dof_id_type pmax_node_id = mesh.max_node_id();
1376  mesh.comm().max(pmax_node_id);
1377 
1378  for (dof_id_type i=0; i != pmax_node_id; ++i)
1379  {
1380  const Node *node = mesh.query_node_ptr(i);
1381  const unique_id_type unique_id = node ? node->unique_id() : 0;
1382  const unique_id_type * uid_ptr = node ? &unique_id : libmesh_nullptr;
1383  libmesh_assert(mesh.comm().semiverify(uid_ptr));
1384  }
1385 }
A geometric point in (x,y,z) space associated with a DOF.
Definition: node.h:52
virtual dof_id_type max_node_id() const =0
The base class for all geometric element types.
Definition: elem.h:86
const class libmesh_nullptr_t libmesh_nullptr
libmesh_assert(j)
virtual dof_id_type max_elem_id() const =0
virtual const Node * query_node_ptr(const dof_id_type i) const =0
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
const Parallel::Communicator & comm() const
unique_id_type unique_id() const
Definition: dof_object.h:641
uint8_t unique_id_type
Definition: id_types.h:79
uint8_t dof_id_type
Definition: id_types.h:64
unsigned int libMesh::MeshTools::max_level ( const MeshBase mesh)
dof_id_type libMesh::MeshTools::n_active_elem_of_type ( const MeshBase mesh,
const ElemType  type 
)

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

Definition at line 493 of file mesh_tools.C.

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

Referenced by weight().

495 {
496  return static_cast<dof_id_type>(std::distance(mesh.active_type_elements_begin(type),
497  mesh.active_type_elements_end (type)));
498 }
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)

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

Definition at line 532 of file mesh_tools.C.

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

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

533 {
534  libmesh_parallel_only(mesh.comm());
535 
536  unsigned int nl = MeshTools::n_active_local_levels(mesh);
537 
540  const MeshBase::const_element_iterator end_el =
542 
543  for( ; el != end_el; ++el)
544  if ((*el)->active())
545  nl = std::max((*el)->level() + 1, nl);
546 
547  mesh.comm().max(nl);
548  return nl;
549 }
unsigned int n_active_local_levels(const MeshBase &mesh)
Definition: mesh_tools.C:517
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)

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

Definition at line 517 of file mesh_tools.C.

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

Referenced by n_active_levels(), and weight().

518 {
519  unsigned int nl = 0;
520 
523 
524  for( ; el != end_el; ++el)
525  nl = std::max((*el)->level() + 1, nl);
526 
527  return nl;
528 }
long double max(long double a, double b)
virtual element_iterator active_local_elements_begin()=0
virtual element_iterator active_local_elements_end()=0
dof_id_type libMesh::MeshTools::n_elem_of_type ( const MeshBase mesh,
const ElemType  type 
)

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

Definition at line 484 of file mesh_tools.C.

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

Referenced by weight().

486 {
487  return static_cast<dof_id_type>(std::distance(mesh.type_elements_begin(type),
488  mesh.type_elements_end (type)));
489 }
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)

Return 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 568 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().

569 {
570  libmesh_parallel_only(mesh.comm());
571 
572  unsigned int nl = MeshTools::n_local_levels(mesh);
573 
576  const MeshBase::const_element_iterator end_el =
578 
579  for( ; el != end_el; ++el)
580  nl = std::max((*el)->level() + 1, nl);
581 
582  mesh.comm().max(nl);
583 
584  // n_levels() is only valid and should only be called in cases where
585  // the mesh is validly distributed (or serialized). Let's run an
586  // expensive test in debug mode to make sure this is such a case.
587 #ifdef DEBUG
588  const unsigned int paranoid_nl = MeshTools::paranoid_n_levels(mesh);
589  libmesh_assert_equal_to(nl, paranoid_nl);
590 #endif
591  return nl;
592 }
virtual element_iterator unpartitioned_elements_begin()=0
unsigned int n_local_levels(const MeshBase &mesh)
Definition: mesh_tools.C:553
long double max(long double a, double b)
unsigned int paranoid_n_levels(const MeshBase &mesh)
Definition: mesh_tools.C:596
const Parallel::Communicator & comm() const
virtual element_iterator unpartitioned_elements_end()=0
unsigned int libMesh::MeshTools::n_local_levels ( const MeshBase mesh)

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

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

554 {
555  unsigned int nl = 0;
556 
559 
560  for( ; el != end_el; ++el)
561  nl = std::max((*el)->level() + 1, nl);
562 
563  return nl;
564 }
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 639 of file mesh_tools.C.

Referenced by weight().

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

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

TODO: Replace all of the n_xxx_elem() functions like this with a single function which takes a range of iterators and returns the std::distance between them.

Definition at line 500 of file mesh_tools.C.

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

Referenced by weight().

503 {
504  dof_id_type cnt = 0;
505  // iterate over the elements of the specified type
508 
509  for(; el!=end; ++el)
510  if( ((*el)->level() == level) && !(*el)->subactive())
511  cnt++;
512 
513  return cnt;
514 }
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)

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

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

648 {
649  libmesh_parallel_only(mesh.comm());
650 
651  unsigned int max_p_level = 0;
652 
653  // first my local elements
655  el = mesh.local_elements_begin(),
656  end_el = mesh.local_elements_end();
657 
658  for( ; el != end_el; ++el)
659  max_p_level = std::max((*el)->p_level(), max_p_level);
660 
661  // then any unpartitioned objects
662  el = mesh.unpartitioned_elements_begin();
663  end_el = mesh.unpartitioned_elements_end();
664 
665  for( ; el != end_el; ++el)
666  max_p_level = std::max((*el)->p_level(), max_p_level);
667 
668  mesh.comm().max(max_p_level);
669  return max_p_level + 1;
670 }
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)

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

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

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

597 {
598  libmesh_parallel_only(mesh.comm());
599 
601  mesh.elements_begin();
602  const MeshBase::const_element_iterator end_el =
603  mesh.elements_end();
604 
605  unsigned int nl = 0;
606  for( ; el != end_el; ++el)
607  nl = std::max((*el)->level() + 1, nl);
608 
609  mesh.comm().max(nl);
610  return nl;
611 }
long double max(long double a, double b)
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
const Parallel::Communicator & comm() const
MeshTools::BoundingBox libMesh::MeshTools::processor_bounding_box ( const MeshBase mesh,
const processor_id_type  pid 
)
Returns
two points defining a cartesian box that bounds the elements belonging to processor pid.

Definition at line 397 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(), and libMesh::MeshBase::pid_elements_end().

Referenced by processor_bounding_sphere(), and weight().

399 {
400  libmesh_assert_less (pid, mesh.n_processors());
401 
402  FindBBox find_bbox;
403 
405  mesh.pid_elements_end(pid)),
406  find_bbox);
407 
408  // Compare the bounding boxes across processors
409  mesh.comm().min(find_bbox.min());
410  mesh.comm().max(find_bbox.max());
411 
412  return find_bbox.bbox();
413 }
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
Sphere libMesh::MeshTools::processor_bounding_sphere ( const MeshBase mesh,
const processor_id_type  pid 
)

Same, but returns a sphere instead of a box.

Definition at line 418 of file mesh_tools.C.

References processor_bounding_box(), and libMesh::Real.

Referenced by weight().

420 {
421  BoundingBox bbox = processor_bounding_box(mesh,pid);
422 
423  const Real diag = (bbox.second - bbox.first).norm();
424  const Point cent = (bbox.second + bbox.first)/2;
425 
426  return Sphere (cent, .5*diag);
427 }
A geometric object representing a sphere.
Definition: sphere.h:72
BoundingBox processor_bounding_box(const MeshBase &mesh, const processor_id_type pid)
Definition: mesh_tools.C:397
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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.

Definition at line 432 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(), and libMesh::Threads::parallel_reduce().

Referenced by subdomain_bounding_sphere(), and weight().

434 {
435  FindBBox find_bbox;
436 
440  find_bbox);
441 
442  // Compare the bounding boxes across processors
443  mesh.comm().min(find_bbox.min());
444  mesh.comm().max(find_bbox.max());
445 
446  return find_bbox.bbox();
447 }
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
Sphere libMesh::MeshTools::subdomain_bounding_sphere ( const MeshBase mesh,
const subdomain_id_type  sid 
)

Same, but returns a sphere instead of a box.

Definition at line 452 of file mesh_tools.C.

References libMesh::Real, and subdomain_bounding_box().

Referenced by weight().

454 {
455  BoundingBox bbox = subdomain_bounding_box(mesh,sid);
456 
457  const Real diag = (bbox.second - bbox.first).norm();
458  const Point cent = (bbox.second + bbox.first)/2;
459 
460  return Sphere (cent, .5*diag);
461 }
A geometric object representing a sphere.
Definition: sphere.h:72
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
A geometric point in (x,y,z) space.
Definition: point.h:38
BoundingBox subdomain_bounding_box(const MeshBase &mesh, const subdomain_id_type sid)
Definition: mesh_tools.C:432
dof_id_type libMesh::MeshTools::total_weight ( const MeshBase mesh)

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

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

253 {
254  if (!mesh.is_serial())
255  {
256  libmesh_parallel_only(mesh.comm());
258  mesh.comm().sum(weight);
259  dof_id_type unpartitioned_weight =
260  MeshTools::weight (mesh, DofObject::invalid_processor_id);
261  return weight + unpartitioned_weight;
262  }
263 
264  SumElemWeight sew;
265 
267  mesh.elements_end()),
268  sew);
269  return sew.weight();
270 
271 }
virtual bool is_serial() const
Definition: mesh_base.h:134
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:275
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 
)

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

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

276 {
277  SumElemWeight sew;
278 
280  mesh.pid_elements_end(pid)),
281  sew);
282  return sew.weight();
283 }
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