Skip to content

Batched fixes: serial old_ic restart, IB overlap-cell rank independence, IGR 1D, Taylor-Green pressure, moment of inertia, and 9 more - #2514

Merged
sbryngelson merged 16 commits into
MFlowCode:masterfrom
sbryngelson:fixes-batch
Nov 26, 2026

Conversation

@sbryngelson

@sbryngelson sbryngelson commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Contribution Policy

All contributions are expected to demonstrate:

  • A clear understanding of the codebase
  • Alignment with product direction
  • Thoughtful reasoning behind changes
  • Evidence of real-world usage or hands-on experience with the problem

If these expectations are not met, we would prefer to implement the changes ourselves rather than spend time reviewing low-effort submissions.

Summary

This PR batches two streams of small fixes. The PR also carries #2486's override_tol_single harness change, with only the harness, unit-test and doc parts. Each fix is the smallest change that resolves its issue, has its own commit, and was checked directly (before/after numbers on each issue). One golden regeneration covers everything, done on the exact tree pushed here.

Closes #2493, closes #2494, closes #2463, closes #2465, closes #2358, closes #2433, closes #1907, closes #1909, closes #1911, closes #1876, closes #2063, closes #2068.
Part of #1994 (the cross-rank sum of the moment is still open) and #2083 (one whitespace-only item no longer applies).

Not in this PR:

Changes

Part 1: small fixes

  • examples/2D_jet_in_crossflow fails validation as shipped (MUSCL with a characteristic bc_x%end); precheck misses it #2493 — jet-in-crossflow example and precheck. The deck examples/2D_jet_in_crossflow/case_2D_jicf.py is now case.py, and its outflow bc_x%end is -3 instead of -12. The free stream is Mach 2.5, and with MUSCL the characteristic BC was silently ignored (s_cbc is WENO-only). Precheck now fails when a tracked example directory has no case.py (examples/scaling/ is exempt). It also fails when an example violates a pre_process or simulation constraint: the batched ./mfc.sh validate used to list such violations and still exit 0. All 230 decks pass. The jet example uses an analytic inflow profile (a case-specific build), so it joins the analytic examples skipped by the Example suite.
  • Serial-I/O restart via pre_process old_ic fails: 'I/O past end of record' (reads a larger array than the restart holds) #2494 — serial-I/O restart through pre_process old_ic.
    • pre_process read the whole buffered q_cons_vf(i)%sf, but simulation writes only the interior record ("I/O past end of record"). It now reads (0:m, 0:n, 0:p).
    • Behind that, the serial writers opened with STATUS = 'old' under old_grid, in a step directory that was just recreated empty ("Cannot open file"). Both writers now use STATUS = 'replace'; the same fix is in s_write_serial_boundary_condition_files, whose now-unused old_grid_in argument is removed.
    • New test: Restart Roundtrip -> 1D -> pre_process old_ic. pre_process old_ic rewrites the mid-run save as step 0, simulation finishes the run, and the result must match the straight run.
  • IGR: 1D cases segfault (validator accepts igr with n = 0); Sod strip needs elliptic_smoothing #2463 — IGR in 1D. check_igr refuses igr with n = 0 (m_igr has no 1D path; the case segfaulted). The docs say IGR is 2D/3D only, and that a sharp initial jump needs elliptic_smoothing.
  • 2D Taylor-Green patch (geometry 20): initial pressure amplitude is 1/4 of the exact solution #2465 — 2D Taylor-Green pressure. The patch now sets p = pres + (cos(2x/L0) + cos(2y/L0)) rho U0^2/4, the exact balance (it was 1/4 of the amplitude, with /L0 misplaced). The initial-pressure error at 32 cells drops from 4.5e-3 to 2.9e-11. The viscous decay check is unchanged at the printed digits.
  • Reacting mixing-layer examples: one shared IC cache directory is overwritten by a concurrent case.py evaluation (tests C4EB58A8, 56F8C4BC) #2358 — mixing-layer IC cache. IC files go to IC/<hash of the cache key>/ and are written atomically (temporary name + os.replace), through two helpers in toolchain/mfc/flamelet.py used by all three mixing-layer examples.
  • IBM: ib_mass_relax return depends on the rank count when a contact sits exactly on a rank seam #2433 — rank dependence at a contact on a seam. A cell inside two bodies took the last body in the rank's local slot order, and that order depends on the decomposition. Between two bodies the cell now takes the larger encoded id, as the many_ib_patch_parallelism path already did. Between periodic images of one body it keeps the later image, as before: the image loops run in the same order on every rank. A first version that took the max there too changed 2D -> IBM -> Plane Poiseuille -> ib_wall_order=2 (slabs longer than the period) by 3.7e-4, so that case was left as it was. The change is per cell, with no communication. Generic head-on pairs whose overlap reaches a rank's first cell differed by 1.27 to 2.12 (relative, all fields) between 1 and 2/4 ranks, with or without ib_mass_relax; they now agree to 5e-12 to 5e-11. One-rank results are bitwise unchanged. New 2-rank test: IBM -> Collision -> Overlap cell on a rank seam.

