OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm_forcing.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
61
62#ifndef OPENSWMM_FORCING_H
63#define OPENSWMM_FORCING_H
64
65#include "openswmm_callbacks.h"
66
67#ifdef OPENSWMM_ENGINE_STATIC
68# define SWMM_ENGINE_API
69#else
70# ifdef _WIN32
71# ifdef openswmm_engine_EXPORTS
72# define SWMM_ENGINE_API __declspec(dllexport)
73# else
74# define SWMM_ENGINE_API __declspec(dllimport)
75# endif
76# else
77# define SWMM_ENGINE_API __attribute__((visibility("default")))
78# endif
79#endif
80
81#ifdef __cplusplus
82extern "C" {
83#endif
84
85/* =========================================================================
86 * Enumerations
87 * ========================================================================= */
88
95
101
124
130
131/* =========================================================================
132 * Node forcing
133 * ========================================================================= */
134
147 SWMM_Engine engine, int idx, double value, int mode, int persist);
148
161 SWMM_Engine engine, int idx, double value, int mode, int persist);
162
176 SWMM_Engine engine, int node_idx, int pollutant_idx,
177 double mass_rate, int mode, int persist);
178
193 SWMM_Engine engine, int node_idx, double value, int mode, int persist);
194
206 SWMM_Engine engine, int node_idx, double value, int mode, int persist);
207
208/* =========================================================================
209 * Link forcing
210 * ========================================================================= */
211
224 SWMM_Engine engine, int idx, double value, int mode, int persist);
225
238 SWMM_Engine engine, int idx, double value, int mode, int persist);
239
257 SWMM_Engine engine, int link_idx, int pollutant_idx,
258 double value, int mode, int persist);
259
260/* =========================================================================
261 * Subcatchment forcing
262 * ========================================================================= */
263
276 SWMM_Engine engine, int idx, double value, int mode, int persist);
277
297 SWMM_Engine engine, int idx, double value, int mode, int persist);
298
317 SWMM_Engine engine, int idx, double value, int mode, int persist);
318
334
335/* =========================================================================
336 * Climate forcing (system-wide)
337 * ========================================================================= */
338
357 SWMM_Engine engine, double value, int mode, int persist);
358
368
384 SWMM_Engine engine, double value, int mode, int persist);
385
395
414 SWMM_Engine engine, double value, int mode, int persist);
415
425
435
436/* =========================================================================
437 * Gage forcing
438 * ========================================================================= */
439
452 SWMM_Engine engine, int idx, double value, int mode, int persist);
453
454/* =========================================================================
455 * Clear forcing
456 * ========================================================================= */
457
467/* =========================================================================
468 * PE4 — per-element climate
469 *
470 * Air temperature, humidity, wind and incoming shortwave are GLOBAL in every
471 * deck and per-element ONLY here. There is no deck syntax for per-element
472 * meteorology at any phase, deliberately: `ClimateState` is shared with
473 * hydrology, snowmelt and evaporation, so a hand-maintained file that could
474 * set a per-conduit air temperature would assert something the snowpack on
475 * the subcatchment above permanently disagrees with. A caller of THIS API is
476 * a coupled driver asserting the heterogeneity per step and answerable for
477 * it — which is how the reference works too: HydroCouple's RHEComponent and
478 * CSHComponent receive per-element meteorology through EXCHANGE ITEMS.
479 *
480 * Values are resolved AT THE FLUX CALL, never written into the climate
481 * state, so a per-link push cannot reach snowmelt or evaporation.
482 * ========================================================================= */
483
513 SWMM_Engine engine, int kind, int index, int variable, double value,
514 int mode, int persist);
515
522 SWMM_Engine engine, int kind, int index, int variable, double* value,
523 int* mode);
524
525SWMM_ENGINE_API int swmm_forcing_clear(SWMM_Engine engine, int type, int idx);
526
535
536#ifdef __cplusplus
537} /* extern "C" */
538#endif
539
540#endif /* OPENSWMM_FORCING_H */
SWMM_ENGINE_API int swmm_forcing_climate_temperature(SWMM_Engine engine, double value, int mode, int persist)
Prescribe the air temperature used for snowmelt and temperature-derived evaporation.
Definition openswmm_forcing_impl.cpp:254
SWMM_ENGINE_API int swmm_climate_get_wind_speed(SWMM_Engine engine, double *value)
Get the current wind speed (read-only).
Definition openswmm_forcing_impl.cpp:306
SWMM_ENGINE_API int swmm_forcing_node_head_boundary(SWMM_Engine engine, int idx, double value, int mode, int persist)
Force a head boundary at an outfall node.
Definition openswmm_forcing_impl.cpp:68
SWMM_ENGINE_API int swmm_forcing_gage_rainfall(SWMM_Engine engine, int idx, double value, int mode, int persist)
Force rainfall on a rain gage (affects all linked subcatchments).
Definition openswmm_forcing_impl.cpp:375
SWMM_ENGINE_API int swmm_forcing_node_age(SWMM_Engine engine, int node_idx, double value, int mode, int persist)
Force the water age at a node (U2, 2026-09-07).
Definition openswmm_forcing_impl.cpp:125
SWMM_ENGINE_API int swmm_forcing_climate_evap(SWMM_Engine engine, double value, int mode, int persist)
Prescribe the system-wide evaporation rate.
Definition openswmm_forcing_impl.cpp:316
SWMM_ENGINE_API int swmm_forcing_element_climate_get(SWMM_Engine engine, int kind, int index, int variable, double *value, int *mode)
Read back a per-element climate forcing.
Definition openswmm_forcing_impl.cpp:578
SWMM_ENGINE_API int swmm_climate_get_temperature(SWMM_Engine engine, double *value)
Get the current air temperature (read-only).
Definition openswmm_forcing_impl.cpp:277
SWMM_ENGINE_API int swmm_forcing_link_setting(SWMM_Engine engine, int idx, double value, int mode, int persist)
Force a control setting on a link (pump, orifice, weir, outlet).
Definition openswmm_forcing_impl.cpp:162
SWMM_ENGINE_API int swmm_forcing_node_lat_inflow(SWMM_Engine engine, int idx, double value, int mode, int persist)
Force a lateral inflow at a node.
Definition openswmm_forcing_impl.cpp:52
SWMM_ENGINE_API int swmm_forcing_subcatch_rainfall(SWMM_Engine engine, int idx, double value, int mode, int persist)
Force rainfall on a subcatchment (bypasses gage lookup).
Definition openswmm_forcing_impl.cpp:182
SWMM_ENGINE_API int swmm_forcing_node_quality(SWMM_Engine engine, int node_idx, int pollutant_idx, double mass_rate, int mode, int persist)
Force a quality mass flux at a node.
Definition openswmm_forcing_impl.cpp:88
SWMM_ENGINE_API int swmm_forcing_node_temperature(SWMM_Engine engine, int node_idx, double value, int mode, int persist)
Force the water temperature at a node (U2, 2026-09-07).
Definition openswmm_forcing_impl.cpp:108
SWMM_ENGINE_API int swmm_forcing_subcatch_snowfall(SWMM_Engine engine, int idx, double value, int mode, int persist)
Prescribe snowfall on a subcatchment.
Definition openswmm_forcing_impl.cpp:229
SWMM_ENGINE_API int swmm_forcing_clear_all(SWMM_Engine engine)
Clear ALL forcings on ALL elements.
Definition openswmm_forcing_impl.cpp:604
SWMM_ENGINE_API int swmm_climate_set_dry_only(SWMM_Engine engine, int flag)
Set the evaporation DRY_ONLY option at runtime.
Definition openswmm_forcing_impl.cpp:335
SWMM_ENGINE_API int swmm_forcing_link_quality(SWMM_Engine engine, int link_idx, int pollutant_idx, double value, int mode, int persist)
Force pollutant quality on a link.
Definition openswmm_forcing_impl.cpp:351
SWMM_ENGINE_API int swmm_climate_get_dry_only(SWMM_Engine engine, int *flag)
Get the evaporation DRY_ONLY option.
Definition openswmm_forcing_impl.cpp:343
SWMM_ENGINE_API int swmm_forcing_link_flow(SWMM_Engine engine, int idx, double value, int mode, int persist)
Force a flow in a link.
Definition openswmm_forcing_impl.cpp:146
SWMM_ENGINE_API int swmm_forcing_climate_wind(SWMM_Engine engine, double value, int mode, int persist)
Prescribe the wind speed used in rain-on-snow melt.
Definition openswmm_forcing_impl.cpp:287
SWMM_ENGINE_API int swmm_forcing_element_climate(SWMM_Engine engine, int kind, int index, int variable, double value, int mode, int persist)
Clear forcing on a specific element and channel.
Definition openswmm_forcing_impl.cpp:548
SWMM_ENGINE_API int swmm_forcing_subcatch_evap(SWMM_Engine engine, int idx, double value, int mode, int persist)
Prescribe a potential evapotranspiration (PET) rate on a subcatchment.
Definition openswmm_forcing_impl.cpp:198
SWMM_ENGINE_API int swmm_climate_get_evap_rate(SWMM_Engine engine, double *value)
Get the current climate-derived evaporation rate.
Definition openswmm_forcing_impl.cpp:218
#define SWMM_ENGINE_API
Definition openswmm_2d.h:53
Callback function typedefs for the OpenSWMM Engine C API.
void * SWMM_Engine
Opaque handle to an OpenSWMM Engine instance.
Definition openswmm_callbacks.h:51
SWMM_ForcingMode
How the forcing value is applied relative to the computed value.
Definition openswmm_forcing.h:90
@ SWMM_FORCING_OVERRIDE
Definition openswmm_forcing.h:92
@ SWMM_FORCING_NONE
Definition openswmm_forcing.h:91
@ SWMM_FORCING_ADD
Definition openswmm_forcing.h:93
SWMM_ENGINE_API int swmm_forcing_clear(SWMM_Engine engine, int type, int idx)
Definition openswmm_forcing_impl.cpp:457
SWMM_ForcingPersist
Whether the forcing persists across timesteps.
Definition openswmm_forcing.h:97
@ SWMM_FORCING_PERSIST
Definition openswmm_forcing.h:99
@ SWMM_FORCING_RESET
Definition openswmm_forcing.h:98
SWMM_HeatElemKind
Which element a per-element climate forcing targets (PE4).
Definition openswmm_forcing.h:126
@ SWMM_HEAT_ELEM_NODE
Definition openswmm_forcing.h:127
@ SWMM_HEAT_ELEM_LINK
Definition openswmm_forcing.h:128
SWMM_ForcingType
Forcing channel identifier (for targeted clear).
Definition openswmm_forcing.h:103
@ SWMM_FORCE_NODE_HEAD_BOUNDARY
Definition openswmm_forcing.h:105
@ SWMM_FORCE_LINK_QUALITY
Definition openswmm_forcing.h:116
@ SWMM_FORCE_NODE_QUALITY
Definition openswmm_forcing.h:106
@ SWMM_FORCE_LINK_SETTING
Definition openswmm_forcing.h:108
@ SWMM_FORCE_ELEM_AIR_TEMPERATURE
Definition openswmm_forcing.h:119
@ SWMM_FORCE_ELEM_HUMIDITY
Definition openswmm_forcing.h:120
@ SWMM_FORCE_ELEM_SHORTWAVE
Definition openswmm_forcing.h:122
@ SWMM_FORCE_SUBCATCH_EVAP
Definition openswmm_forcing.h:110
@ SWMM_FORCE_CLIMATE_WIND
Definition openswmm_forcing.h:113
@ SWMM_FORCE_CLIMATE_TEMPERATURE
Definition openswmm_forcing.h:112
@ SWMM_FORCE_ELEM_WIND_SPEED
Definition openswmm_forcing.h:121
@ SWMM_FORCE_LINK_FLOW
Definition openswmm_forcing.h:107
@ SWMM_FORCE_CLIMATE_EVAP
Definition openswmm_forcing.h:115
@ SWMM_FORCE_SUBCATCH_SNOWFALL
Definition openswmm_forcing.h:114
@ SWMM_FORCE_GAGE_RAINFALL
Definition openswmm_forcing.h:111
@ SWMM_FORCE_SUBCATCH_RAINFALL
Definition openswmm_forcing.h:109
@ SWMM_FORCE_NODE_LAT_INFLOW
Definition openswmm_forcing.h:104