6#include "LayerData.hpp"
7#include "Simulation_Time.hpp"
8#include "State_Exception.hpp"
11#include "HY_Features_MPI.hpp"
13#include "HY_Features.hpp"
31 const std::vector<std::string>& p_u,
118 auto r_c = std::dynamic_pointer_cast<realization::Catchment_Formulation>(r);
119 double response(0.0);
124 std::string msg = e.
what();
126 +
" ("+current_timestamp+
")"
127 +
" at feature id "+id;
130 std::string output = std::to_string(
output_time_index)+
","+current_timestamp+
","+
132 r_c->write_output(output);
136 area =
catchment_data->get_feature(
id)->get_property(
"areasqkm").as_real_number();
138 catch(std::invalid_argument &e)
140 area =
catchment_data->get_feature(
id)->get_property(
"area_sqkm").as_real_number();
142 double response_m_s = response * (area * 1000000);
147 double response_m_h = response_m_s / 3600.0;
153 if(nexus ==
nullptr){
154 throw std::runtime_error(
"Invalid (null) nexus instantiation downstream of "+
id+
". "+SOURCE_LOC);
Simulation Time class providing time-series variables and methods to the model.
Definition Simulation_Time.hpp:48
int get_output_interval_seconds()
Accessor to the output_interval_seconds.
Definition Simulation_Time.hpp:90
int get_total_output_times()
Accessor to the total number of time steps.
Definition Simulation_Time.hpp:81
void advance_timestep()
move this simulation time object to represent the next time step as the current time
Definition Simulation_Time.hpp:155
time_t get_current_epoch_time()
Accessor to the the current simulation time.
Definition Simulation_Time.hpp:100
std::string get_timestamp(int current_output_time_index)
Accessor to the current timestamp string.
Definition Simulation_Time.hpp:109
int next_timestep_index(int epoch_time_seconds)
Definition Simulation_Time.hpp:129
time_t next_timestep_epoch_time(int epoch_time_seconds)
Definition Simulation_Time.hpp:139
Collection interface to HY_Features objects and their associated model formulations.
Definition HY_Features.hpp:41
std::vector< std::shared_ptr< HY_HydroNexus > > destination_nexuses(const std::string &id)
Get a vector of destination (downstream) nexus pointers.
Definition HY_Features.hpp:152
std::shared_ptr< HY_CatchmentRealization > catchment_at(std::string id)
Get the HY_CatchmentRealization pointer identified by id.
Definition HY_Features.hpp:82
Custom exception indicating bad external model state.
Definition State_Exception.hpp:18
virtual char const * what() const noexcept override
Definition State_Exception.hpp:32
const double get_time_step() const
Return this time_step interval used for this layer.
Definition Layer.hpp:94
time_t current_timestep_epoch_time()
Return the last timestep that was processed by this layer in epoch time units.
Definition Layer.hpp:78
long output_time_index
Definition Layer.hpp:182
Layer(const LayerDescription &desc, const Simulation_Time &s_t, feature_type &f, long idx)
Construct a minimum layer object.
Definition Layer.hpp:54
feature_type & features
Definition Layer.hpp:179
const std::string & get_time_step_units() const
Return the units for the time_step value of this layer.
Definition Layer.hpp:99
const geojson::GeoJSON catchment_data
Definition Layer.hpp:181
const std::vector< std::string > processing_units
Definition Layer.hpp:177
const LayerDescription description
Definition Layer.hpp:174
virtual ~Layer()
Definition Layer.hpp:67
Simulation_Time simulation_time
Definition Layer.hpp:178
time_t next_timestep_epoch_time()
Return the next timestep that will be processed by this layer in epoch time units.
Definition Layer.hpp:72
int get_id() const
Return the numeric id of this layer.
Definition Layer.hpp:84
const std::string & get_name() const
Return the name of this layer.
Definition Layer.hpp:89
Layer(const LayerDescription &desc, const std::vector< std::string > &p_u, const Simulation_Time &s_t, feature_type &f, geojson::GeoJSON cd, long idx)
Definition Layer.hpp:29
virtual void update_models()
Run one simulation timestep for each model in this layer.
Definition Layer.hpp:104
std::shared_ptr< FeatureCollection > GeoJSON
Easy short-hand for a smart pointer to a FeatureCollection.
Definition FeatureBuilder.hpp:21
Definition DomainLayer.hpp:9
A simple structure to hold meta data related to a computational layer.
Definition LayerData.hpp:18
std::string time_step_units
Definition LayerData.hpp:20
double time_step
Definition LayerData.hpp:22
std::string name
Definition LayerData.hpp:19
int id
Definition LayerData.hpp:21