36#ifndef OPENSWMM_ROUTING_HPP
37#define OPENSWMM_ROUTING_HPP
261 dw_solver_.setNumThreads(n, warnings);
366 const std::string&
fvBackend()
const {
return fv_backend_; }
375 const std::vector<std::string>&
fvWarnings()
const {
return fv_warnings_; }
384 const std::vector<std::string>&
fvErrors()
const {
return fv_errors_; }
404 std::string checkpointBytes(
const SimulationContext& c, std::string& result)
const;
426 std::shared_ptr<RestartState>
428 const std::array<double, 6>* boundary =
nullptr,
429 const double* delivery =
nullptr,
442 static void validateJointDelivery(
const NodeData& nodes,
const std::vector<uint8_t>& coupled,
457 static void validateSessionStorage(
const std::shared_ptr<RestartState>& s,
471 void installCheckpoint(
SimulationContext& c, std::shared_ptr<RestartState> s)
noexcept;
473 bool checkpoint_owned_session_ =
false;
474 bool checkpoint_aquifer_session_ =
476 std::string checkpoint_model_;
477 double checkpoint_time_ = 0.0, checkpoint_step_end_ = 0.0;
478 bool checkpoint_ready_ =
false, checkpoint_prepared_ =
false, checkpoint_step_finished_ =
false;
520 void checkCheckpointStep(
SimulationContext& ctx,
double dt,
double evap_rate,
bool callback,
521 bool owned_callback =
false);
555 std::vector<char> steady_storage_updated_;
558 std::vector<double> steady_y_;
567 std::unique_ptr<fv::INetworkSolver> fv_solver_;
568 std::string fv_backend_;
569 std::vector<std::string> fv_warnings_, fv_errors_;
574 bool lstep_enabled_ =
false;
575 double lstep_rs_ = 0.0;
576 std::vector<double> lstep_pmin_, lstep_pmax_, lstep_pdt_time_, lstep_ptime_, lstep_pbin_;
589 static void fvStepSink(
void* user,
int conduit,
double dt,
double dur);
592 std::vector<double> fv_lateral_, fv_fixed_head_, fv_struct_flow_, fv_cond_loss_;
598 std::vector<double> fv_link_q_cap_;
605 std::vector<double> fv_struct_int_;
606 double fv_struct_t_prev_ = 0.0;
664 std::vector<int> steady_sorted_links_;
665 bool cycle_detected_ =
false;
718 const std::function<
void()>& eval_structures);
Flow divider node logic — cutoff, overflow, tabular, weir.
Dynamic wave routing solver — batch-oriented St. Venant equations.
Option struct for the explicit finite-volume 1D network solver.
Backend-neutral interface for the explicit FV 1D network integrator.
Kinematic wave routing solver — batch-oriented design.
SoA storage for the 1D finite-volume network mesh and its state.
Cross-section geometry — unified batch + per-element API.
Top-level routing orchestrator.
Definition Routing.hpp:101
void enableCheckpointing(SimulationContext &ctx)
Attach the internal accepted-boundary hydraulic checkpoint profile at initial time.
Definition RoutingCheckpoint.cpp:1106
std::string saveCheckpoint(const SimulationContext &ctx, const std::string &path) const
Serialize and publish an accepted internal hydraulic checkpoint file.
Definition RoutingCheckpoint.cpp:1188
double getAdaptiveStep(SimulationContext &ctx, double fixed_step, double courant)
Select an outer routing interval from the active model telemetry.
Definition Routing.cpp:677
friend class SWMMEngine
Definition Routing.hpp:388
std::unique_ptr< Router > privateDynamicWaveWindow() const
Create private DW numerical history/group scratch for a restricted internal routing trial.
Definition Routing.cpp:544
const fv::INetworkSolver * fvSolver() const
Borrow the currently owned FV backend interface.
Definition Routing.hpp:360
void accumulateLinkStepStats(SimulationContext &ctx, double dt, bool in_window)
Keep or discard the just-completed interval conduit-step report samples.
Definition Routing.cpp:751
void publishDynamicWaveWindow(Router &r) noexcept
Exchange accepted private DW history and grouped scratch into this router.
Definition Routing.cpp:563
void beginCheckpointStep(SimulationContext &ctx, double dt)
Reserve the next chronological tracked routing boundary before preparation mutates state.
Definition RoutingCheckpoint.cpp:1119
void acceptCheckpointBoundary(SimulationContext &ctx)
Validate and accept a fully postprocessed tracked step at its advanced clock.
Definition RoutingCheckpoint.cpp:1149
void setStructureSolver(hydstruct::StructureSolver *s)
Attach the borrowed structure-equation provider for tree routing.
Definition Routing.hpp:277
void setDWNumThreads(int n, std::vector< std::string > *warnings=nullptr)
Configure the owned dynamic-wave solver worker count.
Definition Routing.hpp:260
dynwave::DWSolver & dwSolver()
Access the DW solver (for non-conduit node state scatter).
Definition Routing.hpp:265
bool enableLinkStepStats(SimulationContext &ctx)
Enable conduit-step reporting when the selected solver can provide it.
Definition Routing.cpp:713
const XSectGroups & xsectGroups() const
Access the shape-grouped xsect manager.
Definition Routing.hpp:241
const std::vector< std::string > & fvErrors() const
Borrow accumulated FV mesh initialization errors.
Definition Routing.hpp:384
void init(SimulationContext &ctx, RouteModel model)
Initialize routing groups, solver state and the selected model dispatch.
Definition Routing.cpp:323
const fv::NetworkMeshData & fvMesh() const
The FV mesh built at init (empty unless FLOW_ROUTING FV).
Definition Routing.hpp:363
bool hasCycle() const
Report the topological cycle diagnostic from the most recent initialization.
Definition Routing.hpp:248
bool lastStepConverged() const
Report the selected routing model legacy convergence statistic.
Definition Routing.hpp:314
int step(SimulationContext &ctx, double dt, double evap_rate=0.0, dynwave::DWSolver::NonConduitFlowFunc non_conduit_fn=nullptr)
Definition Routing.cpp:539
bool linkStepStatsEnabled() const
Whether enableLinkStepStats() succeeded.
Definition Routing.hpp:334
std::string loadCheckpoint(SimulationContext &ctx, const std::string &path)
Validate a stored hydraulic checkpoint privately, then install its selected state.
Definition RoutingCheckpoint.cpp:1298
void acceptedQualityWater(const SimulationContext &ctx, double dt, quality::FvTransportWater &out) const
Dispatch one prepared hydraulic routing interval and publish its current state.
Definition Routing.cpp:2254
const std::string & fvBackend() const
Backend label chosen by the FV factory ("cpu (...)", "omp (...)", ...).
Definition Routing.hpp:366
const std::vector< std::string > & fvWarnings() const
Borrow accumulated FV initialization warnings.
Definition Routing.hpp:375
void restoreFvClassicState(SimulationContext &ctx)
Definition Routing.cpp:2333
Shape-grouped cross-section manager for batch computation.
Definition XSectBatch.hpp:447
Dynamic wave solver — operates on entire link/node system.
Definition DynamicWave.hpp:218
std::function< void(SimulationContext &, double, int)> NonConduitFlowFunc
Definition DynamicWave.hpp:258
Abstract time integrator for the explicit FV 1D network.
Definition INetworkSolver.hpp:135
Definition HydStructures.hpp:201
Kinematic wave solver state.
Definition KinematicWave.hpp:176
Top-level orchestrator for the 2D surface routing module.
Definition SurfaceRouter2D.hpp:86
EXTERN int RouteModel
Definition globals.h:82
Definition ExchangeLaw.hpp:60
Definition ExchangeLaw.hpp:60
void applyConduitLengthening(SimulationContext &ctx, RouteModel model)
Refresh routing lengths and apply dynamic-wave/FV Courant lengthening.
Definition Routing.cpp:153
@ FV
Explicit conservative finite volume (Godunov, HLL/HLLC)
Definition SimulationOptions.hpp:81
@ KINWAVE
Kinematic wave approximation.
Definition SimulationOptions.hpp:79
@ STEADY
Steady-state (no routing)
Definition SimulationOptions.hpp:78
@ DYNWAVE
Dynamic wave (full Saint-Venant, implicit Picard)
Definition SimulationOptions.hpp:80
RouteModel
Definition Routing.hpp:66
@ DYNWAVE
Dynamic wave (St. Venant, implicit Picard)
Definition Routing.hpp:69
Structure-of-Arrays storage for all nodes.
Definition NodeData.hpp:125
Dense SoA for outfall boundary-condition properties (one row per OUTFALL).
Definition NodeSubtypes.hpp:273
Definition RoutingCheckpoint.cpp:462
Central, reentrant simulation context.
Definition SimulationContext.hpp:390
Knobs for FLOW_ROUTING FV.
Definition FvOptions.hpp:123
SoA mesh geometry and topology for the FV network solver.
Definition NetworkMeshData.hpp:123
Mutable solver state — the conserved variables and the node volumes.
Definition NetworkMeshData.hpp:519
Definition FvTransportWater.hpp:7