OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
RichardsColumn.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2
11
12#ifndef OPENSWMM_RICHARDS_COLUMN_HPP
13#define OPENSWMM_RICHARDS_COLUMN_HPP
14#include <string>
15#include <vector>
16#include <limits>
17
18namespace openswmm::richards {
19// All kernel quantities are SI. Storage includes explicitly authored elastic
20// water storage; theta is pore water content and remains <= theta_s.
21struct Material {
22 double theta_r = 0.0, alpha = 0.0, n = 0.0, l = 0.5, specific_storage = 0.0;
23};
24struct Options {
25 bool enabled = false;
27 double atol = 1.e-7, rtol = 1.e-5, max_step = 30.0;
28};
29struct Cell {
30 double volume = 0.0, area = 0.0, z = 0.0, dz = 0.0;
31 // Surface theta_s is the open storage fraction; area is always the full
32 // contact footprint. Porous theta_s is saturated pore water content.
33 double theta_s = 1.0, Ks = 0.0, wilting = 0.0, potential_et = 0.0;
35};
36enum class Bottom { Sealed, FreeDrainage, Head };
37struct Column {
38 // First cell is a surface reservoir at z=soil-surface elevation; the
39 // remaining cells are porous control volumes ordered top to bottom.
40 std::vector<Cell> cells;
41 std::vector<double> water;
44 double bottom_K = 0.0, bottom_head = 0.0, bottom_distance = 0.0;
45 // Internal, per-advance reservations in m3, separately in each direction.
46 // No recycling of received water into a donor award within this interval.
47 // Infinity preserves the existing standalone boundary. area=0 uses the
48 // porous face geometry; Head connections may use a reviewed contact area.
49 double bottom_out_limit = std::numeric_limits<double>::infinity();
50 double bottom_in_limit = std::numeric_limits<double>::infinity();
51 double bottom_area = 0.0, bottom_factor = 1.0;
52 double inflow =
53 0.0; // accepted, held surface supply, m3/s; zero preserves standalone preparation
54};
55// Negative indices: -2 surface supply, -3 evaporation, -4 bottom outflow, -5 bottom inflow.
56struct Transfer {
57 int from = -1, to = -1;
58 double volume = 0.0;
59};
60struct Report {
61 bool ok = true;
62 std::string error;
63 int accepted = 0, rejected = 0, rhs = 0, newton = 0;
64 double min_step = 0.0, bottom_volume = 0.0, evaporation = 0.0, balance = 0.0;
65 double bottom_outflow = 0.0, bottom_inflow = 0.0;
66 double inflow = 0.0; // accepted integrated surface supply, m3
67 int bottom_out_limited = 0, bottom_in_limited = 0; // accepted endpoints only
68 std::vector<Transfer> transfers;
69};
70
76bool valid(const Material& p, double theta_s);
81bool valid(const Options& o);
89double theta(const Material& p, double theta_s, double pressure);
96double storage(const Material& p, double theta_s, double pressure);
105double pressure(const Material& p, double theta_s, double storage_fraction);
112double conductivity(const Material& p, double Ks, double pressure);
113
114// Adaptive stiff BDF1 with step doubling. Compatible column sizes are packed
115// cell-major, node-lane minor; each lane has its own clock and error test.
116// Failed calls leave all supplied column states unchanged.
136std::vector<Report> advance(std::vector<Column*>& columns, double dt);
137}
138#endif
Definition RichardsColumn.cpp:25
double conductivity(const Material &p, double Ks, double h)
Evaluate van Genuchten-Mualem unsaturated hydraulic conductivity.
Definition RichardsColumn.cpp:54
double storage(const Material &p, double ts, double h)
Compute pore plus explicitly authored positive-head elastic storage.
Definition RichardsColumn.cpp:43
double pressure(const Material &p, double ts, double w)
Invert volumetric storage to pressure head.
Definition RichardsColumn.cpp:46
double theta(const Material &p, double ts, double h)
Compute van Genuchten pore water content from pressure head.
Definition RichardsColumn.cpp:37
Bottom
Definition RichardsColumn.hpp:36
@ FreeDrainage
Definition RichardsColumn.hpp:36
@ Head
Definition RichardsColumn.hpp:36
@ Sealed
Definition RichardsColumn.hpp:36
std::vector< Report > advance(std::vector< Column * > &columns, double dt)
Advance independently adaptive Richards columns with all-column rollback.
Definition RichardsColumn.cpp:531
bool valid(const Material &p, double ts)
Check the finite material ranges required by the column kernels.
Definition RichardsColumn.cpp:26
Definition RichardsColumn.hpp:29
double Ks
Definition RichardsColumn.hpp:33
Material material
Definition RichardsColumn.hpp:34
double z
Definition RichardsColumn.hpp:30
double theta_s
Definition RichardsColumn.hpp:33
double volume
Definition RichardsColumn.hpp:30
double wilting
Definition RichardsColumn.hpp:33
double area
Definition RichardsColumn.hpp:30
double potential_et
Definition RichardsColumn.hpp:33
double dz
Definition RichardsColumn.hpp:30
Definition RichardsColumn.hpp:37
double bottom_out_limit
Definition RichardsColumn.hpp:49
Bottom bottom
Definition RichardsColumn.hpp:43
double bottom_head
Definition RichardsColumn.hpp:44
double bottom_K
Definition RichardsColumn.hpp:44
double bottom_in_limit
Definition RichardsColumn.hpp:50
double bottom_distance
Definition RichardsColumn.hpp:44
Options options
Definition RichardsColumn.hpp:42
std::vector< double > water
Definition RichardsColumn.hpp:41
double bottom_area
Definition RichardsColumn.hpp:51
std::vector< Cell > cells
Definition RichardsColumn.hpp:40
double inflow
Definition RichardsColumn.hpp:52
double bottom_factor
Definition RichardsColumn.hpp:51
Definition RichardsColumn.hpp:21
double specific_storage
Definition RichardsColumn.hpp:22
double alpha
Definition RichardsColumn.hpp:22
double n
Definition RichardsColumn.hpp:22
double l
Definition RichardsColumn.hpp:22
double theta_r
Definition RichardsColumn.hpp:22
Definition RichardsColumn.hpp:24
double rtol
Definition RichardsColumn.hpp:27
double max_step
Definition RichardsColumn.hpp:27
int cells_per_layer
Definition RichardsColumn.hpp:26
bool enabled
Definition RichardsColumn.hpp:25
double atol
Definition RichardsColumn.hpp:27
Definition RichardsColumn.hpp:60
int newton
Definition RichardsColumn.hpp:63
int bottom_out_limited
Definition RichardsColumn.hpp:67
double bottom_volume
Definition RichardsColumn.hpp:64
double evaporation
Definition RichardsColumn.hpp:64
std::string error
Definition RichardsColumn.hpp:62
double min_step
Definition RichardsColumn.hpp:64
double balance
Definition RichardsColumn.hpp:64
int accepted
Definition RichardsColumn.hpp:63
double inflow
Definition RichardsColumn.hpp:66
int bottom_in_limited
Definition RichardsColumn.hpp:67
int rejected
Definition RichardsColumn.hpp:63
int rhs
Definition RichardsColumn.hpp:63
double bottom_outflow
Definition RichardsColumn.hpp:65
double bottom_inflow
Definition RichardsColumn.hpp:65
std::vector< Transfer > transfers
Definition RichardsColumn.hpp:68
bool ok
Definition RichardsColumn.hpp:61
Definition RichardsColumn.hpp:56
int from
Definition RichardsColumn.hpp:57
int to
Definition RichardsColumn.hpp:57
double volume
Definition RichardsColumn.hpp:58