embedded3 item 12: the DFG 3D-2Z device driver (loads by both routes, Δp, settle criterion, CSV) and the VTK instant export
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 / Test (ubuntu-latest) (push) Blocked by required conditions
CI / Python Bindings (maturin) (macos-latest) (push) Blocked by required conditions
CI / Build (macos-latest) (push) Waiting to run
CI / Test (macos-latest) (push) Blocked by required conditions
CI / Build (ubuntu-latest) (push) Failing after 3s
CI / Build CPU-Only (Explicit) (push) Failing after 3s
Documentation / Build User Guide (push) Successful in 4s
Documentation / Build API Documentation (push) Failing after 4s
CI / Format Check (push) Failing after 11s
CI / Clippy Check (push) Failing after 30s
Performance Benchmarks / Run Benchmarks (push) Successful in 2m6s

Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
Omar Sobh
2026-09-17 17:24:38 -05:00
co-authored by Claude Fable 5.1
parent 3b3d6c84c0
commit 338d66f85e
3 changed files with 246 additions and 0 deletions
@@ -0,0 +1,55 @@
//! VTK legacy `STRUCTURED_POINTS` export of an instant: cell-centred
//! velocity (face values averaged), pressure, and the fluid fraction /
//! mask (1 fluid, 0 solid) — for ParaView and the viewer's 3D wake.
use super::field::Field;
use super::wall::Mask;
use std::io::{BufWriter, Write};
/// Write `field` (and the mask's fluid fraction when given) at `path`.
pub fn write_vtk(
path: &std::path::Path,
field: &Field,
mask: Option<&Mask>,
) -> std::io::Result<()> {
let g = field.grid;
let (nx, ny, nz) = (g.nx, g.ny, g.nz);
let mut out = BufWriter::new(std::fs::File::create(path)?);
writeln!(out, "# vtk DataFile Version 3.0")?;
writeln!(out, "embedded3 instant")?;
writeln!(out, "ASCII")?;
writeln!(out, "DATASET STRUCTURED_POINTS")?;
writeln!(out, "DIMENSIONS {nx} {ny} {nz}")?;
writeln!(out, "ORIGIN {} {} {}", 0.5 * g.dx, 0.5 * g.dy, 0.5 * g.dz)?;
writeln!(out, "SPACING {} {} {}", g.dx, g.dy, g.dz)?;
writeln!(out, "POINT_DATA {}", g.cells())?;
writeln!(out, "VECTORS velocity double")?;
for k in 0..nz {
for j in 0..ny {
for i in 0..nx {
let uc = 0.5 * (field.u[g.uface(k, j, i)] + field.u[g.uface(k, j, i + 1)]);
let vc = 0.5 * (field.v[g.vface(k, j, i)] + field.v[g.vface(k, j + 1, i)]);
let wc = 0.5 * (field.w[g.wface(k, j, i)] + field.w[g.wface(k + 1, j, i)]);
writeln!(out, "{uc:.6e} {vc:.6e} {wc:.6e}")?;
}
}
}
writeln!(out, "SCALARS pressure double 1")?;
writeln!(out, "LOOKUP_TABLE default")?;
for &p in &field.p {
writeln!(out, "{p:.6e}")?;
}
if let Some(m) = mask {
writeln!(out, "SCALARS fluid double 1")?;
writeln!(out, "LOOKUP_TABLE default")?;
for idx in 0..g.cells() {
let f = if m.is_fluid_cell(idx) {
m.vol(idx)
} else {
0.0
};
writeln!(out, "{f:.4}")?;
}
}
out.flush()
}
@@ -9,6 +9,7 @@
pub mod body;
pub mod cut;
pub mod cutwall;
pub mod export_vtk;
pub mod field;
pub mod grid;
pub mod impose;
@@ -19,6 +20,7 @@ pub mod wall;
pub use body::{Body, SurfaceSample};
pub use cut::CutGeometry;
pub use export_vtk::write_vtk;
pub use field::Field;
pub use grid::Grid;
pub use loads::SurfaceForce;