libMesh
tree_base.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2025 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_BASE_H
21 #define LIBMESH_TREE_BASE_H
22 
23 // Local includes
24 #include "libmesh/reference_counted_object.h"
25 #include "libmesh/id_types.h" // subdomain_id_type
26 #include "libmesh/libmesh_common.h" // TOLERANCE
27 
28 // C++ includes
29 #include <set>
30 #include <ostream>
31 
32 namespace libMesh
33 {
34 
35 
36 // Forward Declarations
37 class TreeBase;
38 class MeshBase;
39 class Point;
40 class Elem;
41 
42 
43 namespace Trees
44 {
58 enum BuildType : int {NODES=0,
62 }
63 
68 class TreeBase : public ReferenceCountedObject<TreeBase>
69 {
70 protected:
74  explicit
75  TreeBase (const MeshBase & m) : mesh(m) {}
76 
77 public:
81  virtual ~TreeBase() = default;
82 
86  virtual void print_nodes(std::ostream & out_stream=libMesh::out) const = 0;
87 
91  virtual void print_elements(std::ostream & out_stream=libMesh::out) const = 0;
92 
96  virtual unsigned int n_active_bins() const = 0;
97 
103  virtual const Elem * find_element(const Point & p,
104  const std::set<subdomain_id_type> * allowed_subdomains = nullptr,
105  Real relative_tol = TOLERANCE) const = 0;
106 
113  virtual void find_elements(const Point & p,
114  std::set<const Elem *> & candidate_elements,
115  const std::set<subdomain_id_type> * allowed_subdomains = nullptr,
116  Real relative_tol = TOLERANCE) const = 0;
117 
118 protected:
119 
124  const MeshBase & mesh;
125 };
126 
127 } // namespace libMesh
128 
129 
130 #endif // LIBMESH_TREE_BASE_H
BuildType
enum defining how to build the tree.
Definition: tree_base.h:58
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 =0
Fills candidate_elements with any elements containing the specified point p, optionally restricted to...
static constexpr Real TOLERANCE
TreeBase(const MeshBase &m)
Constructor.
Definition: tree_base.h:75
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
The libMesh namespace provides an interface to certain functionality in the library.
virtual void print_nodes(std::ostream &out_stream=libMesh::out) const =0
Prints the nodes.
virtual unsigned int n_active_bins() const =0
This is the MeshBase class.
Definition: mesh_base.h:75
virtual void print_elements(std::ostream &out_stream=libMesh::out) const =0
Prints the nodes.
const MeshBase & mesh
Constant reference to a mesh.
Definition: tree_base.h:124
virtual ~TreeBase()=default
Destructor.
virtual const Elem * find_element(const Point &p, const std::set< subdomain_id_type > *allowed_subdomains=nullptr, Real relative_tol=TOLERANCE) const =0
This class implements reference counting.
This is the base class for trees, it allows pointer usage of trees.
Definition: tree_base.h:68
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
OStreamProxy out
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:39