From fc8d69af2909fc54d99c48b3f4babef01f2c0725 Mon Sep 17 00:00:00 2001 From: Omar Sobh Date: Thu, 17 Sep 2026 21:11:16 -0500 Subject: [PATCH] embedded3 S2-3b: the flag driver's span knob (full width = the 2D geometry extruded) Co-Authored-By: Claude Fable 5.1 --- .../rtx-cfd/tests/embedded3_flag_wake.rs | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/crates/specialized/rtx-cfd/tests/embedded3_flag_wake.rs b/crates/specialized/rtx-cfd/tests/embedded3_flag_wake.rs index 060942d..3c041f4 100644 --- a/crates/specialized/rtx-cfd/tests/embedded3_flag_wake.rs +++ b/crates/specialized/rtx-cfd/tests/embedded3_flag_wake.rs @@ -95,13 +95,23 @@ fn flag_2d(x: f64, y: f64, t: f64) -> (f64, f64) { (best - FLAG_HALF, v_best) } +/// The flag's span: `RTX_E3_FLAG_SPAN` (default 0.2); at the channel's +/// full width the flag is the 2D geometry extruded (S2-3b). +fn flag_span() -> f64 { + env_f("RTX_E3_FLAG_SPAN", FLAG_SPAN) +} + /// The flag in 3D: the extruded capsule cut to the span with edges -/// rounded to radius `r`. +/// rounded to radius `r` (no cut at the full width). fn flag_3d(x: f64, y: f64, z: f64, t: f64, r: f64) -> (f64, f64) { let (d2, v) = flag_2d(x, y, t); + let span = flag_span(); + if span >= H { + return (d2, v); + } let zc = 0.5 * H; let q1 = d2 + r; - let q2 = (z - zc).abs() - 0.5 * FLAG_SPAN + r; + let q2 = (z - zc).abs() - 0.5 * span + r; let outside = (q1.max(0.0).powi(2) + q2.max(0.0).powi(2)).sqrt(); (outside + q1.max(q2).min(0.0) - r, v) } @@ -174,7 +184,8 @@ fn flag_wake_on_the_device() { } solver.initialize(&mut field); println!( - " flag wake ny {ny}: {nx}×{ny}×{nz} = {} cells, h {h:.4e}, dt {dt:.3e}, {periods} periods = {t_end:.3} s, {} steps", + " flag wake ny {ny} (span {}): {nx}×{ny}×{nz} = {} cells, h {h:.4e}, dt {dt:.3e}, {periods} periods = {t_end:.3} s, {} steps", + flag_span(), g.cells(), (t_end / dt).ceil() as usize ); @@ -256,8 +267,9 @@ fn flag_wake_on_the_device() { } } if phase_due { + let tag = if flag_span() >= H { "full" } else { "free" }; let path = std::path::Path::new(vtk_dir.as_ref().unwrap()) - .join(format!("flag_ny{ny}_phase{next_phase:02}.vtk")); + .join(format!("flag_{tag}_ny{ny}_phase{next_phase:02}.vtk")); write_vtk(&path, &field, Some(mask)).expect("vtk"); next_phase += 1; }