OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm_inflows_impl.cpp File Reference

C API implementation — external inflows, DWF, RDII. More...

#include "openswmm_api_common.hpp"
#include "../../../include/openswmm/engine/openswmm_inflows.h"
#include "../data/InflowData.hpp"
#include "../edit/ObjectDeleter.hpp"
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
Include dependency graph for openswmm_inflows_impl.cpp:

Functions

SWMM_ENGINE_API int swmm_ext_inflow_add (SWMM_Engine engine, int node_idx, const char *constituent, const char *ts_name, const char *type, double m_factor, double s_factor, double baseline, const char *pattern)
 Add an external inflow to a node.
 
SWMM_ENGINE_API int swmm_ext_inflow_set_scale (SWMM_Engine engine, int entry_idx, double scale)
 Replace an external-inflow timeseries scale factor.
 
SWMM_ENGINE_API int swmm_ext_inflow_set_baseline (SWMM_Engine engine, int entry_idx, double baseline)
 Replace one external-inflow baseline.
 
SWMM_ENGINE_API int swmm_ext_inflow_get (SWMM_Engine engine, int entry_idx, int *node_idx, char *constituent_buf, int constituent_buflen, char *ts_buf, int ts_buflen, char *type_buf, int type_buflen, double *m_factor, double *s_factor, double *baseline, char *pattern_buf, int pattern_buflen)
 Read back an external inflow entry by index.
 
SWMM_ENGINE_API int swmm_ext_inflow_remove (SWMM_Engine engine, int entry_idx)
 Remove an external inflow entry by index.
 
SWMM_ENGINE_API int swmm_dwf_add (SWMM_Engine engine, int node_idx, const char *constituent, double avg_value, const char *pat1, const char *pat2, const char *pat3, const char *pat4)
 Add a dry weather flow component to a node.
 
SWMM_ENGINE_API int swmm_dwf_get (SWMM_Engine engine, int entry_idx, int *node_idx, char *constituent_buf, int constituent_buflen, double *avg_value, char *pat1_buf, int pat1_buflen, char *pat2_buf, int pat2_buflen, char *pat3_buf, int pat3_buflen, char *pat4_buf, int pat4_buflen)
 Read back a dry weather flow entry by index.
 
SWMM_ENGINE_API int swmm_dwf_remove (SWMM_Engine engine, int entry_idx)
 Remove a DWF entry by index. Subsequent entries shift down.
 
SWMM_ENGINE_API int swmm_dwf_set_baseline (SWMM_Engine engine, int entry_idx, double avg_value)
 Replace one dry-weather-flow average value.
 
SWMM_ENGINE_API int swmm_rdii_add (SWMM_Engine engine, int node_idx, const char *uh_name, double area)
 Add RDII inflow to a node using a unit hydrograph.
 
SWMM_ENGINE_API int swmm_rdii_get (SWMM_Engine engine, int entry_idx, int *node_idx, char *uh_buf, int buflen, double *area)
 Read back an RDII assignment by entry index.
 
SWMM_ENGINE_API int swmm_rdii_remove (SWMM_Engine engine, int entry_idx)
 Remove an RDII entry by index. Subsequent entries shift down.
 
SWMM_ENGINE_API int swmm_hydrograph_add (SWMM_Engine engine, const char *uh_name, int month, int response, double r, double t, double k, double dmax, double drecov, double dinit)
 Add a unit hydrograph parameter line.
 
SWMM_ENGINE_API int swmm_hydrograph_get (SWMM_Engine engine, int entry_idx, char *uh_buf, int buflen, int *month, int *response, double *r, double *t, double *k, double *dmax, double *drecov, double *dinit)
 Read back a hydrograph parameter entry by index.
 
SWMM_ENGINE_API int swmm_hydrograph_count (SWMM_Engine engine)
 Count stored hydrograph parameter rows, including duplicate keys.
 
SWMM_ENGINE_API int swmm_hydrograph_add_gage (SWMM_Engine engine, const char *uh_name, const char *gage_name)
 Assign a rain gage to a unit hydrograph group.
 
SWMM_ENGINE_API int swmm_hydrograph_get_gage (SWMM_Engine engine, int entry_idx, char *uh_buf, int uh_buflen, char *gage_buf, int gage_buflen)
 Read back a UH-to-gage assignment by index.
 
SWMM_ENGINE_API int swmm_hydrograph_gage_count (SWMM_Engine engine)
 Count stored hydrograph-to-gage assignment rows.
 
SWMM_ENGINE_API int swmm_hydrograph_group_count (SWMM_Engine engine)
 Count the unique unit-hydrograph group names defined.
 
SWMM_ENGINE_API int swmm_hydrograph_group_id (SWMM_Engine engine, int idx, char *buf, int buflen)
 Read back the name of a unit-hydrograph group by its zero-based index.
 
SWMM_ENGINE_API int swmm_rdii_decay_add (SWMM_Engine engine, const char *uh_name, int response, double k_dep, double k_0, double k_T, double T_ref, double theta_rec, double T_freeze, int snow_on, double snow_T, double snow_ddf)
 Append an exponential-depletion and temperature-dependent IA-recovery row.
 
