OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
SolverOptions2D.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
28
29#ifndef OPENSWMM_ENGINE_2D_SOLVER_OPTIONS_HPP
30#define OPENSWMM_ENGINE_2D_SOLVER_OPTIONS_HPP
31
32#include <cstdint>
33#include <string>
34#include <vector>
35
37
38namespace openswmm::twoD {
39
59enum class CellClosure2D : int8_t {
60 FLAT = 0,
61 VFR = 1
62};
63
91enum class FaceDepth2D : int8_t {
92 MEAN = 0,
94};
95
112enum class RainfallMode : int8_t {
114 SYSTEM = 1,
115 NONE = 2
118};
119
133enum class Backend2D : int8_t {
134 CPU = 0,
135 AUTO = 1,
136 OMP = 2,
137 CUDA = 3,
138 HIP = 4,
139 SYCL = 5
140};
141
157enum class Momentum2D : int8_t {
161};
162
169enum class OutputPrecision2D : int8_t {
172};
173
180namespace report2d {
181enum Var : unsigned {
182 DEPTH = 1u << 0,
183 VELOCITY = 1u << 1,
184 EDGE_FLUX = 1u << 2,
185 NODE_HEAD = 1u << 3,
186 SPECIES = 1u << 4,
187 RAINFALL = 1u << 5,
188 INFILTRATION = 1u << 6,
189 COUPLING = 1u << 7,
190 GRADIENTS = 1u << 8,
191 CONTINUITY = 1u << 9,
192 ENVELOPES = 1u << 10,
193 ALL_MASK = (1u << 11) - 1u,
199};
200} // namespace report2d
201
218 int front_rebuild = -1;
226 double max_timestep = 10.0;
227 double dry_depth = 0.001;
228 double limiter_epsilon = 1.0e-6;
237 double flux_dh_eps = 0.004;
246 double coupling_sync = 0.0;
247
248 double coupling_cd = 0.65;
249 bool report_2d = true;
250
251 // ---- Results-file size controls (plans/2D_OUTPUT_FLOAT32_AND_VARIABLE_SELECTION_PLAN) ----
263 std::vector<std::string> report_2d_species;
267 double report_2d_step = 0.0;
268
269 // -----------------------------------------------------------------------
270 // E2 (2026-09-07) — process enables. Every default reproduces the
271 // behaviour before the keys existed, so a deck without them is
272 // bit-identical. Consumed in SurfaceRouter2D::initialize() (infiltration
273 // rows, transport row layout via transport::surface2DEnables) and the
274 // per-step forcing refresh (evaporation).
275 // -----------------------------------------------------------------------
280 int8_t infiltration = -1;
285 double infil_step = 0.0;
297 std::string infil_destination;
303 int8_t evaporation = 1;
309 bool transport_msx = true;
310 bool transport_age = true;
312
313 // -----------------------------------------------------------------------
314 // U5 (2026-09-07), rewired 2026-09-07 once the G1 two-zone kernel landed.
315 // These are the PROCESS ENABLES for the integrated 2D subsurface; the
316 // parameters themselves live in [2D_AQUIFER_OPTIONS] / [2D_AQUIFER] /
317 // [2D_AQUIFER_NODE]. Same shape as INFILTRATION / INFIL_STEP above: a
318 // tri-state enable whose AUTO reproduces the pre-existing behaviour, and
319 // an alias that folds into the authoritative struct at open.
320 // -----------------------------------------------------------------------
326 int8_t groundwater = -1;
333 std::string gw_et;
334
335 // Rainfall→mesh mapping. Default NATURAL_NEIGHBOUR (spatial interpolation
336 // across all located gages); SYSTEM applies the uniform all-gage mean.
337 // Parsed from [2D_OPTIONS] RAINFALL_MODE; env OPENSWMM_2D_RAINFALL_MODE
338 // (natural|system) overrides.
340
341 // Volume → free-surface cell closure. Default FLAT (legacy η = tri_cz + V/A):
342 // fast and the right choice for typical deep-water urban flooding, where a
343 // partially wet cell is the exception. VFR (planar-bed volume/free-surface,
344 // fully implemented on all backends) restores the C-property at shorelines
345 // and removes the water-climbs-uphill artifact, but resolves the shoreline
346 // wetting/drying FLAT freezes out — ~3–8× more marcher substeps — so it is
347 // OPT-IN (best on shallow water / gentle slopes). Parsed from [2D_OPTIONS]
348 // CELL_CLOSURE (FLAT|VFR). See plans/2d/2D_VFR_SOLVER_CLOSURE_PLAN.md.
350
351 // Effective conveyance depth at shared edges. Default MEAN (legacy upwind
352 // cell-mean depth). VFR_FACE (B&S Eq. 14 face depth + wetting gate) pairs
353 // with CELL_CLOSURE=VFR to complete the artifact fix; opt-in for the same
354 // reason. Parsed from [2D_OPTIONS] FACE_RECONSTRUCTION (MEAN|VFR_FACE).
356
362 double vfr_min_wet_frac = 0.01;
363
364 // -----------------------------------------------------------------------
365 // Explicit local-inertial marcher (INTEGRATOR EXPLICIT — the only 2D
366 // integrator since the D2 CVODE/ARKODE retirement) options. Defaults per
367 // the 2026-07-29 reimplementation plan.
368 // -----------------------------------------------------------------------
372 double theta = 0.8;
373 double cfl_number = 0.7;
381 double h_move = 0.003;
386 int lts_tiers = 4;
387 double froude_max = 1.5;
398 bool advection = false;
401 double exchange_beta = 0.8;
402
409 double dispersion = 0.0;
411 double exchange_relax = 1.0;
415 bool coupling_area_auto = false;
416
427
432
439
445
446 // -----------------------------------------------------------------------
447 // Unit-system coupling factors — NOT parsed from input. Computed once in
448 // SurfaceRouter2D::initialize() from the project FLOW_UNITS.
449 //
450 // The 2D solver runs internally in SI (metres, m², m³, m³/s, g=9.80665).
451 // The 1D SWMM engine ALWAYS computes internally in FEET (g=32.2, PHI=1.486)
452 // — for EVERY project, US or SI: its reader converts metric inputs to feet
453 // on load and only converts back at the display/output boundary. So these
454 // coupling factors are ALWAYS the feet⇄metres conversion, independent of
455 // FLOW_UNITS. SurfaceRouter2D::initialize() overwrites the 1.0 defaults
456 // with the real ft⇄m factors; the defaults only stand when 2D is inactive
457 // (no coupling occurs). The MESH scaling factor is separate and IS driven
458 // by FLOW_UNITS (the mesh is authored in project units) — see initialize().
459 // -----------------------------------------------------------------------
460 double len_1d_to_2d = 1.0;
461 double len_2d_to_1d = 1.0;
462 double vol_1d_to_2d = 1.0;
463 double flow_1d_to_2d = 1.0;
464 double flow_2d_to_1d = 1.0;
465
474 int num_threads = 1;
475
481
490 bool mesh_units_si = false;
491
497 bool mesh_scaled_to_si = false;
498
506 double mesh_to_si_factor = 1.0;
507
515
523};
524
525} // namespace openswmm::twoD
526
527#endif // OPENSWMM_ENGINE_2D_SOLVER_OPTIONS_HPP
Carrier for an external file reference in a SWMM model.
Var
Definition SolverOptions2D.hpp:181
@ ALL_MASK
Definition SolverOptions2D.hpp:193
@ INFILTRATION
Mesh2_face_infil_rate, Mesh2_face_infil_cum.
Definition SolverOptions2D.hpp:188
@ VELOCITY
Mesh2_face_vx, Mesh2_face_vy.
Definition SolverOptions2D.hpp:183
@ DEPTH
Mesh2_face_depth, Mesh2_face_head.
Definition SolverOptions2D.hpp:182
@ NODE_HEAD
Mesh2_node_head, Mesh2_node_depth (render reconstruction)
Definition SolverOptions2D.hpp:185
@ MINIMAL_MASK
MINIMAL: depth map + render reconstruction + envelopes only.
Definition SolverOptions2D.hpp:198
@ CONTINUITY
Mesh2_face_continuity_err (solver diagnostic)
Definition SolverOptions2D.hpp:191
@ RAINFALL
Mesh2_face_rainfall, Mesh2_face_rain_cum.
Definition SolverOptions2D.hpp:187
@ DEFAULT_MASK
DEFAULT: everything a user renders or plots; solver diagnostics off.
Definition SolverOptions2D.hpp:195
@ SPECIES
Mesh2_face_species_conc (when transport rows exist)
Definition SolverOptions2D.hpp:186
@ ENVELOPES
Mesh2_face_max_depth / _max_velocity / _max_continuity_err.
Definition SolverOptions2D.hpp:192
@ COUPLING
Mesh2_face_coupling_flux, Mesh2_face_net_source.
Definition SolverOptions2D.hpp:189
@ EDGE_FLUX
Mesh2_edge_flux (GUI velocity reconstruction, profile flux)
Definition SolverOptions2D.hpp:184
@ GRADIENTS
Mesh2_face_grad_hx/hy and the _lim pair (solver diagnostics)
Definition SolverOptions2D.hpp:190
Definition NodeCoupling.cpp:16
RainfallMode
How raingage rainfall is mapped onto the 2D mesh cells.
Definition SolverOptions2D.hpp:112
@ NATURAL_NEIGHBOUR
Default: spatial interpolation across all gages.
Definition SolverOptions2D.hpp:113
@ NONE
Definition SolverOptions2D.hpp:115
@ SYSTEM
Uniform = mean of all gages.
Definition SolverOptions2D.hpp:114
OutputPrecision2D
Storage precision of the 2D results file's time-varying datasets ([2D_OPTIONS] OUTPUT_PRECISION)....
Definition SolverOptions2D.hpp:169
@ FLOAT64
bit-for-bit parity tooling
Definition SolverOptions2D.hpp:171
@ FLOAT32
default — halves the file, ~7 significant digits
Definition SolverOptions2D.hpp:170
Momentum2D
Momentum closure of the explicit 2D marcher (2D_FULL_SWE_SHOCK_CAPTURING_PLAN_2026-09-05 §2).
Definition SolverOptions2D.hpp:157
@ LOCAL_INERTIAL
Definition SolverOptions2D.hpp:158
@ DIFFUSIVE_WAVE
Definition SolverOptions2D.hpp:160
@ FULL_SWE
Definition SolverOptions2D.hpp:159
FaceDepth2D
Effective conveyance depth at a shared edge for the diffusive-wave flux.
Definition SolverOptions2D.hpp:91
@ MEAN
Legacy: upwind cell-mean depth (default).
Definition SolverOptions2D.hpp:92
@ VFR_FACE
B&S Eq. 14 face depth + wetting gate.
Definition SolverOptions2D.hpp:93
Backend2D
Compute backend for the 2D marcher (mirrors fv::Backend).
Definition SolverOptions2D.hpp:133
@ CPU
Built-in marcher (OpenMP-threaded on the host), no plugin.
Definition SolverOptions2D.hpp:134
@ SYCL
Kokkos SYCL device plugin (Intel).
Definition SolverOptions2D.hpp:139
@ HIP
Kokkos HIP device plugin (AMD).
Definition SolverOptions2D.hpp:138
@ OMP
Kokkos OpenMP host plugin.
Definition SolverOptions2D.hpp:136
@ CUDA
Kokkos CUDA device plugin (NVIDIA).
Definition SolverOptions2D.hpp:137
@ AUTO
Default: plugins above their size floors, else CPU.
Definition SolverOptions2D.hpp:135
CellClosure2D
Volume → free-surface closure for a 2D cell.
Definition SolverOptions2D.hpp:59
@ VFR
Planar-bed VFR closure (regularized), CPU solvers only.
Definition SolverOptions2D.hpp:61
@ FLAT
Legacy flat-cell closure η = tri_cz + V/A (default).
Definition SolverOptions2D.hpp:60
Two-string carrier for any external file path that appears in a SWMM .inp file.
Definition FilePathPair.hpp:63
Configuration for the 2D surface routing solver.
Definition SolverOptions2D.hpp:208
double dispersion
Definition SolverOptions2D.hpp:409
double report_2d_step
Definition SolverOptions2D.hpp:267
double flow_2d_to_1d
2D flow → 1D flow (m³/s→ft³/s, 35.315)
Definition SolverOptions2D.hpp:464
bool transport_pollutants
Definition SolverOptions2D.hpp:308
double froude_max
Definition SolverOptions2D.hpp:387
Backend2D backend
Definition SolverOptions2D.hpp:431
double len_2d_to_1d
2D length → 1D length (m→ft, 3.2808)
Definition SolverOptions2D.hpp:461
CellClosure2D cell_closure
Definition SolverOptions2D.hpp:349
double limiter_epsilon
Definition SolverOptions2D.hpp:228
bool mesh_units_si
Definition SolverOptions2D.hpp:490
bool transport_temperature
Definition SolverOptions2D.hpp:311
openswmm::FilePathPair mesh_file
Definition SolverOptions2D.hpp:438
FaceDepth2D face_reconstruction
Definition SolverOptions2D.hpp:355
bool transport_age
Definition SolverOptions2D.hpp:310
int8_t evaporation
Definition SolverOptions2D.hpp:303
double max_timestep
Definition SolverOptions2D.hpp:226
double mesh_to_si_factor
Definition SolverOptions2D.hpp:506
double exchange_beta
Definition SolverOptions2D.hpp:401
std::vector< std::string > report_2d_species
Definition SolverOptions2D.hpp:263
double vol_1d_to_2d
1D volume → 2D volume (ft³→m³, 0.02832)
Definition SolverOptions2D.hpp:462
RainfallMode rainfall_mode
Definition SolverOptions2D.hpp:339
double bc_flow_to_si_applied
Definition SolverOptions2D.hpp:522
bool coupling_in_flooding
Definition SolverOptions2D.hpp:426
double dry_depth
Dry cell threshold (m)
Definition SolverOptions2D.hpp:227
bool report_2d
Write 2D results to output.
Definition SolverOptions2D.hpp:249
unsigned report_2d_vars
Definition SolverOptions2D.hpp:260
int num_threads
Definition SolverOptions2D.hpp:474
double h_move
Definition SolverOptions2D.hpp:381
double coupling_cd
Default discharge coefficient.
Definition SolverOptions2D.hpp:248
std::string gw_et
Definition SolverOptions2D.hpp:333
std::string infil_destination
Definition SolverOptions2D.hpp:297
double vfr_min_wet_frac
Definition SolverOptions2D.hpp:362
double cfl_number
Definition SolverOptions2D.hpp:373
int requested_threads
Definition SolverOptions2D.hpp:480
double coupling_sync
Definition SolverOptions2D.hpp:246
int8_t groundwater
Definition SolverOptions2D.hpp:326
int8_t infiltration
Definition SolverOptions2D.hpp:280
double theta
[2D_OPTIONS] THETA, (0, 1]
Definition SolverOptions2D.hpp:372
bool pending_rows_drained
Definition SolverOptions2D.hpp:514
double flux_dh_eps
Definition SolverOptions2D.hpp:237
double len_1d_to_2d
1D length → 2D length (ft→m, 0.3048)
Definition SolverOptions2D.hpp:460
std::string infil_default_method
Definition SolverOptions2D.hpp:291
bool mesh_scaled_to_si
Definition SolverOptions2D.hpp:497
double infil_step
Definition SolverOptions2D.hpp:285
int lts_tiers
[2D_OPTIONS] LTS_TIERS, 1..8 (1 = global dt)
Definition SolverOptions2D.hpp:386
int front_rebuild
Definition SolverOptions2D.hpp:218
int output_compression
Definition SolverOptions2D.hpp:257
Momentum2D momentum
[2D_OPTIONS] MOMENTUM_EQUATION — momentum closure (see Momentum2D).
Definition SolverOptions2D.hpp:210
bool transport_msx
Definition SolverOptions2D.hpp:309
double exchange_relax
Optional EMA sub-relaxation of per-substep coupling exchange (1 = off).
Definition SolverOptions2D.hpp:411
bool coupling_area_auto
Definition SolverOptions2D.hpp:415
openswmm::FilePathPair output_file
Definition SolverOptions2D.hpp:444
int reconstruction_order
Definition SolverOptions2D.hpp:223
OutputPrecision2D output_precision
Definition SolverOptions2D.hpp:254
double flow_1d_to_2d
1D flow → 2D flow (ft³/s→m³/s, 0.02832)
Definition SolverOptions2D.hpp:463
bool advection
Definition SolverOptions2D.hpp:398