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

#include <PointListAdaptor.h>

Public Types

using Iterator = typename std::vector< PointObject >::const_iterator
 
using coord_t = Real
 libMesh Point coordinate type More...
 

Public Member Functions

 PointListAdaptor (Iterator begin, Iterator end)
 
size_t kdtree_get_point_count () const
 Must return the number of data points. More...
 
const Point & getPoint (const PointObject &item) const
 get a Point reference from the PointData object at index idx in the list 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...
 
template<>
const Point & getPoint (const MooseMesh::PeriodicNodeInfo &item) const
 

Private Attributes

const Iterator _begin
 begin iterator of the underlying point type vector More...
 
const Iterator _end
 end iterator of the underlying point type vector More...
 
std::size_t _size
 number of elements pointed to More...
 

Detailed Description

template<typename PointObject>
class PointListAdaptor< PointObject >

Definition at line 19 of file PointListAdaptor.h.

Member Typedef Documentation

◆ coord_t

template<typename PointObject>
using PointListAdaptor< PointObject >::coord_t = Real

libMesh Point coordinate type

Definition at line 43 of file PointListAdaptor.h.

◆ Iterator

template<typename PointObject>
using PointListAdaptor< PointObject >::Iterator = typename std::vector<PointObject>::const_iterator

Definition at line 22 of file PointListAdaptor.h.

Constructor & Destructor Documentation

◆ PointListAdaptor()

template<typename PointObject>
PointListAdaptor< PointObject >::PointListAdaptor ( Iterator  begin,
Iterator  end 
)
inline

Definition at line 24 of file PointListAdaptor.h.

25  : _begin(begin), _end(end), _size(std::distance(begin, end))
26  {
27  }
const Iterator _end
end iterator of the underlying point type vector
const Iterator _begin
begin iterator of the underlying point type vector
std::size_t _size
number of elements pointed to

Member Function Documentation

◆ getPoint() [1/2]

template<typename PointObject>
const Point& PointListAdaptor< PointObject >::getPoint ( const PointObject &  item) const

get a Point reference from the PointData object at index idx in the list

Referenced by PointListAdaptor< Point >::kdtree_distance(), and PointListAdaptor< Point >::kdtree_get_pt().

◆ getPoint() [2/2]

template<>
const Point & PointListAdaptor< MooseMesh::PeriodicNodeInfo >::getPoint ( const MooseMesh::PeriodicNodeInfo item) const
inline

Definition at line 1200 of file MooseMesh.C.

1202 {
1203  return *(item.first);
1204 }

◆ kdtree_distance()

template<typename PointObject>
coord_t PointListAdaptor< PointObject >::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 59 of file PointListAdaptor.h.

60  {
61  mooseAssert(idx_p2 < _size,
62  "The point index should be less than"
63  "total number of points used to build"
64  "the KDTree.");
65 
66  auto it = _begin;
67  std::advance(it, idx_p2);
68  const Point & p2 = getPoint(*it);
69 
70  coord_t dist = 0.0;
71 
72  for (unsigned int i = 0; i < LIBMESH_DIM; ++i)
73  dist += Utility::pow<2>(p1[i] - p2(i));
74 
75  return dist;
76  }
Real coord_t
libMesh Point coordinate type
const Point & getPoint(const PointObject &item) const
get a Point reference from the PointData object at index idx in the list
const Iterator _begin
begin iterator of the underlying point type vector
std::size_t _size
number of elements pointed to

◆ kdtree_get_bbox()

template<typename PointObject>
template<class BBOX >
bool PointListAdaptor< PointObject >::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 106 of file PointListAdaptor.h.

107  {
108  return false;
109  }

◆ kdtree_get_point_count()

template<typename PointObject>
size_t PointListAdaptor< PointObject >::kdtree_get_point_count ( ) const
inline

Must return the number of data points.

Definition at line 48 of file PointListAdaptor.h.

48 { return _size; }
std::size_t _size
number of elements pointed to

◆ kdtree_get_pt()

template<typename PointObject>
coord_t PointListAdaptor< PointObject >::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 PointListAdaptor.h.

85  {
86  mooseAssert(dim < (int)LIBMESH_DIM,
87  "The required component number should be less than the LIBMESH_DIM.");
88  mooseAssert(idx < _size,
89  "The index of the point should be less"
90  "than total number of points used to"
91  "construct the KDTree.");
92 
93  auto it = _begin;
94  std::advance(it, idx);
95  const Point & p = getPoint(*it);
96 
97  return p(dim);
98  }
const Point & getPoint(const PointObject &item) const
get a Point reference from the PointData object at index idx in the list
const Iterator _begin
begin iterator of the underlying point type vector
std::size_t _size
number of elements pointed to

Member Data Documentation

◆ _begin

template<typename PointObject>
const Iterator PointListAdaptor< PointObject >::_begin
private

begin iterator of the underlying point type vector

Definition at line 31 of file PointListAdaptor.h.

Referenced by PointListAdaptor< Point >::kdtree_distance(), and PointListAdaptor< Point >::kdtree_get_pt().

◆ _end

template<typename PointObject>
const Iterator PointListAdaptor< PointObject >::_end
private

end iterator of the underlying point type vector

Definition at line 34 of file PointListAdaptor.h.

◆ _size

template<typename PointObject>
std::size_t PointListAdaptor< PointObject >::_size
private

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