Skip to content

IBM: take halo-cell momentum in the moving-wall force term from the exchanged primitives - #2340

Merged
sbryngelson merged 1 commit into
MFlowCode:masterfrom
sbryngelson:ib-force-seam-rank-independence
Nov 20, 2026
Merged

sbryngelson merged 1 commit into
MFlowCode:masterfrom
sbryngelson:ib-force-seam-rank-independence

Conversation

@sbryngelson

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

The body-frame force of a moving wall (added in #2208) removes the face momentum times the wall's normal velocity, with the face momentum taken as the mean of the fluid-cell and body-cell momenta read from q_cons. The RHS exchanges only the primitive halos (q_prim_qp), never the q_cons momentum halos, so at a rank seam or a periodic edge the halo cell's q_cons momentum was never filled. It read as zero where the neighbour holds the body-cell momentum (rho V). A moving body touching a seam therefore got a force that depended on the decomposition. Earlier 1- and 2-rank verification could not see this: the term is proportional to the wall velocity normal to the seam, needs a body cell in the halo, and the test bodies moved along their seams or sat away from them.

This reads halo cells from rho*u of the exchanged primitives (new f_ib_cell_momentum; interior cells still read q_cons, so interior values are unchanged). s_accumulate_ib_face_fluxes has no other q_cons read at a halo cell; I did not audit other IB routines.

Evidence

Measured at step 0 with a temporary print (8 ranks, 2D, a circle on the seam, wall velocity 0.6): the halo q_cons momentum is exactly 0.0 where rho*u from the primitives is 0.6. The same stale zero appears with one rank at a periodic edge (32 cells printed with 1 rank, 35 with 8), so the fix can also change 1-rank results for bodies crossing a periodic boundary.

Periodic 2D box, 128x128 cells, 8 circles with prescribed velocity (moving_ibm = 1) or two-way (moving_ibm = 2), 300 steps, force history in ib_forces.dat against 1 rank (CPU build, Cray CCE, MI250X node):

first rows all steps
before, 4 and 8 ranks one body's force off by 1.1e-2 (4 ranks), 2.0e-2 (8 ranks) in row 1
after, moving_ibm = 2, 2/4/8 ranks 1e-16 1e-12 to 1e-11 (2400 rows)
after, moving_ibm = 1, 2/4/8 ranks 1e-16 1e-15 to 1e-14 up to t = 2.9 (1488 rows)

Static bodies in a uniform stream already agreed to 2e-16 at 4 and 8 ranks before the change.

Tests

New test IBM -> Translating Circle -> 2 MPI Ranks -> Body-Frame Force (9C0CAF25): the existing translating circle on the rank seam, now also moving in y (0.6) so a wall normal velocity exists at the seam whichever way the 2 ranks split. Golden from the fixed build; it fails on the unfixed build (D/ib_forces.dat variable 563: -0.6018 against -0.6099, 1.3e-2 relative, tolerance 1e-10) and its force history agrees with the 1-rank golden of the existing translating-circle test to 2e-16. The existing 1-rank body-frame tests also set vel(2) = 0, the default. All 114 existing IBM tests pass against their unchanged goldens (CPU, Cray CCE), so no existing golden changes. ./mfc.sh precheck passes.

Limitations

  • CPU build only; the new function is a sequential device routine like its neighbours, but I have not run GPU tests.
  • With moving_ibm = 1 and two prescribed bodies that overlap (bodies 3 and 4 of the 8-body case from t = 2.9) the 1- and 8-rank force histories differ by up to 0.8. That is outside this change and is not investigated here; two-way and non-overlapping prescribed bodies agree.
  • With IGR the q_cons halos are exchanged, so q_cons is still read.

This PR was made with Claude Code (AI).

…xchanged primitives

The body-frame force of a moving wall removes the face momentum times the wall's normal velocity, with the face momentum the mean of the fluid and body cell momenta read from q_cons. The RHS exchanges only the primitive halos, so q_cons momentum in a halo cell (rank seam, periodic edge) was never filled and read as zero where the neighbor holds rho*V. The force of a body on a seam therefore depended on the decomposition. Read halo cells from rho*u of the primitives. Adds a 2-rank test with the body on the seam moving across it.
@sbryngelson sbryngelson added the ci:phoenix Run the Phoenix (NVHPC GPU) jobs on this PR; push after adding label Nov 19, 2026
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Claude Code Review

Head SHA: b9ce2d0

Files changed:

  • 3
  • src/simulation/m_ibm.fpp
  • src/simulation/m_rhs.fpp
  • toolchain/mfc/test/cases.py

Findings:
No issues found. Checked in step 4: src/simulation/m_ibm.fpp, src/simulation/m_rhs.fpp, toolchain/mfc/test/cases.py. The context directory was empty, so I checked the changed hunks against the master checkout instead. That checkout showed the halo guard using m/n/p, which are swapped to the block's values during the AMR fine advance. Both call sites in m_rhs.fpp are updated, and no other callers of s_accumulate_ib_face_fluxes exist.

@github-actions

Copy link
Copy Markdown

Lines of Code

File Lines Diff
src/simulation/m_ibm.fpp 3499 +14
Directory Lines Diff
simulation 40547 +14
total 60579 +14

@sbryngelson
sbryngelson marked this pull request as ready for review November 19, 2026 19:46
@sbryngelson
sbryngelson requested a review from a team as a code owner November 19, 2026 19:46
@sbryngelson
sbryngelson requested review from danieljvickers and removed request for a team November 19, 2026 19:46
@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.69%. Comparing base (cd2180c) to head (b9ce2d0).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/simulation/m_ibm.fpp 88.88% 0 Missing and 1 partial ⚠️
src/simulation/m_rhs.fpp 75.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2340   +/-   ##
=======================================
  Coverage   65.68%   65.69%           
=======================================
  Files         111      111           
  Lines       30258    30269   +11     
  Branches     4616     4617    +1     
=======================================
+ Hits        19875    19885   +10     
+ Misses       6670     6669    -1     
- Partials     3713     3715    +2     

☔ 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

Tested on one node of MI250X (Cray compiler, OpenACC), applying this branch alone to the base it was cut from (cd2180c).

This comment was made with Claude Code (AI).

@sbryngelson

Copy link
Copy Markdown
Member Author

Independent NVIDIA verification of current master (aad80b3c3, which contains this PR).

  • Machine: NVIDIA A100 80GB (Georgia Tech wingtip)
  • Compiler: NVHPC 25.5, OpenACC, CI-style fat build (cc 70,75,80,89,90)
  • Flags: ./mfc.sh test -v --max-attempts 1 --no-build -o IBM --no-chemistry -j 2 -g <gpus> --gpu acc --mpi --no-debug --no-reldebug --no-single
  • Whole IBM label (chemistry excluded): 118 passed, 0 failed (one 1-GPU run, one 2-GPU run). 909 skipped by the filter, including the NVHPC<25.11 skip 124D7972 (Test: skip 124D7972 on NVHPC < 25.11 GPU builds (known difference, #2181) #2380).
  • Wall time of the full IBM label at -j 2 (machine shared, load varies): 829 s on one GPU, 661 s on two GPUs. Per-test times in the tables are single-test wall times including pre_process/simulation launch and golden compare, not per-step times.
Test Result 1 GPU Result 2 GPUs (2-rank tests split across GPUs) Time 1 GPU / 2 GPUs (s)
9C0CAF25 Translating Circle 2 MPI Ranks, Body-Frame Force (added by this PR) PASS PASS 12.4 / 9.8
993DF695 Periodic Edge guard (#2364) PASS PASS 9.7 / 10.1
997E2B0E Translating Circle Body-Frame Force PASS PASS 11.8 / 9.0

The 2-rank seam test matches its golden with both ranks on one GPU and on two GPUs.

Not run: chemistry tests, OpenMP-offload build, CPU build, any NVHPC other than 25.5, before/after timing of the changes.

AI-assisted (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:phoenix Run the Phoenix (NVHPC GPU) jobs on this PR; push after adding

Development

Successfully merging this pull request may close these issues.

1 participant