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

#include <LID.hpp>

Collaboration diagram for openswmm::lid::LIDSolver:

Classes

struct  CompletedUnitInput
 

Public Member Functions

void init (SimulationContext &ctx)
 Build eight type groups and initialize water state from resolved LID controls and usage.
 
LIDSolver waterTrial () const
 Copy water parameters, runtime state and ledgers for an independent trial.
 
void executeCompleted (double dt, double start, double recovery_factor, const std::vector< CompletedUnitInput > &inputs)
 Advance selected units with already-resolved completed-source forcing.
 
LIDGroupSoA & group (int type_index)
 Borrow mutable parameters and water state for a type group.
 
const LIDGroupSoA & group (int type_index) const
 Borrow read-only parameters and water state for a type group.
 
int numGroups () const
 Return the number of currently allocated type groups.
 
const std::vector< std::pair< int, int > > & usageOrder () const
 Borrow the deterministic legacy accumulation order for usage rows.
 
double storedVolume (const std::vector< int > *source_owners=nullptr) const
 Sum current planar, void-weighted layer storage for ordinary runoff continuity.
 
void checkpoint (detail::CompletedSourceArchive &a, bool model, bool lazy_buffers=false)
 Visit LID model identity or accepted-boundary water state in archive order.
 
void validateCheckpoint (const LIDSolver &model, std::size_t runoff_count) const
 Check restored LID water state against an initialized model.
 
double totalStoredVolume () const
 Sum the latest kernel water-balance final-store ledger over all unit footprints.
 
double totalInitVolume () const
 Sum the initialized water-balance store ledger over all unit footprints.
 
double totalInfilVolume () const
 Sum cumulative native plus spatial bottom exfiltration over all unit footprints.
 
double totalEvapVolume () const
 Sum cumulative evaporation over all unit footprints.
 
void execute (SimulationContext &ctx, double dt, double rainfall, double evap_rate, const std::vector< int > *source_owners=nullptr)
 Advance ordinary LID units with staged inflow and context-resolved evaporation.
 
void setRunoffTime (double old_runoff_sec)
 Set the old runoff clock used by regeneration and report timestamps.
 
void setNativeInfil (std::vector< double > native, std::vector< double > max_native)
 Take ownership of per-subcatchment native-soil rates for subsequent ordinary steps.
 
void setInfilFactors (std::vector< double > infil_factor, double recovery_factor)
 Take ownership of infiltration multipliers and set the evaporation recovery factor.
 
bool anyWet (const std::vector< int > *source_owners=nullptr) const
 Test the last evaluated wet flags of included units.
 

Static Public Member Functions

static void batchBioCellFlux (LIDGroupSoA &g, double rainfall, const double *evap_rate, double dt)
 Advance a standalone biocell/rain-garden group through the shared legacy kernel.
 
static void batchBarrelFlux (LIDGroupSoA &g, double rainfall, double dt)
 Advance a standalone rain-barrel group through the shared legacy kernel.
 
static void batchSwaleFlux (LIDGroupSoA &g, double rainfall, const double *evap_rate, double dt)
 Advance a standalone vegetative-swale group through the shared legacy kernel.
 
static void batchGreenRoofFlux (LIDGroupSoA &g, double rainfall, const double *evap_rate, double dt)
 Advance a standalone green-roof group through the shared legacy kernel.
 
static void batchInfilTrenchFlux (LIDGroupSoA &g, double rainfall, const double *evap_rate, double dt)
 Advance a standalone infiltration-trench group through the shared legacy kernel.
 
static void batchPavementFlux (LIDGroupSoA &g, double rainfall, const double *evap_rate, double dt)
 Advance a standalone permeable-pavement group through the shared legacy kernel.
 
static void batchRoofDisconFlux (LIDGroupSoA &g, double rainfall, const double *evap_rate, double dt)
 Advance a standalone roof-disconnection group through the shared legacy kernel.
 
static void batchSwaleModPuls (LIDGroupSoA &g, double rainfall, const double *evap_rate, double dt)
 Advance a standalone Modified Puls swale group through the shared legacy kernel.
 

Member Function Documentation

◆ anyWet()

bool openswmm::lid::LIDSolver::anyWet ( const std::vector< int > * source_owners = nullptr) const

Test the last evaluated wet flags of included units.

Parameters
[in]source_ownersOptional subcatchment map excluding nonnegative completed-source owners; must cover each nonnegative subcatch_idx examined, or at() throws std::out_of_range.
Returns
True if an included unit has a nonzero is_wet flag; false if none do. Flags reflect the most recent evaluation of each unit, including skipped units retaining older values.

◆ batchBarrelFlux()

