| 1 |
/* |
| 2 |
* (C) Copyright 2013 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 |
#include "atlas/grid/Grid.h" |
| 12 |
|
| 13 |
#include <limits> |
| 14 |
#include <string> |
| 15 |
#include <vector> |
| 16 |
|
| 17 |
#include "eckit/config/Parametrisation.h" |
| 18 |
|
| 19 |
#include "atlas/domain/Domain.h" |
| 20 |
#include "atlas/grid/Grid.h" |
| 21 |
#include "atlas/grid/Spacing.h" |
| 22 |
#include "atlas/grid/StructuredGrid.h" |
| 23 |
#include "atlas/grid/detail/grid/Gaussian.h" |
| 24 |
#include "atlas/projection/Projection.h" |
| 25 |
#include "atlas/util/Config.h" |
| 26 |
|
| 27 |
namespace atlas { |
| 28 |
|
| 29 |
inline const StructuredGrid::grid_t* structured_grid(const Grid::Implementation* grid) { |
| 30 |
return dynamic_cast<const StructuredGrid::grid_t*>(grid); |
| 31 |
} |
| 32 |
|
| 33 |
StructuredGrid::StructuredGrid(): Grid(), grid_(nullptr) {} |
| 34 |
|
| 35 |
StructuredGrid::StructuredGrid(const Grid& grid): Grid(grid), grid_(structured_grid(get())) {} |
| 36 |
|
| 37 |
StructuredGrid::StructuredGrid(const Grid::Implementation* grid): Grid(grid), grid_(structured_grid(get())) {} |
| 38 |
|
| 39 |
StructuredGrid::StructuredGrid(const std::string& grid, const Domain& domain): |
| 40 |
Grid(grid, domain), grid_(structured_grid(get())) {} |
| 41 |
|
| 42 |
StructuredGrid::StructuredGrid(const std::string& grid, const Projection& projection, const Domain& domain): |
| 43 |
Grid(grid, projection, domain), grid_(structured_grid(get())) {} |
| 44 |
|
| 45 |
StructuredGrid::StructuredGrid(const Config& grid): Grid(grid), grid_(structured_grid(get())) {} |
| 46 |
|
| 47 |
StructuredGrid::StructuredGrid(const XSpace& xspace, const YSpace& yspace, const Projection& projection, |
| 48 |
const Domain& domain): |
| 49 |
Grid(new StructuredGrid::grid_t(xspace, yspace, projection, domain)), grid_(structured_grid(get())) {} |
| 50 |
|
| 51 |
StructuredGrid::StructuredGrid(const Grid& grid, const Grid::Domain& domain): |
| 52 |
Grid(grid, domain), grid_(structured_grid(get())) {} |
| 53 |
|
| 54 |
ReducedGaussianGrid::ReducedGaussianGrid(const std::vector<long>& nx, const Domain& domain): |
| 55 |
ReducedGaussianGrid::grid_t(grid::detail::grid::reduced_gaussian(nx, domain)) {} |
| 56 |
|
| 57 |
ReducedGaussianGrid::ReducedGaussianGrid(const std::vector<int>& nx, const Domain& domain): |
| 58 |
ReducedGaussianGrid::grid_t(grid::detail::grid::reduced_gaussian(nx, domain)) {} |
| 59 |
|
| 60 |
ReducedGaussianGrid::ReducedGaussianGrid(const std::vector<long>& nx, const Projection& projection): |
| 61 |
ReducedGaussianGrid::grid_t(grid::detail::grid::reduced_gaussian(nx, projection)) {} |
| 62 |
|
| 63 |
ReducedGaussianGrid::ReducedGaussianGrid(const std::vector<int>& nx, const Projection& projection): |
| 64 |
ReducedGaussianGrid::grid_t(grid::detail::grid::reduced_gaussian(nx, projection)) {} |
| 65 |
|
| 66 |
ReducedGaussianGrid::ReducedGaussianGrid(const std::initializer_list<idx_t>& nx): |
| 67 |
ReducedGaussianGrid(std::vector<idx_t>(nx)) {} |
| 68 |
|
| 69 |
RegularGaussianGrid::RegularGaussianGrid(int N, const Grid::Domain& domain): |
| 70 |
RegularGaussianGrid::grid_t("F" + std::to_string(N), domain) {} |
| 71 |
|
| 72 |
|
| 73 |
inline const HealpixGrid::grid_t* healpix_grid(const Grid::Implementation* grid) { |
| 74 |
return dynamic_cast<const HealpixGrid::grid_t*>(grid); |
| 75 |
} |
| 76 |
|
| 77 |
HealpixGrid::HealpixGrid(const Grid& grid): StructuredGrid(grid), grid_(healpix_grid(get())) {} |
| 78 |
|
| 79 |
HealpixGrid::HealpixGrid(int N, const std::string& ordering): HealpixGrid(Grid(new HealpixGrid::grid_t(N, ordering))) {} |
| 80 |
|
| 81 |
} // namespace atlas |