| 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/redistribution/detail/RedistributionImpl.h" |
| 11 |
#include "atlas/util/ObjectHandle.h" |
| 12 |
|
| 13 |
namespace atlas { |
| 14 |
class Field; |
| 15 |
class FieldSet; |
| 16 |
class FunctionSpace; |
| 17 |
} // namespace atlas |
| 18 |
|
| 19 |
namespace atlas { |
| 20 |
|
| 21 |
/// \brief Base redistributer class. |
| 22 |
/// |
| 23 |
/// \details Class to map two function spaces with the same grid but |
| 24 |
/// different partitioners. |
| 25 |
class Redistribution : public util::ObjectHandle<redistribution::detail::RedistributionImpl> { |
| 26 |
public: |
| 27 |
using Handle::Handle; |
| 28 |
|
| 29 |
/// \brief Empty default constructor. |
| 30 |
Redistribution(); |
| 31 |
|
| 32 |
/// \brief Constructs and initialises the redistributor. |
| 33 |
/// |
| 34 |
/// \details Initialises class to copy fields from a source function space |
| 35 |
/// to fields from a target functionspace. The grids of source and |
| 36 |
/// target function space must match. |
| 37 |
/// |
| 38 |
/// \param[in] source Function space of source fields. |
| 39 |
/// \param[in] target Function space of target fields. |
| 40 |
/// \param[in] config Config to specify "type" of redistribution. |
| 41 |
Redistribution(const FunctionSpace& source, const FunctionSpace& target, |
| 42 |
const util::Config& config = util::Config()); |
| 43 |
|
| 44 |
/// \brief Maps source field to target field. |
| 45 |
/// |
| 46 |
/// \details Transfers data from source field to target field. Function |
| 47 |
/// space of source field must match sourceFunctionSpace. Same |
| 48 |
/// applies to target field. |
| 49 |
/// |
| 50 |
/// \param[in] source input field matching sourceFunctionSpace. |
| 51 |
/// \param[out] target output field matching targetFunctionSpace. |
| 52 |
void execute(const Field& source, Field& target) const; |
| 53 |
|
| 54 |
/// \brief Redistributes source field set to target fields set. |
| 55 |
/// |
| 56 |
/// \details Transfers source field set to target field set via multiple |
| 57 |
/// invocations of execute(sourceField, targetField). |
| 58 |
/// |
| 59 |
/// \param[in] source input field set. |
| 60 |
/// \param[out] target output field set. |
| 61 |
void execute(const FieldSet& sourceFieldSet, FieldSet& targetFieldSet) const; |
| 62 |
|
| 63 |
/// \brief Get const reference to source function space. |
| 64 |
const FunctionSpace& source() const; |
| 65 |
|
| 66 |
/// \brief Get const reference to target function space. |
| 67 |
const FunctionSpace& target() const; |
| 68 |
}; |
| 69 |
|
| 70 |
} // namespace atlas |