OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
ChannelGround.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2
11
12#pragma once
13#include "MeshHeat.hpp"
14#include <cstdint>
15#include <utility>
16namespace openswmm::detail {
18}
19namespace openswmm::twoD {
21 int link = -1, cell = -1, layer = -1;
22 double begin = 0, end = 0, share = 1, invert = 0;
23};
25 double mass = 0, volume = 0, evaporated = 0;
26};
27// All routed water owners sharing a soil column join one finite solve. The
28// router owns this state; the CPU marcher invokes it on its source clock.
30public:
38 void clear() { *this = {}; }
44 bool active() const noexcept { return !contacts_.empty(); }
51 bool ownsCell(int i) const noexcept {
52 return i >= 0 && std::size_t(i) < cell_owned_.size() && cell_owned_[i];
53 }
54
60 bool ownsLink(int i) const noexcept {
61 return i >= 0 && std::size_t(i) < link_owned_.size() && link_owned_[i];
62 }
63
70 const std::vector<int>& cells() const noexcept { return cells_; }
78 const std::vector<ChannelGroundContact>& contacts() const noexcept { return contacts_; }
86 std::size_t contactCount(int link) const noexcept {
87 return ownsLink(link) ? contact_ranges_[link].second - contact_ranges_[link].first : 0;
88 }
89 // Capacity-weighted temperature of the actual soil beneath this reach.
90 // This is a view of existing soil energy, including while the reach is dry.
104 double bedTemperature(int link, double begin = 0, double end = 1) const noexcept;
118 SubsurfaceTransportState&, SurfaceStateData&, double coordinate_to_si);
119 // Samples are already mixed, before intensive sinks. Returned surface
120 // temperature-volume values are published by the caller at that boundary.
132 std::string advance(const SolverOptions2D&, const std::vector<SurfaceThermalSample>&,
133 double seconds, std::vector<double>& surface_mass);
141 const std::vector<double>& channelAtmosphere() const noexcept { return channel_atmospheric_j_; }
149 const std::vector<double>& channelToGround() const noexcept { return channel_ground_j_; }
157 const std::vector<double>& channelSpeciesToGround() const noexcept {
158 return channel_species_to_ground_;
159 }
160
167 const std::vector<double>& channelThermalIncrement() const noexcept {
168 return channel_increment_j_;
169 }
170
178 std::string modelIdentity() const;
186
187private:
188 SimulationContext* context_ = nullptr;
189 const MeshData* mesh_ = nullptr;
190 GroundHeatState* ground_ = nullptr;
191 SubsurfaceTransportState* transport_ = nullptr;
192 SurfaceStateData* surface_ = nullptr;
193 std::vector<ChannelGroundContact> contacts_;
194 std::vector<uint8_t> cell_owned_, link_owned_;
195 std::vector<int> cells_;
196 std::vector<std::pair<std::size_t, std::size_t>> contact_ranges_;
197 std::vector<double> channel_atmospheric_j_, channel_ground_j_, channel_increment_j_,
198 channel_species_to_ground_;
199};
200} // namespace openswmm::twoD
Mesh thermal state, including bed energy retained through surface drying.
Definition CompletedSourceArchive.hpp:25
Definition ChannelGround.hpp:29
const std::vector< double > & channelAtmosphere() const noexcept
Borrow cumulative signed atmospheric energy added to routed channel water.
Definition ChannelGround.hpp:141
std::string advance(const SolverOptions2D &, const std::vector< SurfaceThermalSample > &, double seconds, std::vector< double > &surface_mass)
Advance the shared finite channel/soil solve and publish surface temperature-volume.
Definition ChannelGround.cpp:317
const std::vector< ChannelGroundContact > & contacts() const noexcept
Borrow the prepared contact segments sorted by link, begin fraction and cell.
Definition ChannelGround.hpp:78
const std::vector< int > & cells() const noexcept
Borrow the prepared unique owned cells in increasing mesh-index order.
Definition ChannelGround.hpp:70
std::size_t contactCount(int link) const noexcept
Read the number of mapped contact pieces for a routed link.
Definition ChannelGround.hpp:86
bool active() const noexcept
Test whether any prepared channel/ground contact exists.
Definition ChannelGround.hpp:44
const std::vector< double > & channelThermalIncrement() const noexcept
Borrow cumulative net finite thermal energy change of routed water.
Definition ChannelGround.hpp:167
const std::vector< double > & channelToGround() const noexcept
Borrow cumulative signed channel-to-ground contact energy.
Definition ChannelGround.hpp:149
bool ownsCell(int i) const noexcept
Test the resolved thermal contact ownership mask for one cell.
Definition ChannelGround.hpp:51
const std::vector< double > & channelSpeciesToGround() const noexcept
Borrow cumulative signed species exchange into physical porewater.
Definition ChannelGround.hpp:157
void clear()
Release this contact mapping, borrowed bindings and diagnostic storage.
Definition ChannelGround.hpp:38
double bedTemperature(int link, double begin=0, double end=1) const noexcept
Read the capacity-weighted temperature of physical soil beneath a channel reach.
Definition ChannelGround.cpp:266
std::string modelIdentity() const
Serialize the prepared ownership, contact geometry and transport row identity.
Definition ChannelGround.cpp:57
bool ownsLink(int i) const noexcept
Test the resolved thermal contact ownership mask for one link.
Definition ChannelGround.hpp:60
std::string initialize(SimulationContext &, const MeshData &, GroundHeatState &, SubsurfaceTransportState &, SurfaceStateData &, double coordinate_to_si)
Resolve channel geometry onto shared porous thermal columns and bind borrowed owners.
Definition ChannelGround.cpp:123
Definition OutfallExchange.hpp:17
Definition MeshCheckpointState.hpp:18
Definition ExchangeLaw.hpp:60
Central, reentrant simulation context.
Definition SimulationContext.hpp:390
Definition ChannelGround.hpp:20
double begin
Definition ChannelGround.hpp:22
int layer
Definition ChannelGround.hpp:21
int cell
Definition ChannelGround.hpp:21
double invert
Definition ChannelGround.hpp:22
double end
Definition ChannelGround.hpp:22
double share
Definition ChannelGround.hpp:22
int link
Definition ChannelGround.hpp:21
Definition GroundHeat.hpp:45
SoA storage for 2D mixed triangle/quad mesh geometry and topology.
Definition MeshData.hpp:65
Definition SolverOptions2D.hpp:257
Species mass in both aquifer zones, and where mass crossed a boundary.
Definition SubsurfaceTransportState.hpp:69
Definition SurfaceStateData.hpp:64
Definition ChannelGround.hpp:24
double mass
Definition ChannelGround.hpp:25
double volume
Definition ChannelGround.hpp:25
double evaporated
Definition ChannelGround.hpp:25