| 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 |
#pragma once |
| 11 |
|
| 12 |
#include <functional> |
| 13 |
#include <type_traits> |
| 14 |
|
| 15 |
#include "atlas/functionspace/FunctionSpace.h" |
| 16 |
#include "atlas/functionspace/StructuredColumns.h" |
| 17 |
#include "atlas/functionspace/detail/BlockStructuredColumns.h" |
| 18 |
|
| 19 |
namespace atlas { |
| 20 |
namespace functionspace { |
| 21 |
|
| 22 |
// ------------------------------------------------------------------- |
| 23 |
|
| 24 |
class BlockStructuredColumns : public FunctionSpace { |
| 25 |
public: |
| 26 |
class Block; |
| 27 |
public: |
| 28 |
BlockStructuredColumns(); |
| 29 |
BlockStructuredColumns(const FunctionSpace&); |
| 30 |
BlockStructuredColumns(const Grid&, const eckit::Configuration& = util::NoConfig()); |
| 31 |
BlockStructuredColumns(const Grid&, const grid::Partitioner&, const eckit::Configuration& = util::NoConfig()); |
| 32 |
BlockStructuredColumns(const Grid&, const grid::Distribution&, const eckit::Configuration& = util::NoConfig()); |
| 33 |
BlockStructuredColumns(const Grid&, const Vertical&, const eckit::Configuration& = util::NoConfig()); |
| 34 |
BlockStructuredColumns(const Grid&, const Vertical&, const grid::Partitioner&, |
| 35 |
const eckit::Configuration& = util::NoConfig()); |
| 36 |
BlockStructuredColumns(const Grid&, const grid::Distribution&, const Vertical&, |
| 37 |
const eckit::Configuration& = util::NoConfig()); |
| 38 |
|
| 39 |
static std::string type() { return detail::BlockStructuredColumns::static_type(); } |
| 40 |
|
| 41 |
operator bool() const { return valid(); } |
| 42 |
bool valid() const { return functionspace_; } |
| 43 |
|
| 44 |
idx_t size() const { return functionspace_->size(); } |
| 45 |
idx_t levels() const { return functionspace_->levels(); } |
| 46 |
|
| 47 |
const Vertical& vertical() const { return functionspace_->vertical(); } |
| 48 |
|
| 49 |
const StructuredGrid& grid() const { return functionspace_->grid(); } |
| 50 |
|
| 51 |
std::string checksum(const FieldSet&) const; |
| 52 |
std::string checksum(const Field&) const; |
| 53 |
|
| 54 |
idx_t index(idx_t blk, idx_t rof) const { return functionspace_->index(blk, rof); } |
| 55 |
idx_t k_begin() const { return functionspace_->k_begin(); } |
| 56 |
idx_t k_end() const { return functionspace_->k_end(); } |
| 57 |
idx_t nproma() const { return functionspace_->nproma(); } |
| 58 |
idx_t nblks() const { return functionspace_->nblks(); } |
| 59 |
|
| 60 |
Field xy() const { return functionspace_->xy(); } |
| 61 |
Field partition() const { return functionspace_->partition(); } |
| 62 |
Field global_index() const { return functionspace_->global_index(); } |
| 63 |
Field remote_index() const { return functionspace_->remote_index(); } |
| 64 |
Field index_i() const { return functionspace_->index_i(); } |
| 65 |
Field index_j() const { return functionspace_->index_j(); } |
| 66 |
Field ghost() const { return functionspace_->ghost(); } |
| 67 |
|
| 68 |
const Block block(idx_t jblk) const { |
| 69 |
return Block(functionspace_->block_begin(jblk), functionspace_->block_size(jblk)); |
| 70 |
} |
| 71 |
|
| 72 |
size_t footprint() const { return functionspace_->footprint(); } |
| 73 |
|
| 74 |
class Block { |
| 75 |
public: |
| 76 |
Block(idx_t begin, idx_t size) : begin_(begin), size_(size) {} |
| 77 |
idx_t index(idx_t j) const { return begin_ + j; }; |
| 78 |
idx_t size() const { return size_; } |
| 79 |
private: |
| 80 |
idx_t begin_; |
| 81 |
idx_t size_; |
| 82 |
}; |
| 83 |
|
| 84 |
private: |
| 85 |
const detail::BlockStructuredColumns* functionspace_; |
| 86 |
void setup(const Grid& grid, const Vertical& vertical, const grid::Distribution& distribution, |
| 87 |
const eckit::Configuration& config); |
| 88 |
}; |
| 89 |
|
| 90 |
// ------------------------------------------------------------------- |
| 91 |
|
| 92 |
|
| 93 |
} // namespace functionspace |
| 94 |
} // namespace atlas |