OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
ApiGwTransport.cpp File Reference

U4 — implementation of openswmm_gw_transport.h. More...

#include <openswmm/engine/openswmm_engine.h>
#include <openswmm/engine/openswmm_gw_transport.h>
#include "../../core/SWMMEngine.hpp"
#include "../gw/GwTransportSections.hpp"
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
Include dependency graph for ApiGwTransport.cpp:

Macros

#define GW_GET(engine)
 
#define GW_EDITABLE(eng)
 

Functions

SWMM_ENGINE_API int swmm_gw_transport_option_get (SWMM_Engine engine, const char *key, char *buf, int buflen)
 Read one option into buf. SWMM_ERR_BADPARAM on an unknown key.
 
SWMM_ENGINE_API int swmm_gw_transport_option_set (SWMM_Engine engine, const char *key, const char *value)
 Set one option (BUILDING/OPENED).
 
SWMM_ENGINE_API int swmm_gw_transport_authored (SWMM_Engine engine)
 1 when any [GW_*] row was authored, else 0.
 
SWMM_ENGINE_API int swmm_gw_params_count (SWMM_Engine engine)
 
SWMM_ENGINE_API int swmm_gw_params_get (SWMM_Engine engine, int idx, SWMM_GwParams *row, char *tag_buf, int tag_len)
 Read row idx; tag_buf receives the TAG (empty otherwise).
 
SWMM_ENGINE_API int swmm_gw_params_set (SWMM_Engine engine, const SWMM_GwParams *row, const char *tag)
 Append or replace the row for (scope, tag/cell).
 
SWMM_ENGINE_API int swmm_gw_params_remove (SWMM_Engine engine, int idx)
 
SWMM_ENGINE_API int swmm_gw_sorption_count (SWMM_Engine engine)
 
SWMM_ENGINE_API int swmm_gw_sorption_get (SWMM_Engine engine, int idx, int *scope, char *tag_buf, int tag_len, int *cell, char *species_buf, int species_len, double *kd, double *decay)
 
SWMM_ENGINE_API int swmm_gw_sorption_set (SWMM_Engine engine, int scope, const char *tag, int cell, const char *species, double kd, double decay)
 
SWMM_ENGINE_API int swmm_gw_sorption_remove (SWMM_Engine engine, int idx)
 
SWMM_ENGINE_API int swmm_gw_init_quality_count (SWMM_Engine engine)
 
SWMM_ENGINE_API int swmm_gw_init_quality_get (SWMM_Engine engine, int idx, int *scope, char *tag_buf, int tag_len, int *cell, int *zone, int *layer, char *species_buf, int species_len, double *value)
 
SWMM_ENGINE_API int swmm_gw_init_quality_set (SWMM_Engine engine, int scope, const char *tag, int cell, int zone, int layer, const char *species, double value)
 
SWMM_ENGINE_API int swmm_gw_init_quality_remove (SWMM_Engine engine, int idx)
 
SWMM_ENGINE_API int swmm_gw_init_quality_file_get (SWMM_Engine engine, char *buf, int buflen)
 The FILE <csv> sidecar reference ("" when none).
 
SWMM_ENGINE_API int swmm_gw_init_quality_file_set (SWMM_Engine engine, const char *path)
 
SWMM_ENGINE_API int swmm_gw_boundary_quality_count (SWMM_Engine engine)
 
SWMM_ENGINE_API int swmm_gw_boundary_quality_get (SWMM_Engine engine, int idx, int *cell, int *edge, char *species_buf, int species_len, char *kind_buf, int kind_len, double *value, char *ts_buf, int ts_len)
 
SWMM_ENGINE_API int swmm_gw_boundary_quality_set (SWMM_Engine engine, int cell, int edge, const char *species, const char *kind, double value, const char *ts_name)
 
SWMM_ENGINE_API int swmm_gw_boundary_quality_remove (SWMM_Engine engine, int idx)
 
SWMM_ENGINE_API int swmm_gw_source_count (SWMM_Engine engine)
 
SWMM_ENGINE_API int swmm_gw_source_get (SWMM_Engine engine, int idx, char *name_buf, int name_len, int *scope, char *tag_buf, int tag_len, int *cell, double *flow, char *flow_ts_buf, int flow_ts_len)
 
SWMM_ENGINE_API int swmm_gw_source_set (SWMM_Engine engine, const char *name, int scope, const char *tag, int cell, double flow, const char *flow_ts)
 Append or replace the source named name.
 
