60#ifndef OPENSWMM_ENGINE_FV_KERNELS_HPP
61#define OPENSWMM_ENGINE_FV_KERNELS_HPP
73#ifndef OPENSWMM_KERNEL_FN
74#define OPENSWMM_KERNEL_FN inline
113 return s * s * (3.0 - 2.0 * s);
129 const double s3 = s * s * s;
130 return s3 - 0.5 * s3 * s;
283 double& sr)
noexcept {
287 sl = std::min(L.u - L.c, R.u - R.c);
288 sr = std::max(L.u + L.c, R.u + R.c);
307 if (L.press != R.press && L.press < 2 && R.press < 2) {
309 const double da = L.a - R.a;
310 const double w = (da > 0.0) ? (L.q - R.q) / da : sr;
311 sr = std::max(R.u + R.c, std::min(sr, w));
313 const double da = R.a - L.a;
314 const double w = (da > 0.0) ? (R.q - L.q) / da : sl;
315 sl = std::min(L.u - L.c, std::max(sl, w));
319 sl = R.u - 2.0 * R.c;
323 sr = L.u + 2.0 * L.c;
360 double sl = 0.0, sr = 0.0;
362 double fal = 0.0, fql = 0.0, far = 0.0, fqr = 0.0;
369 return (sr * fal - sl * far + sl * sr * (R.a - L.a)) / (sr - sl);
393 double sl = 0.0, sr = 0.0;
398 double fal = 0.0, fql = 0.0, far = 0.0, fqr = 0.0;
415 const double dsr = sr - sl;
416 out.
mass = (sr * fal - sl * far + sl * sr * (R.a - L.a)) / dsr;
417 out.
mom = (sr * fql - sl * fqr + sl * sr * (R.q - L.q)) / dsr;
422 const double den = R.a * (R.u - sr) - L.a * (L.u - sl);
423 if (std::fabs(den) > 1.0e-14) {
424 out.
sstar = (sl * R.a * (R.u - sr) - sr * L.a * (L.u - sl)) / den;
426 const double a_hll = (sr * R.a - sl * L.a - (far - fal)) / dsr;
451 double phi_l,
double phi_r,
bool hllc)
noexcept {
453 return f.mass * ((f.sstar >= 0.0) ? phi_l : phi_r);
462 const double dsr = f.sr - f.sl;
463 return (f.sr * L.q * phi_l - f.sl * R.q * phi_r + f.sl * f.sr * (R.a * phi_r - L.a * phi_l)) /
486 double rough_factor)
noexcept {
487 if (r <= 0.0 || rough_factor <= 0.0)
489 const double r43 = r * std::cbrt(r);
490 const double den = 1.0 + dt * rough_factor * std::fabs(u) / r43;
505 double dt)
noexcept {
506 if (k <= 0.0 || dx <= 0.0)
508 return q / (1.0 + dt * k * std::fabs(u) / (2.0 * dx));
528 double dt)
noexcept {
529 if (k3 <= 0.0 || a <= 0.0)
539 constexpr double kUfVelFloor = 0.01;
540 if (std::fabs(u_old) < kUfVelFloor && std::fabs(q / a) < kUfVelFloor)
542 double qn = (q + k3 * a * u_old) / (1.0 + k3);
543 qn -= dt * k3 * a * grad_term;
544 const double dq = qn - q;
545 const double cap = 0.5 * std::fabs(q);
546 if (std::fabs(dq) > cap)
547 qn = q + ((dq > 0.0) ? cap : -cap);
579 return g.y_full + (a - g.a_crown) / g.t_slot;
591 return g.a_crown + g.t_slot * (h - g.y_full);
606 return g.i1_crown + g.a_crown * (h - g.y_full);
619 const double s = std::fabs(u) + c;
620 return (s > 1.0e-12) ? cfl * dx / s : 1.0e30;
636 if (outflow <= 0.0 || dt <= 0.0)
638 const double take = outflow * dt;
639 const double avail = (vol > 0.0) ? vol : 0.0;
640 return (take <= avail) ? 1.0 : avail / take;
#define OPENSWMM_KERNEL_FN
Definition ExplicitKokkosSurfaceSolver.cpp:22
Option struct for the explicit finite-volume 1D network solver.
SoA storage for the 1D finite-volume network mesh and its state.
Definition FvClosureKernels.hpp:115
OPENSWMM_KERNEL_FN double closureArea(const FvClosure &c, double h) noexcept
Evaluate the closure flow area.
Definition FvClosureKernels.hpp:289
OPENSWMM_KERNEL_FN FaceFlux riemannFlux(const FaceState &L, const FaceState &R) noexcept
Evaluate HLL hydraulic flux and the scalar contact-wave speed.
Definition FvKernels.hpp:388
OPENSWMM_KERNEL_FN double frictionUpdate(double q, double u, double r, double dt, double rough_factor) noexcept
Apply a semi-implicit Manning discharge sink.
Definition FvKernels.hpp:485
OPENSWMM_KERNEL_FN double closureWidth(const FvClosure &c, double h) noexcept
Evaluate the closure area derivative used as top width.
Definition FvClosureKernels.hpp:317
OPENSWMM_KERNEL_FN double closureI1(const FvClosure &c, double h) noexcept
Evaluate the closure hydrostatic first moment.
Definition FvClosureKernels.hpp:345
OPENSWMM_KERNEL_FN void physicalFlux(const FaceState &S, double &fa, double &fq) noexcept
Evaluate the conservative Saint-Venant physical flux of one state.
Definition FvKernels.hpp:339
OPENSWMM_KERNEL_FN double ufUpdate(double q, double a, double u_old, double k3, double grad_term, double dt) noexcept
Apply the bounded unsteady-friction acceleration correction.
Definition FvKernels.hpp:527
OPENSWMM_KERNEL_FN double closureDepthOfArea(const FvClosure &c, double a) noexcept
Invert aggregate closure area using the same forward geometry.
Definition FvClosureKernels.hpp:394
OPENSWMM_KERNEL_FN double widthOfDepth(const FvGeometry &g, double h) noexcept
Evaluate memoryless slot top width at a depth.
Definition FvKernels.hpp:171
OPENSWMM_KERNEL_FN double faceCflDt(double cfl, double dx, double u, double c) noexcept
Compute a local advective/acoustic Courant timestep bound.
Definition FvKernels.hpp:618
OPENSWMM_KERNEL_FN double localLossUpdate(double q, double u, double k, double dx, double dt) noexcept
Apply a semi-implicit entrance/exit momentum loss over an end cell.
Definition FvKernels.hpp:504
OPENSWMM_KERNEL_FN double riemannMassFlux(const FaceState &L, const FaceState &R) noexcept
Evaluate only the HLL volumetric flux for an algebraic node residual.
Definition FvKernels.hpp:357
OPENSWMM_KERNEL_FN void waveSpeeds(const FaceState &L, const FaceState &R, double &sl, double &sr) noexcept
Estimate left and right signal speeds with dry-front and pressure-bore bounds.
Definition FvKernels.hpp:282
OPENSWMM_KERNEL_FN double positivityScale(double vol, double outflow, double dt) noexcept
Limit exported substep volume to the available donor water.
Definition FvKernels.hpp:635
OPENSWMM_KERNEL_FN double hydRadOfDepth(const FvGeometry &g, double h) noexcept
Evaluate memoryless closure friction radius.
Definition FvKernels.hpp:186
OPENSWMM_KERNEL_FN double slotRamp(double s) noexcept
Evaluate the smooth slot-mouth opening fraction.
Definition FvKernels.hpp:108
constexpr double kDryArea
Area floor paired with kDryDepth for the u = Q/A division.
Definition FvKernels.hpp:89
constexpr double kEtaDeadband
Definition FvKernels.hpp:94
OPENSWMM_KERNEL_FN double tpaDepthOfArea(const FvGeometry &g, double a) noexcept
Evaluate the signed-pressure TPA area-to-head extension.
Definition FvKernels.hpp:578
OPENSWMM_KERNEL_FN double areaOfDepth(const FvGeometry &g, double h) noexcept
Evaluate memoryless slot area at a depth.
Definition FvKernels.hpp:155
OPENSWMM_KERNEL_FN double closureHydRad(const FvClosure &c, double h) noexcept
Evaluate the friction hydraulic radius.
Definition FvClosureKernels.hpp:363
OPENSWMM_KERNEL_FN double i1OfDepth(const FvGeometry &g, double h, double area_at_h) noexcept
Evaluate the memoryless closure hydrostatic area integral.
Definition FvKernels.hpp:204
OPENSWMM_KERNEL_FN double speciesFlux(const FaceState &L, const FaceState &R, const FaceFlux &f, double phi_l, double phi_r, bool hllc) noexcept
Evaluate a conservative advected-scalar flux using the hydraulic fan.
Definition FvKernels.hpp:450
OPENSWMM_KERNEL_FN double slotRampIntegral(double s) noexcept
Integrate the normalized slot-mouth opening from zero to s.
Definition FvKernels.hpp:124
OPENSWMM_KERNEL_FN double tpaI1OfDepth(const FvGeometry &g, double h) noexcept
Evaluate the TPA pressure integral without numerical slot-storage pressure.
Definition FvKernels.hpp:605
OPENSWMM_KERNEL_FN double depthOfArea(const FvGeometry &g, double a) noexcept
Invert aggregate area on the memoryless closure.
Definition FvKernels.hpp:221
constexpr double kDryDepth
Definition FvKernels.hpp:86
OPENSWMM_KERNEL_FN double tpaAreaOfDepth(const FvGeometry &g, double h) noexcept
Evaluate aggregate TPA area on the slot line in either pressure direction.
Definition FvKernels.hpp:590
constexpr double kGravity
Definition FvKernels.hpp:81
OPENSWMM_KERNEL_FN double celerity(double a, double t) noexcept
Compute the gravity-wave speed from aggregate area and top width.
Definition FvKernels.hpp:234
Cross-section closure for one conduit's cell chain.
Definition NetworkMeshData.hpp:71
Result of a face flux evaluation.
Definition FvKernels.hpp:259
double mom
F[1] — momentum flux (ft⁴/s²)
Definition FvKernels.hpp:261
double sstar
contact-wave speed; sign selects the species upwind
Definition FvKernels.hpp:262
double mass
F[0] — volumetric flux (cfs)
Definition FvKernels.hpp:260
double sr
right signal speed
Definition FvKernels.hpp:264
double sl
left signal speed (kept for the species flux)
Definition FvKernels.hpp:263
One side of a face after hydrostatic reconstruction.
Definition FvKernels.hpp:245
double c
celerity (ft/s)
Definition FvKernels.hpp:249
double i1
Definition FvKernels.hpp:250
uint8_t press
Definition FvKernels.hpp:255
double a
reconstructed flow area (ft²)
Definition FvKernels.hpp:246
double q
reconstructed discharge (cfs) = a·u
Definition FvKernels.hpp:247
double u
velocity (ft/s)
Definition FvKernels.hpp:248