embedded3 S2-2b: the moving path's host work 5.0 s → 0.6 s per step at 1.45 M cells, bit-identical — Problem::diagonals (the per-cell link diagonal was cells × links: 1.8 s twice per step), counting CSR + rayon in the device tables, rayon in the cut geometry builder; RTX_E3_MOVING_PROFILE laps
CI / Build CPU-Only (Explicit) (push) Failing after 4s
CI / Clippy Check (push) Failing after 5s
Documentation / Build User Guide (push) Successful in 5s
CI / Format Check (push) Failing after 11s
Documentation / Build API Documentation (push) Failing after 1m34s
Performance Benchmarks / Run Benchmarks (push) Successful in 1m54s
CI / Build (ubuntu-latest) (push) Failing after 2m11s
CI / Build (macos-latest) (push) Canceled after 0s
CI / Test (macos-latest) (push) Canceled after 0s
CI / Test (ubuntu-latest) (push) Canceled after 0s
CI / Python Bindings (maturin) (macos-latest) (push) Canceled after 0s
CI / Python Bindings (maturin) (ubuntu-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 / Build CPU-Only (Explicit) (push) Failing after 4s
CI / Clippy Check (push) Failing after 5s
Documentation / Build User Guide (push) Successful in 5s
CI / Format Check (push) Failing after 11s
Documentation / Build API Documentation (push) Failing after 1m34s
Performance Benchmarks / Run Benchmarks (push) Successful in 1m54s
CI / Build (ubuntu-latest) (push) Failing after 2m11s
CI / Build (macos-latest) (push) Canceled after 0s
CI / Test (macos-latest) (push) Canceled after 0s
CI / Test (ubuntu-latest) (push) Canceled after 0s
CI / Python Bindings (maturin) (macos-latest) (push) Canceled after 0s
CI / Python Bindings (maturin) (ubuntu-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
Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
99e4a7214b
commit
cdd5ad0b66
@@ -59,26 +59,32 @@ impl CutGeometry {
|
||||
let g = grid;
|
||||
let (nx, ny, nz, dx, dy, dz) = (g.nx, g.ny, g.nz, g.dx, g.dy, g.dz);
|
||||
let n_nodes = (nx + 1) * (ny + 1) * (nz + 1);
|
||||
// Every loop below is per-index with read-only inputs: rayon (S2-2b),
|
||||
// the same arithmetic per entry.
|
||||
use rayon::prelude::*;
|
||||
let mut phi = vec![0.0; n_nodes];
|
||||
let mut bound = vec![0.0; n_nodes];
|
||||
for k in 0..=nz {
|
||||
for j in 0..=ny {
|
||||
for i in 0..=nx {
|
||||
let n = Self::node(g, k, j, i);
|
||||
if let Some((p, band, motion)) = prev {
|
||||
let b = p.bound[n] - motion;
|
||||
if b > band {
|
||||
phi[n] = p.phi[n];
|
||||
bound[n] = b;
|
||||
continue;
|
||||
}
|
||||
phi.par_iter_mut()
|
||||
.zip(bound.par_iter_mut())
|
||||
.enumerate()
|
||||
.for_each(|(n, (phi_n, bound_n))| {
|
||||
let (k, j, i) = (
|
||||
n / ((ny + 1) * (nx + 1)),
|
||||
(n / (nx + 1)) % (ny + 1),
|
||||
n % (nx + 1),
|
||||
);
|
||||
if let Some((p, band, motion)) = prev {
|
||||
let b = p.bound[n] - motion;
|
||||
if b > band {
|
||||
*phi_n = p.phi[n];
|
||||
*bound_n = b;
|
||||
return;
|
||||
}
|
||||
let v = body.phi(i as f64 * dx, j as f64 * dy, k as f64 * dz, t);
|
||||
phi[n] = v;
|
||||
bound[n] = v.abs();
|
||||
}
|
||||
}
|
||||
}
|
||||
let v = body.phi(i as f64 * dx, j as f64 * dy, k as f64 * dz, t);
|
||||
*phi_n = v;
|
||||
*bound_n = v.abs();
|
||||
});
|
||||
let corner = |k: usize, j: usize, i: usize| phi[Self::node(g, k, j, i)];
|
||||
// Face apertures: a face's two triangles along the diagonal from its
|
||||
// (0, 0) to its (1, 1) corner in the face's own (a, b) order — the
|
||||
@@ -113,51 +119,51 @@ impl CutGeometry {
|
||||
let mut d_u = vec![0.0; (nx + 1) * ny * nz];
|
||||
let mut d_v = vec![0.0; nx * (ny + 1) * nz];
|
||||
let mut d_w = vec![0.0; nx * ny * (nz + 1)];
|
||||
for k in 0..nz {
|
||||
for j in 0..ny {
|
||||
for i in 0..=nx {
|
||||
// x-face at i: corners (j, k), (j+1, k), (j, k+1), (j+1, k+1)
|
||||
let (q00, q10, q01, q11) = (
|
||||
corner(k, j, i),
|
||||
corner(k, j + 1, i),
|
||||
corner(k + 1, j, i),
|
||||
corner(k + 1, j + 1, i),
|
||||
);
|
||||
a_u[g.uface(k, j, i)] = quad_fraction(q00, q10, q01, q11);
|
||||
d_u[g.uface(k, j, i)] = 0.25 * (q00 + q10 + q01 + q11);
|
||||
}
|
||||
}
|
||||
}
|
||||
for k in 0..nz {
|
||||
for j in 0..=ny {
|
||||
for i in 0..nx {
|
||||
// y-face at j: corners (i, k), (i+1, k), (i, k+1), (i+1, k+1)
|
||||
let (q00, q10, q01, q11) = (
|
||||
corner(k, j, i),
|
||||
corner(k, j, i + 1),
|
||||
corner(k + 1, j, i),
|
||||
corner(k + 1, j, i + 1),
|
||||
);
|
||||
a_v[g.vface(k, j, i)] = quad_fraction(q00, q10, q01, q11);
|
||||
d_v[g.vface(k, j, i)] = 0.25 * (q00 + q10 + q01 + q11);
|
||||
}
|
||||
}
|
||||
}
|
||||
for k in 0..=nz {
|
||||
for j in 0..ny {
|
||||
for i in 0..nx {
|
||||
// z-face at k: corners (i, j), (i+1, j), (i, j+1), (i+1, j+1)
|
||||
let (q00, q10, q01, q11) = (
|
||||
corner(k, j, i),
|
||||
corner(k, j, i + 1),
|
||||
corner(k, j + 1, i),
|
||||
corner(k, j + 1, i + 1),
|
||||
);
|
||||
a_w[g.wface(k, j, i)] = quad_fraction(q00, q10, q01, q11);
|
||||
d_w[g.wface(k, j, i)] = 0.25 * (q00 + q10 + q01 + q11);
|
||||
}
|
||||
}
|
||||
}
|
||||
a_u.par_iter_mut()
|
||||
.zip(d_u.par_iter_mut())
|
||||
.enumerate()
|
||||
.for_each(|(f, (a, d))| {
|
||||
// x-face at i: corners (j, k), (j+1, k), (j, k+1), (j+1, k+1)
|
||||
let (k, j, i) = (f / (ny * (nx + 1)), (f / (nx + 1)) % ny, f % (nx + 1));
|
||||
let (q00, q10, q01, q11) = (
|
||||
corner(k, j, i),
|
||||
corner(k, j + 1, i),
|
||||
corner(k + 1, j, i),
|
||||
corner(k + 1, j + 1, i),
|
||||
);
|
||||
*a = quad_fraction(q00, q10, q01, q11);
|
||||
*d = 0.25 * (q00 + q10 + q01 + q11);
|
||||
});
|
||||
a_v.par_iter_mut()
|
||||
.zip(d_v.par_iter_mut())
|
||||
.enumerate()
|
||||
.for_each(|(f, (a, d))| {
|
||||
// y-face at j: corners (i, k), (i+1, k), (i, k+1), (i+1, k+1)
|
||||
let (k, j, i) = (f / ((ny + 1) * nx), (f / nx) % (ny + 1), f % nx);
|
||||
let (q00, q10, q01, q11) = (
|
||||
corner(k, j, i),
|
||||
corner(k, j, i + 1),
|
||||
corner(k + 1, j, i),
|
||||
corner(k + 1, j, i + 1),
|
||||
);
|
||||
*a = quad_fraction(q00, q10, q01, q11);
|
||||
*d = 0.25 * (q00 + q10 + q01 + q11);
|
||||
});
|
||||
a_w.par_iter_mut()
|
||||
.zip(d_w.par_iter_mut())
|
||||
.enumerate()
|
||||
.for_each(|(f, (a, d))| {
|
||||
// z-face at k: corners (i, j), (i+1, j), (i, j+1), (i+1, j+1)
|
||||
let (k, j, i) = (f / (ny * nx), (f / nx) % ny, f % nx);
|
||||
let (q00, q10, q01, q11) = (
|
||||
corner(k, j, i),
|
||||
corner(k, j, i + 1),
|
||||
corner(k, j + 1, i),
|
||||
corner(k, j + 1, i + 1),
|
||||
);
|
||||
*a = quad_fraction(q00, q10, q01, q11);
|
||||
*d = 0.25 * (q00 + q10 + q01 + q11);
|
||||
});
|
||||
// Cell volumes by the Kuhn split: the six tetrahedra around the
|
||||
// diagonal (0,0,0)–(1,1,1) in unit-cube coordinates.
|
||||
let mut vol = vec![0.0; g.cells()];
|
||||
@@ -170,36 +176,36 @@ impl CutGeometry {
|
||||
[[0, 0, 0], [0, 0, 1], [1, 0, 1], [1, 1, 1]],
|
||||
[[0, 0, 0], [0, 0, 1], [0, 1, 1], [1, 1, 1]],
|
||||
];
|
||||
for k in 0..nz {
|
||||
for j in 0..ny {
|
||||
for i in 0..nx {
|
||||
let mut fluid = 0.0;
|
||||
for tet in &KUHN {
|
||||
let pts: Vec<[f64; 3]> = tet
|
||||
.iter()
|
||||
.map(|c| [c[0] as f64, c[1] as f64, c[2] as f64])
|
||||
.collect();
|
||||
let vals: Vec<f64> = tet
|
||||
.iter()
|
||||
.map(|c| corner(k + c[2], j + c[1], i + c[0]))
|
||||
.collect();
|
||||
fluid += tet_fluid_volume(&pts, &vals);
|
||||
}
|
||||
// The six tets fill the unit cube (volume 1).
|
||||
let idx = g.cell(k, j, i);
|
||||
vol[idx] = fluid;
|
||||
let ax = dy * dz;
|
||||
let ay = dx * dz;
|
||||
let az = dx * dy;
|
||||
// Outward normals of the cell's faces times their fluid area,
|
||||
// summed; the wall closes the fluid part of the cell.
|
||||
let sx = (a_u[g.uface(k, j, i + 1)] - a_u[g.uface(k, j, i)]) * ax;
|
||||
let sy = (a_v[g.vface(k, j + 1, i)] - a_v[g.vface(k, j, i)]) * ay;
|
||||
let sz = (a_w[g.wface(k + 1, j, i)] - a_w[g.wface(k, j, i)]) * az;
|
||||
wall[idx] = [-sx, -sy, -sz];
|
||||
}
|
||||
let cell_fluid = |k: usize, j: usize, i: usize| -> f64 {
|
||||
let mut fluid = 0.0;
|
||||
for tet in &KUHN {
|
||||
let pts: Vec<[f64; 3]> = tet
|
||||
.iter()
|
||||
.map(|c| [c[0] as f64, c[1] as f64, c[2] as f64])
|
||||
.collect();
|
||||
let vals: Vec<f64> = tet
|
||||
.iter()
|
||||
.map(|c| corner(k + c[2], j + c[1], i + c[0]))
|
||||
.collect();
|
||||
fluid += tet_fluid_volume(&pts, &vals);
|
||||
}
|
||||
}
|
||||
fluid
|
||||
};
|
||||
let (ax, ay, az) = (dy * dz, dx * dz, dx * dy);
|
||||
vol.par_iter_mut()
|
||||
.zip(wall.par_iter_mut())
|
||||
.enumerate()
|
||||
.for_each(|(idx, (v, w))| {
|
||||
let (k, j, i) = (idx / (ny * nx), (idx / nx) % ny, idx % nx);
|
||||
// The six tets fill the unit cube (volume 1).
|
||||
*v = cell_fluid(k, j, i);
|
||||
// Outward normals of the cell's faces times their fluid area,
|
||||
// summed; the wall closes the fluid part of the cell.
|
||||
let sx = (a_u[g.uface(k, j, i + 1)] - a_u[g.uface(k, j, i)]) * ax;
|
||||
let sy = (a_v[g.vface(k, j + 1, i)] - a_v[g.vface(k, j, i)]) * ay;
|
||||
let sz = (a_w[g.wface(k + 1, j, i)] - a_w[g.wface(k, j, i)]) * az;
|
||||
*w = [-sx, -sy, -sz];
|
||||
});
|
||||
Self {
|
||||
grid,
|
||||
phi,
|
||||
|
||||
Reference in New Issue
Block a user