A class used to to perform kd-tree based operations. More...
#include <kdtree.h>
Public Member Functions | |
| void | add (const double *x) |
| Add a point. | |
| std::vector< double > | box () const |
| Function to return the bounding box for the tree. | |
| AMP::Mesh::MeshPoint< double > | find_nearest (const AMP::Mesh::MeshPoint< double > &p) const |
| Search the tree for the nearest neighbor point. | |
| size_t | find_nearest (const double *x, double *dist=nullptr, double *pos=nullptr) const |
| Search the tree for the nearest neighbor point. | |
| void | find_nearest (int N, const double *x, size_t *index, double *dist=nullptr, double *pos=nullptr) const |
| Search the tree for the nearest neighbor point. | |
| size_t | find_nearest2d (const double x, const double y) const |
| Search the tree for the nearest neighbor point. | |
| size_t | find_nearest3d (const double x, const double y, const double z) const |
| Search the tree for the nearest neighbor point. | |
| kdtree () | |
| kdtree (const kdtree &)=delete | |
| Copy constructor. | |
| kdtree (const std::vector< AMP::Mesh::MeshPoint< double > > &x) | |
| Default constructor. | |
| kdtree (int ndim, size_t N, const double *const *x) | |
| Default constructor. | |
| kdtree (kdtree &&) | |
| Move constructor. | |
| kdtree & | operator= (const kdtree &)=delete |
| Assignment operator. | |
| kdtree & | operator= (kdtree &&) |
| Move operator. | |
| ~kdtree () | |
| Destructor. | |
Static Public Member Functions | |
| static std::shared_ptr< kdtree > | create2d (size_t N, const double *x, const double *y) |
| Constructor for 2d. | |
| static std::shared_ptr< kdtree > | create3d (size_t N, const double *x, const double *y, const double *z) |
| Constructor for 3d. | |
Private Member Functions | |
| size_t | find_nearest2 (const double *x, double &dist, double *pos) const |
Private Attributes | |
| uint8_t | d_dim |
| size_t | d_N |
| void * | d_tree |
A class used to to perform kd-tree based operations.
This class provides routines for creating and search a kd-tree. The kdtree allows for log(N) nearest neighbor search. The memory requirements for this class are O(N) on the number of points. The search performance for small dimension data is O(log(N)). For high dimension data, the number of points should be N >> 2^d where d is the dimension. Otherwise the performance will degrade approaching O(N).
| AMP::kdtree::kdtree | ( | int | ndim, |
| size_t | N, | ||
| const double *const * | x | ||
| ) |
Default constructor.
This is the default constructor for creating the kdtree
| [in] | ndim | The number of physical dimensions |
| [in] | N | The number of points in the tree |
| [in] | x | The coordinates of each point in the tree (x[ndim][N]) |
| AMP::kdtree::kdtree | ( | const std::vector< AMP::Mesh::MeshPoint< double > > & | x | ) |
Default constructor.
This an alternative constructor for creating the kdtree
| [in] | x | The coordinates of each point in the tree |
| AMP::kdtree::~kdtree | ( | ) |
Destructor.
|
delete |
Copy constructor.
| AMP::kdtree::kdtree | ( | kdtree && | ) |
Move constructor.
| void AMP::kdtree::add | ( | const double * | x | ) |
Add a point.
This will add a point to the kdtree. Note that no rebalancing will be performed
| [in] | x | The coordinates of the point |
| std::vector< double > AMP::kdtree::box | ( | ) | const |
Function to return the bounding box for the tree.
|
static |
Constructor for 2d.
This will create a kdtree in 2d space
| [in] | N | The number of points in the tree |
| [in] | x | The x coordinates of each point |
| [in] | y | The x coordinates of each point |
|
static |
Constructor for 3d.
This will create a kdtree in 3d space
| [in] | N | The number of points in the tree |
| [in] | x | The x coordinates of each point |
| [in] | y | The y coordinates of each point |
| [in] | z | The z coordinates of each point |
| AMP::Mesh::MeshPoint< double > AMP::kdtree::find_nearest | ( | const AMP::Mesh::MeshPoint< double > & | p | ) | const |
Search the tree for the nearest neighbor point.
This will return the index of the nearest neighbor in the tree
| [in] | p | The point to search |
| size_t AMP::kdtree::find_nearest | ( | const double * | x, |
| double * | dist = nullptr, |
||
| double * | pos = nullptr |
||
| ) | const |
Search the tree for the nearest neighbor point.
This will return the index of the nearest neighbor in the tree
| [in] | x | The coordinates of the point to search (NDIM) |
| [out] | dist | Optional output array for the distance to the nearest neighbor (1) |
| [out] | pos | Optional output array for the position of the nearest neighbor (NDIM) |
| void AMP::kdtree::find_nearest | ( | int | N, |
| const double * | x, | ||
| size_t * | index, | ||
| double * | dist = nullptr, |
||
| double * | pos = nullptr |
||
| ) | const |
Search the tree for the nearest neighbor point.
This will return the index of the nearest neighbor in the tree for each point
| [in] | N | The number of points we want to search |
| [in] | x | The coordinates of the points to search ( NDIM x N ) |
| [out] | index | The index of the nearest neighbors (N) |
| [out] | dist | Optional output array for the distance to the nearest neighbor (N) |
| [out] | pos | Optional output array for the position of the nearest neighbor (NDIMxN) |
|
private |
| size_t AMP::kdtree::find_nearest2d | ( | const double | x, |
| const double | y | ||
| ) | const |
Search the tree for the nearest neighbor point.
This will return the index of the nearest neighbor in the tree
| [in] | x | The x coordinate of the search point |
| [in] | y | The y coordinate of the search point |
| size_t AMP::kdtree::find_nearest3d | ( | const double | x, |
| const double | y, | ||
| const double | z | ||
| ) | const |
Search the tree for the nearest neighbor point.
This will return the index of the nearest neighbor in the tree
| [in] | x | The x coordinate of the search point |
| [in] | y | The y coordinate of the search point |
| [in] | z | The z coordinate of the search point |
|
Advanced Multi-Physics (AMP) Oak Ridge National Laboratory Idaho National Laboratory Los Alamos National Laboratory |
This page automatically produced from the source code by Last updated: Tue Mar 10 2026 13:06:42. Comments on this page |