OpenSWMM Engine  6.0.0-alpha.3
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.3)
Loading...
Searching...
No Matches
openswmm_inflows.h
Go to the documentation of this file.
1
15
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
102SWMM_ENGINE_API int swmm_ext_inflow_set_scale(SWMM_Engine engine, int entry_idx, double scale);
103
109SWMM_ENGINE_API int swmm_ext_inflow_set_baseline(SWMM_Engine engine, int entry_idx, double baseline);
110
111/* =========================================================================
112 * Dry weather flow
113 * ========================================================================= */
114
131SWMM_ENGINE_API int swmm_dwf_add(SWMM_Engine engine, int node_idx, const char* constituent,
132 double avg_value, const char* pat1, const char* pat2,
133 const char* pat3, const char* pat4);
134
154SWMM_ENGINE_API int swmm_dwf_get(SWMM_Engine engine, int entry_idx,
155 int* node_idx,
156 char* constituent_buf, int constituent_buflen,
157 double* avg_value,
158 char* pat1_buf, int pat1_buflen,
159 char* pat2_buf, int pat2_buflen,
160 char* pat3_buf, int pat3_buflen,
161 char* pat4_buf, int pat4_buflen);
162
169SWMM_ENGINE_API int swmm_dwf_remove(SWMM_Engine engine, int entry_idx);
170
177SWMM_ENGINE_API int swmm_dwf_set_baseline(SWMM_Engine engine, int entry_idx, double avg_value);
178
179/* =========================================================================
180 * RDII (Rainfall-Dependent Infiltration/Inflow)
181 * ========================================================================= */
182
195SWMM_ENGINE_API int swmm_rdii_add(SWMM_Engine engine, int node_idx, const char* uh_name, double area);
196
208SWMM_ENGINE_API int swmm_rdii_get(SWMM_Engine engine, int entry_idx,
209 int* node_idx, char* uh_buf, int buflen,
210 double* area);
211
218SWMM_ENGINE_API int swmm_rdii_remove(SWMM_Engine engine, int entry_idx);
219
220/* =========================================================================
221 * Unit hydrographs ([HYDROGRAPHS] section)
222 * =========================================================================
223 *
224 * A unit hydrograph group is identified by name and has two kinds of input
225 * lines:
226 * - A gage assignment line: "UHname RainGage"
227 * - One or more parameter lines: "UHname Month Response R T K [Dmax Drecov Dinit]"
228 *
229 * Both kinds are added separately. `swmm_hydrograph_add` adds a parameter
230 * line, `swmm_hydrograph_add_gage` adds the gage assignment. Counts and
231 * getters are also separated.
232 *
233 * `response` is encoded as: 0 = SHORT, 1 = MEDIUM, 2 = LONG.
234 * `month` is encoded as: 0..11 = JAN..DEC, or -1 = ALL.
235 * ========================================================================= */
236
253SWMM_ENGINE_API int swmm_hydrograph_add(SWMM_Engine engine, const char* uh_name,
254 int month, int response,
255 double r, double t, double k,
256 double dmax, double drecov, double dinit);
257
275SWMM_ENGINE_API int swmm_hydrograph_get(SWMM_Engine engine, int entry_idx,
276 char* uh_buf, int buflen,
277 int* month, int* response,
278 double* r, double* t, double* k,
279 double* dmax, double* drecov, double* dinit);
280
286
296 const char* uh_name,
297 const char* gage_name);
298
311 char* uh_buf, int uh_buflen,
312 char* gage_buf, int gage_buflen);
313
319
333
348 char* buf, int buflen);
349
350/* =========================================================================
351 * Mutation surface (BS-02) — upsert + key-based remove + rename
352 * =========================================================================
353 *
354 * The legacy `swmm_hydrograph_add` / `swmm_hydrograph_add_gage` surface above
355 * is append-only, which prevents in-place edits from a UI. The following
356 * setters/removers support the `HydrographGroupEditor` MVC layer in
357 * openswmm.gui: every mutation in the editor routes through one of these
358 * symbols, and the GUI's `SWMMModelLayer` emits a `hydrographChanged(uhName)`
359 * signal so all subscribed views (Object Browser, property panel, picker
360 * combos, etc.) refresh in lock-step.
361 *
362 * Upsert contract (set_rtk, set_ia, decay_set):
363 * - If an entry matching the supplied key exists, update only the fields
364 * this setter owns and leave the rest untouched.
365 * - Otherwise append a new entry with the supplied fields set and the
366 * unspecified fields zeroed (so set_rtk followed by set_ia on the same
367 * key composes correctly).
368 *
369 * Remove contract (remove_entry, remove_group, decay_remove):
370 * - Key-based, not index-based — indices shift as entries are removed and
371 * a UI cannot keep them in sync. Idempotent: returns SWMM_OK if no
372 * match is found.
373 *
374 * Group remove cascades to: [HYDROGRAPHS] parameter rows, gage assignments,
375 * [RDII_DECAY] rows, AND any [RDII] node assignments referencing the group
376 * (so the engine never sees a dangling UH-name reference after a delete).
377 * ========================================================================= */
378
391SWMM_ENGINE_API int swmm_hydrograph_set_rtk(SWMM_Engine engine, const char* uh_name,
392 int month, int response,
393 double r, double t, double k);
394
407SWMM_ENGINE_API int swmm_hydrograph_set_ia(SWMM_Engine engine, const char* uh_name,
408 int month, int response,
409 double dmax, double drecov, double dinit);
410
420SWMM_ENGINE_API int swmm_hydrograph_remove_entry(SWMM_Engine engine, const char* uh_name,
421 int month, int response);
422
429SWMM_ENGINE_API int swmm_hydrograph_remove_group(SWMM_Engine engine, const char* uh_name);
430
441SWMM_ENGINE_API int swmm_hydrograph_clear_group_months(SWMM_Engine engine, const char* uh_name);
442
452SWMM_ENGINE_API int swmm_hydrograph_set_gage(SWMM_Engine engine, const char* uh_name,
453 const char* gage_name);
454
465SWMM_ENGINE_API int swmm_hydrograph_group_rename(SWMM_Engine engine, int idx, const char* new_id);
466
476SWMM_ENGINE_API int swmm_rdii_decay_set(SWMM_Engine engine, const char* uh_name,
477 int response,
478 double k_dep, double k_0, double k_T,
479 double T_ref, double theta_rec, double T_freeze);
480
488SWMM_ENGINE_API int swmm_rdii_decay_remove(SWMM_Engine engine, const char* uh_name, int response);
489
490/* =========================================================================
491 * Exponential IA decay ([RDII_DECAY] section)
492 * =========================================================================
493 *
494 * Physics-based replacement for the legacy linear IA recovery. When a row
495 * is present for a (UH group, response) pair, the exponential depletion /
496 * temperature-dependent recovery model is used in place of the linear
497 * `drecov` rate from the corresponding [HYDROGRAPHS] entry.
498 *
499 * @see docs/RDII_ExpDecay_Implementation.md
500 * ========================================================================= */
501
516SWMM_ENGINE_API int swmm_rdii_decay_add(SWMM_Engine engine, const char* uh_name,
517 int response,
518 double k_dep, double k_0, double k_T,
519 double T_ref, double theta_rec, double T_freeze);
520
537SWMM_ENGINE_API int swmm_rdii_decay_get(SWMM_Engine engine, int entry_idx,
538 char* uh_buf, int buflen,
539 int* response,
540 double* k_dep, double* k_0, double* k_T,
541 double* T_ref, double* theta_rec, double* T_freeze);
542
548
549/* =========================================================================
550 * Count queries
551 * ========================================================================= */
552
559
566
573
574#ifdef __cplusplus
575} /* extern "C" */
576#endif
577
578#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:704
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:381
SWMM_ENGINE_API int swmm_hydrograph_gage_count(SWMM_Engine engine)
Count UH-to-gage assignments.
Definition openswmm_inflows_impl.cpp:354
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:709
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:181
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:596
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:404
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:247
SWMM_ENGINE_API int swmm_rdii_count(SWMM_Engine engine)
Get the total number of RDII entries defined.
Definition openswmm_inflows_impl.cpp:714
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:620
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:274
SWMM_ENGINE_API int swmm_dwf_set_baseline(SWMM_Engine engine, int entry_idx, double avg_value)
Set a DWF entry's average (baseline) value at runtime.
Definition openswmm_inflows_impl.cpp:222
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:236
SWMM_ENGINE_API int swmm_ext_inflow_set_baseline(SWMM_Engine engine, int entry_idx, double baseline)
Set an external inflow entry's constant baseline at runtime.
Definition openswmm_inflows_impl.cpp:105
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:580
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:146
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:338
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:686
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:481
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:115
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:550
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:535
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:213
SWMM_ENGINE_API int swmm_ext_inflow_set_scale(SWMM_Engine engine, int entry_idx, double scale)
Set an external inflow entry's timeseries scale factor at runtime.
Definition openswmm_inflows_impl.cpp:95
SWMM_ENGINE_API int swmm_rdii_decay_count(SWMM_Engine engine)
Count exponential-decay parameter rows.
Definition openswmm_inflows_impl.cpp:429
SWMM_ENGINE_API int swmm_hydrograph_group_count(SWMM_Engine engine)
Count the unique unit-hydrograph group names defined.
Definition openswmm_inflows_impl.cpp:360
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:298
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:366
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:262
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:71
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:654
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:159
SWMM_ENGINE_API int swmm_hydrograph_count(SWMM_Engine engine)
Count parameter entries in the model.
Definition openswmm_inflows_impl.cpp:323
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:328
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:508