OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
BedZoneData.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
71
72#ifndef OPENSWMM_ENGINE_DATA_BED_ZONE_DATA_HPP
73#define OPENSWMM_ENGINE_DATA_BED_ZONE_DATA_HPP
74
75#include <cstddef>
76#include <vector>
77
78namespace openswmm {
79
92 double thermal_diffusivity = 1.0e-6;
93
99 double solute_diffusivity = 1.0e-9;
100
104 double bed_thickness = 0.20;
105
111 double ground_depth = 2.0;
112
114 double ground_temp = 12.0;
115
122 bool has_ground_temp = false;
123
127
132 double hyporheic_velocity = 0.0;
133
135 double sed_density = 1670.0;
136
138 double sed_specific_heat = 1807.0;
139
143 double initial_temp = 12.0;
144 bool has_initial_temp = false;
145};
146
165 std::vector<double> link_temp;
169 std::vector<double> link_conc;
170 int n_species = 0;
171 bool seeded = false;
172
173 // ---- ARD (cell-resolved) bed. The per-link arrays above are the
174 // LEGACY and LARD substrate; under EULERIAN_ARD every CELL gets
175 // its own bed slice, 1:1 — which is exactly the reference's
176 // element mapping (HTSComponent pairs one HTS element with one
177 // channel element) and answers "which cell does the bed under a
178 // 400 ft conduit exchange with?" with "its own". The two shapes
179 // coexist because engine choice is per model and this state is
180 // runtime-only (not persisted), so nothing ever has to convert
181 // one into the other.
182 std::vector<double> cell_temp;
186 std::vector<double> cell_conc;
188 bool cells_seeded = false;
189
190 void resizeCells(int n_cells, int n_spec, double t_init) {
191 const auto nc = static_cast<std::size_t>(n_cells > 0 ? n_cells : 0);
192 const auto ns = static_cast<std::size_t>(n_spec > 0 ? n_spec : 0);
193 cell_n_species = static_cast<int>(ns);
194 cell_temp.assign(nc, t_init);
195 cell_conc.assign(ns * nc, 0.0);
196 cells_seeded = true;
197 }
198
199 void resize(int n_links, int n_spec, double t_init) {
200 const auto nl = static_cast<std::size_t>(n_links > 0 ? n_links : 0);
201 const auto ns = static_cast<std::size_t>(n_spec > 0 ? n_spec : 0);
202 n_species = static_cast<int>(ns);
203 link_temp.assign(nl, t_init);
204 link_conc.assign(nl * ns, 0.0);
205 seeded = false;
206 }
207
208 bool sized(int n_links) const noexcept {
209 return link_temp.size() == static_cast<std::size_t>(n_links > 0 ? n_links : 0);
210 }
211
212 void clear() { *this = BedZoneState{}; }
213};
214
215} // namespace openswmm
216
217#endif // OPENSWMM_ENGINE_DATA_BED_ZONE_DATA_HPP
Definition NodeCoupling.cpp:16
Runtime bed state, one entry per LINK.
Definition BedZoneData.hpp:164
std::vector< double > cell_temp
Definition BedZoneData.hpp:182
int n_species
Definition BedZoneData.hpp:170
int cell_n_species
Definition BedZoneData.hpp:187
std::vector< double > cell_conc
Definition BedZoneData.hpp:186
void clear()
Definition BedZoneData.hpp:212
std::vector< double > link_temp
Definition BedZoneData.hpp:165
void resize(int n_links, int n_spec, double t_init)
Definition BedZoneData.hpp:199
void resizeCells(int n_cells, int n_spec, double t_init)
Definition BedZoneData.hpp:190
std::vector< double > link_conc
Definition BedZoneData.hpp:169
bool seeded
Definition BedZoneData.hpp:171
bool sized(int n_links) const noexcept
Definition BedZoneData.hpp:208
bool cells_seeded
Definition BedZoneData.hpp:188
[SEDIMENT_EXCHANGE] — the bed zone's material and geometry.
Definition BedZoneData.hpp:88
double bed_thickness
Definition BedZoneData.hpp:104
double initial_temp
Definition BedZoneData.hpp:143
double ground_depth
Definition BedZoneData.hpp:111
double sed_density
Bed bulk density rho_sed, kg/m³ (htsmodel.cpp:50).
Definition BedZoneData.hpp:135
double ground_temp
Deep-ground temperature T_gr, °C. Constant spelling.
Definition BedZoneData.hpp:114
double hyporheic_velocity
Definition BedZoneData.hpp:132
bool has_ground_temp
Definition BedZoneData.hpp:122
double sed_specific_heat
Bed specific heat c_sed, J/kg/K (htsmodel.cpp:51).
Definition BedZoneData.hpp:138
int ground_ts_index
Definition BedZoneData.hpp:126
double thermal_diffusivity
Definition BedZoneData.hpp:92
bool has_initial_temp
Definition BedZoneData.hpp:144
double solute_diffusivity
Definition BedZoneData.hpp:99