SWMM_ENGINE_API int swmm_rdii_decay_get (SWMM_Engine engine, int entry_idx, char *uh_buf, int buflen, int *response, double *k_dep, double *k_0, double *k_T, double *T_ref, double *theta_rec, double *T_freeze, int *snow_on, double *snow_T, double *snow_ddf)
 Read back an exponential-decay parameter row by index.
 
SWMM_ENGINE_API int swmm_rdii_decay_count (SWMM_Engine engine)
 Count stored exponential-decay rows.
 
SWMM_ENGINE_API int swmm_hydrograph_set_rtk (SWMM_Engine engine, const char *uh_name, int month, int response, double r, double t, double k)
 Upsert R/T/K parameters for one (group, month, response) row.
 
SWMM_ENGINE_API int swmm_hydrograph_set_ia (SWMM_Engine engine, const char *uh_name, int month, int response, double dmax, double drecov, double dinit)
 Upsert linear-IA parameters for one (group, month, response) row.
 
SWMM_ENGINE_API int swmm_hydrograph_remove_entry (SWMM_Engine engine, const char *uh_name, int month, int response)
 Remove the first matching hydrograph parameter row.
 
SWMM_ENGINE_API int swmm_hydrograph_remove_group (SWMM_Engine engine, const char *uh_name)
 Remove all authoring rows and RDII assignments for a hydrograph group.
 
SWMM_ENGINE_API int swmm_hydrograph_clear_group_months (SWMM_Engine engine, const char *uh_name)
 Remove a group's month-specific parameter rows while retaining ALL rows.
 
SWMM_ENGINE_API int swmm_hydrograph_set_gage (SWMM_Engine engine, const char *uh_name, const char *gage_name)
 Set, replace, or clear the rain gage assigned to a UH group.
 
SWMM_ENGINE_API int swmm_hydrograph_group_rename (SWMM_Engine engine, int idx, const char *new_id)
 Rename a UH group, propagating the new name to parameter rows, gage assignments, [RDII_DECAY] rows, and [RDII] node assignments.
 
SWMM_ENGINE_API int swmm_rdii_decay_set (SWMM_Engine engine, const char *uh_name, int response, double k_dep, double k_0, double k_T, double T_ref, double theta_rec, double T_freeze, int snow_on, double snow_T, double snow_ddf)
 Upsert an exponential-depletion and temperature-dependent IA-recovery row.
 
SWMM_ENGINE_API int swmm_rdii_decay_remove (SWMM_Engine engine, const char *uh_name, int response)
 Remove the first exponential-decay row matching a group and response.
 
SWMM_ENGINE_API int swmm_ext_inflow_count (SWMM_Engine engine)
 Get the total number of external inflows defined.
 
SWMM_ENGINE_API int swmm_dwf_count (SWMM_Engine engine)
 Get the total number of dry weather flow entries defined.
 
SWMM_ENGINE_API int swmm_rdii_count (SWMM_Engine engine)
 Get the total number of RDII entries defined.
 

Detailed Description

C API implementation — external inflows, DWF, RDII.

See also
include/openswmm/engine/openswmm_inflows.h
Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
License
Apache-2.0

Function Documentation

◆ swmm_dwf_add()

SWMM_ENGINE_API int swmm_dwf_add ( SWMM_Engine engine,
int node_idx,
const char * constituent,
double avg_value,
const char * pat1,
const char * pat2,
const char * pat3,
const char * pat4 )

Add a dry weather flow component to a node.

Dry weather flow represents the base sanitary flow entering the system at a node, modulated by up to four time patterns.

Parameters
[in]engineEngine handle.
[in]node_idxZero-based index of the receiving node.
[in]constituentConstituent name ("FLOW" or a pollutant name).
[in]avg_valueAverage DWF value.
[in]pat1Monthly time pattern name (NULL for none).
[in]pat2Daily time pattern name (NULL for none).
[in]pat3Hourly time pattern name (NULL for none).
[in]pat4Weekend time pattern name (NULL for none).
Returns
SWMM_OK on success, or an error code.
Note
A null engine returns SWMM_ERR_BADHANDLE. A failed inflow row/pollutant index check returns SWMM_ERR_BADINDEX. No lifecycle guard; mutations rebuild the inflow cache outside BUILDING/OPENED. Input strings are copied; unresolved names and numeric values are stored without validation here.
Here is the call graph for this function:

◆ swmm_dwf_count()

SWMM_ENGINE_API int swmm_dwf_count ( SWMM_Engine engine)

Get the total number of dry weather flow entries defined.

Parameters
[in]engineEngine handle.
Returns
Number of DWF entries, or -1 on error.

◆ swmm_dwf_get()

SWMM_ENGINE_API int swmm_dwf_get ( SWMM_Engine engine,
int entry_idx,
int * node_idx,
char * constituent_buf,
int constituent_buflen,
double * avg_value,
char * pat1_buf,
int pat1_buflen,
char * pat2_buf,
int pat2_buflen,
char * pat3_buf,
int pat3_buflen,
char * pat4_buf,
int pat4_buflen )

Read back a dry weather flow entry by index.

