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

Move get_var_value_as_double up hierarchy, as it was inadvertently duplicated as a non-override #677

Merged
merged 2 commits into from
Nov 13, 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
32 changes: 32 additions & 0 deletions include/realizations/catchment/Bmi_Formulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,38 @@ namespace realization {
*output_text_stream << std::setprecision(output_precision);
}

/**
* Get value for some BMI model variable.
*
* This function assumes that the given variable, while returned by the model within an array per the BMI spec,
* is actually a single, scalar value. Thus, it returns what is at index 0 of the array reference.
*
* @param index
* @param var_name
* @return
*/
virtual double get_var_value_as_double(const std::string& var_name) = 0;

/**
* Get value for some BMI model variable at a specific index.
*
* Function gets the value for a provided variable, returned from the backing model as an array, and returns the
* specific value at the desired index cast as a double type.
*
* The function makes several assumptions:
*
* 1. `index` is within array bounds
* 2. `var_name` is in the set of valid variable names for the model
* 3. the type for output variable allows the value to be cast to a `double` appropriately
*
* It falls to user (functions) of this function to ensure these assumptions hold before invoking.
*
* @param index
* @param var_name
* @return
*/
virtual double get_var_value_as_double(const int& index, const std::string& var_name) = 0;

protected:

/** Object to help with converting numeric output values to text. */
Expand Down
33 changes: 0 additions & 33 deletions include/realizations/catchment/Bmi_Module_Formulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,39 +462,6 @@ namespace realization {
const time_t &get_bmi_model_start_time_forcing_offset_s() override {
return bmi_model_start_time_forcing_offset_s;
}

/**
* Get value for some BMI model variable.
*
* This function assumes that the given variable, while returned by the model within an array per the BMI spec,
* is actual a single, scalar value. Thus, it returns what is at index 0 of the array reference.
*
* @param index
* @param var_name
* @return
*/
virtual double get_var_value_as_double(const std::string& var_name) = 0;

/**
* Get value for some BMI model variable at a specific index.
*
* Function gets the value for a provided variable, returned from the backing model as an array, and returns the
* specific value at the desired index cast as a double type.
*
* The function makes several assumptions:
*
* 1. `index` is within array bounds
* 2. `var_name` is in the set of valid variable names for the model
* 3. the type for output variable allows the value to be cast to a `double` appropriately
*
* It falls to user (functions) of this function to ensure these assumptions hold before invoking.
*
* @param index
* @param var_name
* @return
*/
virtual double get_var_value_as_double(const int& index, const std::string& var_name) = 0;

/**
* Universal logic applied when creating a BMI-backed formulation from NGen config.
*
Expand Down
4 changes: 2 additions & 2 deletions include/realizations/catchment/Bmi_Multi_Formulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ namespace realization {
* @param var_name
* @return
*/
double get_var_value_as_double(const std::string &var_name) {
double get_var_value_as_double(const std::string &var_name) override {
return get_var_value_as_double(0, var_name);
}

Expand Down Expand Up @@ -574,7 +574,7 @@ namespace realization {
* @param var_name
* @return
*/
double get_var_value_as_double(const int& index, const std::string& var_name) {
double get_var_value_as_double(const int& index, const std::string& var_name) override {
auto data_provider_iter = availableData.find(var_name);
if (data_provider_iter == availableData.end()) {
throw external::ExternalIntegrationException(
Expand Down