embedded3 PERF-3 P1-3 (f): the mask build's whole-grid scans as parallel per-entry maps (cell classification with the anchor as the smallest fluid index, the three face-kind tables, the merging scan's small flags, the centroid-shift table per face) — slab flag ny 62 CSV byte-identical, device moving/cg green; ny 124 rebuild block 2,680 → 2,569 ms per step (build_mask 409 → 309)
CI / Build CPU-Only (Explicit) (push) Failing after 4s
Documentation / Build API Documentation (push) Failing after 5s
Documentation / Build User Guide (push) Successful in 4s
CI / Format Check (push) Failing after 14s
CI / Clippy Check (push) Failing after 54s
CI / Build (ubuntu-latest) (push) Failing after 1m44s
Performance Benchmarks / Run Benchmarks (push) Successful in 2m4s
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
Documentation / Build API Documentation (push) Failing after 5s
Documentation / Build User Guide (push) Successful in 4s
CI / Format Check (push) Failing after 14s
CI / Clippy Check (push) Failing after 54s
CI / Build (ubuntu-latest) (push) Failing after 1m44s
Performance Benchmarks / Run Benchmarks (push) Successful in 2m4s
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
5a376630a7
commit
44caeb8110
@@ -128,35 +128,31 @@ impl Mask {
|
||||
let (nx, ny, nz) = (g.nx, g.ny, g.nz);
|
||||
let periodic = b.z0 == Side::Periodic;
|
||||
let allowed = |side: Side| matches!(side, Side::Velocity | Side::Periodic | Side::SlipWall);
|
||||
let mut cell_fluid = vec![true; g.cells()];
|
||||
let mut fluid_cells = 0;
|
||||
let mut anchor = None;
|
||||
for k in 0..nz {
|
||||
for j in 0..ny {
|
||||
for i in 0..nx {
|
||||
let idx = g.cell(k, j, i);
|
||||
let fluid = cut.vol[idx] > 0.0;
|
||||
cell_fluid[idx] = fluid;
|
||||
if fluid {
|
||||
fluid_cells += 1;
|
||||
if anchor.is_none() {
|
||||
anchor = Some(idx);
|
||||
}
|
||||
} else {
|
||||
let touches = (i == 0 && !allowed(b.x0))
|
||||
|| (i + 1 == nx && !allowed(b.x1))
|
||||
|| (j == 0 && !allowed(b.y0))
|
||||
|| (j + 1 == ny && !allowed(b.y1))
|
||||
|| (k == 0 && !allowed(b.z0))
|
||||
|| (k + 1 == nz && !allowed(b.z1));
|
||||
if touches {
|
||||
return Err(format!(
|
||||
"embedded body reaches a domain side that is not a Velocity/Periodic side at cell ({k}, {j}, {i})"
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
// P1-3 (f): the whole-grid classifications as parallel per-entry
|
||||
// maps (the same values; the anchor is the smallest fluid index, the
|
||||
// serial loop's first).
|
||||
use rayon::prelude::*;
|
||||
let nxy = nx * ny;
|
||||
let cell_fluid: Vec<bool> = cut.vol.par_iter().map(|&v| v > 0.0).collect();
|
||||
let fluid_cells = cell_fluid.par_iter().filter(|&&f| f).count();
|
||||
let anchor = (0..g.cells()).into_par_iter().find_first(|&idx| cell_fluid[idx]);
|
||||
let touching = (0..g.cells()).into_par_iter().find_first(|&idx| {
|
||||
if cell_fluid[idx] {
|
||||
return false;
|
||||
}
|
||||
let (k, j, i) = (idx / nxy, (idx % nxy) / nx, idx % nx);
|
||||
(i == 0 && !allowed(b.x0))
|
||||
|| (i + 1 == nx && !allowed(b.x1))
|
||||
|| (j == 0 && !allowed(b.y0))
|
||||
|| (j + 1 == ny && !allowed(b.y1))
|
||||
|| (k == 0 && !allowed(b.z0))
|
||||
|| (k + 1 == nz && !allowed(b.z1))
|
||||
});
|
||||
if let Some(idx) = touching {
|
||||
let (k, j, i) = (idx / nxy, (idx % nxy) / nx, idx % nx);
|
||||
return Err(format!(
|
||||
"embedded body reaches a domain side that is not a Velocity/Periodic side at cell ({k}, {j}, {i})"
|
||||
));
|
||||
}
|
||||
let Some(anchor) = anchor else {
|
||||
return Err("embedded body covers the whole domain".into());
|
||||
@@ -168,32 +164,28 @@ impl Mask {
|
||||
FaceKind::Solid
|
||||
}
|
||||
};
|
||||
let mut u_kind = vec![FaceKind::Fluid; g.n_ufaces()];
|
||||
let mut v_kind = vec![FaceKind::Fluid; g.n_vfaces()];
|
||||
let mut w_kind = vec![FaceKind::Fluid; g.n_wfaces()];
|
||||
for k in 0..nz {
|
||||
for j in 0..ny {
|
||||
for i in 1..nx {
|
||||
let f = g.uface(k, j, i);
|
||||
u_kind[f] = kind(cut.a_u[f]);
|
||||
}
|
||||
}
|
||||
for j in 1..ny {
|
||||
for i in 0..nx {
|
||||
let f = g.vface(k, j, i);
|
||||
v_kind[f] = kind(cut.a_v[f]);
|
||||
}
|
||||
}
|
||||
}
|
||||
let w_range = if periodic { 0..nz + 1 } else { 1..nz };
|
||||
for k in w_range {
|
||||
for j in 0..ny {
|
||||
for i in 0..nx {
|
||||
let f = g.wface(k, j, i);
|
||||
w_kind[f] = kind(cut.a_w[f]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Domain-side faces keep `Fluid` (the serial loops skipped them).
|
||||
let u_kind: Vec<FaceKind> = (0..g.n_ufaces())
|
||||
.into_par_iter()
|
||||
.map(|f| {
|
||||
let i = f % (nx + 1);
|
||||
if i == 0 || i == nx { FaceKind::Fluid } else { kind(cut.a_u[f]) }
|
||||
})
|
||||
.collect();
|
||||
let v_kind: Vec<FaceKind> = (0..g.n_vfaces())
|
||||
.into_par_iter()
|
||||
.map(|f| {
|
||||
let j = (f / nx) % (ny + 1);
|
||||
if j == 0 || j == ny { FaceKind::Fluid } else { kind(cut.a_v[f]) }
|
||||
})
|
||||
.collect();
|
||||
let w_kind: Vec<FaceKind> = (0..g.n_wfaces())
|
||||
.into_par_iter()
|
||||
.map(|f| {
|
||||
let k = f / nxy;
|
||||
if !periodic && (k == 0 || k == nz) { FaceKind::Fluid } else { kind(cut.a_w[f]) }
|
||||
})
|
||||
.collect();
|
||||
let mut mask = Self {
|
||||
grid: g,
|
||||
periodic_z: periodic,
|
||||
@@ -254,9 +246,13 @@ impl Mask {
|
||||
.ok()
|
||||
.and_then(|v| v.parse().ok())
|
||||
.unwrap_or(MERGE_FRACTION);
|
||||
let small: Vec<bool> = (0..n)
|
||||
.map(|idx| self.cell_active(idx) && frac(idx) < threshold)
|
||||
.collect();
|
||||
let small: Vec<bool> = {
|
||||
use rayon::prelude::*;
|
||||
(0..n)
|
||||
.into_par_iter()
|
||||
.map(|idx| self.cell_active(idx) && frac(idx) < threshold)
|
||||
.collect()
|
||||
};
|
||||
let mut master = vec![usize::MAX; n];
|
||||
for idx in (0..n).filter(|&i| small[i]) {
|
||||
let (k, j, i) = g.kji(idx);
|
||||
|
||||
Reference in New Issue
Block a user