OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
openswmm_inflows.h
Go to the documentation of this file.
1
16#ifndef OPENSWMM_INFLOWS_H
17#define OPENSWMM_INFLOWS_H
18
19#include "openswmm_engine.h"
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/* =========================================================================
26 * External inflows
27 * ========================================================================= */
28
47SWMM_ENGINE_API int swmm_ext_inflow_add(SWMM_Engine engine, int node_idx, const char* constituent,
48 const char* ts_name, const char* type,
49 double m_factor, double s_factor, double baseline,
50 const char* pattern);
51
75SWMM_ENGINE_API int swmm_ext_inflow_get(SWMM_Engine engine, int entry_idx,
76 int* node_idx,
77 char* constituent_buf, int constituent_buflen,
78 char* ts_buf, int ts_buflen,
79 char* type_buf, int type_buflen,
80 double* m_factor, double* s_factor, double* baseline,
81 char* pattern_buf, int pattern_buflen);
82
94SWMM_ENGINE_API int swmm_ext_inflow_remove(SWMM_Engine engine, int entry_idx);
95
96/* =========================================================================
97 * Dry weather flow
98 * ========================================================================= */
99
116SWMM_ENGINE_API int swmm_dwf_add(SWMM_Engine engine, int node_idx, const char* constituent,
117 double avg_value, const char* pat1, const char* pat2,
118 const char* pat3, const char* pat4);
119
139SWMM_ENGINE_API int swmm_dwf_get(SWMM_Engine engine, int entry_idx,
140 int* node_idx,
141 char* constituent_buf, int constituent_buflen,
142 double* avg_value,
143 char* pat1_buf, int pat1_buflen,
144 char* pat2_buf, int pat2_buflen,
145 char* pat3_buf, int pat3_buflen,
146 char* pat4_buf, int pat4_buflen);
147
154SWMM_ENGINE_API int swmm_dwf_remove(SWMM_Engine engine, int entry_idx);
155
156/* =========================================================================
157 * RDII (Rainfall-Dependent Infiltration/Inflow)
158 * ========================================================================= */
159
172SWMM_ENGINE_API int swmm_rdii_add(SWMM_Engine engine, int node_idx, const char* uh_name, double area);
173
185SWMM_ENGINE_API int swmm_rdii_get(SWMM_Engine engine, int entry_idx,
186 int* node_idx, char* uh_buf, int buflen,
187 double* area);
188
195SWMM_ENGINE_API int swmm_rdii_remove(SWMM_Engine engine, int entry_idx);
196
197/* =========================================================================
198 * Unit hydrographs ([HYDROGRAPHS] section)
199 * =========================================================================
200 *
201 * A unit hydrograph group is identified by name and has two kinds of input
202 * lines:
203 * - A gage assignment line: "UHname RainGage"
204 * - One or more parameter lines: "UHname Month Response R T K [Dmax Drecov Dinit]"
205 *
206 * Both kinds are added separately. `swmm_hydrograph_add` adds a parameter
207 * line, `swmm_hydrograph_add_gage` adds the gage assignment. Counts and
208 * getters are also separated.
209 *
210 * `response` is encoded as: 0 = SHORT, 1 = MEDIUM, 2 = LONG.
211 * `month` is encoded as: 0..11 = JAN..DEC, or -1 = ALL.
212 * ========================================================================= */
213
230SWMM_ENGINE_API int swmm_hydrograph_add(SWMM_Engine engine, const char* uh_name,
231 int month, int response,
232 double r, double t, double k,
233 double dmax, double drecov, double dinit);
234
252SWMM_ENGINE_API int swmm_hydrograph_get(SWMM_Engine engine, int entry_idx,
253 char* uh_buf, int buflen,
254 int* month, int* response,
255 double* r, double* t, double* k,
256 double* dmax, double* drecov, double* dinit);
257
263
273 const char* uh_name,
274 const char* gage_name);
275
288 char* uh_buf, int uh_buflen,
289 char* gage_buf, int gage_buflen);
290
296
310
325 char* buf, int buflen);
326
327/* =========================================================================
328 * Mutation surface (BS-02) — upsert + key-based remove + rename
329 * =========================================================================
330 *
331 * The legacy `swmm_hydrograph_add` / `swmm_hydrograph_add_gage` surface above
332 * is append-only, which prevents in-place edits from a UI. The following
333 * setters/removers support the `HydrographGroupEditor` MVC layer in
334 * openswmm.gui: every mutation in the editor routes through one of these
335 * symbols, and the GUI's `SWMMModelLayer` emits a `hydrographChanged(uhName)`
336 * signal so all subscribed views (Object Browser, property panel, picker
337 * combos, etc.) refresh in lock-step.
338 *
339 * Upsert contract (set_rtk, set_ia, decay_set):
340 * - If an entry matching the supplied key exists, update only the fields
341 * this setter owns and leave the rest untouched.
342 * - Otherwise append a new entry with the supplied fields set and the
343 * unspecified fields zeroed (so set_rtk followed by set_ia on the same
344 * key composes correctly).
345 *
346 * Remove contract (remove_entry, remove_group, decay_remove):
347 * - Key-based, not index-based — indices shift as entries are removed and
348 * a UI cannot keep them in sync. Idempotent: returns SWMM_OK if no
349 * match is found.
350 *
351 * Group remove cascades to: [HYDROGRAPHS] parameter rows, gage assignments,
352 * [RDII_DECAY] rows, AND any [RDII] node assignments referencing the group
353 * (so the engine never sees a dangling UH-name reference after a delete).
354 * ========================================================================= */
355
368SWMM_ENGINE_API int swmm_hydrograph_set_rtk(SWMM_Engine engine, const char* uh_name,
369 int month, int response,
370 double r, double t, double k);
371
384SWMM_ENGINE_API int swmm_hydrograph_set_ia(SWMM_Engine engine, const char* uh_name,
385 int month, int response,
386 double dmax, double drecov, double dinit);
387
397SWMM_ENGINE_API int swmm_hydrograph_remove_entry(SWMM_Engine engine, const char* uh_name,
398 int month, int response);
399
406SWMM_ENGINE_API int swmm_hydrograph_remove_group(SWMM_Engine engine, const char* uh_name);
407
418SWMM_ENGINE_API int swmm_hydrograph_clear_group_months(SWMM_Engine engine, const char* uh_name);
419
429SWMM_ENGINE_API int swmm_hydrograph_set_gage(SWMM_Engine engine, const char* uh_name,
430 const char* gage_name);
431
442SWMM_ENGINE_API int swmm_hydrograph_group_rename(SWMM_Engine engine, int idx, const char* new_id);
443
453SWMM_ENGINE_API int swmm_rdii_decay_set(SWMM_Engine engine, const char* uh_name,
454 int response,
455 double k_dep, double k_0, double k_T,
456 double T_ref, double theta_rec, double T_freeze);
457
465SWMM_ENGINE_API int swmm_rdii_decay_remove(SWMM_Engine engine, const char* uh_name, int response);
466
467/* =========================================================================
468 * Exponential IA decay ([RDII_DECAY] section)
469 * =========================================================================
470 *
471 * Physics-based replacement for the legacy linear IA recovery. When a row
472 * is present for a (UH group, response) pair, the exponential depletion /
473 * temperature-dependent recovery model is used in place of the linear
474 * `drecov` rate from the corresponding [HYDROGRAPHS] entry.
475 *
476 * @see docs/RDII_ExpDecay_Implementation.md
477 * ========================================================================= */
478
493SWMM_ENGINE_API int swmm_rdii_decay_add(SWMM_Engine engine, const char* uh_name,
494 int response,
495 double k_dep, double k_0, double k_T,
496 double T_ref, double theta_rec, double T_freeze);
497
514SWMM_ENGINE_API int swmm_rdii_decay_get(SWMM_Engine engine, int entry_idx,
515 char* uh_buf, int buflen,
516 int* response,
517 double* k_dep, double* k_0, double* k_T,
518 double* T_ref, double* theta_rec, double* T_freeze);
519
525
526/* =========================================================================
527 * Count queries
528 * ========================================================================= */
529
536
543
550
551#ifdef __cplusplus
552} /* extern "C" */
553#endif
554
555#endif /* OPENSWMM_INFLOWS_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_ext_inflow_count(SWMM_Engine engine)
Get the total number of external inflows defined.
Definition openswmm_inflows_impl.cpp:657
SWMM_ENGINE_API int swmm_rdii_decay_add(SWMM_Engine engine, const char *uh_name, int response, double k_dep, double k_0, double k_T, double T_ref, double theta_rec, double T_freeze)
Add an exponential-decay parameter row for a (UH, response) pair.
Definition openswmm_inflows_impl.cpp:334
SWMM_ENGINE_API int swmm_hydrograph_gage_count(SWMM_Engine engine)
Count UH-to-gage assignments.
Definition openswmm_inflows_impl.cpp:307
SWMM_ENGINE_API int swmm_dwf_count(SWMM_Engine engine)
Get the total number of dry weather flow entries defined.
Definition openswmm_inflows_impl.cpp:662
SWMM_ENGINE_API int swmm_dwf_get(SWMM_Engine engine, int entry_idx, int *node_idx, char *constituent_buf, int constituent_buflen, double *avg_value, char *pat1_buf, int pat1_buflen, char *pat2_buf, int pat2_buflen, char *pat3_buf, int pat3_buflen, char *pat4_buf, int pat4_buflen)
Read back a dry weather flow entry by index.
Definition openswmm_inflows_impl.cpp:145
SWMM_ENGINE_API int swmm_hydrograph_set_gage(SWMM_Engine engine, const char *uh_name, const char *gage_name)
Set, replace, or clear the rain gage assigned to a UH group.
Definition openswmm_inflows_impl.cpp:549
SWMM_ENGINE_API int swmm_rdii_decay_get(SWMM_Engine engine, int entry_idx, char *uh_buf, int buflen, int *response, double *k_dep, double *k_0, double *k_T, double *T_ref, double *theta_rec, double *T_freeze)
Read back an exponential-decay parameter row by index.
Definition openswmm_inflows_impl.cpp:357
SWMM_ENGINE_API int swmm_rdii_get(SWMM_Engine engine, int entry_idx, int *node_idx, char *uh_buf, int buflen, double *area)
Read back an RDII assignment by entry index.
Definition openswmm_inflows_impl.cpp:200
SWMM_ENGINE_API int swmm_rdii_count(SWMM_Engine engine)
Get the total number of RDII entries defined.
Definition openswmm_inflows_impl.cpp:667
SWMM_ENGINE_API int swmm_hydrograph_group_rename(SWMM_Engine engine, int idx, const char *new_id)
Rename a UH group, propagating the new name to parameter rows, gage assignments, [RDII_DECAY] rows,...
Definition openswmm_inflows_impl.cpp:573
SWMM_ENGINE_API int swmm_hydrograph_add(SWMM_Engine engine, const char *uh_name, int month, int response, double r, double t, double k, double dmax, double drecov, double dinit)
Add a unit hydrograph parameter line.
Definition openswmm_inflows_impl.cpp:227
SWMM_ENGINE_API int swmm_rdii_add(SWMM_Engine engine, int node_idx, const char *uh_name, double area)
Add RDII inflow to a node using a unit hydrograph.
Definition openswmm_inflows_impl.cpp:189
SWMM_ENGINE_API int swmm_hydrograph_clear_group_months(SWMM_Engine engine, const char *uh_name)
Bulk-clear every per-month parameter row for a group, leaving any existing month=-1 (ALL) row intact.
Definition openswmm_inflows_impl.cpp:533
SWMM_ENGINE_API int swmm_ext_inflow_remove(SWMM_Engine engine, int entry_idx)
Remove an external inflow entry by index.
Definition openswmm_inflows_impl.cpp:112
SWMM_ENGINE_API int swmm_hydrograph_get_gage(SWMM_Engine engine, int entry_idx, char *uh_buf, int uh_buflen, char *gage_buf, int gage_buflen)
Read back a UH-to-gage assignment by index.
Definition openswmm_inflows_impl.cpp:291
SWMM_ENGINE_API int swmm_rdii_decay_remove(SWMM_Engine engine, const char *uh_name, int response)
Remove the exponential-decay row for one (group, response) pair.
Definition openswmm_inflows_impl.cpp:639
SWMM_ENGINE_API int swmm_hydrograph_set_rtk(SWMM_Engine engine, const char *uh_name, int month, int response, double r, double t, double k)
Upsert R/T/K parameters for one (group, month, response) row.
Definition openswmm_inflows_impl.cpp:434
SWMM_ENGINE_API int swmm_ext_inflow_get(SWMM_Engine engine, int entry_idx, int *node_idx, char *constituent_buf, int constituent_buflen, char *ts_buf, int ts_buflen, char *type_buf, int type_buflen, double *m_factor, double *s_factor, double *baseline, char *pattern_buf, int pattern_buflen)
Read back an external inflow entry by index.
Definition openswmm_inflows_impl.cpp:81
SWMM_ENGINE_API int swmm_hydrograph_remove_group(SWMM_Engine engine, const char *uh_name)
Remove an entire UH group: parameter rows + gage assignment + [RDII_DECAY] rows + [RDII] node assignm...
Definition openswmm_inflows_impl.cpp:503
SWMM_ENGINE_API int swmm_hydrograph_remove_entry(SWMM_Engine engine, const char *uh_name, int month, int response)
Remove one parameter entry by (group, month, response).
Definition openswmm_inflows_impl.cpp:488
SWMM_ENGINE_API int swmm_dwf_remove(SWMM_Engine engine, int entry_idx)
Remove a DWF entry by index. Subsequent entries shift down.
Definition openswmm_inflows_impl.cpp:177
SWMM_ENGINE_API int swmm_rdii_decay_count(SWMM_Engine engine)
Count exponential-decay parameter rows.
Definition openswmm_inflows_impl.cpp:382
SWMM_ENGINE_API int swmm_hydrograph_group_count(SWMM_Engine engine)
Count the unique unit-hydrograph group names defined.
Definition openswmm_inflows_impl.cpp:313
SWMM_ENGINE_API int swmm_hydrograph_get(SWMM_Engine engine, int entry_idx, char *uh_buf, int buflen, int *month, int *response, double *r, double *t, double *k, double *dmax, double *drecov, double *dinit)
Read back a hydrograph parameter entry by index.
Definition openswmm_inflows_impl.cpp:251
SWMM_ENGINE_API int swmm_hydrograph_group_id(SWMM_Engine engine, int idx, char *buf, int buflen)
Read back the name of a unit-hydrograph group by its zero-based index.
Definition openswmm_inflows_impl.cpp:319
SWMM_ENGINE_API int swmm_rdii_remove(SWMM_Engine engine, int entry_idx)
Remove an RDII entry by index. Subsequent entries shift down.
Definition openswmm_inflows_impl.cpp:215
SWMM_ENGINE_API int swmm_ext_inflow_add(SWMM_Engine engine, int node_idx, const char *constituent, const char *ts_name, const char *type, double m_factor, double s_factor, double baseline, const char *pattern)
Add an external inflow to a node.
Definition openswmm_inflows_impl.cpp:58
SWMM_ENGINE_API int swmm_rdii_decay_set(SWMM_Engine engine, const char *uh_name, int response, double k_dep, double k_0, double k_T, double T_ref, double theta_rec, double T_freeze)
Upsert exponential-decay parameters for one (group, response) row.
Definition openswmm_inflows_impl.cpp:607
SWMM_ENGINE_API int swmm_dwf_add(SWMM_Engine engine, int node_idx, const char *constituent, double avg_value, const char *pat1, const char *pat2, const char *pat3, const char *pat4)
Add a dry weather flow component to a node.
Definition openswmm_inflows_impl.cpp:124
SWMM_ENGINE_API int swmm_hydrograph_count(SWMM_Engine engine)
Count parameter entries in the model.
Definition openswmm_inflows_impl.cpp:276
SWMM_ENGINE_API int swmm_hydrograph_add_gage(SWMM_Engine engine, const char *uh_name, const char *gage_name)
Assign a rain gage to a unit hydrograph group.
Definition openswmm_inflows_impl.cpp:281
SWMM_ENGINE_API int swmm_hydrograph_set_ia(SWMM_Engine engine, const char *uh_name, int month, int response, double dmax, double drecov, double dinit)
Upsert linear-IA parameters for one (group, month, response) row.
Definition openswmm_inflows_impl.cpp:461