void openswmm::lid::LIDSolver::batchBarrelFlux ( LIDGroupSoA & g,
double rainfall,
double dt )
static

Advance a standalone rain-barrel group through the shared legacy kernel.

Updates depths, rates, ledgers, wet/dry clocks and drain history without a context or report IO. Native infiltration is zero, its ceiling 1e10 ft/s, factors 1 and old runoff time zero. All wrappers use the same dispatcher; swales iterate with omega=0.5, other ordinary types use one explicit Modified Puls evaluation. Evaporation is zero for this entry point.

Parameters
[in,out]gInitialized parallel arrays for the intended rain-barrel type; dispatch actually follows g.type, not the wrapper name. Each unit needs positive geometry required by that type.
[in]rainfallFallback inflow in ft/s when a unit staged inflow is not positive; covered rain barrels force inflow to zero.
[in]dtPositive interval in seconds; unchecked.

◆ batchBioCellFlux()

void openswmm::lid::LIDSolver::batchBioCellFlux ( LIDGroupSoA & g,
double rainfall,
const double * evap_rate,
double dt )
static

Advance a standalone biocell/rain-garden group through the shared legacy kernel.

Updates depths, rates, ledgers, wet/dry clocks and drain history without a context or report IO. Native infiltration is zero, its ceiling 1e10 ft/s, factors 1 and old runoff time zero. All wrappers use the same dispatcher; swales iterate with omega=0.5, other ordinary types use one explicit Modified Puls evaluation. The PET array is borrowed and never retained.

Parameters
[in,out]gInitialized parallel arrays for the intended biocell/rain-garden type; dispatch actually follows g.type, not the wrapper name. Each unit needs positive geometry required by that type.
[in]rainfallFallback inflow in ft/s when a unit staged inflow is not positive; covered rain barrels force inflow to zero.
[in]evap_rateOptional readable g.count-element PET array in ft/s, used only during this call; null means zero.
[in]dtPositive interval in seconds; unchecked.

◆ batchGreenRoofFlux()

void openswmm::lid::LIDSolver::batchGreenRoofFlux ( LIDGroupSoA & g,
double rainfall,
const double * evap_rate,
double dt )
static

Advance a standalone green-roof group through the shared legacy kernel.

Updates depths, rates, ledgers, wet/dry clocks and drain history without a context or report IO. Native infiltration is zero, its ceiling 1e10 ft/s, factors 1 and old runoff time zero. All wrappers use the same dispatcher; swales iterate with omega=0.5, other ordinary types use one explicit Modified Puls evaluation. The PET array is borrowed and never retained.

Parameters
[in,out]gInitialized parallel arrays for the intended green-roof type; dispatch actually follows g.type, not the wrapper name. Each unit needs positive geometry required by that type.
[in]rainfallFallback inflow in ft/s when a unit staged inflow is not positive; covered rain barrels force inflow to zero.
[in]evap_rateOptional readable g.count-element PET array in ft/s, used only during this call; null means zero.
[in]dtPositive interval in seconds; unchecked.

◆ batchInfilTrenchFlux()

void openswmm::lid::LIDSolver::batchInfilTrenchFlux ( LIDGroupSoA & g,
double rainfall,
const double * evap_rate,
double dt )
static

Advance a standalone infiltration-trench group through the shared legacy kernel.

Updates depths, rates, ledgers, wet/dry clocks and drain history without a context or report IO. Native infiltration is zero, its ceiling 1e10 ft/s, factors 1 and old runoff time zero. All wrappers use the same dispatcher; swales iterate with omega=0.5, other ordinary types use one explicit Modified Puls evaluation. The PET array is borrowed and never retained.

Parameters
[in,out]gInitialized parallel arrays for the intended infiltration-trench type; dispatch actually follows g.type, not the wrapper name. Each unit needs positive geometry required by that type.
[in]rainfallFallback inflow in ft/s when a unit staged inflow is not positive; covered rain barrels force inflow to zero.
[in]evap_rateOptional readable g.count-element PET array in ft/s, used only during this call; null means zero.
[in]dtPositive interval in seconds; unchecked.

◆ batchPavementFlux()

void openswmm::lid::LIDSolver::batchPavementFlux ( LIDGroupSoA & g,
double rainfall,
const double * evap_rate,
double dt )
static

Advance a standalone permeable-pavement group through the shared legacy kernel.

Updates depths, rates, ledgers, wet/dry clocks and drain history without a context or report IO. Native infiltration is zero, its ceiling 1e10 ft/s, factors 1 and old runoff time zero. All wrappers use the same dispatcher; swales iterate with omega=0.5, other ordinary types use one explicit Modified Puls evaluation. The PET array is borrowed and never retained.

