OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm_hotstart.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2//
3// Copyright 2026 Caleb Buahin
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
68
75
76#ifndef OPENSWMM_ENGINE_HOTSTART_H
77#define OPENSWMM_ENGINE_HOTSTART_H
78
79#include "openswmm_engine.h"
80
81#ifdef __cplusplus
82extern "C" {
83#endif
84
86typedef void* SWMM_HotStart;
87
89#define OPENSWMM_HOTSTART_MAGIC "OPENSWMM_HS_V1\0"
90
94#define OPENSWMM_HOTSTART_VERSION 1
95
96/* =========================================================================
97 * [FILES] section — `SAVE HOTSTART` entry management (Slice BV-01)
98 *
99 * These functions manage the *static* list of scheduled hot-start save
100 * entries that live in the `[FILES]` section of an `.inp` file
101 * (`SimulationContext::hotstart_saves`). They are distinct from the
102 * runtime `swmm_hotstart_save()` function below, which writes a single
103 * hot-start file at the current sim time.
104 *
105 * Each entry is a `{path, datetime, format}` triple. A `datetime` of `0.0`
106 * means "no datetime — save at end of run" (matches legacy semantics);
107 * `format` is one of `SWMM_HOTSTART_FORMAT_*` (default AUTO).
108 *
109 * The legacy singular `swmm_files_set("HOTSTART_SAVE_PATH", …)` /
110 * `_DATETIME` keys remain as slot-0 sugar.
111 * ========================================================================= */
112
123
137SWMM_ENGINE_API int swmm_hotstart_saves_get_path(SWMM_Engine engine, int idx, char* buf,
138 int buflen);
139
152SWMM_ENGINE_API int swmm_hotstart_saves_get_datetime(SWMM_Engine engine, int idx, double* datetime);
153
169SWMM_ENGINE_API int swmm_hotstart_saves_set_path(SWMM_Engine engine, int idx, const char* path);
170
182SWMM_ENGINE_API int swmm_hotstart_saves_set_datetime(SWMM_Engine engine, int idx, double datetime);
183
196#define SWMM_HOTSTART_FORMAT_AUTO 0
197#define SWMM_HOTSTART_FORMAT_LEGACY 1
198#define SWMM_HOTSTART_FORMAT_NATIVE 2
199
211SWMM_ENGINE_API int swmm_hotstart_saves_get_format(SWMM_Engine engine, int idx, int* format);
212
227SWMM_ENGINE_API int swmm_hotstart_saves_set_format(SWMM_Engine engine, int idx, int format);
228
230#define SWMM_HOTSTART_OMITS_WATER_AGE 0x1
231#define SWMM_HOTSTART_OMITS_REACTION_SPECIES 0x2
232#define SWMM_HOTSTART_OMITS_AQUIFER 0x4
233#define SWMM_HOTSTART_OMITS_NODE_LIDS 0x8
234
250
265SWMM_ENGINE_API int swmm_hotstart_saves_add(SWMM_Engine engine, const char* path, double datetime);
266
277
288
289/* =========================================================================
290 * Create / save
291 * ========================================================================= */
292
309SWMM_ENGINE_API int swmm_hotstart_save(SWMM_Engine engine, const char* path);
310
320
321/* =========================================================================
322 * Open / read
323 * ========================================================================= */
324
338SWMM_ENGINE_API int swmm_hotstart_open(const char* path, SWMM_HotStart* hs);
339
340/* =========================================================================
341 * Apply
342 * ========================================================================= */
343
363
364/* =========================================================================
365 * Modify hot start data
366 * ========================================================================= */
367
385 double depth);
386
402SWMM_ENGINE_API int swmm_hotstart_set_node_head(SWMM_HotStart hs, const char* node_id, double head);
403
420SWMM_ENGINE_API int swmm_hotstart_set_link_flow(SWMM_HotStart hs, const char* link_id, double flow);
421
438 double depth);
439
457 double runoff);
458
459/* =========================================================================
460 * Query hot start metadata
461 * ========================================================================= */
462
474
486
500SWMM_ENGINE_API int swmm_hotstart_get_crs(SWMM_HotStart hs, char* buf, int buflen);
501
512
521
522/* =========================================================================
523 * Warning access (populated after swmm_hotstart_apply())
524 * ========================================================================= */
525
538
548SWMM_ENGINE_API const char* swmm_hotstart_warning(SWMM_HotStart hs, int index);
549
550/* =========================================================================
551 * Close
552 * ========================================================================= */
553
565
566#ifdef __cplusplus
567} /* extern "C" */
568#endif
569
570#endif /* OPENSWMM_ENGINE_HOTSTART_H */
#define SWMM_ENGINE_API
Definition openswmm_2d.h:62
void * SWMM_Engine
Opaque handle to an OpenSWMM Engine instance.
Definition openswmm_callbacks.h:55
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)
Edit one stored node depth record before application/write-back.
Definition openswmm_hotstart_impl.cpp:210
SWMM_ENGINE_API int swmm_hotstart_saves_get_format(SWMM_Engine engine, int idx, int *format)
Read the authored format selector of one scheduled save.
Definition openswmm_model_impl.cpp:979
SWMM_ENGINE_API int swmm_hotstart_saves_set_datetime(SWMM_Engine engine, int idx, double datetime)
Assign a scheduled save calendar date directly.
Definition openswmm_model_impl.cpp:970
SWMM_ENGINE_API int swmm_hotstart_saves_get_datetime(SWMM_Engine engine, int idx, double *datetime)
Read the scheduled calendar date of one save entry.
Definition openswmm_model_impl.cpp:947
SWMM_ENGINE_API int swmm_hotstart_get_start_date(SWMM_HotStart hs, double *start_date)
Read the saving run start calendar date.
Definition openswmm_hotstart_impl.cpp:262
SWMM_ENGINE_API int swmm_hotstart_set_link_flow(SWMM_HotStart hs, const char *link_id, double flow)
Edit one stored link flow record before application/write-back.
Definition openswmm_hotstart_impl.cpp:226
SWMM_ENGINE_API int swmm_hotstart_set_subcatch_runoff(SWMM_HotStart hs, const char *subcatch_id, double runoff)
Edit one stored subcatchment runoff record before application/write-back.
Definition openswmm_hotstart_impl.cpp:242
SWMM_ENGINE_API int swmm_hotstart_set_link_depth(SWMM_HotStart hs, const char *link_id, double depth)
Edit one stored link depth record before application/write-back.
Definition openswmm_hotstart_impl.cpp:234
SWMM_ENGINE_API int swmm_hotstart_set_node_head(SWMM_HotStart hs, const char *node_id, double head)
Edit one stored node head record before application/write-back.
Definition openswmm_hotstart_impl.cpp:218
SWMM_ENGINE_API int swmm_hotstart_warning_count(SWMM_HotStart hs)
Count warnings retained by the hot-start handle.
Definition openswmm_hotstart_impl.cpp:298
SWMM_ENGINE_API int swmm_hotstart_saves_add(SWMM_Engine engine, const char *path, double datetime)
Append an AUTO-format scheduled save authoring entry.
Definition openswmm_model_impl.cpp:1023
SWMM_ENGINE_API const char * swmm_hotstart_last_io_error(void)
Borrow the built-in hot-start reader/writer diagnostic for this thread.
Definition openswmm_hotstart_impl.cpp:98
SWMM_ENGINE_API int swmm_hotstart_close(SWMM_HotStart hs)
Flush dirty record edits and destroy a hot-start handle.
Definition openswmm_hotstart_impl.cpp:317
SWMM_ENGINE_API int swmm_hotstart_save(SWMM_Engine engine, const char *path)
Write current simulation state through the native checkpoint or state-IO path.
Definition openswmm_hotstart_impl.cpp:106
SWMM_ENGINE_API int swmm_hotstart_saves_clear(SWMM_Engine engine)
Remove all scheduled save authoring entries.
Definition openswmm_model_impl.cpp:1041
void * SWMM_HotStart
Opaque handle to an open hot start file.
Definition openswmm_hotstart.h:86
SWMM_ENGINE_API int swmm_hotstart_open(const char *path, SWMM_HotStart *hs)
Load a native OPENSWMM hot-start file into an independent handle.
Definition openswmm_hotstart_impl.cpp:154
SWMM_ENGINE_API int swmm_hotstart_link_count(SWMM_HotStart hs)
Count stored link records in a hot-start handle.
Definition openswmm_hotstart_impl.cpp:288
SWMM_ENGINE_API const char * swmm_hotstart_warning(SWMM_HotStart hs, int index)
Borrow one retained hot-start warning.
Definition openswmm_hotstart_impl.cpp:304
SWMM_ENGINE_API int swmm_hotstart_saves_count(SWMM_Engine engine, int *count)
Count scheduled SAVE HOTSTART authoring entries.
Definition openswmm_model_impl.cpp:927
SWMM_ENGINE_API int swmm_hotstart_saves_set_path(SWMM_Engine engine, int idx, const char *path)
Replace a scheduled save path without removing its row.
Definition openswmm_model_impl.cpp:959
SWMM_ENGINE_API int swmm_hotstart_node_count(SWMM_HotStart hs)
Count stored node records in a hot-start handle.
Definition openswmm_hotstart_impl.cpp:282
SWMM_ENGINE_API int swmm_hotstart_get_sim_time(SWMM_HotStart hs, double *sim_time)
Read the saved elapsed simulation time.
Definition openswmm_hotstart_impl.cpp:254
SWMM_ENGINE_API int swmm_hotstart_get_crs(SWMM_HotStart hs, char *buf, int buflen)
Copy the hot-start header CRS string.
Definition openswmm_hotstart_impl.cpp:270
SWMM_ENGINE_API int swmm_hotstart_apply(SWMM_Engine engine, SWMM_HotStart hs)
Apply record state or queue a complete restart on an initialized engine.
Definition openswmm_hotstart_impl.cpp:173
SWMM_ENGINE_API int swmm_hotstart_saves_set_format(SWMM_Engine engine, int idx, int format)
Select the authored format of an existing scheduled save.
Definition openswmm_model_impl.cpp:990
SWMM_ENGINE_API int swmm_hotstart_legacy_omits(SWMM_Engine engine, int *flags)
Report selected model features that legacy routing hotstarts cannot retain.
Definition openswmm_model_impl.cpp:1001
SWMM_ENGINE_API int swmm_hotstart_saves_get_path(SWMM_Engine engine, int idx, char *buf, int buflen)
Copy the authored path of one scheduled save entry.
Definition openswmm_model_impl.cpp:935
SWMM_ENGINE_API int swmm_hotstart_saves_remove(SWMM_Engine engine, int idx)
Remove a scheduled save entry and shift later indices down.
Definition openswmm_model_impl.cpp:1032