Debian Codegraph @

src/atlas/interpolation/method/cubedsphere/CellFinder.h

raw
1 /*
2 * (C) Crown Copyright 2022 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 <array>
11
12 #include "atlas/interpolation/method/Intersect.h"
13 #include "atlas/mesh/Mesh.h"
14 #include "atlas/util/Config.h"
15 #include "atlas/util/Geometry.h"
16 #include "atlas/util/KDTree.h"
17 #include "atlas/util/Point.h"
18
19
20 namespace atlas {
21 namespace projection {
22 namespace detail {
23 class CubedSphereProjectionBase;
24 } // namespace detail
25 } // namespace projection
26 } // namespace atlas
27
28
29 namespace atlas {
30 namespace interpolation {
31 namespace method {
32 namespace cubedsphere {
33
34 using namespace util;
35
36 /// @brief class to find points within cells of cubedsphere mesh.
37 class CellFinder {
38 public:
39 struct Cell {
40 idx_t idx;
41 std::vector<idx_t> nodes;
42 Intersect isect;
43 };
44
45 /// @brief Constructor.
46 CellFinder(const Mesh& mesh, const util::Config& config = util::Config("halo", 0));
47
48 /// @brief Find a cell which encompasses an xy point.
49 Cell getCell(const PointXY& xy, size_t listSize = 4,
50 double edgeEpsilon = 5. * std::numeric_limits<double>::epsilon(),
51 double epsilon = 5. * std::numeric_limits<double>::epsilon()) const;
52
53 /// @brief Find a cell which encompasses a lonlat point.
54 Cell getCell(const PointLonLat& lonlat, size_t listSize = 4,
55 double edgeEpsilon = 5. * std::numeric_limits<double>::epsilon(),
56 double epsilon = 5. * std::numeric_limits<double>::epsilon()) const;
57
58
59 private:
60 Mesh mesh_{};
61 const projection::detail::CubedSphereProjectionBase* projection_{};
62 util::IndexKDTree tree_{Geometry{}};
63 };
64
65 } // namespace cubedsphere
66 } // namespace method
67 } // namespace interpolation
68 } // namespace atlas