![]() |
OpenSWMM Engine
6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
|
Hot start file management — transparent C API. More...
#include "openswmm_engine.h"Go to the source code of this file.
Macros | |
| #define | OPENSWMM_HOTSTART_MAGIC "OPENSWMM_HS_V1\0" |
| Magic string written at the start of every OPENSWMM_HS_V1 file. | |
| #define | OPENSWMM_HOTSTART_VERSION 1 |
| Current hot start format version number. | |
Typedefs | |
| typedef void * | SWMM_HotStart |
| Opaque handle to an open hot start file. | |
Functions | |
| SWMM_ENGINE_API int | swmm_hotstart_save (SWMM_Engine engine, const char *path) |
| Save the current engine state to a new hot start file. | |
| SWMM_ENGINE_API int | swmm_hotstart_open (const char *path, SWMM_HotStart *hs) |
| Open an existing hot start file for reading. | |
| SWMM_ENGINE_API int | swmm_hotstart_apply (SWMM_Engine engine, SWMM_HotStart hs) |
| Apply hot start state to an engine. | |
| SWMM_ENGINE_API int | swmm_hotstart_set_node_depth (SWMM_HotStart hs, const char *node_id, double depth) |
| Modify the stored depth for a node in the hot start file. | |
| SWMM_ENGINE_API int | swmm_hotstart_set_node_head (SWMM_HotStart hs, const char *node_id, double head) |
| Modify the stored head for a node. | |
| SWMM_ENGINE_API int | swmm_hotstart_set_link_flow (SWMM_HotStart hs, const char *link_id, double flow) |
| Modify the stored flow for a link. | |
| SWMM_ENGINE_API int | swmm_hotstart_set_link_depth (SWMM_HotStart hs, const char *link_id, double depth) |
| Modify the stored depth for a link. | |
| SWMM_ENGINE_API int | swmm_hotstart_set_subcatch_runoff (SWMM_HotStart hs, const char *subcatch_id, double runoff) |
| Modify the stored runoff for a subcatchment. | |
| SWMM_ENGINE_API int | swmm_hotstart_get_sim_time (SWMM_HotStart hs, double *sim_time) |
| Get the simulation timestamp stored in the hot start file. | |
| SWMM_ENGINE_API int | swmm_hotstart_get_crs (SWMM_HotStart hs, char *buf, int buflen) |
| Get the CRS string stored in the hot start file. | |
| SWMM_ENGINE_API int | swmm_hotstart_node_count (SWMM_HotStart hs) |
| Get the number of nodes stored in the hot start file. | |
| SWMM_ENGINE_API int | swmm_hotstart_link_count (SWMM_HotStart hs) |
| Get the number of links stored in the hot start file. | |
| SWMM_ENGINE_API int | swmm_hotstart_warning_count (SWMM_HotStart hs) |
| Get the number of warnings generated by the last swmm_hotstart_apply(). | |
| SWMM_ENGINE_API const char * | swmm_hotstart_warning (SWMM_HotStart hs, int index) |
| Get the i-th warning message from the last swmm_hotstart_apply(). | |
| SWMM_ENGINE_API int | swmm_hotstart_close (SWMM_HotStart hs) |
| Close and free the hot start handle. | |
Hot start file management — transparent C API.
Hot start files capture the hydraulic and water quality state of a SWMM simulation so it can be resumed later without running a warm-up period from dry-weather initial conditions.
The new hot start format (OPENSWMM_HS_V1) extends the legacy SWMM binary hot start format with:
| #define OPENSWMM_HOTSTART_MAGIC "OPENSWMM_HS_V1\0" |
Magic string written at the start of every OPENSWMM_HS_V1 file.
| #define OPENSWMM_HOTSTART_VERSION 1 |
Current hot start format version number.
| typedef void* SWMM_HotStart |
Opaque handle to an open hot start file.
| SWMM_ENGINE_API int swmm_hotstart_apply | ( | SWMM_Engine | engine, |
| SWMM_HotStart | hs | ||
| ) |
Apply hot start state to an engine.
For each object in the hot start file, the engine's corresponding object (matched by string ID) is updated. Objects in the hot start that do not exist in the target engine generate warnings (not errors). Objects in the target engine that are absent from the hot start are left at their default initial conditions.
| engine | Engine handle (must be in SWMM_STATE_INITIALIZED). |
| hs | Hot start handle (from swmm_hotstart_open()). |
| SWMM_ENGINE_API int swmm_hotstart_close | ( | SWMM_HotStart | hs | ) |
Close and free the hot start handle.
If any modifications were made via swmm_hotstart_set_*(), the changes are written back to the file before closing.
| hs | Hot start handle. Safe to call with NULL. |
| SWMM_ENGINE_API int swmm_hotstart_get_crs | ( | SWMM_HotStart | hs, |
| char * | buf, | ||
| int | buflen | ||
| ) |
Get the CRS string stored in the hot start file.
| hs | Hot start handle. |
| buf | Caller-allocated buffer. |
| buflen | Buffer size. |
| SWMM_ENGINE_API int swmm_hotstart_get_sim_time | ( | SWMM_HotStart | hs, |
| double * | sim_time | ||
| ) |
Get the simulation timestamp stored in the hot start file.
| hs | Hot start handle. |
| sim_time | [out] Simulation time (decimal days) at which state was saved. |
| SWMM_ENGINE_API int swmm_hotstart_link_count | ( | SWMM_HotStart | hs | ) |
Get the number of links stored in the hot start file.
| hs | Hot start handle. |
| SWMM_ENGINE_API int swmm_hotstart_node_count | ( | SWMM_HotStart | hs | ) |
Get the number of nodes stored in the hot start file.
| hs | Hot start handle. |
| SWMM_ENGINE_API int swmm_hotstart_open | ( | const char * | path, |
| SWMM_HotStart * | hs | ||
| ) |
Open an existing hot start file for reading.
Validates the magic number, version, and CRC32 checksum. Loads the full object UUID map into memory.
| path | Path to an existing OPENSWMM_HS_V1 hot start file. |
| hs | [out] Handle to the opened hot start. |
| SWMM_ENGINE_API int swmm_hotstart_save | ( | SWMM_Engine | engine, |
| const char * | path | ||
| ) |
Save the current engine state to a new hot start file.
Captures the full hydraulic state (node depths, heads, volumes; link flows, depths; subcatchment runoff and groundwater depths; user flag values) and writes it to the OPENSWMM_HS_V1 binary format.
| engine | Engine handle (must be in SWMM_STATE_STARTED or SWMM_STATE_RUNNING). |
| path | File path for the new hot start file. |
| SWMM_ENGINE_API int swmm_hotstart_set_link_depth | ( | SWMM_HotStart | hs, |
| const char * | link_id, | ||
| double | depth | ||
| ) |
Modify the stored depth for a link.
| hs | Hot start handle. |
| link_id | Link identifier. |
| depth | New depth value. |
| SWMM_ENGINE_API int swmm_hotstart_set_link_flow | ( | SWMM_HotStart | hs, |
| const char * | link_id, | ||
| double | flow | ||
| ) |
Modify the stored flow for a link.
| hs | Hot start handle. |
| link_id | Link identifier. |
| flow | New flow value. |
| SWMM_ENGINE_API int swmm_hotstart_set_node_depth | ( | SWMM_HotStart | hs, |
| const char * | node_id, | ||
| double | depth | ||
| ) |
Modify the stored depth for a node in the hot start file.
This allows adjusting initial conditions before applying a hot start. Changes are written back to the file when the handle is closed.
| hs | Hot start handle. |
| node_id | Node identifier string. |
| depth | New depth in the original project length units. |
| SWMM_ENGINE_API int swmm_hotstart_set_node_head | ( | SWMM_HotStart | hs, |
| const char * | node_id, | ||
| double | head | ||
| ) |
Modify the stored head for a node.
| hs | Hot start handle. |
| node_id | Node identifier. |
| head | New head value. |
| SWMM_ENGINE_API int swmm_hotstart_set_subcatch_runoff | ( | SWMM_HotStart | hs, |
| const char * | subcatch_id, | ||
| double | runoff | ||
| ) |
Modify the stored runoff for a subcatchment.
| hs | Hot start handle. |
| subcatch_id | Subcatchment identifier. |
| runoff | New runoff value. |
| SWMM_ENGINE_API const char * swmm_hotstart_warning | ( | SWMM_HotStart | hs, |
| int | index | ||
| ) |
Get the i-th warning message from the last swmm_hotstart_apply().
| hs | Hot start handle. |
| index | Warning index [0, count-1]. |
| SWMM_ENGINE_API int swmm_hotstart_warning_count | ( | SWMM_HotStart | hs | ) |
Get the number of warnings generated by the last swmm_hotstart_apply().
Warnings are issued for objects that were in the hot start file but not found in the target engine model.
| hs | Hot start handle. |