OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
openswmm_hotstart.h
Go to the documentation of this file.
1
58#ifndef OPENSWMM_ENGINE_HOTSTART_H
59#define OPENSWMM_ENGINE_HOTSTART_H
60
61#include "openswmm_engine.h"
62
63#ifdef __cplusplus
64extern "C" {
65#endif
66
68typedef void* SWMM_HotStart;
69
71#define OPENSWMM_HOTSTART_MAGIC "OPENSWMM_HS_V1\0"
72
74#define OPENSWMM_HOTSTART_VERSION 1
75
76/* =========================================================================
77 * [FILES] section — `SAVE HOTSTART` entry management (Slice BV-01)
78 *
79 * These functions manage the *static* list of scheduled hot-start save
80 * entries that live in the `[FILES]` section of an `.inp` file
81 * (`SimulationContext::hotstart_saves`). They are distinct from the
82 * runtime `swmm_hotstart_save()` function below, which writes a single
83 * hot-start file at the current sim time.
84 *
85 * Each entry is a `{path, datetime}` pair. A `datetime` of `0.0`
86 * means "no datetime — save at end of run" (matches legacy semantics).
87 *
88 * The legacy singular `swmm_files_set("HOTSTART_SAVE_PATH", …)` /
89 * `_DATETIME` keys remain as slot-0 sugar.
90 * ========================================================================= */
91
99
109 SWMM_Engine engine, int idx, char* buf, int buflen);
110
120 SWMM_Engine engine, int idx, double* datetime);
121
137 SWMM_Engine engine, int idx, const char* path);
138
148 SWMM_Engine engine, int idx, double datetime);
149
160 SWMM_Engine engine, const char* path, double datetime);
161
169
176
177/* =========================================================================
178 * Create / save
179 * ========================================================================= */
180
195SWMM_ENGINE_API int swmm_hotstart_save(SWMM_Engine engine, const char* path);
196
197/* =========================================================================
198 * Open / read
199 * ========================================================================= */
200
211SWMM_ENGINE_API int swmm_hotstart_open(const char* path, SWMM_HotStart* hs);
212
213/* =========================================================================
214 * Apply
215 * ========================================================================= */
216
235
236/* =========================================================================
237 * Modify hot start data
238 * ========================================================================= */
239
252 SWMM_HotStart hs,
253 const char* node_id,
254 double depth
255);
256
265 SWMM_HotStart hs,
266 const char* node_id,
267 double head
268);
269
278 SWMM_HotStart hs,
279 const char* link_id,
280 double flow
281);
282
291 SWMM_HotStart hs,
292 const char* link_id,
293 double depth
294);
295
304 SWMM_HotStart hs,
305 const char* subcatch_id,
306 double runoff
307);
308
309/* =========================================================================
310 * Query hot start metadata
311 * ========================================================================= */
312
320
328SWMM_ENGINE_API int swmm_hotstart_get_crs(SWMM_HotStart hs, char* buf, int buflen);
329
336
343
344/* =========================================================================
345 * Warning access (populated after swmm_hotstart_apply())
346 * ========================================================================= */
347
358
366SWMM_ENGINE_API const char* swmm_hotstart_warning(SWMM_HotStart hs, int index);
367
368/* =========================================================================
369 * Close
370 * ========================================================================= */
371
382
383#ifdef __cplusplus
384} /* extern "C" */
385#endif
386
387#endif /* OPENSWMM_ENGINE_HOTSTART_H */
#define SWMM_ENGINE_API
Definition openswmm_2d.h:37
void * SWMM_Engine
Opaque handle to an OpenSWMM Engine instance.
Definition openswmm_callbacks.h:35
OpenSWMM Engine — primary transparent C API (master header).
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.
Definition openswmm_hotstart_impl.cpp:150
SWMM_ENGINE_API int swmm_hotstart_saves_set_datetime(SWMM_Engine engine, int idx, double datetime)
Replace the datetime of an existing SAVE HOTSTART entry.
Definition openswmm_model_impl.cpp:430
SWMM_ENGINE_API int swmm_hotstart_saves_get_datetime(SWMM_Engine engine, int idx, double *datetime)
Get the datetime (decimal day; 0.0 = "end of run") of the i-th SAVE HOTSTART entry.
Definition openswmm_model_impl.cpp:408
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.
Definition openswmm_hotstart_impl.cpp:168
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.
Definition openswmm_hotstart_impl.cpp:186
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.
Definition openswmm_hotstart_impl.cpp:177
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.
Definition openswmm_hotstart_impl.cpp:159
SWMM_ENGINE_API int swmm_hotstart_warning_count(SWMM_HotStart hs)
Get the number of warnings generated by the last swmm_hotstart_apply().
Definition openswmm_hotstart_impl.cpp:231
SWMM_ENGINE_API int swmm_hotstart_saves_add(SWMM_Engine engine, const char *path, double datetime)
Append a new SAVE HOTSTART entry.
Definition openswmm_model_impl.cpp:440
SWMM_ENGINE_API int swmm_hotstart_close(SWMM_HotStart hs)
Close and free the hot start handle.
Definition openswmm_hotstart_impl.cpp:247
SWMM_ENGINE_API int swmm_hotstart_save(SWMM_Engine engine, const char *path)
Save the current engine state to a new hot start file.
Definition openswmm_hotstart_impl.cpp:60
SWMM_ENGINE_API int swmm_hotstart_saves_clear(SWMM_Engine engine)
Remove all SAVE HOTSTART entries.
Definition openswmm_model_impl.cpp:459
void * SWMM_HotStart
Opaque handle to an open hot start file.
Definition openswmm_hotstart.h:68
SWMM_ENGINE_API int swmm_hotstart_open(const char *path, SWMM_HotStart *hs)
Open an existing hot start file for reading.
Definition openswmm_hotstart_impl.cpp:102
SWMM_ENGINE_API int swmm_hotstart_link_count(SWMM_HotStart hs)
Get the number of links stored in the hot start file.
Definition openswmm_hotstart_impl.cpp:222
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().
Definition openswmm_hotstart_impl.cpp:236
SWMM_ENGINE_API int swmm_hotstart_saves_count(SWMM_Engine engine, int *count)
Get the number of SAVE HOTSTART entries currently in [FILES].
Definition openswmm_model_impl.cpp:389
SWMM_ENGINE_API int swmm_hotstart_saves_set_path(SWMM_Engine engine, int idx, const char *path)
Replace the path of an existing SAVE HOTSTART entry.
Definition openswmm_model_impl.cpp:419
SWMM_ENGINE_API int swmm_hotstart_node_count(SWMM_HotStart hs)
Get the number of nodes stored in the hot start file.
Definition openswmm_hotstart_impl.cpp:217
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.
Definition openswmm_hotstart_impl.cpp:199
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.
Definition openswmm_hotstart_impl.cpp:206
SWMM_ENGINE_API int swmm_hotstart_apply(SWMM_Engine engine, SWMM_HotStart hs)
Apply hot start state to an engine.
Definition openswmm_hotstart_impl.cpp:118
SWMM_ENGINE_API int swmm_hotstart_saves_get_path(SWMM_Engine engine, int idx, char *buf, int buflen)
Get the path of the i-th SAVE HOTSTART entry.
Definition openswmm_model_impl.cpp:397
SWMM_ENGINE_API int swmm_hotstart_saves_remove(SWMM_Engine engine, int idx)
Remove the i-th SAVE HOTSTART entry; subsequent slots shift down.
Definition openswmm_model_impl.cpp:450