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

#include <kdtree.hpp>

Classes

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

Public Types

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

Public Member Functions

 KDTree ()=default
 Default constructor. More...
 
int SpaceDimension ()
 Returns the spatial dimension of the points. More...
 
iterator begin ()
 Returns iterator to beginning of the point cloud. More...
 
iterator end ()
 Returns iterator to the end of the point cloud. More...
 
size_t size ()
 Returns the size of the point cloud. More...
 
void clear ()
 Clears the point cloud. More...
 
void Sort ()
 
void AddPoint (PointND &pt, Tindex ii)
 Adds a new node to the point cloud. More...
 
void AddPoint (Tfloat *xx, Tindex ii)
 Adds a new node by coordinates and an associated index. More...
 
Tindex FindClosestPoint (PointND &pt)
 Finds the nearest neighbour index. More...
 
Tindex FindClosestPoint (PointND &pt, PointND &clp)
 Finds the nearest neighbour index and return the clossest poitn in clp. More...
 
void FindClosestPoint (PointND &pt, Tindex &ind, Tfloat &dist)
 Returns the closest point and the distance to the input point pt. More...
 
void FindClosestPoint (PointND &pt, Tindex &ind, Tfloat &dist, PointND &clp)
 Returns the closest point and the distance to the input point pt. More...
 
void FindClosestPointSlow (PointND &pt, Tindex &ind, Tfloat &dist)
 Brute force search - please, use it only for debuging purposes. More...
 
void FindNeighborPoints (PointND &pt, Tfloat R, std::vector< Tindex > &res, std::vector< Tfloat > &dist)
 
void FindNeighborPoints (PointND &pt, Tfloat R, std::vector< Tindex > &res)
 
void FindNeighborPointsSlow (PointND &pt, Tfloat R, std::vector< Tindex > &res, std::vector< Tfloat > &dist)
 Brute force search - please, use it only for debuging purposes. More...
 
void FindNeighborPointsSlow (PointND &pt, Tfloat R, std::vector< Tindex > &res)
 Brute force search - please, use it only for debuging purposes. More...
 

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 98 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 135 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 ( PointND pt,
Tindex  ii 
)
inline

Adds a new node to the point cloud.

Definition at line 169 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 ( Tfloat *  xx,
Tindex  ii 
)
inline

Adds a new node by coordinates and an associated index.

Definition at line 178 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 138 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 156 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 144 of file kdtree.hpp.

◆ FindClosestPoint() [1/4]

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

Finds the nearest neighbour index.

Definition at line 190 of file kdtree.hpp.

◆ FindClosestPoint() [2/4]

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

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

Definition at line 203 of file kdtree.hpp.

◆ FindClosestPoint() [3/4]

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

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

Definition at line 218 of file kdtree.hpp.

◆ FindClosestPoint() [4/4]

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

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

Definition at line 226 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 ( PointND pt,
Tindex &  ind,
Tfloat &  dist 
)
inline

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

Definition at line 243 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 ( 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 267 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 ( 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 275 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 ( 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 281 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 ( PointND pt,
Tfloat  R,
std::vector< Tindex > &  res 
)
inline

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

Definition at line 297 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 ( )
inline

Returns the size of the point cloud.

Definition at line 150 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 ( )
inline

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

Definition at line 163 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 ( )
inline

Returns the spatial dimension of the points.

Definition at line 129 of file kdtree.hpp.


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