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 <cmath>
34#include <string>
35#include <vector>
36
38
39namespace openswmm::twoD {
40
60enum class CellClosure2D : int8_t {
61 FLAT = 0,
62 VFR = 1
63};
64
92enum class FaceDepth2D : int8_t {
93 MEAN = 0,
95};
96
113enum class RainfallMode : int8_t {
115 SYSTEM = 1,
116 NONE = 2,
120};
121
130enum class CouplingLaw2D : int8_t { ORIFICE = 0, WEIR_ORIFICE = 1 };
131
143enum class CouplingHead2D : int8_t { CELL = 0, VERTEX = 1, STENCIL_WET_MEAN = 2 };
144
156enum class CouplingPondMode2D : int8_t { FOOTPRINT = 0, CHAMBER = 1, TRACKING = 2 };
157
171enum class Backend2D : int8_t {
172 CPU = 0,
173 AUTO = 1,
174 OMP = 2,
175 CUDA = 3,
176 HIP = 4,
177 SYCL = 5
178};
179
195enum class Momentum2D : int8_t { LOCAL_INERTIAL = 0, FULL_SWE = 1, DIFFUSIVE_WAVE = 2 };
196
203enum class OutputPrecision2D : int8_t {
206};
207
214namespace report2d {
215enum Var : unsigned {
216 DEPTH = 1u << 0,
217 VELOCITY = 1u << 1,
218 EDGE_FLUX = 1u << 2,
219 NODE_HEAD = 1u << 3,
220 SPECIES = 1u << 4,
221 RAINFALL = 1u << 5,
222 INFILTRATION = 1u << 6,
223 COUPLING = 1u << 7,
224 GRADIENTS = 1u << 8,
225 CONTINUITY = 1u << 9,
226 ENVELOPES = 1u << 10,
227 BUILDUP = 1u << 11,
229 1u
230 << 12,
232 1u << 13,
233 HEAT = 1u << 14,
234 TURBULENCE = 1u << 15,
235 ALL_MASK = (1u << 16) - 1u,
241};
242} // namespace report2d
243
250enum class Coriolis2D : int8_t { OFF = 0, LATITUDE = 1, CONSTANT_F = 2 };
251enum class Turbulence2D : int8_t { NONE = 0, SMAGORINSKY = 1, MIXING_LENGTH = 2 };
253inline const char* turbulenceName(Turbulence2D t) noexcept {
254 return t == Turbulence2D::SMAGORINSKY ? "SMAGORINSKY" : t == Turbulence2D::MIXING_LENGTH ? "MIXING_LENGTH" : "NONE";
255}
256
258 // Explicit opt-in. Unauthored fields are omitted by the writer.
259 bool coupled_heat = false, heat_model_authored = false;
260 int heat_surface = -1, heat_radiative = -1; // AUTO inherits network module
262 int bed_heat_model = 0; // NONE, LOCAL_STORAGE, GROUND_COLUMN
263 bool bed_heat_authored = false;
264 // Derived during initialization: legacy runtime-water conversion stays
265 // 4.186 MJ/(m3 K); opt-in coupled heat uses configured water rho*cp.
266 double water_heat_capacity = 4186000.0;
272 double coriolis_latitude = 0.0, coriolis_f = 0.0, smagorinsky_cs = 0.10;
283 bool wall_drag_enabled = false;
284 bool momentumPhysics() const noexcept {
286 }
287 double coriolisParameter() const noexcept {
290 ? 1.4584231711061317e-4 * std::sin(coriolis_latitude * 0.017453292519943295)
291 : 0.0;
292 }
293
300 int front_rebuild = -1;
308 double max_timestep = 10.0;
309 double dry_depth = 0.001;
310 double limiter_epsilon = 1.0e-6;
319 double flux_dh_eps = 0.004;
328 double coupling_sync = 0.0;
329
330 double coupling_cd = 0.65;
347 double coupling_rim_band = -1.0;
351 int8_t coupling_equalize = -1;
352 bool report_2d = true;
353
354 // ---- Results-file size controls (plans/2D_OUTPUT_FLOAT32_AND_VARIABLE_SELECTION_PLAN) ----
366 std::vector<std::string> report_2d_species;
370 double report_2d_step = 0.0;
371
372 // -----------------------------------------------------------------------
373 // E2 (2026-09-07) — process enables. Every default reproduces the
374 // behaviour before the keys existed, so a deck without them is
375 // bit-identical. Consumed in SurfaceRouter2D::initialize() (infiltration
376 // rows, transport row layout via transport::surface2DEnables) and the
377 // per-step forcing refresh (evaporation).
378 // -----------------------------------------------------------------------
383 int8_t infiltration = -1;
388 double infil_step = 0.0;
400 std::string infil_destination;
406 int8_t evaporation = 1;
412 bool transport_msx = true;
413 bool transport_age = true;
415
416 // -----------------------------------------------------------------------
417 // U5 (2026-09-07), rewired 2026-09-07 once the G1 two-zone kernel landed.
418 // These are the PROCESS ENABLES for the integrated 2D subsurface; the
419 // parameters themselves live in [2D_AQUIFER_OPTIONS] / [2D_AQUIFER] /
420 // [2D_AQUIFER_NODE]. Same shape as INFILTRATION / INFIL_STEP above: a
421 // tri-state enable whose AUTO reproduces the pre-existing behaviour, and
422 // an alias that folds into the authoritative struct at open.
423 // -----------------------------------------------------------------------
429 int8_t groundwater = -1;
436 std::string gw_et;
437
438 // Rainfall→mesh mapping. Default NATURAL_NEIGHBOUR (spatial interpolation
439 // across all located gages); SYSTEM applies the uniform all-gage mean.
440 // Parsed from [2D_OPTIONS] RAINFALL_MODE; env OPENSWMM_2D_RAINFALL_MODE
441 // (natural|nearest|system|none) overrides.
443
444 // Volume → free-surface cell closure. Default FLAT (legacy η = tri_cz + V/A):
445 // fast and the right choice for typical deep-water urban flooding, where a
446 // partially wet cell is the exception. VFR (planar-bed volume/free-surface,
447 // fully implemented on all backends) restores the C-property at shorelines
448 // and removes the water-climbs-uphill artifact, but resolves the shoreline
449 // wetting/drying FLAT freezes out — ~3–8× more marcher substeps — so it is
450 // OPT-IN (best on shallow water / gentle slopes). Parsed from [2D_OPTIONS]
451 // CELL_CLOSURE (FLAT|VFR). See plans/2d/2D_VFR_SOLVER_CLOSURE_PLAN.md.
453
454 // Effective conveyance depth at shared edges. Default MEAN (legacy upwind
455 // cell-mean depth). VFR_FACE (B&S Eq. 14 face depth + wetting gate) pairs
456 // with CELL_CLOSURE=VFR to complete the artifact fix; opt-in for the same
457 // reason. Parsed from [2D_OPTIONS] FACE_RECONSTRUCTION (MEAN|VFR_FACE).
459
465 double vfr_min_wet_frac = 0.01;
466
467 // -----------------------------------------------------------------------
468 // Explicit local-inertial marcher (INTEGRATOR EXPLICIT — the only 2D
469 // integrator since the D2 CVODE/ARKODE retirement) options. Defaults per
470 // the 2026-07-29 reimplementation plan.
471 // -----------------------------------------------------------------------
475 double theta = 0.8;
479 double theta_reference_step = 0.0;
480 double cfl_number = 0.7;
488 double h_move = 0.003;
493 int lts_tiers = 4;
494 double froude_max = 1.5;
505 bool advection = false;
508 double exchange_beta = 0.8;
509
516 double dispersion = 0.0;
520 double exchange_relax = 1.0;
524 bool coupling_area_auto = false;
525
536
541
545 bool auto_backend_cpu = false;
546
553
559
560 // -----------------------------------------------------------------------
561 // Unit-system coupling factors — NOT parsed from input. Computed once in
562 // SurfaceRouter2D::initialize() from the project FLOW_UNITS.
563 //
564 // The 2D solver runs internally in SI (metres, m², m³, m³/s, g=9.80665).
565 // The 1D SWMM engine ALWAYS computes internally in FEET (g=32.2, PHI=1.486)
566 // — for EVERY project, US or SI: its reader converts metric inputs to feet
567 // on load and only converts back at the display/output boundary. So these
568 // coupling factors are ALWAYS the feet⇄metres conversion, independent of
569 // FLOW_UNITS. SurfaceRouter2D::initialize() overwrites the 1.0 defaults
570 // with the real ft⇄m factors; the defaults only stand when 2D is inactive
571 // (no coupling occurs). The MESH scaling factor is separate and IS driven
572 // by FLOW_UNITS (the mesh is authored in project units) — see initialize().
573 // -----------------------------------------------------------------------
574 double len_1d_to_2d = 1.0;
575 double len_2d_to_1d = 1.0;
576 double vol_1d_to_2d = 1.0;
577 double flow_1d_to_2d = 1.0;
578 double flow_2d_to_1d = 1.0;
579
588 int num_threads = 1;
589
595
604 bool mesh_units_si = false;
605
611 bool mesh_scaled_to_si = false;
612
620 double mesh_to_si_factor = 1.0;
621
629
637};
638
639} // namespace openswmm::twoD
640
641#endif // OPENSWMM_ENGINE_2D_SOLVER_OPTIONS_HPP
Carrier for an external file reference in a SWMM model.
Var
Definition SolverOptions2D.hpp:215
@ ALL_MASK
Definition SolverOptions2D.hpp:235
@ INFILTRATION
Mesh2_face_infil_rate, Mesh2_face_infil_cum.
Definition SolverOptions2D.hpp:222
@ HEAT
Thermal temperatures, soil layers, and signed cumulative heat budgets.
Definition SolverOptions2D.hpp:233
@ VELOCITY
Mesh2_face_vx, Mesh2_face_vy.
Definition SolverOptions2D.hpp:217
@ DEPTH
Mesh2_face_depth, Mesh2_face_head.
Definition SolverOptions2D.hpp:216
@ NODE_HEAD
Mesh2_node_head, Mesh2_node_depth (render reconstruction)
Definition SolverOptions2D.hpp:219
@ BUILDUP
S7: Mesh2_face_buildup (when [2D_COVERAGES] rows resolved)
Definition SolverOptions2D.hpp:227
@ MINIMAL_MASK
MINIMAL: depth map + render reconstruction + envelopes only.
Definition SolverOptions2D.hpp:240
@ CONTINUITY
Mesh2_face_continuity_err (solver diagnostic)
Definition SolverOptions2D.hpp:225
@ RAINFALL
Mesh2_face_rainfall, Mesh2_face_rain_cum.
Definition SolverOptions2D.hpp:221
@ DEFAULT_MASK
DEFAULT: everything a user renders or plots; solver diagnostics off.
Definition SolverOptions2D.hpp:237
@ SPECIES
Mesh2_face_species_conc (when transport rows exist)
Definition SolverOptions2D.hpp:220
@ TURBULENCE
Horizontal eddy viscosity and strain rate diagnostics.
Definition SolverOptions2D.hpp:234
@ ENVELOPES
Mesh2_face_max_depth / _max_velocity / _max_continuity_err.
Definition SolverOptions2D.hpp:226
@ COUPLING
Mesh2_face_coupling_flux, Mesh2_face_net_source.
Definition SolverOptions2D.hpp:223
@ GW_DETAILED
G-O: Mesh2_face_gw_theta_sigma [time, layer, face] — m × nFace per step.
Definition SolverOptions2D.hpp:231
@ EDGE_FLUX
Mesh2_edge_flux (GUI velocity reconstruction, profile flux)
Definition SolverOptions2D.hpp:218
@ GROUNDWATER
G-O: Mesh2_face_gw_* per-cell fields, groundwater_ledger, groundwater_node_exchange_cum (when a [2D_A...
Definition SolverOptions2D.hpp:228
@ GRADIENTS
Mesh2_face_grad_hx/hy and the _lim pair (solver diagnostics)
Definition SolverOptions2D.hpp:224
Definition ExchangeLaw.hpp:60
Coriolis2D
Configuration for the 2D surface routing solver.
Definition SolverOptions2D.hpp:250
@ LATITUDE
Definition SolverOptions2D.hpp:250
@ OFF
Definition SolverOptions2D.hpp:250
@ CONSTANT_F
Definition SolverOptions2D.hpp:250
CouplingHead2D
Where the 2D head driving a junction exchange is read ([2D_OPTIONS] COUPLING_HEAD).
Definition SolverOptions2D.hpp:143
@ VERTEX
Definition SolverOptions2D.hpp:143
@ STENCIL_WET_MEAN
Definition SolverOptions2D.hpp:143
@ CELL
Definition SolverOptions2D.hpp:143
RainfallMode
How raingage rainfall is mapped onto the 2D mesh cells.
Definition SolverOptions2D.hpp:113
@ NATURAL_NEIGHBOUR
Default: spatial interpolation across all gages.
Definition SolverOptions2D.hpp:114
@ NEAREST_NEIGHBOUR
Closest located gage; ties use first gage order.
Definition SolverOptions2D.hpp:119
@ NONE
Definition SolverOptions2D.hpp:116
@ SYSTEM
Uniform = mean of all gages.
Definition SolverOptions2D.hpp:115
const char * turbulenceName(Turbulence2D t) noexcept
[2D_OPTIONS] TURBULENCE_MODEL token for a closure.
Definition SolverOptions2D.hpp:253
Turbulence2D
Definition SolverOptions2D.hpp:251
@ SMAGORINSKY
Definition SolverOptions2D.hpp:251
@ MIXING_LENGTH
Definition SolverOptions2D.hpp:251
@ NONE
Definition SolverOptions2D.hpp:251
CouplingLaw2D
1D↔2D exchange law at junction coupling points ([2D_OPTIONS] COUPLING_LAW; a node's [2D_NODE_COUPLING...
Definition SolverOptions2D.hpp:130
@ WEIR_ORIFICE
Definition SolverOptions2D.hpp:130
@ ORIFICE
Definition SolverOptions2D.hpp:130
OutputPrecision2D
Storage precision of the 2D results file's time-varying datasets ([2D_OPTIONS] OUTPUT_PRECISION)....
Definition SolverOptions2D.hpp:203
@ FLOAT64
bit-for-bit parity tooling
Definition SolverOptions2D.hpp:205
@ FLOAT32
default — halves the file, ~7 significant digits
Definition SolverOptions2D.hpp:204
Momentum2D
Momentum closure of the explicit 2D marcher (2D_FULL_SWE_SHOCK_CAPTURING_PLAN_2026-09-05 §2).
Definition SolverOptions2D.hpp:195
@ LOCAL_INERTIAL
Definition SolverOptions2D.hpp:195
@ DIFFUSIVE_WAVE
Definition SolverOptions2D.hpp:195
@ FULL_SWE
Definition SolverOptions2D.hpp:195
CouplingPondMode2D
Above-rim storage of a 2D-coupled junction under dynamic wave ([2D_OPTIONS] COUPLING_POND_MODE; plan ...
Definition SolverOptions2D.hpp:156
@ CHAMBER
Definition SolverOptions2D.hpp:156
@ FOOTPRINT
Definition SolverOptions2D.hpp:156
@ TRACKING
Definition SolverOptions2D.hpp:156
FaceDepth2D
Effective conveyance depth at a shared edge for the diffusive-wave flux.
Definition SolverOptions2D.hpp:92
@ MEAN
Legacy: upwind cell-mean depth (default).
Definition SolverOptions2D.hpp:93
@ VFR_FACE
B&S Eq. 14 face depth + wetting gate.
Definition SolverOptions2D.hpp:94
Backend2D
Compute backend for the 2D marcher (mirrors fv::Backend).
Definition SolverOptions2D.hpp:171
@ CPU
Built-in marcher (OpenMP-threaded on the host), no plugin.
Definition SolverOptions2D.hpp:172
@ SYCL
Kokkos SYCL device plugin (Intel).
Definition SolverOptions2D.hpp:177
@ HIP
Kokkos HIP device plugin (AMD).
Definition SolverOptions2D.hpp:176
@ OMP
Kokkos OpenMP host plugin.
Definition SolverOptions2D.hpp:174
@ CUDA
Kokkos CUDA device plugin (NVIDIA).
Definition SolverOptions2D.hpp:175
@ AUTO
Default: plugins above their size floors, else CPU.
Definition SolverOptions2D.hpp:173
CellClosure2D
Volume → free-surface closure for a 2D cell.
Definition SolverOptions2D.hpp:60
@ VFR
Planar-bed VFR closure (regularized), CPU solvers only.
Definition SolverOptions2D.hpp:62
@ FLAT
Legacy flat-cell closure η = tri_cz + V/A (default).
Definition SolverOptions2D.hpp:61
Two-string carrier for any external file path that appears in a SWMM .inp file.
Definition FilePathPair.hpp:63
Definition SolverOptions2D.hpp:257
double dispersion
Definition SolverOptions2D.hpp:516
double report_2d_step
Definition SolverOptions2D.hpp:370
double flow_2d_to_1d
2D flow → 1D flow (m³/s→ft³/s, 35.315)
Definition SolverOptions2D.hpp:578
bool transport_pollutants
Definition SolverOptions2D.hpp:411
double froude_max
Definition SolverOptions2D.hpp:494
Backend2D backend
Definition SolverOptions2D.hpp:540
int heat_surface
Definition SolverOptions2D.hpp:260
double len_2d_to_1d
2D length → 1D length (m→ft, 3.2808)
Definition SolverOptions2D.hpp:575
CellClosure2D cell_closure
Definition SolverOptions2D.hpp:452
double limiter_epsilon
Definition SolverOptions2D.hpp:310
bool mesh_units_si
Definition SolverOptions2D.hpp:604
bool coriolis_latitude_set
Definition SolverOptions2D.hpp:281
bool transport_temperature
Definition SolverOptions2D.hpp:414
openswmm::FilePathPair mesh_file
Definition SolverOptions2D.hpp:552
double coupling_pond_relax
Definition SolverOptions2D.hpp:343
int heat_radiative
Definition SolverOptions2D.hpp:260
double water_heat_capacity
Definition SolverOptions2D.hpp:266
FaceDepth2D face_reconstruction
Definition SolverOptions2D.hpp:458
int bed_heat_model
Definition SolverOptions2D.hpp:262
bool bed_heat_authored
Definition SolverOptions2D.hpp:263
bool transport_age
Definition SolverOptions2D.hpp:413
bool coriolis_f_set
Definition SolverOptions2D.hpp:281
int8_t evaporation
Definition SolverOptions2D.hpp:406
double max_timestep
Definition SolverOptions2D.hpp:308
double mesh_to_si_factor
Definition SolverOptions2D.hpp:620
double smagorinsky_cs
Definition SolverOptions2D.hpp:272
double exchange_beta
Definition SolverOptions2D.hpp:508
double eddy_viscosity_background
Definition SolverOptions2D.hpp:276
std::vector< std::string > report_2d_species
Definition SolverOptions2D.hpp:366
CouplingHead2D coupling_head
[2D_OPTIONS] COUPLING_HEAD CELL|VERTEX|STENCIL_WET_MEAN (default CELL).
Definition SolverOptions2D.hpp:334
double vol_1d_to_2d
1D volume → 2D volume (ft³→m³, exact 0.3048³)
Definition SolverOptions2D.hpp:576
bool heat_surface_authored
Definition SolverOptions2D.hpp:261
RainfallMode rainfall_mode
Definition SolverOptions2D.hpp:442
double mixing_length_coefficient
Definition SolverOptions2D.hpp:280
double bc_flow_to_si_applied
Definition SolverOptions2D.hpp:636
bool wall_drag_enabled
Derived from authored WALL_DRAG edges; not a global input switch.
Definition SolverOptions2D.hpp:283
bool coupling_in_flooding
Definition SolverOptions2D.hpp:535
double dry_depth
Dry cell threshold (m)
Definition SolverOptions2D.hpp:309
double coriolisParameter() const noexcept
Definition SolverOptions2D.hpp:287
bool heat_radiative_authored
Definition SolverOptions2D.hpp:261
bool report_2d
Write 2D results to output.
Definition SolverOptions2D.hpp:352
bool heat_model_authored
Definition SolverOptions2D.hpp:259
int coupling_coeffs
Definition SolverOptions2D.hpp:338
unsigned report_2d_vars
Definition SolverOptions2D.hpp:363
double coupling_rim_band
Definition SolverOptions2D.hpp:347
double theta_reference_step
[2D_OPTIONS] THETA_REFERENCE_STEP, s >= 0
Definition SolverOptions2D.hpp:479
int num_threads
Definition SolverOptions2D.hpp:588
CouplingPondMode2D coupling_pond_mode
[2D_OPTIONS] COUPLING_POND_MODE FOOTPRINT|CHAMBER|TRACKING.
Definition SolverOptions2D.hpp:340
double h_move
Definition SolverOptions2D.hpp:488
double coupling_cd
Definition SolverOptions2D.hpp:330
bool momentumPhysics() const noexcept
Definition SolverOptions2D.hpp:284
std::string gw_et
Definition SolverOptions2D.hpp:436
std::string infil_destination
Definition SolverOptions2D.hpp:400
double vfr_min_wet_frac
Definition SolverOptions2D.hpp:465
double cfl_number
Definition SolverOptions2D.hpp:480
Coriolis2D coriolis
Optional horizontal momentum physics; CPU FULL_SWE, global timestep only.
Definition SolverOptions2D.hpp:270
int8_t coupling_equalize
Definition SolverOptions2D.hpp:351
Turbulence2D turbulence
Definition SolverOptions2D.hpp:271
int requested_threads
Definition SolverOptions2D.hpp:594
double coupling_sync
Definition SolverOptions2D.hpp:328
int8_t groundwater
Definition SolverOptions2D.hpp:429
bool coupled_heat
Definition SolverOptions2D.hpp:259
int8_t infiltration
Definition SolverOptions2D.hpp:383
double theta
Definition SolverOptions2D.hpp:475
bool pending_rows_drained
Definition SolverOptions2D.hpp:628
bool auto_backend_cpu
Definition SolverOptions2D.hpp:545
double coriolis_latitude
Definition SolverOptions2D.hpp:272
double flux_dh_eps
Definition SolverOptions2D.hpp:319
CouplingLaw2D coupling_law
[2D_OPTIONS] COUPLING_LAW ORIFICE|WEIR_ORIFICE (default ORIFICE).
Definition SolverOptions2D.hpp:332
double len_1d_to_2d
1D length → 2D length (ft→m, 0.3048)
Definition SolverOptions2D.hpp:574
std::string infil_default_method
Definition SolverOptions2D.hpp:394
bool mesh_scaled_to_si
Definition SolverOptions2D.hpp:611
double coriolis_f
Definition SolverOptions2D.hpp:272
double infil_step
Definition SolverOptions2D.hpp:388
int lts_tiers
[2D_OPTIONS] LTS_TIERS, 1..8 (1 = global dt)
Definition SolverOptions2D.hpp:493
int front_rebuild
Definition SolverOptions2D.hpp:300
int output_compression
Definition SolverOptions2D.hpp:360
Momentum2D momentum
[2D_OPTIONS] MOMENTUM_EQUATION — momentum closure (see Momentum2D).
Definition SolverOptions2D.hpp:268
bool transport_msx
Definition SolverOptions2D.hpp:412
double exchange_relax
Definition SolverOptions2D.hpp:520
bool coupling_area_auto
Definition SolverOptions2D.hpp:524
openswmm::FilePathPair output_file
Definition SolverOptions2D.hpp:558
int reconstruction_order
Definition SolverOptions2D.hpp:305
OutputPrecision2D output_precision
Definition SolverOptions2D.hpp:357
double flow_1d_to_2d
1D flow → 2D flow (ft³/s→m³/s, exact 0.3048³)
Definition SolverOptions2D.hpp:577
bool advection
Definition SolverOptions2D.hpp:505