| 1 |
/* |
| 2 |
* (C) Copyright 2024 Meteorologisk Institutt |
| 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 <vector> |
| 13 |
|
| 14 |
#include "atlas/field.h" |
| 15 |
#include "atlas/functionspace.h" |
| 16 |
#include "atlas/grid/Grid.h" |
| 17 |
|
| 18 |
#include "eckit/config/Configuration.h" |
| 19 |
#include "eckit/mpi/Comm.h" |
| 20 |
|
| 21 |
namespace atlas { |
| 22 |
namespace interpolation { |
| 23 |
namespace method { |
| 24 |
|
| 25 |
|
| 26 |
class RegionalLinear2D : public Method { |
| 27 |
public: |
| 28 |
/// @brief Regional linear interpolation |
| 29 |
/// |
| 30 |
/// @details |
| 31 |
/// |
| 32 |
RegionalLinear2D(const Config& config) : Method(config), comm_(eckit::mpi::comm()) {} |
| 33 |
~RegionalLinear2D() override {} |
| 34 |
|
| 35 |
void print(std::ostream&) const override; |
| 36 |
const FunctionSpace& source() const override { return source_; } |
| 37 |
const FunctionSpace& target() const override { return target_; } |
| 38 |
|
| 39 |
void do_execute(const FieldSet& sourceFieldSet, FieldSet& targetFieldSet, |
| 40 |
Metadata& metadata) const override; |
| 41 |
void do_execute(const Field& sourceField, Field& targetField, |
| 42 |
Metadata& metadata) const override; |
| 43 |
|
| 44 |
void do_execute_adjoint(FieldSet& sourceFieldSet, |
| 45 |
const FieldSet& targetFieldSet, |
| 46 |
Metadata& metadata) const override; |
| 47 |
void do_execute_adjoint(Field& sourceField, const Field& targetField, |
| 48 |
Metadata& metadata) const override; |
| 49 |
|
| 50 |
private: |
| 51 |
using Method::do_setup; |
| 52 |
void do_setup(const FunctionSpace& source, const FunctionSpace& target) override; |
| 53 |
void do_setup(const Grid& source, const Grid& target, const Cache&) override; |
| 54 |
void do_setup(const FunctionSpace& source, const FunctionSpace& target, const Cache&) override; |
| 55 |
|
| 56 |
FunctionSpace source_{}; |
| 57 |
FunctionSpace target_{}; |
| 58 |
|
| 59 |
const eckit::mpi::Comm & comm_; |
| 60 |
size_t sourceSize_; |
| 61 |
std::vector<int> mpiTask_; |
| 62 |
size_t targetSize_; |
| 63 |
size_t sourceSendSize_; |
| 64 |
size_t targetRecvSize_; |
| 65 |
std::vector<int> sourceSendCounts_; |
| 66 |
std::vector<int> sourceSendDispls_; |
| 67 |
std::vector<int> targetRecvCounts_; |
| 68 |
std::vector<int> targetRecvDispls_; |
| 69 |
std::vector<size_t> sourceSendMapping_; |
| 70 |
std::vector<std::array<size_t,4>> stencil_; |
| 71 |
std::vector<std::array<double,4>> weights_; |
| 72 |
std::vector<size_t> stencilSize_; |
| 73 |
}; |
| 74 |
|
| 75 |
|
| 76 |
} // namespace method |
| 77 |
} // namespace interpolation |
| 78 |
} // namespace atlas |