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
60
65
66#ifndef OPENSWMM_FORCING_H
67#define OPENSWMM_FORCING_H
68
69#include "openswmm_callbacks.h"
70
71#ifdef OPENSWMM_ENGINE_STATIC
72#define SWMM_ENGINE_API
73#else
74#ifdef _WIN32
75#ifdef openswmm_engine_EXPORTS
76#define SWMM_ENGINE_API __declspec(dllexport)
77#else
78#define SWMM_ENGINE_API __declspec(dllimport)
79#endif
80#else
81#define SWMM_ENGINE_API __attribute__((visibility("default")))
82#endif
83#endif
84
85#ifdef __cplusplus
86extern "C" {
87#endif
88
89/* =========================================================================
90 * Enumerations
91 * ========================================================================= */
92
99
105
129
135
136/* =========================================================================
137 * Node forcing
138 * ========================================================================= */
139
159SWMM_ENGINE_API int swmm_forcing_node_lat_inflow(SWMM_Engine engine, int idx, double value,
160 int mode, int persist);
161
181SWMM_ENGINE_API int swmm_forcing_node_head_boundary(SWMM_Engine engine, int idx, double value,
182 int mode, int persist);
183
207SWMM_ENGINE_API int swmm_forcing_node_quality(SWMM_Engine engine, int node_idx, int pollutant_idx,
208 double mass_rate, int mode, int persist);
209
231SWMM_ENGINE_API int swmm_forcing_node_temperature(SWMM_Engine engine, int node_idx, double value,
232 int mode, int persist);
233
255SWMM_ENGINE_API int swmm_forcing_node_age(SWMM_Engine engine, int node_idx, double value, int mode,
256 int persist);
257
258/* =========================================================================
259 * Link forcing
260 * ========================================================================= */
261
281SWMM_ENGINE_API int swmm_forcing_link_flow(SWMM_Engine engine, int idx, double value, int mode,
282 int persist);
283
302SWMM_ENGINE_API int swmm_forcing_link_setting(SWMM_Engine engine, int idx, double value, int mode,
303 int persist);
304
325SWMM_ENGINE_API int swmm_forcing_link_seepage(SWMM_Engine engine, int idx, double value, int mode,
326 int persist);
327
351SWMM_ENGINE_API int swmm_forcing_link_quality(SWMM_Engine engine, int link_idx, int pollutant_idx,
352 double value, int mode, int persist);
353
354/* =========================================================================
355 * Subcatchment forcing
356 * ========================================================================= */
357
376SWMM_ENGINE_API int swmm_forcing_subcatch_rainfall(SWMM_Engine engine, int idx, double value,
377 int mode, int persist);
378
399SWMM_ENGINE_API int swmm_forcing_subcatch_evap(SWMM_Engine engine, int idx, double value, int mode,
400 int persist);
401
421SWMM_ENGINE_API int swmm_forcing_subcatch_snowfall(SWMM_Engine engine, int idx, double value,
422 int mode, int persist);
423
435
436/* =========================================================================
437 * Climate forcing (system-wide)
438 * ========================================================================= */
439
458SWMM_ENGINE_API int swmm_forcing_climate_temperature(SWMM_Engine engine, double value, int mode,
459 int persist);
460
472
490SWMM_ENGINE_API int swmm_forcing_climate_wind(SWMM_Engine engine, double value, int mode,
491 int persist);
492
504
522SWMM_ENGINE_API int swmm_forcing_climate_evap(SWMM_Engine engine, double value, int mode,
523 int persist);
524
536
545
546/* =========================================================================
547 * Gage forcing
548 * ========================================================================= */
549
569SWMM_ENGINE_API int swmm_forcing_gage_rainfall(SWMM_Engine engine, int idx, double value, int mode,
570 int persist);
571
572/* =========================================================================
573 * Clear forcing
574 * ========================================================================= */
575
576/* =========================================================================
577 * PE4 — per-element climate
578 *
579 * Air temperature, humidity, wind and incoming shortwave are GLOBAL in every
580 * deck and per-element ONLY here. There is no deck syntax for per-element
581 * meteorology at any phase, deliberately: `ClimateState` is shared with
582 * hydrology, snowmelt and evaporation, so a hand-maintained file that could
583 * set a per-conduit air temperature would assert something the snowpack on
584 * the subcatchment above permanently disagrees with. A caller of THIS API is
585 * a coupled driver asserting the heterogeneity per step and answerable for
586 * it — which is how the reference works too: HydroCouple's RHEComponent and
587 * CSHComponent receive per-element meteorology through EXCHANGE ITEMS.
588 *
589 * Values are resolved AT THE FLUX CALL, never written into the climate
590 * state, so a per-link push cannot reach snowmelt or evaporation.
591 * ========================================================================= */
592
615SWMM_ENGINE_API int swmm_forcing_element_climate(SWMM_Engine engine, int kind, int index,
616 int variable, double value, int mode, int persist);
617
635SWMM_ENGINE_API int swmm_forcing_element_climate_get(SWMM_Engine engine, int kind, int index,
636 int variable, double* value, int* mode);
637
654SWMM_ENGINE_API int swmm_forcing_clear(SWMM_Engine engine, int type, int idx);
655
667
668#ifdef __cplusplus
669} /* extern "C" */
670#endif
671
672#endif /* OPENSWMM_FORCING_H */
#define SWMM_ENGINE_API
Definition openswmm_2d.h:62
Callback function typedefs for the OpenSWMM Engine C API.
void * SWMM_Engine
Opaque handle to an OpenSWMM Engine instance.
Definition openswmm_callbacks.h:55
SWMM_ENGINE_API int swmm_forcing_climate_temperature(SWMM_Engine engine, double value, int mode, int persist)
Register system air temperature forcing.
Definition openswmm_forcing_impl.cpp:288
SWMM_ENGINE_API int swmm_climate_get_wind_speed(SWMM_Engine engine, double *value)
Read the current wind speed.
Definition openswmm_forcing_impl.cpp:340
SWMM_ENGINE_API int swmm_forcing_node_head_boundary(SWMM_Engine engine, int idx, double value, int mode, int persist)
Register outfall head-boundary overlay for the next step(s).
Definition openswmm_forcing_impl.cpp:82
SWMM_ForcingMode
How the forcing value is applied relative to the computed value.
Definition openswmm_forcing.h:94
@ SWMM_FORCING_OVERRIDE
Definition openswmm_forcing.h:96
@ SWMM_FORCING_NONE
Definition openswmm_forcing.h:95
@ SWMM_FORCING_ADD
Definition openswmm_forcing.h:97
SWMM_ENGINE_API int swmm_forcing_gage_rainfall(SWMM_Engine engine, int idx, double value, int mode, int persist)
Register gage rainfall forcing for the next step(s).
Definition openswmm_forcing_impl.cpp:408
SWMM_ENGINE_API int swmm_forcing_node_age(SWMM_Engine engine, int node_idx, double value, int mode, int persist)
Register reserved-species node water age forcing.
Definition openswmm_forcing_impl.cpp:140
SWMM_ENGINE_API int swmm_forcing_clear(SWMM_Engine engine, int type, int idx)
Disable selected forcing modes without clearing their stored values.
Definition openswmm_forcing_impl.cpp:531
SWMM_ENGINE_API int swmm_forcing_climate_evap(SWMM_Engine engine, double value, int mode, int persist)
Register system evaporation rate forcing.
Definition openswmm_forcing_impl.cpp:350
SWMM_ENGINE_API int swmm_forcing_element_climate_get(SWMM_Engine engine, int kind, int index, int variable, double *value, int *mode)
Read an element-local registered climate prescription.
Definition openswmm_forcing_impl.cpp:661
SWMM_ForcingPersist
Whether the forcing persists across timesteps.
Definition openswmm_forcing.h:101
@ SWMM_FORCING_PERSIST
Definition openswmm_forcing.h:103
@ SWMM_FORCING_RESET
Definition openswmm_forcing.h:102
SWMM_ENGINE_API int swmm_climate_get_temperature(SWMM_Engine engine, double *value)
Read the current air temperature.
Definition openswmm_forcing_impl.cpp:310
SWMM_ENGINE_API int swmm_forcing_link_setting(SWMM_Engine engine, int idx, double value, int mode, int persist)
Register link setting forcing for the next step(s).
Definition openswmm_forcing_impl.cpp:179
SWMM_ENGINE_API int swmm_forcing_node_lat_inflow(SWMM_Engine engine, int idx, double value, int mode, int persist)
Register lateral user-flow overlay for the next step(s).
Definition openswmm_forcing_impl.cpp:66
SWMM_ENGINE_API int swmm_forcing_subcatch_rainfall(SWMM_Engine engine, int idx, double value, int mode, int persist)
Register subcatchment rainfall forcing for the next step(s).
Definition openswmm_forcing_impl.cpp:215
SWMM_ENGINE_API int swmm_forcing_node_quality(SWMM_Engine engine, int node_idx, int pollutant_idx, double mass_rate, int mode, int persist)
Register direct pollutant concentration forcing on a node.
Definition openswmm_forcing_impl.cpp:102
SWMM_ENGINE_API int swmm_forcing_node_temperature(SWMM_Engine engine, int node_idx, double value, int mode, int persist)
Register reserved-species node water temperature forcing.
Definition openswmm_forcing_impl.cpp:121
SWMM_ENGINE_API int swmm_forcing_subcatch_snowfall(SWMM_Engine engine, int idx, double value, int mode, int persist)
Register subcatchment snowfall forcing for the next step(s).
Definition openswmm_forcing_impl.cpp:262
SWMM_ENGINE_API int swmm_forcing_clear_all(SWMM_Engine engine)
Clear all ForcingData channels on the engine.
Definition openswmm_forcing_impl.cpp:691
SWMM_ENGINE_API int swmm_climate_set_dry_only(SWMM_Engine engine, int flag)
Set the stored evaporation DRY_ONLY flag.
Definition openswmm_forcing_impl.cpp:370
SWMM_HeatElemKind
Which element a per-element climate forcing targets (PE4).
Definition openswmm_forcing.h:131
@ SWMM_HEAT_ELEM_NODE
Definition openswmm_forcing.h:132
@ SWMM_HEAT_ELEM_LINK
Definition openswmm_forcing.h:133
SWMM_ForcingType
Forcing channel identifier (for targeted clear).
Definition openswmm_forcing.h:107
@ SWMM_FORCE_NODE_HEAD_BOUNDARY
Definition openswmm_forcing.h:109
@ SWMM_FORCE_LINK_QUALITY
Definition openswmm_forcing.h:120
@ SWMM_FORCE_NODE_QUALITY
Definition openswmm_forcing.h:110
@ SWMM_FORCE_LINK_SETTING
Definition openswmm_forcing.h:112
@ SWMM_FORCE_ELEM_AIR_TEMPERATURE
Definition openswmm_forcing.h:123
@ SWMM_FORCE_ELEM_HUMIDITY
Definition openswmm_forcing.h:124
@ SWMM_FORCE_ELEM_SHORTWAVE
Definition openswmm_forcing.h:126
@ SWMM_FORCE_SUBCATCH_EVAP
Definition openswmm_forcing.h:114
@ SWMM_FORCE_CLIMATE_WIND
Definition openswmm_forcing.h:117
@ SWMM_FORCE_CLIMATE_TEMPERATURE
Definition openswmm_forcing.h:116
@ SWMM_FORCE_ELEM_WIND_SPEED
Definition openswmm_forcing.h:125
@ SWMM_FORCE_LINK_FLOW
Definition openswmm_forcing.h:111
@ SWMM_FORCE_LINK_SEEPAGE
Definition openswmm_forcing.h:127
@ SWMM_FORCE_CLIMATE_EVAP
Definition openswmm_forcing.h:119
@ SWMM_FORCE_SUBCATCH_SNOWFALL
Definition openswmm_forcing.h:118
@ SWMM_FORCE_GAGE_RAINFALL
Definition openswmm_forcing.h:115
@ SWMM_FORCE_SUBCATCH_RAINFALL
Definition openswmm_forcing.h:113
@ SWMM_FORCE_NODE_LAT_INFLOW
Definition openswmm_forcing.h:108
SWMM_ENGINE_API int swmm_forcing_link_quality(SWMM_Engine engine, int link_idx, int pollutant_idx, double value, int mode, int persist)
Register direct pollutant concentration forcing on a link.
Definition openswmm_forcing_impl.cpp:385
SWMM_ENGINE_API int swmm_climate_get_dry_only(SWMM_Engine engine, int *flag)
Read the stored evaporation DRY_ONLY flag.
Definition openswmm_forcing_impl.cpp:377
SWMM_ENGINE_API int swmm_forcing_link_flow(SWMM_Engine engine, int idx, double value, int mode, int persist)
Register link flow-state forcing for the next step(s).
Definition openswmm_forcing_impl.cpp:163
SWMM_ENGINE_API int swmm_forcing_climate_wind(SWMM_Engine engine, double value, int mode, int persist)
Register system wind speed forcing.
Definition openswmm_forcing_impl.cpp:320
SWMM_ENGINE_API int swmm_forcing_element_climate(SWMM_Engine engine, int kind, int index, int variable, double value, int mode, int persist)
Register an element-local atmospheric heat-flux forcing.
Definition openswmm_forcing_impl.cpp:631
SWMM_ENGINE_API int swmm_forcing_link_seepage(SWMM_Engine engine, int idx, double value, int mode, int persist)
Register conduit groundwater-exchange forcing for the next step(s).
Definition openswmm_forcing_impl.cpp:195
SWMM_ENGINE_API int swmm_forcing_subcatch_evap(SWMM_Engine engine, int idx, double value, int mode, int persist)
Register subcatchment potential-evaporation forcing for the next step(s).
Definition openswmm_forcing_impl.cpp:231
SWMM_ENGINE_API int swmm_climate_get_evap_rate(SWMM_Engine engine, double *value)
Read the current broadcast evaporation rate.
Definition openswmm_forcing_impl.cpp:251