55#ifndef OPENSWMM_ENGINE_2D_SUBSURFACE_TRANSPORT_STATE_HPP
56#define OPENSWMM_ENGINE_2D_SUBSURFACE_TRANSPORT_STATE_HPP
97 int rowIndex(std::string_view name)
const noexcept {
98 for (std::size_t i = 0; i <
row_names.size(); ++i)
100 return static_cast<int>(i);
132 std::size_t
layerIdx(
int s,
int j,
int c)
const noexcept {
161 std::vector<double>
kd;
187 if (
kd.empty() || !(theta > 0.0))
189 const double k =
kd[
idx(s, c)];
192 const double R = 1.0 +
rho_b[
static_cast<std::size_t
>(c)] * k / theta;
193 return (R > 1.0) ? 1.0 / R : 1.0;
268 std::size_t
idx(
int s,
int c)
const noexcept {
269 return static_cast<std::size_t
>(s) *
static_cast<std::size_t
>(
n_cells) +
270 static_cast<std::size_t
>(c);
276 std::size_t
lateralIndex(
int species, std::size_t edge)
const noexcept {
277 return edge *
static_cast<std::size_t
>(
n_species) +
static_cast<std::size_t
>(species);
293 void resize(
int n_spec,
int n_cell,
int n_edges) {
295 n_cells = (n_cell > 0) ? n_cell : 0;
296 const auto ns =
static_cast<std::size_t
>(
n_species);
297 const auto nc =
static_cast<std::size_t
>(
n_cells);
298 const auto ne =
static_cast<std::size_t
>(n_edges > 0 ? n_edges : 0);
301 sacc_L.assign(ns * ne, 0.0);
302 sacc_R.assign(ns * ne, 0.0);
332 D_m.assign(
nc, 1.0e-9);
334 kd.assign(ns *
nc, 0.0);
365 for (std::size_t b = 0; b < nb; ++b)
366 m +=
nacc_mass[
static_cast<std::size_t
>(s) * nb + b];
368 const auto base =
static_cast<std::size_t
>(s) *
static_cast<std::size_t
>(
n_cells);
369 for (
int c = 0; c <
n_cells; ++c)
370 m +=
lacc_mass[base +
static_cast<std::size_t
>(c)];
372 for (
int c = 0; c <
n_cells; ++c) {
395 const auto base =
static_cast<std::size_t
>(s) *
static_cast<std::size_t
>(
n_cells);
396 for (
int c = 0; c <
n_cells; ++c) {
397 m +=
sat_mass[base +
static_cast<std::size_t
>(c)];
398 m +=
unsat_mass[base +
static_cast<std::size_t
>(c)];
403 for (std::size_t e = 0; e < ne; ++e) {
429 const auto base =
static_cast<std::size_t
>(s) *
static_cast<std::size_t
>(
n_cells);
430 for (
int c = 0; c <
n_cells; ++c)
431 m +=
sat_mass[base +
static_cast<std::size_t
>(c)] +
432 unsat_mass[base +
static_cast<std::size_t
>(c)];
434 for (std::size_t e = 0; e < ne; ++e) {
466 const auto us =
static_cast<std::size_t
>(s);
492 const auto us =
static_cast<std::size_t
>(s);
Definition NodeCoupling2D.cpp:23
Definition ExchangeLaw.hpp:60
Species mass in both aquifer zones, and where mass crossed a boundary.
Definition SubsurfaceTransportState.hpp:69
std::vector< double > D_m
molecular diffusivity (m²/s)
Definition SubsurfaceTransportState.hpp:156
std::vector< double > nacc_mass
Definition SubsurfaceTransportState.hpp:212
std::vector< double > contact_link_mass
Definition SubsurfaceTransportState.hpp:121
std::vector< double > lacc_mass
Definition SubsurfaceTransportState.hpp:215
std::vector< double > sacc_L
Definition SubsurfaceTransportState.hpp:199
int n_layers
Definition SubsurfaceTransportState.hpp:114
std::vector< double > boundary_out
Definition SubsurfaceTransportState.hpp:242
std::vector< double > generated_age
Definition SubsurfaceTransportState.hpp:245
double dissolvedFraction(int s, int c, double theta) const noexcept
The share of a cell's stored mass that is DISSOLVED and therefore mobile: 1 / R with the retardation ...
Definition SubsurfaceTransportState.hpp:184
std::vector< double > sacc_R
Definition SubsurfaceTransportState.hpp:199
bool dispersion_on
Whether dispersion runs at all ([GW_TRANSPORT_OPTIONS] DISPERSION).
Definition SubsurfaceTransportState.hpp:164
std::vector< double > xacc_to_surface
Definition SubsurfaceTransportState.hpp:206
double ledgeredStorage(int s) const noexcept
The storage the LEDGER can account for: holdings less the two surface accumulators,...
Definition SubsurfaceTransportState.hpp:427
std::vector< double > unsat_mass
[s*n_cells+c] in the column store
Definition SubsurfaceTransportState.hpp:111
double inFlight1D(int s) const noexcept
T7.4: mass in flight on the two 1D seams — booked by the producer, not yet taken by the owner....
Definition SubsurfaceTransportState.hpp:360
std::vector< double > init_mass
Definition SubsurfaceTransportState.hpp:249
std::vector< double > lost_node
to a 1D node through its bed
Definition SubsurfaceTransportState.hpp:233
std::vector< double > net_lateral
net across the domain edge (0 on a closed mesh)
Definition SubsurfaceTransportState.hpp:240
long dispersion_limiter_binds
Definition SubsurfaceTransportState.hpp:169
int rowIndex(std::string_view name) const noexcept
Row index of a species by name, or −1 — the [GW_*] sections address species by name and resolve throu...
Definition SubsurfaceTransportState.hpp:97
int n_cells
Definition SubsurfaceTransportState.hpp:73
std::vector< double > node_out_mass
Definition SubsurfaceTransportState.hpp:227
std::vector< double > gained_source
Definition SubsurfaceTransportState.hpp:241
int age_row
Definition SubsurfaceTransportState.hpp:76
std::vector< double > gained_contact
Definition SubsurfaceTransportState.hpp:246
std::vector< std::string > row_names
Definition SubsurfaceTransportState.hpp:78
std::vector< double > link_gain_shortfall
Definition SubsurfaceTransportState.hpp:223
std::size_t idx(int s, int c) const noexcept
Map a species/cell pair into bulk species-major storage.
Definition SubsurfaceTransportState.hpp:268
std::vector< double > lost_reaction
T7.2: first-order decay.
Definition SubsurfaceTransportState.hpp:244
std::size_t lateralIndex(int species, std::size_t edge) const noexcept
Index a lateral species packet in edge-major owned storage. Requires valid species/edge indices and c...
Definition SubsurfaceTransportState.hpp:276
int n_pollut
Definition SubsurfaceTransportState.hpp:74
std::vector< double > alpha_L
[GW_TRANSPORT_PARAMS] per cell, after * < TAG < CELL resolution.
Definition SubsurfaceTransportState.hpp:154
std::vector< double > internal_recharge
Definition SubsurfaceTransportState.hpp:252
int n_species
Definition SubsurfaceTransportState.hpp:72
std::vector< double > gained_infil
from the surface's infiltration
Definition SubsurfaceTransportState.hpp:237
double continuityDenominator(int s) const noexcept
T7.4 (2026-09-21): the scale a residual is judged against — what the aquifer started with plus every ...
Definition SubsurfaceTransportState.hpp:465
std::vector< double > lost_deep
deep percolation
Definition SubsurfaceTransportState.hpp:232
std::vector< double > alpha_T
transverse dispersivity (m)
Definition SubsurfaceTransportState.hpp:155
std::vector< double > lost_et
the intensive rows ET carried off
Definition SubsurfaceTransportState.hpp:236
std::vector< double > lost_dunne
saturation excess + rejection, to the surface
Definition SubsurfaceTransportState.hpp:235
double storage(int s) const noexcept
Everything the aquifer HOLDS of one species, including mass in flight in a side accumulator (the wate...
Definition SubsurfaceTransportState.hpp:393
std::vector< double > lost_source
wells, native concentration x m3
Definition SubsurfaceTransportState.hpp:241
std::vector< double > decay
Definition SubsurfaceTransportState.hpp:162
std::vector< double > lout_mass
Definition SubsurfaceTransportState.hpp:220
std::vector< double > contact_water
[j*n_cells+c], SI m3
Definition SubsurfaceTransportState.hpp:119
std::size_t layerIdx(int s, int j, int c) const noexcept
< layerIdx
Definition SubsurfaceTransportState.hpp:132
bool signedRow(int s) const noexcept
A row whose mass may legitimately be negative — the temperature row (°C·m³ below zero is a state,...
Definition SubsurfaceTransportState.hpp:87
std::vector< double > lost_link
to a gaining conduit (G-X4)
Definition SubsurfaceTransportState.hpp:234
std::vector< double > contact_node_mass
Definition SubsurfaceTransportState.hpp:121
std::vector< double > boundary_in
Definition SubsurfaceTransportState.hpp:242
bool active() const noexcept
Test whether the subsurface transport layout is nonempty.
Definition SubsurfaceTransportState.hpp:259
std::vector< double > contact_link_out
gross promised water, per bed/cell
Definition SubsurfaceTransportState.hpp:120
std::vector< double > boundary_flux_in
Definition SubsurfaceTransportState.hpp:242
std::vector< double > contact_node_out
Definition SubsurfaceTransportState.hpp:120
void clear()
Reset the complete subsurface transport state to empty defaults.
Definition SubsurfaceTransportState.hpp:344
std::vector< double > rho_b
Definition SubsurfaceTransportState.hpp:157
int temp_row
Definition SubsurfaceTransportState.hpp:77
std::vector< double > kd
Definition SubsurfaceTransportState.hpp:161
void refreshUnsat(int s, int c) noexcept
Refresh one derived unsaturated bulk inventory from canonical layers.
Definition SubsurfaceTransportState.hpp:145
std::vector< double > xacc_from_surface
Definition SubsurfaceTransportState.hpp:202
std::vector< double > gained_link
from a leaking conduit (T7.4 seam)
Definition SubsurfaceTransportState.hpp:239
int n_msx
Definition SubsurfaceTransportState.hpp:75
std::vector< double > boundary_flux_out
gross split of net_lateral
Definition SubsurfaceTransportState.hpp:243
std::vector< double > gained_node
from a recharging node (T7.4 seam)
Definition SubsurfaceTransportState.hpp:238
double residual(int s) const noexcept
T7.1's conservation statement, the twin of SurfaceTransportState::totalIncludingLedgers: what the aqu...
Definition SubsurfaceTransportState.hpp:491
std::vector< double > layer_mass
[(s*n_cells+c)*n_layers+j]
Definition SubsurfaceTransportState.hpp:115
std::vector< double > sat_mass
[s*n_cells+c] in the saturated water
Definition SubsurfaceTransportState.hpp:110
void resize(int n_spec, int n_cell, int n_edges)
Allocate/reset the core two-zone transport arrays and ledgers.
Definition SubsurfaceTransportState.hpp:293
double c_diff
explicit solute diffusion safety factor
Definition SubsurfaceTransportState.hpp:71