| 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/functionspace.h" |
| 11 |
#include "atlas/util/Object.h" |
| 12 |
|
| 13 |
namespace atlas { |
| 14 |
class Field; |
| 15 |
class FieldSet; |
| 16 |
class FunctionSpace; |
| 17 |
} // namespace atlas |
| 18 |
|
| 19 |
namespace atlas { |
| 20 |
namespace redistribution { |
| 21 |
namespace detail { |
| 22 |
|
| 23 |
/// \brief Abstract base class for redistributor implementation. |
| 24 |
class RedistributionImpl : public util::Object { |
| 25 |
public: |
| 26 |
RedistributionImpl() = default; |
| 27 |
|
| 28 |
/// \brief Initialises the redistributor. |
| 29 |
/// |
| 30 |
/// \details Performs MPI_Allgatherv to determine the (i, j, k) ranges |
| 31 |
/// of each source and target function space on each PE. |
| 32 |
/// The grids of source and target function space must match. |
| 33 |
/// |
| 34 |
/// \param[in] source Function space of source fields. |
| 35 |
/// \param[in] target Function space of target fields. |
| 36 |
void setup(const FunctionSpace& source, const FunctionSpace& target); |
| 37 |
|
| 38 |
/// \Setup class. |
| 39 |
virtual void do_setup() = 0; |
| 40 |
|
| 41 |
/// \brief Concrete type. |
| 42 |
virtual std::string type() const = 0; |
| 43 |
|
| 44 |
/// \brief Maps source field to target field. |
| 45 |
virtual void execute(const Field& source, Field& target) const = 0; |
| 46 |
|
| 47 |
/// \brief Maps source field set to target field set. |
| 48 |
virtual void execute(const FieldSet& source, FieldSet& target) const = 0; |
| 49 |
|
| 50 |
/// \brief Get const reference to source function space. |
| 51 |
const FunctionSpace& source() const; |
| 52 |
|
| 53 |
/// \brief Get const reference to target function space. |
| 54 |
const FunctionSpace& target() const; |
| 55 |
|
| 56 |
private: |
| 57 |
FunctionSpace source_; |
| 58 |
FunctionSpace target_; |
| 59 |
}; |
| 60 |
|
| 61 |
} // namespace detail |
| 62 |
} // namespace redistribution |
| 63 |
} // namespace atlas |