From 4273c849e8df48dd7ff2aa4ddf2dfd58f04f5ffc Mon Sep 17 00:00:00 2001 From: danieljvickers Date: Sun, 15 Mar 2026 07:51:06 -0400 Subject: [PATCH 1/5] Remove interior point conservative variable protection for stationary boundaries --- src/simulation/m_ibm.fpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/simulation/m_ibm.fpp b/src/simulation/m_ibm.fpp index b87f5a1b19..d5eeb527cb 100644 --- a/src/simulation/m_ibm.fpp +++ b/src/simulation/m_ibm.fpp @@ -192,7 +192,7 @@ contains type(ghost_point) :: gp type(ghost_point) :: innerp - ! set the Moving IBM interior Pressure Values + ! set the Moving IBM interior conservative variables $:GPU_PARALLEL_LOOP(private='[i,j,k,patch_id,rho]', copyin='[E_idx,momxb]', collapse=3) do l = 0, p do k = 0, n @@ -200,18 +200,16 @@ contains patch_id = ib_markers%sf(j, k, l) if (patch_id /= 0) then q_prim_vf(E_idx)%sf(j, k, l) = 1._wp - if (patch_ib(patch_id)%moving_ibm > 0) then - rho = 0._wp - do i = 1, num_fluids - rho = rho + q_prim_vf(contxb + i - 1)%sf(j, k, l) - end do + rho = 0._wp + do i = 1, num_fluids + rho = rho + q_prim_vf(contxb + i - 1)%sf(j, k, l) + end do - ! Sets the momentum - do i = 1, num_dims - q_cons_vf(momxb + i - 1)%sf(j, k, l) = patch_ib(patch_id)%vel(i)*rho - q_prim_vf(momxb + i - 1)%sf(j, k, l) = patch_ib(patch_id)%vel(i) - end do - end if + ! Sets the momentum + do i = 1, num_dims + q_cons_vf(momxb + i - 1)%sf(j, k, l) = patch_ib(patch_id)%vel(i)*rho + q_prim_vf(momxb + i - 1)%sf(j, k, l) = patch_ib(patch_id)%vel(i) + end do end if end do end do From 390511ef5070559b8ff3357c214a211af28d1b60 Mon Sep 17 00:00:00 2001 From: danieljvickers Date: Wed, 22 Apr 2026 17:25:53 -0400 Subject: [PATCH 2/5] Added check for untested edge case as Ib sums force as it wraps periodically --- src/simulation/m_ib_patches.fpp | 15 +++++++++------ src/simulation/m_ibm.fpp | 10 ++++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/simulation/m_ib_patches.fpp b/src/simulation/m_ib_patches.fpp index 3735d9a8a0..cf3ad9ecfa 100644 --- a/src/simulation/m_ib_patches.fpp +++ b/src/simulation/m_ib_patches.fpp @@ -1049,9 +1049,10 @@ contains $:GPU_ROUTINE(parallelism='[seq]') - integer, intent(in) :: encoded_patch_id - integer, intent(out) :: patch_id, x_periodicity, y_periodicity, z_periodicity - integer :: offset, remainder, xp, yp, zp, base + integer, intent(in) :: encoded_patch_id + integer, intent(out) :: patch_id + integer, intent(out), optional :: x_periodicity, y_periodicity, z_periodicity + integer :: offset, remainder, xp, yp, zp, base base = num_ibs + 1 @@ -1064,9 +1065,11 @@ contains zp = remainder/3 ! Reverse map: 2 -> -1, 0 -> 0, 1 -> 1 - x_periodicity = xp; if (xp == 2) x_periodicity = -1 - y_periodicity = yp; if (yp == 2) y_periodicity = -1 - z_periodicity = zp; if (zp == 2) z_periodicity = -1 + if (present(x_periodicity) .and. present(y_periodicity) .and. present(z_periodicity)) then + x_periodicity = xp; if (xp == 2) x_periodicity = -1 + y_periodicity = yp; if (yp == 2) y_periodicity = -1 + z_periodicity = zp; if (zp == 2) z_periodicity = -1 + end if end subroutine s_decode_patch_periodicity diff --git a/src/simulation/m_ibm.fpp b/src/simulation/m_ibm.fpp index 469eecdabd..8bc5bace13 100644 --- a/src/simulation/m_ibm.fpp +++ b/src/simulation/m_ibm.fpp @@ -886,7 +886,7 @@ contains type(scalar_field), dimension(1:sys_size), intent(in) :: q_prim_vf type(physical_parameters), dimension(1:num_fluids), intent(in) :: fluid_pp - integer :: i, j, k, l, ib_idx, fluid_idx + integer :: i, j, k, l, encoded_ib_idx, fluid_idx real(wp), dimension(num_ibs, 3) :: forces, torques real(wp), dimension(1:3,1:3) :: viscous_stress_div, viscous_stress_div_1, & & viscous_stress_div_2 ! viscous stress tensor with temp vectors to hold divergence calculations @@ -914,15 +914,17 @@ contains end do end if - $:GPU_PARALLEL_LOOP(private='[ib_idx, fluid_idx, radial_vector, local_force_contribution, cell_volume, & + $:GPU_PARALLEL_LOOP(private='[ib_idx, encoded_ib_idx, fluid_idx, radial_vector, local_force_contribution, cell_volume, & & local_torque_contribution, dynamic_viscosity, viscous_stress_div, viscous_stress_div_1, & & viscous_stress_div_2, dx, dy, dz]', copy='[forces, torques]', copyin='[patch_ib, & & dynamic_viscosities]', collapse=3) do i = 0, m do j = 0, n do k = 0, p - ib_idx = ib_markers%sf(i, j, k) - if (ib_idx /= 0) then + encoded_ib_idx = ib_markers%sf(i, j, k) + if (encoded_ib_idx /= 0) then + call s_decode_patch_id(encoded_ib_idx, ib_dx) + ! get the vector pointing to the grid cell from the IB centroid if (num_dims == 3) then radial_vector = [x_cc(i), y_cc(j), z_cc(k)] - [patch_ib(ib_idx)%x_centroid, & From 10d746ad214e9967a8efbb7f48eb7db715023d8c Mon Sep 17 00:00:00 2001 From: danieljvickers Date: Wed, 22 Apr 2026 17:36:24 -0400 Subject: [PATCH 3/5] Accidentally deleted the ib_idx --- src/simulation/m_ibm.fpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simulation/m_ibm.fpp b/src/simulation/m_ibm.fpp index 8bc5bace13..febae1479d 100644 --- a/src/simulation/m_ibm.fpp +++ b/src/simulation/m_ibm.fpp @@ -886,7 +886,7 @@ contains type(scalar_field), dimension(1:sys_size), intent(in) :: q_prim_vf type(physical_parameters), dimension(1:num_fluids), intent(in) :: fluid_pp - integer :: i, j, k, l, encoded_ib_idx, fluid_idx + integer :: i, j, k, l, encoded_ib_idx, ib_idx, fluid_idx real(wp), dimension(num_ibs, 3) :: forces, torques real(wp), dimension(1:3,1:3) :: viscous_stress_div, viscous_stress_div_1, & & viscous_stress_div_2 ! viscous stress tensor with temp vectors to hold divergence calculations From 417c90f8f9105267ca698b4e54d6520b88ef512c Mon Sep 17 00:00:00 2001 From: danieljvickers Date: Wed, 22 Apr 2026 18:25:15 -0400 Subject: [PATCH 4/5] Spelling --- src/simulation/m_ibm.fpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simulation/m_ibm.fpp b/src/simulation/m_ibm.fpp index febae1479d..6d71b09310 100644 --- a/src/simulation/m_ibm.fpp +++ b/src/simulation/m_ibm.fpp @@ -923,7 +923,7 @@ contains do k = 0, p encoded_ib_idx = ib_markers%sf(i, j, k) if (encoded_ib_idx /= 0) then - call s_decode_patch_id(encoded_ib_idx, ib_dx) + call s_decode_patch_id(encoded_ib_idx, ib_idx) ! get the vector pointing to the grid cell from the IB centroid if (num_dims == 3) then From b06591275a3315d7c05a9aa7813e9d767e28d059 Mon Sep 17 00:00:00 2001 From: danieljvickers Date: Wed, 22 Apr 2026 19:47:49 -0400 Subject: [PATCH 5/5] More spelling --- src/simulation/m_ibm.fpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simulation/m_ibm.fpp b/src/simulation/m_ibm.fpp index 6d71b09310..5f865cffeb 100644 --- a/src/simulation/m_ibm.fpp +++ b/src/simulation/m_ibm.fpp @@ -923,7 +923,7 @@ contains do k = 0, p encoded_ib_idx = ib_markers%sf(i, j, k) if (encoded_ib_idx /= 0) then - call s_decode_patch_id(encoded_ib_idx, ib_idx) + call s_decode_patch_periodicity(encoded_ib_idx, ib_idx) ! get the vector pointing to the grid cell from the IB centroid if (num_dims == 3) then