OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
Inflow.hpp
Go to the documentation of this file.
1
18#ifndef OPENSWMM_INFLOW_HPP
19#define OPENSWMM_INFLOW_HPP
20
21#include <vector>
22
23namespace openswmm {
24
25struct SimulationContext;
26
27namespace inflow {
28
29// ============================================================================
30// Pattern types
31// ============================================================================
32
33constexpr int MONTHLY_PATTERN = 0;
34constexpr int DAILY_PATTERN = 1;
35constexpr int HOURLY_PATTERN = 2;
36constexpr int WEEKEND_PATTERN = 3;
37
38// ============================================================================
39// Per-node external inflow definition (SoA)
40// ============================================================================
41
43 int count = 0;
44 std::vector<int> node_idx;
45 std::vector<int> ts_idx;
46 std::vector<int> base_pat_idx;
47 std::vector<double> baseline;
48 std::vector<double> scale_factor;
49 std::vector<double> conv_factor;
50
51 void resize(int n);
52};
53
54// ============================================================================
55// Per-node dry weather flow definition (SoA)
56// ============================================================================
57
59 int count = 0;
60 std::vector<int> node_idx;
61 std::vector<double> avg_value;
62 std::vector<int> pat_monthly;
63 std::vector<int> pat_daily;
64 std::vector<int> pat_hourly;
65 std::vector<int> pat_weekend;
66
67 void resize(int n);
68};
69
70// ============================================================================
71// Time pattern table (12 monthly, 7 daily, 24 hourly values)
72// ============================================================================
73
75 int type = 0;
76 double factors[24] = {};
77};
78
79// ============================================================================
80// Inflow solver
81// ============================================================================
82
84public:
85 void init(SimulationContext& ctx);
86
100 void computeAll(SimulationContext& ctx, double current_date, double dt);
101
102private:
103 ExtInflowSoA ext_inflows_;
104 DwfInflowSoA dwf_inflows_;
105 std::vector<TimePattern> patterns_;
106
108 double getPatternFactor(int pat_idx, int month, int day, int hour) const;
109};
110
111} // namespace inflow
112} // namespace openswmm
113
114#endif // OPENSWMM_INFLOW_HPP
Definition Inflow.hpp:83
void init(SimulationContext &ctx)
Definition Inflow.cpp:59
void computeAll(SimulationContext &ctx, double current_date, double dt)
Compute all external + DWF inflows and add to node lateral flow.
Definition Inflow.cpp:157
constexpr int WEEKEND_PATTERN
Definition Inflow.hpp:36
constexpr int MONTHLY_PATTERN
Definition Inflow.hpp:33
constexpr int HOURLY_PATTERN
Definition Inflow.hpp:35
constexpr int DAILY_PATTERN
Definition Inflow.hpp:34
Definition Controls.cpp:24
Central, reentrant simulation context.
Definition SimulationContext.hpp:141
Definition Inflow.hpp:58
void resize(int n)
Definition Inflow.cpp:34
int count
Definition Inflow.hpp:59
std::vector< int > node_idx
Which node.
Definition Inflow.hpp:60
std::vector< double > avg_value
Average DWF value.
Definition Inflow.hpp:61
std::vector< int > pat_weekend
Weekend pattern index (-1 = none)
Definition Inflow.hpp:65
std::vector< int > pat_hourly
Hourly pattern index (-1 = none)
Definition Inflow.hpp:64
std::vector< int > pat_monthly
Monthly pattern index (-1 = none)
Definition Inflow.hpp:62
std::vector< int > pat_daily
Daily pattern index (-1 = none)
Definition Inflow.hpp:63
Definition Inflow.hpp:42
std::vector< int > ts_idx
Timeseries index (-1 = none)
Definition Inflow.hpp:45
int count
Definition Inflow.hpp:43
void resize(int n)
Definition Inflow.cpp:23
std::vector< double > scale_factor
Timeseries scaling factor.
Definition Inflow.hpp:48
std::vector< double > conv_factor
Units conversion factor.
Definition Inflow.hpp:49
std::vector< int > node_idx
Which node this inflow applies to.
Definition Inflow.hpp:44
std::vector< int > base_pat_idx
Baseline pattern index (-1 = none)
Definition Inflow.hpp:46
std::vector< double > baseline
Constant baseline value.
Definition Inflow.hpp:47
Definition Inflow.hpp:74
int type
0=monthly, 1=daily, 2=hourly, 3=weekend
Definition Inflow.hpp:75
double factors[24]
Up to 24 factors (monthly=12, daily=7, hourly=24)
Definition Inflow.hpp:76