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 <span>
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,
39 long idx,
40 std::shared_ptr<utils::CatchmentOutputsMgr> cat_output_mgr) :
41 description(desc),
43 simulation_time(s_t),
44 features(f),
46 catchment_output_mgr(cat_output_mgr)
47 {
48
49 }
50
61 const LayerDescription& desc,
62 const Simulation_Time& s_t,
63 feature_type& f,
64 long idx,
65 std::shared_ptr<utils::CatchmentOutputsMgr> cat_output_mgr) :
66 description(desc),
67 simulation_time(s_t),
68 features(f),
70 catchment_output_mgr(cat_output_mgr)
71 {
72
73 }
74
75 virtual ~Layer(); // out-of-line; see Layer.cpp
76
77
81
82
83
87
88
89
92 int get_id() const { return this->description.id; }
93
94
97 const std::string& get_name() const { return this->description.name; }
98
99
102 const double get_time_step() const { return this->description.time_step; }
103
104
107 const std::string& get_time_step_units() const { return this->description.time_step_units; }
108
109
112 virtual void update_models(std::span<double> catchment_outflows,
113 std::unordered_map<std::string, int> const& catchment_indexes,
114 std::span<double> nexus_downstream_flows,
115 std::unordered_map<std::string, int> const& nexus_indexes,
116 int current_step);
117
118 protected:
119
121 //TODO is this really required at the top level?
122 //See "minimum" constructor above used for DomainLayer impl...
123 const std::vector<std::string> processing_units;
128 std::shared_ptr<utils::CatchmentOutputsMgr> catchment_output_mgr = nullptr;
129
130 };
131}
132
133#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:47
Definition Layer.hpp:25
Layer(const LayerDescription &desc, const std::vector< std::string > &p_u, const Simulation_Time &s_t, feature_type &f, long idx, std::shared_ptr< utils::CatchmentOutputsMgr > cat_output_mgr)
Definition Layer.hpp:34
const double get_time_step() const
Return this time_step interval used for this layer.
Definition Layer.hpp:102
time_t current_timestep_epoch_time()
Return the last timestep that was processed by this layer in epoch time units.
Definition Layer.hpp:86
long output_time_index
Definition Layer.hpp:126
feature_type & features
Definition Layer.hpp:125
const std::string & get_time_step_units() const
Return the units for the time_step value of this layer.
Definition Layer.hpp:107
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:128
const std::vector< std::string > processing_units
Definition Layer.hpp:123
const LayerDescription description
Definition Layer.hpp:120
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:60
Simulation_Time simulation_time
Definition Layer.hpp:124
virtual void update_models(std::span< double > catchment_outflows, std::unordered_map< std::string, int > const &catchment_indexes, std::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:19
time_t next_timestep_epoch_time()
Return the next timestep that will be processed by this layer in epoch time units.
Definition Layer.hpp:80
int get_id() const
Return the numeric id of this layer.
Definition Layer.hpp:92
const std::string & get_name() const
Return the name of this layer.
Definition Layer.hpp:97
virtual ~Layer()
Abstract class for managing and writing to catchment data files.
Definition CatchmentOutputsMgr.hpp:48
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