OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
MeshHeat.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2
11
12#pragma once
13#include <limits>
14#include <string>
15#include <vector>
16#include "GroundHeat.hpp"
17#include "LidNodeHeat.hpp"
18namespace openswmm {
20}
21namespace openswmm::twoD {
22struct MeshData;
23struct SurfaceStateData;
24struct SolverOptions2D;
25struct GwNodeBed;
26// Empty in compatibility mode. Bed energy survives surface drying.
28 SimulationContext* context = nullptr; // owning engine; never serialized
29 bool enabled = false, surface = false, radiative = false, bed = false;
31 bool ground_column = false;
33 GroundHeatState* aquifer_ground = nullptr; // borrowed physical owner
34 std::vector<unsigned char> aquifer_owned;
35 std::vector<double> channel_footprint; // empty by default; SI area owned by routed channels
36 double ground_now = 0;
40 std::vector<int> failures;
41 // Seconds already advanced during the current router interval. Surface
42 // temperature rows update stores inside the marcher; dry columns receive
43 // only the remaining interval after routing completes.
44 std::vector<double> ground_column_seconds;
45 std::vector<unsigned char> hyporheic_eligible;
46 // LOCAL_STORAGE porewater: fixed saturated pore volume, independent of
47 // surface wetness. Temperature remains solely in bed_energy.
63
72 const GroundHeatState& groundOwner(int i) const {
74 }
75 void refreshBedView(int i);
82 void clear() { *this = MeshHeatState{}; }
83};
85 double radiation = 0, sensible = 0, latent = 0;
91 double total() const noexcept { return radiation + sensible + latent; }
92};
93// A column's portion of one shared finite thermal system. Index ranges let
94// a multi-owner solve reuse exactly the same mesh physics and receipts.
96 struct LidEnergy {
97 int row = -1, first_store = 0;
98 double area = 0;
100 std::vector<double> physical_energy;
101 std::vector<double> physical_ground_contact_j;
102 std::vector<std::size_t> vertical_contacts;
103 std::size_t ground_contact = std::numeric_limits<std::size_t>::max();
104 };
107 int cell = -1, first_store = 0, soil_count = 0, water = -1;
110 std::vector<LidEnergy> lids;
112 double mass = 0, volume = 0, evaporated = 0, seconds = 0, wet = 0, temperature = 0, slope = 0,
115};
117 GroundHeatState&, int cell, MeshHeatState*,
118 double temperature_volume, double volume,
119 double evaporated, double seconds,
120 double channel_area, std::vector<ThermalStore>&,
121 std::vector<ThermalContact>&,
122 std::vector<ThermalBoundary>&);
125 const SolverOptions2D&, GroundHeatState* aquifer = nullptr,
126 const std::vector<uint8_t>* coverage = nullptr);
128 const std::vector<GwNodeBed>&);
129void prepareMeshHeat(SimulationContext&, SurfaceStateData&, double seconds);
130// Complete the unprocessed part of the ground-column thermal interval after
131// the hydraulic march. The surface owns this conduction only when it has a
132// temperature row; otherwise the groundwater clock owns it.
134 double seconds) noexcept;
135// Called before intensive source sinks: the accepted evaporating water must
136// receive its thermal update before it leaves, including complete drying.
137double applyMeshHeatCell(const MeshData&, const SolverOptions2D&, MeshHeatState&, int cell,
138 double temperature_volume, double available_m3, double evaporated_m3,
139 double seconds, bool midpoint = false) noexcept;
140// Standalone storage has a fixed saturated pore volume: accepted infiltration
141// displaces an equal volume at its bottom, with finite soil heat exchange.
142void advectStandaloneGround(MeshHeatState&, int cell, double accepted_m3,
143 double donor_celsius) noexcept;
144double applyLocalBedSpecies(const MeshData&, MeshHeatState&, int cell, int species,
145 double surface_mass, double available_m3, double seconds) noexcept;
146// Beginning-state donor budgets for one Euler evaluation of the RK2 contact.
147double applyLocalBedSpeciesEuler(const MeshData&, MeshHeatState&, int cell, int species,
148 double surface_mass, double available_m3, double seconds);
149bool ageLocalBedPorewater(MeshHeatState&, double seconds) noexcept;
150} // namespace openswmm::twoD
Thermal state and exchange bookkeeping for fixed ground layers.
Finite-volume thermal graphs for LID node storage layers.
Definition ExchangeLaw.hpp:60
void advectStandaloneGround(MeshHeatState &h, int i, double volume, double donor) noexcept
Carry accepted infiltration heat through a standalone saturated physical soil column.
Definition MeshHeat.cpp:1361
bool ageLocalBedPorewater(MeshHeatState &h, double dt) noexcept
Advance the local-storage porewater age inventory without altering water volume.
Definition MeshHeat.cpp:1305
void advanceRemainingGroundColumns(const MeshData &mesh, const SolverOptions2D &options, SurfaceStateData &state, double seconds) noexcept
Complete each surface-owned physical ground column's unprocessed router interval.
Definition MeshHeat.cpp:1578
double applyMeshHeatCell(const MeshData &mesh, const SolverOptions2D &options, MeshHeatState &h, int i, double mass, double volume, double evaporated, double dt, bool midpoint) noexcept
Update one mixed surface thermal sample before accepted intensive water sinks.
Definition MeshHeat.cpp:1448
double applyLocalBedSpecies(const MeshData &mesh, MeshHeatState &h, int i, int r, double mass, double volume, double dt) noexcept
Exchange one native surface row with finite bed porewater.
Definition MeshHeat.cpp:1026
double commitGroundColumnSystem(GroundColumnAssembly &a, const ThermalSolution &solved) noexcept
Publish an accepted shared thermal solution into one assembly's canonical owners.
Definition MeshHeat.cpp:707
double applyLocalBedSpeciesEuler(const MeshData &mesh, MeshHeatState &h, int i, int r, double mass, double volume, double dt)
Exchange one native surface row with finite bed porewater for an Euler RK2 stage.
Definition MeshHeat.cpp:1196
GroundColumnAssembly appendGroundColumnSystem(const MeshData &mesh, const SolverOptions2D &options, GroundHeatState &owner, int i, MeshHeatState *h, double mass, double volume, double evaporated, double dt, double channel_area, std::vector< ThermalStore > &stores, std::vector< ThermalContact > &contacts, std::vector< ThermalBoundary > &boundaries)
Append one physical column and its finite surface/LID contacts to a shared thermal graph.
Definition MeshHeat.cpp:519
std::string initializeMeshHeat(SimulationContext &ctx, const MeshData &mesh, SurfaceStateData &state, const SolverOptions2D &options, GroundHeatState *aquifer, const std::vector< uint8_t > *coverage)
Prepare optional surface thermal stores, porewater and physical ground ownership.
Definition MeshHeat.cpp:835
std::string configureGroundLidOwners(SimulationContext &ctx, const MeshData &mesh, GroundHeatState &owner, const std::vector< GwNodeBed > &beds)
Map persistent Mesh Richards LID thermal owners onto physical ground cells.
Definition MeshHeat.cpp:964
void prepareMeshHeat(SimulationContext &ctx, SurfaceStateData &state, double dt)
Prepare inherited exchange flags, weather and fresh per-cell thermal interval accounting.
Definition MeshHeat.cpp:1409
Definition ExchangeLaw.hpp:60
Central, reentrant simulation context.
Definition SimulationContext.hpp:390
std::size_t ground_contact
Definition MeshHeat.hpp:103
std::vector< double > physical_ground_contact_j
Definition MeshHeat.hpp:101
std::vector< std::size_t > vertical_contacts
Definition MeshHeat.hpp:102
double area
Definition MeshHeat.hpp:98
std::vector< double > physical_energy
Definition MeshHeat.hpp:100
int first_store
Definition MeshHeat.hpp:97
LidNodeThermalGraph graph
Definition MeshHeat.hpp:99
Definition MeshHeat.hpp:95
std::size_t vertical_count
Definition MeshHeat.hpp:108
double water_initial_j
Definition MeshHeat.hpp:113
double mass
Definition MeshHeat.hpp:112
MeshHeatState * mesh_heat
Definition MeshHeat.hpp:106
double seconds
Definition MeshHeat.hpp:112
double temperature
Definition MeshHeat.hpp:112
double wet
Definition MeshHeat.hpp:112
int first_store
Definition MeshHeat.hpp:107
std::size_t first_contact
Definition MeshHeat.hpp:108
int soil_count
Definition MeshHeat.hpp:107
MeshAtmosphericFlux flux1
Definition MeshHeat.hpp:114
double volume
Definition MeshHeat.hpp:112
std::vector< LidEnergy > lids
Definition MeshHeat.hpp:110
MeshAtmosphericFlux flux0
Definition MeshHeat.hpp:114
int cell
Definition MeshHeat.hpp:107
GroundHeatState * owner
Definition MeshHeat.hpp:105
int snow_boundary
Definition MeshHeat.hpp:111
double evaporated
Definition MeshHeat.hpp:112
int water
Definition MeshHeat.hpp:107
std::size_t first_boundary
Definition MeshHeat.hpp:108
std::size_t top_count
Definition MeshHeat.hpp:109
std::size_t contact_count
Definition MeshHeat.hpp:108
double slope
Definition MeshHeat.hpp:112
std::size_t atmosphere
Definition MeshHeat.hpp:109
std::size_t ground_count
Definition MeshHeat.hpp:109
Definition GroundHeat.hpp:45
Definition SubsurfaceData.hpp:79
Definition LidNodeHeat.hpp:24
Definition MeshHeat.hpp:84
double total() const noexcept
Sum signed outward atmospheric components.
Definition MeshHeat.hpp:91
double radiation
Definition MeshHeat.hpp:85
double latent
Definition MeshHeat.hpp:85
double sensible
Definition MeshHeat.hpp:85
SoA storage for 2D mixed triangle/quad mesh geometry and topology.
Definition MeshData.hpp:65
Definition MeshHeat.hpp:27
std::vector< int > failures
Definition MeshHeat.hpp:40
std::vector< double > water_j
Definition MeshHeat.hpp:38
std::vector< double > water_bed_j
Definition MeshHeat.hpp:38
std::vector< double > radiative_j
Definition MeshHeat.hpp:38
int bed_age_row
Definition MeshHeat.hpp:48
std::vector< double > evaporated_m3
Definition MeshHeat.hpp:39
std::vector< double > ground_j
Definition MeshHeat.hpp:38
std::vector< double > sensible_j
Definition MeshHeat.hpp:38
std::vector< double > channel_footprint
Definition MeshHeat.hpp:35
void refreshBedView(int i)
Rebuild reported bed energy/capacity from the physical ground column's upper bed thickness.
Definition MeshHeat.cpp:1332
std::vector< unsigned char > aquifer_owned
Definition MeshHeat.hpp:34
std::vector< double > latent_j
Definition MeshHeat.hpp:39
std::vector< double > ground_column_seconds
Definition MeshHeat.hpp:44
bool surface_inherits
Definition MeshHeat.hpp:30
const GroundHeatState & groundOwner(int i) const
Borrow the physical thermal owner selected for one surface cell.
Definition MeshHeat.hpp:72
GroundHeatState & groundOwner(int i)
Borrow the physical thermal owner selected for one surface cell.
Definition MeshHeat.hpp:60
GroundHeatState * aquifer_ground
Definition MeshHeat.hpp:33
bool enabled
Definition MeshHeat.hpp:29
std::vector< double > initial_bed_energy
Definition MeshHeat.hpp:37
std::vector< double > bed_generated_age
Definition MeshHeat.hpp:50
bool surface
Definition MeshHeat.hpp:29
std::vector< double > reported_temperature
Definition MeshHeat.hpp:37
bool radiative_inherits
Definition MeshHeat.hpp:30
double ground_now
Definition MeshHeat.hpp:36
std::vector< double > bed_pore_volume
Definition MeshHeat.hpp:49
GroundHeatState standalone_ground
Definition MeshHeat.hpp:32
std::vector< double > bed_carried_mass
Definition MeshHeat.hpp:49
std::vector< double > atmospheric_j
Definition MeshHeat.hpp:38
std::vector< double > bed_energy
Definition MeshHeat.hpp:37
void clear()
Reset mesh thermal flags, owned stores, diagnostics and borrowed bindings.
Definition MeshHeat.hpp:82
bool ground_column
Definition MeshHeat.hpp:31
std::vector< double > bed_exchange_mass
Definition MeshHeat.hpp:49
bool radiative
Definition MeshHeat.hpp:29
int bed_temp_row
Definition MeshHeat.hpp:48
int bed_species
Definition MeshHeat.hpp:48
std::vector< unsigned char > hyporheic_eligible
Definition MeshHeat.hpp:45
SimulationContext * context
Definition MeshHeat.hpp:28
std::vector< double > bed_initial_mass
Definition MeshHeat.hpp:49
std::vector< double > bed_capacity
Definition MeshHeat.hpp:37
bool bed
Definition MeshHeat.hpp:29
Definition SolverOptions2D.hpp:257
Definition SurfaceStateData.hpp:64
Definition PorousHeat.hpp:60