fix: correct MTHINC normals on non-uniform grids#1401
fix: correct MTHINC normals on non-uniform grids#1401sbryngelson wants to merge 40 commits intoMFlowCode:masterfrom
Conversation
- case.md: add muscl_eps row/description alongside int_comp (MTHINC version) - m_global_parameters.fpp: keep int_comp as integer (0/1/2), add muscl_eps; keep GPU_DECLARE; both GPU_UPDATEs - m_mpi_proxy.fpp: broadcast both int_comp and collision_model as integers - case_validator.py: keep recon_type validation from master; drop stale int_comp=boolean check (superseded by check_interface_compression)
…rface_tension f_thinc_integral_1d used log_cosh(a+h) - log_cosh(a-h) which suffers catastrophic cancellation in single precision when h (= beta*n_transverse/2) is small (interface nearly axis-aligned). Replace with the identity 2*atanh(tanh(a)*tanh(h)), which is algebraically equivalent and numerically stable at all precisions. Fixes the single-precision CI failure on the 2D and 3D MTHINC WENO tests (5126B21F, 4F3722DB). Also add validator rules prohibiting int_comp > 0 with viscous=T or surface_tension=T: the split reconstruction paths in m_rhs prevent s_thinc_compression from ever running in those cases, so permitting the combination would silently produce unsharpened results.
Claude Code ReviewHead SHA: ae74a6a Files changed:
Findings1. GPU correctness bug — Gauss-quadrature constants uninitialized on device (MTHINC only)File: real(wp) :: gq3_pts(3) = [-5e-1_wp*0.7745966692414834_wp, 0._wp, 5e-1_wp*0.7745966692414834_wp]
real(wp) :: gq3_wts(3) = [5._wp/18._wp, 8._wp/18._wp, 5._wp/18._wp]
real(wp) :: ln2 = 0.6931471805599453_wp
$:GPU_DECLARE(create='[gq3_pts, gq3_wts, ln2]')
Fix: add 2. Dead device function —
|
Summary
Builds on #1303 (MTHINC implementation). Fixes two bugs found during review:
int_compincompatible with viscous / surface-tension flowsFix 1: MTHINC normals on non-uniform grids (#1395)
The reference-space normal in
s_compute_mthinc_normalsused a uniform-grid assumption (* 0.5) that gives the wrong direction when cell widths vary. The correct weighting is:On uniform grids this ratio equals
0.5exactly, so all existing tests pass unchanged.Fix 2: int_comp with viscous / surface-tension flows (#1396)
int_comp > 0requires full (non-split) reconstruction, but the viscous and surface-tension RHS paths were calling split reconstruction, silently disabling interface compression. Fixed by routing those paths through the full reconstruction branch and adding a runtime@:PROHIBITguard.New regression test (
7A1719C6)A new golden-file test exercises Fix 1 on a non-uniform grid:
nr_x ≠ 0andnr_y ≠ 0) — only diagonal cells are sensitive to theΔx_jweighting correction; axis-aligned interfaces always normalize to±1regardless of scalingvel(1)=0.5advects the bubble so MTHINC reconstruction produces non-trivial fluxes; 129+ distinct values at t=50 confirm genuine interface evolutionTest plan
5126B21F,4E4FECA9,4F3722DB,4C4F339C)7A1719C6)./mfc.sh precheck -j 8passes./mfc.sh build -t simulation -j 8compiles cleanly