Skip to content

Commit 88d2e6c

Browse files
Fixed broken moment of inertia workaround and regenerated golden files
1 parent 2bd2b59 commit 88d2e6c

4 files changed

Lines changed: 23 additions & 21 deletions

File tree

src/simulation/m_ibm.fpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/simulation/m_time_steppers.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ contains
756756
! update the angular velocity with the torque value
757757
patch_ib(i)%angular_vel = (patch_ib(i)%angular_vel*patch_ib(i)%moment) + (rk_coef(s, &
758758
& 3)*dt*patch_ib(i)%torque/rk_coef(s, 4)) ! add the torque to the angular momentum
759-
if (num_dims == 3) call s_compute_moment_of_inertia(patch_ib(i), patch_ib(i)%angular_vel)
759+
if (num_dims == 3) call s_compute_moment_of_inertia(patch_ib(i), patch_ib(i)%angular_vel, patch_ib(i)%moment)
760760
! update the moment of inertia to be based on the direction of the angular momentum
761761
patch_ib(i)%angular_vel = patch_ib(i)%angular_vel/patch_ib(i)%moment
762762
end if

tests/38B4AED7/golden-metadata.txt

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/38B4AED7/golden.txt

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)