![]() |
OpenSWMM Engine
6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
|
S7 (2026-09-19) — C API for the 2D surface-quality rows ([2D_COVERAGES], [2D_LOADINGS], [2D_CURB_LENGTH]) and the cell buildup store.
More...
#include "openswmm_engine.h"Go to the source code of this file.
Macros | |
| #define | SWMM_SQ2D_SCOPE_GLOBAL 0 |
| #define | SWMM_SQ2D_SCOPE_TAG 1 |
| #define | SWMM_SQ2D_SCOPE_CELL 2 |
Functions | |
| SWMM_ENGINE_API int | swmm_2d_coverage_count (SWMM_Engine engine, int *count) |
| Count authored 2D coverage scope rows. | |
| SWMM_ENGINE_API int | swmm_2d_coverage_set (SWMM_Engine engine, int scope, const char *tag, int cell, const char *const *landuses, const double *percents, int n) |
| Replace the complete land-use coverage set for one scope. | |
| SWMM_ENGINE_API int | swmm_2d_coverage_row_size (SWMM_Engine engine, int index, int *n) |
| Count the land-use pairs in an authored coverage row. | |
| SWMM_ENGINE_API int | swmm_2d_coverage_get (SWMM_Engine engine, int index, int k, int *scope, char *tag, int taglen, int *cell, char *landuse, int lulen, double *percent) |
| Copy the scope and one land-use/percentage pair of a coverage row. | |
| SWMM_ENGINE_API int | swmm_2d_coverage_remove (SWMM_Engine engine, int index) |
| Remove an authored 2D coverage scope row. | |
| SWMM_ENGINE_API int | swmm_2d_loading_count (SWMM_Engine engine, int *count) |
| Count authored 2D loading scope rows. | |
| SWMM_ENGINE_API int | swmm_2d_loading_set (SWMM_Engine engine, int scope, const char *tag, int cell, const char *species, double value) |
| Upsert a scope/species initial buildup loading. | |
| SWMM_ENGINE_API int | swmm_2d_loading_get (SWMM_Engine engine, int index, int *scope, char *tag, int taglen, int *cell, char *species, int splen, double *value) |
| Copy one authored initial-loading scope row. | |
| SWMM_ENGINE_API int | swmm_2d_loading_remove (SWMM_Engine engine, int index) |
| Remove an authored 2D loading scope row. | |
| SWMM_ENGINE_API int | swmm_2d_curb_length_count (SWMM_Engine engine, int *count) |
| Count authored 2D curb-length scope rows. | |
| SWMM_ENGINE_API int | swmm_2d_curb_length_set (SWMM_Engine engine, int scope, const char *tag, int cell, double length) |
| Upsert a scope's authored curb length. | |
| SWMM_ENGINE_API int | swmm_2d_curb_length_get (SWMM_Engine engine, int index, int *scope, char *tag, int taglen, int *cell, double *length) |
| Copy one authored curb-length scope row. | |
| SWMM_ENGINE_API int | swmm_2d_curb_length_remove (SWMM_Engine engine, int index) |
| Remove an authored 2D curb-length scope row. | |
| SWMM_ENGINE_API int | swmm_2d_get_buildup_bulk (SWMM_Engine engine, const char *species, double *out, int n) |
| Read per-cell total land-use buildup for an active surface species. | |
S7 (2026-09-19) — C API for the 2D surface-quality rows ([2D_COVERAGES], [2D_LOADINGS], [2D_CURB_LENGTH]) and the cell buildup store.
Rows are authored per SCOPE — the * row, a TAG row (every cell carrying the tag) or a CELL row — and resolve GLOBAL < TAG < CELL at initialize, exactly as the .inp sections do (one parser, one rule). A coverage row is the WHOLE land-use set of its scope: setting it replaces any earlier row with the same scope key.
Row edits need the engine OPENED or BUILDING (SWMM_ERR_LIFECYCLE otherwise); the read-backs work in every state, and the buildup store reads back once the run has started.
Units follow the project: percent for coverages, user mass per acre | hectare for loadings and buildup (lbs | kg; a reactions species declared in UG scales through its own unit factor), and the project's length unit for curb lengths.
| #define SWMM_SQ2D_SCOPE_CELL 2 |
one cell, 0-based here (1-based in the file)
| #define SWMM_SQ2D_SCOPE_GLOBAL 0 |
the * row
| #define SWMM_SQ2D_SCOPE_TAG 1 |
every cell carrying a tag
| SWMM_ENGINE_API int swmm_2d_coverage_count | ( | SWMM_Engine | engine, |
| int * | count ) |
Count authored 2D coverage scope rows.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [out] | count | Non-null caller-owned row-count slot; zero when no rows are authored. |
| SWMM_ENGINE_API int swmm_2d_coverage_get | ( | SWMM_Engine | engine, |
| int | index, | ||
| int | k, | ||
| int * | scope, | ||
| char * | tag, | ||
| int | taglen, | ||
| int * | cell, | ||
| char * | landuse, | ||
| int | lulen, | ||
| double * | percent ) |
Copy the scope and one land-use/percentage pair of a coverage row.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [in] | index | Zero-based authored coverage-row index. |
| [in] | k | Zero-based pair index, below swmm_2d_coverage_row_size(). |
| [out] | scope | Optional SWMM_SQ2D_SCOPE_* slot; NULL skips it. |
| [out] | tag | Optional writable tag string buffer. |
| [in] | taglen | Byte capacity; <= 0 skips the buffer, positive values truncate to len - 1 and append NUL. |
| [out] | cell | Optional zero-based cell slot; meaningful for CELL scope. |
| [out] | landuse | Optional writable selected land-use-name buffer. |
| [in] | lulen | Name-buffer byte capacity, with the same skip/truncation convention. |
| [out] | percent | Optional selected coverage percentage slot. |
| SWMM_ENGINE_API int swmm_2d_coverage_remove | ( | SWMM_Engine | engine, |
| int | index ) |
Remove an authored 2D coverage scope row.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [in] | index | Zero-based current row index; later row indices shift on removal. |
| SWMM_ENGINE_API int swmm_2d_coverage_row_size | ( | SWMM_Engine | engine, |
| int | index, | ||
| int * | n ) |
Count the land-use pairs in an authored coverage row.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [in] | index | Zero-based authored row index. |
| [out] | n | Non-null caller-owned pair-count slot for that row. |
| SWMM_ENGINE_API int swmm_2d_coverage_set | ( | SWMM_Engine | engine, |
| int | scope, | ||
| const char * | tag, | ||
| int | cell, | ||
| const char *const * | landuses, | ||
| const double * | percents, | ||
| int | n ) |
Replace the complete land-use coverage set for one scope.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [in] | scope | SWMM_SQ2D_SCOPE_GLOBAL, SWMM_SQ2D_SCOPE_TAG or SWMM_SQ2D_SCOPE_CELL. |
| [in] | tag | Required nonempty tag for TAG scope; ignored otherwise and may be NULL. |
| [in] | cell | Nonnegative zero-based cell for CELL scope; ignored otherwise. |
| [in] | landuses | Non-null borrowed array of n non-null existing land-use names. |
| [in] | percents | Non-null borrowed n-element percentage array, validated by the shared coverage parser; percentages sum to at most 100. |
| [in] | n | Positive number of land-use/percentage pairs. |
| SWMM_ENGINE_API int swmm_2d_curb_length_count | ( | SWMM_Engine | engine, |
| int * | count ) |
Count authored 2D curb-length scope rows.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [out] | count | Non-null caller-owned row-count slot; zero when no rows are authored. |
| SWMM_ENGINE_API int swmm_2d_curb_length_get | ( | SWMM_Engine | engine, |
| int | index, | ||
| int * | scope, | ||
| char * | tag, | ||
| int | taglen, | ||
| int * | cell, | ||
| double * | length ) |
Copy one authored curb-length scope row.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [in] | index | Zero-based current row index; invalid indices return SWMM_ERR_BADPARAM. |
| [out] | scope | Optional SWMM_SQ2D_SCOPE_* slot. |
| [out] | tag | Optional writable tag buffer; empty outside TAG scope. |
| [in] | taglen | Byte capacity; <= 0 skips, positive capacities safely truncate with NUL. |
| [out] | cell | Optional zero-based cell slot, meaningful for CELL scope. |
| [out] | length | Optional authored numeric slot in project length units. |
| SWMM_ENGINE_API int swmm_2d_curb_length_remove | ( | SWMM_Engine | engine, |
| int | index ) |
Remove an authored 2D curb-length scope row.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [in] | index | Zero-based current row index; later row indices shift on removal. |
| SWMM_ENGINE_API int swmm_2d_curb_length_set | ( | SWMM_Engine | engine, |
| int | scope, | ||
| const char * | tag, | ||
| int | cell, | ||
| double | length ) |
Upsert a scope's authored curb length.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [in] | scope | SWMM_SQ2D_SCOPE_GLOBAL, SWMM_SQ2D_SCOPE_TAG or SWMM_SQ2D_SCOPE_CELL. |
| [in] | tag | Required nonempty tag for TAG scope; ignored otherwise and may be NULL. |
| [in] | cell | Nonnegative zero-based cell for CELL scope; ignored otherwise. |
| [in] | length | Positive curb length in project length units, validated by the shared parser. |
| SWMM_ENGINE_API int swmm_2d_get_buildup_bulk | ( | SWMM_Engine | engine, |
| const char * | species, | ||
| double * | out, | ||
| int | n ) |
Read per-cell total land-use buildup for an active surface species.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [in] | species | Non-null exact active species name (pollutant or reactions species). |
| [out] | out | Non-null caller-owned array for every active surface-quality cell, receiving project species mass per acre/hectare summed over land uses. |
| [in] | n | Output capacity in doubles, at least the active cell count; only the cell-count prefix is written. |
| SWMM_ENGINE_API int swmm_2d_loading_count | ( | SWMM_Engine | engine, |
| int * | count ) |
Count authored 2D loading scope rows.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [out] | count | Non-null caller-owned row-count slot; zero when no rows are authored. |
| SWMM_ENGINE_API int swmm_2d_loading_get | ( | SWMM_Engine | engine, |
| int | index, | ||
| int * | scope, | ||
| char * | tag, | ||
| int | taglen, | ||
| int * | cell, | ||
| char * | species, | ||
| int | splen, | ||
| double * | value ) |
Copy one authored initial-loading scope row.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [in] | index | Zero-based current row index; invalid indices return SWMM_ERR_BADPARAM. |
| [out] | scope | Optional SWMM_SQ2D_SCOPE_* slot. |
| [out] | tag | Optional writable tag buffer; empty outside TAG scope. |
| [in] | taglen | Byte capacity; <= 0 skips, positive capacities safely truncate with NUL. |
| [out] | cell | Optional zero-based cell slot, meaningful for CELL scope. |
| [out] | species | Optional writable species-name buffer. |
| [in] | splen | Name-buffer byte capacity; <= 0 skips, positive capacities truncate with NUL. |
| [out] | value | Optional authored numeric slot in project pollutant mass per acre/hectare. |
| SWMM_ENGINE_API int swmm_2d_loading_remove | ( | SWMM_Engine | engine, |
| int | index ) |
Remove an authored 2D loading scope row.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [in] | index | Zero-based current row index; later row indices shift on removal. |
| SWMM_ENGINE_API int swmm_2d_loading_set | ( | SWMM_Engine | engine, |
| int | scope, | ||
| const char * | tag, | ||
| int | cell, | ||
| const char * | species, | ||
| double | value ) |
Upsert a scope/species initial buildup loading.
| [in] | engine | Borrowed live engine handle; not retained by this call. |
| [in] | scope | SWMM_SQ2D_SCOPE_GLOBAL, SWMM_SQ2D_SCOPE_TAG or SWMM_SQ2D_SCOPE_CELL. |
| [in] | tag | Required nonempty tag for TAG scope; ignored otherwise and may be NULL. |
| [in] | cell | Nonnegative zero-based cell for CELL scope; ignored otherwise. |
| [in] | species | Non-null existing pollutant or reactions-species name. |
| [in] | value | Loading in project pollutant mass per acre/hectare; validated by the shared loading parser and retained at exact double precision. |