rtx-cfd embedded3 items 4–6: field.rs + step/{mod, predictor, projection} (364/700/419 lines) — the host PISO step re-laid from the verified three_d code; gates HELD: MMS + Poiseuille marches value-identical to the 2D embedded solver at nz=1 over 200 steps; 3D MMS orders 0.88 upwind / 1.61 TVD, div ≤ 5e-9; Beltrami 1.08 / 1.25 with face-averaged data, div−mean ≤ 7e-8; Poiseuille |u−û| ≤ 8e-10 at nz 1 and periodic nz 4
CI / Build CPU-Only (Explicit) (push) Failing after 5s
Documentation / Build API Documentation (push) Failing after 5s
Documentation / Build User Guide (push) Successful in 5s
CI / Format Check (push) Failing after 12s
CI / Build (ubuntu-latest) (push) Failing after 2m10s
CI / Clippy Check (push) Failing after 2m25s
Performance Benchmarks / Run Benchmarks (push) Successful in 4m13s
CI / Build (macos-latest) (push) Canceled after 0s
CI / Python Bindings (maturin) (macos-latest) (push) Canceled after 0s
CI / Test (macos-latest) (push) Canceled after 0s
CI / WASM Build + Size Check (push) Canceled after 0s
CI / Distributed Training Tests (push) Canceled after 0s
CI / CI Success (push) Canceled after 0s
CI / Test (ubuntu-latest) (push) Canceled after 0s
CI / Python Bindings (maturin) (ubuntu-latest) (push) Canceled after 0s
CI / Build CPU-Only (Explicit) (push) Failing after 5s
Documentation / Build API Documentation (push) Failing after 5s
Documentation / Build User Guide (push) Successful in 5s
CI / Format Check (push) Failing after 12s
CI / Build (ubuntu-latest) (push) Failing after 2m10s
CI / Clippy Check (push) Failing after 2m25s
Performance Benchmarks / Run Benchmarks (push) Successful in 4m13s
CI / Build (macos-latest) (push) Canceled after 0s
CI / Python Bindings (maturin) (macos-latest) (push) Canceled after 0s
CI / Test (macos-latest) (push) Canceled after 0s
CI / WASM Build + Size Check (push) Canceled after 0s
CI / Distributed Training Tests (push) Canceled after 0s
CI / CI Success (push) Canceled after 0s
CI / Test (ubuntu-latest) (push) Canceled after 0s
CI / Python Bindings (maturin) (ubuntu-latest) (push) Canceled after 0s
Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
765ba6d3f6
commit
8821e18520
@@ -0,0 +1,98 @@
|
||||
//! The 3D staggered field: u on `(nx + 1) × ny × nz` faces, v on
|
||||
//! `nx × (ny + 1) × nz`, w on `nx × ny × (nz + 1)`, p on the cells; flat
|
||||
//! storage (see [`super::Grid`] for the index conventions).
|
||||
|
||||
use super::Grid;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Field {
|
||||
pub grid: Grid,
|
||||
pub u: Vec<f64>,
|
||||
pub v: Vec<f64>,
|
||||
pub w: Vec<f64>,
|
||||
pub p: Vec<f64>,
|
||||
pub u_old: Vec<f64>,
|
||||
pub v_old: Vec<f64>,
|
||||
pub w_old: Vec<f64>,
|
||||
pub u_star: Vec<f64>,
|
||||
pub v_star: Vec<f64>,
|
||||
pub w_star: Vec<f64>,
|
||||
pub p_prime: Vec<f64>,
|
||||
/// The continuity source of the projection.
|
||||
pub sp: Vec<f64>,
|
||||
}
|
||||
|
||||
impl Field {
|
||||
#[must_use]
|
||||
pub fn new(grid: Grid) -> Self {
|
||||
let nu = (grid.nx + 1) * grid.ny * grid.nz;
|
||||
let nv = grid.nx * (grid.ny + 1) * grid.nz;
|
||||
let nw = grid.nx * grid.ny * (grid.nz + 1);
|
||||
let nc = grid.cells();
|
||||
Self {
|
||||
grid,
|
||||
u: vec![0.0; nu],
|
||||
v: vec![0.0; nv],
|
||||
w: vec![0.0; nw],
|
||||
p: vec![0.0; nc],
|
||||
u_old: vec![0.0; nu],
|
||||
v_old: vec![0.0; nv],
|
||||
w_old: vec![0.0; nw],
|
||||
u_star: vec![0.0; nu],
|
||||
v_star: vec![0.0; nv],
|
||||
w_star: vec![0.0; nw],
|
||||
p_prime: vec![0.0; nc],
|
||||
sp: vec![0.0; nc],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update_old_values(&mut self) {
|
||||
self.u_old.copy_from_slice(&self.u);
|
||||
self.v_old.copy_from_slice(&self.v);
|
||||
self.w_old.copy_from_slice(&self.w);
|
||||
}
|
||||
|
||||
pub fn copy_to_starred(&mut self) {
|
||||
self.u_star.copy_from_slice(&self.u);
|
||||
self.v_star.copy_from_slice(&self.v);
|
||||
self.w_star.copy_from_slice(&self.w);
|
||||
}
|
||||
|
||||
/// `max |∇·u|` over the cells (per unit volume).
|
||||
#[must_use]
|
||||
pub fn max_divergence(&self) -> f64 {
|
||||
let g = self.grid;
|
||||
let mut worst = 0.0_f64;
|
||||
for k in 0..g.nz {
|
||||
for j in 0..g.ny {
|
||||
for i in 0..g.nx {
|
||||
let div = (self.u[g.uface(k, j, i + 1)] - self.u[g.uface(k, j, i)]) / g.dx
|
||||
+ (self.v[g.vface(k, j + 1, i)] - self.v[g.vface(k, j, i)]) / g.dy
|
||||
+ (self.w[g.wface(k + 1, j, i)] - self.w[g.wface(k, j, i)]) / g.dz;
|
||||
worst = worst.max(div.abs());
|
||||
}
|
||||
}
|
||||
}
|
||||
worst
|
||||
}
|
||||
|
||||
/// Kinetic energy `½ Σ (u² + v² + w²) dV` over the cells (face values
|
||||
/// averaged to the cell).
|
||||
#[must_use]
|
||||
pub fn kinetic_energy(&self, rho: f64) -> f64 {
|
||||
let g = self.grid;
|
||||
let dv = g.dx * g.dy * g.dz;
|
||||
let mut e = 0.0;
|
||||
for k in 0..g.nz {
|
||||
for j in 0..g.ny {
|
||||
for i in 0..g.nx {
|
||||
let uc = 0.5 * (self.u[g.uface(k, j, i)] + self.u[g.uface(k, j, i + 1)]);
|
||||
let vc = 0.5 * (self.v[g.vface(k, j, i)] + self.v[g.vface(k, j + 1, i)]);
|
||||
let wc = 0.5 * (self.w[g.wface(k, j, i)] + self.w[g.wface(k + 1, j, i)]);
|
||||
e += 0.5 * rho * (uc * uc + vc * vc + wc * wc) * dv;
|
||||
}
|
||||
}
|
||||
}
|
||||
e
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user