From cf28f53b35609803aec6b78120488c2540e20739 Mon Sep 17 00:00:00 2001 From: Phil Miller Date: Thu, 18 Apr 2024 14:16:31 -0700 Subject: [PATCH 1/3] Formulation: Drop unused public member --- include/realizations/catchment/Formulation.hpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/include/realizations/catchment/Formulation.hpp b/include/realizations/catchment/Formulation.hpp index 161252e16f..ed73fa634b 100644 --- a/include/realizations/catchment/Formulation.hpp +++ b/include/realizations/catchment/Formulation.hpp @@ -53,11 +53,6 @@ namespace realization { */ virtual double get_response(time_step_t t_index, time_step_t d_delta_s) = 0; - // TODO: look at adding another overloaded function that uses instance members to get the index and delta - - // The neccessity of this function is in question - virtual void add_time(time_t t, double n){}; - std::string get_id() const { return this->id; } From 0031697791c17d10b3f4326835e0f450add3e73e Mon Sep 17 00:00:00 2001 From: Phil Miller Date: Thu, 18 Apr 2024 14:52:19 -0700 Subject: [PATCH 2/3] BMI_Multi_Formulation: get rid of code to perform pointless down-casts --- .../catchment/Bmi_Multi_Formulation.hpp | 6 ----- .../catchment/Bmi_Multi_Formulation.cpp | 23 ++----------------- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/include/realizations/catchment/Bmi_Multi_Formulation.hpp b/include/realizations/catchment/Bmi_Multi_Formulation.hpp index 920b5eb9a2..8db0983bb2 100644 --- a/include/realizations/catchment/Bmi_Multi_Formulation.hpp +++ b/include/realizations/catchment/Bmi_Multi_Formulation.hpp @@ -531,12 +531,6 @@ namespace realization { */ void create_multi_formulation(geojson::PropertyMap properties, bool needs_param_validation); - template - double get_module_var_value_as_double(const std::string &var_name, std::shared_ptr mod) { - std::shared_ptr module = std::static_pointer_cast(mod); - return module->get_var_value_as_double(var_name); - } - /** * Get value for some BMI model variable. * diff --git a/src/realizations/catchment/Bmi_Multi_Formulation.cpp b/src/realizations/catchment/Bmi_Multi_Formulation.cpp index 29f7f2b0e5..ab04392eef 100644 --- a/src/realizations/catchment/Bmi_Multi_Formulation.cpp +++ b/src/realizations/catchment/Bmi_Multi_Formulation.cpp @@ -388,27 +388,8 @@ double Bmi_Multi_Formulation::get_response(time_step_t t_index, time_step_t t_de } } } - // With the module index, we can also pick the type - if (module_types[index] == "bmi_c++") { - return get_module_var_value_as_double(get_bmi_main_output_var(), modules[index]); - } - #ifdef NGEN_BMI_C_LIB_ACTIVE - if (module_types[index] == "bmi_c") { - return get_module_var_value_as_double(get_bmi_main_output_var(), modules[index]); - } - #endif // NGEN_BMI_C_LIB_ACTIVE - #ifdef NGEN_BMI_FORTRAN_ACTIVE - if (module_types[index] == "bmi_fortran") { - return get_module_var_value_as_double(get_bmi_main_output_var(), modules[index]); - } - #endif // NGEN_BMI_FORTRAN_ACTIVE - #ifdef ACTIVATE_PYTHON - if (module_types[index] == "bmi_python") { - return get_module_var_value_as_double(get_bmi_main_output_var(), modules[index]); - } - #endif // ACTIVATE_PYTHON - throw std::runtime_error(get_formulation_type() + " unimplemented type " + module_types[index] + - " in get_response for main return value"); + + return modules[index]->get_var_value_as_double(get_bmi_main_output_var()); } bool Bmi_Multi_Formulation::is_bmi_input_variable(const std::string &var_name) { From 559de3a9f1a9f495d6ecd5bdcaea431e063bdd99 Mon Sep 17 00:00:00 2001 From: Phil Miller Date: Thu, 18 Apr 2024 15:15:39 -0700 Subject: [PATCH 3/3] BMI_Multi_Formulation: Drop another silly cast --- include/realizations/catchment/Bmi_Multi_Formulation.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/realizations/catchment/Bmi_Multi_Formulation.hpp b/include/realizations/catchment/Bmi_Multi_Formulation.hpp index 8db0983bb2..accac74703 100644 --- a/include/realizations/catchment/Bmi_Multi_Formulation.hpp +++ b/include/realizations/catchment/Bmi_Multi_Formulation.hpp @@ -577,8 +577,7 @@ namespace realization { } // Otherwise, we have a provider, and we can cast it based on the documented assumptions try { - std::shared_ptr nested_module = - std::dynamic_pointer_cast(data_provider_iter->second); + auto const& nested_module = data_provider_iter->second; long nested_module_time = nested_module->get_data_start_time() + ( this->get_model_current_time() - this->get_model_start_time() ); auto selector = CatchmentAggrDataSelector(this->get_catchment_id(),var_name,nested_module_time,this->record_duration(),"1"); //TODO: After merge PR#405, try re-adding support for index