Skip to content

Commit effd324

Browse files
Added the rotation matrix calculation, which will be needed for identifying rotated markers and velocity calculations
1 parent e1c3b3f commit effd324

File tree

1 file changed

+32
-11
lines changed

1 file changed

+32
-11
lines changed

src/simulation/m_ibm.fpp

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -897,24 +897,45 @@ contains
897897
end subroutine s_interpolate_image_point
898898

899899
!> Subroutine the updates the moving imersed boundary positions via Euler's method
900-
impure subroutine s_propagate_mib(patch_id)
900+
impure subroutine s_update_mib_rotation_matrix(patch_id)
901901
902902
integer, intent(in) :: patch_id
903903
integer :: i
904904
905-
! start by using euler's method naiively, but eventually incorporate more sophistocation
906-
if (patch_ib(patch_id)%moving_ibm == 1) then
907-
! this continues with euler's method, which is obviously not that great and we need to add acceleration
908-
do i = 1, 3
909-
patch_ib(patch_id)%vel(i) = patch_ib(patch_id)%vel(i) + 0.0*dt ! TODO :: ADD EXTERNAL FORCES HERE
910-
end do
905+
real(wp), dimension(3, 3, 3) :: rotation
906+
real(wp) :: angle
907+
908+
! construct the x, y, and z rotation matrices
909+
if (num_dims == 3) then
910+
! also compute the x and y axes in 3D
911+
angle = patch_ib(patch_id)%angles(1)
912+
rotation(1, 1, :) = (1._wp, 0._wp , 0._wp )
913+
rotation(1, 2, :) = (0._wp, cos(angle), -sin(angle))
914+
rotation(1, 3, :) = (0._wp, sin(angle), cos(angle) )
915+
916+
angle = patch_ib(patch_id)%angles(2)
917+
rotation(2, 1, :) = (cos(angle) , 0._wp, sin(angle))
918+
rotation(2, 2, :) = (0._wp , 1._wp, 0._wp )
919+
rotation(2, 3, :) = (-sin(angle), 0._wp, cos(angle))
911920
912-
patch_ib(patch_id)%x_centroid = patch_ib(patch_id)%x_centroid + patch_ib(patch_id)%vel(1)*dt
913-
patch_ib(patch_id)%y_centroid = patch_ib(patch_id)%y_centroid + patch_ib(patch_id)%vel(2)*dt
914-
patch_ib(patch_id)%z_centroid = patch_ib(patch_id)%z_centroid + patch_ib(patch_id)%vel(3)*dt
921+
! apply the y rotation to the x rotation
922+
rotation(1, :, :) = matmul(rotation(1, :, :), rotation(2, :, :))
923+
end if
924+
! z component first, since it applies in 2D and 3D
925+
angle = patch_ib(patch_id)%angles(3)
926+
rotation(3, 1, :) = (cos(angle), -sin(angle), 0._wp)
927+
rotation(3, 2, :) = (sin(angle), cos(angle) , 0._wp)
928+
rotation(3, 3, :) = (0._wp , 0._wp , 1._wp)
929+
930+
if (num_dims == 3) then
931+
! apply the z rotation to the xy rotation in 3D
932+
patch_ib(patch_id)%rotation_matrix(:, :) = matmul(rotation(1, :, :), rotation(3, :, :))
933+
else
934+
! write out only the z rotation in 2D
935+
patch_ib(patch_id)%rotation_matrix(:, :) = rotation(3, :, :)
915936
end if
916937
917-
end subroutine s_propagate_mib
938+
end subroutine s_update_mib_rotation_matrix
918939
919940
!> Resets the current indexes of immersed boundaries and replaces them after updating
920941
!> the position of each moving immersed boundary

0 commit comments

Comments
 (0)