Base class for different Tree types. More...
#include <tree_node.h>
Public Member Functions | |
TreeNode (const MeshBase &m, unsigned int tbs, const TreeNode< N > *p=libmesh_nullptr) | |
~TreeNode () | |
bool | is_root () const |
bool | active () const |
bool | insert (const Node *nd) |
bool | insert (const Elem *nd) |
void | refine () |
void | set_bounding_box (const std::pair< Point, Point > &bbox) |
bool | bounds_node (const Node *nd, Real relative_tol=0) const |
bool | bounds_point (const Point &p, Real relative_tol=0) const |
unsigned int | level () const |
void | print_nodes (std::ostream &out=libMesh::out) const |
void | print_elements (std::ostream &out=libMesh::out) const |
void | transform_nodes_to_elements (std::vector< std::vector< const Elem * >> &nodes_to_elem) |
unsigned int | n_active_bins () const |
const Elem * | find_element (const Point &p, const std::set< subdomain_id_type > *allowed_subdomains=libmesh_nullptr, Real relative_tol=TOLERANCE) const |
Private Member Functions | |
const Elem * | find_element_in_children (const Point &p, const std::set< subdomain_id_type > *allowed_subdomains, Real relative_tol) const |
BoundingBox | create_bounding_box (unsigned int c) const |
Private Attributes | |
const MeshBase & | mesh |
const TreeNode< N > * | parent |
std::vector< TreeNode< N > * > | children |
BoundingBox | bounding_box |
std::vector< const Elem * > | elements |
std::vector< const Node * > | nodes |
const unsigned int | tgt_bin_size |
unsigned int | target_bin_size_increase_level |
bool | contains_ifems |
std::vector< bool > | searched_child |
Base class for different Tree types.
This class defines a node on a tree. A tree node contains a pointer to its parent (NULL if the node is the root) and pointers to its children (NULL if the node is active.
Definition at line 52 of file tree_node.h.
|
inline |
Constructor. Takes a pointer to this node's parent. The pointer should only be NULL for the top-level (root) node.
Definition at line 238 of file tree_node.h.
References libMesh::TreeNode< N >::active(), libMesh::TreeNode< N >::children, libMesh::TreeNode< N >::elements, libMesh::TreeNode< N >::nodes, and libMesh::TreeNode< N >::tgt_bin_size.
|
inline |
Destructor. Deletes all children, if any. Thus to delete a tree it is sufficient to explicitly delete the root node.
Definition at line 260 of file tree_node.h.
References libMesh::TreeNode< N >::children.
|
inline |
true
if this node is active (i.e. has no children), false otherwise. Definition at line 81 of file tree_node.h.
References libMesh::TreeNode< N >::bounds_node(), libMesh::TreeNode< N >::bounds_point(), libMesh::TreeNode< N >::children, libMesh::TreeNode< N >::create_bounding_box(), libMesh::TreeNode< N >::find_element(), libMesh::TreeNode< N >::find_element_in_children(), libMesh::TreeNode< N >::insert(), libMesh::TreeNode< N >::level(), libmesh_nullptr, libMesh::TreeNode< N >::n_active_bins(), libMesh::out, libMesh::TreeNode< N >::print_elements(), libMesh::TreeNode< N >::print_nodes(), libMesh::Real, libMesh::TreeNode< N >::refine(), libMesh::TreeNode< N >::set_bounding_box(), libMesh::TOLERANCE, and libMesh::TreeNode< N >::transform_nodes_to_elements().
Referenced by libMesh::TreeNode< N >::TreeNode().
bool libMesh::TreeNode< N >::bounds_node | ( | const Node * | nd, |
Real | relative_tol = 0 |
||
) | const |
true
if this TreeNode (or its children) contain node n (within relative tolerance), false otherwise. Definition at line 190 of file tree_node.C.
Referenced by libMesh::TreeNode< N >::active().
bool libMesh::TreeNode< N >::bounds_point | ( | const Point & | p, |
Real | relative_tol = 0 |
||
) | const |
true
if this TreeNode (or its children) contain point p (within relative tolerance), false otherwise. Definition at line 200 of file tree_node.C.
References libMesh::MeshTools::bounding_box(), std::max(), std::min(), and libMesh::Real.
Referenced by libMesh::TreeNode< N >::active().
|
private |
Constructs the bounding box for child c
.
Definition at line 228 of file tree_node.C.
References libMesh::MeshTools::bounding_box(), and libMesh::Real.
Referenced by libMesh::TreeNode< N >::active().
const Elem * libMesh::TreeNode< N >::find_element | ( | const Point & | p, |
const std::set< subdomain_id_type > * | allowed_subdomains = libmesh_nullptr , |
||
Real | relative_tol = TOLERANCE |
||
) | const |
Definition at line 467 of file tree_node.C.
References libmesh_nullptr.
Referenced by libMesh::TreeNode< N >::active().
|
private |
Look for point p
in our children, optionally restricted to a set of allowed subdomains.
Definition at line 495 of file tree_node.C.
References libmesh_nullptr.
Referenced by libMesh::TreeNode< N >::active().
bool libMesh::TreeNode< N >::insert | ( | const Node * | nd | ) |
Tries to insert Node
nd
into the TreeNode.
true
iff nd
is inserted into the TreeNode or one of its children. Definition at line 35 of file tree_node.C.
References libMesh::DofObject::id(), mesh, and libMesh::MeshBase::n_nodes().
Referenced by libMesh::TreeNode< N >::active().
bool libMesh::TreeNode< N >::insert | ( | const Elem * | nd | ) |
Inserts Elem
el
into the TreeNode.
true
iff el
is inserted into the TreeNode or one of its children. Definition at line 70 of file tree_node.C.
References libMesh::MeshTools::bounding_box(), libMesh::MeshBase::elem_dimensions(), libMesh::MeshBase::get_count_lower_dim_elems_in_point_locator(), libMesh::Elem::infinite(), libMesh::BoundingBox::intersects(), libMesh::Elem::loose_bounding_box(), and mesh.
|
inline |
true
if this node is the root node, false otherwise. Definition at line 75 of file tree_node.h.
References libmesh_nullptr, and libMesh::TreeNode< N >::parent.
|
inline |
Definition at line 273 of file tree_node.h.
References libmesh_nullptr, and libMesh::TreeNode< N >::parent.
Referenced by libMesh::TreeNode< N >::active().
unsigned int libMesh::TreeNode< N >::n_active_bins | ( | ) | const |
Definition at line 447 of file tree_node.C.
References libMesh::Parallel::sum().
Referenced by libMesh::TreeNode< N >::active().
void libMesh::TreeNode< N >::print_elements | ( | std::ostream & | out = libMesh::out | ) | const |
Prints the contents of the elements set if we are active.
Definition at line 366 of file tree_node.C.
Referenced by libMesh::TreeNode< N >::active().
void libMesh::TreeNode< N >::print_nodes | ( | std::ostream & | out = libMesh::out | ) | const |
Prints the contents of the node_numbers vector if we are active.
Definition at line 345 of file tree_node.C.
Referenced by libMesh::TreeNode< N >::active().
void libMesh::TreeNode< N >::refine | ( | ) |
Refine the tree node into N children if it contains more than tol nodes.
Definition at line 137 of file tree_node.C.
References libMesh::MeshTools::create_bounding_box(), mesh, libMesh::TreeNode< N >::set_bounding_box(), and swap().
Referenced by libMesh::TreeNode< N >::active().
void libMesh::TreeNode< N >::set_bounding_box | ( | const std::pair< Point, Point > & | bbox | ) |
Sets the bounding box;
Definition at line 182 of file tree_node.C.
References libMesh::MeshTools::bounding_box().
Referenced by libMesh::TreeNode< N >::active(), and libMesh::TreeNode< N >::refine().
void libMesh::TreeNode< N >::transform_nodes_to_elements | ( | std::vector< std::vector< const Elem * >> & | nodes_to_elem | ) |
Transforms node numbers to element pointers.
Definition at line 388 of file tree_node.C.
References mesh, libMesh::MeshBase::n_nodes(), and swap().
Referenced by libMesh::TreeNode< N >::active().
|
private |
The Cartesian bounding box for the node.
Definition at line 192 of file tree_node.h.
|
private |
Pointers to our children. This vector is empty if the node is active.
Definition at line 187 of file tree_node.h.
Referenced by libMesh::TreeNode< N >::active(), libMesh::TreeNode< N >::TreeNode(), and libMesh::TreeNode< N >::~TreeNode().
|
private |
Does this node contain any infinite elements.
Definition at line 222 of file tree_node.h.
|
private |
Pointers to the elements in this tree node.
Definition at line 197 of file tree_node.h.
Referenced by libMesh::TreeNode< N >::TreeNode().
|
private |
Reference to the mesh.
Definition at line 176 of file tree_node.h.
|
private |
The node numbers contained in this portion of the tree.
Definition at line 202 of file tree_node.h.
Referenced by libMesh::TreeNode< N >::TreeNode().
|
private |
Pointer to this node's parent.
Definition at line 181 of file tree_node.h.
Referenced by libMesh::TreeNode< N >::is_root(), and libMesh::TreeNode< N >::level().
|
mutableprivate |
Used in find_element_in_children
Definition at line 227 of file tree_node.h.
|
private |
This specifies the refinement level beyond which we will scale up the target bin size in child TreeNodes. We set the default to be 10, which should be large enough such that in most cases the target bin size does not need to be increased.
Definition at line 217 of file tree_node.h.
|
private |
The maximum number of things we should store before refining ourself.
Definition at line 208 of file tree_node.h.
Referenced by libMesh::TreeNode< N >::TreeNode().