libMesh
Public Types | Public Member Functions | Private Attributes | List of all members
libMesh::InverseDistanceInterpolation< KDDim >::PointListAdaptor< PLDim > Class Template Reference

This class adapts list of libMesh Point types for use in a nanoflann KD-Tree. More...

#include <meshfree_interpolation.h>

Public Types

typedef Real coord_t
 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 size) const
 
coord_t kdtree_get_pt (const size_t idx, int dim) const
 
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>
template<unsigned int PLDim>
class libMesh::InverseDistanceInterpolation< KDDim >::PointListAdaptor< PLDim >

This class adapts list of libMesh Point types for use in a nanoflann KD-Tree.

For more on the basic idea see examples/pointcloud_adaptor_example.cpp in the nanoflann source tree.

Definition at line 191 of file meshfree_interpolation.h.

Member Typedef Documentation

template<unsigned int KDDim>
template<unsigned int PLDim>
typedef Real libMesh::InverseDistanceInterpolation< KDDim >::PointListAdaptor< PLDim >::coord_t

libMesh Point coordinate type

Definition at line 204 of file meshfree_interpolation.h.

Constructor & Destructor Documentation

template<unsigned int KDDim>
template<unsigned int PLDim>
libMesh::InverseDistanceInterpolation< KDDim >::PointListAdaptor< PLDim >::PointListAdaptor ( const std::vector< Point > &  pts)

Definition at line 197 of file meshfree_interpolation.h.

197  :
198  _pts(pts)
199  {}

Member Function Documentation

template<unsigned int KDDim>
template<unsigned int PLDim>
coord_t libMesh::InverseDistanceInterpolation< KDDim >::PointListAdaptor< PLDim >::kdtree_distance ( const coord_t p1,
const size_t  idx_p2,
size_t  size 
) const
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 215 of file meshfree_interpolation.h.

216  {
217  libmesh_assert_equal_to (size, PLDim);
218  libmesh_assert_less (idx_p2, _pts.size());
219 
220  const Point & p2(_pts[idx_p2]);
221 
222  switch (size)
223  {
224  case 3:
225  {
226  const coord_t d0=p1[0] - p2(0);
227  const coord_t d1=p1[1] - p2(1);
228  const coord_t d2=p1[2] - p2(2);
229 
230  return d0*d0 + d1*d1 + d2*d2;
231  }
232 
233  case 2:
234  {
235  const coord_t d0=p1[0] - p2(0);
236  const coord_t d1=p1[1] - p2(1);
237 
238  return d0*d0 + d1*d1;
239  }
240 
241  case 1:
242  {
243  const coord_t d0=p1[0] - p2(0);
244 
245  return d0*d0;
246  }
247 
248  default:
249  libmesh_error_msg("ERROR: unknown size " << size);
250  }
251 
252  return -1.;
253  }
template<unsigned int KDDim>
template<unsigned int PLDim>
template<class BBOX >
bool libMesh::InverseDistanceInterpolation< KDDim >::PointListAdaptor< PLDim >::kdtree_get_bbox ( BBOX &  ) const

Optional bounding-box computation.

Returns
true if the BBOX was already computed by the class and returned in bb so we can avoid redoing it, or false to default to a standard bbox computation loop.

Look at bb.size() to find out the expected dimensionality (e.g. 2 or 3 for point clouds)

Definition at line 284 of file meshfree_interpolation.h.

284 { return false; }
template<unsigned int KDDim>
template<unsigned int PLDim>
size_t libMesh::InverseDistanceInterpolation< KDDim >::PointListAdaptor< PLDim >::kdtree_get_point_count ( ) const

Must return the number of data points.

Definition at line 209 of file meshfree_interpolation.h.

209 { return _pts.size(); }
template<unsigned int KDDim>
template<unsigned int PLDim>
coord_t libMesh::InverseDistanceInterpolation< KDDim >::PointListAdaptor< PLDim >::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.

Definition at line 260 of file meshfree_interpolation.h.

261  {
262  libmesh_assert_less (dim, (int) PLDim);
263  libmesh_assert_less (idx, _pts.size());
264  libmesh_assert_less (dim, 3);
265 
266  const Point & p(_pts[idx]);
267 
268  if (dim==0) return p(0);
269  if (dim==1) return p(1);
270  return p(2);
271  }
unsigned int dim
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)
A useful inline function which replaces the macros used previously.

Member Data Documentation

template<unsigned int KDDim>
template<unsigned int PLDim>
const std::vector<Point>& libMesh::InverseDistanceInterpolation< KDDim >::PointListAdaptor< PLDim >::_pts
private

Definition at line 194 of file meshfree_interpolation.h.


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