OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm::twoD::RuntimeForcings Struct Reference

#include <RuntimeCoupling.hpp>

Collaboration diagram for openswmm::twoD::RuntimeForcings:

Public Member Functions

RuntimeForcing * find (int channel, int cell)
 Find an exact channel/cell forcing row, including disabled retained rows.
 
const RuntimeForcing * get (int channel, int cell) const noexcept
 Resolve enabled cell-specific forcing with uniform fallback.
 
double rate (int channel, int cell, double native) const noexcept
 Resolve a forced scalar rate from a native value.
 
void replace (RuntimeForcing row)
 Upsert one forcing prescription while retaining its accumulated receipt.
 
void rebuild (int count)
 Rebuild channel/cell and uniform forcing gather indices.
 
bool active () const noexcept
 Test whether any retained runtime prescription is enabled.
 
double nextTime (double now) const noexcept
 Find the next enabled prescription expiry strictly after now.
 
void expire (double now) noexcept
 Disable all enabled prescriptions whose expiry has been reached.
 

Public Attributes

std::vector< RuntimeForcing > rows
 
std::vector< std::array< int, 4 > > cells
 
std::array< int, 4 > uniform {{-1, -1, -1, -1}}
 
std::unordered_map< int, std::unordered_map< int, std::size_t > > index
 

Member Function Documentation

◆ active()

bool openswmm::twoD::RuntimeForcings::active ( ) const
inlinenoexcept

Test whether any retained runtime prescription is enabled.

Returns
True if at least one row.enabled is true, otherwise false. Expiry time is not inspected; expire() must run first for time-based status.
Note
Read-only, allocation-free; serialize with registry mutations.

◆ expire()

void openswmm::twoD::RuntimeForcings::expire ( double now)
inlinenoexcept

Disable all enabled prescriptions whose expiry has been reached.

Parameters
[in]nowFinite elapsed simulation time, seconds; until <= now expires.
Postcondition
Keeps row identity and cumulative receipts; cached indices remain and get() checks enabled flags, falling back to uniform forcing.
Note
Requires exclusive registry access. No allocation or exceptions.

◆ find()

RuntimeForcing * openswmm::twoD::RuntimeForcings::find ( int channel,
int cell )
inline

Find an exact channel/cell forcing row, including disabled retained rows.

Parameters
[in]channelRuntime forcing channel key (normally 1..4).
[in]cellZero-based cell key, or negative uniform key as authored.
Returns
Borrowed mutable row pointer or NULL for no key. Invalidated by rows growth/replacement/destruction; never free it.
Precondition
index and rows are coherent. No allocation/mutation; serialize with edits.
Here is the caller graph for this function:

◆ get()

const RuntimeForcing * openswmm::twoD::RuntimeForcings::get ( int channel,
int cell ) const
inlinenoexcept

Resolve enabled cell-specific forcing with uniform fallback.

Parameters
[in]channelChannel in [1,4]; unchecked and used as channel-1 array offset.
[in]cellZero-based target cell; out-of-range/negative uses the uniform fallback directly.
Returns
Borrowed enabled row pointer, first the cell override then uniform, or NULL if neither is enabled. Expiry time is not checked here.
Precondition
Cached indices are rebuilt and coherent. Read-only, no allocation/exceptions; serialize with edits.
Here is the caller graph for this function:

◆ nextTime()

double openswmm::twoD::RuntimeForcings::nextTime ( double now) const
inlinenoexcept

Find the next enabled prescription expiry strictly after now.

Parameters
[in]nowFinite elapsed simulation time, seconds.
Returns
Earliest enabled until > now in elapsed seconds, or positive infinity if none exists.
Note
Read-only; expired/equal-time rows are skipped without disabling them. No allocation; serialize with edits.

◆ rate()

double openswmm::twoD::RuntimeForcings::rate ( int channel,
int cell,
double native ) const
inlinenoexcept

Resolve a forced scalar rate from a native value.

Parameters
[in]channelValid runtime channel [1,4].
[in]cellCell whose specific/uniform forcing is selected by get().
[in]nativeNative rate in the channel's units, normally m/s.
Returns
native when no row, native + row.rate for mode 2, otherwise row.rate.
Note
No validation, clamping, expiry or receipt update. Read-only and allocation-free; channel units must be consistent.
Here is the call graph for this function:

◆ rebuild()

void openswmm::twoD::RuntimeForcings::rebuild ( int count)
inline

Rebuild channel/cell and uniform forcing gather indices.

Parameters
[in]countNonnegative number of mesh cells.
Precondition
Every enabled channel is [1,4]; every nonnegative enabled cell is < count.
Postcondition
Replaces cells and uniform; later rows overwrite earlier duplicate placement. Does not rebuild the channel/cell identity map or alter receipts.
Exceptions
std::out_of_rangeFor a nonnegative cell outside count. Invalid channels are unchecked.
Note
May allocate and leave partial indices on failure; requires exclusive access.

◆ replace()

void openswmm::twoD::RuntimeForcings::replace ( RuntimeForcing row)
inline

Upsert one forcing prescription while retaining its accumulated receipt.

Parameters
[in]rowOwned draft with a validated channel/cell key and consistent units; moved into the registry.
Postcondition
Existing keys retain receipts; new rows keep their supplied receipt. Cached cell/uniform indices are not rebuilt automatically.
Note
Requires exclusive access. Allocation may throw after index changes; use a private staged registry for transactional publication. Input storage is not retained and row pointers may be invalidated.
Here is the call graph for this function:

Member Data Documentation

◆ cells

std::vector<std::array<int, 4> > openswmm::twoD::RuntimeForcings::cells

◆ index

std::unordered_map<int, std::unordered_map<int, std::size_t> > openswmm::twoD::RuntimeForcings::index

◆ rows

std::vector<RuntimeForcing> openswmm::twoD::RuntimeForcings::rows

◆ uniform

std::array<int, 4> openswmm::twoD::RuntimeForcings::uniform {{-1, -1, -1, -1}}

The documentation for this struct was generated from the following file: