Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Geometry class #3

Merged
merged 4 commits into from
Sep 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 26 additions & 17 deletions src/oisst/Geometry/Geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,51 @@

#include "eckit/config/Configuration.h"

#include "atlas/grid.h"

#include "oops/util/abor1_cpp.h"

namespace oisst {

// ----------------------------------------------------------------------------

Geometry::Geometry(const eckit::Configuration & conf,
const eckit::mpi::Comm & comm)
: comm_(comm) {
util::abor1_cpp("Geometry::Geometry() needs to be implemented.",
__FILE__, __LINE__);
const eckit::mpi::Comm & comm) : comm_(comm) {
atlas::RegularLonLatGrid atlasRllGrid(conf.getString("grid"));
atlasFunctionSpace_.reset(
new atlas::functionspace::StructuredColumns(atlasRllGrid,
atlas::option::halo(0)));

atlasFieldSet_.reset(new atlas::FieldSet());
}

// ----------------------------------------------------------------------------

Geometry::Geometry(const Geometry & other)
: comm_(other.comm_) {
util::abor1_cpp("Geometry::Geometry() needs to be implemented.",
__FILE__, __LINE__);
Geometry::Geometry(const Geometry & other) : comm_(other.comm_) {
atlasFunctionSpace_.reset(new
atlas::functionspace::StructuredColumns(other.atlasFunctionSpace_->grid(),
atlas::option::halo(0)));

atlasFieldSet_.reset(new atlas::FieldSet());
for (int ifield = 0; ifield < other.atlasFieldSet_->size(); ifield++) {
atlas::Field atlasField = other.atlasFieldSet_->field(ifield);
atlasFieldSet_->add(atlasField);
}
}

// ----------------------------------------------------------------------------

Geometry::~Geometry() {
util::abor1_cpp("Geometry::~Geometry() needs to be implemented.",
__FILE__, __LINE__);
}
Geometry::~Geometry() {}

// ----------------------------------------------------------------------------

void Geometry::print(std::ostream & os) const {
util::abor1_cpp("Geometry::print() needs to be implemented.",
__FILE__, __LINE__);
os << "Geometry: "
<< "(TODO, print diagnostic info about the geometry here)"
<< std::endl;
int nx, ny;
ny = static_cast<int>(atlasFunctionSpace()->grid().ny());
nx = static_cast<int>(
((atlas::RegularLonLatGrid&)(atlasFunctionSpace()->grid())).nx() );

os << "Geometry: nx = " << nx << ", ny = " << ny << std::endl;
}

// ----------------------------------------------------------------------------
Expand Down
19 changes: 16 additions & 3 deletions src/oisst/Geometry/Geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
#include <ostream>
#include <string>

#include "eckit/mpi/Comm.h"
#include <memory>

#include "atlas/functionspace.h"
#include "atlas/field.h"

#include "eckit/mpi/Comm.h"
#include "oops/util/ObjectCounter.h"
#include "oops/util/Printable.h"

Expand All @@ -27,7 +31,6 @@ namespace oisst {
// ----------------------------------------------------------------------------

namespace oisst {

// Geometry class
class Geometry : public util::Printable,
private util::ObjectCounter<Geometry> {
Expand All @@ -46,10 +49,20 @@ namespace oisst {
// TODO(template_impl) GeometryIterator begin() const;
// TODO(template_impl) GeometryIterator end() const;

atlas::functionspace::StructuredColumns* atlasFunctionSpace() const {
return atlasFunctionSpace_.get();
}
atlas::FieldSet* atlasFieldSet() const {
return atlasFieldSet_.get();
}

private:
void print(std::ostream &) const;

const eckit::mpi::Comm & comm_;

std::unique_ptr<atlas::functionspace::StructuredColumns>
atlasFunctionSpace_;
std::unique_ptr<atlas::FieldSet> atlasFieldSet_;
};
} // namespace oisst

Expand Down
10 changes: 5 additions & 5 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ endforeach()
# TODO: uncomment all of these tests as the appropriate interfaces are implemented
#================================================================================

# ecbuild_add_test(
# TARGET test_oisst_geometry
# SOURCES executables/TestGeometry.cc
# ARGS testinput/geometry.yml
# LIBS oisst )
ecbuild_add_test(
TARGET test_oisst_geometry
SOURCES executables/TestGeometry.cc
ARGS testinput/geometry.yml
LIBS oisst )

# ecbuild_add_test(
# TARGET test_oisst_state
Expand Down
2 changes: 1 addition & 1 deletion test/testinput/geometry.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
geometry:
# insert other model specific things here
grid: Slat360x180