| 1 |
/* |
| 2 |
* (C) Copyright 1996- 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 |
|
| 12 |
#pragma once |
| 13 |
|
| 14 |
#include "atlas/interpolation/method/knn/KNearestNeighboursBase.h" |
| 15 |
|
| 16 |
#include <forward_list> |
| 17 |
|
| 18 |
#include "atlas/functionspace.h" |
| 19 |
#include "atlas/interpolation/method/knn/GridBox.h" |
| 20 |
|
| 21 |
|
| 22 |
namespace atlas { |
| 23 |
namespace interpolation { |
| 24 |
namespace method { |
| 25 |
|
| 26 |
|
| 27 |
class GridBoxMethod : public KNearestNeighboursBase { |
| 28 |
public: |
| 29 |
GridBoxMethod(const Config&); |
| 30 |
virtual ~GridBoxMethod() override; |
| 31 |
|
| 32 |
protected: |
| 33 |
virtual void print(std::ostream&) const override; |
| 34 |
|
| 35 |
using KNearestNeighboursBase::do_setup; |
| 36 |
/** |
| 37 |
* @brief Create an interpolant sparse matrix relating two functionspaces, using grid-box average method |
| 38 |
* @param source functionspace containing source points |
| 39 |
* @param target functionspace containing target points |
| 40 |
*/ |
| 41 |
virtual void do_setup(const FunctionSpace& source, const FunctionSpace& target) override; |
| 42 |
virtual void do_setup(const Grid& source, const Grid& target, const Cache&) override; |
| 43 |
virtual void do_setup(const FunctionSpace& source, const FunctionSpace& target, const Cache&) override; |
| 44 |
|
| 45 |
virtual const FunctionSpace& source() const override { return source_; } |
| 46 |
virtual const FunctionSpace& target() const override { return target_; } |
| 47 |
|
| 48 |
bool intersect(size_t i, const GridBox& iBox, const util::IndexKDTree::ValueList&, std::vector<Triplet>&) const; |
| 49 |
|
| 50 |
virtual void do_execute(const FieldSet& source, FieldSet& target, Metadata&) const override = 0; |
| 51 |
virtual void do_execute(const Field& source, Field& target, Metadata&) const override = 0; |
| 52 |
|
| 53 |
virtual Cache createCache() const override; |
| 54 |
|
| 55 |
protected: |
| 56 |
static void giveUp(const std::forward_list<size_t>&); |
| 57 |
|
| 58 |
FunctionSpace source_; |
| 59 |
FunctionSpace target_; |
| 60 |
|
| 61 |
GridBoxes sourceBoxes_; |
| 62 |
GridBoxes targetBoxes_; |
| 63 |
|
| 64 |
double searchRadius_; |
| 65 |
|
| 66 |
mutable std::forward_list<size_t> failures_; |
| 67 |
|
| 68 |
bool matrixFree_; |
| 69 |
bool failEarly_; |
| 70 |
bool gaussianWeightedLatitudes_; |
| 71 |
}; |
| 72 |
|
| 73 |
|
| 74 |
} // namespace method |
| 75 |
} // namespace interpolation |
| 76 |
} // namespace atlas |