OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
PorousHeat.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>
15namespace openswmm::twoD {
16struct SubsurfaceState;
17
18// Local thermal equilibrium: theta is water per bulk volume. Solids do not
19// disappear when the water table moves or a hydraulic layer collapses.
21 double porosity = .4, grain_density = 2650, grain_specific_heat = 880;
23 double water_heat_capacity = 4184000;
24 bool geometric = false;
31 std::string validate() const;
39 double volumetricCapacity(double theta) const;
47 double conductivity(double theta) const;
48};
50 double capacity = 0, energy = 0;
51};
53 int a = -1, b = -1;
54 double conductance = 0;
55};
57 int store = -1;
58 double conductance = 0, temperature = 0, power = 0;
59};
61 std::string error;
62 bool interval_limit = false; // bounded work, distinct from invalid physics
63 std::vector<double> energy, temperature, contact_j, boundary_j;
65 int iterations = 0;
66};
67// Caller-owned workspaces: inputs must not alias writable workspace/result storage.
68// One active call owns each workspace. Borrowed mutable results expire on reuse;
69// owning overloads below retain independent value semantics.
72 std::vector<double> diag, rhs, x, r, z, p, ap, energy;
73};
81ThermalSolution& solveThermalContacts(const std::vector<ThermalStore>&,
82 const std::vector<ThermalContact>&,
83 const std::vector<ThermalBoundary>&, double seconds,
85ThermalSolution& solveThermalContactsRk2(const std::vector<ThermalStore>&,
86 const std::vector<ThermalContact>&,
87 const std::vector<ThermalBoundary>&, double seconds,
89// Backward Euler for a reciprocal thermal contact network. All stores are
90// finite; all contact receipts enter one store and leave the other. Inputs
91// are never modified, including on numerical refusal.
115ThermalSolution solveThermalContacts(const std::vector<ThermalStore>&,
116 const std::vector<ThermalContact>&,
117 const std::vector<ThermalBoundary>&, double seconds);
118// Implicit midpoint with conservative receipts and bounded monotone
119// subdivision for stiff contact graphs. Boundary data is held for seconds.
120// This does not advance moisture, advection or a borrowed thermal owner.
144ThermalSolution solveThermalContactsRk2(const std::vector<ThermalStore>&,
145 const std::vector<ThermalContact>&,
146 const std::vector<ThermalBoundary>&, double seconds);
147
150 double area = 0;
166 std::string initialize(double area_m2, const std::vector<double>& fixed_depth_edges,
167 const ThermalMaterial&, const std::vector<double>& moisture,
168 const std::vector<double>& initial_celsius);
169 // Changing theta changes capacity, never energy. Physical water transfers
170 // must add/remove their own sensible heat before calling this method.
185 std::string setMoisture(const std::vector<double>&);
192 std::vector<ThermalStore> stores() const;
193 void stores(std::vector<ThermalStore>& result) const;
201 std::vector<ThermalContact> contacts() const;
202 void contacts(std::vector<ThermalContact>& result) const;
203};
205 std::string error;
207 double external_j = 0, water_residual = 0;
208};
209// Fixed-grid flux reconstruction from accepted physical external transfers
210// and overlap-projected hydraulic water contents. Geometric sigma handover
211// is not an external transfer. The interior flux is the unique conservative
212// net flux satisfying each fixed layer's water balance (piston attribution
213// for a bulk closure). External energy is the actual paired donor receipt.
238ThermalAdvection advectPorousColumn(PorousHeatColumn&, const std::vector<double>& new_moisture,
239 const std::vector<double>& external_water_m3,
240 const std::vector<double>& external_j,
241 const std::vector<double>& implicit_withdrawal_m3 = {});
242// Forward-Euler energy derivative for shared RK stages. water_change is
243// the beginning-state fixed-grid water tangent integrated over the stage;
244// endpoint moisture only derives the next capacity. Donor temperatures
245// exclude already reserved outgoing water and are returned for paired
246// withdrawal receipts. No column mutation on refusal.
270ThermalAdvection advectPorousColumnEuler(PorousHeatColumn&, const std::vector<double>& new_moisture,
271 const std::vector<double>& water_change_m3,
272 const std::vector<double>& external_water_m3,
273 const std::vector<double>& external_j,
274 const std::vector<double>& withdrawal_m3,
275 const std::vector<double>& donor_temperature);
276// Tangent of the overlap projection from equal stretching hydraulic layers
277// to fixed physical layers. Water depths are per hydraulic layer. Moving
278// interface jumps belong to the receiving fixed layer at an aligned edge.
298std::string projectGroundWaterIncrement(const PorousHeatColumn&, double unsaturated_length,
299 double length_change,
300 const std::vector<double>& old_water_depth,
301 const std::vector<double>& water_depth_change,
302 std::vector<double>& fixed_water_change);
303// Conservative geometric projection. Bulk closures use uniform unsaturated
304// theta; SIGMA uses overlaps of accepted stretching hydraulic layers. The
305// thermal depth grid itself never moves. Optional sat_water is SI m3/layer.
326std::string projectGroundMoisture(const SubsurfaceState&, int cell, double saturated_thickness,
327 const std::vector<double>& fixed_depth_edges,
328 std::vector<double>& theta,
329 std::vector<double>* sat_water = nullptr);
330} // namespace openswmm::twoD
Definition ExchangeLaw.hpp:60
std::string projectGroundWaterIncrement(const PorousHeatColumn &column, double length, double delta_length, const std::vector< double > &old_water, const std::vector< double > &delta_water, std::vector< double > &output)
Project a moving hydraulic-layer water tangent onto the fixed thermal grid.
Definition PorousHeat.cpp:689
ThermalAdvection advectPorousColumn(PorousHeatColumn &column, const std::vector< double > &moisture, const std::vector< double > &external_water, const std::vector< double > &external_j, const std::vector< double > &withdrawal)
Reconstruct conservative layer water fluxes and apply implicit upwind heat advection.
Definition PorousHeat.cpp:490
ThermalAdvection advectPorousColumnEuler(PorousHeatColumn &column, const std::vector< double > &moisture, const std::vector< double > &change, const std::vector< double > &external_water, const std::vector< double > &external_j, const std::vector< double > &withdrawal, const std::vector< double > &temperature)
Apply a conservative explicit heat-advection tangent for one shared RK stage.
Definition PorousHeat.cpp:608
ThermalSolution solveThermalContacts(const std::vector< ThermalStore > &stores, const std::vector< ThermalContact > &contacts, const std::vector< ThermalBoundary > &boundaries, double dt)
Solve reciprocal heat contacts by backward Euler and diagonal-preconditioned CG.
Definition PorousHeat.cpp:227
ThermalSolution solveThermalContactsRk2(const std::vector< ThermalStore > &stores, const std::vector< ThermalContact > &contacts, const std::vector< ThermalBoundary > &boundaries, double dt)
Solve reciprocal heat contacts by bounded implicit-midpoint subdivisions.
Definition PorousHeat.cpp:259
std::string projectGroundMoisture(const SubsurfaceState &s, int i, double hg, const std::vector< double > &edges, std::vector< double > &output, std::vector< double > *saturated_water)
Project accepted hydraulic moisture into a fixed physical thermal depth grid.
Definition PorousHeat.cpp:752
Definition PorousHeat.hpp:148
std::vector< double > capacity
Definition PorousHeat.hpp:151
std::string initialize(double area_m2, const std::vector< double > &fixed_depth_edges, const ThermalMaterial &, const std::vector< double > &moisture, const std::vector< double > &initial_celsius)
Build a validated candidate physical heat column and publish it on success.
Definition PorousHeat.cpp:389
double area
Definition PorousHeat.hpp:150
std::string setMoisture(const std::vector< double > &)
Recompute moisture-dependent heat capacity and conductivity without changing energy.
Definition PorousHeat.cpp:424
ThermalMaterial material
Definition PorousHeat.hpp:149
std::vector< double > energy
Definition PorousHeat.hpp:151
std::vector< ThermalContact > contacts() const
Construct conductive contacts between consecutive fixed layers.
Definition PorousHeat.cpp:455
std::vector< double > conductivity
Definition PorousHeat.hpp:151
std::vector< double > initial_energy
Definition PorousHeat.hpp:151
std::vector< ThermalStore > stores() const
Copy canonical layer capacity and energy into finite-network stores.
Definition PorousHeat.cpp:444
std::vector< double > depth_edges
Definition PorousHeat.hpp:151
std::vector< double > theta
Definition PorousHeat.hpp:151
Per-cell resolved parameters and state (SoA).
Definition SubsurfaceData.hpp:219
Definition PorousHeat.hpp:204
std::vector< double > vertical_j
Definition PorousHeat.hpp:206
double water_residual
Definition PorousHeat.hpp:207
std::string error
Definition PorousHeat.hpp:205
double external_j
Definition PorousHeat.hpp:207
std::vector< double > vertical_water
Definition PorousHeat.hpp:206
std::vector< double > withdrawn_j
Definition PorousHeat.hpp:206
std::vector< double > temperature
Definition PorousHeat.hpp:206
Definition PorousHeat.hpp:56
double power
Definition PorousHeat.hpp:58
int store
Definition PorousHeat.hpp:57
double conductance
Definition PorousHeat.hpp:58
double temperature
Definition PorousHeat.hpp:58
Definition PorousHeat.hpp:52
int b
Definition PorousHeat.hpp:53
double conductance
Definition PorousHeat.hpp:54
int a
Definition PorousHeat.hpp:53
Definition PorousHeat.hpp:70
std::vector< double > p
Definition PorousHeat.hpp:72
std::vector< double > r
Definition PorousHeat.hpp:72
std::vector< double > rhs
Definition PorousHeat.hpp:72
std::vector< double > ap
Definition PorousHeat.hpp:72
ThermalSolution result
Definition PorousHeat.hpp:71
std::vector< double > z
Definition PorousHeat.hpp:72
std::vector< double > energy
Definition PorousHeat.hpp:72
std::vector< double > diag
Definition PorousHeat.hpp:72
std::vector< double > x
Definition PorousHeat.hpp:72
Definition PorousHeat.hpp:20
double grain_conductivity
Definition PorousHeat.hpp:22
double grain_density
Definition PorousHeat.hpp:21
double water_conductivity
Definition PorousHeat.hpp:22
bool geometric
Definition PorousHeat.hpp:24
double volumetricCapacity(double theta) const
Compute local-equilibrium bulk heat capacity without an air heat-capacity term.
Definition PorousHeat.cpp:27
double porosity
Definition PorousHeat.hpp:21
double conductivity(double theta) const
Mix solid, water and air conductivities for a prescribed water fraction.
Definition PorousHeat.cpp:30
std::string validate() const
Check finite porosity and positive phase thermal properties.
Definition PorousHeat.cpp:18
double air_conductivity
Definition PorousHeat.hpp:22
double grain_specific_heat
Definition PorousHeat.hpp:21
double water_heat_capacity
Definition PorousHeat.hpp:23
Definition PorousHeat.hpp:74
std::vector< ThermalStore > current
Definition PorousHeat.hpp:78
std::vector< double > contact_correction
Definition PorousHeat.hpp:79
ThermalSolution result
Definition PorousHeat.hpp:75
std::vector< double > boundary_correction
Definition PorousHeat.hpp:79
std::vector< double > energy_correction
Definition PorousHeat.hpp:79
ThermalContactScratch implicit
Definition PorousHeat.hpp:76
std::vector< long double > rate
Definition PorousHeat.hpp:77
Definition PorousHeat.hpp:60
std::vector< double > temperature
Definition PorousHeat.hpp:63
bool interval_limit
Definition PorousHeat.hpp:62
std::vector< double > energy
Definition PorousHeat.hpp:63
std::string error
Definition PorousHeat.hpp:61
std::vector< double > boundary_j
Definition PorousHeat.hpp:63
std::vector< double > contact_j
Definition PorousHeat.hpp:63
double algebraic_residual
Definition PorousHeat.hpp:64
int iterations
Definition PorousHeat.hpp:65
Definition PorousHeat.hpp:49
double energy
Definition PorousHeat.hpp:50
double capacity
Definition PorousHeat.hpp:50