OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm::inp_writer Namespace Reference

Classes

struct  InpWriteOptions
 Write profile: which engine the file is written for. More...
 

Functions

std::string groundwaterSections (const SimulationContext &ctx)
 Render the authored groundwater chemistry/aquifer reactor sections as text.
 
int writeInpFile (const SimulationContext &ctx, const std::string &path, std::vector< std::string > *warnings=nullptr)
 Write the full model to a SWMM .inp file.
 
int writeInpFile (const SimulationContext &ctx_internal, const std::string &path, std::vector< std::string > *warnings, const InpWriteOptions &opts)
 Write a complete model with explicit native or SWMM5 export options.
 
std::string modelText (const SimulationContext &ctx, const std::string &anchor, bool internal_units)
 

Function Documentation

◆ groundwaterSections()

std::string openswmm::inp_writer::groundwaterSections ( const SimulationContext & ctx)

Render the authored groundwater chemistry/aquifer reactor sections as text.

Uses a temporary FILE to reuse emitGwTransportSections; runtime_error on temporary-file/write/read failure. Does not install output, advance state or rebase the retained FILE reference; allocation can throw.

Parameters
[in]ctxBorrowed model with live optional twod_io groundwater attachment and coherent authored rows.
Returns
Owned serialized section text; empty without a 2D build or configured data.
Here is the caller graph for this function:

◆ modelText()

std::string openswmm::inp_writer::modelText ( const SimulationContext & ctx,
const std::string & anchor,
bool internal_units )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeInpFile() [1/2]

int openswmm::inp_writer::writeInpFile ( const SimulationContext & ctx,
const std::string & path,
std::vector< std::string > * warnings = nullptr )

Write the full model to a SWMM .inp file.

Sections written (in order): [TITLE], [OPTIONS], [EVAPORATION], [TEMPERATURE], [SNOWPACKS], [ADJUSTMENTS], [RAINGAGES], [SUBCATCHMENTS], [SUBAREAS], [INFILTRATION], [JUNCTIONS], [OUTFALLS], [STORAGE], [DIVIDERS], [CONDUITS], [PUMPS], [ORIFICES], [WEIRS], [OUTLETS], [XSECTIONS], [TRANSECTS], [LOSSES], [CONTROLS], [REPORT], [INFLOWS], [DWF], [RDII], [POLLUTANTS], [LANDUSES], [BUILDUP], [WASHOFF], [TREATMENT], [TIMESERIES], [CURVES], [PATTERNS], [USER_FLAGS], [PLUGINS], [MAP], [COORDINATES], [VERTICES], [Polygons], [SYMBOLS]

Slice IO-4: every external-file path slot ([FILES], [RAINGAGES] FILE, [TIMESERIES] FILE, [TEMPERATURE] FILE, etc.) is emitted relative to the destination directory by default. Set ctx.options.write_absolute_paths = true to disable rebasing. Slots that cannot be expressed relatively (cross-volume on Windows, UNC roots, beyond the depth cap) fall back to absolute form and append a human-readable explanation to warnings when that vector is non-null.

Parameters
ctxSimulation context with all model data.
pathOutput file path.
warningsOptional sink for non-fatal portability warnings (cross-volume slots, etc.). Pass nullptr to discard.

Main INP, engine-owned mesh and written component configs use adjacent temporary files, checked write/flush/sync/close, and individual atomic replacement. Errors are returned and described in warnings when supplied. This is not a multi-file transaction: a later main-file failure does not roll back an already-published mesh or component configuration. Output redirection/recovery remain caller concerns.

Returns
0 on success, -1 on file error.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeInpFile() [2/2]

int openswmm::inp_writer::writeInpFile ( const SimulationContext & ctx_internal,
const std::string & path,
std::vector< std::string > * warnings,
const InpWriteOptions & opts )

Write a complete model with explicit native or SWMM5 export options.

Converts a local context copy back to display/authored representation as needed, leaving the live model unchanged. Writes main/mesh/component files via individual AtomicOutputFile commits; a later failure does not roll back earlier sidecar publication. Maps legacy-incompatible features according to profile; rejects UEB/mesh snow rather than silently replacing physics. Allocation, callback and serializer exceptions can propagate.

Parameters
[in]ctx_internalBorrowed coherent model in its current authored/resolved unit/orientation state; valid flow_units and aligned names/arrays required.
[in]pathUTF-8 final INP destination, also the path-rebasing anchor.
[in,out]warningsOptional append-only portability, profile-substitution and IO diagnostics; NULL discards them.
[in]optsExport profile and optional physical staging callback; caller owns mapped staging cleanup/publication.
Returns
0 after successful main commit, -1 for most handled IO/profile failures. Current mesh-snow SWMM5 refusal also returns false (integer zero) before writing, so inspect warnings/output for that case.