www.mooseframework.org
KDTree.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 // Moose includes
13 #include "MooseMesh.h"
14 #include "PointListAdaptor.h"
15 
16 #include "libmesh/nanoflann.hpp"
17 #include "libmesh/utility.h"
18 
19 class KDTree
20 {
21 public:
22  KDTree(std::vector<Point> & master_points, unsigned int max_leaf_size);
23 
24  virtual ~KDTree() = default;
25 
26  void neighborSearch(Point & query_point,
27  unsigned int patch_size,
28  std::vector<std::size_t> & return_index);
29 
30  void neighborSearch(Point & query_point,
31  unsigned int patch_size,
32  std::vector<std::size_t> & return_index,
33  std::vector<Real> & return_dist_sqr);
34 
35  void radiusSearch(Point & query_point,
36  Real radius,
37  std::vector<std::pair<std::size_t, Real>> & indices_dist);
38 
39  using KdTreeT = nanoflann::KDTreeSingleIndexAdaptor<
40  nanoflann::L2_Simple_Adaptor<Real, PointListAdaptor<Point>>,
42  LIBMESH_DIM>;
43 
44 protected:
46  std::unique_ptr<KdTreeT> _kd_tree;
47 };
48 
KDTree(std::vector< Point > &master_points, unsigned int max_leaf_size)
Definition: KDTree.C:16
std::unique_ptr< KdTreeT > _kd_tree
Definition: KDTree.h:46
Definition: KDTree.h:19
void neighborSearch(Point &query_point, unsigned int patch_size, std::vector< std::size_t > &return_index)
Definition: KDTree.C:27
virtual ~KDTree()=default
void radiusSearch(Point &query_point, Real radius, std::vector< std::pair< std::size_t, Real >> &indices_dist)
Definition: KDTree.C:54
nanoflann::KDTreeSingleIndexAdaptor< nanoflann::L2_Simple_Adaptor< Real, PointListAdaptor< Point > >, PointListAdaptor< Point >, LIBMESH_DIM > KdTreeT
Definition: KDTree.h:42
PointListAdaptor< Point > _point_list_adaptor
Definition: KDTree.h:45