OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
openswmm_forcing.h File Reference

Runtime forcing API — inject fluxes with mass-balance tracking. More...

Include dependency graph for openswmm_forcing.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SWMM_ENGINE_API   __attribute__((visibility("default")))
 

Typedefs

typedef enum SWMM_ForcingMode SWMM_ForcingMode
 How the forcing value is applied relative to the computed value.
 
typedef enum SWMM_ForcingPersist SWMM_ForcingPersist
 Whether the forcing persists across timesteps.
 
typedef enum SWMM_ForcingType SWMM_ForcingType
 Forcing channel identifier (for targeted clear).
 

Enumerations

enum  SWMM_ForcingMode {
  SWMM_FORCING_NONE = 0 ,
  SWMM_FORCING_OVERRIDE = 1 ,
  SWMM_FORCING_ADD = 2
}
 How the forcing value is applied relative to the computed value. More...
 
enum  SWMM_ForcingPersist {
  SWMM_FORCING_RESET = 0 ,
  SWMM_FORCING_PERSIST = 1
}
 Whether the forcing persists across timesteps. More...
 
enum  SWMM_ForcingType {
  SWMM_FORCE_NODE_LAT_INFLOW = 0 ,
  SWMM_FORCE_NODE_HEAD_BOUNDARY = 1 ,
  SWMM_FORCE_NODE_QUALITY = 2 ,
  SWMM_FORCE_LINK_FLOW = 3 ,
  SWMM_FORCE_LINK_SETTING = 4 ,
  SWMM_FORCE_SUBCATCH_RAINFALL = 5 ,
  SWMM_FORCE_SUBCATCH_EVAP = 6 ,
  SWMM_FORCE_GAGE_RAINFALL = 7
}
 Forcing channel identifier (for targeted clear). More...
 

Functions

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.
 
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.
 
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.
 
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.
 
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).
 
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).
 
SWMM_ENGINE_API int swmm_forcing_subcatch_evap (SWMM_Engine engine, int idx, double value, int mode, int persist)
 Force an evaporation rate on a subcatchment.
 
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).
 
SWMM_ENGINE_API int swmm_forcing_clear (SWMM_Engine engine, int type, int idx)
 Clear forcing on a specific element and channel.
 
SWMM_ENGINE_API int swmm_forcing_clear_all (SWMM_Engine engine)
 Clear ALL forcings on ALL elements.
 

Detailed Description

Runtime forcing API — inject fluxes with mass-balance tracking.

Provides per-element runtime forcing of lateral inflows, head boundaries, rainfall, evaporation, link settings, and quality mass fluxes. Each forcing specifies:

  • mode: NONE (disabled), OVERRIDE (replace computed value), ADD (add to computed value)
  • persistence: RESET (auto-clear after each timestep), PERSIST (keep until explicitly cleared)

Forced volumes are tracked in the mass balance and reported separately via SWMM_ROUTING_FORCING.

All forcing functions require SWMM_STATE_RUNNING.

Lifecycle

while (swmm_engine_step(e, &elapsed) == SWMM_OK && elapsed > 0) {
// Set forcings for this step (or let PERSIST carry forward)
// ... step runs, forcing is applied, mass balance tracks it ...
// RESET forcings auto-clear; PERSIST forcings remain
}
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:35
@ SWMM_OK
Definition openswmm_engine.h:100
SWMM_ENGINE_API int swmm_engine_end(SWMM_Engine engine)
End the simulation → SWMM_STATE_ENDED.
Definition openswmm_engine_impl.cpp:50
SWMM_ENGINE_API int swmm_engine_start(SWMM_Engine engine, int save_results)
Start the simulation → SWMM_STATE_STARTED.
Definition openswmm_engine_impl.cpp:40
SWMM_ENGINE_API int swmm_engine_step(SWMM_Engine engine, double *elapsed_time)
Advance one explicit timestep. elapsed_time==0 when done.
Definition openswmm_engine_impl.cpp:45
@ SWMM_FORCING_ADD
Definition openswmm_forcing.h:77
@ SWMM_FORCING_PERSIST
Definition openswmm_forcing.h:83
Note
All value parameters are in the simulation's internal units (ft, sec, CFS) unless otherwise noted. Rainfall values are in user display units (in/hr for US, mm/hr for SI) — the engine converts internally.

Macro Definition Documentation

◆ SWMM_ENGINE_API

#define SWMM_ENGINE_API   __attribute__((visibility("default")))

Typedef Documentation

◆ SWMM_ForcingMode

How the forcing value is applied relative to the computed value.

◆ SWMM_ForcingPersist

Whether the forcing persists across timesteps.

◆ SWMM_ForcingType

Forcing channel identifier (for targeted clear).

Enumeration Type Documentation

◆ SWMM_ForcingMode

How the forcing value is applied relative to the computed value.

Enumerator
SWMM_FORCING_NONE 

No forcing — use model-computed value.

SWMM_FORCING_OVERRIDE 

Replace computed value with user value.

SWMM_FORCING_ADD 

Add user value to computed value.

◆ SWMM_ForcingPersist

Whether the forcing persists across timesteps.

Enumerator
SWMM_FORCING_RESET 

Auto-clear after each timestep.

SWMM_FORCING_PERSIST 

Keep until explicitly cleared.

◆ SWMM_ForcingType

Forcing channel identifier (for targeted clear).

Enumerator
SWMM_FORCE_NODE_LAT_INFLOW 
SWMM_FORCE_NODE_HEAD_BOUNDARY 
SWMM_FORCE_NODE_QUALITY 
SWMM_FORCE_LINK_FLOW 
SWMM_FORCE_LINK_SETTING 
SWMM_FORCE_SUBCATCH_RAINFALL 
SWMM_FORCE_SUBCATCH_EVAP 
SWMM_FORCE_GAGE_RAINFALL