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 2 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
49 changes: 33 additions & 16 deletions src/oisst/Geometry/Geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,59 @@

#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__);
Geometry::Geometry(const eckit::Configuration & conf, const eckit::mpi::Comm & comm) : comm_(comm) {
//util::abor1_cpp("Geometry::Geometry() needs to be implemented.", __FILE__, __LINE__);

atlas::RegularLonLatGrid atlasRllGrid("Slat360x180");
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_) {
//util::abor1_cpp("Geometry::Geometry() needs to be implemented.", __FILE__, __LINE__);

atlasFunctionSpace_.reset(new atlas::functionspace::StructuredColumns(other.atlasFunctionSpace_->grid(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if all this is needed in the copy constructor here, it might work if the unique pointers were changed to shared pointers, and you just copy the pointers instead. Doesn't really matter at this point though, we can worry about that later when it's time to optimize the code

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes let's worry about it later, right now what I (and Jim) want is to get an initial result first. Later on we will optimize the code as I get more familiar with JEDI and ATLAS etc.

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__);
//util::abor1_cpp("Geometry::~Geometry() needs to be implemented.", __FILE__, __LINE__);


}

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

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;
//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;
//double dx, dy;
ny = int(atlasFunctionSpace()->grid().ny());
nx = int(((atlas::RegularLonLatGrid&)(atlasFunctionSpace()->grid())).nx());

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

// ----------------------------------------------------------------------------
Expand Down
23 changes: 16 additions & 7 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,11 +31,9 @@ namespace oisst {
// ----------------------------------------------------------------------------

namespace oisst {

// Geometry class
class Geometry : public util::Printable,
private util::ObjectCounter<Geometry> {
public:
class Geometry : public util::Printable, private util::ObjectCounter<Geometry> {
public:
static const std::string classname() {return "oisst::Geometry";}

// constructors and destructor
Expand All @@ -46,10 +48,17 @@ namespace oisst {
// TODO(template_impl) GeometryIterator begin() const;
// TODO(template_impl) GeometryIterator end() const;

private:
void print(std::ostream &) const;
// atlas::FunctionSpace* atlasFunctionSpace() const { return atlasFunctionSpace_.get(); }
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
80 changes: 80 additions & 0 deletions test/CMakeLists.txt_org
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
list( APPEND oisst_test_input
testinput/geometry.yml
testinput/errorcovariance.yml
testinput/getvalues.yml
testinput/lineargetvalues.yml
testinput/linearmodel.yml
testinput/increment.yml
testinput/model.yml
testinput/modelaux.yml
testinput/state.yml
)


# link the input files for the tests
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/testinput)
foreach(FILENAME ${oisst_test_input})
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}
${CMAKE_CURRENT_BINARY_DIR}/${FILENAME} )
endforeach()


#================================================================================
# Tests of class interfaces
# 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_state
# SOURCES executables/TestState.cc
# ARGS testinput/state.yml
# LIBS oisst )

# ecbuild_add_test(
# TARGET test_oisst_increment
# SOURCES executables/TestIncrement.cc
# ARGS testinput/increment.yml
# LIBS oisst )

# ecbuild_add_test(
# TARGET test_oisst_modelauxcontrol
# SOURCES executables/TestModelAuxControl.cc
# ARGS testinput/modelaux.yml
# LIBS oisst )

# ecbuild_add_test(
# TARGET test_oisst_getvalues
# SOURCES executables/TestGetValues.cc
# ARGS testinput/getvalues.yml
# LIBS oisst )

# ecbuild_add_test(
# TARGET test_oisst_lineargetvalues
# SOURCES executables/TestLinearGetValues.cc
# ARGS testinput/lineargetvalues.yml
# LIBS oisst )

# ecbuild_add_test(
# TARGET test_oisst_errorcovariance
# SOURCES executables/TestErrorCovariance.cc
# ARGS testinput/errorcovariance.yml
# LIBS oisst )

# ecbuild_add_test(
# TARGET test_oisst_modelauxcovariance
# SOURCES executables/TestModelAuxCovariance.cc
# ARGS testinput/modelaux.yml
# LIBS oisst )

# ecbuild_add_test(
# TARGET test_oisst_modelauxincrement
# SOURCES executables/TestModelAuxIncrement.cc
# ARGS testinput/modelaux.yml
# LIBS oisst )