| 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 "atlas/interpolation/method/Method.h" |
| 11 |
|
| 12 |
#include <string> |
| 13 |
|
| 14 |
#include "eckit/config/Configuration.h" |
| 15 |
|
| 16 |
#include "atlas/array/ArrayView.h" |
| 17 |
#include "atlas/functionspace/FunctionSpace.h" |
| 18 |
#include "atlas/interpolation/method/PointIndex3.h" |
| 19 |
#include "atlas/mesh/Elements.h" |
| 20 |
|
| 21 |
namespace atlas { |
| 22 |
namespace interpolation { |
| 23 |
namespace method { |
| 24 |
|
| 25 |
class UnstructuredBilinearLonLat : public Method { |
| 26 |
public: |
| 27 |
UnstructuredBilinearLonLat(const Config& config): Method(config) { |
| 28 |
} |
| 29 |
|
| 30 |
virtual ~UnstructuredBilinearLonLat() override {} |
| 31 |
|
| 32 |
virtual void print(std::ostream&) const override; |
| 33 |
|
| 34 |
protected: |
| 35 |
/** |
| 36 |
* @brief Create an interpolant sparse matrix relating two (pre-partitioned) |
| 37 |
* meshes, |
| 38 |
* using elements as per the Finite Element Method and ray-tracing to |
| 39 |
* calculate |
| 40 |
* source mesh elements intersections (and interpolation weights) with target |
| 41 |
* grid |
| 42 |
* node-containing rays |
| 43 |
* @param meshSource mesh containing source elements |
| 44 |
* @param meshTarget mesh containing target points |
| 45 |
*/ |
| 46 |
void setup(const FunctionSpace& source); |
| 47 |
|
| 48 |
/** |
| 49 |
* Find in which element the point is contained by projecting (ray-tracing) |
| 50 |
* the |
| 51 |
* point to the nearest element(s), returning the (normalized) interpolation |
| 52 |
* weights |
| 53 |
*/ |
| 54 |
Triplets projectPointToElements(size_t ip, const ElemIndex3::NodeList& elems) const; |
| 55 |
|
| 56 |
virtual const FunctionSpace& source() const override { return source_; } |
| 57 |
virtual const FunctionSpace& target() const override { return target_; } |
| 58 |
|
| 59 |
private: |
| 60 |
using Method::do_setup; |
| 61 |
virtual void do_setup(const FunctionSpace& source, const FunctionSpace& target) override; |
| 62 |
|
| 63 |
virtual void do_setup(const Grid& source, const Grid& target, const Cache&) override; |
| 64 |
virtual void do_setup(const FunctionSpace& source, const FunctionSpace& target, const Cache&) override; |
| 65 |
|
| 66 |
protected: |
| 67 |
mesh::MultiBlockConnectivity* connectivity_; |
| 68 |
std::unique_ptr<array::ArrayView<double, 2>> ilonlat_; |
| 69 |
std::unique_ptr<array::ArrayView<double, 2>> olonlat_; |
| 70 |
std::unique_ptr<array::ArrayView<double, 2>> oxyz_; |
| 71 |
std::unique_ptr<array::ArrayView<gidx_t, 1>> igidx_; |
| 72 |
|
| 73 |
Field target_lonlat_; |
| 74 |
Field target_xyz_; |
| 75 |
Field target_ghost_; |
| 76 |
|
| 77 |
FunctionSpace source_; |
| 78 |
FunctionSpace target_; |
| 79 |
|
| 80 |
bool treat_failure_as_missing_value_{true}; |
| 81 |
}; |
| 82 |
|
| 83 |
} // namespace method |
| 84 |
} // namespace interpolation |
| 85 |
} // namespace atlas |