OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
openswmm_2d.h
Go to the documentation of this file.
1
22#ifndef OPENSWMM_2D_H
23#define OPENSWMM_2D_H
24
25#include "openswmm_callbacks.h"
26
27#ifdef OPENSWMM_ENGINE_STATIC
28# define SWMM_ENGINE_API
29#else
30# ifdef _WIN32
31# ifdef openswmm_engine_EXPORTS
32# define SWMM_ENGINE_API __declspec(dllexport)
33# else
34# define SWMM_ENGINE_API __declspec(dllimport)
35# endif
36# else
37# define SWMM_ENGINE_API __attribute__((visibility("default")))
38# endif
39#endif
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
45/* =========================================================================
46 * 2D Module Status
47 * ========================================================================= */
48
55SWMM_ENGINE_API int swmm_2d_is_active(SWMM_Engine engine, int* active);
56
57/* =========================================================================
58 * Mesh Geometry — Query (read-only after initialization)
59 * ========================================================================= */
60
64
68
74 double* x, double* y, double* z);
75
80 double* x, double* y, double* z);
81
100SWMM_ENGINE_API int swmm_2d_set_vertex_z(SWMM_Engine engine, int idx, double z);
101
107 int* v0, int* v1, int* v2);
108
114 double* area);
115
119 double* cx, double* cy,
120 double* cz);
121
125 double* n);
126
131 int* n0, int* n1, int* n2);
132
145 double* length,
146 double* nx,
147 double* ny);
148
149/* =========================================================================
150 * Coupling Map — Query
151 * ========================================================================= */
152
156
160
166 int vertex_idx,
167 int* node_idx);
168
174 int tri_idx,
175 int* node_idx);
176
177/* =========================================================================
178 * 2D State — Per-Triangle (read during RUNNING)
179 * ========================================================================= */
180
185SWMM_ENGINE_API int swmm_2d_get_depth(SWMM_Engine engine, int idx, double* depth);
186
189SWMM_ENGINE_API int swmm_2d_get_head(SWMM_Engine engine, int idx, double* head);
190
194 double* flux);
195
199 double* rainfall);
200
204 double* net_source);
205
209SWMM_ENGINE_API int swmm_2d_get_depths_bulk(SWMM_Engine engine, double* depths);
210
213SWMM_ENGINE_API int swmm_2d_get_heads_bulk(SWMM_Engine engine, double* heads);
214
218 double* fluxes);
219
232 double* flux);
233
234/* =========================================================================
235 * 2D State — Per-Vertex (reconstructed heads)
236 * ========================================================================= */
237
241 double* head);
242
246 double* heads);
247
248/* =========================================================================
249 * 2D Solver Statistics
250 * ========================================================================= */
251
254SWMM_ENGINE_API int swmm_2d_get_max_depth(SWMM_Engine engine, double* max_depth);
255
258SWMM_ENGINE_API int swmm_2d_get_total_volume(SWMM_Engine engine, double* volume);
259
264 double* flow);
265
269
273 double* h_last);
274
279 double* max_depths);
280
281/* =========================================================================
282 * 2D Forcing — Override rainfall or coupling for external control
283 * ========================================================================= */
284
292 double value, int mode,
293 int persist);
294
298 double value, int mode,
299 int persist);
300
305 double value, int mode,
306 int persist);
307
311
312/* =========================================================================
313 * 2D Solver Options — Query/Modify (valid after INITIALIZED)
314 * ========================================================================= */
315
318SWMM_ENGINE_API int swmm_2d_get_dry_depth(SWMM_Engine engine, double* dry_depth);
319
322SWMM_ENGINE_API int swmm_2d_set_dry_depth(SWMM_Engine engine, double dry_depth);
323
327
331
335
339
340/* =========================================================================
341 * 2D Boundary Conditions
342 * ========================================================================= */
343
353#define SWMM_2D_BC_WALL 0
354#define SWMM_2D_BC_NORMAL_FLOW 1
355#define SWMM_2D_BC_SPECIFIED_STAGE 2
356#define SWMM_2D_BC_SPECIFIED_FLOW 3
357#define SWMM_2D_BC_RATING_CURVE 4
362
369 int tri_idx, int edge,
370 int* bc_type);
371
375 int tri_idx, int edge,
376 int bc_type);
377
381 int tri_idx, int edge,
382 double* head);
383
387 int tri_idx, int edge,
388 double head);
389
393 int tri_idx, int edge,
394 double* slope);
395
399 int tri_idx, int edge,
400 double slope);
401
410 int tri_idx,
411 int edge,
412 const char* name);
413
418 int tri_idx, int edge,
419 double* flow);
420
423 int tri_idx, int edge,
424 double flow);
425
429 int tri_idx,
430 int edge,
431 const char* name);
432
439 int tri_idx,
440 int edge,
441 const char* name);
442
446 int tri_idx, int edge,
447 double* cum_flux);
448
449#ifdef __cplusplus
450} /* extern "C" */
451#endif
452
453#endif /* OPENSWMM_2D_H */
int tri_idx
Definition MeshBuilder.cpp:41
SWMM_ENGINE_API int swmm_2d_get_total_exchange_flow(SWMM_Engine engine, double *flow)
Get total exchange flow rate (sum of all coupling flows, m³/s). Positive = net flow from 2D into 1D n...
Definition Api2D.cpp:375
SWMM_ENGINE_API int swmm_2d_get_edge_bc_head(SWMM_Engine engine, int tri_idx, int edge, double *head)
Get specified stage boundary head for an edge.
Definition Api2D.cpp:600
SWMM_ENGINE_API int swmm_2d_vertex_get_coupled_node(SWMM_Engine engine, int vertex_idx, int *node_idx)
Get vertex coupling: which SWMM node is coupled to this vertex.
Definition Api2D.cpp:196
SWMM_ENGINE_API int swmm_2d_triangle_get_area(SWMM_Engine engine, int idx, double *area)
Get triangle area.
Definition Api2D.cpp:120
SWMM_ENGINE_API int swmm_2d_get_rel_tolerance(SWMM_Engine engine, double *rtol)
Get CVODE relative tolerance.
Definition Api2D.cpp:497
SWMM_ENGINE_API int swmm_2d_get_edge_bc_flow(SWMM_Engine engine, int tri_idx, int edge, double *flow)
Get prescribed flow per metre of edge (m³/s/m) for a SPECIFIED_FLOW edge. V-E4.
Definition Api2D.cpp:681
SWMM_ENGINE_API int swmm_2d_triangle_get_neighbours(SWMM_Engine engine, int idx, int *n0, int *n1, int *n2)
Get triangle neighbour indices (-1 = boundary edge).
Definition Api2D.cpp:152
SWMM_ENGINE_API int swmm_2d_get_edge_bc_type(SWMM_Engine engine, int tri_idx, int edge, int *bc_type)
Get boundary condition type for an edge.
Definition Api2D.cpp:570
SWMM_ENGINE_API int swmm_2d_get_cvode_steps(SWMM_Engine engine, long *steps)
Get number of CVODE internal steps taken in the last advance.
Definition Api2D.cpp:384
SWMM_ENGINE_API int swmm_2d_edge_get_geometry_bulk(SWMM_Engine engine, double *length, double *nx, double *ny)
Bulk get edge geometry — time-invariant edge length and outward unit normal components,...
Definition Api2D.cpp:314
SWMM_ENGINE_API int swmm_2d_get_total_volume(SWMM_Engine engine, double *volume)
Get total 2D surface volume (sum of depth * area).
Definition Api2D.cpp:366
SWMM_ENGINE_API int swmm_2d_boundary_edge_count(SWMM_Engine engine, int *count)
Get the number of boundary edges (edges with no neighbour).
Definition Api2D.cpp:554
SWMM_ENGINE_API int swmm_2d_set_edge_bc_type(SWMM_Engine engine, int tri_idx, int edge, int bc_type)
Set boundary condition type for an edge.
Definition Api2D.cpp:581
SWMM_ENGINE_API int swmm_2d_vertex_get_xyz_bulk(SWMM_Engine engine, double *x, double *y, double *z)
Bulk get vertex coordinates.
Definition Api2D.cpp:83
SWMM_ENGINE_API int swmm_2d_set_vertex_z(SWMM_Engine engine, int idx, double z)
Set vertex Z (ground elevation).
Definition Api2D.cpp:97
SWMM_ENGINE_API int swmm_2d_set_rel_tolerance(SWMM_Engine engine, double rtol)
Set CVODE relative tolerance.
Definition Api2D.cpp:506
SWMM_ENGINE_API int swmm_2d_vertex_get_heads_bulk(SWMM_Engine engine, double *heads)
Bulk get reconstructed heads at all vertices.
Definition Api2D.cpp:342
SWMM_ENGINE_API int swmm_2d_get_coupling_flux(SWMM_Engine engine, int idx, double *flux)
Get coupling exchange flux at a triangle (m/s, + = into 2D).
Definition Api2D.cpp:242
SWMM_ENGINE_API int swmm_2d_get_stat_max_depths(SWMM_Engine engine, double *max_depths)
Get per-triangle max depth statistics (cumulative).
Definition Api2D.cpp:402
SWMM_ENGINE_API int swmm_2d_set_edge_bc_slope(SWMM_Engine engine, int tri_idx, int edge, double slope)
Set normal flow boundary slope for an edge.
Definition Api2D.cpp:633
SWMM_ENGINE_API int swmm_2d_force_rainfall(SWMM_Engine engine, int idx, double value, int mode, int persist)
Force rainfall on a specific triangle.
Definition Api2D.cpp:417
SWMM_ENGINE_API int swmm_2d_get_max_depth(SWMM_Engine engine, double *max_depth)
Get the maximum depth across all triangles.
Definition Api2D.cpp:356
SWMM_ENGINE_API int swmm_2d_get_depth(SWMM_Engine engine, int idx, double *depth)
Get water depth at a triangle.
Definition Api2D.cpp:222
SWMM_ENGINE_API int swmm_2d_get_head(SWMM_Engine engine, int idx, double *head)
Get total head at a triangle (z + depth).
Definition Api2D.cpp:232
SWMM_ENGINE_API int swmm_2d_get_edge_flux_bulk(SWMM_Engine engine, double *flux)
Bulk get normal edge flux at every edge of every triangle.
Definition Api2D.cpp:303
SWMM_ENGINE_API int swmm_2d_get_edge_bc_cum_flux(SWMM_Engine engine, int tri_idx, int edge, double *cum_flux)
Get cumulative boundary flux at an edge (m³, + = outflow).
Definition Api2D.cpp:645
SWMM_ENGINE_API int swmm_2d_triangle_coupling_count(SWMM_Engine engine, int *count)
Get the number of triangle-to-node coupling points.
Definition Api2D.cpp:182
SWMM_ENGINE_API int swmm_2d_triangle_get_centroid(SWMM_Engine engine, int idx, double *cx, double *cy, double *cz)
Get triangle centroid coordinates.
Definition Api2D.cpp:130
SWMM_ENGINE_API int swmm_2d_get_net_source(SWMM_Engine engine, int idx, double *net_source)
Get net source/sink rate at a triangle (m/s).
Definition Api2D.cpp:262
SWMM_ENGINE_API int swmm_2d_vertex_get_head(SWMM_Engine engine, int idx, double *head)
Get reconstructed head at a vertex.
Definition Api2D.cpp:332
SWMM_ENGINE_API int swmm_2d_get_depths_bulk(SWMM_Engine engine, double *depths)
Bulk get depths for all triangles.
Definition Api2D.cpp:272
SWMM_ENGINE_API int swmm_2d_set_edge_bc_head(SWMM_Engine engine, int tri_idx, int edge, double head)
Set specified stage boundary head for an edge.
Definition Api2D.cpp:611
SWMM_ENGINE_API int swmm_2d_set_abs_tolerance(SWMM_Engine engine, double atol)
Set CVODE absolute tolerance.
Definition Api2D.cpp:524
SWMM_ENGINE_API int swmm_2d_triangle_count(SWMM_Engine engine, int *count)
Get the number of mesh triangles.
Definition Api2D.cpp:63
SWMM_ENGINE_API int swmm_2d_get_rainfall(SWMM_Engine engine, int idx, double *rainfall)
Get rainfall intensity at a triangle (m/s).
Definition Api2D.cpp:252
SWMM_ENGINE_API int swmm_2d_get_coupling_fluxes_bulk(SWMM_Engine engine, double *fluxes)
Bulk get coupling fluxes for all triangles.
Definition Api2D.cpp:292
SWMM_ENGINE_API int swmm_2d_get_dry_depth(SWMM_Engine engine, double *dry_depth)
Get the dry depth threshold (m).
Definition Api2D.cpp:479
SWMM_ENGINE_API int swmm_2d_set_edge_bc_tseries_name(SWMM_Engine engine, int tri_idx, int edge, const char *name)
Set the timeseries NAME to drive a SPECIFIED_STAGE edge.
Definition Api2D.cpp:662
SWMM_ENGINE_API int swmm_2d_get_cvode_last_step(SWMM_Engine engine, double *h_last)
Get CVODE last internal step size.
Definition Api2D.cpp:393
SWMM_ENGINE_API int swmm_2d_force_clear_all(SWMM_Engine engine)
Clear all 2D forcings.
Definition Api2D.cpp:458
SWMM_ENGINE_API int swmm_2d_vertex_count(SWMM_Engine engine, int *count)
Get the number of mesh vertices.
Definition Api2D.cpp:55
SWMM_ENGINE_API int swmm_2d_triangle_get_coupled_node(SWMM_Engine engine, int tri_idx, int *node_idx)
Get triangle coupling: which SWMM node is coupled to this triangle.
Definition Api2D.cpp:207
SWMM_ENGINE_API int swmm_2d_force_rainfall_uniform(SWMM_Engine engine, double value, int mode, int persist)
Force rainfall on all triangles (uniform).
Definition Api2D.cpp:430
SWMM_ENGINE_API int swmm_2d_vertex_get_xyz(SWMM_Engine engine, int idx, double *x, double *y, double *z)
Get vertex coordinates.
Definition Api2D.cpp:71
SWMM_ENGINE_API int swmm_2d_get_edge_bc_slope(SWMM_Engine engine, int tri_idx, int edge, double *slope)
Get normal flow boundary slope for an edge.
Definition Api2D.cpp:622
SWMM_ENGINE_API int swmm_2d_get_abs_tolerance(SWMM_Engine engine, double *atol)
Get CVODE absolute tolerance.
Definition Api2D.cpp:515
SWMM_ENGINE_API int swmm_2d_triangle_get_vertices(SWMM_Engine engine, int idx, int *v0, int *v1, int *v2)
Get triangle connectivity (3 vertex indices).
Definition Api2D.cpp:108
SWMM_ENGINE_API int swmm_2d_get_heads_bulk(SWMM_Engine engine, double *heads)
Bulk get heads for all triangles.
Definition Api2D.cpp:282
SWMM_ENGINE_API int swmm_2d_set_dry_depth(SWMM_Engine engine, double dry_depth)
Set the dry depth threshold (m).
Definition Api2D.cpp:488
SWMM_ENGINE_API int swmm_2d_vertex_coupling_count(SWMM_Engine engine, int *count)
Get the number of vertex-to-node coupling points.
Definition Api2D.cpp:168
SWMM_ENGINE_API int swmm_2d_triangle_get_mannings(SWMM_Engine engine, int idx, double *n)
Get triangle Manning's roughness.
Definition Api2D.cpp:142
SWMM_ENGINE_API int swmm_2d_force_coupling_flux(SWMM_Engine engine, int idx, double value, int mode, int persist)
Force coupling flux on a specific triangle (override computed exchange).
Definition Api2D.cpp:445
SWMM_ENGINE_API int swmm_2d_is_active(SWMM_Engine engine, int *active)
Check whether the 2D module is active for this simulation.
Definition Api2D.cpp:44
double * y
Definition odesolve.c:28
SWMM_ENGINE_API int swmm_2d_set_edge_bc_flow_tseries_name(SWMM_Engine engine, int tri_idx, int edge, const char *name)
Set the timeseries NAME to drive a SPECIFIED_FLOW edge. V-E4 — same resolution contract as swmm_2d_se...
Definition Api2D.cpp:703
#define SWMM_ENGINE_API
Definition openswmm_2d.h:37
SWMM_ENGINE_API int swmm_2d_set_edge_bc_flow(SWMM_Engine engine, int tri_idx, int edge, double flow)
Set prescribed flow per metre of edge (m³/s/m). V-E4.
Definition Api2D.cpp:692
SWMM_ENGINE_API int swmm_2d_set_edge_bc_rating_curve_name(SWMM_Engine engine, int tri_idx, int edge, const char *name)
Set the curve NAME to drive a RATING_CURVE edge.
Definition Api2D.cpp:722
Callback function typedefs for the OpenSWMM Engine C API.
void * SWMM_Engine
Opaque handle to an OpenSWMM Engine instance.
Definition openswmm_callbacks.h:35