@@ -85,7 +85,7 @@ contains
8585 $:GPU_PARALLEL_LOOP(private= ' [i]' )
8686 do i = 1 , num_ibs
8787 if (patch_ib(i)%moving_ibm /= 0 ) then
88- call s_compute_moment_of_inertia(patch_ib(i), patch_ib(i)%angular_vel)
88+ call s_compute_moment_of_inertia(patch_ib(i), patch_ib(i)%angular_vel, patch_ib(i)%moment )
8989 end if
9090 call s_update_ib_rotation_matrix(i)
9191 end do
@@ -1108,12 +1108,13 @@ contains
11081108 end subroutine s_compute_centroid_offset
11091109
11101110 !> Computes the moment of inertia for an immersed boundary
1111- subroutine s_compute_moment_of_inertia (patch , moment )
1111+ subroutine s_compute_moment_of_inertia (patch , axis , moment )
11121112
11131113 $:GPU_ROUTINE(parallelism= ' [seq]' )
11141114
11151115 type(ib_patch_parameters), intent (in ) :: patch
1116- real (wp), dimension (3 ), intent (out ) :: moment
1116+ real (wp), dimension (3 ), intent (in ) :: axis
1117+ real (wp), intent (out ) :: moment
11171118 real (wp) :: distance_to_axis, cell_volume
11181119 real (wp), dimension (3 ) :: position, closest_point_along_axis, vector_to_axis, normal_axis
11191120 integer :: i, j, k, count, ib_marker
@@ -1129,7 +1130,6 @@ contains
11291130 moment = 0.4 * patch%mass* (patch%radius)** 2
11301131 else ! we do not have an analytic moment of inertia calculation and need to approximate it directly via a sum
11311132 count = 0
1132- moment = 0._wp
11331133 cell_volume = (x_cc(1 ) - x_cc(0 ))* (y_cc(1 ) - y_cc(0 ))
11341134 ! computed without grid stretching. Update in the loop to perform with stretching
11351135 if (p /= 0 ) then
@@ -1140,14 +1140,16 @@ contains
11401140
11411141 if (p == 0 ) then
11421142 normal_axis = [0 , 0 , 1 ]
1143- else if (sqrt (sum (moment ** 2 )) < sgm_eps) then
1143+ else if (sqrt (sum (axis ** 2 )) < sgm_eps) then
11441144 ! if the object is not actually rotating at this time, return a dummy value and exit
11451145 moment = 1._wp
11461146 return
11471147 else
1148- normal_axis = moment / sqrt (sum (moment ** 2 ))
1148+ normal_axis = axis / sqrt (sum (axis ** 2 ))
11491149 end if
11501150
1151+ moment = 0._wp
1152+
11511153 do i = 0 , m
11521154 do j = 0 , n
11531155 do k = 0 , p
0 commit comments