SWMM_ENGINE_API int swmm_gw_source_remove (SWMM_Engine engine, int idx)
 
SWMM_ENGINE_API int swmm_gw_source_species_count (SWMM_Engine engine, int src_idx)
 Species terms carried by source src_idx.
 
SWMM_ENGINE_API int swmm_gw_source_species_get (SWMM_Engine engine, int src_idx, int term_idx, char *species_buf, int species_len, char *kind_buf, int kind_len, double *value, char *ts_buf, int ts_len)
 
SWMM_ENGINE_API int swmm_gw_source_species_set (SWMM_Engine engine, int src_idx, const char *species, const char *kind, double value, const char *ts_name)
 
SWMM_ENGINE_API int swmm_gw_source_species_remove (SWMM_Engine engine, int src_idx, int term_idx)
 

Detailed Description

U4 — implementation of openswmm_gw_transport.h.

Every setter parses through the SAME line parsers the .inp sections use, so the API and the file can never drift: an option the file refuses the API refuses, with the same message shape. The rows live on SurfaceRouter2D (via ctx.twod_io.gw), so a save re-emits exactly what the API wrote.

Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
License\n Apache-2.0

Macro Definition Documentation

◆ GW_EDITABLE

#define GW_EDITABLE ( eng)
Value:
if (eng->context().state != openswmm::EngineState::OPENED && \
eng->context().state != openswmm::EngineState::BUILDING) \
@ BUILDING
Programmatic model construction in progress (no .inp)
Definition SimulationContext.hpp:271
@ OPENED
Input file parsed, objects allocated.
Definition SimulationContext.hpp:263
@ SWMM_ERR_LIFECYCLE
Definition openswmm_engine.h:123

◆ GW_GET

#define GW_GET ( engine)
Value:
auto* eng = reinterpret_cast<openswmm::SWMMEngine*>(engine); \
if (!eng) return SWMM_ERR_BADHANDLE; \
GwTransportData& gw = eng->surfaceRouter2D().gwTransport()
@ SWMM_ERR_BADHANDLE
Definition openswmm_engine.h:124

Function Documentation

◆ swmm_gw_boundary_quality_count()

SWMM_ENGINE_API int swmm_gw_boundary_quality_count ( SWMM_Engine engine)

◆ swmm_gw_boundary_quality_get()

SWMM_ENGINE_API int swmm_gw_boundary_quality_get ( SWMM_Engine engine,
int idx,
int * cell,
int * edge,
char * species_buf,
int species_len,
char * kind_buf,
int kind_len,
double * value,
char * ts_buf,
int ts_len )

◆ swmm_gw_boundary_quality_remove()

SWMM_ENGINE_API int swmm_gw_boundary_quality_remove ( SWMM_Engine engine,
int idx )

◆ swmm_gw_boundary_quality_set()

SWMM_ENGINE_API int swmm_gw_boundary_quality_set ( SWMM_Engine engine,
int cell,
int edge,
const char * species,
const char * kind,
double value,
const char * ts_name )
Parameters
edgeLOCAL edge 0..nv-1 of cell (3 for a triangle, 4 for a quad).

◆ swmm_gw_init_quality_count()

SWMM_ENGINE_API int swmm_gw_init_quality_count ( SWMM_Engine engine)

◆ swmm_gw_init_quality_file_get()

SWMM_ENGINE_API int swmm_gw_init_quality_file_get ( SWMM_Engine engine,
char * buf,
int buflen )

The FILE <csv> sidecar reference ("" when none).

◆ swmm_gw_init_quality_file_set()

SWMM_ENGINE_API int swmm_gw_init_quality_file_set ( SWMM_Engine engine,
const char * path )

◆ swmm_gw_init_quality_get()

SWMM_ENGINE_API int swmm_gw_init_quality_get ( SWMM_Engine engine,
int idx,
int * scope,
char * tag_buf,
int tag_len,
int * cell,
int * zone,
int * layer,
char * species_buf,
int species_len,
double * value )
Parameters
layer1-based, meaningful only when zone is SWMM_GW_ZONE_LAYER.

◆ swmm_gw_init_quality_remove()

SWMM_ENGINE_API int swmm_gw_init_quality_remove ( SWMM_Engine engine,
int idx )

◆ swmm_gw_init_quality_set()

