OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
SourceWaterDeliveryBridge.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 Caleb Buahin
3
12
13#pragma once
14#include "SourceWaterDriver.hpp"
15#include <cstdint>
16#include <optional>
17
18namespace openswmm::runoff {
20 uint64_t ordinal = 0;
21 double available = 0; // accepted receiving boundary, seconds
22 SourceWaterDelivery water; // original completed source interval and ft3
23};
25 double runoff = 0, drain = 0; // ft3, kept separate for hydraulic continuity
26 double rate = 0; // total ft3/s over the staged receiving interval
27};
28
38public:
50 std::string initialize(const SourceWaterDriver& source);
55 bool ownsSubcatch(int source) const;
60 const std::vector<int>& sourceGroups() const { return source_groups_; }
66 std::string validateReceiver(const SimulationContext& context) const;
79 std::string capture(const SourceWaterDriver& source, double accepted_end);
88 std::string stage(double start, double end);
95 std::string commit();
99 void cancel() { trial_.reset(); }
104 const std::vector<SourceNodeDelivery>& receipts() const;
109 const std::vector<QueuedSourceDelivery>& pending() const { return state_.pending; }
113 const std::vector<SourceNodeDelivery>& received() const { return state_.received; }
117 const std::vector<SourceNodeDelivery>& delivered() const { return state_.delivered; }
122 const std::vector<SourceNodeDelivery>& lastReceipts() const { return state_.last; }
126 double lastStart() const { return state_.last_start; }
130 double receiverEnd() const { return state_.receiver_end; }
134 uint64_t capturedCount() const { return state_.count; }
148 void checkpoint(detail::CompletedSourceArchive& archive, bool model,
149 const SourceWaterDriver& source);
150
151private:
152 struct State {
153 uint64_t count = 0, digest = 14695981039346656037ULL;
154 double receiver_end = 0;
155 std::vector<double> source_ends;
156 std::vector<QueuedSourceDelivery> pending;
157 std::vector<SourceNodeDelivery> received, delivered, last;
158 uint64_t last_begin = 0;
159 double last_start = 0;
160 } state_;
161 struct Trial {
162 double end = 0;
163 std::vector<SourceNodeDelivery> receipts, delivered;
164 };
165 bool initialized_ = false;
166 std::string source_model_;
167 std::vector<std::string> node_names_;
168 std::vector<int> source_groups_;
169 std::optional<Trial> trial_;
179 void validate(const State& state, const SourceWaterDriver& source) const;
180};
181}
Advancement and bookkeeping of hydrological water sources.
Definition CompletedSourceArchive.hpp:25
Definition SourceWaterDeliveryBridge.hpp:37
const std::vector< SourceNodeDelivery > & lastReceipts() const
Borrow exact receipts of the preceding accepted receiving interval.
Definition SourceWaterDeliveryBridge.hpp:122
std::string stage(double start, double end)
Offer every pending receipt once over the next contiguous receiving interval.
Definition SourceWaterDeliveryBridge.cpp:265
std::string commit()
Accept the staged receiving interval and consume its pending source water.
Definition SourceWaterDeliveryBridge.cpp:289
std::string validateReceiver(const SimulationContext &context) const
Check receiver node count and exact ordered node-name identity.
Definition SourceWaterDeliveryBridge.cpp:152
const std::vector< SourceNodeDelivery > & received() const
Borrow cumulative captured volumes per receiver node.
Definition SourceWaterDeliveryBridge.hpp:113
double receiverEnd() const
Read the accepted receiving frontier.
Definition SourceWaterDeliveryBridge.hpp:130
std::string initialize(const SourceWaterDriver &source)
Attach whole-source ownership before any source/receiving advancement.
Definition SourceWaterDeliveryBridge.cpp:105
const std::vector< QueuedSourceDelivery > & pending() const
Borrow the ordered captured-but-unconsumed delivery suffix.
Definition SourceWaterDeliveryBridge.hpp:109
void checkpoint(detail::CompletedSourceArchive &archive, bool model, const SourceWaterDriver &source)
Stream private same-platform identity or accepted delivery restart state.
Definition SourceWaterDeliveryBridge.cpp:306
double lastStart() const
Read the previous accepted receiving interval's opening time.
Definition SourceWaterDeliveryBridge.hpp:126
const std::vector< SourceNodeDelivery > & receipts() const
Borrow staged per-node water offers in receiver index order.
Definition SourceWaterDeliveryBridge.cpp:301
const std::vector< SourceNodeDelivery > & delivered() const
Borrow cumulative volumes consumed by accepted receiving intervals.
Definition SourceWaterDeliveryBridge.hpp:117
std::string capture(const SourceWaterDriver &source, double accepted_end)
Queue newly completed source outlet records at an accepted receiver boundary.
Definition SourceWaterDeliveryBridge.cpp:233
bool ownsSubcatch(int source) const
Test whether a model subcatchment belongs to a captured source component.
Definition SourceWaterDeliveryBridge.cpp:148
void cancel()
Drop a receiving trial without consuming any accepted pending receipt. Leaves accepted clocks/totals/...
Definition SourceWaterDeliveryBridge.hpp:99
uint64_t capturedCount() const
Read the length of the source delivery prefix captured by this bridge.
Definition SourceWaterDeliveryBridge.hpp:134
const std::vector< int > & sourceGroups() const
Borrow the original-subcatchment-to-source-group mapping.
Definition SourceWaterDeliveryBridge.hpp:60
Owned completed-source water/snow and conservative-pollutant trial driver. Context and kernel histori...
Definition SourceWaterDriver.hpp:83
Definition ExplicitInertialSolver.hpp:68
Central, reentrant simulation context.
Definition SimulationContext.hpp:390
Definition SourceWaterDeliveryBridge.hpp:19
SourceWaterDelivery water
Definition SourceWaterDeliveryBridge.hpp:22
uint64_t ordinal
Definition SourceWaterDeliveryBridge.hpp:20
double available
Definition SourceWaterDeliveryBridge.hpp:21
Definition SourceWaterDeliveryBridge.hpp:24
double rate
Definition SourceWaterDeliveryBridge.hpp:26
double drain
Definition SourceWaterDeliveryBridge.hpp:25
double runoff
Definition SourceWaterDeliveryBridge.hpp:25
Definition SourceWaterDriver.hpp:35