Parameters
[in,out]gInitialized parallel arrays for the intended permeable-pavement type; dispatch actually follows g.type, not the wrapper name. Each unit needs positive geometry required by that type.
[in]rainfallFallback inflow in ft/s when a unit staged inflow is not positive; covered rain barrels force inflow to zero.
[in]evap_rateOptional readable g.count-element PET array in ft/s, used only during this call; null means zero.
[in]dtPositive interval in seconds; unchecked.

◆ batchRoofDisconFlux()

void openswmm::lid::LIDSolver::batchRoofDisconFlux ( LIDGroupSoA & g,
double rainfall,
const double * evap_rate,
double dt )
static

Advance a standalone roof-disconnection group through the shared legacy kernel.

Updates depths, rates, ledgers, wet/dry clocks and drain history without a context or report IO. Native infiltration is zero, its ceiling 1e10 ft/s, factors 1 and old runoff time zero. All wrappers use the same dispatcher; swales iterate with omega=0.5, other ordinary types use one explicit Modified Puls evaluation. The PET array is borrowed and never retained.

Parameters
[in,out]gInitialized parallel arrays for the intended roof-disconnection type; dispatch actually follows g.type, not the wrapper name. Each unit needs positive geometry required by that type.
[in]rainfallFallback inflow in ft/s when a unit staged inflow is not positive; covered rain barrels force inflow to zero.
[in]evap_rateOptional readable g.count-element PET array in ft/s, used only during this call; null means zero.
[in]dtPositive interval in seconds; unchecked.

◆ batchSwaleFlux()

void openswmm::lid::LIDSolver::batchSwaleFlux ( LIDGroupSoA & g,
double rainfall,
const double * evap_rate,
double dt )
static

Advance a standalone vegetative-swale group through the shared legacy kernel.

Updates depths, rates, ledgers, wet/dry clocks and drain history without a context or report IO. Native infiltration is zero, its ceiling 1e10 ft/s, factors 1 and old runoff time zero. All wrappers use the same dispatcher; swales iterate with omega=0.5, other ordinary types use one explicit Modified Puls evaluation. The PET array is borrowed and never retained.

Parameters
[in,out]gInitialized parallel arrays for the intended vegetative-swale type; dispatch actually follows g.type, not the wrapper name. Each unit needs positive geometry required by that type.
[in]rainfallFallback inflow in ft/s when a unit staged inflow is not positive; covered rain barrels force inflow to zero.
[in]evap_rateOptional readable g.count-element PET array in ft/s, used only during this call; null means zero.
[in]dtPositive interval in seconds; unchecked.

◆ batchSwaleModPuls()

void openswmm::lid::LIDSolver::batchSwaleModPuls ( LIDGroupSoA & g,
double rainfall,
const double * evap_rate,
double dt )
static

Advance a standalone Modified Puls swale group through the shared legacy kernel.

Updates depths, rates, ledgers, wet/dry clocks and drain history without a context or report IO. Native infiltration is zero, its ceiling 1e10 ft/s, factors 1 and old runoff time zero. All wrappers use the same dispatcher; swales iterate with omega=0.5, other ordinary types use one explicit Modified Puls evaluation. The PET array is borrowed and never retained.

Parameters
[in,out]gInitialized parallel arrays for the intended Modified Puls swale type; dispatch actually follows g.type, not the wrapper name. Each unit needs positive geometry required by that type.
[in]rainfallFallback inflow in ft/s when a unit staged inflow is not positive; covered rain barrels force inflow to zero.
[in]evap_rateOptional readable g.count-element PET array in ft/s, used only during this call; null means zero.
[in]dtPositive interval in seconds; unchecked.

◆ checkpoint()

void openswmm::lid::LIDSolver::checkpoint ( detail::CompletedSourceArchive & a,
bool model,
bool lazy_buffers = false )

Visit LID model identity or accepted-boundary water state in archive order.

The group sequence and Green-Ampt state use fixed shapes. Report streams are never persisted. Call only at an accepted completed-source boundary with exclusive access, and validate restored state with validateCheckpoint(); this visitor itself does not validate or roll back reads.

Parameters
[in,out]aArchive that controls read, write or digest behavior; archive errors propagate and reads mutate this solver.
[in]modelTrue visits authored/resolved material, unit identities and order; false visits runtime water, Green-Ampt state, clocks and forcing buffers.
[in]lazy_buffersFor state archives only, allow the three runoff forcing buffers to use dynamic sizes for fresh session restore; false enforces existing fixed buffer shapes.

◆ execute()

