NGen
Loading...
Searching...
No Matches
Layer.hpp
1#ifndef __NGEN_LAYER__
2#define __NGEN_LAYER__
3
4#include <NGenConfig.h>
5
6#include "LayerData.hpp"
7#include "Simulation_Time.hpp"
8#include "State_Exception.hpp"
9#include "geojson/FeatureBuilder.hpp"
10#include <boost/core/span.hpp>
11#include <memory>
12
13namespace hy_features
14{
15 class HY_Features;
16 class HY_Features_MPI;
17}
18
19namespace utils { class CatchmentOutputsMgr; }
20
21namespace ngen
22{
23
24 class Layer
25 {
26 public:
27
28 #if NGEN_WITH_MPI
29 using feature_type = hy_features::HY_Features_MPI;
30 #else
32 #endif
33
35 const LayerDescription& desc,
36 const std::vector<std::string>& p_u,
37 const Simulation_Time& s_t,
38 feature_type& f,
40 long idx,
41 std::shared_ptr<utils::CatchmentOutputsMgr> cat_output_mgr) :
42 description(desc),
44 simulation_time(s_t),
45 features(f),
48 catchment_output_mgr(cat_output_mgr)
49 {
50
51 }
52
63 const LayerDescription& desc,
64 const Simulation_Time& s_t,
65 feature_type& f,
66 long idx,
67 std::shared_ptr<utils::CatchmentOutputsMgr> cat_output_mgr) :
68 description(desc),
69 simulation_time(s_t),
70 features(f),
72 catchment_output_mgr(cat_output_mgr)
73 {
74
75 }
76
77 virtual ~Layer(); // out-of-line; see Layer.cpp
78
79
83
84
85
89
90
91
94 int get_id() const { return this->description.id; }
95
96
99 const std::string& get_name() const { return this->description.name; }
100
101
104 const double get_time_step() const { return this->description.time_step; }
105
106
109 const std::string& get_time_step_units() const { return this->description.time_step_units; }
110
111
114 virtual void update_models(boost::span<double> catchment_outflows,
115 std::unordered_map<std::string, int> const& catchment_indexes,
116 boost::span<double> nexus_downstream_flows,
117 std::unordered_map<std::string, int> const& nexus_indexes,
118 int current_step);
119
120 protected:
121
123 //TODO is this really required at the top level?
124 //See "minimum" constructor above used for DomainLayer impl...
125 const std::vector<std::string> processing_units;
128 //TODO is this really required at the top level? or can this be moved to SurfaceLayer?
132 std::shared_ptr<utils::CatchmentOutputsMgr> catchment_output_mgr = nullptr;
133
134 };
135}
136
137#endif
Simulation Time class providing time-series variables and methods to the model.
Definition Simulation_Time.hpp:48
time_t next_timestep_epoch_time(int epoch_time_seconds) const
Definition Simulation_Time.hpp:139
time_t get_current_epoch_time() const
Accessor to the the current simulation time.
Definition Simulation_Time.hpp:100
Collection interface to HY_Features objects and their associated model formulations.
Definition HY_Features.hpp:46
Definition Layer.hpp:25
const double get_time_step() const
Return this time_step interval used for this layer.
Definition Layer.hpp:104
virtual void update_models(boost::span< double > catchment_outflows, std::unordered_map< std::string, int > const &catchment_indexes, boost::span< double > nexus_downstream_flows, std::unordered_map< std::string, int > const &nexus_indexes, int current_step)
Run one simulation timestep for each model in this layer.
Definition Layer.cpp:15
time_t current_timestep_epoch_time()
Return the last timestep that was processed by this layer in epoch time units.
Definition Layer.hpp:88
long output_time_index
Definition Layer.hpp:130
feature_type & features
Definition Layer.hpp:127
const std::string & get_time_step_units() const
Return the units for the time_step value of this layer.
Definition Layer.hpp:109
std::shared_ptr< utils::CatchmentOutputsMgr > catchment_output_mgr
Catchment output sink for this layer's per-timestep push; null when output is disabled.
Definition Layer.hpp:132
const geojson::GeoJSON catchment_data
Definition Layer.hpp:129
const std::vector< std::string > processing_units
Definition Layer.hpp:125
const LayerDescription description
Definition Layer.hpp:122
Layer(const LayerDescription &desc, const Simulation_Time &s_t, feature_type &f, long idx, std::shared_ptr< utils::CatchmentOutputsMgr > cat_output_mgr)
Construct a minimum layer object.
Definition Layer.hpp:62
Layer(const LayerDescription &desc, const std::vector< std::string > &p_u, const Simulation_Time &s_t, feature_type &f, geojson::GeoJSON cd, long idx, std::shared_ptr< utils::CatchmentOutputsMgr > cat_output_mgr)
Definition Layer.hpp:34
Simulation_Time simulation_time
Definition Layer.hpp:126
time_t next_timestep_epoch_time()
Return the next timestep that will be processed by this layer in epoch time units.
Definition Layer.hpp:82
int get_id() const
Return the numeric id of this layer.
Definition Layer.hpp:94
const std::string & get_name() const
Return the name of this layer.
Definition Layer.hpp:99
virtual ~Layer()
Abstract class for managing and writing to catchment data files.
Definition CatchmentOutputsMgr.hpp:48
std::shared_ptr< FeatureCollection > GeoJSON
Easy short-hand for a smart pointer to a FeatureCollection.
Definition FeatureBuilder.hpp:21
HY_HydroLocation: class representing a hydrologic position.
Definition HY_Features.hpp:17
Definition DomainLayer.hpp:13
Definition Layer.hpp:19
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