@@ -198,16 +198,16 @@ contains
198198
199199 ! set the Moving IBM interior Pressure Values
200200 $:GPU_PARALLEL_LOOP(private= ' [i,j,k]' , copyin= ' [E_idx]' , collapse= 3 )
201- do l = 0 , p
202- do k = 0 , n
203- do j = 0 , m
204- if (ib_markers%sf(j, k, l) /= 0 ) then
205- q_prim_vf(E_idx)%sf(j, k, l) = 1._wp
206- end if
207- end do
201+ do l = 0 , p
202+ do k = 0 , n
203+ do j = 0 , m
204+ if (ib_markers%sf(j, k, l) /= 0 ) then
205+ q_prim_vf(E_idx)%sf(j, k, l) = 1._wp
206+ end if
208207 end do
209208 end do
210- $:END_GPU_PARALLEL_LOOP()
209+ end do
210+ $:END_GPU_PARALLEL_LOOP()
211211
212212 if (num_gps > 0 ) then
213213 $:GPU_PARALLEL_LOOP(private= ' [i,physical_loc,dyn_pres,alpha_rho_IP, alpha_IP,pres_IP,vel_IP,vel_g,vel_norm_IP,r_IP, v_IP,pb_IP,mv_IP,nmom_IP,presb_IP,massv_IP,rho, gamma,pi_inf,Re_K,G_K,Gs,gp,innerp,norm,buf, radial_vector, rotation_velocity, j,k,l,q,qv_K,c_IP,nbub,patch_id]' )
@@ -258,12 +258,13 @@ contains
258258 end if
259259
260260 ! set the pressure
261- if (patch_ib(patch_id)%moving_ibm == 0 ) then
261+ if (patch_ib(patch_id)%moving_ibm < = 1 ) then
262262 q_prim_vf(E_idx)%sf(j, k, l) = pres_IP
263263 else
264264 q_prim_vf(E_idx)%sf(j, k, l) = 0._wp
265265 $:GPU_LOOP(parallelism= ' [seq]' )
266266 do q = 1 , num_fluids
267+ ! Se the pressure inside a moving immersed boundary based upon the pressure of the image point. acceleration, and normal vector direction
267268 q_prim_vf(E_idx)%sf(j, k, l) = q_prim_vf(E_idx)%sf(j, k, l) + pres_IP/ (1._wp - 2._wp * abs (levelset%sf(j, k, l, patch_id)* alpha_rho_IP(q)/ pres_IP)* dot_product (patch_ib(patch_id)%force/ patch_ib(patch_id)%mass, levelset_norm%sf(j, k, l, patch_id, :)))
268269 end do
269270 end if
@@ -1002,16 +1003,16 @@ contains
10021003 idwbuff(2)%beg:idwbuff(2)%end, &
10031004 idwbuff(3)%beg:idwbuff(3)%end), intent(in) :: pressure
10041005
1005- integer :: i, j, k, ib_idx
1006+ integer :: i, j, k, l, ib_idx
10061007 real(wp), dimension(num_ibs, 3) :: forces, torques
1007- real(wp), dimension(1:3) :: pressure_divergence, radial_vector
1008+ real(wp), dimension(1:3) :: pressure_divergence, radial_vector, temp_torque_vector
10081009 real(wp) :: cell_volume, dx, dy, dz
10091010
10101011 forces = 0._wp
10111012 torques = 0._wp
10121013
10131014 ! TODO :: This is currently only valid inviscid, and needs to be extended to add viscocity
1014- $:GPU_PARALLEL_LOOP(private=' [ib_idx,radial_vector,pressure_divergence,cell_volume, dx, dy, dz]' , copy=' [forces,torques]' , copyin=' [ib_markers]' , collapse=3)
1015+ $:GPU_PARALLEL_LOOP(private=' [ib_idx,radial_vector,pressure_divergence,cell_volume,temp_torque_vector, dx, dy, dz]' , copy=' [forces,torques]' , copyin=' [ib_markers]' , collapse=3)
10151016 do i = 0, m
10161017 do j = 0, n
10171018 do k = 0, p
@@ -1042,10 +1043,13 @@ contains
10421043 end if
10431044
10441045 ! Update the force values atomically to prevent race conditions
1045- $:GPU_ATOMIC(atomic=' update' )
1046- forces(ib_idx, :) = forces(ib_idx, :) - (pressure_divergence*cell_volume)
1047- $:GPU_ATOMIC(atomic=' update' )
1048- torques(ib_idx, :) = torques(ib_idx, :) - (cross_product(radial_vector, pressure_divergence)*cell_volume)
1046+ temp_torque_vector = cross_product(radial_vector, pressure_divergence)*cell_volume ! separate out to make atomics safe
1047+ do l = 1, 3
1048+ $:GPU_ATOMIC(atomic=' update' )
1049+ forces(ib_idx, l) = forces(ib_idx, l) - (pressure_divergence(l)*cell_volume)
1050+ $:GPU_ATOMIC(atomic=' update' )
1051+ torques(ib_idx, l) = torques(ib_idx, l) - temp_torque_vector(l)
1052+ end do
10491053 end if
10501054 end if
10511055 end do
0 commit comments