void openswmm::lid::LIDSolver::execute ( SimulationContext & ctx,
double dt,
double rainfall,
double evap_rate,
const std::vector< int > * source_owners = nullptr )

Advance ordinary LID units with staged inflow and context-resolved evaporation.

A mismatched ownership-map size throws std::invalid_argument before evaluation. Skips nonpositive footprints; uses previously staged native infiltration/factors and runoff start time. Updates water states, fluxes, ledgers, wet flags and dry clocks, and lazily writes configured report files. No rollback is provided after evaluation starts. The per-unit old_drain_flow/drain_open history is left as stored; standalone batch entry points explicitly refresh it.

Parameters
[in,out]ctxInitialized model, names, forcing and simulation dates used to resolve PET and format optional reports; this routine does not scatter unit runoff/drains to context totals.
[in]dtPositive runoff interval in seconds; unchecked before divisions in the kernel.
[in]rainfallCompatibility argument, ignored; each group inflow must already contain rain plus captured runoff.
[in]evap_rateClimate potential evaporation fallback in ft/s; DRY_ONLY suppresses it during rain, and prescribed parent-subcatchment PET can override it.
[in]source_ownersOptional ownership map exactly ctx.n_subcatches() long; nonnegative entries exclude units owned by completed sources. Null evaluates all eligible units.
Here is the call graph for this function:

◆ executeCompleted()

void openswmm::lid::LIDSolver::executeCompleted ( double dt,
double start,
double recovery_factor,
const std::vector< CompletedUnitInput > & inputs )

Advance selected units with already-resolved completed-source forcing.

Validates the entire input batch before evaluation, throwing std::invalid_argument on a bad interval, key or value. Zero/nonpositive-area units are skipped. Updates selected water states, per-layer rates, ledgers, resolved inflow/PET/rain and dry clocks using completed-volume rules; it does not resolve forcing, write report files or scatter runoff to the context. Existing old_drain_flow/drain_open history is not refreshed by this entry point. Evaluation is in-place after validation; use waterTrial() for transactional trial ownership.

Parameters
[in]dtFinite positive interval length in seconds.
[in]startFinite nonnegative interval start in elapsed runoff seconds, used for pavement regeneration.
[in]recovery_factorFinite nonnegative Green-Ampt recovery multiplier.
[in]inputsStrictly increasing unique (type, unit) keys within initialized group bounds. All rate/ceiling/factor fields must be finite and nonnegative; spatial_fraction must be -1 or in [0,1]. Rates are ft/s; fractions and factors are dimensionless.
Here is the call graph for this function:

◆ group() [1/2]

LIDGroupSoA & openswmm::lid::LIDSolver::group ( int type_index)
inline

Borrow mutable parameters and water state for a type group.

Parameters
[in]type_indexUnchecked index in [0, numGroups()); after init(), the LIDType value 0..7.
Returns
Reference owned by this solver, invalidated by group reallocation or solver destruction. Caller edits must preserve parallel-array sizes and physical invariants.
Here is the caller graph for this function:

◆ group() [2/2]

const LIDGroupSoA & openswmm::lid::LIDSolver::group ( int type_index) const
inline

Borrow read-only parameters and water state for a type group.

Parameters
[in]type_indexUnchecked index in [0, numGroups()).
Returns
Const reference owned by this solver, invalidated by reinitialization, group reallocation or destruction.

◆ init()

void openswmm::lid::LIDSolver::init ( SimulationContext & ctx)

Build eight type groups and initialize water state from resolved LID controls and usage.

Converts authored lengths, areas and rates to internal ft/ft2/ft/s, resolves drain destinations, seeds moisture, Green-Ampt history and water ledgers, and orders units by subcatchment then reverse usage parse order. Invalid control indices or unknown type codes are skipped. Intended for a fresh solver: existing report streams and ancillary forcing buffers are not cleared; the zero-usage early return also leaves usage_order_ unchanged. No report file is opened here; allocation failures propagate.

Parameters
[in,out]ctxValidated model with parallel control/usage arrays; usage water ledgers and subcatchment total_lid_area_ft2 are updated.
Here is the call graph for this function:

◆ numGroups()

int openswmm::lid::LIDSolver::numGroups ( ) const
inline

Return the number of currently allocated type groups.

Returns
Zero for a default solver and eight after init().
Here is the caller graph for this function:

◆ setInfilFactors()

void openswmm::lid::LIDSolver::setInfilFactors ( std::vector< double > infil_factor,
double recovery_factor )
inline

Take ownership of infiltration multipliers and set the evaporation recovery factor.

