OpenSWMM Engine  6.0.0-alpha.3
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.3)
Loading...
Searching...
No Matches
Gage.hpp
Go to the documentation of this file.
1
17
18#ifndef OPENSWMM_GAGE_HPP
19#define OPENSWMM_GAGE_HPP
20
22#include <cstddef>
23#include <vector>
24
25namespace openswmm {
26
28
29namespace gage {
30
31// ============================================================================
32// Constants
33// ============================================================================
34
35constexpr double ONE_SECOND = 1.1574074e-5;
36constexpr int MAXPASTRAIN = 48;
37
38// ============================================================================
39// Rain type codes
40// ============================================================================
41
42enum class RainType : int {
44 VOLUME = 1,
46};
47
48// ============================================================================
49// Per-gage state
50// ============================================================================
51
52struct GageState {
53 double rainfall = 0.0;
54 double snowfall = 0.0;
55 double total_precip = 0.0;
56 double rain_accum = 0.0;
57 double api_rainfall = -1.0;
58 double snow_factor = 1.0;
59 double scale_factor = 1.0;
60 double units_factor = 1.0;
61 double adjust_factor = 1.0;
62 double rain_interval = 0.0;
64
65 double past_rain[MAXPASTRAIN] = {};
66 double past_rain_accum = 0.0;
67 double past_rain_time = 0.0;
68};
69
70// ============================================================================
71// Functions
72// ============================================================================
73
81double convertRainfall(double raw_value, GageState& state);
82
87 double rainfall = 0.0;
88 double snowfall = 0.0;
89};
90
114PrecipSplit splitPrecip(const SimulationContext& ctx, std::size_t sub);
115
122void updatePastRain(GageState& state, double current_time);
123
131double getPastRain(const GageState& state, int hours);
132
139void updateAllGages(SimulationContext& ctx, double current_time);
140
153double getReportRainfall(const SimulationContext& ctx, int gage_idx,
154 double report_date);
155
156} // namespace gage
157} // namespace openswmm
158
159#endif // OPENSWMM_GAGE_HPP
Structure-of-Arrays (SoA) storage for subcatchments.
Definition Gage.cpp:20
constexpr double ONE_SECOND
One second in days.
Definition Gage.hpp:35
double getReportRainfall(const SimulationContext &ctx, int gage_idx, double report_date)
Query a gage's rainfall at a specific report date.
Definition Gage.cpp:270
void updateAllGages(SimulationContext &ctx, double current_time)
Process all gages for one timestep.
Definition Gage.cpp:110
double getPastRain(const GageState &state, int hours)
Get past n-hour rainfall total.
Definition Gage.cpp:101
void updatePastRain(GageState &state, double current_time)
Update past n-hour rainfall accumulation.
Definition Gage.cpp:85
RainType
Definition Gage.hpp:42
@ INTENSITY
Definition Gage.hpp:43
@ VOLUME
Definition Gage.hpp:44
@ CUMULATIVE
Definition Gage.hpp:45
PrecipSplit splitPrecip(const SimulationContext &ctx, std::size_t sub)
Split a subcatchment's gage precipitation into rain and snow.
Definition Gage.cpp:51
constexpr int MAXPASTRAIN
Max past hours tracked.
Definition Gage.hpp:36
double convertRainfall(double raw_value, GageState &state)
Convert raw rainfall value based on rain type.
Definition Gage.cpp:22
Definition NodeCoupling.cpp:15
Central, reentrant simulation context.
Definition SimulationContext.hpp:292
Definition Gage.hpp:52
double past_rain_time
Time of last past-rain update.
Definition Gage.hpp:67
double rain_interval
Rain recording interval (seconds)
Definition Gage.hpp:62
double rainfall
Current rainfall intensity (project units/sec)
Definition Gage.hpp:53
double past_rain_accum
Accumulator for current hour.
Definition Gage.hpp:66
double scale_factor
Rainfall scaling factor (1.0 = no scaling)
Definition Gage.hpp:59
double snow_factor
Snow catch factor.
Definition Gage.hpp:58
double adjust_factor
Monthly/seasonal adjustment factor.
Definition Gage.hpp:61
double past_rain[MAXPASTRAIN]
Past hourly rainfall totals.
Definition Gage.hpp:65
double total_precip
rainfall + snowfall
Definition Gage.hpp:55
RainType rain_type
Definition Gage.hpp:63
double snowfall
Current snowfall intensity (project units/sec)
Definition Gage.hpp:54
double api_rainfall
API-overridden rainfall (-1 = no override)
Definition Gage.hpp:57
double rain_accum
Cumulative rain accumulator (for CUMULATIVE type)
Definition Gage.hpp:56
double units_factor
Unit conversion factor.
Definition Gage.hpp:60
Result of splitting a gage's precipitation for one subcatchment.
Definition Gage.hpp:86
double snowfall
Snowfall (ft/sec, internal units)
Definition Gage.hpp:88
double rainfall
Rainfall (ft/sec, internal units)
Definition Gage.hpp:87