www.mooseframework.org
Public Types | Public Member Functions | Private Attributes | List of all members
KDTree::PointListAdaptor< KDDim > Class Template Reference

PointListAdaptor is required to use libMesh Point coordinate type with nanoflann KDTree library. More...

#include <KDTree.h>

Public Types

using coord_t = Real
 libMesh Point coordinate type More...
 

Public Member Functions

 PointListAdaptor (const std::vector< Point > &pts)
 
size_t kdtree_get_point_count () const
 Must return the number of data points. More...
 
coord_t kdtree_distance (const coord_t *p1, const size_t idx_p2, size_t) const
 Returns the distance between the vector "p1[0:size-1]" and the data point with index "idx_p2" stored in the class. More...
 
coord_t kdtree_get_pt (const size_t idx, int dim) const
 Returns the dim'th component of the idx'th point in the class: Since this is inlined and the "dim" argument is typically an immediate value, the "if's" are actually solved at compile time. More...
 
template<class BBOX >
bool kdtree_get_bbox (BBOX &) const
 Optional bounding-box computation. More...
 

Private Attributes

const std::vector< Point > & _pts
 

Detailed Description

template<unsigned int KDDim>
class KDTree::PointListAdaptor< KDDim >

PointListAdaptor is required to use libMesh Point coordinate type with nanoflann KDTree library.

The member functions within the PointListAdaptor are used by nanoflann library.

Definition at line 40 of file KDTree.h.

Member Typedef Documentation

template<unsigned int KDDim>
using KDTree::PointListAdaptor< KDDim >::coord_t = Real

libMesh Point coordinate type

Definition at line 51 of file KDTree.h.

Constructor & Destructor Documentation

template<unsigned int KDDim>
KDTree::PointListAdaptor< KDDim >::PointListAdaptor ( const std::vector< Point > &  pts)
inline

Definition at line 46 of file KDTree.h.

46 : _pts(pts) {}
const std::vector< Point > & _pts
Definition: KDTree.h:43

Member Function Documentation

template<unsigned int KDDim>
coord_t KDTree::PointListAdaptor< KDDim >::kdtree_distance ( const coord_t p1,
const size_t  idx_p2,
size_t   
) const
inline

Returns the distance between the vector "p1[0:size-1]" and the data point with index "idx_p2" stored in the class.

Definition at line 61 of file KDTree.h.

62  {
63  mooseAssert(idx_p2 <= _pts.size(),
64  "The point index should be less than"
65  "total number of points used to build"
66  "the KDTree.");
67 
68  const Point & p2(_pts[idx_p2]);
69 
70  coord_t dist = 0.0;
71 
72  for (unsigned int i = 0; i < LIBMESH_DIM; ++i)
73  dist += std::pow(p1[i] - p2(i), 2.0);
74 
75  return dist;
76  }
Real coord_t
libMesh Point coordinate type
Definition: KDTree.h:51
const std::vector< Point > & _pts
Definition: KDTree.h:43
template<unsigned int KDDim>
template<class BBOX >
bool KDTree::PointListAdaptor< KDDim >::kdtree_get_bbox ( BBOX &  ) const
inline

Optional bounding-box computation.

This function is called by the nanoflann library. If the return value is false, the standard bbox computation loop in the nanoflann library is activated.

Definition at line 104 of file KDTree.h.

105  {
106  return false;
107  }
template<unsigned int KDDim>
size_t KDTree::PointListAdaptor< KDDim >::kdtree_get_point_count ( ) const
inline

Must return the number of data points.

Definition at line 55 of file KDTree.h.

55 { return _pts.size(); }
const std::vector< Point > & _pts
Definition: KDTree.h:43
template<unsigned int KDDim>
coord_t KDTree::PointListAdaptor< KDDim >::kdtree_get_pt ( const size_t  idx,
int  dim 
) const
inline

Returns the dim'th component of the idx'th point in the class: Since this is inlined and the "dim" argument is typically an immediate value, the "if's" are actually solved at compile time.

Definition at line 84 of file KDTree.h.

85  {
86  mooseAssert(dim < (int)LIBMESH_DIM,
87  "The required component number should be less than the LIBMESH_DIM.");
88  mooseAssert(idx < _pts.size(),
89  "The index of the point should be less"
90  "than total number of points used to"
91  "construct the KDTree.");
92 
93  const Point & p(_pts[idx]);
94 
95  return p(dim);
96  }
const std::vector< Point > & _pts
Definition: KDTree.h:43

Member Data Documentation

template<unsigned int KDDim>
const std::vector<Point>& KDTree::PointListAdaptor< KDDim >::_pts
private

Definition at line 43 of file KDTree.h.


The documentation for this class was generated from the following file: