Skip to content

Fix periodic ib issues#1618

Draft
danieljvickers wants to merge 5 commits into
MFlowCode:masterfrom
danieljvickers:fix-periodic-ib-issues
Draft

Fix periodic ib issues#1618
danieljvickers wants to merge 5 commits into
MFlowCode:masterfrom
danieljvickers:fix-periodic-ib-issues

Conversation

@danieljvickers

@danieljvickers danieljvickers commented Jun 24, 2026

Copy link
Copy Markdown
Member

Description

I was made aware of several bugs in the IB MPI communication in periodic cases. This branch resolves all of the issues that I have been made aware of. They include

  1. periodic IBs not having the radial vector account for their periodicity
  2. Force integration can double-count if the Ib neighbors itself or has the same neighbor periodically
  3. Collisions can be missed as neither processor believes they own the collision
  4. There is drift in IB information between ranks.

The good news is that the fix for number 2 is also a computational optimization in small cases by limiting the total number of communications to the minimum required to successfully sum. So we have a slight upside.

A new example will be added that should check for this behavior and ensure that it does not break again.

Type of change (delete unused ones)

  • Bug fix

…umber of IB force communications. This limits the number of transmits and prevents double-counting in periodic cases.
@github-actions

Copy link
Copy Markdown

Claude Code Review

Head SHA: 347d6c6

Files changed:

  • 3
  • src/common/m_global_parameters_common.fpp
  • src/common/m_mpi_common.fpp
  • src/simulation/m_ibm.fpp

Findings:

Wrong array indices in radial_vector computation in s_compute_ib_forces (src/simulation/m_ibm.fpp)

The new radial-vector calculation for force/torque integration uses the wrong loop index for the y and z components:

radial_vector(2) = y_cc(i) - (patch_ib(ib_idx)%y_centroid + real(yp, wp)*(y_domain%end - y_domain%beg))
...
if (num_dims == 3) radial_vector(3) = z_cc(i) - (patch_ib(ib_idx)%z_centroid + real(zp, wp)*(z_domain%end - z_domain%beg))

Both use index i (the x-loop variable). The enclosing loop is do i = 0, m; do j = 0, n; do k = 0, p, so:

  • radial_vector(2) must use y_cc(j) (j is the y-index)
  • radial_vector(3) must use z_cc(k) (k is the z-index)

Using y_cc(i) and z_cc(i) makes the torque calculation use the x-coordinate for all three components, producing silently wrong forces and torques for any simulation with more than one cell in y or z.

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