embedded3 S2-6: the transverse gradient from the face at least 0.2 h off the wall (full neighbours over their own distance along the cut partner's normal) — the first form blew up at DFG ny 61 with the fine floor (coefficient ~ 1/d_f); host = device 7.7e-14 with the closures on; Couette linear exactness kept (<= 0.01 h); RTX_E3_OBLIQUE_N rung knob
CI / Build (macos-latest) (push) Waiting to run
CI / Test (macos-latest) (push) Blocked by required conditions
CI / Test (ubuntu-latest) (push) Blocked by required conditions
CI / Python Bindings (maturin) (macos-latest) (push) Blocked by required conditions
CI / Python Bindings (maturin) (ubuntu-latest) (push) Blocked by required conditions
CI / WASM Build + Size Check (push) Blocked by required conditions
CI / Distributed Training Tests (push) Blocked by required conditions
CI / CI Success (push) Blocked by required conditions
CI / Format Check (push) Failing after 4s
CI / Clippy Check (push) Failing after 4s
CI / Build (ubuntu-latest) (push) Failing after 5s
Performance Benchmarks / Run Benchmarks (push) Failing after 5s
Documentation / Build User Guide (push) Successful in 7s
CI / Build CPU-Only (Explicit) (push) Failing after 49s
Documentation / Build API Documentation (push) Failing after 1m1s

Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
Omar Sobh
2026-09-18 16:54:52 -05:00
co-authored by Claude Fable 5.1
parent e9b2e7887b
commit 9c3fac0755
3 changed files with 55 additions and 17 deletions
@@ -16,6 +16,7 @@
#define CUT_INERTIA_FLOOR 0.1 #define CUT_INERTIA_FLOOR 0.1
#define CUT_DISTANCE_FLOOR 0.05 #define CUT_DISTANCE_FLOOR 0.05
#define CUT_DISTANCE_FLOOR_FINE 0.01 #define CUT_DISTANCE_FLOOR_FINE 0.01
#define CUT_TRANSVERSE_FLOOR 0.2
struct E3Cut { struct E3Cut {
const double *a_u, *a_v, *a_w; /* apertures per face */ const double *a_u, *a_v, *a_w; /* apertures per face */
@@ -121,18 +122,31 @@ __device__ double cut_transverse(const E3Params& g, const E3Cut& m, int c, int d
if (!any) return 0.0; if (!any) return 0.0;
double alpha_q, apm_q[3], app_q[3], wall_q[3], distance_q; double alpha_q, apm_q[3], app_q[3], wall_q[3], distance_q;
cut_cv(g, m, c, q[0], q[1], q[2], fq, &alpha_q, apm_q, app_q, wall_q, &distance_q); cut_cv(g, m, c, q[0], q[1], q[2], fq, &alpha_q, apm_q, app_q, wall_q, &distance_q);
/* Explicit, coefficient ~ 1/d_f: the gradient from the faces at least
CUT_TRANSVERSE_FLOOR h off the wall — a FULL neighbour too, over its own
distance along the cut partner's normal; only when neither is that far,
from the cut faces over the floored distance (cut_predictor.rs). */
double h_min = fmin(fmin(g.dx, g.dy), g.dz);
double d_min = CUT_TRANSVERSE_FLOOR * h_min;
double a0 = sqrt(wall[0] * wall[0] + wall[1] * wall[1] + wall[2] * wall[2]);
double aq = sqrt(wall_q[0] * wall_q[0] + wall_q[1] * wall_q[1] + wall_q[2] * wall_q[2]);
int cut0 = a0 > 0.0 && alpha < 1.0, cutq = aq > 0.0 && alpha_q < 1.0;
if (!cut0 && !cutq) return 0.0;
double n0[3], nq[3];
for (int e = 0; e < 3; ++e) { n0[e] = cut0 ? wall[e] / a0 : 0.0; nq[e] = cutq ? wall_q[e] / aq : 0.0; }
if (!cut0) for (int e = 0; e < 3; ++e) n0[e] = nq[e];
if (!cutq) for (int e = 0; e < 3; ++e) nq[e] = n0[e];
int far = distance >= d_min || distance_q >= d_min;
double gr[3] = { 0.0, 0.0, 0.0 }; double gr[3] = { 0.0, 0.0, 0.0 };
double count = 0.0; double count = 0.0;
double a0 = sqrt(wall[0] * wall[0] + wall[1] * wall[1] + wall[2] * wall[2]); if (!((far && distance < d_min) || (!far && !cut0))) {
if (a0 > 0.0 && alpha < 1.0) { double slope = (u0 - ub) / fmax(distance, d_min);
double slope = (u0 - ub) / (distance * a0); for (int e = 0; e < 3; ++e) gr[e] -= slope * n0[e];
for (int e = 0; e < 3; ++e) gr[e] -= slope * wall[e];
count += 1.0; count += 1.0;
} }
double aq = sqrt(wall_q[0] * wall_q[0] + wall_q[1] * wall_q[1] + wall_q[2] * wall_q[2]); if (!((far && distance_q < d_min) || (!far && !cutq))) {
if (aq > 0.0 && alpha_q < 1.0) { double slope = (uq - ubt[fq]) / fmax(distance_q, d_min);
double slope = (uq - ubt[fq]) / (distance_q * aq); for (int e = 0; e < 3; ++e) gr[e] -= slope * nq[e];
for (int e = 0; e < 3; ++e) gr[e] -= slope * wall_q[e];
count += 1.0; count += 1.0;
} }
if (count == 0.0) return 0.0; if (count == 0.0) return 0.0;
@@ -5,6 +5,10 @@
use super::cutwall::CvGeometry; use super::cutwall::CvGeometry;
use super::wall::Mask; use super::wall::Mask;
/// The distance floor inside the explicit transverse gradient (S2-6), in
/// units of the smallest spacing.
pub(in crate::solvers::incompressible::embedded3) const TRANSVERSE_DISTANCE_FLOOR: f64 = 0.2;
impl Mask { impl Mask {
/// The shift of a face's open-part centroid from the face centre: /// The shift of a face's open-part centroid from the face centre:
/// `½h(1 α)` along the wall normal's in-plane part, away from the /// `½h(1 α)` along the wall normal's in-plane part, away from the
@@ -11,6 +11,8 @@
//! carries the inertia floor. //! carries the inertia floor.
use super::{Side, Solver}; use super::{Side, Solver};
use crate::solvers::incompressible::embedded3::closure::TRANSVERSE_DISTANCE_FLOOR;
use crate::solvers::incompressible::embedded3::cutwall::CvGeometry;
use crate::solvers::incompressible::embedded3::cutwall::INERTIA_FLOOR; use crate::solvers::incompressible::embedded3::cutwall::INERTIA_FLOOR;
use crate::solvers::incompressible::embedded3::field::Field; use crate::solvers::incompressible::embedded3::field::Field;
use crate::solvers::incompressible::simple::ConvectionScheme; use crate::solvers::incompressible::simple::ConvectionScheme;
@@ -202,6 +204,7 @@ impl Solver {
// the own direction); the two-point difference then carries // the own direction); the two-point difference then carries
// `∇u · Δs_⊥`, removed with the cut faces' own wall-normal // `∇u · Δs_⊥`, removed with the cut faces' own wall-normal
// gradients `(u U_b)/d_f` (old values: explicit). // gradients `(u U_b)/d_f` (old values: explicit).
let h_min = h[0].min(h[1]).min(h[2]);
let transverse = |q: [i64; 3], uq: f64, sign: f64| -> f64 { let transverse = |q: [i64; 3], uq: f64, sign: f64| -> f64 {
let sq = mask.face_shift(c, q); let sq = mask.face_shift(c, q);
let mut ds = [0.0; 3]; let mut ds = [0.0; 3];
@@ -215,20 +218,37 @@ impl Solver {
} }
let cvq = mask.cv_geometry(c, q); let cvq = mask.cv_geometry(c, q);
let ubq = mask.surface_velocity_at(body, lat.face_position(c, q), c, t_old); let ubq = mask.surface_velocity_at(body, lat.face_position(c, q), c, t_old);
let mut g = [0.0; 3]; // Explicit, with a coefficient ∝ 1/d_f: take the gradient from
let mut count = 0.0; // the faces at least TRANSVERSE_DISTANCE_FLOOR h off the wall —
for (cvk, uk, ubk) in [(&cv, u0, ub), (&cvq, uq, ubq)] { // a FULL neighbour too, over its own distance along the cut
// partner's normal (a linear field gives the same gradient on
// every one of them); only when neither is that far, from the
// cut faces over the floored distance.
let d_min = TRANSVERSE_DISTANCE_FLOOR * h_min;
let unit = |cvk: &CvGeometry| {
let a = (cvk.wall[0] * cvk.wall[0] let a = (cvk.wall[0] * cvk.wall[0]
+ cvk.wall[1] * cvk.wall[1] + cvk.wall[1] * cvk.wall[1]
+ cvk.wall[2] * cvk.wall[2]) + cvk.wall[2] * cvk.wall[2])
.sqrt(); .sqrt();
if a > 0.0 && cvk.alpha < 1.0 { (a > 0.0 && cvk.alpha < 1.0)
let slope = (uk - ubk) / (cvk.distance * a); .then(|| [cvk.wall[0] / a, cvk.wall[1] / a, cvk.wall[2] / a])
for e2 in 0..3 { };
g[e2] -= slope * cvk.wall[e2]; let (n0, nq) = (unit(&cv), unit(&cvq));
} let faces = [(&cv, u0, ub, n0.or(nq)), (&cvq, uq, ubq, nq.or(n0))];
count += 1.0; let far = faces.iter().any(|f| f.3.is_some() && f.0.distance >= d_min);
let mut g = [0.0; 3];
let mut count = 0.0;
for (cvk, uk, ubk, normal) in faces {
let Some(nk) = normal else { continue };
let is_cut = unit(cvk).is_some();
if far && cvk.distance < d_min || !far && !is_cut {
continue;
} }
let slope = (uk - ubk) / cvk.distance.max(d_min);
for e2 in 0..3 {
g[e2] -= slope * nk[e2];
}
count += 1.0;
} }
if count == 0.0 { if count == 0.0 {
return 0.0; return 0.0;