|
NGen
|
A model attached to a feature: what is run for that feature, and what it emits. More...
#include <Formulation.hpp>
Inheritance diagram for realization::Formulation:
Collaboration diagram for realization::Formulation:Public Types | |
| typedef long | time_step_t |
Public Member Functions | |||||||||||||||||
| Formulation (const std::string &id, std::shared_ptr< data_access::GenericDataProvider > forcing) | |||||||||||||||||
| Formulation (const std::string &id) | |||||||||||||||||
| virtual | ~Formulation () | ||||||||||||||||
| virtual std::string | get_formulation_type () const =0 | ||||||||||||||||
Identity | |||||||||||||||||
Three roles, not three independent names. A formulation has a subject, a locator, and an identity made of the two:
Subject and locator diverge only when one formulation composes another. The composer builds each module's locator from its own locator and that module's index within it, so a multi on A domain layer has no hydrofabric feature, but the layer is still what its model belongs to, so it stands as the subject. | |||||||||||||||||
| std::string | get_id () const | ||||||||||||||||
| See Identity. | |||||||||||||||||
| virtual void | create_formulation (boost::property_tree::ptree &config, geojson::PropertyMap *global=nullptr)=0 | ||||||||||||||||
| See Identity. | |||||||||||||||||
| virtual void | create_formulation (geojson::PropertyMap properties)=0 | ||||||||||||||||
| See Identity. | |||||||||||||||||
| virtual void | check_mass_balance (const int &iteration, const int &total_steps, const std::string ×tamp) const =0 | ||||||||||||||||
| See Identity. | |||||||||||||||||
| virtual void | checkpoint_state (const int &iteration, const int &total_steps, const std::string ×tamp) const =0 | ||||||||||||||||
| Invoke the state-save side of the ngen BMI Serialization Protocol. | |||||||||||||||||
| virtual void | update (time_step_t t_index, time_step_t t_delta)=0 | ||||||||||||||||
| Advance the backing model formulation through the given time step. | |||||||||||||||||
| virtual double | get_response (time_step_t t_index, time_step_t t_delta)=0 | ||||||||||||||||
| Execute the backing model formulation for the given time step, where it is of the specified size, and return the response output. | |||||||||||||||||
| virtual std::vector< utils::OutputField > | get_output_fields () const =0 | ||||||||||||||||
| Get this formulation's output fields – name plus metadata (units, ...) – in the same order as the values returned by get_output_values_for_timestep. | |||||||||||||||||
| virtual std::vector< double > | get_output_values_for_timestep (int timestep)=0 | ||||||||||||||||
| Get the output values for the given time step, positionally aligned with get_output_fields. | |||||||||||||||||
| void | finalize () | ||||||||||||||||
| Release resources of the given forcing provider. | |||||||||||||||||
| const std::string & | get_feature_id () const | ||||||||||||||||
| The feature whose data this model reads and produces; see Identity. | |||||||||||||||||
| void | set_feature_id (const std::string &feature_id) | ||||||||||||||||
| Associate this formulation with a feature other than the one it is named for. | |||||||||||||||||
Protected Member Functions | |
| virtual const std::vector< std::string > & | get_required_parameters () const =0 |
| geojson::PropertyMap | interpret_parameters (boost::property_tree::ptree &config, geojson::PropertyMap *global=nullptr) |
| void | validate_parameters (geojson::PropertyMap options) |
Protected Attributes | |
| std::string | id |
| This formulation's locator; see get_id. | |
| std::shared_ptr< data_access::GenericDataProvider > | forcing |
Private Attributes | |
| std::string | feature_id |
| This formulation's subject; see get_feature_id. | |
A model attached to a feature: what is run for that feature, and what it emits.
A formulation is driven by a forcing provider, advances a time step at a time, and emits a set of named output fields. It is identified both by its own id and by the id of the feature it is attached to, which an HY_CatchmentRealization uses to realize that feature.
| realization::Formulation::Formulation | ( | const std::string & | id, |
| std::shared_ptr< data_access::GenericDataProvider > | forcing ) |
| realization::Formulation::Formulation | ( | const std::string & | id | ) |
|
inlinevirtual |
|
pure virtual |
See Identity.
Implemented in Depth_Formulation, realization::Bmi_Module_Formulation, and realization::Bmi_Multi_Formulation.
|
pure virtual |
Invoke the state-save side of the ngen BMI Serialization Protocol.
Called from the per-timestep driver (see core/Layer.cpp) alongside check_mass_balance. Implementations build a protocol Context from the arguments and the formulation's own compound identity, then forward to the NgenBmiProtocols container. Non-BMI formulations may implement as a no-op; unconfigured save protocols short-circuit inside run() so the cost is just the virtual dispatch.
Implemented in Depth_Formulation, realization::Bmi_Module_Formulation, and realization::Bmi_Multi_Formulation.
|
pure virtual |
See Identity.
Implemented in Depth_Formulation, realization::Bmi_Module_Formulation, and realization::Bmi_Multi_Formulation.
|
pure virtual |
See Identity.
Implemented in Depth_Formulation, realization::Bmi_Module_Formulation, and realization::Bmi_Multi_Formulation.
| void realization::Formulation::finalize | ( | ) |
Release resources of the given forcing provider.
References forcing.
|
inline |
The feature whose data this model reads and produces; see Identity.
References feature_id.
Referenced by realization::Bmi_Module_Formulation::get_output_values_for_timestep(), realization::Bmi_Multi_Formulation::get_output_values_for_timestep(), realization::Bmi_Module_Formulation::get_response(), realization::Bmi_Multi_Formulation::get_response(), realization::Bmi_Multi_Formulation::init_nested_module(), and realization::Bmi_Module_Formulation::perform_set().
|
pure virtual |
Implemented in Depth_Formulation, realization::Bmi_C_Formulation, realization::Bmi_Cpp_Formulation, and realization::Bmi_Multi_Formulation.
Referenced by realization::Bmi_Module_Formulation::get_value(), realization::Bmi_Module_Formulation::get_values(), realization::Bmi_Module_Formulation::update(), and validate_parameters().
|
inline |
See Identity.
References id.
Referenced by realization::Bmi_Multi_Formulation::create_multi_formulation().
|
pure virtual |
Get this formulation's output fields – name plus metadata (units, ...) – in the same order as the values returned by get_output_values_for_timestep.
The name is the output header field (configured, or defaulting to the output variable name); the units come from the same source that produces each value. So each field is positionally aligned with, and describes, the corresponding value.
Implemented in Depth_Formulation, realization::Bmi_Module_Formulation, and realization::Bmi_Multi_Formulation.
|
pure virtual |
Get the output values for the given time step, positionally aligned with get_output_fields.
Values are returned as raw doubles, with no formatting or precision applied by the formulation.
| timestep | The time step for which values are desired. |
timestep, one per output column. Implemented in Depth_Formulation, realization::Bmi_Module_Formulation, and realization::Bmi_Multi_Formulation.
Referenced by ngen::DomainLayer::update_models().
|
protectedpure virtual |
Implemented in Depth_Formulation, realization::Bmi_Formulation, and realization::Bmi_Module_Formulation.
Referenced by validate_parameters().
|
pure virtual |
Execute the backing model formulation for the given time step, where it is of the specified size, and return the response output.
Advances the model as update does, and additionally reduces its state to one value. Callers that only need the model stepped should use update instead. This function should be implemented and used when a single-value representation of the model's state is required.
Any inputs and additional parameters must be made available as instance members.
The response is a depth, in meters. Implementations are responsible for converting it: the BMI ones ask their model for "m" and convert from whatever it declares in GetVarUnits. HY_CatchmentRealization takes that for granted when it records the response as a depth, and HY_CatchmentArea multiplies it by an area in m^2.
Types should clearly document anything further about their particular response.
| t_index | The index of the time step for which to run model calculations. |
| t_delta | The duration, in seconds, of the time step for which to run model calculations. |
Implemented in Depth_Formulation, realization::Bmi_Module_Formulation, and realization::Bmi_Multi_Formulation.
Referenced by HY_CatchmentRealization::get_response().
|
protected |
References validate_parameters().
Referenced by realization::Bmi_Module_Formulation::create_formulation(), and realization::Bmi_Multi_Formulation::create_formulation().
|
inline |
Associate this formulation with a feature other than the one it is named for.
For a formulation composing others: a nested module's id names its position within the composition, so the composing formulation gives it the feature they share.
References feature_id.
|
pure virtual |
Advance the backing model formulation through the given time step.
| t_index | The index of the time step to run. |
| t_delta | The duration, in seconds, of that time step. |
Implemented in Depth_Formulation, realization::Bmi_Formulation, realization::Bmi_Module_Formulation, and realization::Bmi_Multi_Formulation.
Referenced by ngen::DomainLayer::update_models().
|
protected |
|
private |
This formulation's subject; see get_feature_id.
Referenced by get_feature_id(), and set_feature_id().
|
protected |
Referenced by realization::Bmi_Multi_Formulation::create_multi_formulation(), realization::Bmi_Module_Formulation::determine_model_time_offset(), finalize(), realization::Bmi_Module_Formulation::get_provider_for_input_var(), realization::Bmi_Multi_Formulation::get_variable_time_begin(), realization::Bmi_Multi_Formulation::get_variable_time_end(), and realization::Bmi_Module_Formulation::inner_create_formulation().
|
protected |