Debian Codegraph @

src/atlas/interpolation/method/sphericalvector/SphericalVector.h

raw
1 /*
2 * (C) Crown Copyright 2024 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/functionspace/FunctionSpace.h"
11 #include "atlas/interpolation/method/Method.h"
12 #include "atlas/interpolation/method/sphericalvector/Types.h"
13
14 namespace atlas {
15 namespace interpolation {
16 namespace method {
17
18 class SphericalVector : public Method {
19 public:
20 /// @brief Interpolation post-processor for vector field interpolation
21 ///
22 /// @details Takes a base interpolation config keyed to "scheme" and creates
23 /// A set of complex intepolation weights which rotate source vector
24 /// elements into the target elements' individual frame of reference.
25 /// Method works by creating a great-circle arc between the source
26 /// and target locations; the amount of rotation is determined by the
27 /// difference the in the great-cricle course (relative to north) at
28 /// the source and target location.
29 /// Both source and target fields require the "type" metadata to be
30 /// set to "vector" for this method to be invoked. Otherwise, the
31 /// base scalar interpolation method is invoked.
32 /// Note: This method only works with matrix-based interpolation
33 /// schemes.
34 ///
35 SphericalVector(const Config& config);
36 ~SphericalVector() override {}
37
38 void print(std::ostream&) const override;
39 const FunctionSpace& source() const override { return source_; }
40 const FunctionSpace& target() const override { return target_; }
41
42 void do_execute(const FieldSet& sourceFieldSet, FieldSet& targetFieldSet,
43 Metadata& metadata) const override;
44 void do_execute(const Field& sourceField, Field& targetField,
45 Metadata& metadata) const override;
46
47 void do_execute_adjoint(FieldSet& sourceFieldSet,
48 const FieldSet& targetFieldSet,
49 Metadata& metadata) const override;
50 void do_execute_adjoint(Field& sourceField, const Field& targetField,
51 Metadata& metadata) const override;
52
53 private:
54 template <typename MatMul>
55 static void interpolate_vector_field(const Field& sourceField,
56 Field& targetField,
57 const MatMul& matMul);
58
59 template <typename Value, typename MatMul>
60 static void interpolate_vector_field(const Field& sourceField,
61 Field& targetField,
62 const MatMul& matMul);
63
64 template <typename Value, int Rank, typename MatMul>
65 static void interpolate_vector_field(const Field& sourceField,
66 Field& targetField,
67 const MatMul& matMul);
68
69 using Method::do_setup;
70 void do_setup(const FunctionSpace& source,
71 const FunctionSpace& target) override;
72 void do_setup(const Grid& source, const Grid& target, const Cache&) override;
73 void do_setup(const FunctionSpace& source, const FunctionSpace& target, const Cache&) override;
74
75 eckit::LocalConfiguration interpolationScheme_{};
76
77 FunctionSpace source_{};
78 FunctionSpace target_{};
79
80 detail::ComplexMatrix complexWeights_{};
81 detail::RealMatrix realWeights_{};
82 detail::ComplexMatrix complexWeightsAdjoint_{};
83 detail::RealMatrix realWeightsAdjoint_{};
84 bool adjoint_;
85 };
86
87 } // namespace method
88 } // namespace interpolation
89 } // namespace atlas