SWMM_ENGINE_API int swmm_gw_init_quality_set ( SWMM_Engine engine,
int scope,
const char * tag,
int cell,
int zone,
int layer,
const char * species,
double value )

◆ swmm_gw_params_count()

SWMM_ENGINE_API int swmm_gw_params_count ( SWMM_Engine engine)

◆ swmm_gw_params_get()

SWMM_ENGINE_API int swmm_gw_params_get ( SWMM_Engine engine,
int idx,
SWMM_GwParams * row,
char * tag_buf,
int tag_len )

Read row idx; tag_buf receives the TAG (empty otherwise).

◆ swmm_gw_params_remove()

SWMM_ENGINE_API int swmm_gw_params_remove ( SWMM_Engine engine,
int idx )

◆ swmm_gw_params_set()

SWMM_ENGINE_API int swmm_gw_params_set ( SWMM_Engine engine,
const SWMM_GwParams * row,
const char * tag )

Append or replace the row for (scope, tag/cell).

◆ swmm_gw_sorption_count()

SWMM_ENGINE_API int swmm_gw_sorption_count ( SWMM_Engine engine)

◆ swmm_gw_sorption_get()

SWMM_ENGINE_API int swmm_gw_sorption_get ( SWMM_Engine engine,
int idx,
int * scope,
char * tag_buf,
int tag_len,
int * cell,
char * species_buf,
int species_len,
double * kd,
double * decay )
Parameters
decay1/day; negative means "use the [POLLUTANTS] kdecay".

◆ swmm_gw_sorption_remove()

SWMM_ENGINE_API int swmm_gw_sorption_remove ( SWMM_Engine engine,
int idx )

◆ swmm_gw_sorption_set()

SWMM_ENGINE_API int swmm_gw_sorption_set ( SWMM_Engine engine,
int scope,
const char * tag,
int cell,
const char * species,
double kd,
double decay )

◆ swmm_gw_source_count()

SWMM_ENGINE_API int swmm_gw_source_count ( SWMM_Engine engine)

◆ swmm_gw_source_get()

SWMM_ENGINE_API int swmm_gw_source_get ( SWMM_Engine engine,
int idx,
char * name_buf,
int name_len,
int * scope,
char * tag_buf,
int tag_len,
int * cell,
double * flow,
char * flow_ts_buf,
int flow_ts_len )

◆ swmm_gw_source_remove()

SWMM_ENGINE_API int swmm_gw_source_remove ( SWMM_Engine engine,
int idx )

◆ swmm_gw_source_set()

SWMM_ENGINE_API int swmm_gw_source_set ( SWMM_Engine engine,
const char * name,
int scope,
const char * tag,
int cell,
double flow,
const char * flow_ts )

Append or replace the source named name.

◆ swmm_gw_source_species_count()

SWMM_ENGINE_API int swmm_gw_source_species_count ( SWMM_Engine engine,
int src_idx )

Species terms carried by source src_idx.

◆ swmm_gw_source_species_get()

SWMM_ENGINE_API int swmm_gw_source_species_get ( SWMM_Engine engine,
int src_idx,
int term_idx,
char * species_buf,
int species_len,
char * kind_buf,
int kind_len,
double * value,
char * ts_buf,
int ts_len )

◆ swmm_gw_source_species_remove()

SWMM_ENGINE_API int swmm_gw_source_species_remove ( SWMM_Engine engine,
int src_idx,
int term_idx )

◆ swmm_gw_source_species_set()

SWMM_ENGINE_API int swmm_gw_source_species_set ( SWMM_Engine engine,
int src_idx,
const char * species,
const char * kind,
double value,
const char * ts_name )
Parameters
kind"CONC" or "MASS". Upserts on the species name.

◆ swmm_gw_transport_authored()

SWMM_ENGINE_API int swmm_gw_transport_authored ( SWMM_Engine engine)

1 when any [GW_*] row was authored, else 0.

◆ swmm_gw_transport_option_get()

SWMM_ENGINE_API int swmm_gw_transport_option_get ( SWMM_Engine engine,
const char * key,
char * buf,
int buflen )

Read one option into buf. SWMM_ERR_BADPARAM on an unknown key.

◆ swmm_gw_transport_option_set()

SWMM_ENGINE_API int swmm_gw_transport_option_set ( SWMM_Engine engine,
const char * key,
const char * value )

Set one option (BUILDING/OPENED).

Here is the call graph for this function: