OpenSWMM Engine  6.0.0-alpha.3
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.3)
Loading...
Searching...
No Matches
SimulationSnapshot.hpp
Go to the documentation of this file.
1
25
26#ifndef OPENSWMM_SIMULATION_SNAPSHOT_HPP
27#define OPENSWMM_SIMULATION_SNAPSHOT_HPP
28
29#include <vector>
30#include <string>
31#include <cstdint>
32
33namespace openswmm {
34
35// NOTE ON UNITS: the 1D node / link / subcatchment / gage / system fields below
36// are delivered in PROJECT DISPLAY units (e.g. m, m³, CMS for an SI project;
37// ft, ft³, CFS for US). The engine applies a single conversion boundary
38// (convertSnapshotToDisplay) when building the snapshot, so output plugins
39// write values directly without re-applying Ucf/Qcf. Dimensionless fields
40// (capacity, soil moisture, pollutant concentrations) are unconverted. The 2D
41// surface_* arrays on SimulationSnapshot are the exception: they are SI-native
42// solver outputs and are NOT touched by the boundary.
43
49 std::vector<double> depth;
50 std::vector<double> head;
51 std::vector<double> volume;
52 std::vector<double> lateral_inflow;
53 std::vector<double> total_inflow;
54 std::vector<double> overflow;
55};
56
62 std::vector<double> flow;
63 std::vector<double> depth;
64 std::vector<double> velocity;
65 std::vector<double> volume;
66 std::vector<double> capacity;
67};
68
74 std::vector<double> rainfall;
75 std::vector<double> snow_depth;
76 std::vector<double> evap;
77 std::vector<double> infil;
78 std::vector<double> runoff;
79 std::vector<double> gw_flow;
80 std::vector<double> gw_elev;
81 std::vector<double> soil_moist;
82};
83
89 std::vector<double> rainfall;
90};
91
102 // -----------------------------------------------------------------------
103 // Timing
104 // -----------------------------------------------------------------------
105
107 double sim_time = 0.0;
108
110 std::int64_t wall_time_unix = 0;
111
114
115 // -----------------------------------------------------------------------
116 // Object counts
117 // -----------------------------------------------------------------------
118
119 int node_count = 0;
120 int link_count = 0;
122 int gage_count = 0;
123 int pollut_count = 0;
124
125 // -----------------------------------------------------------------------
126 // State arrays (parallel to the engine's SoA arrays)
127 // -----------------------------------------------------------------------
128
133
134 // -----------------------------------------------------------------------
135 // System-level results (for binary output file)
136 // -----------------------------------------------------------------------
137
138 double sys_temperature = 0.0;
139 double sys_rainfall = 0.0;
140 double sys_snow_depth = 0.0;
141 double sys_evap = 0.0;
142 double sys_infil = 0.0;
143 double sys_runoff = 0.0;
144 double sys_dw_inflow = 0.0;
145 double sys_gw_inflow = 0.0;
146 double sys_ii_inflow = 0.0;
147 double sys_ext_inflow = 0.0;
148 double sys_flooding = 0.0;
149 double sys_outflow = 0.0;
150 double sys_storage = 0.0;
151 double sys_pet = 0.0;
152
153 // -----------------------------------------------------------------------
154 // Pollutant concentrations (optional; populated only if quality routing active)
155 // -----------------------------------------------------------------------
156
162 std::vector<double> node_quality;
163
168 std::vector<double> link_quality;
169
173 std::vector<double> subcatch_quality;
174
175 // -----------------------------------------------------------------------
176 // String tables (for plugins that need to label their output)
177 // -----------------------------------------------------------------------
178
180 const std::vector<std::string>* node_ids = nullptr;
181
183 const std::vector<std::string>* link_ids = nullptr;
184
186 const std::vector<std::string>* subcatch_ids = nullptr;
187
189 const std::vector<std::string>* gage_ids = nullptr;
190
192 const std::vector<std::string>* pollut_names = nullptr;
193
194 // -----------------------------------------------------------------------
195 // Unit information
196 // -----------------------------------------------------------------------
197
199 const char* flow_units = nullptr;
200
202 const char* length_units = nullptr;
203
206
207 // -----------------------------------------------------------------------
208 // 2D surface routing state (optional; populated only when the engine was
209 // built with OPENSWMM_BUILD_2D and the input file contains a 2D mesh)
210 //
211 // Layout: per-triangle vectors are sized `surface_tri_count`; per-vertex
212 // vectors are sized `surface_vert_count`. `surface_edge_flux` is flat
213 // [tri * 3 + edge] of size `surface_tri_count * 3`.
214 //
215 // Fields are deep-copied from `SurfaceRouter2D::state()` on the main
216 // simulation thread; consumers (Default2DOutputPlugin and any third-party
217 // 2D output plugins) read them through the IO-thread snapshot reference
218 // without further synchronization.
219 //
220 // Vectors are empty when 2D is inactive (either OPENSWMM_BUILD_2D=OFF or
221 // the input file contained no [2D_VERTICES] section). Plugins must check
222 // `surface_tri_count == 0` to skip 2D-specific work in that case.
223 // -----------------------------------------------------------------------
224
227
228 std::vector<double> surface_depth;
229 std::vector<double> surface_head;
230 std::vector<double> surface_grad_hx;
231 std::vector<double> surface_grad_hy;
232 std::vector<double> surface_grad_hx_lim;
233 std::vector<double> surface_grad_hy_lim;
234 std::vector<double> surface_rainfall;
235 std::vector<double> surface_coupling_flux;
236 std::vector<double> surface_net_source;
237 std::vector<double> surface_edge_flux;
238 std::vector<double> surface_vert_head;
239 std::vector<double> surface_face_vx;
240 std::vector<double> surface_face_vy;
241 std::vector<double> surface_continuity_err;
242
243 // Cumulative rendering envelopes (SI-native, monotone over the run), per face.
244 // A snapshot of these at any time is the envelope up to that time; the 2D
245 // output plugin overwrites the fixed [nFace] envelope datasets in place.
246 std::vector<double> surface_stat_max_depth;
247 std::vector<double> surface_stat_max_velocity;
248 std::vector<double> surface_stat_max_cont_err;
249};
250
251} /* namespace openswmm */
252
253#endif /* OPENSWMM_SIMULATION_SNAPSHOT_HPP */
Definition NodeCoupling.cpp:15
Snapshot of rain gage state at an output time step.
Definition SimulationSnapshot.hpp:88
std::vector< double > rainfall
Current rainfall rate [project rate units].
Definition SimulationSnapshot.hpp:89
Snapshot of node state at an output time step.
Definition SimulationSnapshot.hpp:48
std::vector< double > volume
Stored volume [display volume units].
Definition SimulationSnapshot.hpp:51
std::vector< double > lateral_inflow
Lateral inflow [display flow units].
Definition SimulationSnapshot.hpp:52
std::vector< double > total_inflow
Total inflow [display flow units].
Definition SimulationSnapshot.hpp:53
std::vector< double > head
Hydraulic head [display length units].
Definition SimulationSnapshot.hpp:50
std::vector< double > overflow
Overflow / surcharge [display flow units].
Definition SimulationSnapshot.hpp:54
std::vector< double > depth
Water depth [display length units].
Definition SimulationSnapshot.hpp:49
Complete simulation state snapshot at one output time step.
Definition SimulationSnapshot.hpp:101
std::vector< double > subcatch_quality
Subcatchment pollutant loadings.
Definition SimulationSnapshot.hpp:173
const std::vector< std::string > * gage_ids
Gage IDs in index order.
Definition SimulationSnapshot.hpp:189
std::vector< double > surface_edge_flux
Normal flux through each edge, flat [tri*3+edge].
Definition SimulationSnapshot.hpp:237
SubcatchSnapshot subcatch
Subcatchment state.
Definition SimulationSnapshot.hpp:131
std::vector< double > surface_stat_max_depth
Max overland depth ψ_o (m), per face.
Definition SimulationSnapshot.hpp:246
LinkSnapshot links
Link state.
Definition SimulationSnapshot.hpp:130
GageSnapshot gages
Gage state.
Definition SimulationSnapshot.hpp:132
int surface_vert_count
Number of vertices (nodes)
Definition SimulationSnapshot.hpp:226
const char * flow_units
Flow unit string (e.g., "CFS", "LPS").
Definition SimulationSnapshot.hpp:199
double sys_gw_inflow
Total groundwater inflow.
Definition SimulationSnapshot.hpp:145
double sys_ext_inflow
Total external inflow.
Definition SimulationSnapshot.hpp:147
std::vector< double > surface_grad_hy
Unlimited head gradient ∂h/∂y, per face.
Definition SimulationSnapshot.hpp:231
int link_count
Number of links.
Definition SimulationSnapshot.hpp:120
std::vector< double > surface_rainfall
Rainfall intensity (m/s), per face.
Definition SimulationSnapshot.hpp:234
double sys_pet
Potential evapotranspiration.
Definition SimulationSnapshot.hpp:151
double sys_outflow
Total outflow.
Definition SimulationSnapshot.hpp:149
std::vector< double > surface_face_vy
Cell-centred velocity Y (m/s), per face.
Definition SimulationSnapshot.hpp:240
int flow_units_code
Flow units code (FlowUnits enum value: 0=CFS, 3=CMS, etc.).
Definition SimulationSnapshot.hpp:205
double sim_time
Simulation date/time (SWMM DateTime: days since 12/31/1899).
Definition SimulationSnapshot.hpp:107
std::vector< double > surface_coupling_flux
Coupling flux to SWMM node (m/s, + = into 2D), per face.
Definition SimulationSnapshot.hpp:235
int gage_count
Number of rain gages.
Definition SimulationSnapshot.hpp:122
std::vector< double > surface_grad_hy_lim
Slope-limited head gradient ∂h/∂y, per face.
Definition SimulationSnapshot.hpp:233
std::vector< double > surface_continuity_err
Per-cell continuity residual (m³/s), per face.
Definition SimulationSnapshot.hpp:241
std::vector< double > surface_net_source
Net source/sink (m/s), per face.
Definition SimulationSnapshot.hpp:236
double sys_storage
Total storage volume.
Definition SimulationSnapshot.hpp:150
std::vector< double > node_quality
Node pollutant concentrations.
Definition SimulationSnapshot.hpp:162
int subcatch_count
Number of subcatchments.
Definition SimulationSnapshot.hpp:121
int pollut_count
Number of pollutants.
Definition SimulationSnapshot.hpp:123
double sys_runoff
Total runoff flow.
Definition SimulationSnapshot.hpp:143
std::vector< double > surface_face_vx
Cell-centred velocity X (m/s), per face.
Definition SimulationSnapshot.hpp:239
int output_step_index
Sequential output step index (0-based).
Definition SimulationSnapshot.hpp:113
int node_count
Number of nodes.
Definition SimulationSnapshot.hpp:119
std::vector< double > surface_depth
Overland flow depth ψ_o (m), per face.
Definition SimulationSnapshot.hpp:228
const std::vector< std::string > * link_ids
Link IDs in index order.
Definition SimulationSnapshot.hpp:183
std::int64_t wall_time_unix
Wall-clock Unix timestamp when snapshot was taken.
Definition SimulationSnapshot.hpp:110
double sys_evap
Total evaporation loss.
Definition SimulationSnapshot.hpp:141
const std::vector< std::string > * node_ids
Node IDs in index order. Pointer to engine-managed strings.
Definition SimulationSnapshot.hpp:180
double sys_rainfall
Average rainfall over all gages.
Definition SimulationSnapshot.hpp:139
double sys_ii_inflow
Total RDII inflow.
Definition SimulationSnapshot.hpp:146
double sys_infil
Total infiltration loss.
Definition SimulationSnapshot.hpp:142
std::vector< double > surface_grad_hx
Unlimited head gradient ∂h/∂x, per face.
Definition SimulationSnapshot.hpp:230
std::vector< double > surface_stat_max_velocity
Max cell speed |v| (m/s), per face.
Definition SimulationSnapshot.hpp:247
const char * length_units
Length unit string (e.g., "FEET", "METERS").
Definition SimulationSnapshot.hpp:202
const std::vector< std::string > * pollut_names
Pollutant names in index order.
Definition SimulationSnapshot.hpp:192
std::vector< double > surface_grad_hx_lim
Slope-limited head gradient ∂h/∂x, per face.
Definition SimulationSnapshot.hpp:232
double sys_snow_depth
Total snow depth.
Definition SimulationSnapshot.hpp:140
std::vector< double > surface_head
Total head h_o = z_s + ψ_o (m), per face.
Definition SimulationSnapshot.hpp:229
double sys_flooding
Total flooding.
Definition SimulationSnapshot.hpp:148
const std::vector< std::string > * subcatch_ids
Subcatchment IDs in index order.
Definition SimulationSnapshot.hpp:186
int surface_tri_count
Number of triangles (faces)
Definition SimulationSnapshot.hpp:225
double sys_temperature
Air temperature.
Definition SimulationSnapshot.hpp:138
NodeSnapshot nodes
Node state.
Definition SimulationSnapshot.hpp:129
std::vector< double > surface_stat_max_cont_err
Max |continuity residual| (m³/s), per face.
Definition SimulationSnapshot.hpp:248
std::vector< double > link_quality
Link pollutant concentrations.
Definition SimulationSnapshot.hpp:168
std::vector< double > surface_vert_head
Reconstructed head at vertices (m)
Definition SimulationSnapshot.hpp:238
double sys_dw_inflow
Total dry weather inflow.
Definition SimulationSnapshot.hpp:144
Snapshot of subcatchment state at an output time step.
Definition SimulationSnapshot.hpp:73
std::vector< double > soil_moist
Soil moisture [-].
Definition SimulationSnapshot.hpp:81
std::vector< double > rainfall
Rainfall rate [display rate units].
Definition SimulationSnapshot.hpp:74
std::vector< double > infil
Infiltration [display rate units].
Definition SimulationSnapshot.hpp:77
std::vector< double > runoff
Surface runoff [display flow units].
Definition SimulationSnapshot.hpp:78
std::vector< double > gw_flow
Groundwater outflow [display flow units].
Definition SimulationSnapshot.hpp:79
std::vector< double > evap
Evaporation [display rate units].
Definition SimulationSnapshot.hpp:76
std::vector< double > gw_elev
Groundwater elevation [display length units].
Definition SimulationSnapshot.hpp:80
std::vector< double > snow_depth
Snow depth [display depth units].
Definition SimulationSnapshot.hpp:75