MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
mfem::KDTree< Tindex, Tfloat, ndim, Tnorm > Class Template Reference

#include <kdtree.hpp>

Inheritance diagram for mfem::KDTree< Tindex, Tfloat, ndim, Tnorm >:
[legend]
Collaboration diagram for mfem::KDTree< Tindex, Tfloat, ndim, Tnorm >:
[legend]

Classes

struct  NodeND
 Structure defining a node in the KDTree. More...
 
struct  PointND
 

Public Types

typedef std::vector< NodeND >::iterator iterator
 Data iterator.
 

Public Member Functions

 KDTree ()=default
 Default constructor.
 
int SpaceDimension () const
 Returns the spatial dimension of the points.
 
iterator begin ()
 Returns iterator to beginning of the point cloud.
 
iterator end ()
 Returns iterator to the end of the point cloud.
 
size_t size () const
 Returns the size of the point cloud.
 
void clear ()
 Clears the point cloud.
 
void Sort () override
 
void AddPoint (const PointND &pt, Tindex ii)
 Adds a new node to the point cloud.
 
void AddPoint (const Tfloat *xx, Tindex ii) override
 Adds a new node by coordinates and an associated index.
 
Tindex FindClosestPoint (const PointND &pt) const
 Finds the nearest neighbour index.
 
Tindex FindClosestPoint (const Tfloat *xx) const override
 Returns the index of the closest point to xx.
 
Tindex FindClosestPoint (const PointND &pt, const PointND &clp) const
 Finds the nearest neighbour index and return the clossest point in clp.
 
void FindClosestPoint (const PointND &pt, Tindex &ind, Tfloat &dist) const
 Returns the closest point and the distance to the input point pt.
 
void FindClosestPoint (const PointND &pt, Tindex &ind, Tfloat &dist, PointND &clp) const
 Returns the closest point and the distance to the input point pt.
 
void FindClosestPointSlow (const PointND &pt, Tindex &ind, Tfloat &dist) const
 Brute force search - please, use it only for debuging purposes.
 
void FindNeighborPoints (const PointND &pt, Tfloat R, std::vector< Tindex > &res, std::vector< Tfloat > &dist)
 
void FindNeighborPoints (const PointND &pt, Tfloat R, std::vector< Tindex > &res)
 
void FindNeighborPointsSlow (const PointND &pt, Tfloat R, std::vector< Tindex > &res, std::vector< Tfloat > &dist)
 Brute force search - please, use it only for debuging purposes.
 
void FindNeighborPointsSlow (const PointND &pt, Tfloat R, std::vector< Tindex > &res)
 Brute force search - please, use it only for debuging purposes.
 
- Public Member Functions inherited from mfem::KDTreeBase< Tindex, Tfloat >
virtual void AddPoint (const Tfloat *xx, Tindex ii)=0
 Adds a point to the tree. See KDTree::AddPoint().
 
virtual void Sort ()=0
 Sorts the tree. Should be performed after adding points and before performing queries. See KDTree::Sort().
 
virtual Tindex FindClosestPoint (const Tfloat *xx) const =0
 Returns the index of the closest point to xx.
 
virtual ~KDTreeBase ()
 Virtual destructor.
 

Detailed Description

template<typename Tindex, typename Tfloat, size_t ndim = 3, typename Tnorm = KDTreeNorms::Norm_l2<Tfloat,ndim>>
class mfem::KDTree< Tindex, Tfloat, ndim, Tnorm >

Template class for build KDTree with template parameters Tindex specifying the type utilized for indexing the points, Tfloat specifying a float type for representing the coordinates of the points, integer parameter ndim specifying the dimensionality of the space and template function Tnorm for evaluating the distance between two points. The KDTree class implements the standard k-d tree data structure that can be used to transfer a ParGridFunction defined on one MPI communicator to a ParGridFunction/GridFunction defined on different MPI communicator. This can be useful when comparing a solution computed on m ranks against a solution computed with n or 1 rank(s).

Definition at line 118 of file kdtree.hpp.

Member Typedef Documentation

◆ iterator

template<typename Tindex , typename Tfloat , size_t ndim = 3, typename Tnorm = KDTreeNorms::Norm_l2<Tfloat,ndim>>
typedef std::vector<NodeND>::iterator mfem::KDTree< Tindex, Tfloat, ndim, Tnorm >::iterator

Data iterator.

Definition at line 159 of file kdtree.hpp.

Constructor & Destructor Documentation

