libMesh
point_locator_tree.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2024 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_POINT_LOCATOR_TREE_H
21 #define LIBMESH_POINT_LOCATOR_TREE_H
22 
23 // Local Includes
24 #include "libmesh/point_locator_base.h"
25 #include "libmesh/tree_base.h"
26 
27 // C++ includes
28 #include <cstddef>
29 #include <memory> // std::shared_ptr
30 
31 namespace libMesh
32 {
33 
34 // Forward Declarations
35 class MeshBase;
36 class Point;
37 class Elem;
38 
50 {
51 public:
61  const PointLocatorBase * master = nullptr);
62 
63 
76  const Trees::BuildType build_type,
77  const PointLocatorBase * master = nullptr);
78 
83 
87  virtual void clear() override final;
88 
93  void init(Trees::BuildType build_type);
94 
99  virtual void init() override final;
100 
108  virtual const Elem * operator() (const Point & p,
109  const std::set<subdomain_id_type> * allowed_subdomains = nullptr) const override final;
110 
115  virtual void operator() (const Point & p,
116  std::set<const Elem *> & candidate_elements,
117  const std::set<subdomain_id_type> * allowed_subdomains = nullptr) const override final;
118 
127  const Elem * perform_linear_search(const Point & p,
128  const std::set<subdomain_id_type> * allowed_subdomains,
129  bool use_close_to_point,
130  Real close_to_point_tolerance=TOLERANCE) const;
131 
137  std::set<const Elem *> perform_fuzzy_linear_search(const Point & p,
138  const std::set<subdomain_id_type> * allowed_subdomains,
139  Real close_to_point_tolerance=TOLERANCE) const;
140 
147  virtual void enable_out_of_mesh_mode () override final;
148 
154  virtual void disable_out_of_mesh_mode () override final;
155 
159  void set_target_bin_size(unsigned int target);
160 
164  unsigned int get_target_bin_size() const;
165 
166 protected:
172  std::shared_ptr<TreeBase> _tree;
173 
179  mutable const Elem * _element;
180 
186 
190  unsigned int _target_bin_size;
191 
196 };
197 
198 } // namespace libMesh
199 
200 #endif // LIBMESH_POINT_LOCATOR_TREE_H
virtual void enable_out_of_mesh_mode() override final
Enables out-of-mesh mode.
~PointLocatorTree()
Destructor.
BuildType
enum defining how to build the tree.
Definition: tree_base.h:58
virtual const Elem * operator()(const Point &p, const std::set< subdomain_id_type > *allowed_subdomains=nullptr) const override final
Locates the element in which the point with global coordinates p is located, optionally restricted to...
This is a point locator.
static constexpr Real TOLERANCE
virtual void clear() override final
Clears the locator.
virtual void init() override final
Initializes the locator, so that the operator() methods can be used.
std::shared_ptr< TreeBase > _tree
Pointer to our tree.
unsigned int get_target_bin_size() const
Get the target bin size.
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
MeshBase & mesh
The libMesh namespace provides an interface to certain functionality in the library.
const Elem * _element
Pointer to the last element that was found by the tree.
This is the MeshBase class.
Definition: mesh_base.h:74
PointLocatorTree(const MeshBase &mesh, const PointLocatorBase *master=nullptr)
Constructor.
This is the base class for point locators.
Trees::BuildType _build_type
How the underlying tree is built.
unsigned int _target_bin_size
Target bin size, which gets passed to the constructor of _tree.
bool _out_of_mesh_mode
true if out-of-mesh mode is enabled.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Elem * perform_linear_search(const Point &p, const std::set< subdomain_id_type > *allowed_subdomains, bool use_close_to_point, Real close_to_point_tolerance=TOLERANCE) const
As a fallback option, it&#39;s helpful to be able to do a linear search over the entire mesh...
std::set< const Elem * > perform_fuzzy_linear_search(const Point &p, const std::set< subdomain_id_type > *allowed_subdomains, Real close_to_point_tolerance=TOLERANCE) const
A method to check if "fat" point p is in multiple elements.
void set_target_bin_size(unsigned int target)
Set the target bin size.
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:39
virtual void disable_out_of_mesh_mode() override final
Disables out-of-mesh mode (default).