20 #ifndef LIBMESH_POINT_LOCATOR_NANOFLANN_H 21 #define LIBMESH_POINT_LOCATOR_NANOFLANN_H 23 #include "libmesh/libmesh_config.h" 26 #ifdef LIBMESH_HAVE_NANOFLANN 29 #include "libmesh/point_locator_base.h" 30 #include "libmesh/point.h" 31 #include "libmesh/bounding_box.h" 34 #include "libmesh/nanoflann.hpp" 92 virtual void clear()
override final;
98 virtual void init()
override final;
106 const std::set<subdomain_id_type> * allowed_subdomains =
nullptr)
const override final;
118 std::set<const Elem *> & candidate_elements,
119 const std::set<subdomain_id_type> * allowed_subdomains =
nullptr)
const override final;
179 const std::size_t idx_p2,
180 std::size_t size)
const;
195 template <
class BBOX>
222 std::shared_ptr<std::vector<const Elem *>>
_elems;
228 typedef nanoflann::L2_Simple_Adaptor<Real, PointLocatorNanoflann>
adapter_t;
229 typedef nanoflann::KDTreeSingleIndexAdaptor<adapter_t, PointLocatorNanoflann, LIBMESH_DIM>
kd_tree_t;
244 mutable std::vector<std::size_t>
_b;
254 nanoflann::KNNResultSet<Real>
256 std::size_t num_results)
const;
261 #endif // LIBMESH_HAVE_NANOFLANN 262 #endif // LIBMESH_POINT_LOCATOR_NANOFLANN_H nanoflann::KNNResultSet< Real > kd_tree_find_neighbors(const Point &p, std::size_t num_results) const
Helper function that wraps the call to the KDTree's findNeighbors() routine.
nanoflann::KDTreeSingleIndexAdaptor< adapter_t, PointLocatorNanoflann, LIBMESH_DIM > kd_tree_t
std::vector< std::size_t > _b
Vector of indices used by indirect sort.
bool kdtree_get_bbox(BBOX &) const
Optional bounding-box computation: return false to default to a standard bbox computation loop...
coord_t kdtree_distance(const coord_t *p1, const std::size_t idx_p2, std::size_t size) const
Returns the squared distance between the vector (p1[0], p1[1], p1[2]) and the vertex average of Elem ...
bool _out_of_mesh_mode
true if out-of-mesh mode is enabled.
This is the base class from which all geometric element types are derived.
virtual void init() override final
Initializes the locator, so that the operator() methods can be used.
std::size_t get_num_results() const
Set/get the number of results returned by each Nanoflann findNeighbors() search.
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...
The libMesh namespace provides an interface to certain functionality in the library.
This is the MeshBase class.
std::size_t _num_results
The number of results returned by Nanoflann when operator() is called.
std::vector< Real > _out_dist_sqr
Real coord_t
Floating point type used for storing coordinates.
virtual ~PointLocatorNanoflann()
Destructor.
This is the base class for point locators.
std::size_t kdtree_get_point_count() const
Must return the number of data points.
std::vector< std::size_t > _ret_index
The operator() functions on PointLocator-derived classes are const, so to avoid re-allocating these r...
PointLocatorNanoflann(const MeshBase &mesh, const PointLocatorBase *master=nullptr)
Constructor.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::shared_ptr< kd_tree_t > _kd_tree
nanoflann::L2_Simple_Adaptor< Real, PointLocatorNanoflann > adapter_t
virtual void disable_out_of_mesh_mode() override final
Disables out-of-mesh mode (default).
coord_t kdtree_get_pt(const std::size_t idx, int dim) const
Returns the dim'th component of the idx'th vertex average.
std::shared_ptr< std::vector< const Elem * > > _elems
Lists of Points and ids which make up the "point cloud" that is to be searched via Nanoflann...
void set_num_results(std::size_t val)
std::shared_ptr< std::vector< Point > > _point_cloud
A Point defines a location in LIBMESH_DIM dimensional Real space.
This is a PointLocator that uses Nanoflann for its implementation.
virtual void enable_out_of_mesh_mode() override final
Enables out-of-mesh mode.
virtual void clear() override final
Restore to PointLocator to a just-constructed state.