Skip to content

Commit 3826b81

Browse files
Fixed desynced force values for collision forces
1 parent 8a053dd commit 3826b81

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

src/simulation/m_time_steppers.fpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,13 @@ contains
729729
patch_ib(i)%step_z_centroid = patch_ib(i)%z_centroid
730730
end if
731731

732+
! Compute forces BEFORE the RK velocity blend so the device copy of patch_ib%vel matches the host (pre-blend) when
733+
! velocity-dependent collision damping forces are evaluated on the GPU.
734+
if (patch_ib(i)%moving_ibm == 2 .and. .not. forces_computed) then
735+
call s_compute_ib_forces(q_prim_vf, fluid_pp)
736+
forces_computed = .true.
737+
end if
738+
732739
if (patch_ib(i)%moving_ibm > 0) then
733740
patch_ib(i)%vel = (rk_coef(s, 1)*patch_ib(i)%step_vel + rk_coef(s, 2)*patch_ib(i)%vel)/rk_coef(s, 4)
734741
patch_ib(i)%angular_vel = (rk_coef(s, 1)*patch_ib(i)%step_angular_vel + rk_coef(s, &
@@ -738,12 +745,6 @@ contains
738745
! plug in analytic velocities for 1-way coupling, if it exists
739746
@:mib_analytical()
740747
else if (patch_ib(i)%moving_ibm == 2) then ! if we are using two-way coupling, apply force and torque
741-
! compute the force and torque on the IB from the fluid
742-
if (.not. forces_computed) then
743-
call s_compute_ib_forces(q_prim_vf, fluid_pp)
744-
forces_computed = .true.
745-
end if
746-
747748
! update the velocity from the force value
748749
patch_ib(i)%vel = patch_ib(i)%vel + rk_coef(s, 3)*dt*(patch_ib(i)%force/patch_ib(i)%mass)/rk_coef(s, 4)
749750

0 commit comments

Comments
 (0)