libMesh
tree.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2019 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_TREE_H
21 #define LIBMESH_TREE_H
22 
23 // Local includes
24 #include "libmesh/tree_node.h"
25 #include "libmesh/tree_base.h"
26 
27 // C++ includes
28 
29 namespace libMesh
30 {
31 
32 // Forward Declarations
33 class MeshBase;
34 
43 template <unsigned int N>
44 class Tree : public TreeBase
45 {
46 public:
50  Tree (const MeshBase & m,
51  unsigned int target_bin_size,
53 
57  Tree (const Tree<N> & other_tree);
58 
62  ~Tree() {}
63 
67  virtual void print_nodes(std::ostream & my_out=libMesh::out) const override;
68 
72  virtual void print_elements(std::ostream & my_out=libMesh::out) const override;
73 
77  virtual unsigned int n_active_bins() const override
78  { return root.n_active_bins(); }
79 
85  virtual const Elem * find_element(const Point & p,
86  const std::set<subdomain_id_type> * allowed_subdomains = nullptr,
87  Real relative_tol = TOLERANCE) const override;
88 
95  virtual void find_elements(const Point & p,
96  std::set<const Elem *> & candidate_elements,
97  const std::set<subdomain_id_type> * allowed_subdomains = nullptr,
98  Real relative_tol = TOLERANCE) const override;
99 
105  const Elem * operator() (const Point & p,
106  const std::set<subdomain_id_type> * allowed_subdomains = nullptr,
107  Real relative_tol = TOLERANCE) const;
108 
109 private:
114 
119 };
120 
121 
122 
127 namespace Trees
128 {
134 
140 
145 typedef Tree<8> OctTree;
146 }
147 
148 } // namespace libMesh
149 
150 
151 #endif // LIBMESH_TREE_H
libMesh::Tree::build_type
const Trees::BuildType build_type
How the tree is built.
Definition: tree.h:118
libMesh::Tree::find_elements
virtual void find_elements(const Point &p, std::set< const Elem * > &candidate_elements, const std::set< subdomain_id_type > *allowed_subdomains=nullptr, Real relative_tol=TOLERANCE) const override
Fills candidate_elements with any elements containing the specified point p, optionally restricted to...
Definition: tree.C:150
libMesh::Trees::BinaryTree
Tree< 2 > BinaryTree
A BinaryTree is a tree appropriate for 1D meshes.
Definition: tree.h:133
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::Tree::~Tree
~Tree()
Destructor.
Definition: tree.h:62
libMesh::TOLERANCE
static const Real TOLERANCE
Definition: libmesh_common.h:128
libMesh::Tree::root
TreeNode< N > root
The tree root.
Definition: tree.h:113
libMesh::Tree::print_nodes
virtual void print_nodes(std::ostream &my_out=libMesh::out) const override
Prints the nodes.
Definition: tree.C:120
libMesh::TreeNode
This class defines a node on a tree.
Definition: tree_node.h:53
libMesh::Trees::BuildType
BuildType
enum defining how to build the tree.
Definition: tree_base.h:55
libMesh::Tree::n_active_bins
virtual unsigned int n_active_bins() const override
Definition: tree.h:77
libMesh::MeshBase
This is the MeshBase class.
Definition: mesh_base.h:78
libMesh::Point
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
libMesh::TreeBase
This is the base class for trees, it allows pointer usage of trees.
Definition: tree_base.h:65
libMesh::Tree::operator()
const Elem * operator()(const Point &p, const std::set< subdomain_id_type > *allowed_subdomains=nullptr, Real relative_tol=TOLERANCE) const
Definition: tree.C:162
libMesh::Tree::find_element
virtual const Elem * find_element(const Point &p, const std::set< subdomain_id_type > *allowed_subdomains=nullptr, Real relative_tol=TOLERANCE) const override
Definition: tree.C:139
libMesh::Elem
This is the base class from which all geometric element types are derived.
Definition: elem.h:100
libMesh::Trees::NODES
Definition: tree_base.h:55
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
libMesh::Trees::OctTree
Tree< 8 > OctTree
An OctTree is a tree appropriate for 3D meshes.
Definition: tree.h:145
libMesh::Tree
This class defines a tree that may be used for fast point location in space.
Definition: tree.h:44
libMesh::out
OStreamProxy out
libMesh::Tree::print_elements
virtual void print_elements(std::ostream &my_out=libMesh::out) const override
Prints the nodes.
Definition: tree.C:129
libMesh::Trees::QuadTree
Tree< 4 > QuadTree
A QuadTree is a tree appropriate for 2D meshes.
Definition: tree.h:139
libMesh::Tree::Tree
Tree(const MeshBase &m, unsigned int target_bin_size, Trees::BuildType bt=Trees::NODES)
Constructor.
Definition: tree.C:37