![]() |
OpenSWMM Engine
6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
|
#include <DegreeDaySnow.hpp>
Public Member Functions | |
| void | init (int n_subcatch) |
| Reset native three-subarea storage through SnowSoA::resize(). | |
| void | initializeElements (int n) override |
| Allocate native storage rounded up to whole three-element packs. | |
| void | step (int e, const surface::SnowInputs &input, surface::SnowOutputs &output) override |
| Accumulate and melt one SI point element without batch plowing. | |
| int | stateSize () const override |
| Read the fixed native per-element payload size. | |
| void | pack (int e, double *output) const override |
| Copy twelve native element history values without validating the buffer. | |
| void | unpack (int e, const double *input) override |
| Assign twelve native element history fields from a matching payload. | |
| void | execute (SimulationContext &ctx, double dt, double temp, double wind, const double *rainfall, const double *snowfall, double gamma=0.0, double ea=0.0) override |
| Melt every enabled native-owned batch pack after snowfall/plowing preparation. | |
| void | execute (SimulationContext &ctx, double dt, double temp, double wind, double rainfall, double snowfall=0.0, double gamma=0.0, double ea=0.0) |
| Broadcast native precipitation rates then call the array melt overload. | |
| void | setMeltCoeffs (int day_of_year) |
| Update every native subarea's seasonal degree-day coefficient. | |
| void | plowSnow (SimulationContext &ctx, double dt, const double *snowfall) override |
| Add native snowfall once, age packs, then redistribute plowable solid snow. | |
| void | plowSnow (SimulationContext &ctx, double dt, double snowfall) |
| Broadcast uniform snowfall then use native accumulation/plowing. | |
| SnowSoA & | state () |
| Borrow mutable native geometry, controls, ownership and pack history. | |
| const SnowSoA & | state () const |
| Borrow immutable current native snow state and liquid-flux outputs. | |
Public Member Functions inherited from openswmm::surface::SnowModel | |
| virtual | ~SnowModel ()=default |
| Destroy derived owned snow state through the base interface. Caller ends all active callbacks/borrows before destruction; no implicit commit. | |
|
overridevirtual |
Melt every enabled native-owned batch pack after snowfall/plowing preparation.
| ctx | Unused by this degree-day melt overload; geometry is already in soa_. |
| dt | Finite positive seconds, unchecked and used as divisor. |
| temp | Held air Fahrenheit. |
| wind | Held nonnegative mph for rain-on-snow. |
| rainfall | Readable n_subcatch finite nonnegative ft/s values. |
| snowfall | Readable n_subcatch finite nonnegative ft/s values, already added to wsnow by plowSnow; used for depletion/cold-content transitions, not added again. |
| gamma | Native psychrometric coefficient F^-1, default zero. |
| ea | Native vapour pressure in Hg, default zero. Processes three subareas in order, skips disabled/external source rows, computes liquid melt/coverage and optional out_age. Must pair exactly once with plowSnow and current setMeltCoeffs; does not advance context date or perform external UEB. No-op when n_subcatch==0. Invalid inputs can propagate without status/rollback. |
Implements openswmm::surface::SnowModel.
| void openswmm::snow::DegreeDaySnow::execute | ( | SimulationContext & | ctx, |
| double | dt, | ||
| double | temp, | ||
| double | wind, | ||
| double | rainfall, | ||
| double | snowfall = 0.0, | ||
| double | gamma = 0.0, | ||
| double | ea = 0.0 ) |
Broadcast native precipitation rates then call the array melt overload.
| ctx | Forwarded compatible context; unused by the degree-day melt kernel. |
| dt | Finite positive interval seconds. |
| temp | Held Fahrenheit. |
| wind | Held mph. |
| rainfall | Uniform finite nonnegative rain ft/s. |
| snowfall | Uniform snow ft/s, already accumulated by prior plowSnow. |
| gamma | Native psychrometric F^-1 coefficient. |
| ea | Native vapour pressure in Hg. Allocates temporary n_subcatch arrays, no-op for zero sources. Same ownership/ sequence/output contract as array execute; allocation exceptions propagate. |
| void openswmm::snow::DegreeDaySnow::init | ( | int | n_subcatch | ) |
Reset native three-subarea storage through SnowSoA::resize().
| n_subcatch | Nonnegative model source count with safe integer products/storage. Does not populate snowpack geometry/parameters or reset retained global controls/ removed totals. Caller configures compatible state before accumulation/melt. |
|
inlineoverridevirtual |
Allocate native storage rounded up to whole three-element packs.
| n | Nonnegative requested point count with n+2 representable as int. Calls init(ceil(n/3)), so actual step capacity is 3*ceil(n/3); extra slots are allocated/defaulted too. Does not load physical parameters or distinguish mesh from native sources; caller supplies per-element configuration and ownership. |
Implements openswmm::surface::SnowModel.
|
overridevirtual |
Copy twelve native element history values without validating the buffer.
| e | Valid allocated flat index, unchecked. | |
| [out] | output | Writable twelve doubles: wsnow/fw/coldc(ft), ati(F), awe, imelt(ft/s), si(ft), sba/sbws/asc (depletion fractions/indices), age/out_age(seconds). No metadata/version, unit conversion, global state or complete restart identity. Serialize reads with mutation; pointer is borrowed only during the call. |
Implements openswmm::surface::SnowModel.
|
overridevirtual |
Add native snowfall once, age packs, then redistribute plowable solid snow.
| [in,out] | ctx | Compatible source geometry/project units, total LID areas and cross-source plow destinations; context is read for physical non-LID footprints. |
| dt | Finite positive seconds; no general validation (instant plow melt alone guards dt>0). Caller follows once with execute() for the same interval. | |
| snowfall | Readable n_subcatch finite nonnegative snow ft/s values. Skips disabled/external donor sources. First pass ages existing complete-mix water and adds new snow at precip_age, then a separate pass plows to removal, native impervious/pervious, instant melt or another pervious source. Zero threshold plows every step. Fractions/areas must be qualified; only their total donor subtraction is capped at one. Conservative mode or external receivers include donor/receiver physical-area ratio; ordinary legacy transfer preserves its fraction-only arithmetic. Can transfer cold energy to an external UEB receiver and records removed ft3. Mutates owned histories immediately; no conservation diagnostic/rollback or clock advance, and external receivers must be settled by their own qualified driver. |
Implements openswmm::surface::SnowModel.
| void openswmm::snow::DegreeDaySnow::plowSnow | ( | SimulationContext & | ctx, |
| double | dt, | ||
| double | snowfall ) |
Broadcast uniform snowfall then use native accumulation/plowing.
| [in,out] | ctx | Compatible geometry/units forwarded to array plowSnow. |
| dt | Finite positive seconds. | |
| snowfall | Uniform finite nonnegative ft/s, added exactly once per enabled native pack before melt execution. No-op with zero sources; temporary allocation can throw. Same plowing/age/ownership and immediate-mutation contract as array overload. |
| void openswmm::snow::DegreeDaySnow::setMeltCoeffs | ( | int | day_of_year | ) |
Update every native subarea's seasonal degree-day coefficient.
| day_of_year | Valid ordinal [1,366], unchecked. Stores sin(0.0172615*(day-81)) season and interpolates current dhm from dhmin/dhmax. This legacy phase/period is preserved, not normalized to 365 days. Does not advance water, reset age/fluxes, load parameters or skip externally owned/masked rows. |
|
inline |
Borrow mutable native geometry, controls, ownership and pack history.
|
inline |
Borrow immutable current native snow state and liquid-flux outputs.
|
inlineoverridevirtual |
Read the fixed native per-element payload size.
Implements openswmm::surface::SnowModel.
|
overridevirtual |
Accumulate and melt one SI point element without batch plowing.
| e | Flat allocated element index (source*3+subarea); invalid returns zeroed output. | |
| input | Finite positive dt_s; interval rain/snow depths metres, temperature C, wind m/s and native gamma/ea. Other weather/energy fields are ignored by degree day. | |
| [out] | output | Reset first, even for invalid index/nonpositive dt. Replaces melt_m with total liquid pack drainage, throughfall_m with uncovered rain, swe_m with snow+free water and cover_frac. Thermal/albedo/sublimation fields stay zero. Adds snowfall once, ages/mixes the optional complete snow/free-water age pool and uses current seasonal melt coefficients/depletion history. Does not honor native enabled/external source masks or perform inter-element plowing: caller exclusively owns this element and sets coefficients first. No finite-input checks, status or rollback; dt NaN is not caught by the nonpositive guard. |
Implements openswmm::surface::SnowModel.
|
overridevirtual |
Assign twelve native element history fields from a matching payload.
| e | Valid allocated flat index, unchecked. |
| input | Readable twelve doubles in pack() order/native units. No finite, nonnegative, coverage or model/shape validation; caller qualifies payload before publishing a restart. Does not restore geometry/globals/masks or resize storage. |
Implements openswmm::surface::SnowModel.