OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
SurfaceExchange.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2
11
12#pragma once
13#include <string>
14#include <vector>
15#include <functional>
16
17namespace openswmm::twoD {
19
21
22// SI units. One donor's water ceiling is repeated identically across its cells.
23// Candidates must already account for competing source withdrawals (ET,
24// outside/native loss, drains). Receiver denial never migrates to another cell.
27 std::string source;
28 int unit = -1, cell = -1;
29 double area = 0, pond = 0, water_ceiling = 0, candidate = 0;
30};
37 double start = 0, end = 0, volume = 0;
38 // Actual donor-pool masses in the receiver's species order; never inferred
39 // from outlet or mesh concentration. Empty only when transport is inactive.
40 std::vector<double> mass;
41};
43// Refunds retain the original donor tuple; physical/older-column emergence
44// identifies only the receiver cell, to be split by reviewed surface ownership.
53 double volume = 0;
54 std::vector<double> mass;
55};
56
57// Serial transaction foundation, not a scheduler or runtime activation switch.
58// Plan is read-only. Commit revalidates receiver headroom BEFORE callers install
59// their trial source state. Invalid settlements book nothing and can be retried.
60// Reviewed source ownership retains pending provenance in the receiver.
61// Source adoption and restart integration remain the caller's responsibilities;
62// the production ownership gate remains closed.
64public:
65 // Optional qualified mesh prescription; returns a capacity volume in m3.
66 // Both planning and settlement use it; donor/receiver ceilings still apply.
67 using Capacity = std::function<double(const SurfaceIntakeRequest&, double)>;
81 std::string plan(const SubsurfaceSolver&, double start, double end, double completed_through,
82 const std::vector<SurfaceIntakeRequest>&, const Capacity* = nullptr);
95 std::string commit(SubsurfaceSolver&, const std::vector<SurfaceIntakeActual>&,
96 const Capacity* = nullptr);
97 void cancel() noexcept;
105 const std::vector<SurfaceIntakeAward>& awards() const noexcept { return awards_; }
114 const std::vector<SurfaceIntakeReceipt>& receipts() const noexcept { return receipts_; }
122 double completedEnd() const noexcept { return completed_end_; }
123
124private:
125 friend class CommonSourceStage;
126 double start_ = 0, end_ = 0, completed_end_ = 0;
127 bool planned_ = false;
128 const SubsurfaceSolver* receiver_ = nullptr;
129 std::vector<SurfaceIntakeAward> awards_;
130 std::vector<SurfaceIntakeReceipt> receipts_;
131};
132}
The two-zone kernel. Owned by SurfaceRouter2D; driven by the marcher's tier hooks.
Definition SubsurfaceSolver.hpp:128
Definition SurfaceExchange.hpp:63
const std::vector< SurfaceIntakeAward > & awards() const noexcept
Read this exchange transaction's stable result state.
Definition SurfaceExchange.hpp:105
void cancel() noexcept
Discard pending intake awards without undoing committed receipts.
Definition SurfaceExchange.cpp:235
std::string commit(SubsurfaceSolver &, const std::vector< SurfaceIntakeActual > &, const Capacity *=nullptr)
Settle the current awards against the same aquifer owner.
Definition SurfaceExchange.cpp:177
double completedEnd() const noexcept
Read this exchange transaction's stable result state.
Definition SurfaceExchange.hpp:122
friend class CommonSourceStage
Definition SurfaceExchange.hpp:125
std::function< double(const SurfaceIntakeRequest &, double)> Capacity
Definition SurfaceExchange.hpp:67
const std::vector< SurfaceIntakeReceipt > & receipts() const noexcept
Read this exchange transaction's stable result state.
Definition SurfaceExchange.hpp:114
std::string plan(const SubsurfaceSolver &, double start, double end, double completed_through, const std::vector< SurfaceIntakeRequest > &, const Capacity *=nullptr)
Plan donor-limited, receiver-limited intake over a contiguous completed interval.
Definition SurfaceExchange.cpp:68
Definition ExchangeLaw.hpp:60
SurfaceReturnKind
Definition SurfaceExchange.hpp:42
@ COLUMN_EXCESS
Definition SurfaceExchange.hpp:42
@ PHYSICAL_DUNNE
Definition SurfaceExchange.hpp:42
@ NUMERICAL_REFUND
Definition SurfaceExchange.hpp:42
SurfaceDonorKind
Definition SurfaceExchange.hpp:20
@ NON_LID
Definition SurfaceExchange.hpp:20
@ LID_BOTTOM
Definition SurfaceExchange.hpp:20
@ MESH
Definition CommonSourceStage.hpp:27
Definition SurfaceExchange.hpp:52
std::vector< double > mass
Definition SurfaceExchange.hpp:54
double volume
Definition SurfaceExchange.hpp:53
Definition SurfaceExchange.hpp:31
SurfaceIntakeRequest request
Definition SurfaceExchange.hpp:32
double demand
Definition SurfaceExchange.hpp:33
double maximum
Definition SurfaceExchange.hpp:33
Definition SurfaceExchange.hpp:35
double volume
Definition SurfaceExchange.hpp:37
SurfaceIntakeRequest request
Definition SurfaceExchange.hpp:36
double start
Definition SurfaceExchange.hpp:37
double end
Definition SurfaceExchange.hpp:37
std::vector< double > mass
Definition SurfaceExchange.hpp:40
Definition SurfaceExchange.hpp:25
double candidate
Definition SurfaceExchange.hpp:29
std::string source
Definition SurfaceExchange.hpp:27
int unit
Definition SurfaceExchange.hpp:28
double water_ceiling
Definition SurfaceExchange.hpp:29
SurfaceDonorKind kind
Definition SurfaceExchange.hpp:26
double area
Definition SurfaceExchange.hpp:29
double pond
Definition SurfaceExchange.hpp:29
int cell
Definition SurfaceExchange.hpp:28
Definition SurfaceExchange.hpp:45
std::vector< double > mass
Definition SurfaceExchange.hpp:50
SurfaceReturnKind kind
Definition SurfaceExchange.hpp:46
SurfaceIntakeReceipt intake
Definition SurfaceExchange.hpp:47
double volume
Definition SurfaceExchange.hpp:49
double available_at
Definition SurfaceExchange.hpp:48