libMesh
Public Member Functions | Private Member Functions | Private Attributes | List of all members
libMesh::TreeNode< N > Class Template Reference

This class defines a node on a tree. More...

#include <tree_node.h>

Public Member Functions

 TreeNode (const MeshBase &m, unsigned int tbs, const TreeNode< N > *p=nullptr)
 Constructor. More...
 
 ~TreeNode ()
 Destructor. More...
 
bool is_root () const
 
bool active () const
 
bool insert (const Node *nd)
 Tries to insert Node nd into the TreeNode. More...
 
bool insert (const Elem *nd)
 Inserts Elem el into the TreeNode. More...
 
void refine ()
 Refine the tree node into N children if it contains more than tol nodes. More...
 
void set_bounding_box (const std::pair< Point, Point > &bbox)
 Sets the bounding box;. More...
 
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
 Prints the contents of the node_numbers vector if we are active. More...
 
void print_elements (std::ostream &out=libMesh::out) const
 Prints the contents of the elements set if we are active. More...
 
void transform_nodes_to_elements (std::vector< std::vector< const Elem *>> &nodes_to_elem)
 Transforms node numbers to element pointers. More...
 
void transform_nodes_to_elements (std::unordered_map< dof_id_type, std::vector< const Elem *>> &nodes_to_elem)
 Transforms node numbers to element pointers. More...
 
unsigned int n_active_bins () const
 
const Elemfind_element (const Point &p, const std::set< subdomain_id_type > *allowed_subdomains=nullptr, Real relative_tol=TOLERANCE) const
 

Private Member Functions

const Elemfind_element_in_children (const Point &p, const std::set< subdomain_id_type > *allowed_subdomains, Real relative_tol) const
 Look for point p in our children, optionally restricted to a set of allowed subdomains. More...
 
BoundingBox create_bounding_box (unsigned int c) const
 Constructs the bounding box for child c. More...
 

Private Attributes

const MeshBasemesh
 Reference to the mesh. More...
 
const TreeNode< N > * parent
 Pointer to this node's parent. More...
 
std::vector< TreeNode< N > *> children
 Pointers to our children. More...
 
BoundingBox bounding_box
 The Cartesian bounding box for the node. More...
 
std::vector< const Elem * > elements
 Pointers to the elements in this tree node. More...
 
std::vector< const Node * > nodes
 The node numbers contained in this portion of the tree. More...
 
const unsigned int tgt_bin_size
 The maximum number of things we should store before refining ourself. More...
 
unsigned int target_bin_size_increase_level
 This specifies the refinement level beyond which we will scale up the target bin size in child TreeNodes. More...
 
bool contains_ifems
 Does this node contain any infinite elements. More...
 

Detailed Description

template<unsigned int N>
class libMesh::TreeNode< N >

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.

Author
Daniel Dreyer
Date
2003 Base class for different Tree types.

Definition at line 53 of file tree_node.h.

Constructor & Destructor Documentation

◆ TreeNode()

template<unsigned int N>
libMesh::TreeNode< N >::TreeNode ( const MeshBase m,
unsigned int  tbs,
const TreeNode< N > *  p = nullptr 
)

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.

241  :
242  mesh (m),
243  parent (p),
244  tgt_bin_size (tbs),
246  contains_ifems (false)
247 {
248  // libmesh_assert our children are empty, thus we are active.
249  libmesh_assert (children.empty());
250  libmesh_assert (this->active());
251 
252  // Reserve space for the nodes & elements
253  nodes.reserve (tgt_bin_size);
254  elements.reserve (tgt_bin_size);
255 }
unsigned int target_bin_size_increase_level
This specifies the refinement level beyond which we will scale up the target bin size in child TreeNo...
Definition: tree_node.h:223
const TreeNode< N > * parent
Pointer to this node&#39;s parent.
Definition: tree_node.h:187
std::vector< const Node * > nodes
The node numbers contained in this portion of the tree.
Definition: tree_node.h:208
bool active() const
Definition: tree_node.h:82
std::vector< const Elem * > elements
Pointers to the elements in this tree node.
Definition: tree_node.h:203
const unsigned int tgt_bin_size
The maximum number of things we should store before refining ourself.
Definition: tree_node.h:214
const MeshBase & mesh
Reference to the mesh.
Definition: tree_node.h:182
std::vector< TreeNode< N > *> children
Pointers to our children.
Definition: tree_node.h:193
bool contains_ifems
Does this node contain any infinite elements.
Definition: tree_node.h:228

◆ ~TreeNode()

template<unsigned int N>
libMesh::TreeNode< N >::~TreeNode ( )

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.

262 {
263  // When we are destructed we must delete all of our
264  // children. They will this delete their children,
265  // All the way down the line...
266  for (std::size_t c=0; c<children.size(); c++)
267  delete children[c];
268 }
std::vector< TreeNode< N > *> children
Pointers to our children.
Definition: tree_node.h:193

Member Function Documentation

◆ active()

template<unsigned int N>
bool libMesh::TreeNode< N >::active ( ) const
Returns
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().

82 { return children.empty(); }
std::vector< TreeNode< N > *> children
Pointers to our children.
Definition: tree_node.h:193

◆ bounds_node()

template<unsigned int N>
bool libMesh::TreeNode< N >::bounds_node ( const Node nd,
Real  relative_tol = 0 
) const
Returns
true if this TreeNode (or its children) contain node n (within relative tolerance), false otherwise.