Parameters
[in]engineEngine handle.
[in]entry_idxZero-based entry index (0..swmm_dwf_count()-1).
[out]node_idxReceiving node index.
[in]constituent_bufConstituent name (NUL-terminated).
[in]constituent_buflenSize of constituent_buf.
[out]avg_valueAverage value.
[out]pat1_bufMonthly pattern name (NUL-terminated; empty if none).
[in]pat1_buflenSize of pat1_buf.
[out]pat2_bufDaily pattern name.
[in]pat2_buflenSize of pat2_buf.
[out]pat3_bufHourly pattern name.
[in]pat3_buflenSize of pat3_buf.
[out]pat4_bufWeekend pattern name.
[in]pat4_buflenSize of pat4_buf.
Returns
SWMM_OK on success, or an error code.
Note
A null engine returns SWMM_ERR_BADHANDLE. A failed inflow row/pollutant index check returns SWMM_ERR_BADINDEX. Every declared output pointer is required; every text capacity must be positive, otherwise SWMM_ERR_BADPARAM. Text is copied into caller-owned buffers, NUL-terminated and silently truncated to capacity minus one byte.
Here is the call graph for this function:

◆ swmm_dwf_remove()

SWMM_ENGINE_API int swmm_dwf_remove ( SWMM_Engine engine,
int entry_idx )

Remove a DWF entry by index. Subsequent entries shift down.

Parameters
[in]engineEngine handle.
[in]entry_idxZero-based entry index (0..swmm_dwf_count()-1).
Returns
SWMM_OK on success, or an error code.
Note
A null engine returns SWMM_ERR_BADHANDLE. A failed inflow row/pollutant index check returns SWMM_ERR_BADINDEX. No lifecycle guard; mutations rebuild the inflow cache outside BUILDING/OPENED. Input strings are copied; unresolved names and numeric values are stored without validation here.
Here is the call graph for this function:

◆ swmm_dwf_set_baseline()

SWMM_ENGINE_API int swmm_dwf_set_baseline ( SWMM_Engine engine,
int entry_idx,
double avg_value )

Replace one dry-weather-flow average value.

Rebuilds the inflow cache in states other than BUILDING/OPENED; preserves all four pattern bindings.

Parameters
[in]engineNon-null live engine with exclusive caller access.
[in]entry_idxZero-based existing row index in the corresponding flat entry list.
[in]avg_valueAverage constituent value in input/display units (project flow units for FLOW); no finite/range validation.
Returns
SWMM_OK; SWMM_ERR_BADHANDLE for null engine, SWMM_ERR_BADINDEX for an invalid row index, or SWMM_ERR_BADPARAM for invalid required arguments.
Here is the call graph for this function:

◆ swmm_ext_inflow_add()

SWMM_ENGINE_API int swmm_ext_inflow_add ( SWMM_Engine engine,
int node_idx,
const char * constituent,
const char * ts_name,
const char * type,
double m_factor,
double s_factor,
double baseline,
const char * pattern )

Add an external inflow to a node.

External inflows define time-varying flows or pollutant loads applied at a node, optionally driven by a time series, with scaling, baseline, and pattern modifiers.

