OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm::snow::DegreeDaySnow Class Reference

#include <DegreeDaySnow.hpp>

Inheritance diagram for openswmm::snow::DegreeDaySnow:
Collaboration diagram for openswmm::snow::DegreeDaySnow:

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.
 

Member Function Documentation

◆ execute() [1/2]

void openswmm::snow::DegreeDaySnow::execute ( SimulationContext & ctx,
double dt,
double temp,
double wind,
const double * rainfall,
const double * snowfall,
double gamma = 0.0,
double ea = 0.0 )
overridevirtual

Melt every enabled native-owned batch pack after snowfall/plowing preparation.

Parameters
ctxUnused by this degree-day melt overload; geometry is already in soa_.
dtFinite positive seconds, unchecked and used as divisor.
tempHeld air Fahrenheit.
windHeld nonnegative mph for rain-on-snow.
rainfallReadable n_subcatch finite nonnegative ft/s values.
snowfallReadable n_subcatch finite nonnegative ft/s values, already added to wsnow by plowSnow; used for depletion/cold-content transitions, not added again.
gammaNative psychrometric coefficient F^-1, default zero.
eaNative 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.

Here is the caller graph for this function:

◆ execute() [2/2]

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.

Parameters
ctxForwarded compatible context; unused by the degree-day melt kernel.
dtFinite positive interval seconds.
tempHeld Fahrenheit.
windHeld mph.
rainfallUniform finite nonnegative rain ft/s.
snowfallUniform snow ft/s, already accumulated by prior plowSnow.
gammaNative psychrometric F^-1 coefficient.
eaNative 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.
Here is the call graph for this function:

◆ init()

void openswmm::snow::DegreeDaySnow::init ( int n_subcatch)

Reset native three-subarea storage through SnowSoA::resize().

Parameters
n_subcatchNonnegative 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.
Here is the caller graph for this function:

◆ initializeElements()

void openswmm::snow::DegreeDaySnow::initializeElements ( int n)
inlineoverridevirtual

Allocate native storage rounded up to whole three-element packs.

Parameters
nNonnegative 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.

Here is the call graph for this function:

◆ pack()

void openswmm::snow::DegreeDaySnow::pack ( int e,
double * output ) const
overridevirtual

Copy twelve native element history values without validating the buffer.

Parameters
eValid allocated flat index, unchecked.
[out]outputWritable 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.

Here is the call graph for this function:

◆ plowSnow() [1/2]

void openswmm::snow::DegreeDaySnow::plowSnow ( SimulationContext & ctx,
double dt,
const double * snowfall )
overridevirtual

Add native snowfall once, age packs, then redistribute plowable solid snow.

Parameters
[in,out]ctxCompatible source geometry/project units, total LID areas and cross-source plow destinations; context is read for physical non-LID footprints.
dtFinite positive seconds; no general validation (instant plow melt alone guards dt>0). Caller follows once with execute() for the same interval.
snowfallReadable 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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plowSnow() [2/2]

void openswmm::snow::DegreeDaySnow::plowSnow ( SimulationContext & ctx,
double dt,
double snowfall )

Broadcast uniform snowfall then use native accumulation/plowing.

Parameters
[in,out]ctxCompatible geometry/units forwarded to array plowSnow.
dtFinite positive seconds.
snowfallUniform 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.
Here is the call graph for this function:

◆ setMeltCoeffs()

void openswmm::snow::DegreeDaySnow::setMeltCoeffs ( int day_of_year)

Update every native subarea's seasonal degree-day coefficient.

Parameters
day_of_yearValid 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.

◆ state() [1/2]

SnowSoA & openswmm::snow::DegreeDaySnow::state ( )
inline

Borrow mutable native geometry, controls, ownership and pack history.

Returns
Owned SoA; resize/init/move/destruction can invalidate elements. Caller keeps all arrays aligned and physically valid and serializes edits with every snow call. No automatic model qualification, external UEB synchronization or trial rollback.
Here is the caller graph for this function:

◆ state() [2/2]

const SnowSoA & openswmm::snow::DegreeDaySnow::state ( ) const
inline

Borrow immutable current native snow state and liquid-flux outputs.

Returns
Owned SoA, flat source*3+subarea layout. Current imelt is ft/s; out_age seconds meaningful only for positive emitted liquid. Init/resize/replacement can invalidate elements and stepping changes contents; copy stable snapshots as needed.

◆ stateSize()

int openswmm::snow::DegreeDaySnow::stateSize ( ) const
inlineoverridevirtual

Read the fixed native per-element payload size.

Returns
Twelve doubles; pack/unpack omit geometry/global parameters, removed total, source masks, pending UEB transfer energy and external-solver runtime ownership.

Implements openswmm::surface::SnowModel.

Here is the caller graph for this function:

◆ step()

void openswmm::snow::DegreeDaySnow::step ( int e,
const surface::SnowInputs & input,
surface::SnowOutputs & output )
overridevirtual

Accumulate and melt one SI point element without batch plowing.

Parameters
eFlat allocated element index (source*3+subarea); invalid returns zeroed output.
inputFinite 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]outputReset 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.

◆ unpack()

void openswmm::snow::DegreeDaySnow::unpack ( int e,
const double * input )
overridevirtual

Assign twelve native element history fields from a matching payload.

Parameters
eValid allocated flat index, unchecked.
inputReadable 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.

Here is the call graph for this function:

The documentation for this class was generated from the following files: