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

Remove et_calc and pdm03 #599

Merged
merged 4 commits into from
Aug 10, 2023
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
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ if(NGEN_WITH_SQLITE3)
endif()

add_subdirectory("src/realizations/catchment")
add_subdirectory("src/models/kernels/evapotranspiration")
add_subdirectory("src/forcing")

target_link_libraries(ngen PUBLIC
Expand All @@ -234,7 +233,6 @@ target_link_libraries(ngen PUBLIC
NGen::core_nexus
NGen::geojson
NGen::realizations_catchment
NGen::kernels_evapotranspiration
NGen::forcing
NGen::core_mediator
libudunits2
Expand Down
7 changes: 0 additions & 7 deletions include/realizations/catchment/Bmi_Formulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@
#define BMI_REALIZATION_CFG_PARAM_OPT__CPP_CREATE_FUNC_DEFAULT "bmi_model_create"
#define BMI_REALIZATION_CFG_PARAM_OPT__CPP_DESTROY_FUNC_DEFAULT "bmi_model_destroy"

// Supported Standard Names for BMI variables
// This is needed to provide a calculated potential ET value back to a BMI model
#define NGEN_STD_NAME_POTENTIAL_ET_FOR_TIME_STEP "potential_evapotranspiration"

// Taken from the CSDMS Standard Names list
// TODO: need to add these in for anything BMI model input or output variables we need to know how to recognize
#define CSDMS_STD_NAME_POTENTIAL_ET "water_potential_evaporation_flux"
/* *************** See also the Forcing.h file for several CSDMS Standard Names definitions *************** */

// Forward declaration to provide access to protected items in testing
Expand Down
207 changes: 5 additions & 202 deletions include/realizations/catchment/Bmi_Module_Formulation.hpp

Large diffs are not rendered by default.

61 changes: 0 additions & 61 deletions include/realizations/catchment/Bmi_Multi_Formulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#define BMI_REALIZATION_CFG_PARAM_REQ__MODULES "modules"
#define BMI_REALIZATION_CFG_PARAM_OPT__DEFAULT_OUT_VALS "default_output_values"
#define DEFAULT_ET_FORMULATION_INDEX 0

using namespace std;

Expand Down Expand Up @@ -44,18 +43,6 @@ namespace realization {

virtual ~Bmi_Multi_Formulation() {};

/**
* Perform ET (or PET) calculations.
*
* This function defers to the analogous function of the appropriate nested submodule, using
* @ref determine_et_formulation_index to determine which one that is.
*
* @return The ET calculation from the appropriate module from this instance's collection of BMI nested modules.
*/
double calc_et() override {
return modules[determine_et_formulation_index()]->calc_et();
}

/**
* Convert a time value from the model to an epoch time in seconds.
*
Expand Down Expand Up @@ -100,54 +87,6 @@ namespace realization {
create_multi_formulation(properties, true);
}

/**
* Determine the index of the correct sub-module formulation from which ET values should be obtain.
*
* This is primarily used to determine the correct module in the multi-module collection for getting the ET
* value when calls to @ref calc_et are made on this "outer" multi-module formulation.
*
* The function first attempts to find the nested module that makes available either
* ``NGEN_STD_NAME_POTENTIAL_ET_FOR_TIME_STEP`` or ``CSDMS_STD_NAME_POTENTIAL_ET`` available, if any does. It
* then provides the index of this module.
*
* Otherwise, the function iterates through the nested modules in order performing a search for one that
* provides a value with either the name defined in ``NGEN_STD_NAME_POTENTIAL_ET_FOR_TIME_STEP`` or defined in
* ``CSDMS_STD_NAME_POTENTIAL_ET``. It return the index of the first having either.
*
* If neither means finds the appropriate module, at default value ``DEFAULT_ET_FORMULATION_INDEX`` is returned.
*
* @return The index of correct sub-module formulation from which ET values should be obtain.
*/
size_t determine_et_formulation_index() {
std::shared_ptr<data_access::GenericDataProvider> et_provider = nullptr;
if (availableData.find(NGEN_STD_NAME_POTENTIAL_ET_FOR_TIME_STEP) != availableData.end()) {
et_provider = availableData[NGEN_STD_NAME_POTENTIAL_ET_FOR_TIME_STEP];
}
else if (availableData.find(CSDMS_STD_NAME_POTENTIAL_ET) != availableData.end()) {
et_provider = availableData[CSDMS_STD_NAME_POTENTIAL_ET];
}
// The pointers in availableData and modules should be the same, based on create_multi_formulation()
// So, if an et_provider was found from availableData, we can compare to determine the right index.
if (et_provider != nullptr) {
for (size_t i = 0; i < modules.size(); ++i) {
if (et_provider == modules[i]) {
return i;
}
}
}
// Otherwise, check the modules directly for the standard ET output variable names.
for (size_t i = 0; i < modules.size(); ++i) {
std::vector<std::string> values = modules[i]->get_available_variable_names();
if (std::find(values.begin(), values.end(), NGEN_STD_NAME_POTENTIAL_ET_FOR_TIME_STEP) != values.end()) {
return i;
}
if (std::find(values.begin(), values.end(), CSDMS_STD_NAME_POTENTIAL_ET) != values.end()) {
return i;
}
}
return DEFAULT_ET_FORMULATION_INDEX;
}

/**
* Get whether a model may perform updates beyond its ``end_time``.
*
Expand Down
3 changes: 1 addition & 2 deletions include/realizations/catchment/Catchment_Formulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
#include <memory>
#include <vector>
#include "Formulation.hpp"
#include "Et_Accountable.hpp"
#include <HY_CatchmentArea.hpp>
#include "GenericDataProvider.hpp"

namespace realization {

class Catchment_Formulation : public Formulation, public HY_CatchmentArea, public Et_Accountable {
class Catchment_Formulation : public Formulation, public HY_CatchmentArea {
public:
Catchment_Formulation(std::string id, std::shared_ptr<data_access::GenericDataProvider> forcing, utils::StreamHandler output_stream)
: Formulation(id), HY_CatchmentArea(forcing, output_stream) {
Expand Down
61 changes: 0 additions & 61 deletions include/realizations/catchment/Et_Accountable.hpp

This file was deleted.

37 changes: 0 additions & 37 deletions include/realizations/catchment/Et_Aware.hpp

This file was deleted.

4 changes: 1 addition & 3 deletions include/realizations/catchment/Formulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
#include <exception>
#include <vector>

#include "Et_Accountable.hpp"
#include "JSONProperty.hpp"
#include "Pdm03.h"

#include <boost/property_tree/ptree.hpp>
#include <boost/algorithm/string.hpp>
Expand All @@ -18,7 +16,7 @@

namespace realization {

class Formulation : public virtual Et_Aware {
class Formulation {
public:
typedef long time_step_t;

Expand Down
Loading