Parameters
[in]engineEngine handle.
[in]node_idxZero-based index of the receiving node.
[in]constituentConstituent name ("FLOW" for flow, a pollutant name, or the reserved species "__WATER_AGE__" — such a row prescribes the AGE, in HOURS, carried by the node's external inflow water, and wins over the [WATER_AGE_SOURCES] EXTERNAL_INFLOW entry (Z1, amendment D-Y4). It adds no water and no mass.
[in]ts_nameTime series name (NULL or "" for constant baseline only).
[in]typeInflow type: "FLOW", "CONCEN", or "MASS".
[in]m_factorMultiplier applied to the time series values.
[in]s_factorScale factor (unit conversion).
[in]baselineConstant baseline value added to the time series.
[in]patternTime pattern name (NULL or "" for none).
Returns
SWMM_OK on success, or an error code.
Note
A null engine returns SWMM_ERR_BADHANDLE. A failed inflow row/pollutant index check returns SWMM_ERR_BADINDEX. No lifecycle guard; mutations rebuild the inflow cache outside BUILDING/OPENED. Input strings are copied; unresolved names and numeric values are stored without validation here. A null type defaults to FLOW; constituent must be non-null. Appends a row rather than replacing an existing constituent/node pair.
Here is the call graph for this function:

◆ swmm_ext_inflow_count()

SWMM_ENGINE_API int swmm_ext_inflow_count ( SWMM_Engine engine)

Get the total number of external inflows defined.

Parameters
[in]engineEngine handle.
Returns
Number of external inflows, or -1 on error.

◆ swmm_ext_inflow_get()

SWMM_ENGINE_API int swmm_ext_inflow_get ( SWMM_Engine engine,
int entry_idx,
int * node_idx,
char * constituent_buf,
int constituent_buflen,
char * ts_buf,
int ts_buflen,
char * type_buf,
int type_buflen,
double * m_factor,
double * s_factor,
double * baseline,
char * pattern_buf,
int pattern_buflen )

Read back an external inflow entry by index.

The model stores external inflows as a flat SoA, indexed 0..swmm_ext_inflow_count()-1. To list a single node's inflows, iterate all entries and filter by node_idx.

Parameters
[in]engineEngine handle.
[in]entry_idxZero-based entry index.
[out]node_idxReceiving node index.
[in]constituent_bufConstituent name buffer (NUL-terminated).
[in]constituent_buflenSize of constituent_buf.
[out]ts_bufTime series name buffer (NUL-terminated; empty if none).
[in]ts_buflenSize of ts_buf.
[out]type_bufInflow type buffer (NUL-terminated; "FLOW"/"CONCEN"/"MASS").
[in]type_buflenSize of type_buf.
[out]m_factorMultiplier factor.
[out]s_factorScale factor.
[out]baselineBaseline value.
[out]pattern_bufPattern name buffer (NUL-terminated; empty if none).
[in]pattern_buflenSize of pattern_buf.
Returns
SWMM_OK on success, or an error code.
Note
A null engine returns SWMM_ERR_BADHANDLE. A failed inflow row/pollutant index check returns SWMM_ERR_BADINDEX. Every declared output pointer is required; every text capacity must be positive, otherwise SWMM_ERR_BADPARAM. Text is copied into caller-owned buffers, NUL-terminated and silently truncated to capacity minus one byte.
Here is the call graph for this function:

◆ swmm_ext_inflow_remove()

SWMM_ENGINE_API int swmm_ext_inflow_remove ( SWMM_Engine engine,
int entry_idx )

Remove an external inflow entry by index.

Entries with index > entry_idx shift down by one. Callers holding cached indices must re-resolve via swmm_ext_inflow_count() / iteration.

Parameters
[in]engineEngine handle.
[in]entry_idxZero-based entry index (0..swmm_ext_inflow_count()-1).
Returns
SWMM_OK on success, or an error code.
Note
A null engine returns SWMM_ERR_BADHANDLE. A failed inflow row/pollutant index check returns SWMM_ERR_BADINDEX. No lifecycle guard; mutations rebuild the inflow cache outside BUILDING/OPENED. Input strings are copied; unresolved names and numeric values are stored without validation here.
Here is the call graph for this function:

◆ swmm_ext_inflow_set_baseline()

SWMM_ENGINE_API int swmm_ext_inflow_set_baseline ( SWMM_Engine engine,
int entry_idx,
double baseline )

Replace one external-inflow baseline.

Rebuilds the inflow cache in states other than BUILDING/OPENED. Does not change the timeseries, pattern or scale factors.

Parameters
[in]engineNon-null live engine with exclusive caller access.
[in]entry_idxZero-based existing row index in the corresponding flat entry list.
[in]baselineConstant baseline in the constituent input/display units; no finite/range validation.
Returns
SWMM_OK; SWMM_ERR_BADHANDLE for null engine, SWMM_ERR_BADINDEX for an invalid row index, or SWMM_ERR_BADPARAM for invalid required arguments.
Here is the call graph for this function:

◆ swmm_ext_inflow_set_scale()

SWMM_ENGINE_API int swmm_ext_inflow_set_scale ( SWMM_Engine engine,
int entry_idx,
double scale )

Replace an external-inflow timeseries scale factor.

Rebuilds the inflow cache in states other than BUILDING/OPENED so subsequent evaluation uses the new value. Does not change m_factor, baseline or other entries.

Parameters
[in]engineNon-null live engine with exclusive caller access.
[in]entry_idxZero-based existing row index in the corresponding flat entry list.
[in]scaleStored s_factor, used in the constituent input-unit conversion; no finite/range validation.
Returns
SWMM_OK; SWMM_ERR_BADHANDLE for null engine, SWMM_ERR_BADINDEX for an invalid row index, or SWMM_ERR_BADPARAM for invalid required arguments.
Here is the call graph for this function:

◆ swmm_hydrograph_add()

SWMM_ENGINE_API int swmm_hydrograph_add ( SWMM_Engine engine,
const char * uh_name,
int month,
int response,
double r,
double t,
double k,
double dmax,
double drecov,
double dinit )

Add a unit hydrograph parameter line.

Parameters
[in]engineEngine handle.
[in]uh_nameUnit hydrograph group name.
[in]month0..11 = JAN..DEC, or -1 for ALL months.
[in]response0 = SHORT, 1 = MEDIUM, 2 = LONG.
[in]rFraction of rainfall volume that becomes RDII.
[in]tTime to peak (hours).
[in]kRatio of recession-limb time to time-to-peak (>= 0). Base time = t * (1 + k); the falling limb spans k * t hours.
[in]dmaxMaximum initial-abstraction depth (project depth units; 0 if unused).
[in]drecovLinear-model IA recovery rate (project depth/day; 0 if unused or if [RDII_DECAY] is configured).
[in]dinitInitial IA already used at start of simulation (project depth units; 0 if unused).
Returns
SWMM_OK on success, or an error code.
Note
A null engine returns SWMM_ERR_BADHANDLE. Always appends; duplicate keys are accepted. Required name pointers must be non-null, but empty/unresolved names are not rejected. No lifecycle guard or runtime RDII cache rebuild. Only month/response codes are range-checked; RTK and abstraction values are stored without finite/range validation.
Here is the call graph for this function:

◆ swmm_hydrograph_add_gage()

SWMM_ENGINE_API int swmm_hydrograph_add_gage ( SWMM_Engine engine,
const char * uh_name,
const char * gage_name )

Assign a rain gage to a unit hydrograph group.

Parameters
[in]engineEngine handle.
[in]uh_nameUnit hydrograph group name.
[in]gage_nameRain gage name.
Returns
SWMM_OK on success, or an error code.
Note
A null engine returns SWMM_ERR_BADHANDLE. Always appends; duplicate keys are accepted. Required name pointers must be non-null, but empty/unresolved names are not rejected. No lifecycle guard or runtime RDII cache rebuild.
Here is the call graph for this function:

◆ swmm_hydrograph_clear_group_months()

SWMM_ENGINE_API int swmm_hydrograph_clear_group_months ( SWMM_Engine engine,
const char * uh_name )

Remove a group's month-specific parameter rows while retaining ALL rows.

Case-insensitive name comparison; retains every month=-1 row, other groups, gage assignments and decay rows. Missing groups succeed. No lifecycle guard or runtime RDII cache rebuild.

Parameters
[in]engineNon-null live engine with exclusive caller access.
[in]uh_nameNon-null, nonempty copied unit-hydrograph group name; matched case-insensitively for hydrograph rows.
Returns
SWMM_OK; SWMM_ERR_BADHANDLE for null engine, SWMM_ERR_BADINDEX for an invalid row index, or SWMM_ERR_BADPARAM for invalid required arguments.

◆ swmm_hydrograph_count()

SWMM_ENGINE_API int swmm_hydrograph_count ( SWMM_Engine engine)

Count stored hydrograph parameter rows, including duplicate keys.

Parameters
[in]engineNon-null live engine with exclusive caller access.
Returns
Nonnegative row count, or -1 for a null engine.

◆ swmm_hydrograph_gage_count()

SWMM_ENGINE_API int swmm_hydrograph_gage_count ( SWMM_Engine engine)

Count stored hydrograph-to-gage assignment rows.

Parameters
[in]engineNon-null live engine with exclusive caller access.
Returns
Nonnegative row count, or -1 for a null engine.

◆ swmm_hydrograph_get()

SWMM_ENGINE_API int swmm_hydrograph_get ( SWMM_Engine engine,
int entry_idx,
char * uh_buf,
int buflen,
int * month,
int * response,
double * r,
double * t,
double * k,
double * dmax,
double * drecov,
double * dinit )

Read back a hydrograph parameter entry by index.

Parameters
[in]engineEngine handle.
[in]entry_idxZero-based index (0..swmm_hydrograph_count()-1).
[out]uh_bufUH group name buffer (NUL-terminated).
[in]buflenSize of uh_buf.
[out]monthMonth code (-1, or 0..11).
[out]responseResponse code (0..2).
[out]rRainfall fraction.
[out]tTime to peak (hours).
[out]kRecession ratio.
[out]dmaxIA max depth.
[out]drecovLinear IA recovery rate.
[out]dinitInitial IA used.
Returns
SWMM_OK on success, or an error code.
Note
A null engine returns SWMM_ERR_BADHANDLE. A failed inflow row/pollutant index check returns SWMM_ERR_BADINDEX. Every declared output pointer is required; every text capacity must be positive, otherwise SWMM_ERR_BADPARAM. Text is copied into caller-owned buffers, NUL-terminated and silently truncated to capacity minus one byte.
Here is the call graph for this function:

◆ swmm_hydrograph_get_gage()

SWMM_ENGINE_API int swmm_hydrograph_get_gage ( SWMM_Engine engine,
int entry_idx,
char * uh_buf,
int uh_buflen,
char * gage_buf,
int gage_buflen )

Read back a UH-to-gage assignment by index.

Parameters
[in]engineEngine handle.
[in]entry_idxZero-based index (0..swmm_hydrograph_gage_count()-1).
[out]uh_bufUH group name (NUL-terminated).
[in]uh_buflenSize of uh_buf.
[out]gage_bufRain gage name (NUL-terminated).
[in]gage_buflenSize of gage_buf.
Returns
SWMM_OK on success, or an error code.
Note
A null engine returns SWMM_ERR_BADHANDLE. A failed inflow row/pollutant index check returns SWMM_ERR_BADINDEX. Every declared output pointer is required; every text capacity must be positive, otherwise SWMM_ERR_BADPARAM. Text is copied into caller-owned buffers, NUL-terminated and silently truncated to capacity minus one byte.

◆ swmm_hydrograph_group_count()

SWMM_ENGINE_API int swmm_hydrograph_group_count ( SWMM_Engine engine)

Count the unique unit-hydrograph group names defined.

A unit-hydrograph "group" is identified by name; the engine stores one entry per (group, month, response). This count is the number of distinct nonempty group names across parameter entries and gage assignments, useful for enumerating groups in a UI without manually de-duplicating the per-entry list.

Parameters
[in]engineEngine handle.
Returns
Number of unique groups, or -1 on error.

◆ swmm_hydrograph_group_id()

SWMM_ENGINE_API int swmm_hydrograph_group_id ( SWMM_Engine engine,
int idx,
char * buf,
int buflen )

Read back the name of a unit-hydrograph group by its zero-based index.

Groups are enumerated in first-occurrence order across the parameter entry list, then gage assignments; names are deduplicated case-insensitively. Gage-only groups are included; decay-only names are not.

Parameters
[in]engineEngine handle.
[in]idxZero-based group index (0..swmm_hydrograph_group_count()-1).
[out]bufCaller-allocated buffer to receive the group name.
[in]buflenSize of buf in bytes.
Returns
SWMM_OK on success, or an error code.
Note
A null engine returns SWMM_ERR_BADHANDLE. A failed inflow row/pollutant index check returns SWMM_ERR_BADINDEX. Every declared output pointer is required; every text capacity must be positive, otherwise SWMM_ERR_BADPARAM. Text is copied into caller-owned buffers, NUL-terminated and silently truncated to capacity minus one byte.

◆ swmm_hydrograph_group_rename()

SWMM_ENGINE_API int swmm_hydrograph_group_rename ( SWMM_Engine engine,
int idx,
const char * new_id )

Rename a UH group, propagating the new name to parameter rows, gage assignments, [RDII_DECAY] rows, and [RDII] node assignments.

Parameters
[in]engineEngine handle.
[in]idxZero-based group index (0..swmm_hydrograph_group_count()-1).
[in]new_idNew group name (non-null, non-empty, must not already exist).
Returns
SWMM_OK on success, SWMM_ERR_BADPARAM if new_id is invalid or duplicates an existing group, or another error code.
Note
A null engine returns SWMM_ERR_BADHANDLE. A failed inflow row/pollutant index check returns SWMM_ERR_BADINDEX. Unique names use case-insensitive identity across parameter rows followed by gage assignments. Case-only renaming is permitted. Rewrites parameter/gage/decay/RDII references case-insensitively. No lifecycle guard or runtime RDII cache rebuild.
Here is the call graph for this function:

◆ swmm_hydrograph_remove_entry()

SWMM_ENGINE_API int swmm_hydrograph_remove_entry ( SWMM_Engine engine,
const char * uh_name,
int month,
int response )

Remove the first matching hydrograph parameter row.

Case-insensitive group key; absent rows succeed without mutation. Later flat indices shift down. No lifecycle guard or runtime RDII cache rebuild.

Parameters
[in]engineNon-null live engine with exclusive caller access.
[in]uh_nameNon-null, nonempty copied unit-hydrograph group name; matched case-insensitively for hydrograph rows.
[in]month-1 for ALL months or 0..11 for January..December.
[in]response0=SHORT, 1=MEDIUM or 2=LONG.
Returns
SWMM_OK; SWMM_ERR_BADHANDLE for null engine, SWMM_ERR_BADINDEX for an invalid row index, or SWMM_ERR_BADPARAM for invalid required arguments.

◆ swmm_hydrograph_remove_group()

SWMM_ENGINE_API int swmm_hydrograph_remove_group ( SWMM_Engine engine,
const char * uh_name )

Remove all authoring rows and RDII assignments for a hydrograph group.

Cascades through parameter rows, rain-gage assignments, exponential-decay rows and node RDII references using the edit deletion helper. Absent groups succeed. No lifecycle guard or runtime RDII cache rebuild.

Parameters
[in]engineNon-null live engine with exclusive caller access.
[in]uh_nameNon-null, nonempty borrowed group name; all deletion matches use exact case.
Returns
SWMM_OK; SWMM_ERR_BADHANDLE for null engine, SWMM_ERR_BADINDEX for an invalid row index, or SWMM_ERR_BADPARAM for invalid required arguments.
Here is the call graph for this function:

◆ swmm_hydrograph_set_gage()

SWMM_ENGINE_API int swmm_hydrograph_set_gage ( SWMM_Engine engine,
const char * uh_name,
const char * gage_name )

Set, replace, or clear the rain gage assigned to a UH group.

Parameters
[in]engineEngine handle.
[in]uh_nameUnit hydrograph group name (non-null, non-empty).
[in]gage_nameRain gage name, or NULL/empty to clear an existing assignment.
Returns
SWMM_OK on success, or an error code.
Note
A null engine returns SWMM_ERR_BADHANDLE. Upserts the first case-insensitive group assignment; NULL/empty gage removes that first assignment if present. The referenced gage is not resolved here. No lifecycle guard or runtime RDII cache rebuild.
Here is the call graph for this function:

◆ swmm_hydrograph_set_ia()

SWMM_ENGINE_API int swmm_hydrograph_set_ia ( SWMM_Engine engine,
const char * uh_name,
int month,
int response,
double dmax,
double drecov,
double dinit )

Upsert linear-IA parameters for one (group, month, response) row.

Parameters
[in]engineEngine handle.
[in]uh_nameUnit hydrograph group name (non-null, non-empty).
[in]month0..11 = JAN..DEC, or -1 for ALL.
[in]response0 = SHORT, 1 = MEDIUM, 2 = LONG.
[in]dmaxMaximum initial-abstraction depth.
[in]drecovLinear IA recovery rate.
[in]dinitInitial IA already used.
Returns
SWMM_OK on success, or an error code.
Note
A null engine returns SWMM_ERR_BADHANDLE. Matches the first case-insensitive (group,month,response) key; updates only the named fields, or appends with other numeric fields zero. Required names and month/response codes are checked, numeric values are not. No lifecycle guard or runtime RDII cache rebuild.
Here is the call graph for this function:

◆ swmm_hydrograph_set_rtk()

SWMM_ENGINE_API int swmm_hydrograph_set_rtk ( SWMM_Engine engine,
const char * uh_name,
int month,
int response,
double r,
double t,
double k )

Upsert R/T/K parameters for one (group, month, response) row.

Parameters
[in]engineEngine handle.
[in]uh_nameUnit hydrograph group name (non-null, non-empty).
[in]month0..11 = JAN..DEC, or -1 for ALL.
[in]response0 = SHORT, 1 = MEDIUM, 2 = LONG.
[in]rRainfall fraction.
[in]tTime to peak (hours).
[in]kRecession-limb-to-peak-time ratio (>= 0). Base time = t * (1 + k).
Returns
SWMM_OK on success, or an error code.
Note
A null engine returns SWMM_ERR_BADHANDLE. Matches the first case-insensitive (group,month,response) key; updates only the named fields, or appends with other numeric fields zero. Required names and month/response codes are checked, numeric values are not. No lifecycle guard or runtime RDII cache rebuild.
Here is the call graph for this function:

◆ swmm_rdii_add()

SWMM_ENGINE_API int swmm_rdii_add ( SWMM_Engine engine,
int node_idx,
const char * uh_name,
double area )

Add RDII inflow to a node using a unit hydrograph.

Associates a node with a unit hydrograph group and its sewershed area to compute rainfall-dependent infiltration/inflow.

Parameters
[in]engineEngine handle.
[in]node_idxZero-based index of the receiving node.
[in]uh_nameUnit hydrograph group name.
[in]areaSewershed area in project area units.
Returns
SWMM_OK on success, or an error code.
Note
A null engine returns SWMM_ERR_BADHANDLE. A failed inflow row/pollutant index check returns SWMM_ERR_BADINDEX. Copies the group name and stores area verbatim; group existence, area range and lifecycle are not checked. Does not rebuild the running RDII cache.
Here is the call graph for this function:

◆ swmm_rdii_count()

SWMM_ENGINE_API int swmm_rdii_count ( SWMM_Engine engine)

Get the total number of RDII entries defined.

Parameters
[in]engineEngine handle.
Returns
Number of RDII entries, or -1 on error.

◆ swmm_rdii_decay_add()

SWMM_ENGINE_API int swmm_rdii_decay_add ( SWMM_Engine engine,
const char * uh_name,
int response,
double k_dep,
double k_0,
double k_T,
double T_ref,
double theta_rec,
double T_freeze,
int snow_on,
double snow_T,
double snow_ddf )

Append an exponential-depletion and temperature-dependent IA-recovery row.

Always appends; duplicate keys are permitted. Negative rate/melt-factor comparisons are checked; provide finite values because no independent finiteness guard exists. No lifecycle guard or runtime RDII cache rebuild.

Parameters
[in]engineNon-null live engine with exclusive caller access.
[in]uh_nameCopied group name; non-null; empty names are not rejected. Group existence is not resolved here.
[in]response0=SHORT, 1=MEDIUM or 2=LONG.
[in]k_depNonnegative depletion rate, inverse project rainfall-depth units.
[in]k_0Nonnegative base recovery rate, per hour.
[in]k_TNonnegative thermal recovery rate at T_ref, per hour.
[in]T_refReference temperature, degrees C.
[in]theta_recThermal recovery sensitivity, inverse degrees C.
[in]T_freezeAir-temperature threshold below which recovery is suppressed, degrees C.
[in]snow_onZero disables; any nonzero value enables this row's degree-day snow model.
[in]snow_TRain/snow partition and melt-base temperature, degrees C.
[in]snow_ddfNonnegative melt factor, project rainfall-depth units per degree C per day.
Returns
SWMM_OK; SWMM_ERR_BADHANDLE for null engine, SWMM_ERR_BADINDEX for an invalid row index, or SWMM_ERR_BADPARAM for invalid required arguments.
Here is the call graph for this function:

◆ swmm_rdii_decay_count()

SWMM_ENGINE_API int swmm_rdii_decay_count ( SWMM_Engine engine)

Count stored exponential-decay rows.

Parameters
[in]engineNon-null live engine with exclusive caller access.
Returns
Nonnegative row count, or -1 for a null engine.

◆ swmm_rdii_decay_get()

SWMM_ENGINE_API int swmm_rdii_decay_get ( SWMM_Engine engine,
int entry_idx,
char * uh_buf,
int buflen,
int * response,
double * k_dep,
double * k_0,
double * k_T,
double * T_ref,
double * theta_rec,
double * T_freeze,
int * snow_on,
double * snow_T,
double * snow_ddf )

Read back an exponential-decay parameter row by index.

Parameters
[in]engineEngine handle.
[in]entry_idxZero-based index (0..swmm_rdii_decay_count()-1).
[out]uh_bufUH group name (NUL-terminated).
[in]buflenSize of uh_buf.
[out]responseResponse code (0..2).
[out]k_depDepletion rate.
[out]k_0Base recovery rate.
[out]k_TThermal recovery rate.
[out]T_refReference temperature.
[out]theta_recTemperature sensitivity.
[out]T_freezeFrozen-ground threshold.
[out]snow_onDegree-day snow model flag (0/1).
[out]snow_TRain/snow partition threshold & melt base (deg C).
[out]snow_ddfDegree-day melt factor.
Returns
SWMM_OK on success, or an error code.
Note
A null engine returns SWMM_ERR_BADHANDLE. A failed inflow row/pollutant index check returns SWMM_ERR_BADINDEX. Every declared output pointer is required; every text capacity must be positive, otherwise SWMM_ERR_BADPARAM. Text is copied into caller-owned buffers, NUL-terminated and silently truncated to capacity minus one byte.
Here is the call graph for this function:

◆ swmm_rdii_decay_remove()

SWMM_ENGINE_API int swmm_rdii_decay_remove ( SWMM_Engine engine,
const char * uh_name,
int response )

Remove the first exponential-decay row matching a group and response.

Absent keys succeed. Later flat row indices shift down. Does not remove hydrograph parameters or RDII node assignments; no runtime RDII cache rebuild.

Parameters
[in]engineNon-null live engine with exclusive caller access.
[in]uh_nameNon-null, nonempty group name; this decay-row lookup is case-sensitive.
[in]response0=SHORT, 1=MEDIUM or 2=LONG.
Returns
SWMM_OK; SWMM_ERR_BADHANDLE for null engine, SWMM_ERR_BADINDEX for an invalid row index, or SWMM_ERR_BADPARAM for invalid required arguments.

◆ swmm_rdii_decay_set()

SWMM_ENGINE_API int swmm_rdii_decay_set ( SWMM_Engine engine,
const char * uh_name,
int response,
double k_dep,
double k_0,
double k_T,
double T_ref,
double theta_rec,
double T_freeze,
int snow_on,
double snow_T,
double snow_ddf )

Upsert an exponential-depletion and temperature-dependent IA-recovery row.

Updates the first exact-case (group,response) match or appends. Negative rate/melt-factor comparisons are checked; provide finite values because no independent finiteness guard exists. No lifecycle guard or runtime RDII cache rebuild.

Parameters
[in]engineNon-null live engine with exclusive caller access.
[in]uh_nameCopied group name; non-null, nonempty, matched case-sensitively. Group existence is not resolved here.
[in]response0=SHORT, 1=MEDIUM or 2=LONG.
[in]k_depNonnegative depletion rate, inverse project rainfall-depth units.
[in]k_0Nonnegative base recovery rate, per hour.
[in]k_TNonnegative thermal recovery rate at T_ref, per hour.
[in]T_refReference temperature, degrees C.
[in]theta_recThermal recovery sensitivity, inverse degrees C.
[in]T_freezeAir-temperature threshold below which recovery is suppressed, degrees C.
[in]snow_onZero disables; any nonzero value enables this row's degree-day snow model.
[in]snow_TRain/snow partition and melt-base temperature, degrees C.
[in]snow_ddfNonnegative melt factor, project rainfall-depth units per degree C per day.
Returns
SWMM_OK; SWMM_ERR_BADHANDLE for null engine, SWMM_ERR_BADINDEX for an invalid row index, or SWMM_ERR_BADPARAM for invalid required arguments.
Here is the call graph for this function:

◆ swmm_rdii_get()

SWMM_ENGINE_API int swmm_rdii_get ( SWMM_Engine engine,
int entry_idx,
int * node_idx,
char * uh_buf,
int buflen,
double * area )

Read back an RDII assignment by entry index.

Parameters
[in]engineEngine handle.
[in]entry_idxZero-based index into the RDII assignment list (0..swmm_rdii_count()-1).
[out]node_idxReceiving node index.
[out]uh_bufBuffer to receive the unit hydrograph name (NUL-terminated, truncated if too small).
[in]buflenSize of uh_buf in bytes.
[out]areaSewershed area in project area units.
Returns
SWMM_OK on success, or an error code.
Note
A null engine returns SWMM_ERR_BADHANDLE. A failed inflow row/pollutant index check returns SWMM_ERR_BADINDEX. Every declared output pointer is required; every text capacity must be positive, otherwise SWMM_ERR_BADPARAM. Text is copied into caller-owned buffers, NUL-terminated and silently truncated to capacity minus one byte.
Here is the call graph for this function:

◆ swmm_rdii_remove()

SWMM_ENGINE_API int swmm_rdii_remove ( SWMM_Engine engine,
int entry_idx )

Remove an RDII entry by index. Subsequent entries shift down.

Parameters
[in]engineEngine handle.
[in]entry_idxZero-based entry index (0..swmm_rdii_count()-1).
Returns
SWMM_OK on success, or an error code.
Note
A null engine returns SWMM_ERR_BADHANDLE. A failed inflow row/pollutant index check returns SWMM_ERR_BADINDEX.
Here is the call graph for this function: