OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm_2d.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
37
38#ifndef OPENSWMM_2D_H
39#define OPENSWMM_2D_H
40
41#include "openswmm_callbacks.h"
42
43#ifdef OPENSWMM_ENGINE_STATIC
44# define SWMM_ENGINE_API
45#else
46# ifdef _WIN32
47# ifdef openswmm_engine_EXPORTS
48# define SWMM_ENGINE_API __declspec(dllexport)
49# else
50# define SWMM_ENGINE_API __declspec(dllimport)
51# endif
52# else
53# define SWMM_ENGINE_API __attribute__((visibility("default")))
54# endif
55#endif
56
57#ifdef __cplusplus
58extern "C" {
59#endif
60
61/* =========================================================================
62 * 2D Module Status
63 * ========================================================================= */
64
71SWMM_ENGINE_API int swmm_2d_is_active(SWMM_Engine engine, int* active);
72
84
85/* =========================================================================
86 * Mesh Geometry — Query (read-only after initialization)
87 * ========================================================================= */
88
92
96
102 double* x, double* y, double* z);
103
108 double* x, double* y, double* z);
109
128SWMM_ENGINE_API int swmm_2d_set_vertex_z(SWMM_Engine engine, int idx, double z);
129
154 const double* z, int count);
155
162 int* v0, int* v1, int* v2);
163
164/* -------------------------------------------------------------------------
165 * Mixed triangle / quadrilateral meshes (2D_TRI_QUAD_MESH_PLAN_2026-09-06).
166 *
167 * A "triangle index" everywhere in this header is a CELL index: cells are
168 * numbered triangles first (the [2D_TRIANGLES] rows), then quads (the
169 * [2D_QUADS] rows). Every swmm_2d_triangle_* accessor that reads a per-cell
170 * scalar (area, centroid, Manning, init depth/velocity, tag, coupling) works
171 * on a quad too; only the two 3-slot connectivity getters refuse quads.
172 * Local edge k of a cell has endpoints v[(k+1)%nv], v[(k+2)%nv].
173 * ------------------------------------------------------------------------- */
174
178SWMM_ENGINE_API int swmm_2d_cell_count(SWMM_Engine engine, int* count);
179
182SWMM_ENGINE_API int swmm_2d_quad_count(SWMM_Engine engine, int* count);
183
191SWMM_ENGINE_API int swmm_2d_edge_stride(SWMM_Engine engine, int* stride);
192
195SWMM_ENGINE_API int swmm_2d_cell_vertex_count(SWMM_Engine engine, int idx, int* nv);
196
202 int* v, int* nv);
203
209 int* n, int* nv);
210
216 double* area);
217
221 double* cx, double* cy,
222 double* cz);
223
227 double* n);
228
235 double n);
236
243 int idx, double* d);
244
251 int idx, double d);
252
256 int idx, double* u,
257 double* v);
258
266 int idx, double u,
267 double v);
268
273 const char* tag);
274
279 const char* tag);
280
286 char* buf, int buflen);
287
293 char* buf, int buflen);
294
299 int* n0, int* n1, int* n2);
300
313 double* length,
314 double* nx,
315 double* ny);
316
317/* =========================================================================
318 * Coupling Map — Query
319 * ========================================================================= */
320
324
328
334 int vertex_idx,
335 int* node_idx);
336
342 int tri_idx,
343 int* node_idx);
344
361 int vertex_idx,
362 const char* node_name);
363
381 int tri_idx,
382 const char* node_name,
383 double cd,
384 double area);
385
393
398 int* count);
399
408 int row_idx,
409 int* tri_idx,
410 int* node_idx,
411 double* cd,
412 double* area);
413
420 int vertex_idx,
421 double* cd);
422
430 int vertex_idx,
431 double cd);
432
445 int vertex_idx,
446 double* area);
447
457 int vertex_idx,
458 double area);
459
460/* =========================================================================
461 * 2D State — Per-Triangle (read during RUNNING)
462 * ========================================================================= */
463
468SWMM_ENGINE_API int swmm_2d_get_depth(SWMM_Engine engine, int idx, double* depth);
469
472SWMM_ENGINE_API int swmm_2d_get_head(SWMM_Engine engine, int idx, double* head);
473
477 double* flux);
478
482 double* rainfall);
483
487 double* net_source);
488
492SWMM_ENGINE_API int swmm_2d_get_depths_bulk(SWMM_Engine engine, double* depths);
493
496SWMM_ENGINE_API int swmm_2d_get_heads_bulk(SWMM_Engine engine, double* heads);
497
501 double* fluxes);
502
508 double* rainfall);
509
516 double* volumes);
517
537 double* volumes);
538
555 double* flux);
556
557/* =========================================================================
558 * 2D Edge Conveyance (§11A of docs/2dModelStrategy.md)
559 *
560 * Per-edge multiplicative factor in [0, 1] that attenuates the
561 * diffusion-wave flux across the edge (default 1.0 = unrestricted, 0.0 =
562 * wall). Storage is flat 2D `[tri * 3 + edge_local]`. Interior edges
563 * are symmetric: setting the value on one slot mirrors to the partner
564 * slot on the neighbour triangle so mass conservation is preserved.
565 *
566 * Safe to call between routing steps. Calling during a routing step is
567 * undefined — the 2D sub-stepper holds a const reference to the mesh.
568 * ========================================================================= */
569
577 int tri, int edge,
578 double* conveyance);
579
593 int tri, int edge,
594 double conveyance);
595
602 double* conveyance);
603
607
608/* =========================================================================
609 * 2D State — Per-Vertex (reconstructed heads)
610 * ========================================================================= */
611
615 double* head);
616
620 double* heads);
621
632 double* depths);
633
634/* =========================================================================
635 * 2D Solver Statistics
636 * ========================================================================= */
637
640SWMM_ENGINE_API int swmm_2d_get_max_depth(SWMM_Engine engine, double* max_depth);
641
644SWMM_ENGINE_API int swmm_2d_get_total_volume(SWMM_Engine engine, double* volume);
645
650 double* flow);
651
657
663 double* h_last);
664
683
689 SWMM_2DRunStats* stats);
690
695 double* max_depths);
696
701 double* max_velocities);
702
707 double* max_errs);
708
713
719 double* init_storage,
720 double* final_storage,
721 double* rainfall_in,
722 double* coupling_1d_to_2d_in,
723 double* coupling_2d_to_1d_out,
724 double* outfall_in,
725 double* outfall_out,
726 double* boundary_in,
727 double* boundary_out,
728 double* evap_out);
729
730/* =========================================================================
731 * 2D Forcing — Override rainfall or coupling for external control
732 * ========================================================================= */
733
741 double value, int mode,
742 int persist);
743
747 double value, int mode,
748 int persist);
749
762 double value, int mode,
763 int persist);
764
768 double value, int mode,
769 int persist);
770
775 double value, int mode,
776 int persist);
777
781
782/* =========================================================================
783 * 2D Solver Options — Query/Modify (valid after INITIALIZED)
784 * ========================================================================= */
785
788SWMM_ENGINE_API int swmm_2d_get_dry_depth(SWMM_Engine engine, double* dry_depth);
789
792SWMM_ENGINE_API int swmm_2d_set_dry_depth(SWMM_Engine engine, double dry_depth);
793
794
795
796
797
798/* =========================================================================
799 * 2D Boundary Conditions
800 * ========================================================================= */
801
812#define SWMM_2D_BC_WALL 0
813#define SWMM_2D_BC_NORMAL_FLOW 1
814#define SWMM_2D_BC_SPECIFIED_STAGE 2
815#define SWMM_2D_BC_SPECIFIED_FLOW 3
816#define SWMM_2D_BC_RATING_CURVE 4
817
821
828 int tri_idx, int edge,
829 int* bc_type);
830
834 int tri_idx, int edge,
835 int bc_type);
836
844 int tri_idx, int edge,
845 double* head);
846
851 int tri_idx, int edge,
852 double head);
853
857 int tri_idx, int edge,
858 double* slope);
859
863 int tri_idx, int edge,
864 double slope);
865
874 int tri_idx,
875 int edge,
876 const char* name);
877
885 int tri_idx,
886 int edge,
887 char* buf, int buflen);
888
897 int tri_idx, int edge,
898 double* flow);
899
904 int tri_idx, int edge,
905 double flow);
906
910 int tri_idx,
911 int edge,
912 const char* name);
913
917 int tri_idx,
918 int edge,
919 char* buf,
920 int buflen);
921
928 int tri_idx,
929 int edge,
930 const char* name);
931
935 int tri_idx,
936 int edge,
937 char* buf,
938 int buflen);
939
943 int tri_idx, int edge,
944 double* cum_flux);
945
946
947/* =========================================================================
948 * Results-file variable selection ([2D_OPTIONS] REPORT_2D_VARIABLES)
949 * =========================================================================
950 * Engine-independent helpers so a host can build a checklist without
951 * re-implementing the token vocabulary. Tokens are listed in bit order; the
952 * presets DEFAULT / MINIMAL / ALL map to masks. Use swmm_options_get_ext /
953 * swmm_options_set_ext with key "REPORT_2D_VARIABLES" to read/write a model.
954 */
955
962SWMM_ENGINE_API unsigned swmm_2d_output_variable_mask(const char* text);
964SWMM_ENGINE_API const char* swmm_2d_output_variable_text(unsigned mask);
965
966#ifdef __cplusplus
967} /* extern "C" */
968#endif
969
970#endif /* OPENSWMM_2D_H */
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:884
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:1224
SWMM_ENGINE_API int swmm_2d_get_triangle_coupling_row(SWMM_Engine engine, int row_idx, int *tri_idx, int *node_idx, double *cd, double *area)
Read one authored node→cell coupling row by row index.
Definition Api2D.cpp:518
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:420
SWMM_ENGINE_API int swmm_2d_set_vertex_coupling_cd(SWMM_Engine engine, int vertex_idx, double cd)
Set the coupling discharge coefficient of a vertex ([2D_VERTEX_NODE_MAP] CD column)....
Definition Api2D.cpp:548
SWMM_ENGINE_API int swmm_2d_get_solver_last_step(SWMM_Engine engine, double *h_last)
Get the explicit marcher's last sub-step size (s). (Renamed from swmm_2d_get_cvode_last_step with the...
Definition Api2D.cpp:902
SWMM_ENGINE_API int swmm_2d_triangle_get_area(SWMM_Engine engine, int idx, double *area)
Get triangle area.
Definition Api2D.cpp:237
SWMM_ENGINE_API int swmm_2d_edge_stride(SWMM_Engine engine, int *stride)
Edge-slot stride of the bulk edge arrays (swmm_2d_get_edge_flux_bulk, swmm_2d_edge_get_geometry_bulk,...
Definition Api2D.cpp:196
SWMM_ENGINE_API int swmm_2d_get_run_stats(SWMM_Engine engine, SWMM_2DRunStats *stats)
Read the cumulative marcher statistics and backend of the 2D run. Counters are zero (and n_tiers 0) b...
Definition Api2D.cpp:911
SWMM_ENGINE_API int swmm_2d_get_continuity_error(SWMM_Engine engine, double *err)
Get the global 2D surface continuity error (fraction).
Definition Api2D.cpp:969
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 for a SPECIFIED_FLOW edge. V-E4.
Definition Api2D.cpp:1311
SWMM_ENGINE_API int swmm_2d_add_triangle_coupling(SWMM_Engine engine, int tri_idx, const char *node_name, double cd, double area)
Append one node→cell coupling row ([2D_TRIANGLE_NODE_MAP] repeated-row form).
Definition Api2D.cpp:467
SWMM_ENGINE_API int swmm_2d_get_rainfall_bulk(SWMM_Engine engine, double *rainfall)
Bulk get the rainfall intensity (m/s) applied to every triangle this step — the same field the HDF5 M...
Definition Api2D.cpp:645
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:373
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:1191
SWMM_ENGINE_API int swmm_2d_reset_edge_conveyance(SWMM_Engine engine)
Reset every edge's conveyance factor to 1.0 (unrestricted).
Definition Api2D.cpp:775
SWMM_ENGINE_API int swmm_2d_quad_count(SWMM_Engine engine, int *count)
Number of quadrilateral cells (0 for an all-triangle mesh).
Definition Api2D.cpp:188
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:804
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:875
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:1162
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:1204
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:126
SWMM_ENGINE_API int swmm_2d_set_vertex_tag(SWMM_Engine engine, int idx, const char *tag)
Set the descriptive tag of a vertex (the [2D_VERTICES] TAG column). Distinct from the 1D<->2D couplin...
Definition Api2D.cpp:313
SWMM_ENGINE_API int swmm_2d_clear_triangle_couplings(SWMM_Engine engine)
Remove every authored node→cell coupling row (all triangles).
Definition Api2D.cpp:495
SWMM_ENGINE_API int swmm_2d_get_rain_volume_bulk(SWMM_Engine engine, double *volumes)
Bulk get the cumulative rainfall VOLUME (m³) booked onto every triangle since the start of the run — ...
Definition Api2D.cpp:655
SWMM_ENGINE_API int swmm_2d_set_vertex_z(SWMM_Engine engine, int idx, double z)
Set vertex Z (ground elevation).
Definition Api2D.cpp:140
SWMM_ENGINE_API int swmm_2d_get_stat_max_continuity_err(SWMM_Engine engine, double *max_errs)
Get per-triangle max |continuity residual| statistics (cumulative, m3/s).
Definition Api2D.cpp:958
SWMM_ENGINE_API int swmm_2d_get_edge_bc_tseries_name(SWMM_Engine engine, int tri_idx, int edge, char *buf, int buflen)
Get the timeseries NAME driving a SPECIFIED_STAGE edge.
Definition Api2D.cpp:1337
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:838
SWMM_ENGINE_API int swmm_2d_get_triangle_tag(SWMM_Engine engine, int idx, char *buf, int buflen)
Get the descriptive tag of a triangle (the [2D_TRIANGLES] TAG column). Copies up to buflen-1 bytes in...
Definition Api2D.cpp:349
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:605
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:936
SWMM_ENGINE_API int swmm_2d_set_triangle_tag(SWMM_Engine engine, int idx, const char *tag)
Set the descriptive tag of a triangle (the [2D_TRIANGLES] TAG column, e.g. a region / subcatchment id...
Definition Api2D.cpp:324
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:1261
SWMM_ENGINE_API int swmm_2d_cell_get_neighbours(SWMM_Engine engine, int idx, int *n, int *nv)
Neighbour cell across each local edge, any shape.
Definition Api2D.cpp:225
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:1012
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:865
SWMM_ENGINE_API int swmm_2d_get_depth(SWMM_Engine engine, int idx, double *depth)
Get water depth at a triangle.
Definition Api2D.cpp:585
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:595
SWMM_ENGINE_API int swmm_2d_get_solver_steps(SWMM_Engine engine, long *steps)
Get number of explicit-marcher sub-steps taken in the last advance. (Renamed from swmm_2d_get_cvode_s...
Definition Api2D.cpp:893
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:784
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:1273
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:405
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:247
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:625
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:827
SWMM_ENGINE_API int swmm_2d_force_evap(SWMM_Engine engine, int idx, double value, int mode, int persist)
Force evaporation on a specific triangle.
Definition Api2D.cpp:1048
SWMM_ENGINE_API int swmm_2d_get_depths_bulk(SWMM_Engine engine, double *depths)
Bulk get depths for all triangles.
Definition Api2D.cpp:635
SWMM_ENGINE_API int swmm_2d_set_triangle_init_velocity(SWMM_Engine engine, int idx, double u, double v)
Set triangle initial velocity (u, v in m/s; finite values; SWMM_ERR_BADPARAM otherwise)....
Definition Api2D.cpp:301
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 (same units convention as the getter).
Definition Api2D.cpp:1237
SWMM_ENGINE_API int swmm_2d_triangle_count(SWMM_Engine engine, int *count)
Get the number of mesh triangles.
Definition Api2D.cpp:106
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:615
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:685
SWMM_ENGINE_API int swmm_2d_prepare_for_edit(SWMM_Engine engine)
Make the parsed 2D mesh editable without a full initialize().
Definition Api2D.cpp:87
SWMM_ENGINE_API int swmm_2d_cell_count(SWMM_Engine engine, int *count)
Number of cells (triangles + quads) — same value as swmm_2d_triangle_count.
Definition Api2D.cpp:180
SWMM_ENGINE_API int swmm_2d_set_triangle_mannings(SWMM_Engine engine, int idx, double n)
Set triangle Manning's roughness coefficient.
Definition Api2D.cpp:259
SWMM_ENGINE_API int swmm_2d_get_stat_max_velocities(SWMM_Engine engine, double *max_velocities)
Get per-triangle max velocity-magnitude statistics (cumulative, m/s).
Definition Api2D.cpp:947
SWMM_ENGINE_API int swmm_2d_triangle_coupling_rows(SWMM_Engine engine, int *count)
Number of authored node→cell coupling rows.
Definition Api2D.cpp:510
SWMM_ENGINE_API int swmm_2d_set_vertex_coupled_node(SWMM_Engine engine, int vertex_idx, const char *node_name)
Set (or clear) the SWMM node a vertex is coupled to, by name.
Definition Api2D.cpp:446
SWMM_ENGINE_API int swmm_2d_get_dry_depth(SWMM_Engine engine, double *dry_depth)
Get the dry depth threshold (m).
Definition Api2D.cpp:1127
SWMM_ENGINE_API int swmm_2d_get_edge_conveyance_bulk(SWMM_Engine engine, double *conveyance)
Bulk get conveyance factor at every edge of every triangle.
Definition Api2D.cpp:757
SWMM_ENGINE_API int swmm_2d_cell_vertex_count(SWMM_Engine engine, int idx, int *nv)
Vertices (== edges) of a cell: 3 or 4.
Definition Api2D.cpp:204
SWMM_ENGINE_API int swmm_2d_cell_get_vertices(SWMM_Engine engine, int idx, int *v, int *nv)
Cell connectivity for any shape.
Definition Api2D.cpp:213
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:1292
SWMM_ENGINE_API int swmm_2d_set_vertex_z_bulk(SWMM_Engine engine, const double *z, int count)
Set EVERY vertex Z in one call.
Definition Api2D.cpp:151
SWMM_ENGINE_API int swmm_2d_get_coupling_volume_bulk(SWMM_Engine engine, double *volumes)
Bulk get the SIGNED cumulative 1D↔2D coupling exchange VOLUME (m³) per triangle since the start of th...
Definition Api2D.cpp:665
SWMM_ENGINE_API int swmm_2d_force_clear_all(SWMM_Engine engine)
Clear all 2D forcings.
Definition Api2D.cpp:1101
SWMM_ENGINE_API int swmm_2d_vertex_get_render_depths_bulk(SWMM_Engine engine, double *depths)
Bulk get render-oriented SIGNED vertex depths (m) at all vertices.
Definition Api2D.cpp:849
SWMM_ENGINE_API int swmm_2d_get_mass_balance(SWMM_Engine engine, double *init_storage, double *final_storage, double *rainfall_in, double *coupling_1d_to_2d_in, double *coupling_2d_to_1d_out, double *outfall_in, double *outfall_out, double *boundary_in, double *boundary_out, double *evap_out)
Get the global 2D mass-balance terms (all m3). Any pointer may be NULL.
Definition Api2D.cpp:981
SWMM_ENGINE_API int swmm_2d_vertex_count(SWMM_Engine engine, int *count)
Get the number of mesh vertices.
Definition Api2D.cpp:98
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:433
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:1029
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:114
SWMM_ENGINE_API int swmm_2d_force_evap_uniform(SWMM_Engine engine, double value, int mode, int persist)
Force evaporation on all triangles (uniform).
Definition Api2D.cpp:1065
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:1248
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:165
SWMM_ENGINE_API int swmm_2d_set_triangle_init_depth(SWMM_Engine engine, int idx, double d)
Set triangle initial water depth (mesh length units, >= 0; SWMM_ERR_BADPARAM otherwise — see the gett...
Definition Api2D.cpp:279
SWMM_ENGINE_API int swmm_2d_get_heads_bulk(SWMM_Engine engine, double *heads)
Bulk get heads for all triangles.
Definition Api2D.cpp:675
SWMM_ENGINE_API int swmm_2d_set_dry_depth(SWMM_Engine engine, double dry_depth)
Set the dry depth threshold (m).
Definition Api2D.cpp:1136
SWMM_ENGINE_API int swmm_2d_set_edge_conveyance(SWMM_Engine engine, int tri, int edge, double conveyance)
Set the per-edge conveyance factor for one edge.
Definition Api2D.cpp:737
SWMM_ENGINE_API int swmm_2d_get_vertex_coupling_cd(SWMM_Engine engine, int vertex_idx, double *cd)
Get the coupling discharge coefficient of a vertex ([2D_VERTEX_NODE_MAP] CD column; default 0....
Definition Api2D.cpp:537
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:390
SWMM_ENGINE_API int swmm_2d_triangle_get_mannings(SWMM_Engine engine, int idx, double *n)
Get triangle Manning's roughness.
Definition Api2D.cpp:363
SWMM_ENGINE_API int swmm_2d_get_edge_conveyance(SWMM_Engine engine, int tri, int edge, double *conveyance)
Get the per-edge conveyance factor for one edge.
Definition Api2D.cpp:724
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:1084
SWMM_ENGINE_API int swmm_2d_triangle_get_init_depth(SWMM_Engine engine, int idx, double *d)
Get triangle initial water depth ([2D_TRIANGLES] INIT_DEPTH column, default 0 = dry)....
Definition Api2D.cpp:269
SWMM_ENGINE_API int swmm_2d_triangle_get_init_velocity(SWMM_Engine engine, int idx, double *u, double *v)
Get triangle initial velocity (u, v in m/s; [2D_INITIAL_VELOCITY] rows, default 0,...
Definition Api2D.cpp:289
SWMM_ENGINE_API int swmm_2d_get_vertex_tag(SWMM_Engine engine, int idx, char *buf, int buflen)
Get the descriptive tag of a vertex (the [2D_VERTICES] TAG column). Copies up to buflen-1 bytes into ...
Definition Api2D.cpp:335
SWMM_ENGINE_API int swmm_2d_get_vertex_coupling_area(SWMM_Engine engine, int vertex_idx, double *area)
Get the coupling exchange area of a vertex ([2D_VERTEX_NODE_MAP] AREA column; default 1....
Definition Api2D.cpp:559
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:80
SWMM_ENGINE_API int swmm_2d_set_vertex_coupling_area(SWMM_Engine engine, int vertex_idx, double area)
Set the coupling exchange area of a vertex ([2D_VERTEX_NODE_MAP] AREA column). Persisted by the ....
Definition Api2D.cpp:570
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:1387
SWMM_ENGINE_API int swmm_2d_get_edge_bc_flow_tseries_name(SWMM_Engine engine, int tri_idx, int edge, char *buf, int buflen)
Get the timeseries NAME driving a SPECIFIED_FLOW edge. SVBC A8 — same contract as swmm_2d_get_edge_bc...
Definition Api2D.cpp:1350
#define SWMM_ENGINE_API
Definition openswmm_2d.h:53
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 (same units convention as the getter: display flow units/m befo...
Definition Api2D.cpp:1376
SWMM_ENGINE_API const char * swmm_2d_output_variable_name(int i)
Definition Api2D.cpp:1433
SWMM_ENGINE_API unsigned swmm_2d_output_variable_mask(const char *text)
Definition Api2D.cpp:1439
SWMM_ENGINE_API int swmm_2d_output_variable_count(void)
Definition Api2D.cpp:1429
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:1406
SWMM_ENGINE_API int swmm_2d_get_edge_bc_rating_curve_name(SWMM_Engine engine, int tri_idx, int edge, char *buf, int buflen)
Get the curve NAME driving a RATING_CURVE edge. SVBC A8 — same contract as swmm_2d_get_edge_bc_tserie...
Definition Api2D.cpp:1363
SWMM_ENGINE_API const char * swmm_2d_output_variable_text(unsigned mask)
Definition Api2D.cpp:1446
Callback function typedefs for the OpenSWMM Engine C API.
void * SWMM_Engine
Opaque handle to an OpenSWMM Engine instance.
Definition openswmm_callbacks.h:51
Cumulative explicit-marcher run statistics plus the backend and closure this run is on — the numbers ...
Definition openswmm_2d.h:669
double last_step
Definition openswmm_2d.h:676
long tier_cells[8]
Definition openswmm_2d.h:681
int momentum
Definition openswmm_2d.h:672
long steps
Definition openswmm_2d.h:674
int n_tiers
Definition openswmm_2d.h:680
double active_frac_min
Definition openswmm_2d.h:677
double active_frac_max
Definition openswmm_2d.h:679
long face_evals
Definition openswmm_2d.h:675
double active_frac_mean
Definition openswmm_2d.h:678
int lts_tiers
Definition openswmm_2d.h:673
char backend[64]
Definition openswmm_2d.h:670