@@ -279,6 +279,15 @@ contains
279279 end if
280280 end if
281281
282+ if (patch_ib(patch_id)%moving_ibm /= 0 ) then
283+ ! get the vector that points from the centroid to the ghost
284+ radial_vector(1 ) = physical_loc(1 ) - (patch_ib(ib_idx)%x_centroid + real (xp, wp)* (x_domain%end - x_domain%beg))
285+ radial_vector(2 ) = physical_loc(2 ) - (patch_ib(ib_idx)%y_centroid + real (yp, wp)* (y_domain%end - y_domain%beg))
286+ radial_vector(3 ) = 0._wp
287+ if (num_dims == 3 ) radial_vector(3 ) = physical_loc(3 ) - (patch_ib(ib_idx)%z_centroid + real (zp, &
288+ & wp)* (z_domain%end - z_domain%beg))
289+ end if
290+
282291 ! Calculate velocity of ghost cell
283292 if (gp%slip) then
284293 norm(1 :3 ) = gp%levelset_norm
@@ -288,8 +297,6 @@ contains
288297 vel_g = vel_IP - vel_norm_IP
289298 if (patch_ib(patch_id)%moving_ibm /= 0 ) then
290299 ! compute the linear velocity of the ghost point due to rotation
291- radial_vector = physical_loc - [patch_ib(patch_id)%x_centroid, patch_ib(patch_id)%y_centroid, &
292- & patch_ib(patch_id)%z_centroid]
293300 call s_cross_product(patch_ib(patch_id)%angular_vel, radial_vector, rotation_velocity)
294301
295302 ! add only the component of the IB' s motion that is normal to the surface
@@ -300,9 +307,6 @@ contains
300307 ! we know the object is not moving if moving_ibm is 0 (false)
301308 vel_g = 0._wp
302309 else
303- ! get the vector that points from the centroid to the ghost
304- radial_vector = physical_loc - [patch_ib(patch_id)%x_centroid, patch_ib(patch_id)%y_centroid, &
305- & patch_ib(patch_id)%z_centroid]
306310 ! convert the angular velocity from the inertial reference frame to the fluids frame, then convert to linear
307311 ! velocity
308312 call s_cross_product(patch_ib(patch_id)%angular_vel, radial_vector, rotation_velocity)
@@ -935,21 +939,23 @@ contains
935939 end do
936940 end if
937941
938- $:GPU_PARALLEL_LOOP(private= ' [i, j, k, l, ib_idx, ib_idx_temp, encoded_ib_idx, fluid_idx, radial_vector, &
942+ $:GPU_PARALLEL_LOOP(private= ' [i, j, k, l, xp, yp, zp, ib_idx, ib_idx_temp, encoded_ib_idx, fluid_idx, radial_vector, &
939943 & local_force_contribution, cell_volume, local_torque_contribution, dynamic_viscosity, &
940944 & viscous_stress]' , copy= ' [forces, torques]' , copyin= ' [dynamic_viscosities]' , collapse= 3 )
941945 do i = 0 , m
942946 do j = 0 , n
943947 do k = 0 , p
944948 encoded_ib_idx = ib_markers%sf(i, j, k)
945949 if (encoded_ib_idx /= 0 ) then
946- call s_decode_patch_periodicity(encoded_ib_idx, ib_idx_temp)
950+ call s_decode_patch_periodicity(encoded_ib_idx, ib_idx_temp, xp, yp, zp )
947951 call s_get_neighborhood_idx(ib_idx_temp, ib_idx) ! global patch ID - > local index
948952 if (ib_idx > 0 ) then
949953 ! get the vector pointing to the grid cell from the IB centroid
950- radial_vector = [x_cc(i), y_cc(j), 0._wp ] - [patch_ib(ib_idx)%x_centroid, &
951- & patch_ib(ib_idx)%y_centroid, 0._wp ]
952- if (num_dims == 3 ) radial_vector(3 ) = patch_ib(ib_idx)%z_centroid
954+ radial_vector(1 ) = x_cc(i) - (patch_ib(ib_idx)%x_centroid + real (xp, wp)* (x_domain%end - x_domain%beg))
955+ radial_vector(2 ) = y_cc(i) - (patch_ib(ib_idx)%y_centroid + real (yp, wp)* (y_domain%end - y_domain%beg))
956+ radial_vector(3 ) = 0._wp
957+ if (num_dims == 3 ) radial_vector(3 ) = z_cc(i) - (patch_ib(ib_idx)%z_centroid + real (zp, &
958+ & wp)* (z_domain%end - z_domain%beg))
953959
954960 local_force_contribution(:) = 0._wp
955961
0 commit comments