OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
Gage.hpp
Go to the documentation of this file.
1
18#ifndef OPENSWMM_GAGE_HPP
19#define OPENSWMM_GAGE_HPP
20
21#include "../data/SubcatchData.hpp"
22#include <vector>
23
24namespace openswmm {
25
26struct SimulationContext;
27
28namespace gage {
29
30// ============================================================================
31// Constants
32// ============================================================================
33
34constexpr double ONE_SECOND = 1.1574074e-5;
35constexpr int MAXPASTRAIN = 48;
36
37// ============================================================================
38// Rain type codes
39// ============================================================================
40
41enum class RainType : int {
42 INTENSITY = 0,
43 VOLUME = 1,
44 CUMULATIVE = 2
45};
46
47// ============================================================================
48// Per-gage state
49// ============================================================================
50
51struct GageState {
52 double rainfall = 0.0;
53 double snowfall = 0.0;
54 double total_precip = 0.0;
55 double rain_accum = 0.0;
56 double api_rainfall = -1.0;
57 double snow_factor = 1.0;
58 double units_factor = 1.0;
59 double adjust_factor = 1.0;
60 double rain_interval = 0.0;
62
63 double past_rain[MAXPASTRAIN] = {};
64 double past_rain_accum = 0.0;
65 double past_rain_time = 0.0;
66};
67
68// ============================================================================
69// Functions
70// ============================================================================
71
79double convertRainfall(double raw_value, GageState& state);
80
89void separatePrecip(GageState& state, double intensity,
90 double temperature, double snow_temp);
91
98void updatePastRain(GageState& state, double current_time);
99
107double getPastRain(const GageState& state, int hours);
108
115void updateAllGages(SimulationContext& ctx, double current_time);
116
117} // namespace gage
118} // namespace openswmm
119
120#endif // OPENSWMM_GAGE_HPP
constexpr double ONE_SECOND
One second in days.
Definition Gage.hpp:34
void updateAllGages(SimulationContext &ctx, double current_time)
Process all gages for one timestep.
Definition Gage.cpp:87
double getPastRain(const GageState &state, int hours)
Get past n-hour rainfall total.
Definition Gage.cpp:78
void separatePrecip(GageState &state, double intensity, double temperature, double snow_temp)
Separate rainfall from snowfall based on temperature.
Definition Gage.cpp:50
void updatePastRain(GageState &state, double current_time)
Update past n-hour rainfall accumulation.
Definition Gage.cpp:62
RainType
Definition Gage.hpp:41
constexpr int MAXPASTRAIN
Max past hours tracked.
Definition Gage.hpp:35
double convertRainfall(double raw_value, GageState &state)
Convert raw rainfall value based on rain type.
Definition Gage.cpp:21
Definition Controls.cpp:24
Central, reentrant simulation context.
Definition SimulationContext.hpp:141
Definition Gage.hpp:51
double past_rain_time
Time of last past-rain update.
Definition Gage.hpp:65
double rain_interval
Rain recording interval (seconds)
Definition Gage.hpp:60
double rainfall
Current rainfall intensity (project units/sec)
Definition Gage.hpp:52
double past_rain_accum
Accumulator for current hour.
Definition Gage.hpp:64
double snow_factor
Snow catch factor.
Definition Gage.hpp:57
double adjust_factor
Monthly/seasonal adjustment factor.
Definition Gage.hpp:59
double past_rain[MAXPASTRAIN]
Past hourly rainfall totals.
Definition Gage.hpp:63
double total_precip
rainfall + snowfall
Definition Gage.hpp:54
RainType rain_type
Definition Gage.hpp:61
double snowfall
Current snowfall intensity (project units/sec)
Definition Gage.hpp:53
double api_rainfall
API-overridden rainfall (-1 = no override)
Definition Gage.hpp:56
double rain_accum
Cumulative rain accumulator (for CUMULATIVE type)
Definition Gage.hpp:55
double units_factor
Unit conversion factor.
Definition Gage.hpp:58