| 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 |
* |
| 7 |
* In applying this licence, ECMWF does not waive the privileges and immunities |
| 8 |
* granted to it by virtue of its status as an intergovernmental organisation nor |
| 9 |
* does it submit to any jurisdiction. |
| 10 |
*/ |
| 11 |
|
| 12 |
|
| 13 |
#include "atlas/interpolation/NonLinear.h" |
| 14 |
|
| 15 |
#include "atlas/interpolation/nonlinear/NonLinear.h" |
| 16 |
#include "atlas/runtime/Exception.h" |
| 17 |
#include "atlas/util/Config.h" |
| 18 |
|
| 19 |
|
| 20 |
namespace atlas { |
| 21 |
namespace interpolation { |
| 22 |
|
| 23 |
|
| 24 |
namespace { |
| 25 |
std::string config_type(const eckit::Parametrisation& config) { |
| 26 |
std::string value; |
| 27 |
ATLAS_ASSERT_MSG(config.get("type", value), ""); |
| 28 |
return value; |
| 29 |
} |
| 30 |
} // namespace |
| 31 |
|
| 32 |
|
| 33 |
NonLinear::NonLinear(): Handle(nullptr) {} |
| 34 |
|
| 35 |
|
| 36 |
NonLinear::NonLinear(const NonLinear::Config& config): |
| 37 |
Handle(nonlinear::NonLinearFactory::build(config_type(config), config)) {} |
| 38 |
|
| 39 |
|
| 40 |
NonLinear::NonLinear(const std::string& type, const NonLinear::Config& config): |
| 41 |
Handle(nonlinear::NonLinearFactory::build(type, config)) {} |
| 42 |
|
| 43 |
|
| 44 |
bool NonLinear::operator()(const Field& f) const { |
| 45 |
return operator bool() && get()->applicable(f); |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
bool NonLinear::execute(NonLinear::Matrix& W, const Field& f) const { |
| 50 |
ATLAS_ASSERT_MSG(operator bool(), "NonLinear: ObjectHandle not setup"); |
| 51 |
return get()->execute(W, f); |
| 52 |
} |
| 53 |
|
| 54 |
bool NonLinear::execute(NonLinear::Matrix& W, const array::Array& a, const NonLinear::Config& c) const { |
| 55 |
ATLAS_ASSERT_MSG(operator bool(), "NonLinear: ObjectHandle not setup"); |
| 56 |
return get()->execute(W, a, c); |
| 57 |
} |
| 58 |
|
| 59 |
} // namespace interpolation |
| 60 |
} // namespace atlas |