Below is a step‐by‐step explanation of enums.h
, which defines the enumerations (i.e., sets of named integer constants) used throughout EPA SWMM5. These enumerations help the SWMM code identify everything from object types and link/node sub‐types to options, file usage types, flow classes, etc. By giving each concept a named integer constant (e.g., CONDUIT = 0
, OUTFALL = 1
), the code becomes more readable and maintainable.
1. Purpose
// enums.h
//
// Enumerated constants
enums.h
is the central place where all major SWMM named constants are declared.- Each
enum
represents a conceptual category: object types, link types, measurement units, infiltration models, etc.
1.1 Why Enumerations?
- They replace “magic numbers” with named constants, so code referencing an object type “LINK” uses
LINK
instead of a raw integer. - They ensure type safety (or at least consistent usage) in function parameters.
- They facilitate switch-case logic or array indexing by enumerated types.
2. Major Enumerations
Below is a summary of each enumerated group in enums.h
, typically sorted by conceptual group:
2.1 Object Types
enum ObjectType {
GAGE, SUBCATCH, NODE, LINK, POLLUT, LANDUSE,
TIMEPATTERN, CURVE, TSERIES, CONTROL, TRANSECT,
AQUIFER, UNITHYD, SNOWMELT, SHAPE, LID, STREET, INLET,
MAX_OBJ_TYPES
};
- Identifies major SWMM objects: e.g., a rain gage (GAGE), subcatchment (SUBCATCH), or drainage system node (NODE).
MAX_OBJ_TYPES
is not an actual object, but a sentinel indicating how many object types exist.
2.2 Node Sub‐types
enum NodeType {
JUNCTION, OUTFALL, STORAGE, DIVIDER
};
- Distinguishes types of nodes:
- JUNCTION: normal node,
- OUTFALL: boundary node where flow leaves the system,
- STORAGE: a storage unit,
- DIVIDER: splits flow in different directions.
2.3 Link Sub‐types
enum LinkType {
CONDUIT, PUMP, ORIFICE, WEIR, OUTLET
};
- Distinguishes link objects: conduit (pipe or channel), pump, orifice, weir, or outlet.
2.4 File Types & File Usage
enum FileType {
RAINFALL_FILE, RUNOFF_FILE, HOTSTART_FILE, RDII_FILE,
INFLOWS_FILE, OUTFLOWS_FILE
};
enum FileUsageType {
NO_FILE, SCRATCH_FILE, USE_FILE, SAVE_FILE
};
- SWMM can read/write various files (rainfall, runoff interface, hotstart, etc.).
- “File usage” indicates how a file is used: none, temporary scratch, using an existing file, or saving to a new file.
2.5 Cross Section and Shape Types
enum XsectType {
DUMMY, CIRCULAR, FILLED_CIRCULAR, ...
RECT_CLOSED, RECT_OPEN, TRAPEZOIDAL, ...
IRREGULAR, CUSTOM, FORCE_MAIN, STREET_XSECT
};
- Identifies shapes of cross sections (like circular pipe, trapezoidal channel, custom shape, or a street cross section).
2.6 Measurement Units
enum UnitsType {
US, SI
};
enum FlowUnitsType {
CFS, GPM, MGD, CMS, LPS, MLD
};
enum ConcUnitsType {
MG, UG, COUNT
};
- For flow, we might see CFS (cubic feet/s) or CMS (cubic meters/s).
- For concentration, we might see mg/L, ug/L, or count/L.
2.7 Runoff or Routing Computations
enum ConversionType {
RAINFALL, RAINDEPTH, EVAPRATE, LENGTH,
LANDAREA, VOLUME, WINDSPEED, TEMPERATURE,
MASS, GWFLOW, FLOW
};
- Each item indicates some quantity that might need unit conversions if switching between US and SI.
2.8 Computed Result Types
For Subcatchments:
enum SubcatchResultType {
SUBCATCH_RAINFALL, SUBCATCH_SNOWDEPTH, SUBCATCH_EVAP, ...
SUBCATCH_RUNOFF, ...
SUBCATCH_WASHOFF
};
- Summaries of subcatch results: rainfall intensity, infiltration, runoff flow rate, pollutant washoff, etc.
For Nodes:
enum NodeResultType {
NODE_DEPTH, NODE_HEAD, NODE_VOLUME,
NODE_LATFLOW, NODE_INFLOW, NODE_OVERFLOW, NODE_QUAL
};
- E.g. water depth, hydraulic head, volume, etc.
For Links:
enum LinkResultType {
LINK_FLOW, LINK_DEPTH, LINK_VELOCITY, LINK_VOLUME, LINK_CAPACITY, LINK_QUAL
};
- E.g. flow, depth, velocity, volume in pipe, capacity ratio, etc.
For System‐wide:
enum SysFlowType {
SYS_TEMPERATURE, SYS_RAINFALL, SYS_SNOWDEPTH,
SYS_INFIL, SYS_RUNOFF, SYS_DWFLOW, ...
SYS_STORAGE, SYS_EVAP, SYS_PET
};
- Summaries for the entire system: e.g., total infiltration, total runoff, total outflow, etc.
2.9 Conduit Flow Classification
enum FlowClassType {
DRY, UP_DRY, DN_DRY, SUBCRITICAL, SUPCRITICAL,
UP_CRITICAL, DN_CRITICAL, MAX_FLOW_CLASSES,
UP_FULL, DN_FULL, ALL_FULL
};
- SWMM classifies a conduit’s flow state at each time step: is it dry, subcritical, supercritical, or surcharged? This helps shape the solver’s approach.
2.10 Additional Enumerations
RunoffFlowType
andLoadingType
describe mass balance flow categories or pollutant loading categories (build up, washoff, infiltration load, etc.).RainfallType
,TempType
,WindType
,EvapType
: how precipitation, temperature, wind, or evaporation data are provided (time series, file, monthly, etc.).RouteModelType
enumerates routing methods: none, steady flow, kin wave, dynamic wave, etc.ForceMainType
: Darcy-Weisbach or Hazen-Williams for force mains.OffsetType
: depth offset vs elevation offset for node inverts.InertialDampingType
: how inertial terms are damped in dynamic wave calculations.SurchargeMethodType
: EXTRAN vs Preissmann slot method for node surcharging.InflowType
,PatternType
,OutfallType
,StorageType
,ReactorType
,TreatmentType
,DividerType
,PumpCurveType
,OrificeType
,WeirType
,CurveType
,NodeInletType
: each enumerates specialized sub‐types or sub‐options for certain objects.
2.11 Input Section Types
enum InputSectionType {
s_TITLE, s_OPTION, s_FILE, s_RAINGAGE, ... s_INLET
};
- Identifies lines in the SWMM input file by which section they belong to (like
[TITLE]
,[OPTIONS]
,[RAINGAGE]
,[MAP]
, etc.).
2.12 Additional Options
enum InputOptionType {
FLOW_UNITS, INFIL_MODEL, ROUTE_MODEL, ...
MIN_ROUTE_STEP, NUM_THREADS, SURCHARGE_METHOD
};
- Lists all the possible [OPTIONS] keys that can appear in the SWMM input file.
- E.g.
FLOW_UNITS
sets units system,NUM_THREADS
sets # of threads for parallel logic, etc.
2.13 Generic Yes/No or All/None
enum NoYesType { NO, YES };
enum NoneAllType { NONE, ALL, SOME };
- Basic enumerations used to interpret “YES/NO” or “ALL/NONE/SOME” type flags.
3. Usage in SWMM
- Throughout SWMM: these enumerations are used in switch‐cases or function parameters. For example, to check if a node is of type
OUTFALL
, or to store the method used for infiltration as an integer fromRouteModelType
. - Compatibility: enumerations also help keep track of older SWMM versions or new features (like
STREET
orINLET
). - Extendability: If new object or method types appear, they can be added to
enums.h
without changing unrelated parts of the code.
4. Key Takeaways
enums.h
is the master dictionary of SWMM’s enumerated constants.- Each enumerated group covers a domain of related categories (e.g., Link sub‐types, infiltration models, flow routing types).
- This central approach ensures consistent usage of numeric IDs across the entire SWMM codebase, supporting clear and maintainable code.
No comments:
Post a Comment