| 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 |
* 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 |
#pragma once |
| 12 |
|
| 13 |
#include <array> |
| 14 |
#include <string> |
| 15 |
|
| 16 |
#include "atlas/grid/detail/tiles/Tiles.h" |
| 17 |
#include "atlas/util/Point.h" |
| 18 |
|
| 19 |
namespace atlas { |
| 20 |
namespace grid { |
| 21 |
namespace detail { |
| 22 |
|
| 23 |
class LFRicCubedSphereTiles : public CubedSphereTiles { |
| 24 |
public: |
| 25 |
// constructor |
| 26 |
LFRicCubedSphereTiles(const eckit::Parametrisation&); |
| 27 |
|
| 28 |
static std::string static_type() { return "cubedsphere_lfric"; } |
| 29 |
|
| 30 |
virtual std::string type() const override { return static_type(); } |
| 31 |
|
| 32 |
virtual std::array<std::array<double, 6>, 2> xy2abOffsets() const override; |
| 33 |
|
| 34 |
virtual std::array<std::array<double, 6>, 2> ab2xyOffsets() const override; |
| 35 |
|
| 36 |
virtual void rotate(idx_t t, double xyz[]) const override; |
| 37 |
|
| 38 |
virtual void unrotate(idx_t t, double xyz[]) const override; |
| 39 |
|
| 40 |
virtual idx_t indexFromXY(const double xy[]) const override; |
| 41 |
|
| 42 |
virtual idx_t indexFromLonLat(const double lonlat[]) const override; |
| 43 |
|
| 44 |
virtual void enforceXYdomain(double xy[]) const override; |
| 45 |
|
| 46 |
virtual PointXY tileCubePeriodicity(const PointXY& xyExtended, const idx_t tile) const override; |
| 47 |
|
| 48 |
virtual void print(std::ostream&) const override; |
| 49 |
|
| 50 |
virtual const PointXY& tileCentre(size_t t) const override; |
| 51 |
|
| 52 |
virtual const Jacobian& tileJacobian(size_t t) const override; |
| 53 |
|
| 54 |
private: |
| 55 |
static PointXY botLeftTile(size_t t); |
| 56 |
static PointXY botRightTile(size_t t); |
| 57 |
static PointXY topLeftTile(size_t t); |
| 58 |
static PointXY topRightTile(size_t t); |
| 59 |
|
| 60 |
bool withinCross(const idx_t t, const PointXY& withinRange) const; |
| 61 |
|
| 62 |
void enforceWrapAround(const idx_t t, PointXY& withinRange) const; |
| 63 |
|
| 64 |
|
| 65 |
// Centre of each tile in xy-space. |
| 66 |
static const std::array<PointXY, 6> tileCentres_; |
| 67 |
// Jacobian of xy with respect to tile curvilinear coordinates. |
| 68 |
static const std::array<Jacobian, 6> tileJacobians_; |
| 69 |
}; |
| 70 |
|
| 71 |
} // namespace detail |
| 72 |
} // namespace grid |
| 73 |
} // namespace atlas |