libMesh
Loading...
Searching...
No Matches
point_locator_base.h
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 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_BASE_H
21#define LIBMESH_POINT_LOCATOR_BASE_H
22
23// Local Includes
24#include "libmesh/reference_counted_object.h"
25#include "libmesh/libmesh_common.h"
26
27// C++ includes
28#include <cstddef>
29#include <memory>
30#include <set>
31#include <vector>
32
33namespace libMesh
34{
35
36// Forward Declarations
37class PointLocatorBase;
38class MeshBase;
39class Point;
40class TreeBase;
41class Elem;
42class Node;
44
45
54class PointLocatorBase : public ReferenceCountedObject<PointLocatorBase>
55{
56protected:
63 const PointLocatorBase * master);
64
65public:
70
77 static std::unique_ptr<PointLocatorBase> build (PointLocatorType t,
78 const MeshBase & mesh,
79 const PointLocatorBase * master = nullptr);
80
84 virtual void clear() = 0;
85
90 virtual void init() = 0;
91
97 virtual const Elem * operator() (const Point & p,
98 const std::set<subdomain_id_type> * allowed_subdomains = nullptr) const = 0;
99
105 virtual void operator() (const Point & p,
106 std::set<const Elem *> & candidate_elements,
107 const std::set<subdomain_id_type> * allowed_subdomains = nullptr) const = 0;
108
125 virtual const Node *
126 locate_node (const Point & p,
127 const std::set<subdomain_id_type> * allowed_subdomains = nullptr,
128 Real tol = TOLERANCE) const;
129
134 bool initialized () const;
135
142 virtual void enable_out_of_mesh_mode () = 0;
143
149 virtual void disable_out_of_mesh_mode () = 0;
150
155
160 virtual void set_close_to_point_tol(Real close_to_point_tol);
161
166 virtual void unset_close_to_point_tol();
167
172 virtual void set_contains_point_tol(Real contains_point_tol);
173
178 virtual void unset_contains_point_tol();
179
184 virtual Real get_contains_point_tol() const;
185
193
197 const MeshBase & get_mesh() const;
198
203 bool get_verbose() const { return _verbose; }
204
208 void set_verbose(bool verbosity) { _verbose = verbosity; }
209
210#ifndef NDEBUG
221#endif
222
223
224#ifndef LIBMESH_ENABLE_DEPRECATED
225protected:
226#endif
227
232
233protected:
240
245
250
256
261
267
272};
273
274} // namespace libMesh
275
276#endif // LIBMESH_POINT_LOCATOR_BASE_H
void ErrorVector unsigned int
This is the base class from which all geometric element types are derived.
Definition elem.h:96
This is the MeshBase class.
Definition mesh_base.h:81
A Node is like a Point, but with more information.
Definition node.h:55
This is the base class for point locators.
bool get_verbose() const
Get the verbosity setting (whether to print extra info to screen, default false) for this PointLocato...
const MeshBase & get_mesh() const
Get a const reference to this PointLocator's mesh.
void libmesh_assert_valid_point_locator()
Verifies that, for every node of every element, the point locator finds that element when searching a...
virtual ~PointLocatorBase()
Destructor.
void set_verbose(bool verbosity)
Set the verbosity setting for this PointLocator.
Real _close_to_point_tol
The tolerance to use.
virtual void enable_out_of_mesh_mode()=0
Enables out-of-mesh mode.
Real _contains_point_tol
The tolerance to use when locating an element in the tree.
virtual void unset_contains_point_tol()
Specify that we do not want to use a user-specified tolerance to determine if a point is inside an el...
virtual const Elem * operator()(const Point &p, const std::set< subdomain_id_type > *allowed_subdomains=nullptr) const =0
Locates the element in which the point with global coordinates p is located.
virtual const Node * locate_node(const Point &p, const std::set< subdomain_id_type > *allowed_subdomains=nullptr, Real tol=TOLERANCE) const
virtual void init()=0
Initializes the point locator, so that the operator() methods can be used.
bool _initialized
true when properly initialized, false otherwise.
virtual void set_contains_point_tol(Real contains_point_tol)
Set a tolerance to use when checking if a point is within an element in the mesh.
static std::unique_ptr< PointLocatorBase > build(PointLocatorType t, const MeshBase &mesh, const PointLocatorBase *master=nullptr)
Builds an PointLocator for the mesh mesh.
virtual void clear()=0
Clears the PointLocator.
virtual void disable_out_of_mesh_mode()=0
Disables out-of-mesh mode (default).
bool _use_contains_point_tol
true if we will use a user-specified tolerance for locating the element.
bool _use_close_to_point_tol
true if we will use a user-specified tolerance for locating the element in an exhaustive search.
bool get_use_contains_point_tol() const
The contains_point_tol may be nonzero (in fact it defaults to non-zero) but unless the user calls set...
virtual void set_close_to_point_tol(Real close_to_point_tol)
Set a tolerance to use when determining if a point is contained within the mesh.
virtual Real get_contains_point_tol() const
Get the tolerance for determining element containment in the point locator.
bool _verbose
Boolean flag to indicate whether to print out extra info.
const MeshBase & _mesh
constant reference to the mesh in which the point is looked for.
Real get_close_to_point_tol() const
Get the close-to-point tolerance.
const PointLocatorBase * _master
Const pointer to our master, initialized to nullptr if none given.
virtual void unset_close_to_point_tol()
Specify that we do not want to use a user-specified tolerance to determine if a point is contained wi...
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:40
This class implements reference counting.
MeshBase & mesh
The libMesh namespace provides an interface to certain functionality in the library.
static constexpr Real TOLERANCE
PointLocatorType
defines an enum for the types of point locators (given a point with global coordinates,...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real