Skip to content

IBM: wrap a periodic centroid that lands exactly on the domain end - #2335

Merged
sbryngelson merged 1 commit into
MFlowCode:masterfrom
sbryngelson:ib-periodic-edge-ownership
Nov 20, 2026
Merged

sbryngelson merged 1 commit into
MFlowCode:masterfrom
sbryngelson:ib-periodic-edge-ownership

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

With periodic boundaries a moving body's centroid is wrapped by s_wrap_periodic_ibs only when it is strictly greater than the domain end. The last rank owns the half-open interval [beg, end), so a centroid exactly on the end belongs to no rank until the next step wraps it. For that step no rank owns the body: it has no row in ib_forces.dat (a hole of NUL bytes) and no owner for its force reduction. This changes the wrap to >= (all three directions share the macro). The left end needs no change: a centroid equal to beg is owned by the first rank.

A centroid lands exactly on the end whenever positions and steps are exactly representable, for example bodies started on a regular lattice and moved with dyadic steps.

Evidence

Periodic 2D box (128x128 cells, 8 prescribed-velocity circles, 300 steps, dt = 2^-6), a circle reaching x = 8 = the domain end exactly at step 256. On 2, 4 and 8 ranks ib_forces.dat had one NUL-filled record for that body and step (1 rank: none). With the change the file has every record.

Tests

New test IBM -> Centroid On Periodic Domain End -> 2 MPI Ranks (50B98DBF): a circle that reaches x = 1 exactly after 3 steps (dt = 2^-11), ib_force_wrt, 2 ranks. Golden generated with the fix (CPU build, Cray CCE, MI250X node). Without the change the test fails: Failed to interpret the content of .../D/ib_forces.dat as a list of floating point numbers (the NUL record). With it, the test passes on rerun. ./mfc.sh precheck passes.

Limitations

Only the CPU build was run by hand; the change is host-side-equivalent in the GPU loop (one comparison). A centroid placed exactly on the end in the input file is not wrapped at start-up and is still unowned at step 0; that is not changed here.

This PR was made with Claude Code (AI).

s_wrap_periodic_ibs wrapped a centroid only when it was greater than the domain end, but the last rank owns [beg, end), so a centroid exactly on the end belonged to no rank until the next step. The body then lost its row in ib_forces.dat (and its owner) for that step. Wrap at >= end. Adds a 2-rank test whose circle reaches x = 1 exactly.
@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: d503aac

Files changed:

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

Findings:
No issues found. Checked in step 4: src/simulation/m_ibm.fpp (s_wrap_periodic_ibs, all three x/y/z directions via the fypp loop) and toolchain/mfc/test/cases.py (new ppn=2 case). The context directory was empty, so I read both files from the repo checkout.

@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 wilfonba and removed request for a team November 19, 2026 19:46
@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.71%. Comparing base (cd2180c) to head (d503aac).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2335      +/-   ##
==========================================
+ Coverage   65.68%   65.71%   +0.02%     
==========================================
  Files         111      111              
  Lines       30258    30258              
  Branches     4616     4616              
==========================================
+ Hits        19875    19884       +9     
+ Misses       6670     6657      -13     
- Partials     3713     3717       +4     

☔ 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

For information, from tests on one node of MI250X applying each branch alone to the base it was cut from (cd2180c): a periodic box with 1000 free moving circles that aborts on the ICFL check at step 2 on that base still aborts with only this change applied, and runs with #2340 applied. With both applied, six free spinning circles on and across the seams of a 2x2 split give 1-rank and 4-rank force and torque histories identical to 1e-14 over 100 steps.

This comment was made with Claude Code (AI).

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