◆ bounds_point()

template<unsigned int N>
bool libMesh::TreeNode< N >::bounds_point ( const Point p,
Real  relative_tol = 0 
) const
Returns
true if this TreeNode (or its children) contain point p (within relative tolerance), false otherwise.

◆ create_bounding_box()

template<unsigned int N>
BoundingBox libMesh::TreeNode< N >::create_bounding_box ( unsigned int  c) const
private

Constructs the bounding box for child c.

◆ find_element()

template<unsigned int N>
const Elem* libMesh::TreeNode< N >::find_element ( const Point p,
const std::set< subdomain_id_type > *  allowed_subdomains = nullptr,
Real  relative_tol = TOLERANCE 
) const
Returns
An element containing point p, optionally restricted to a set of allowed subdomains.

◆ find_element_in_children()

template<unsigned int N>
const Elem* libMesh::TreeNode< N >::find_element_in_children ( const Point p,
const std::set< subdomain_id_type > *  allowed_subdomains,
Real  relative_tol 
) const
private

Look for point p in our children, optionally restricted to a set of allowed subdomains.

◆ insert() [1/2]

template<unsigned int N>
bool libMesh::TreeNode< N >::insert ( const Node nd)

Tries to insert Node nd into the TreeNode.

Returns
true iff nd is inserted into the TreeNode or one of its children.

◆ insert() [2/2]

template<unsigned int N>
bool libMesh::TreeNode< N >::insert ( const Elem nd)

Inserts Elem el into the TreeNode.

Returns
true iff el is inserted into the TreeNode or one of its children.

◆ is_root()

template<unsigned int N>
bool libMesh::TreeNode< N >::is_root ( ) const
Returns
true if this node is the root node, false otherwise.

Definition at line 76 of file tree_node.h.

References libMesh::TreeNode< N >::parent.

76 { return (parent == nullptr); }
const TreeNode< N > * parent
Pointer to this node&#39;s parent.
Definition: tree_node.h:187

◆ level()

template<unsigned int N>
unsigned int libMesh::TreeNode< N >::level ( ) const
Returns
The level of the node.

Definition at line 274 of file tree_node.h.

275 {
276  if (parent != nullptr)
277  return parent->level()+1;
278 
279  // if we have no parent, we are a level-0 box
280  return 0;
281 }
const TreeNode< N > * parent
Pointer to this node&#39;s parent.
Definition: tree_node.h:187

◆ n_active_bins()

template<unsigned int N>
unsigned int libMesh::TreeNode< N >::n_active_bins ( ) const
Returns
The number of active bins below (including) this element.

◆ print_elements()

template<unsigned int N>
void libMesh::TreeNode< N >::print_elements ( std::ostream &  out = libMesh::out) const

Prints the contents of the elements set if we are active.

◆ print_nodes()

template<unsigned int N>
void libMesh::TreeNode< N >::print_nodes ( std::ostream &  out = libMesh::out) const

Prints the contents of the node_numbers vector if we are active.

◆ refine()

template<unsigned int N>
void libMesh::TreeNode< N >::refine ( )

Refine the tree node into N children if it contains more than tol nodes.

◆ set_bounding_box()

template<unsigned int N>
void libMesh::TreeNode< N >::set_bounding_box ( const std::pair< Point, Point > &  bbox)

Sets the bounding box;.

◆ transform_nodes_to_elements() [1/2]

template<unsigned int N>
void libMesh::TreeNode< N >::transform_nodes_to_elements ( std::vector< std::vector< const Elem *>> &  nodes_to_elem)

Transforms node numbers to element pointers.

◆ transform_nodes_to_elements() [2/2]

template<unsigned int N>
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.

Member Data Documentation

◆ bounding_box

template<unsigned int N>
BoundingBox libMesh::TreeNode< N >::bounding_box
private

The Cartesian bounding box for the node.

Definition at line 198 of file tree_node.h.

◆ children

template<unsigned int N>
std::vector<TreeNode<N> * > libMesh::TreeNode< N >::children
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().

◆ contains_ifems

template<unsigned int N>
bool libMesh::TreeNode< N >::contains_ifems
private

Does this node contain any infinite elements.

Definition at line 228 of file tree_node.h.

◆ elements

template<unsigned int N>
std::vector<const Elem *> libMesh::TreeNode< N >::elements
private

Pointers to the elements in this tree node.

Definition at line 203 of file tree_node.h.

Referenced by libMesh::TreeNode< N >::TreeNode().

◆ mesh

template<unsigned int N>
const MeshBase& libMesh::TreeNode< N >::mesh
private

Reference to the mesh.

Definition at line 182 of file tree_node.h.

◆ nodes

template<unsigned int N>
std::vector<const Node *> libMesh::TreeNode< N >::nodes
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().

◆ parent

template<unsigned int N>
const TreeNode<N>* libMesh::TreeNode< N >::parent
private

Pointer to this node's parent.

Definition at line 187 of file tree_node.h.

Referenced by libMesh::TreeNode< N >::is_root().

◆ target_bin_size_increase_level

template<unsigned int N>
unsigned int libMesh::TreeNode< N >::target_bin_size_increase_level
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.

◆ tgt_bin_size

template<unsigned int N>
const unsigned int libMesh::TreeNode< N >::tgt_bin_size
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().


The documentation for this class was generated from the following file: