Skip to content

Decode periodic IB markers in the moment of inertia sum - #1992

Closed
sbryngelson wants to merge 3 commits into
MFlowCode:masterfrom
sbryngelson:fix/ib-moment-of-inertia
Closed

sbryngelson wants to merge 3 commits into
MFlowCode:masterfrom
sbryngelson:fix/ib-moment-of-inertia

Conversation

@sbryngelson

@sbryngelson sbryngelson commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

s_compute_moment_of_inertia compared raw ib_markers against
gbl_patch_id. Cells of a periodic image carry an encoded marker
(gbl_id + (num_gbl_ibs+1)(xp + 3yp + 9*zp)), so they were dropped
from the sum. Decode the marker with s_decode_patch_periodicity, as
the other marker loops do, and measure each cell from the centroid of
the image it belongs to, as s_compute_ib_forces does.

A rank holding no cell of the body divided 0 by 0. Return the same
dummy value of 1 used for a non-rotating body instead.

Remaining issue: count and the r^2 sum are over this rank's cells
only, so a body split across ranks gets a different moment on each
rank. The routine is a GPU_ROUTINE called from inside the
s_initialize_ibm_module and s_propagate_immersed_boundaries device
loops, so an MPI reduction cannot be added here; the sum has to move
to host code with an allreduce before those loops.

All 61 IBM tests and 12 IB example tests pass against the existing
goldens.

s_compute_moment_of_inertia compared raw ib_markers against
gbl_patch_id. Cells of a periodic image carry an encoded marker
(gbl_id + (num_gbl_ibs+1)*(xp + 3*yp + 9*zp)), so they were dropped
from the sum. Decode the marker with s_decode_patch_periodicity, as
the other marker loops do, and measure each cell from the centroid of
the image it belongs to, as s_compute_ib_forces does.

A rank holding no cell of the body divided 0 by 0. Return the same
dummy value of 1 used for a non-rotating body instead.

Remaining issue: count and the r^2 sum are over this rank's cells
only, so a body split across ranks gets a different moment on each
rank. The routine is a GPU_ROUTINE called from inside the
s_initialize_ibm_module and s_propagate_immersed_boundaries device
loops, so an MPI reduction cannot be added here; the sum has to move
to host code with an allreduce before those loops.

All 61 IBM tests and 12 IB example tests pass against the existing
goldens.
@github-actions

Copy link
Copy Markdown

Lines of Code

File Lines Diff
src/simulation/m_ibm.fpp 1825 +7
Directory Lines Diff
simulation 28510 +7
total 47521 +7

@sbryngelson

Copy link
Copy Markdown
Member Author

Closing this for now to bring the number of open PRs from me down to four, so the ones that stay open get real review attention rather than being lost in a queue of 35.

No work is lost and nothing needs re-doing. The branch fix/ib-moment-of-inertia remains on the fork at 67de4571f9, this PR's diff and discussion stay here, and the head commit is additionally archived in a local verified bundle. Reopening takes no force-push and no rebase:

gh pr reopen 1992 -R MFlowCode/MFC

I intend to reopen these in small batches as the open slots free up. Apologies for the notification noise.

Opened and closed with Claude Code.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant