| 1 |
/* |
| 2 |
* (C) Crown Copyright 2021 Met Office |
| 3 |
* |
| 4 |
* This software is licensed under the terms of the Apache Licence Version 2.0 |
| 5 |
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. |
| 6 |
*/ |
| 7 |
|
| 8 |
#pragma once |
| 9 |
|
| 10 |
#include "eckit/container/KDMapped.h" |
| 11 |
#include "eckit/container/KDMemory.h" |
| 12 |
#include "eckit/container/KDTree.h" |
| 13 |
#include "eckit/geometry/Point2.h" |
| 14 |
|
| 15 |
#include "atlas/field/Field.h" |
| 16 |
#include "atlas/mesh/Mesh.h" |
| 17 |
#include "atlas/util/CoordinateEnums.h" |
| 18 |
|
| 19 |
namespace atlas { |
| 20 |
namespace interpolation { |
| 21 |
namespace method { |
| 22 |
|
| 23 |
//---------------------------------------------------------------------------------------------------------------------- |
| 24 |
|
| 25 |
template <class Traits> |
| 26 |
class Point2KdTree : public eckit::KDTreeMemory<Traits> { |
| 27 |
public: |
| 28 |
typedef eckit::KDTreeMemory<Traits> Tree; |
| 29 |
|
| 30 |
typedef typename Tree::Alloc Alloc; |
| 31 |
typedef typename Tree::NodeInfo NodeInfo; |
| 32 |
typedef typename Tree::NodeList NodeList; |
| 33 |
typedef typename Tree::PayloadType Payload; |
| 34 |
typedef typename Tree::Point Point; |
| 35 |
typedef typename Tree::Value Value; |
| 36 |
|
| 37 |
Point2KdTree(): eckit::KDTreeMemory<Traits>() {} |
| 38 |
Point2KdTree(Alloc& alloc): Tree(alloc) {} |
| 39 |
|
| 40 |
using Tree::findInSphere; |
| 41 |
using Tree::kNearestNeighbours; |
| 42 |
using Tree::nearestNeighbour; |
| 43 |
|
| 44 |
using Tree::findInSphereBruteForce; |
| 45 |
using Tree::kNearestNeighboursBruteForce; |
| 46 |
using Tree::nearestNeighbourBruteForce; |
| 47 |
}; |
| 48 |
|
| 49 |
//---------------------------------------------------------------------------------------------------------------------- |
| 50 |
|
| 51 |
struct PointIndex2TreeTrait { |
| 52 |
typedef eckit::geometry::Point2 Point; |
| 53 |
typedef size_t Payload; |
| 54 |
}; |
| 55 |
|
| 56 |
typedef Point2KdTree<PointIndex2TreeTrait> PointIndex2; |
| 57 |
|
| 58 |
//---------------------------------------------------------------------------------------------------------------------- |
| 59 |
|
| 60 |
struct ElemIndex2TreeTrait { |
| 61 |
typedef eckit::geometry::Point2 Point; |
| 62 |
typedef size_t Payload; |
| 63 |
}; |
| 64 |
|
| 65 |
typedef Point2KdTree<ElemIndex2TreeTrait> ElemIndex2; |
| 66 |
|
| 67 |
ElemIndex2* create_element2D_kdtree(const Mesh& mesh, const Field& field_centres); |
| 68 |
|
| 69 |
//---------------------------------------------------------------------------------------------------------------------- |
| 70 |
|
| 71 |
} // namespace method |
| 72 |
} // namespace interpolation |
| 73 |
} // namespace atlas |