Debian Codegraph @

src/atlas/trans/Trans.h

raw
1 /*
2 * (C) Copyright 2013 ECMWF.
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 * In applying this licence, ECMWF does not waive the privileges and immunities
7 * granted to it by virtue of its status as an intergovernmental organisation
8 * nor does it submit to any jurisdiction.
9 */
10
11 #pragma once
12
13 #include <iosfwd>
14
15 #include "atlas/library/config.h"
16 #include "atlas/trans/Cache.h"
17 #include "atlas/util/Config.h"
18 #include "atlas/util/ObjectHandle.h"
19
20 //-----------------------------------------------------------------------------
21 // Forward declarations
22
23 namespace atlas {
24 class Field;
25 class FieldSet;
26 class FunctionSpace;
27 class Grid;
28 class Domain;
29 namespace functionspace {
30 class Spectral;
31 }
32 } // namespace atlas
33
34 //-----------------------------------------------------------------------------
35
36 namespace atlas {
37 namespace trans {
38
39 //----------------------------------------------------------------------------------------------------------------------
40
41 class TransImpl;
42 class Trans : DOXYGEN_HIDE(public util::ObjectHandle<TransImpl>) {
43 public:
44 static void listBackends(std::ostream&);
45 static bool hasBackend(const std::string&);
46 static void backend(const std::string&);
47 static std::string backend();
48 static void config(const eckit::Configuration&);
49 static const eckit::Configuration& config();
50
51 using Handle::Handle;
52 Trans() = default;
53
54 Trans(const FunctionSpace& gp, const FunctionSpace& sp, const eckit::Configuration& = util::NoConfig());
55 Trans(const Grid&, int truncation, const eckit::Configuration& = util::NoConfig());
56 Trans(const Grid&, const Domain&, int truncation, const eckit::Configuration& = util::NoConfig());
57
58 Trans(const Cache&, const FunctionSpace& gp, const FunctionSpace& sp,
59 const eckit::Configuration& = util::NoConfig());
60 Trans(const Cache&, const Grid&, int truncation, const eckit::Configuration& = util::NoConfig());
61 Trans(const Cache&, const Grid&, const Domain&, int truncation, const eckit::Configuration& = util::NoConfig());
62
63 void hash(eckit::Hash&) const;
64
65 int truncation() const;
66 size_t spectralCoefficients() const;
67 const Grid& grid() const;
68 const functionspace::Spectral& spectral() const;
69
70 void dirtrans(const Field& gpfield, Field& spfield, const eckit::Configuration& = util::NoConfig()) const;
71
72 void dirtrans(const FieldSet& gpfields, FieldSet& spfields, const eckit::Configuration& = util::NoConfig()) const;
73
74 void dirtrans_wind2vordiv(const Field& gpwind, Field& spvor, Field& spdiv,
75 const eckit::Configuration& = util::NoConfig()) const;
76
77 void dirtrans_adj(const Field& spfield, Field& gpfield, const eckit::Configuration& = util::NoConfig()) const;
78
79 void dirtrans_adj(const FieldSet& spfields, FieldSet& gpfields, const eckit::Configuration& = util::NoConfig()) const;
80
81 void dirtrans_wind2vordiv_adj(const Field& spvor, const Field& spdiv, Field& gpwind,
82 const eckit::Configuration& = util::NoConfig()) const;
83
84 void invtrans(const Field& spfield, Field& gpfield, const eckit::Configuration& = util::NoConfig()) const;
85
86 void invtrans(const FieldSet& spfields, FieldSet& gpfields, const eckit::Configuration& = util::NoConfig()) const;
87
88 void invtrans_grad(const Field& spfield, Field& gradfield, const eckit::Configuration& = util::NoConfig()) const;
89
90 void invtrans_grad(const FieldSet& spfields, FieldSet& gradfields,
91 const eckit::Configuration& = util::NoConfig()) const;
92
93 void invtrans_vordiv2wind(const Field& spvor, const Field& spdiv, Field& gpwind,
94 const eckit::Configuration& = util::NoConfig()) const;
95
96 void invtrans_adj(const Field& gpfield, Field& spfield, const eckit::Configuration& = util::NoConfig()) const;
97
98 void invtrans_adj(const FieldSet& gpfields, FieldSet& spfields,
99 const eckit::Configuration& = util::NoConfig()) const;
100
101 void invtrans_grad_adj(const Field& gradfield, Field& spfield,
102 const eckit::Configuration& = util::NoConfig()) const;
103
104 void invtrans_grad_adj(const FieldSet& gradfields, FieldSet& spfields,
105 const eckit::Configuration& = util::NoConfig()) const;
106
107 void invtrans_vordiv2wind_adj(const Field& gpwind, Field& spvor, Field& spdiv,
108 const eckit::Configuration& = util::NoConfig()) const;
109
110 // -- IFS type fields --
111 // These fields have special interpretation required. You need to know what
112 // you're doing.
113 // See IFS trans library.
114
115 /*!
116 * @brief invtrans
117 * @param nb_scalar_fields
118 * @param scalar_spectra
119 * @param nb_vordiv_fields
120 * @param vorticity_spectra
121 * @param divergence_spectra
122 * @param gp_fields
123 */
124 void invtrans(const int nb_scalar_fields, const double scalar_spectra[], const int nb_vordiv_fields,
125 const double vorticity_spectra[], const double divergence_spectra[], double gp_fields[],
126 const eckit::Configuration& = util::NoConfig()) const;
127
128 /*!
129 * @brief invtrans
130 * @param nb_fields
131 * @param scalar_spectra
132 * @param scalar_fields
133 */
134 void invtrans(const int nb_scalar_fields, const double scalar_spectra[], double gp_fields[],
135 const eckit::Configuration& = util::NoConfig()) const;
136
137 /*!
138 * @brief Inverse transform of vorticity/divergence to wind(U/V)
139 * @param nb_fields [in] Number of fields ( both components of wind count as 1
140 * )
141 */
142 void invtrans(const int nb_vordiv_fields, const double vorticity_spectra[], const double divergence_spectra[],
143 double gp_fields[], const eckit::Configuration& = util::NoConfig()) const;
144
145
146 /*!
147 * @brief invtrans_adj
148 * @param nb_scalar_fields
149 * @param scalar_spectra
150 * @param nb_vordiv_fields
151 * @param vorticity_spectra
152 * @param divergence_spectra
153 * @param gp_fields
154 */
155 void invtrans_adj(const int nb_scalar_fields, const double gp_fields[], const int nb_vordiv_fields,
156 double vorticity_spectra[], double divergence_spectra[], double scalar_spectra[],
157 const eckit::Configuration& = util::NoConfig()) const;
158
159 /*!
160 * @brief invtrans_adj
161 * @param nb_fields
162 * @param scalar_spectra
163 * @param scalar_fields
164 */
165 void invtrans_adj(const int nb_scalar_fields, const double gp_fields[], double scalar_spectra[],
166 const eckit::Configuration& = util::NoConfig()) const;
167
168 /*!
169 * @brief Adjoint of Inverse transform of vorticity/divergence to wind(U/V)
170 * @param nb_fields [in] Number of fields ( both components of wind count as 1
171 * )
172 */
173 void invtrans_adj(const int nb_vordiv_fields, const double gp_fields[], double vorticity_spectra[],
174 double divergence_spectra[], const eckit::Configuration& = util::NoConfig()) const;
175
176 /*!
177 * @brief Direct transform of scalar fields
178 */
179 void dirtrans(const int nb_fields, const double scalar_fields[], double scalar_spectra[],
180 const eckit::Configuration& = util::NoConfig()) const;
181
182 /*!
183 * @brief Direct transform of wind(U/V) to vorticity/divergence
184 * @param nb_fields [in] Number of fields ( both components of wind count as 1
185 * )
186 */
187 void dirtrans(const int nb_fields, const double wind_fields[], double vorticity_spectra[],
188 double divergence_spectra[], const eckit::Configuration& = util::NoConfig()) const;
189 };
190
191 //----------------------------------------------------------------------------------------------------------------------
192
193 } // namespace trans
194 } // namespace atlas