OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
Groundwater.hpp
Go to the documentation of this file.
1
26#ifndef OPENSWMM_GROUNDWATER_HPP
27#define OPENSWMM_GROUNDWATER_HPP
28
29#ifndef OPENSWMM_RESTRICT
30# if defined(_MSC_VER)
31# define OPENSWMM_RESTRICT __restrict
32# else
33# define OPENSWMM_RESTRICT __restrict__
34# endif
35#endif
36
37#include <vector>
38
39namespace openswmm {
40
41struct SimulationContext;
42
43namespace groundwater {
44
45// ============================================================================
46// Per-subcatchment GW state (SoA for vectorization)
47// ============================================================================
48
49struct GWSoA {
50 int n_subcatch = 0;
51
52 // Aquifer properties (set at init, constant during sim)
53 std::vector<double> porosity;
54 std::vector<double> field_cap;
55 std::vector<double> wilt_point;
56 std::vector<double> k_sat;
57 std::vector<double> k_slope;
58 std::vector<double> tension_slope;
59 std::vector<double> upper_evap_frac;
60 std::vector<double> lower_evap_depth;
61 std::vector<double> lower_loss_coeff;
62 std::vector<double> total_depth;
63
64 // Lateral flow coefficients
65 std::vector<double> a1, b1;
66 std::vector<double> a2, b2;
67 std::vector<double> a3;
68 std::vector<double> h_star;
69
70 // State variables (updated each timestep)
71 std::vector<double> theta;
72 std::vector<double> lower_depth;
73
74 // Outputs
75 std::vector<double> gw_flow;
76 std::vector<double> upper_evap;
77 std::vector<double> lower_evap;
78 std::vector<double> deep_loss;
79
80 void resize(int n);
81};
82
83// ============================================================================
84// GW solver
85// ============================================================================
86
87class GWSolver {
88public:
89 void init(int n_subcatch);
90
107 void execute(SimulationContext& ctx, double dt, double max_evap,
108 const double* infil_rate, const double* sw_head);
109
110 GWSoA& state() { return soa_; }
111
112private:
113 GWSoA soa_;
114
116 static void batchUpperPerc(
117 const double* OPENSWMM_RESTRICT theta,
118 const double* OPENSWMM_RESTRICT field_cap,
119 const double* OPENSWMM_RESTRICT k_sat,
120 const double* OPENSWMM_RESTRICT k_slope,
121 double* OPENSWMM_RESTRICT perc,
122 int count
123 );
124
126 static void batchGWFlow(
127 const double* OPENSWMM_RESTRICT lower_depth,
128 const double* OPENSWMM_RESTRICT h_star,
129 const double* OPENSWMM_RESTRICT a1, const double* OPENSWMM_RESTRICT b1,
130 const double* OPENSWMM_RESTRICT a2, const double* OPENSWMM_RESTRICT b2,
131 const double* OPENSWMM_RESTRICT a3,
132 const double* OPENSWMM_RESTRICT sw_head,
133 double* OPENSWMM_RESTRICT gw_flow,
134 int count
135 );
136};
137
138} // namespace groundwater
139} // namespace openswmm
140
141#endif // OPENSWMM_GROUNDWATER_HPP
#define OPENSWMM_RESTRICT
Definition XSectBatch.hpp:41
Definition Groundwater.hpp:87
GWSoA & state()
Definition Groundwater.hpp:110
void init(int n_subcatch)
Definition Groundwater.cpp:48
void execute(SimulationContext &ctx, double dt, double max_evap, const double *infil_rate, const double *sw_head)
Compute groundwater for all subcatchments (batch).
Definition Groundwater.cpp:126
Definition Controls.cpp:24
Central, reentrant simulation context.
Definition SimulationContext.hpp:141
Definition Groundwater.hpp:49
void resize(int n)
Definition Groundwater.cpp:19
std::vector< double > total_depth
Aquifer thickness (ft)
Definition Groundwater.hpp:62
std::vector< double > gw_flow
Lateral GW flow to node (cfs)
Definition Groundwater.hpp:75
std::vector< double > upper_evap
Upper zone evap (ft3/sec)
Definition Groundwater.hpp:76
std::vector< double > lower_loss_coeff
Deep percolation coeff.
Definition Groundwater.hpp:61
std::vector< double > b2
Surface water interaction.
Definition Groundwater.hpp:66
std::vector< double > theta
Upper zone moisture content (0-φ)
Definition Groundwater.hpp:71
std::vector< double > tension_slope
Definition Groundwater.hpp:58
std::vector< double > porosity
Definition Groundwater.hpp:53
std::vector< double > field_cap
Definition Groundwater.hpp:54
std::vector< double > lower_evap_depth
Definition Groundwater.hpp:60
std::vector< double > k_slope
Exponential decay slope.
Definition Groundwater.hpp:57
int n_subcatch
Definition Groundwater.hpp:50
std::vector< double > deep_loss
Deep percolation (ft3/sec)
Definition Groundwater.hpp:78
std::vector< double > b1
GW outflow.
Definition Groundwater.hpp:65
std::vector< double > wilt_point
Definition Groundwater.hpp:55
std::vector< double > a3
Cross-interaction.
Definition Groundwater.hpp:67
std::vector< double > upper_evap_frac
Definition Groundwater.hpp:59
std::vector< double > lower_depth
Lower zone depth (ft)
Definition Groundwater.hpp:72
std::vector< double > k_sat
Saturated conductivity (ft/sec)
Definition Groundwater.hpp:56
std::vector< double > a1
Definition Groundwater.hpp:65
std::vector< double > h_star
Threshold water table height (ft)
Definition Groundwater.hpp:68
std::vector< double > a2
Definition Groundwater.hpp:66
std::vector< double > lower_evap
Lower zone evap (ft3/sec)
Definition Groundwater.hpp:77