Part 2: small fixes

Golden changes

All goldens were generated on this branch's exact source (rebased onto master 73816da; #2492 changed no Fortran), with Phoenix GNU 12.3 + OpenMPI 4.1.5 (p-cpu, double precision).

Test Change Why
09FDDC81 2D -> 1 Fluid(s) -> IBM -> Adaptive dt regenerated two-way rectangle: its moment of inertia is now /12 (#1994, #2068). The body also moved 0.137 dx and 0.213 dx off the cell faces (generic placement). override_tol_single = 1e-1 from the measured 1e-2 single/double spread; the double tolerance is unchanged at 1e-10
493989F3 2D -> 1 Fluid(s) -> IBM -> Collision -> Overlap cell on a rank seam (2 ranks) new (generated on the rebased base) #2433 regression test (generic placement)
B3EF129B Restart Roundtrip -> 1D -> pre_process old_ic new; equals the existing 1D restart golden 1A379909 to 1.1e-13 #2494 regression test

No other golden changes. 2D -> Example -> TaylorGreenVortex (#2465) stays within its tolerance: the pressure correction is 4.5e-3 on a 1e5 base.

Testing

Limitations

This PR was made with Claude Code (AI).

@sbryngelson
sbryngelson requested a review from a team as a code owner November 26, 2026 04:03
@sbryngelson
sbryngelson requested review from danieljvickers and removed request for a team November 26, 2026 04:03
@sbryngelson

Copy link
Copy Markdown
Member Author

Hand tests (commit 873301f, this PR's head, on origin/master 34aadf1)

Machine Compiler / MPI Device What Result
Phoenix (gpu-rtx6000 node, CPU only) GNU 12.3 + OpenMPI 4.1.5 (p-cpu), double CPU goldens 09FDDC81, 493989F3, B3EF129B generated, then the default CPU suite 1006 passed, 0 failed
Phoenix NVHPC 25.11 OpenACC, HPC-X Open MPI, --mpi NVIDIA H200 (driver 615.71) labels IBM (140), Restart (5), model_eqns=3 (15), Chemistry (69), TaylorGreenVortex (2), Non-Newtonian (8), Conduction (6), Axisymmetric (25), Cylindrical (8) 278 passed, 0 failed
Phoenix GNU 12.3 CPU ./mfc.sh precheck; ./mfc.sh lint (with the test-suite linters) 7/7; 1000 passed, 1 skipped

Earlier on the same commits (before the rebase onto 34aadf1):

AI-assisted (Claude Code).

@github-actions

Copy link
Copy Markdown

Claude Code Review

Head SHA: 873301f

Files changed:

  • 48
  • .github/scripts/preflight.sh
  • .github/scripts/submit-slurm-job.sh
  • CMakeLists.txt
  • src/common/m_boundary_io.fpp
  • src/pre_process/m_data_output.fpp
  • src/pre_process/m_start_up.fpp
  • src/simulation/m_ib_patches.fpp
  • src/simulation/m_ibm.fpp
  • src/simulation/m_rhs.fpp
  • toolchain/mfc/test/case.py

Summary: The PR batches 14 small fixes. They cover the serial old_ic restart (read only the interior record, open with STATUS='replace'), a rank-independent marker for cells inside two bodies (f_ib_marker), rejecting 1D IGR, the 2D Taylor-Green pressure, the IB moment of inertia, rescaling clamped volume fractions, cross-rank pressure-relaxation counters, a hashed IC cache with atomic writes, a parallel default for -j, and docs and comment cleanups. I checked each fix against the code it touches and found it correct for the issue it closes: record shapes match, alloc/dealloc pairs match, the MPI helper kinds match, the moment formulas use full side lengths, and the pressure is the exact TGV balance. The remaining concerns are a silent multi-rank failure mode left by the moment change, one build side effect the description does not mention, and two doc comments.

Findings:

  • medium src/simulation/m_ibm.fpp:4195 (likely): Multi-rank runs of a two-way body with no analytic moment (moving_ibm = 2, geometry 4, 5, 9, 10, 11 or 12) now give wrong rotation silently instead of NaN.
    • The moment is still a sum over the rank's own cells. Ranks that hold part of the body get different partial moments; your own numbers on IB moment of inertia from the cell sum has an extra 1/cell_volume factor #1994 are 1.2872e-2 and 9.1819e-3 for one cuboid on 2 ranks.
    • A rank that holds the body in its neighborhood but none of its cells now gets the dummy moment = 1._wp.
    • s_communicate_ib_forces makes the torque bit-identical on every rank, so that each rank integrates the same body. With a different I per rank, s_advance_ib_pose (m_time_steppers.fpp:1051-1054, angular_new = (angular_new*moment + dt*torque)/moment) produces a different angular_vel and angles on each rank. A rank with the dummy moment advances ω by dt*τ instead of dt*τ/I.
    • In 2D the moment is computed only at start-up, so that dummy value stays for the whole run. When the body later reaches such a rank, it is marked there with that rank's orientation.
    • Before this PR, 2D gave NaN on every rank, and 3D gave NaN on ranks without cells at the first non-zero spin. That configuration was loudly broken; now it runs to completion and is wrong. Nothing guards it: no example or test uses such a body, and case_validator.py only checks mass > 0.
    • Fix: until the cross-rank sum lands, add a runtime @:PROHIBIT(num_procs > 1 ...) for two-way non-analytic bodies in src/simulation/m_checker.fpp, next to the existing num_procs > 1 IB/AMR checks with their ! lint: runtime-check tag. At minimum, list this under Limitations.
  • low toolchain/mfc/build.py:482 (likely): The new -j default also changes the AMD GPU device link, which the description does not mention.
    • -DMFC_BUILD_JOBS={build_jobs()} feeds -flto-partitions=${MFC_BUILD_JOBS} on the amdflang offload link (cmake/MFCTargets.cmake:235).
    • A fresh --gpu mp configure without -j (for example the build inside ./mfc.sh run --case-optimization) used to link the device image as 1 LTO partition. It now uses min(cores, 16), so the partition count depends on the build host.
    • CI always passes -j 8 or $(nproc), so CI is unaffected.
    • gpuParallelization.md documents that amdflang device-image codegen is sensitive to whole-image effects. Either keep MFC_BUILD_JOBS at its previous value when -j is unset, or say in the PR and the -j help that the default now also sets the device LTO partition count.
  • low src/simulation/m_ib_patches.fpp:775 (confident): The doc comment of s_decode_patch_periodicity (!> Decode the encoded ID to recover the original patch ID and periodicity) was left above the inserted f_ib_marker. Doxygen now merges it into f_ib_marker's brief, and s_decode_patch_periodicity (line 790) has no doc comment. Move that line down to just above subroutine s_decode_patch_periodicity.
  • low src/simulation/m_ibm.fpp:3346 (confident): The rewritten s_interpolate_image_point docstring says ib_ip_interp = 1 uses inverse-distance weights over the 2x2(x2) cell. s_interpolation_weights (lines 3315-3329) uses bilinear (Mittal) weights there when ib_second_order_vel = T. case.md and the ib_ip_width comment at line 203 say the same ("inverse distance, bilinear"). Since this PR set out to fix this stale docstring, say "inverse-distance weights (bilinear with ib_second_order_vel)".

Coverage:

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Claude Code Review

Head SHA: f9fb735

Files changed:

  • 49
  • .github/scripts/preflight.sh
  • .github/scripts/submit-slurm-job.sh
  • .gitignore
  • CMakeLists.txt
  • docs/documentation/architecture.md.in
  • docs/documentation/case.md
  • docs/documentation/getting-started.md
  • docs/documentation/gpuParallelization.md
  • docs/documentation/testing.md
  • docs/documentation/validation_shock_tubes.md

Summary: The PR batches small fixes: serial old_ic restart I/O, rank-independent IB overlap markers, the 1D IGR refusal, the 2D Taylor-Green initial pressure, the pressure-relaxation cap count across ranks, the mixing-layer IC cache, the chemistry deallocation and energy-flux guard, the IB moment of inertia, volume-fraction rescaling, the default build -j, and assorted docs and comments. The Fortran changes held up when checked against their callers, allocations, GPU clauses and MPI call sites, and I found no correctness bug in them. The main problem is in the toolchain. The batched validate, which precheck now uses as a hard gate, still depends on the developer's last build configuration (--no-mpi). The other findings are stale docs, a misplaced doc comment and an undescribed build side effect.

Findings:

  • medium toolchain/mfc/validate.py:21 (confident): _validate_batch now exits 1 on any pre_process or simulation constraint violation. It resets only single to the default build. check_build_flags runs in validate_common, so in every stage, and refuses parallel_io = T when CFG().mpi is false (case_validator.py:3761). CFG() is the persisted build/lock.yaml config. getting-started.md says one --no-mpi "makes the change permanent". I ran CaseValidator with mpi=False on examples/1D_sodshocktube and examples/2D_riemann_test: both are refused in pre_process and simulation with the parallel_io message, and accepted with mpi=True. 178 of the 230 example decks set parallel_io = T. So anyone whose last build or test used --no-mpi now fails ./mfc.sh precheck (the pre-commit hook) on most examples. Before this PR those violations were warnings. CI is unaffected because its lint job validates from a fresh ./mfc.sh init (mpi on). Suggested fix: check against the full default build, e.g. state.gCFG = MFCConfig() (this also covers mixed, which gates kahan_summation), not just single=False.

  • low docs/documentation/validation_vortex_order.md:162 (confident): this PR closes 2D Taylor-Green patch (geometry 20): initial pressure amplitude is 1/4 of the exact solution #2465, but two places still describe the bug as current:

    Neither file is in the diff, while the matching IGR: 1D cases segfault (validator accepts igr with n = 0); Sod strip needs elliptic_smoothing #2463 sentence in validation_shock_tubes.md was updated. Remove the limitation or reword it as fixed.

  • low src/simulation/m_ib_patches.fpp:775 (confident): f_ib_marker was inserted between s_decode_patch_periodicity and its doc brief. The line !> Decode the encoded ID to recover the original patch ID and periodicity now sits directly above the new function's own !> block. Doxygen will merge both into f_ib_marker's documentation, and s_decode_patch_periodicity (line 790) loses its brief. Move that line down to just above subroutine s_decode_patch_periodicity.

  • low toolchain/mfc/build.py:482 (confident about the mechanism; its effect on kernels is untested): MFC_BUILD_JOBS does more than set build parallelism. cmake/MFCTargets.cmake:235 also passes it as -flto-partitions=${MFC_BUILD_JOBS} to the amdflang OpenMP-offload device link. With -j unset, a fresh --gpu mp configure on amdflang used to link the device image as 1 LTO partition; it now uses min(cores, 16). The value sticks, because configure runs only when the slug is not yet configured. CI always passes -j 8, so only local default builds change. The description of mfc.sh run defaults to -j 1, so builds triggered by run compile serially #1876 mentions only build parallelism. Please confirm this is intended, given the whole-image device-codegen caveats in gpuParallelization.md, or document it.

Coverage:

  • Fortran, read in full in the post-change context:
    • every changed routine in m_ib_patches.fpp: both marker paths, encode/decode and f_ib_marker;
    • in m_ibm.fpp: s_initialize_ibm_module, s_ibm_setup through ghost-point sizing, and s_compute_moment_of_inertia;
    • in m_rhs.fpp: the flux_src_n allocation, s_compute_additional_physics_rhs and s_finalize_rhs_module;
    • m_pressure_relaxation.fpp (procedure and report);
    • m_conduction.fpp (whole file);
    • the first non-Newtonian kernel in m_riemann_state.fpp (the second from the diff);
    • in simulation m_start_up.fpp: s_perform_time_step, s_save_performance_metrics and s_finalize_modules;
    • in pre_process: s_read_serial_grid_data_files, s_read_serial_ic_data_files, s_write_serial_data_files and the data-output init;
    • s_icpp_2D_TaylorGreen_Vortex.
  • Fortran, reviewed from the diff plus greps: m_boundary_io.fpp, m_derived_types.fpp (comment only), simulation m_data_output.fpp.
  • Toolchain:
    • read in full: validate.py, precheck.sh, the restart and tolerance code in test/case.py, the restart flow in test/test.py, and the cache helpers in flamelet.py;
    • relevant sections: build.py, the case_validator.py dispatch, the new and edited blocks in cases.py, test_case_validator.py and test_thermochem.py;
    • from the diff: CLI, main, params and generator text.
  • Examples, CI scripts and CMake: checked by targeted reads and greps.
  • Traced in the base checkout:
    • both callers of s_write_serial_boundary_condition_files;
    • that markers are zeroed before every s_apply_ib_patches, and that all 10 grid-cell marker writes now use f_ib_marker;
    • the 3D s_compute_moment_of_inertia call in m_time_steppers.fpp;
    • the single collective call site of s_report_pressure_relaxation and the MPI helper signatures;
    • pre_process buffer allocation and -1e-6 fill of q_cons_vf, and the (0:m,0:n,0:p) allocation of pb/mv against simulation's interior-only writes;
    • every ARG("jobs") consumer after the default became None, and where MFC_BUILD_JOBS is used;
    • how lock.py/main.py load gCFG;
    • that IGR tests and examples are all 2D or 3D, and that only 2D_jet_in_crossflow lacked a case.py;
    • .gitignore coverage of the new IC/<hash>/ files, using git check-ignore in a scratch repo;
    • that the packer collects only D/**/*.dat, which the old_ic restart harness relies on;
    • issues IB moment of inertia from the cell sum has an extra 1/cell_volume factor #1994 and Serial-I/O restart via pre_process old_ic fails: 'I/O past end of record' (reads a larger array than the restart holds) #2494.
  • Considered and dropped:
  • Not reviewed: golden files (excluded from the diff). I did not build Fortran or run tests.

@codecov

codecov Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.35484% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.57%. Comparing base (ea89e86) to head (4836d1c).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
src/simulation/m_rhs.fpp 0.00% 5 Missing and 2 partials ⚠️
src/simulation/m_ibm.fpp 62.50% 2 Missing and 4 partials ⚠️
src/simulation/m_ib_patches.fpp 78.57% 2 Missing and 1 partial ⚠️
src/simulation/m_riemann_state.fpp 50.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2514      +/-   ##
==========================================
+ Coverage   66.44%   66.57%   +0.12%     
==========================================
  Files         112      112              
  Lines       31462    31478      +16     
  Branches     4837     4839       +2     
==========================================
+ Hits        20905    20956      +51     
+ Misses       6596     6555      -41     
- Partials     3961     3967       +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sbryngelson

Copy link
Copy Markdown
Member Author

CI: 09FDDC81 (2D -> 1 Fluid(s) -> IBM -> Adaptive dt) in the single-precision GNU lane

The lane is --single. In CI the candidate differs from the double golden by 2.9e-2 abs and 1.23e-2 rel (cons.4, cell 1030), against the 1e-2 single tolerance.

Measured on Phoenix with GNU 12.3 + OpenMPI 4.1.5 (CPU). Each row is the max over cells, on the same run of the test case.

Comparison rho E (cons.4)
master: single vs double 3.5e-3 rel 4.9e-3 rel (1.3e-2 abs)
this PR: single vs double 9.2e-3 rel 1.28e-2 rel (3.0e-2 abs)
double: this PR vs master (the golden change) 8.8e-3 rel 1.22e-2 rel
  • This is precision spread, not a defect in the change.
    • Master's single run is already 5e-3 from its double golden, half the tolerance.
    • The body's angular velocity after the save is 1e-13 (double) and 1e-11 (single), driven by a round-off torque (1e-5, of either sign), so rotation is not what moves the field.
    • At cell 1030, this PR's single value (2.3539) equals master's double value (2.3527) to 5e-4. The 1.2e-2 double golden change at that cell therefore comes from a tiny effect that single precision does not resolve.
  • The test is degenerate by design: "the edges sit on cell faces", so image points land on faces and their stencil choice is sensitive to round-off.
  • Plan: keep the double tolerance (1e-10). Give this test a single-precision tolerance with the per-test mechanism being added in Tests: generic configurations and tight tolerances; ib_wall_order = 2, TSC image points and ib_visc_compact by default #2486, set to about 4x the measured 1.3e-2.
    • The alternative is to move the edges 0.1 dx off the faces. The body moves 0.2 dx, so no cell would cross the surface; that keeps the test's purpose and removes the degeneracy.

The other lanes are still running.

AI-assisted (Claude Code).

@sbryngelson

Copy link
Copy Markdown
Member Author

09FDDC81 off the cell faces: single vs double before and after

The test case now puts the rectangle 0.137 dx (x) and 0.213 dx (y) past the cell faces, instead of exactly on them. The body still moves 0.2 dx, so no cell centre crosses the surface. The golden was regenerated from a clean clone of the branch on 34aadf1 (Phoenix GNU 12.3 + OpenMPI 4.1.5, double), and the double test passes against it. The single build was run against that same golden.

09FDDC81, single vs double, max over cells rho E (cons.4) single test vs the 1e-2 tolerance
master (edges on faces) 3.5e-3 rel 4.9e-3 rel passes
this PR as pushed (edges on faces) 9.2e-3 rel 1.28e-2 rel fails in CI
this PR, edges off the faces 7.1e-3 rel 9.99e-3 rel (2.5e-2 abs) passes on Phoenix, with no margin
  • Moving the body off the faces barely changes the spread. The face alignment is not what makes this test sensitive to precision.
  • With 5 steps of an impulsively started body, single and double stay about 1e-2 apart, so the new placement gives the single lane no real margin.
  • Next step: keep the generic placement and the double tolerance. Then give this test a measured single-precision tolerance, about 10x the 1e-2 spread, using the per-test mechanism from Tests: generic configurations and tight tolerances; ib_wall_order = 2, TSC image points and ib_visc_compact by default #2486 once that commit is available. This is not pushed yet.

AI-assisted (Claude Code).

@sbryngelson

Copy link
Copy Markdown
Member Author

Pushed ea7846e: 09FDDC81 fix, single-precision tolerance, validate fix

Base is still 34aadf1. Changes since 873301f:

  1. 09FDDC81 off the cell faces. The rectangle centre moves by 0.137 dx (x) and 0.213 dx (y). The body still moves 0.2 dx, so no cell centre crosses the surface. The golden was regenerated in double from a clean clone (Phoenix GNU 12.3 + OpenMPI 4.1.5), and the test ID is unchanged.

  2. override_tol_single harness change from Tests: generic configurations and tight tolerances; ib_wall_order = 2, TSC image points and ib_visc_compact by default #2486. This is only its toolchain/mfc/test/case.py, test_tolerance.py and testing.md parts; Tests: generic configurations and tight tolerances; ib_wall_order = 2, TSC image points and ib_visc_compact by default #2486's own tolerance edits in cases.py are left out, so the two PRs carry the same harness change.

  3. 09FDDC81 tolerances. override_tol = 1e-10, the same IBM double tolerance it had before. override_tol_single = 1e-1, from the measured spread:

    09FDDC81 single vs double (max rel, E)
    master, edges on faces 4.9e-3
    873301f, edges on faces 1.28e-2 (failed the 1e-2 single tolerance in CI)
    ea7846e, edges off faces 9.99e-3
  4. Precheck example validation. It now checks the decks against the default double build. Run after a --single build, it had refused examples/3D_cyl_azimuthal_conduction_convergence ("3D cylindrical is not supported in single precision"), because the validator reads the local build's precision.

Verification on ea7846e (clean clones):

Check Machine Result
09FDDC81, double, against the new golden Phoenix GNU 12.3 CPU passed
09FDDC81, single, against the double golden Phoenix GNU 12.3 CPU passed
IBM label, double Phoenix GNU 12.3 CPU 140 passed, 0 failed
09FDDC81 Quadro RTX 6000, NVHPC 25.11 OpenACC passed
./mfc.sh precheck Phoenix 7/7
./mfc.sh lint Phoenix 1004 passed, 1 skipped (includes the 4 new test_tolerance.py tests)

No other golden changes. The earlier H200 run (IBM 140, Restart 5, model_eqns=3 15, Chemistry 69 and 5 more labels, 278 passed in total) was on 873301f. Since then the Fortran has not changed, and among the goldens only 09FDDC81's has.

AI-assisted (Claude Code).

@sbryngelson

Copy link
Copy Markdown
Member Author

Rebased onto master 73816da (after #2491 and #2492): head f9fb735

Conflicts. Both came from #2491 and were resolved in favour of master's new code:

Goldens. No overlap with the 140 goldens #2491 regenerated or the two from #2492 (82A64F89, A078904B). On the #2491 base, regenerated from a clean clone with Phoenix GNU 12.3 + OpenMPI 4.1.5 (double):

Test Change on the new base
09FDDC81 data unchanged, metadata only
493989F3 (new) regenerated: #2491's stage-time change moves the moving pair
B3EF129B (new) data unchanged, metadata only

#2492 changes no Fortran (only case_validator.py, descriptions.py, its unit tests, docs and example decks), so these goldens hold on 73816da too.

Verification.

Check Head Machine Result
Full CPU suite on 10e1299 Phoenix GNU 12.3 + OpenMPI 4.1.5 1006 passed, 0 failed
82A64F89, A078904B, 09FDDC81, 493989F3, B3EF129B f9fb735 same 5 passed
test_case_validator.py f9fb735 same 212 passed
./mfc.sh precheck f9fb735 Phoenix 7/7 (examples now with mpp_lim = F)
./mfc.sh lint f9fb735 Phoenix 1008 passed, 1 skipped
GPU hand test: 09FDDC81, 493989F3, B3EF129B, IBM (140), Restart (5) on 10e1299 NVIDIA L40S, driver 615.71, NVHPC 25.11 OpenACC all passed, 0 failed

The 10e1299 head has the same Fortran as f9fb735.

AI-assisted (Claude Code).

@sbryngelson

Copy link
Copy Markdown
Member Author

Moment of inertia at step 0 after the #2491 rebase (f9fb735)

(a) One computation, after the markers. On this branch s_compute_moment_of_inertia is called once in s_ibm_setup, at m_ibm.fpp:346. The call comes after s_apply_ib_patches, the centroid offsets and the per-patch GPU_UPDATE(device).

  • It runs in a GPU_PARALLEL_LOOP over the moving bodies, so the device copy is set first. GPU_UPDATE(host='[patch_ib(1:num_ibs)]') then copies it to the host.
  • Nothing between the start-up and the first stage of step 0 reads patch_ib%moment.
  • The early call that Stage-time sources and forcing; mpp_lim off for interface advection; document the primitive-reconstruction order limit #2491 put in its stage-time loop, before the markers exist, was dropped when the rebase conflict was resolved. No early call is left to produce a NaN.
  • The only other call site is the per-step 3D update in m_time_steppers.fpp:1053, which runs after the markers.

(b) A finite, correct moment at step 0. I printed patch_ib%moment right after that host update (local debug edit, not pushed). The bodies were two-way (moving_ibm = 2), with mass 1 and angular_vel(3) = 0.5, at generic centroids:

Body Path Analytic m(a^2+b^2)/12 Phoenix GNU 12.3, CPU NVIDIA V100, NVHPC 25.11 OpenACC
3D cuboid 0.31 x 0.23 x 0.17 summed over marked cells 1.2417e-2 1.32340466666667e-2 1.32340466666667e-2
2D rectangle (test lengths) analytic /12 4.1667e-4 4.16666666666667e-4 4.16666666666667e-4
  • Both values are finite, and CPU and GPU agree in every printed digit.
  • The cuboid moment is summed over about 8 x 6 x 4 cells (dx = 0.04), so it sits 6.6% above the continuum value from the staircase resolution.
  • The NaN of the old start-up order would have shown up here as NaN. No code changed, so nothing was pushed.

AI-assisted (Claude Code).

@sbryngelson sbryngelson added claude-full-review Trigger Claude Code review and removed claude-full-review Trigger Claude Code review labels Nov 26, 2026
@sbryngelson

Copy link
Copy Markdown
Member Author

Reply to the Claude review of f9fb735

Fixes are in 4b04872, a fast-forward on f9fb735 with no rebase. That commit changes no Fortran: only toolchain/, docs and one example README.

Finding Action
(medium) validate.py: batch validation reset only single; other build-dependent checks still read the local build _validate_batch now runs on a fresh state.MFCConfig() (all build flags at their defaults: mpi, single, mixed, ...) and restores the local configuration afterwards. New unit test toolchain/mfc/test_validate_batch.py sets a local --no-mpi --single --mixed configuration and checks that the batch sees the default one and that the local one is restored.
(low) stale #2465 "known limitation" Reworded in validation_vortex_order.md: the patch has set the exact pressure since #2465, and the decay table is unchanged at the printed digits (the 32-cell run was repeated after the fix). Removed from examples/2D_TaylorGreenVortex/README.md.
(low) m_ib_patches.fpp: orphaned brief of s_decode_patch_periodicity Not changed in this push, to keep it free of Fortran and avoid another GPU matrix. It is a misplaced comment only, and goes in with the next Fortran change to that file.
(low) build.py: MFC_BUILD_JOBS also sets -flto-partitions for the amdflang offload link -DMFC_BUILD_JOBS again passes -j as given (ARG('jobs')), as on master, so LTO partitioning does not follow the new default job count. The default (min(cores, 16)) now applies only to cmake --build --parallel.

Checked on Phoenix (GNU 12.3 + OpenMPI 4.1.5, CPU):

  • ./mfc.sh lint: 1009 passed, 1 skipped.
  • test_case_validator.py plus the new test: 213 passed.
  • Precheck: every step passed except spelling. Spelling failed only on the run's own log files left in the clone, and passes once they are moved out.
  • IBM label: 140 passed. That run was on the clone that also had the brief move; the Fortran is unchanged by this push.

No golden changes.

AI-assisted (Claude Code).

…sion guards (MFlowCode#1907, MFlowCode#1909)

s_finalize_rhs_module now deallocates flux_src_n(1)%vf(species%beg:species%end) (MFlowCode#1907). The chem-diffusion energy term is added only when the mom:E loop did not already add it, i.e. under .not. (viscous .or. surface_tension .or. heat_conduction), the same condition the allocation and deallocation use (MFlowCode#1909; unreachable by accepted cases today). Update the stale validator comment.
Summed moment: mass*sum(r^2)/count (drop the extra 1/cell_volume), decode periodic markers and measure from the image's centroid, dummy moment on a rank with no body cell instead of 0/0. Rectangle /12 (was /6), sphere 0.4_wp. Compute the start-up moment after s_apply_ib_patches: before, the sum saw no marked cells and gave NaN for every non-analytic moving body.
…1911)

Independent [0, 1] clamping can push the sum above 1 with 3+ fluids, inflating the non-Newtonian viscosity mixture and the conductivity. Divide by max(sum, 1) at the two viscous sites and the two conduction sites: a no-op when the clamped sum is <= 1.
…#1876)

An unset -j built serially, notably for builds triggered by run/test. Builds now use min(cpu_count, 16) unless -j is given and print the job count; test cases still run one at a time unless -j is given.
…FlowCode#2063, MFlowCode#2026)

Generated-file header and NAMELIST_VARS note: generated at build time (cmake/ParamsCodegen.cmake). architecture.md: parameters in definitions.py, validation in case_validator.py. getting-started: params --families, over 4,000 parameters; drop the counts from docstrings and CLI help. gpuParallelization typo. s_interpolate_image_point docstring: inverse-distance or TSC weights, not bilinear.
sacct node-recovery fallback ends in || true under set -euo pipefail (a failing sacct exited the script silently); preflight comment on the kept text match; LINK_DEPENDS_USE_LINKER OFF only for the amdflang offload build; inflow ramp f(t0) ~ f0 wording; example SUMMARY reads TOPOLOGY; drop unused LEVELS; explicit is None in the validator; one required list for grcbc_in; compiler probe keyed on FC; time_final/io_time_final comments; explicit real(t_step, wp) in the fixed-dt clock (bitwise unchanged).
… 493989F3 and B3EF129B (Phoenix GNU 12.3 + OpenMPI 4.1.5)
@github-actions

Copy link
Copy Markdown

Lines of Code

File Lines Diff
src/simulation/m_riemann_state.fpp 1200 +12
src/simulation/m_ib_patches.fpp 707 +10
src/simulation/m_ibm.fpp 4444 +10
src/common/m_boundary_io.fpp 312 -7
src/pre_process/m_data_output.fpp 663 -6
src/simulation/m_conduction.fpp 102 +6
src/simulation/m_rhs.fpp 2136 +5
Directory Lines Diff
common 12507 -7
pre_process 3712 -6
simulation 42544 +43
total 62599 +30

@sbryngelson

Copy link
Copy Markdown
Member Author

Rebased onto master ea89e86: head 4836d1c

After #2506, #2437 and #2447 merged, GitHub reported this PR CONFLICTING, so it needed a rebase.

Checked on a clean clone of 4836d1c (Phoenix GNU 12.3 + OpenMPI 4.1.5, CPU):

Check Result
IBM label 140 passed, 0 failed
09FDDC81, 493989F3, B3EF129B and master's 4 regenerated goldens 7 passed
Validator and batch-validation unit tests 214 passed
./mfc.sh precheck 7/7
./mfc.sh lint 1018 passed, 1 skipped

AI-assisted (Claude Code).

@sbryngelson
sbryngelson merged commit fd2eaa5 into MFlowCode:master Nov 26, 2026
48 checks passed
@sbryngelson

Copy link
Copy Markdown
Member Author

#2510: the two moment-of-inertia traps (5334FF40, D7E7DE04) with and without #2514

Setup: Phoenix GNU 12.3 + OpenMPI 4.1.5, CPU, built with FFLAGS=-g. Floating-point traps (invalid, divide-by-zero, overflow) are switched on right after MPI_Init by an LD_PRELOAD shim (feenableexcept).

Test master ea89e86 #2514 head 4836d1c
5334FF40 3D -> 2 Fluid(s) -> IBM -> Prescribed Kinematics -> Pitch Ramp SIGFPE in s_compute_moment_of_inertia (m_ibm.fpp:4191), called from s_ibm_setup (m_ibm.fpp:304) passes, no trap
D7E7DE04 3D -> 1 Fluid(s) -> IBM -> Prescribed Kinematics -> Pitch Ramp SIGFPE, same place passes, no trap

This leaves 16 of the 18 traps in #2510 open; this PR does not touch the other sites.

AI-assisted (Claude Code).

sbryngelson added a commit to sbryngelson/MFC that referenced this pull request Nov 26, 2026
sbryngelson added a commit to sbryngelson/MFC that referenced this pull request Nov 26, 2026
sbryngelson added a commit that referenced this pull request Nov 27, 2026
…, TSC image points and ib_visc_compact by default (#2486)

* Tests: generic configurations for degenerate tests; tolerances from measured spreads

* IBM: ib_wall_order = 2 by default (1 with ib_second_order_vel)

* IBM: ib_ip_interp = 2 (TSC) by default (1 with ib_second_order_vel)

* Docs: TSC image points and the quadratic no-slip ghost are the defaults

* Viscous IB: ib_visc_compact by default with weno_Re_flux, so the viscous flux no longer reads unfilled solid cells (#2041)

* Tests: tolerances measured with the new defaults on more lanes

* Tests: cold-wall twin and flux-wall tolerances from the measured GNU/GPU spread

* Tests: override_tol_single for the single-precision lane; tolerances from the measured CI spread

* Review: explicit IB options in the validation examples, ib_visc_compact = F tests, wording of the old defaults

* Tests: regenerate the changed goldens (Phoenix, GNU 12.3, OpenMPI 4.1.5)

* Format the wall_fill comment

* Tests: goldens that move on the new base (09FDDC81, and the overlap-cell seam test from #2514)

* Tests: C1F0BCB1 tolerance 1e-7 (GitHub ubuntu GNU differs from the Phoenix GNU golden by 4e-9 relative)

* Tests: goldens that move on the new base (master 946d1e5; Tuolumne, GNU 13.3.1 CPU)

* Tests: regenerate 872A4241 and F1BD319C on top of #2517 (HLLC central tangential velocity); their #2515 goldens predate it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment