OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
SubsurfaceData.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2//
3// Copyright 2026 Caleb Buahin
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
48
49#ifndef OPENSWMM_ENGINE_2D_SUBSURFACE_DATA_HPP
50#define OPENSWMM_ENGINE_2D_SUBSURFACE_DATA_HPP
51
52#include <cstdint>
53#include <string>
54#include <vector>
55
56namespace openswmm::twoD {
57
61enum class SoilChar : int8_t {
62 RUSSO = 0,
63 GARDNER = 1,
66};
67
69enum class GwClosure : int8_t {
70 AUTO = -1,
73 SIGMA = 2
74};
75
78struct GwNodeBed {
79 int node = -1;
80 int cell = -1;
81 double Kc = 0.0;
82 double dC = 0.0;
83 double area = 0.0;
84};
85
87struct GwOptions {
90 int m_layers = 8;
91 bool capillary_diff = false;
92 double c_gw = 0.5;
93 double c_col = 0.9;
94 bool force_closed_form = false;
98 bool per_subcatch = false;
102 bool dunne = true;
104 std::string gw_et = "NONE";
106 bool authored = false;
107};
108
112 int scope = 0;
113 std::string tag;
114 int cell = -1;
115
116 double Ks = 1.0e-5;
117 double zs = 5.0;
118 double theta_s = 0.45;
119 double theta_r = 0.10;
120 double alpha = 2.0;
122 double psi_b = 0.20;
123 double lambda = 0.40;
125 double vg_n = 1.6;
126 double vg_L = 0.5;
128 double c_loss = 0.0;
130 double hg0 = -1.0;
131
134 int m_layers = -1;
135 bool soil_char_set = false, closure_set = false;
136};
137
147 int n_cells = 0;
148 int m_layers = 0;
149
150 // ---- resolved parameters (per cell) ---------------------------------
151 std::vector<double> Ks, zs, theta_s, theta_r, alpha;
152 std::vector<double> psi_b, lambda, vg_n, vg_L, c_loss;
153 std::vector<int8_t> soil_char;
154 std::vector<int8_t> closure;
155 std::vector<double> area;
156 std::vector<double> z_bed;
157
158 // ---- state ----------------------------------------------------------
159 std::vector<double> hg;
160 std::vector<double> hu;
164 std::vector<double> theta_sigma;
165
166 // ---- per-firing diagnostics + transport donors ------------------------
167 std::vector<double> q0_last;
168 std::vector<double> qnode_last;
169 std::vector<double> qlat_last;
170 std::vector<double> qdeep_last;
171 std::vector<double> qet_last;
172 std::vector<double> dunne_last;
173 std::vector<double> qplus_last;
174
175 // ---- LTS ------------------------------------------------------------
176 std::vector<double> dt_cell;
177 std::vector<uint8_t> tier;
182 std::vector<double> eacc_L, eacc_R;
185 std::vector<double> xacc_from_surface;
188 std::vector<double> xacc_to_surface;
191 std::vector<double> nacc;
192
193 // ---- ledger (m³, cumulative) ----------------------------------------
194 double led_recharge = 0.0;
195 double led_lateral = 0.0;
196 double led_deep = 0.0;
197 double led_node = 0.0;
198 double led_dunne = 0.0;
199 double led_caprise = 0.0;
200 double led_et = 0.0;
201 double led_infil_in = 0.0;
202 double led_init_storage = 0.0;
203 double led_final_storage = 0.0;
204
205 bool active = false;
206
207 void resize(int n, int m);
209 double storage() const noexcept;
210};
211
227 double length = 1.0;
228 double rate = 1.0;
229 double inv_len = 1.0;
230 double area = 1.0;
231};
232
236 std::vector<GwAquiferRow> rows;
237 std::vector<GwNodeBed> node_beds;
238
239 bool empty() const noexcept {
240 return !options.authored && rows.empty() && node_beds.empty();
241 }
242 void clear() { *this = SubsurfaceConfig{}; }
243};
244
245const char* soilCharToken(SoilChar s) noexcept;
246bool parseSoilChar(const std::string& t, SoilChar& s) noexcept;
247const char* gwClosureToken(GwClosure c) noexcept;
248bool parseGwClosure(const std::string& t, GwClosure& c) noexcept;
249
250} // namespace openswmm::twoD
251
252#endif // OPENSWMM_ENGINE_2D_SUBSURFACE_DATA_HPP
Definition NodeCoupling.cpp:16
bool parseSoilChar(const std::string &t, SoilChar &s) noexcept
Definition SubsurfaceData.cpp:128
const char * soilCharToken(SoilChar s) noexcept
Definition SubsurfaceData.cpp:118
const char * gwClosureToken(GwClosure c) noexcept
Definition SubsurfaceData.cpp:139
SoilChar
Definition SubsurfaceData.hpp:61
@ GARDNER
K = Ks·e^(αψ); the closed form of eq. 22.
Definition SubsurfaceData.hpp:63
@ RUSSO
default; Mualem-consistent, same α slot as Gardner
Definition SubsurfaceData.hpp:62
@ BROOKS_COREY
piecewise about the air-entry pressure
Definition SubsurfaceData.hpp:64
@ VAN_GENUCHTEN
Rosetta/UNSODA parameter databases.
Definition SubsurfaceData.hpp:65
bool parseGwClosure(const std::string &t, GwClosure &c) noexcept
Definition SubsurfaceData.cpp:149
GwClosure
Unsaturated-zone closure, resolved per cell from AUTO at initialize.
Definition SubsurfaceData.hpp:69
@ CLOSED_FORM
closure A: bulk hu + quasi-steady recharge
Definition SubsurfaceData.hpp:71
@ SIGMA
closure B: explicit σ column of m layers
Definition SubsurfaceData.hpp:73
@ ENSLAVED
closure A reduced: hu algebraic in hg (eq. 39)
Definition SubsurfaceData.hpp:72
@ AUTO
select from αL at initialize (never stored per cell)
Definition SubsurfaceData.hpp:70
@ AUTO
Default: plugins above their size floors, else CPU.
Definition SolverOptions2D.hpp:135
Definition SubsurfaceData.hpp:111
int scope
0 GLOBAL, 1 TAG, 2 CELL (mirrors GwScope)
Definition SubsurfaceData.hpp:112
bool soil_char_set
Definition SubsurfaceData.hpp:135
double theta_r
residual water content
Definition SubsurfaceData.hpp:119
GwClosure closure
Definition SubsurfaceData.hpp:133
int m_layers
< 0 ⇒ the global M_LAYERS
Definition SubsurfaceData.hpp:134
double vg_L
Definition SubsurfaceData.hpp:126
double Ks
saturated hydraulic conductivity (m/s)
Definition SubsurfaceData.hpp:116
double theta_s
porosity / saturated water content
Definition SubsurfaceData.hpp:118
double psi_b
Brooks–Corey: psi_b air-entry head (m, positive) and lambda shape.
Definition SubsurfaceData.hpp:122
double alpha
Definition SubsurfaceData.hpp:120
double hg0
Initial saturated thickness (m). < 0 ⇒ the option default seeds it.
Definition SubsurfaceData.hpp:130
double vg_n
van Genuchten: n (m = 1 − 1/n) and the Mualem exponent L.
Definition SubsurfaceData.hpp:125
std::string tag
Definition SubsurfaceData.hpp:113
double lambda
Definition SubsurfaceData.hpp:123
int cell
0-based
Definition SubsurfaceData.hpp:114
SoilChar soil_char
Definition SubsurfaceData.hpp:132
double c_loss
Deep-loss coefficient (m/s at full saturation): q⁻ = c_loss·hg/zs.
Definition SubsurfaceData.hpp:128
double zs
soil column thickness, bottom→surface (m)
Definition SubsurfaceData.hpp:117
bool closure_set
Definition SubsurfaceData.hpp:135
Definition SubsurfaceData.hpp:78
double area
exchange area (m²); 0 ⇒ derived from the cell area
Definition SubsurfaceData.hpp:83
int cell
containing mesh cell, resolved at initialize
Definition SubsurfaceData.hpp:80
int node
1D node index
Definition SubsurfaceData.hpp:79
double Kc
semi-confining bed conductivity (m/s); 0 = direct
Definition SubsurfaceData.hpp:81
double dC
bed thickness (m)
Definition SubsurfaceData.hpp:82
[2D_AQUIFER_OPTIONS]. Defaults are the plan's starred values.
Definition SubsurfaceData.hpp:87
SoilChar soil_char
Definition SubsurfaceData.hpp:88
double c_col
column stability safety factor
Definition SubsurfaceData.hpp:93
std::string gw_et
GW_ET: NONE | CAPILLARY_RISE | BOUNDARY_ET | BOTH.
Definition SubsurfaceData.hpp:104
bool capillary_diff
closure B optional diffusive term (D-N3: OFF)
Definition SubsurfaceData.hpp:91
bool dunne
Definition SubsurfaceData.hpp:102
bool per_subcatch
Definition SubsurfaceData.hpp:98
bool authored
True once any [2D_AQUIFER*] row was authored.
Definition SubsurfaceData.hpp:106
int m_layers
σ layers under closure B (global default)
Definition SubsurfaceData.hpp:90
GwClosure closure
Definition SubsurfaceData.hpp:89
double c_gw
saturated stability safety factor
Definition SubsurfaceData.hpp:92
bool force_closed_form
Definition SubsurfaceData.hpp:94
Project-unit → SI multipliers for the four kinds of aquifer number.
Definition SubsurfaceData.hpp:226
double inv_len
1/ft → 1/m, or 1/m → 1/m
Definition SubsurfaceData.hpp:229
double length
ft → m, or m → m
Definition SubsurfaceData.hpp:227
double area
ft² → m², or m² → m²
Definition SubsurfaceData.hpp:230
double rate
in/hr → m/s, or mm/hr → m/s
Definition SubsurfaceData.hpp:228
Everything the parser fills, before resolution onto cells.
Definition SubsurfaceData.hpp:234
bool empty() const noexcept
Definition SubsurfaceData.hpp:239
GwOptions options
Definition SubsurfaceData.hpp:235
void clear()
Definition SubsurfaceData.hpp:242
std::vector< GwNodeBed > node_beds
Definition SubsurfaceData.hpp:237
std::vector< GwAquiferRow > rows
Definition SubsurfaceData.hpp:236
Per-cell resolved parameters and state (SoA).
Definition SubsurfaceData.hpp:146
double led_recharge
unsat → sat (negative = capillary rise)
Definition SubsurfaceData.hpp:194
double led_lateral
net lateral Darcy across the domain edge
Definition SubsurfaceData.hpp:195
std::vector< double > xacc_from_surface
Definition SubsurfaceData.hpp:185
std::vector< double > dt_cell
min(Δt_g, Δt_u) per cell (s)
Definition SubsurfaceData.hpp:176
void resize(int n, int m)
Definition SubsurfaceData.cpp:37
bool active
the kernel ran this simulation
Definition SubsurfaceData.hpp:205
double led_infil_in
q⁺ delivered from the surface
Definition SubsurfaceData.hpp:201
std::vector< double > hg
saturated thickness (m)
Definition SubsurfaceData.hpp:159
std::vector< double > eacc_R
Definition SubsurfaceData.hpp:182
std::vector< double > nacc
Definition SubsurfaceData.hpp:191
std::vector< int8_t > closure
GwClosure, AUTO already resolved.
Definition SubsurfaceData.hpp:154
std::vector< double > theta_r
Definition SubsurfaceData.hpp:151
std::vector< uint8_t > tier
Definition SubsurfaceData.hpp:177
int m_layers
σ layers per closure-B column (fixed)
Definition SubsurfaceData.hpp:148
std::vector< double > hu
Definition SubsurfaceData.hpp:160
std::vector< double > zs
Definition SubsurfaceData.hpp:151
std::vector< double > vg_n
Definition SubsurfaceData.hpp:152
std::vector< double > theta_sigma
Definition SubsurfaceData.hpp:164
std::vector< double > c_loss
Definition SubsurfaceData.hpp:152
double led_init_storage
Definition SubsurfaceData.hpp:202
std::vector< double > psi_b
Definition SubsurfaceData.hpp:152
std::vector< double > xacc_to_surface
Definition SubsurfaceData.hpp:188
std::vector< double > area
cell planimetric area (m²)
Definition SubsurfaceData.hpp:155
std::vector< double > theta_s
Definition SubsurfaceData.hpp:151
std::vector< double > z_bed
aquifer bottom elevation (m) = cell z − zs
Definition SubsurfaceData.hpp:156
std::vector< double > vg_L
Definition SubsurfaceData.hpp:152
std::vector< double > dunne_last
saturation-excess to the surface (m³/s)
Definition SubsurfaceData.hpp:172
std::vector< double > qnode_last
node exchange (m³/s), + into the pipe
Definition SubsurfaceData.hpp:168
double led_caprise
capillary rise (the negative recharge share)
Definition SubsurfaceData.hpp:199
std::vector< double > lambda
Definition SubsurfaceData.hpp:152
std::vector< double > qplus_last
infiltration delivered in (m/s)
Definition SubsurfaceData.hpp:173
std::vector< double > qlat_last
net lateral Darcy into the cell (m³/s)
Definition SubsurfaceData.hpp:169
std::vector< double > q0_last
recharge (m/s), + down, − capillary rise
Definition SubsurfaceData.hpp:167
std::vector< double > alpha
Definition SubsurfaceData.hpp:151
std::vector< double > Ks
Definition SubsurfaceData.hpp:151
std::vector< int8_t > soil_char
SoilChar.
Definition SubsurfaceData.hpp:153
double led_deep
deep percolation out
Definition SubsurfaceData.hpp:196
std::vector< double > qdeep_last
deep loss (m/s)
Definition SubsurfaceData.hpp:170
std::vector< double > eacc_L
Definition SubsurfaceData.hpp:182
double led_et
subsurface ET out
Definition SubsurfaceData.hpp:200
double storage() const noexcept
Total water in both zones (m³) — the continuity check's storage term.
Definition SubsurfaceData.cpp:77
double led_final_storage
Definition SubsurfaceData.hpp:203
std::vector< double > qet_last
subsurface ET (m/s, ≥ 0 out)
Definition SubsurfaceData.hpp:171
int n_cells
Definition SubsurfaceData.hpp:147
double led_node
node exchange, + out of the aquifer
Definition SubsurfaceData.hpp:197
double led_dunne
saturation excess to the surface
Definition SubsurfaceData.hpp:198