Parameters
[in]infil_factorPer-subcatchment dimensionless Green-Ampt conductivity factors; moved into the solver. Missing indices default to 1.
[in]recovery_factorDimensionless Green-Ampt recovery multiplier used by subsequent ordinary steps; expected finite and nonnegative, unchecked.

◆ setNativeInfil()

void openswmm::lid::LIDSolver::setNativeInfil ( std::vector< double > native,
std::vector< double > max_native )
inline

Take ownership of per-subcatchment native-soil rates for subsequent ordinary steps.

Arrays may be empty or shorter than the subcatchment count; no size or value validation is performed here. Completed execution instead uses each explicit CompletedUnitInput.

Parameters
[in]nativeNative infiltration capacities in ft/s; moved into the solver. Missing indices use zero.
[in]max_nativeBottom exfiltration ceilings in ft/s; moved into the solver. Missing indices use 1e10 ft/s.

◆ setRunoffTime()

void openswmm::lid::LIDSolver::setRunoffTime ( double old_runoff_sec)
inline

Set the old runoff clock used by regeneration and report timestamps.

Parameters
[in]old_runoff_secElapsed seconds at the beginning of the next execute() interval; expected finite and nonnegative, unchecked.

◆ storedVolume()

double openswmm::lid::LIDSolver::storedVolume ( const std::vector< int > * source_owners = nullptr) const

Sum current planar, void-weighted layer storage for ordinary runoff continuity.

Parameters
[in]source_ownersOptional borrowed subcatchment ownership map; nonnegative entries exclude completed-source units. Must cover every nonnegative subcatch_idx accessed; short maps throw std::out_of_range.
Returns
Current included water in ft3, computed from layer states and aggregate footprints; swales use planar surface depth here. No ownership exclusion when null.

◆ totalEvapVolume()

double openswmm::lid::LIDSolver::totalEvapVolume ( ) const

Sum cumulative evaporation over all unit footprints.

Returns
Total in ft3, with no source-owner exclusion. Each per-area ledger depth is multiplied by the aggregate usage footprint.

◆ totalInfilVolume()

double openswmm::lid::LIDSolver::totalInfilVolume ( ) const

Sum cumulative native plus spatial bottom exfiltration over all unit footprints.

Returns
Total in ft3, with no source-owner exclusion. Each per-area ledger depth is multiplied by the aggregate usage footprint.

◆ totalInitVolume()

double openswmm::lid::LIDSolver::totalInitVolume ( ) const

Sum the initialized water-balance store ledger over all unit footprints.

Returns
Total in ft3, with no source-owner exclusion. Each per-area ledger depth is multiplied by the aggregate usage footprint.

◆ totalStoredVolume()

double openswmm::lid::LIDSolver::totalStoredVolume ( ) const

Sum the latest kernel water-balance final-store ledger over all unit footprints.

Returns
Total in ft3, with no source-owner exclusion. Uses wb_final_vol rather than recomputing current layer storage; kernel evaluation conventions can differ from storedVolume().

◆ usageOrder()

const std::vector< std::pair< int, int > > & openswmm::lid::LIDSolver::usageOrder ( ) const
inline

Borrow the deterministic legacy accumulation order for usage rows.

Shared per-subcatchment sums use this order to preserve floating-point addition order. Invalidated by reinitialization or destruction; the zero-usage init early return does not rebuild it.

Returns
Solver-owned (group index, unit index) pairs, ordered by ascending subcatchment index and reverse parse order within each subcatchment after init().
Here is the caller graph for this function:

◆ validateCheckpoint()

void openswmm::lid::LIDSolver::validateCheckpoint ( const LIDSolver & model,
std::size_t runoff_count ) const

Check restored LID water state against an initialized model.

Throws std::runtime_error on the first invalid state/material: mismatched counts, open report streams, invalid clocks, buffer values/shapes, nonfinite runtime fields, invalid moisture/depth/flags/ledgers, changed initial volumes or changed Green-Ampt material. Small negative depth/ledger roundoff is tolerated to 1e-12 and soil moisture to porosity + 1e-8. Fixed-array shape compatibility must already have been enforced by archive loading; this method uses unchecked indexing within each unit.

Parameters
[in]modelCompatible initialized reference with matching group counts and already-compatible array shapes; not modified.
[in]runoff_countRequired size of any nonempty per-subcatchment forcing buffer.

◆ waterTrial()

LIDSolver openswmm::lid::LIDSolver::waterTrial ( ) const

Copy water parameters, runtime state and ledgers for an independent trial.

The copy performs no forcing resolution or file IO. Advancing the trial does not mutate this solver; allocation failures propagate.

Returns
A solver with independent group/order/forcing storage and clocks, and no report streams.
Here is the caller graph for this function:

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