◆ KDTree()

template<typename Tindex , typename Tfloat , size_t ndim = 3, typename Tnorm = KDTreeNorms::Norm_l2<Tfloat,ndim>>
mfem::KDTree< Tindex, Tfloat, ndim, Tnorm >::KDTree ( )
default

Default constructor.

Member Function Documentation

◆ AddPoint() [1/2]

template<typename Tindex , typename Tfloat , size_t ndim = 3, typename Tnorm = KDTreeNorms::Norm_l2<Tfloat,ndim>>
void mfem::KDTree< Tindex, Tfloat, ndim, Tnorm >::AddPoint ( const PointND pt,
Tindex  ii 
)
inline

Adds a new node to the point cloud.

Definition at line 193 of file kdtree.hpp.

◆ AddPoint() [2/2]

template<typename Tindex , typename Tfloat , size_t ndim = 3, typename Tnorm = KDTreeNorms::Norm_l2<Tfloat,ndim>>
void mfem::KDTree< Tindex, Tfloat, ndim, Tnorm >::AddPoint ( const Tfloat *  xx,
Tindex  ii 
)
inlineoverridevirtual

Adds a new node by coordinates and an associated index.

Implements mfem::KDTreeBase< Tindex, Tfloat >.

Definition at line 199 of file kdtree.hpp.

◆ begin()

template<typename Tindex , typename Tfloat , size_t ndim = 3, typename Tnorm = KDTreeNorms::Norm_l2<Tfloat,ndim>>
iterator mfem::KDTree< Tindex, Tfloat, ndim, Tnorm >::begin ( )
inline

Returns iterator to beginning of the point cloud.

Definition at line 162 of file kdtree.hpp.

◆ clear()

template<typename Tindex , typename Tfloat , size_t ndim = 3, typename Tnorm = KDTreeNorms::Norm_l2<Tfloat,ndim>>
void mfem::KDTree< Tindex, Tfloat, ndim, Tnorm >::clear ( )
inline

Clears the point cloud.

Definition at line 180 of file kdtree.hpp.

◆ end()

template<typename Tindex , typename Tfloat , size_t ndim = 3, typename Tnorm = KDTreeNorms::Norm_l2<Tfloat,ndim>>
iterator mfem::KDTree< Tindex, Tfloat, ndim, Tnorm >::end ( )
inline

Returns iterator to the end of the point cloud.

Definition at line 168 of file kdtree.hpp.

◆ FindClosestPoint() [1/5]

template<typename Tindex , typename Tfloat , size_t ndim = 3, typename Tnorm = KDTreeNorms::Norm_l2<Tfloat,ndim>>
Tindex mfem::KDTree< Tindex, Tfloat, ndim, Tnorm >::FindClosestPoint ( const PointND pt) const
inline

Finds the nearest neighbour index.

Definition at line 205 of file kdtree.hpp.

◆ FindClosestPoint() [2/5]

template<typename Tindex , typename Tfloat , size_t ndim = 3, typename Tnorm = KDTreeNorms::Norm_l2<Tfloat,ndim>>
Tindex mfem::KDTree< Tindex, Tfloat, ndim, Tnorm >::FindClosestPoint ( const PointND pt,
const PointND clp 
) const
inline

Finds the nearest neighbour index and return the clossest point in clp.

Definition at line 223 of file kdtree.hpp.

◆ FindClosestPoint() [3/5]

template<typename Tindex , typename Tfloat , size_t ndim = 3, typename Tnorm = KDTreeNorms::Norm_l2<Tfloat,ndim>>
void mfem::KDTree< Tindex, Tfloat, ndim, Tnorm >::FindClosestPoint ( const PointND pt,
Tindex &  ind,
Tfloat &  dist 
) const
inline

Returns the closest point and the distance to the input point pt.

Definition at line 238 of file kdtree.hpp.

◆ FindClosestPoint() [4/5]

template<typename Tindex , typename Tfloat , size_t ndim = 3, typename Tnorm = KDTreeNorms::Norm_l2<Tfloat,ndim>>
void mfem::KDTree< Tindex, Tfloat, ndim, Tnorm >::FindClosestPoint ( const PointND pt,
Tindex &  ind,
Tfloat &  dist,
PointND clp 
) const
inline

Returns the closest point and the distance to the input point pt.

Definition at line 245 of file kdtree.hpp.

◆ FindClosestPoint() [5/5]

template<typename Tindex , typename Tfloat , size_t ndim = 3, typename Tnorm = KDTreeNorms::Norm_l2<Tfloat,ndim>>
Tindex mfem::KDTree< Tindex, Tfloat, ndim, Tnorm >::FindClosestPoint ( const Tfloat *  xx) const
inlineoverridevirtual

Returns the index of the closest point to xx.

Implements mfem::KDTreeBase< Tindex, Tfloat >.

Definition at line 217 of file kdtree.hpp.

◆ FindClosestPointSlow()

template<typename Tindex , typename Tfloat , size_t ndim = 3, typename Tnorm = KDTreeNorms::Norm_l2<Tfloat,ndim>>
void mfem::KDTree< Tindex, Tfloat, ndim, Tnorm >::FindClosestPointSlow ( const PointND pt,
Tindex &  ind,
Tfloat &  dist 
) const
inline

Brute force search - please, use it only for debuging purposes.

Definition at line 263 of file kdtree.hpp.

◆ FindNeighborPoints() [1/2]

template<typename Tindex , typename Tfloat , size_t ndim = 3, typename Tnorm = KDTreeNorms::Norm_l2<Tfloat,ndim>>
void mfem::KDTree< Tindex, Tfloat, ndim, Tnorm >::FindNeighborPoints ( const PointND pt,
Tfloat  R,
std::vector< Tindex > &  res 
)
inline

Finds all points within a distance R from point pt. The indices are returned in the vector res and the correponding distances in vector dist.

Definition at line 295 of file kdtree.hpp.

◆ FindNeighborPoints() [2/2]

template<typename Tindex , typename Tfloat , size_t ndim = 3, typename Tnorm = KDTreeNorms::Norm_l2<Tfloat,ndim>>
void mfem::KDTree< Tindex, Tfloat, ndim, Tnorm >::FindNeighborPoints ( const PointND pt,
Tfloat  R,
std::vector< Tindex > &  res,
std::vector< Tfloat > &  dist 
)
inline

Finds all points within a distance R from point pt. The indices are returned in the vector res and the correponding distances in vector dist.

Definition at line 287 of file kdtree.hpp.

◆ FindNeighborPointsSlow() [1/2]

template<typename Tindex , typename Tfloat , size_t ndim = 3, typename Tnorm = KDTreeNorms::Norm_l2<Tfloat,ndim>>
void mfem::KDTree< Tindex, Tfloat, ndim, Tnorm >::FindNeighborPointsSlow ( const PointND pt,
Tfloat  R,
std::vector< Tindex > &  res 
)
inline

Brute force search - please, use it only for debuging purposes.

Definition at line 318 of file kdtree.hpp.

◆ FindNeighborPointsSlow() [2/2]

template<typename Tindex , typename Tfloat , size_t ndim = 3, typename Tnorm = KDTreeNorms::Norm_l2<Tfloat,ndim>>
void mfem::KDTree< Tindex, Tfloat, ndim, Tnorm >::FindNeighborPointsSlow ( const PointND pt,
Tfloat  R,
std::vector< Tindex > &  res,
std::vector< Tfloat > &  dist 
)
inline

Brute force search - please, use it only for debuging purposes.

Definition at line 301 of file kdtree.hpp.

◆ size()

template<typename Tindex , typename Tfloat , size_t ndim = 3, typename Tnorm = KDTreeNorms::Norm_l2<Tfloat,ndim>>
size_t mfem::KDTree< Tindex, Tfloat, ndim, Tnorm >::size ( ) const
inline

Returns the size of the point cloud.

Definition at line 174 of file kdtree.hpp.

◆ Sort()

template<typename Tindex , typename Tfloat , size_t ndim = 3, typename Tnorm = KDTreeNorms::Norm_l2<Tfloat,ndim>>
void mfem::KDTree< Tindex, Tfloat, ndim, Tnorm >::Sort ( )
inlineoverridevirtual

Builds the KDTree. If the point cloud is modified the tree needs to be rebuild by a new call to Sort().

Implements mfem::KDTreeBase< Tindex, Tfloat >.

Definition at line 187 of file kdtree.hpp.

◆ SpaceDimension()

template<typename Tindex , typename Tfloat , size_t ndim = 3, typename Tnorm = KDTreeNorms::Norm_l2<Tfloat,ndim>>
int mfem::KDTree< Tindex, Tfloat, ndim, Tnorm >::SpaceDimension ( ) const
inline

Returns the spatial dimension of the points.

Definition at line 153 of file kdtree.hpp.


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