![]() |
OpenSWMM Engine
6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
|
Public C API for snow packs, meteorology, and snow model configuration. More...
#include "openswmm_engine.h"Go to the source code of this file.
Classes | |
| struct | SWMM_UebSnowpack |
| struct | SWMM_SnowpackEdit |
| struct | SWMM_SnowState |
| struct | SWMM_SnowLedger |
| struct | SWMM_RadiationConfig |
| struct | SWMM_ClimateCloudConfig |
| struct | SWMM_ClimateMetSummary |
Typedefs | |
| typedef struct SWMM_UebSnowpack | SWMM_UebSnowpack |
| typedef struct SWMM_SnowpackEdit | SWMM_SnowpackEdit |
| typedef struct SWMM_SnowState | SWMM_SnowState |
| typedef struct SWMM_SnowLedger | SWMM_SnowLedger |
| typedef struct SWMM_RadiationConfig | SWMM_RadiationConfig |
| typedef struct SWMM_ClimateCloudConfig | SWMM_ClimateCloudConfig |
| typedef struct SWMM_ClimateMetSummary | SWMM_ClimateMetSummary |
Enumerations | |
| enum | { SWMM_SNOW_DEFAULT = -1 , SWMM_SNOW_DEGREE_DAY = 0 , SWMM_SNOW_UEB = 1 } |
Functions | |
| SWMM_ENGINE_API int | swmm_snow_get_model (SWMM_Engine engine, int *model) |
| Read the global snow-process model. | |
| SWMM_ENGINE_API int | swmm_snow_set_model (SWMM_Engine engine, int model) |
| Select the global snow-process model. | |
| SWMM_ENGINE_API int | swmm_snow_get_step (SWMM_Engine engine, double *seconds) |
| Read the snow-process cadence in seconds. | |
| SWMM_ENGINE_API int | swmm_snow_set_step (SWMM_Engine engine, double seconds) |
| Configure the snow-process cadence in seconds. | |
| SWMM_ENGINE_API int | swmm_ueb_option_get (SWMM_Engine engine, const char *key, char *value, int capacity) |
| Read a recognized UEB option in its input-section text format. | |
| SWMM_ENGINE_API int | swmm_ueb_option_set (SWMM_Engine engine, const char *key, const char *value) |
| Parse and assign one UEB option from a textual value. | |
| SWMM_ENGINE_API int | swmm_ueb_get_monthly_ranges (SWMM_Engine engine, double values[12]) |
| Read monthly mean diurnal temperature ranges. | |
| SWMM_ENGINE_API int | swmm_ueb_set_monthly_ranges (SWMM_Engine engine, const double values[12]) |
| Replace monthly mean diurnal temperature ranges. | |
| SWMM_ENGINE_API int | swmm_snowpack_get_ueb (SWMM_Engine engine, int pack, SWMM_UebSnowpack *value) |
| Read a named pack's UEB/model overrides. | |
| SWMM_ENGINE_API int | swmm_snowpack_set_ueb (SWMM_Engine engine, int pack, const SWMM_UebSnowpack *value) |
| Replace a named pack's UEB/model overrides. | |
| SWMM_ENGINE_API int | swmm_snowpack_apply (SWMM_Engine engine, const SWMM_SnowpackEdit *edits, int count, char *diagnostic, int capacity) |
| Validate and upsert a batch of named snowpacks as one atomic edit. | |
| SWMM_ENGINE_API int | swmm_subcatch_get_snow_process_state (SWMM_Engine engine, int subcatch, int surface, SWMM_SnowState *value) |
| Snapshot one subcatchment snow surface's accepted process state. | |
| SWMM_ENGINE_API int | swmm_snow_get_ueb_ledger (SWMM_Engine engine, SWMM_SnowLedger *value) |
| Aggregate the active UEB subcatchment water and energy inventory. | |
| SWMM_ENGINE_API int | swmm_climate_get_radiation (SWMM_Engine engine, SWMM_RadiationConfig *value) |
| Read the shared radiation site and source selectors. | |
| SWMM_ENGINE_API int | swmm_climate_set_radiation (SWMM_Engine engine, const SWMM_RadiationConfig *value) |
| Replace the shared radiation site and source selectors. | |
| SWMM_ENGINE_API int | swmm_climate_get_radiation_source (SWMM_Engine engine, int channel, char *value, int capacity) |
| Read one radiation source name or meteorology path. | |
| SWMM_ENGINE_API int | swmm_climate_set_radiation_source (SWMM_Engine engine, int channel, const char *value) |
| Bind one radiation source name or meteorology path. | |
| SWMM_ENGINE_API int | swmm_snow_apply_configuration (SWMM_Engine engine, const char *temperature_rows, const char *ueb_rows, char *diagnostic, int capacity) |
| Atomically replace global snow/radiation section configuration. | |
| SWMM_ENGINE_API int | swmm_climate_get_cloud (SWMM_Engine engine, SWMM_ClimateCloudConfig *config, char *series, int capacity) |
| Snapshot the shared heat/climatology cloud configuration and series name. | |
| SWMM_ENGINE_API int | swmm_climate_preview_meteorology (SWMM_Engine engine, const char *path, SWMM_ClimateMetSummary *result, char *diagnostic, int capacity) |
| Read and validate hourly meteorology without changing the model binding. | |
| SWMM_ENGINE_API int | swmm_snow_apply_configuration_with_cloud (SWMM_Engine engine, const char *temperature_rows, const char *ueb_rows, const SWMM_ClimateCloudConfig *cloud, const char *cloud_series, char *diagnostic, int capacity) |
| Atomically replace global snow/radiation section configuration, optionally including clouds. | |
Public C API for snow packs, meteorology, and snow model configuration.
| typedef struct SWMM_ClimateCloudConfig SWMM_ClimateCloudConfig |
| typedef struct SWMM_ClimateMetSummary SWMM_ClimateMetSummary |
| typedef struct SWMM_RadiationConfig SWMM_RadiationConfig |
| typedef struct SWMM_SnowLedger SWMM_SnowLedger |
| typedef struct SWMM_SnowpackEdit SWMM_SnowpackEdit |
| typedef struct SWMM_SnowState SWMM_SnowState |
| typedef struct SWMM_UebSnowpack SWMM_UebSnowpack |
| SWMM_ENGINE_API int swmm_climate_get_cloud | ( | SWMM_Engine | engine, |
| SWMM_ClimateCloudConfig * | config, | ||
| char * | series, | ||
| int | capacity ) |
Snapshot the shared heat/climatology cloud configuration and series name.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [out] | config | Non-null configuration: mode 0 default, 1 constant or 2 series, fraction dimensionless and attenuation coefficients in their authored convention. |
| [out] | series | Non-null writable name buffer; empty when no valid series binding exists. |
| [in] | capacity | Positive byte capacity including the terminator; a short buffer returns SWMM_ERR_BUFSIZE and writes nothing. |
| SWMM_ENGINE_API int swmm_climate_get_radiation | ( | SWMM_Engine | engine, |
| SWMM_RadiationConfig * | value ) |
Read the shared radiation site and source selectors.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [out] | value | Non-null configuration. Site latitude/longitude are degrees, timezone hours and elevation m. Modes are 0 computed, 1 time series, 2 met file; authored flags control legacy-alias preservation. |
| SWMM_ENGINE_API int swmm_climate_get_radiation_source | ( | SWMM_Engine | engine, |
| int | channel, | ||
| char * | value, | ||
| int | capacity ) |
Read one radiation source name or meteorology path.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [in] | channel | 0 shortwave time series, 1 longwave time series, 2 met-file path. |
| [out] | value | Non-null writable string buffer. |
| [in] | capacity | Positive byte capacity including the terminator; insufficient capacity returns SWMM_ERR_BUFSIZE and writes nothing. |
| SWMM_ENGINE_API int swmm_climate_preview_meteorology | ( | SWMM_Engine | engine, |
| const char * | path, | ||
| SWMM_ClimateMetSummary * | result, | ||
| char * | diagnostic, | ||
| int | capacity ) |
Read and validate hourly meteorology without changing the model binding.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [in] | path | Non-null filename; relative paths resolve from the input file's parent directory. |
| [out] | result | Non-null summary with record count, half-open SWMM-date coverage, and min/max columns in degrees C, relative-humidity percent, m/s, and W/m2 radiation. |
| [out] | diagnostic | Non-null writable text buffer; empty on success. |
| [in] | capacity | Positive byte capacity; an error message may be safely truncated. |
| SWMM_ENGINE_API int swmm_climate_set_radiation | ( | SWMM_Engine | engine, |
| const SWMM_RadiationConfig * | value ) |
Replace the shared radiation site and source selectors.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [in] | value | Non-null configuration. Site latitude/longitude are degrees, timezone hours and elevation m. Modes are 0 computed, 1 time series, 2 met file; authored flags control legacy-alias preservation. |
| SWMM_ENGINE_API int swmm_climate_set_radiation_source | ( | SWMM_Engine | engine, |
| int | channel, | ||
| const char * | value ) |
Bind one radiation source name or meteorology path.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [in] | channel | 0 shortwave time series, 1 longwave time series, 2 met-file path. |
| [in] | value | Non-null null-terminated source text; newline and quote characters are rejected. |
| SWMM_ENGINE_API int swmm_snow_apply_configuration | ( | SWMM_Engine | engine, |
| const char * | temperature_rows, | ||
| const char * | ueb_rows, | ||
| char * | diagnostic, | ||
| int | capacity ) |
Atomically replace global snow/radiation section configuration.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [in] | temperature_rows | Non-null null-terminated TEMPERATURE section body without headers. |
| [in] | ueb_rows | Non-null null-terminated UEB section body without headers. Empty bodies restore defaults; existing named-pack assignments are preserved. |
| [out] | diagnostic | Non-null writable buffer, empty on success or a validation message on failure. |
| [in] | capacity | Positive byte capacity; diagnostics are truncated safely to fit. |
| SWMM_ENGINE_API int swmm_snow_apply_configuration_with_cloud | ( | SWMM_Engine | engine, |
| const char * | temperature_rows, | ||
| const char * | ueb_rows, | ||
| const SWMM_ClimateCloudConfig * | cloud, | ||
| const char * | cloud_series, | ||
| char * | diagnostic, | ||
| int | capacity ) |
Atomically replace global snow/radiation section configuration, optionally including clouds.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [in] | temperature_rows | Non-null null-terminated TEMPERATURE section body without headers. |
| [in] | ueb_rows | Non-null null-terminated UEB section body without headers. Empty bodies restore defaults; existing named-pack assignments are preserved. |
| [in] | cloud | Optional shared cloud configuration; NULL preserves it. Mode is 0 default, 1 constant or 2 time series; fraction is [0, 1] and attenuation coefficients/exponents are finite nonnegative values. |
| [in] | cloud_series | Required existing series name for cloud mode 2; ignored when cloud is NULL or a non-series mode is selected. |
| [out] | diagnostic | Non-null writable buffer, empty on success or a validation message on failure. |
| [in] | capacity | Positive byte capacity; diagnostics are truncated safely to fit. |
| SWMM_ENGINE_API int swmm_snow_get_model | ( | SWMM_Engine | engine, |
| int * | model ) |
Read the global snow-process model.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [out] | model | Non-null result slot: SWMM_SNOW_DEGREE_DAY (0) or SWMM_SNOW_UEB (1). |
| SWMM_ENGINE_API int swmm_snow_get_step | ( | SWMM_Engine | engine, |
| double * | seconds ) |
Read the snow-process cadence in seconds.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [out] | seconds | Non-null result slot for the authored cadence. |
| SWMM_ENGINE_API int swmm_snow_get_ueb_ledger | ( | SWMM_Engine | engine, |
| SWMM_SnowLedger * | value ) |
Aggregate the active UEB subcatchment water and energy inventory.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [out] | value | Non-null caller-owned ledger: elapsed_s in seconds, water categories in m3, and energy categories in kJ. Transfers are signed into the inventory; inactive duplicate native columns are excluded. |
| SWMM_ENGINE_API int swmm_snow_set_model | ( | SWMM_Engine | engine, |
| int | model ) |
Select the global snow-process model.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [in] | model | SWMM_SNOW_DEGREE_DAY (0) or SWMM_SNOW_UEB (1). |
| SWMM_ENGINE_API int swmm_snow_set_step | ( | SWMM_Engine | engine, |
| double | seconds ) |
Configure the snow-process cadence in seconds.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [in] | seconds | Finite cadence in [1, 21600] seconds, validated by the SNOW_STEP parser. |
| SWMM_ENGINE_API int swmm_snowpack_apply | ( | SWMM_Engine | engine, |
| const SWMM_SnowpackEdit * | edits, | ||
| int | count, | ||
| char * | diagnostic, | ||
| int | capacity ) |
Validate and upsert a batch of named snowpacks as one atomic edit.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [in] | edits | Borrowed count-element edit array; may be NULL only for count == 0. Pack names must be nonempty, unique case-insensitively within the batch, and contain no newline/quote characters. Surface/removal units follow the existing three snowpack rows; UEB fields use SI units from SWMM_UebSnowpack. |
| [in] | count | Nonnegative number of pack edits; omitted existing packs are preserved. |
| [out] | diagnostic | Non-null writable diagnostic buffer; empty on successful validation. |
| [in] | capacity | Positive diagnostic byte capacity; error text may be truncated with a terminator. |
| SWMM_ENGINE_API int swmm_snowpack_get_ueb | ( | SWMM_Engine | engine, |
| int | pack, | ||
| SWMM_UebSnowpack * | value ) |
Read a named pack's UEB/model overrides.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [in] | pack | Zero-based snowpack index, in [0, snowpack count). |
| [out] | value | Non-null destination structure. Forest/drift are dimensionless, ground heat W/m2, extinction depth m and initial energy kJ/m2. An absent row returns SWMM_SNOW_DEFAULT with standard site defaults. |
| SWMM_ENGINE_API int swmm_snowpack_set_ueb | ( | SWMM_Engine | engine, |
| int | pack, | ||
| const SWMM_UebSnowpack * | value ) |
Replace a named pack's UEB/model overrides.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [in] | pack | Zero-based snowpack index, in [0, snowpack count). |
| [in] | value | Non-null configuration structure. Forest/drift are dimensionless, ground heat W/m2, extinction depth m and initial energy kJ/m2. SWMM_SNOW_DEFAULT removes the explicit override; other models and site values are validated by the snowpack parser. |
| SWMM_ENGINE_API int swmm_subcatch_get_snow_process_state | ( | SWMM_Engine | engine, |
| int | subcatch, | ||
| int | surface, | ||
| SWMM_SnowState * | value ) |
Snapshot one subcatchment snow surface's accepted process state.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [in] | subcatch | Zero-based valid subcatchment index. |
| [in] | surface | 0 plowable, 1 impervious, or 2 pervious. |
| [out] | value | Non-null caller-owned state. SWE/depth is subarea-averaged m, liquid/sublimation rates m/s, temperatures degrees C, covered-pack energy kJ/m2, water age seconds, and other fractions/age terms dimensionless. |
| SWMM_ENGINE_API int swmm_ueb_get_monthly_ranges | ( | SWMM_Engine | engine, |
| double | values[12] ) |
Read monthly mean diurnal temperature ranges.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [out] | values | Non-null caller-owned array of twelve writable doubles, January through December, in degrees Celsius. An inherited month reads as zero. |
| SWMM_ENGINE_API int swmm_ueb_option_get | ( | SWMM_Engine | engine, |
| const char * | key, | ||
| char * | value, | ||
| int | capacity ) |
Read a recognized UEB option in its input-section text format.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [in] | key | Non-null null-terminated UEB key, accepted by uebOptionValue(). |
| [out] | value | Non-null writable string buffer; receives the complete value and terminator. |
| [in] | capacity | Positive byte capacity including the terminator; insufficient capacity returns SWMM_ERR_BUFSIZE and writes nothing. |
| SWMM_ENGINE_API int swmm_ueb_option_set | ( | SWMM_Engine | engine, |
| const char * | key, | ||
| const char * | value ) |
Parse and assign one UEB option from a textual value.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [in] | key | Non-null null-terminated UEB option key. |
| [in] | value | Non-null null-terminated value text, tokenized using input-file syntax. |
| SWMM_ENGINE_API int swmm_ueb_set_monthly_ranges | ( | SWMM_Engine | engine, |
| const double | values[12] ) |
Replace monthly mean diurnal temperature ranges.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [in] | values | Non-null caller-owned array of twelve readable doubles, January through December, in degrees Celsius. Each value must be finite and in [0, 100]; zero selects temperature-source derivation. The whole array is validated before publication. |