@@ -1004,13 +1004,13 @@ contains
10041004 integer :: i, j, k, ib_idx
10051005 real(wp), dimension(num_ibs, 3) :: forces, torques
10061006 real(wp), dimension(1:3) :: pressure_divergence, radial_vector
1007- real(wp) :: cell_volume
1007+ real(wp) :: cell_volume, dx, dy, dz
10081008
10091009 forces = 0._wp
10101010 torques = 0._wp
10111011
10121012 ! TODO :: This is currently only valid inviscid, and needs to be extended to add viscocity
1013- $:GPU_PARALLEL_LOOP(private=' [ib_idx,radial_vector,pressure_divergence,cell_volume]' , copy=' [forces,torques]' , copyin=' [ib_markers]' , collapse=3)
1013+ $:GPU_PARALLEL_LOOP(private=' [ib_idx,radial_vector,pressure_divergence,cell_volume, dx, dy, dz ]' , copy=' [forces,torques]' , copyin=' [ib_markers]' , collapse=3)
10141014 do i = 0, m
10151015 do j = 0, n
10161016 do k = 0, p
@@ -1023,16 +1023,19 @@ contains
10231023 else
10241024 radial_vector = [x_cc(i), y_cc(j), 0._wp] - [patch_ib(ib_idx)%x_centroid, patch_ib(ib_idx)%y_centroid, 0._wp]
10251025 end if
1026+ dx = x_cc(i+1)-x_cc(i)
1027+ dy = y_cc(j+1)-y_cc(j)
10261028
10271029 ! use a finite difference to compute the 2D components of the gradient of the pressure and cell volume
1028- pressure_divergence(1) = (pressure(i + 1, j, k) - pressure(i - 1, j, k))/(2._wp*x_cc(i) )
1029- pressure_divergence(2) = (pressure(i, j + 1, k) - pressure(i, j - 1, k))/(2._wp*y_cc(j) )
1030- cell_volume = x_cc(i)*y_cc(j)
1030+ pressure_divergence(1) = (pressure(i + 1, j, k) - pressure(i - 1, j, k))/(2._wp*dx )
1031+ pressure_divergence(2) = (pressure(i, j + 1, k) - pressure(i, j - 1, k))/(2._wp*dy )
1032+ cell_volume = dx*dy
10311033
10321034 ! add the 3D component, if we are working in 3 dimensions
10331035 if (num_dims == 3) then
1034- pressure_divergence(3) = (pressure(i, j, k + 1) - pressure(i, j, k - 1))/(2._wp*z_cc(k))
1035- cell_volume = cell_volume*z_cc(k)
1036+ dz = z_cc(k+1)-z_cc(k)
1037+ pressure_divergence(3) = (pressure(i, j, k + 1) - pressure(i, j, k - 1))/(2._wp*dz)
1038+ cell_volume = cell_volume*dz
10361039 else
10371040 pressure_divergence(3) = 0._wp
10381041 end if
0 commit comments