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

Formulation cleanup #796

Merged
merged 3 commits into from
Apr 19, 2024
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
9 changes: 1 addition & 8 deletions include/realizations/catchment/Bmi_Multi_Formulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,12 +531,6 @@ namespace realization {
*/
void create_multi_formulation(geojson::PropertyMap properties, bool needs_param_validation);

template<class T>
double get_module_var_value_as_double(const std::string &var_name, std::shared_ptr<Bmi_Formulation> mod) {
std::shared_ptr<T> module = std::static_pointer_cast<T>(mod);
return module->get_var_value_as_double(var_name);
}

/**
* Get value for some BMI model variable.
*
Expand Down Expand Up @@ -583,8 +577,7 @@ namespace realization {
}
// Otherwise, we have a provider, and we can cast it based on the documented assumptions
try {
std::shared_ptr <data_access::GenericDataProvider> nested_module =
std::dynamic_pointer_cast<data_access::GenericDataProvider>(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
Expand Down
5 changes: 0 additions & 5 deletions include/realizations/catchment/Formulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
23 changes: 2 additions & 21 deletions src/realizations/catchment/Bmi_Multi_Formulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Bmi_Cpp_Formulation>(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<Bmi_C_Formulation>(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<Bmi_Fortran_Formulation>(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<Bmi_Py_Formulation>(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) {
Expand Down
Loading