OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
LidNode.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 Caleb Buahin
3
12
13#ifndef OPENSWMM_LID_NODE_HPP
14#define OPENSWMM_LID_NODE_HPP
16#include <string>
17namespace openswmm {
19namespace lidnode {
27bool richardsMode(const SimulationContext& ctx, int node);
35LidNodeBottom bottomMode(const SimulationContext& c, int node);
56double exchangeRichardsPorts(SimulationContext& ctx, int link, double flow, double dt);
73void prepareRichardsStep(SimulationContext& ctx, double dt, double evaporation,
74 bool mesh_prepared = false);
88void refreshRichardsState(SimulationContext& ctx, int row);
103void readRichards(SimulationContext& ctx, const std::vector<std::string>& lines);
118std::vector<LidNodeLayer> layers(const SimulationContext& ctx, int control);
131bool validLayer(const LidNodeLayer& l);
143std::string validateStack(const std::vector<LidNodeLayer>& stack);
150double thickness(const std::vector<LidNodeLayer>& stack);
151// Validate references, layer stacks, MaxDepth and anchored offsets. Authored
152// layer units remain unchanged; node/link values are canonical internal units.
165void validate(SimulationContext& ctx);
179void sync(SimulationContext& ctx, int control);
194void initialize(SimulationContext& ctx);
195// Reconstruct infiltration history from current physical moisture when loading
196// a pre-V10 hot start. Exact continuation requires V10 history.
210void initializeInfiltration(SimulationContext& ctx, int node);
228void prepareStep(SimulationContext& ctx, double dt, double evaporation);
229// Internal mixed-mode preparation after all Mesh columns share an accepted interval.
243void prepareStepAfterMesh(SimulationContext& ctx, double dt, double evaporation);
257void finishStep(SimulationContext& ctx);
258// Internal Mesh cohort boundary. Every connected Mesh endpoint must belong to
259// the same accepted interval/cohort. Other LID rows and GW clocks are untouched.
275void finishRichardsNodes(SimulationContext& ctx, double start, double end,
276 const std::vector<int>& nodes);
277// Global routing preflight, before loss/flow/Picard mutation. Returns whether
278// Mesh owners are present; all must have accepted the current routing interval.
291bool validateRichardsRouting(const SimulationContext& ctx, double dt);
303void resetPorts(SimulationContext& ctx);
316double portOffset(const SimulationContext& ctx, int link, int node);
317// Physical interfaces belong to the cell above, allowing only roundoff-sized
318// elevation differences. Shared by hydraulic and pollutant port coupling.
331int portCell(const LidNodeState& state, double offset);
345double portDepth(const SimulationContext& ctx, int node, double offset);
365double exchangePorts(SimulationContext& ctx, int link, double flow, double dt);
378double bottomConductivity(const SimulationContext& c, int storage_row);
390double bottomCloggingFactor(const SimulationContext& c, int storage_row);
402double heldVolume(const SimulationContext& ctx, int node);
412bool active(const SimulationContext& ctx, int node);
427bool validTreatment(const SimulationContext& ctx, const LidLayerTreatment& rule,
428 std::string& error);
442void readTreatment(SimulationContext& ctx, const std::vector<std::string>& lines);
460void prepareQuality(SimulationContext& ctx, double dt);
477void prepareOutletQuality(SimulationContext& ctx, double dt, bool book_reaction);
498bool receiveQuality(SimulationContext& ctx, int node, int link, double volume, int pollutant,
499 double mass, double dt);
514double outletQuality(const SimulationContext& ctx, int node, int link, int pollutant,
515 double fallback);
528double heldMass(const SimulationContext& ctx, int node, int pollutant);
542void readNodes(SimulationContext& ctx, const std::vector<std::string>& lines);
556void readOutlets(SimulationContext& ctx, const std::vector<std::string>& lines);
557} // namespace lidnode
558} // namespace openswmm
559#endif
Data-oriented storage for LID node layers, properties, and state.
Definition LidNode.cpp:25
void prepareOutletQuality(SimulationContext &ctx, double dt, bool book_reaction)
Refresh mobile outlet treatment against the current coupled node mixture.
Definition LidNodeTreatment.cpp:364
double portOffset(const SimulationContext &ctx, int link, int node)
Resolve the actual hydraulic port elevation relative to a selected node invert.
Definition LidNode.cpp:258
double bottomConductivity(const SimulationContext &c, int r)
Select the authored conductivity driving native storage bottom exfiltration.
Definition LidNode.cpp:980
void prepareQuality(SimulationContext &ctx, double dt)
Apply accepted LID vertical/retained-port transfers and resident decay to pollutant mass.
Definition LidNodeTreatment.cpp:178
bool receiveQuality(SimulationContext &ctx, int node, int link, double volume, int pollutant, double mass, double dt)
Divert the retained fraction of an arriving pollutant load into its LID port cell.
Definition LidNodeTreatment.cpp:412
bool validateRichardsRouting(const SimulationContext &ctx, double dt)
Preflight the common accepted Mesh Richards routing interval without mutation.
Definition LidNodeRichards.cpp:335
double exchangePorts(SimulationContext &ctx, int link, double flow, double dt)
Limit and book one trial link transfer through LID mobile/retained ports.
Definition LidNode.cpp:1051
void readTreatment(SimulationContext &ctx, const std::vector< std::string > &lines)
Parse authored node-LID layer treatment rows.
Definition LidNodeTreatment.cpp:46
void sync(SimulationContext &ctx, int control)
Synchronize dependent storage depth and authored outlet anchors after a control edit.
Definition LidNode.cpp:356
void prepareStep(SimulationContext &ctx, double dt, double evaporation)
Prepare one node-LID moisture/routing interval before hydraulic mutation.
Definition LidNode.cpp:912
void readRichards(SimulationContext &ctx, const std::vector< std::string > &lines)
Parse node-LID Richards numerical options and layer retention/storage materials.
Definition LidNodeRichards.cpp:129
void refreshRichardsState(SimulationContext &ctx, int row)
Recompute one initialized Richards row pressure, moisture and retained inventory.
Definition LidNodeRichards.cpp:205
double bottomCloggingFactor(const SimulationContext &c, int r)
Evaluate the node-LID bottom clogging multiplier from cumulative treated water.
Definition LidNode.cpp:993
void readNodes(SimulationContext &ctx, const std::vector< std::string > &lines)
Parse LID storage-node assignments and bottom-boundary modes.
Definition LidNode.cpp:193
double exchangeRichardsPorts(SimulationContext &ctx, int link, double flow, double dt)
Limit and book a link transfer involving Richards or mixed retained-water ports.
Definition LidNodeRichards.cpp:33
void initializeInfiltration(SimulationContext &ctx, int node)
Initialize/reconstruct node-LID surface Green-Ampt history from physical moisture.
Definition LidNode.cpp:490
std::vector< LidNodeLayer > layers(const SimulationContext &ctx, int control)
Copy an authored node layer stack or adapt a supported conventional LID control.
Definition LidNode.cpp:102
int portCell(const LidNodeState &state, double offset)
Map a hydraulic port offset to a physical LID cell with stable interface ownership.
Definition LidNode.cpp:1012
bool validLayer(const LidNodeLayer &l)
Check one authored node-layer material record.
Definition LidNode.cpp:134
std::string validateStack(const std::vector< LidNodeLayer > &stack)
Validate layer material/order and optional Richards requirements.
Definition LidNode.cpp:157
void initialize(SimulationContext &ctx)
Build node-LID hydraulic cells and initial retained/mobile water state.
Definition LidNode.cpp:517
bool active(const SimulationContext &ctx, int node)
Check whether a node has initialized physical LID cells.
Definition LidNode.cpp:398
double heldVolume(const SimulationContext &ctx, int node)
Read retained node-LID water outside the mobile hydraulic volume.
Definition LidNode.cpp:402
void resetPorts(SimulationContext &ctx)
Clear trial port-transfer accumulators before a fresh hydraulic iteration.
Definition LidNode.cpp:1026
bool richardsMode(const SimulationContext &ctx, int node)
Read the initialized LID Richards mode flag for a node.
Definition LidNodeRichards.cpp:29
void validate(SimulationContext &ctx)
Validate node-LID model references, layers, supported physics and anchored geometry.
Definition LidNode.cpp:271
void readOutlets(SimulationContext &ctx, const std::vector< std::string > &lines)
Parse hydraulic outlet anchors to numbered LID layer interfaces.
Definition LidNode.cpp:231
double portDepth(const SimulationContext &ctx, int node, double offset)
Read the port hydraulic head as a node-relative depth.
Definition LidNode.cpp:1037
bool validTreatment(const SimulationContext &ctx, const LidLayerTreatment &rule, std::string &error)
Validate a layer pollutant rule and optional legacy treatment expression.
Definition LidNodeTreatment.cpp:23
double outletQuality(const SimulationContext &ctx, int node, int link, int pollutant, double fallback)
Read a cached treated outlet concentration with a caller fallback.
Definition LidNodeTreatment.cpp:429
void finishStep(SimulationContext &ctx)
Finish all node-LID port transfers at a common accepted boundary.
Definition LidNode.cpp:920
void prepareRichardsStep(SimulationContext &ctx, double dt, double evaporation, bool mesh_prepared=false)
Advance non-Mesh Richards owners privately, then publish the whole successful batch.
Definition LidNodeRichards.cpp:358
double thickness(const std::vector< LidNodeLayer > &stack)
Sum all physical layer thicknesses while excluding the bottom boundary record.
Definition LidNode.cpp:186
double heldMass(const SimulationContext &ctx, int node, int pollutant)
Sum retained pollutant inventory across all initialized LID cells.
Definition LidNodeTreatment.cpp:438
void finishRichardsNodes(SimulationContext &ctx, double start, double end, const std::vector< int > &nodes)
Finish exactly one connected accepted Mesh Richards owner cohort.
Definition LidNode.cpp:936
LidNodeBottom bottomMode(const SimulationContext &c, int node)
Read the assigned bottom-boundary policy for a node.
Definition LidNode.cpp:972
void prepareStepAfterMesh(SimulationContext &ctx, double dt, double evaporation)
Prepare mixed-mode LID rows after Mesh Richards owners accepted this interval.
Definition LidNode.cpp:915
Definition ExchangeLaw.hpp:60
LidNodeBottom
Definition LidNodeData.hpp:90
Central, reentrant simulation context.
Definition SimulationContext.hpp:390