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=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) |
void | transform_nodes_to_elements (std::unordered_map< dof_id_type, 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=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 |
Base class for different Tree types.
This class defines a node on a tree. A tree node contains a pointer to its parent (nullptr if the node is the root) and pointers to its children (nullptr if the node is active.
Definition at line 53 of file tree_node.h.
|
inline |
Constructor. Takes a pointer to this node's parent. The pointer should only be nullptr for the top-level (root) node.
Definition at line 239 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 261 of file tree_node.h.
|
inline |
true
if this node is active (i.e. has no children), false otherwise. Definition at line 82 of file tree_node.h.
References libMesh::TreeNode< N >::children.
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 191 of file tree_node.C.
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 201 of file tree_node.C.
References libMesh::MeshTools::bounding_box(), std::max(), std::min(), and libMesh::Real.
|
private |
Constructs the bounding box for child c
.
Definition at line 229 of file tree_node.C.
References libMesh::MeshTools::bounding_box(), and libMesh::Real.
const Elem * libMesh::TreeNode< N >::find_element | ( | const Point & | p, |
const std::set< subdomain_id_type > * | allowed_subdomains = nullptr , |
||
Real | relative_tol = TOLERANCE |
||
) | const |
Definition at line 523 of file tree_node.C.
|
private |
Look for point p
in our children, optionally restricted to a set of allowed subdomains.
Definition at line 550 of file tree_node.C.
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 36 of file tree_node.C.
References libMesh::DofObject::id(), mesh, and libMesh::MeshBase::n_nodes().
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 71 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 76 of file tree_node.h.
References libMesh::TreeNode< N >::parent.
|
inline |
unsigned int libMesh::TreeNode< N >::n_active_bins | ( | ) | const |
Definition at line 503 of file tree_node.C.
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 367 of file tree_node.C.
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 346 of file tree_node.C.
void libMesh::TreeNode< N >::refine | ( | ) |
Refine the tree node into N children if it contains more than tol nodes.
Definition at line 138 of file tree_node.C.
References libMesh::MeshTools::create_bounding_box(), mesh, libMesh::TreeNode< N >::set_bounding_box(), and swap().
void libMesh::TreeNode< N >::set_bounding_box | ( | const std::pair< Point, Point > & | bbox | ) |
Sets the bounding box;
Definition at line 183 of file tree_node.C.
References libMesh::MeshTools::bounding_box().
Referenced by 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().
void libMesh::TreeNode< N >::transform_nodes_to_elements | ( | std::unordered_map< dof_id_type, std::vector< const Elem *>> & | nodes_to_elem | ) |
Transforms node numbers to element pointers.
Definition at line 446 of file tree_node.C.
References mesh, libMesh::MeshBase::n_nodes(), and swap().
|
private |
The Cartesian bounding box for the node.
Definition at line 198 of file tree_node.h.
|
private |
Pointers to our children. This vector is empty if the node is active.
Definition at line 193 of file tree_node.h.
Referenced by libMesh::TreeNode< N >::active(), and libMesh::TreeNode< N >::TreeNode().
|
private |
Does this node contain any infinite elements.
Definition at line 228 of file tree_node.h.
|
private |
Pointers to the elements in this tree node.
Definition at line 203 of file tree_node.h.
Referenced by libMesh::TreeNode< N >::TreeNode().
|
private |
Reference to the mesh.
Definition at line 182 of file tree_node.h.
|
private |
The node numbers contained in this portion of the tree.
Definition at line 208 of file tree_node.h.
Referenced by libMesh::TreeNode< N >::TreeNode().
|
private |
Pointer to this node's parent.
Definition at line 187 of file tree_node.h.
Referenced by libMesh::TreeNode< N >::is_root().
|
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 223 of file tree_node.h.
|
private |
The maximum number of things we should store before refining ourself.
Definition at line 214 of file tree_node.h.
Referenced by libMesh::TreeNode< N >::TreeNode().