@@ -94,8 +94,9 @@ contains
9494 do i = 1 , num_ibs
9595 if (patch_ib(i)%moving_ibm /= 0 ) then
9696 moving_immersed_boundary_flag = .true.
97- exit
97+
9898 end if
99+ call s_update_ib_rotation_matrix(i)
99100 end do
100101
101102 ! Allocating the patch identities bookkeeping variable
@@ -149,7 +150,7 @@ contains
149150 !! @param q_prim_vf Primitive variables
150151 !! @param pb Internal bubble pressure
151152 !! @param mv Mass of vapor in bubble
152- pure subroutine s_ibm_correct_state (q_cons_vf , q_prim_vf , pb_in , mv_in )
153+ subroutine s_ibm_correct_state (q_cons_vf , q_prim_vf , pb_in , mv_in )
153154
154155 type(scalar_field), &
155156 dimension (sys_size), &
@@ -267,13 +268,15 @@ contains
267268 ! we know the object is not moving if moving_ibm is 0 (false)
268269 vel_g = 0._wp
269270 else
270- radial_vector = physical_loc - (patch_ib(patch_id)%x_centroid, &
271- patch_ib(patch_id)%y_centroid, patch_ib(patch_id)%z_centroid)
272- rotational_velocity = cross_product(matmul (patch_ib(patch_id)%rotation_matrix, patch_ib(patch_id)%angular_vel), radial_vector)
271+ ! get the vector that points from the centroid to the ghost
272+ radial_vector = physical_loc - [patch_ib(patch_id)%x_centroid, &
273+ patch_ib(patch_id)%y_centroid, patch_ib(patch_id)%z_centroid]
274+ ! convert the angular velcoity from the inertial reference frame to the fluids frame, then convert to linear velocity
275+ rotation_velocity = cross_product(matmul (patch_ib(patch_id)%rotation_matrix, patch_ib(patch_id)%angular_vel), radial_vector)
273276 do q = 1 , 3
274277 ! if mibm is 1 or 2 , then the boundary may be moving
275278 vel_g(q) = patch_ib(patch_id)%vel(q) ! add the linear velocity
276- vel_g(q) = vel_g(q) + rotational_velocity (q) ! add the rotational velocity
279+ vel_g(q) = vel_g(q) + rotation_velocity (q) ! add the rotational velocity
277280 end do
278281 end if
279282 end if
@@ -902,8 +905,8 @@ contains
902905
903906 end subroutine s_interpolate_image_point
904907
905- !> Subroutine the updates the moving imersed boundary positions via Euler ' s method
906- impure subroutine s_update_mib_rotation_matrix (patch_id)
908+ !> Subroutine that computes a rotation matrix for converting to the rotating frame of the boundary
909+ impure subroutine s_update_ib_rotation_matrix (patch_id )
907910
908911 integer , intent (in ) :: patch_id
909912 integer :: i
@@ -915,33 +918,36 @@ contains
915918 if (num_dims == 3 ) then
916919 ! also compute the x and y axes in 3D
917920 angle = patch_ib(patch_id)%angles(1 )
918- rotation(1, 1, :) = ( 1._wp, 0._wp , 0._wp )
919- rotation(1, 2, :) = ( 0._wp, cos(angle), -sin(angle))
920- rotation(1, 3, :) = ( 0._wp, sin(angle), cos(angle) )
921+ rotation(1 , 1 , :) = [ 1._wp , 0._wp , 0._wp ]
922+ rotation(1 , 2 , :) = [ 0._wp , cos (angle), - sin (angle)]
923+ rotation(1 , 3 , :) = [ 0._wp , sin (angle), cos (angle) ]
921924
922925 angle = patch_ib(patch_id)%angles(2 )
923- rotation(2, 1, :) = ( cos(angle) , 0._wp, sin(angle))
924- rotation(2, 2, :) = ( 0._wp , 1._wp, 0._wp )
925- rotation(2, 3, :) = ( -sin(angle), 0._wp, cos(angle))
926+ rotation(2 , 1 , :) = [ cos (angle) , 0._wp , sin (angle)]
927+ rotation(2 , 2 , :) = [ 0._wp , 1._wp , 0._wp ]
928+ rotation(2 , 3 , :) = [ - sin (angle), 0._wp , cos (angle)]
926929
927930 ! apply the y rotation to the x rotation
928- rotation(1, :, :) = matmul(rotation(1, :, :), rotation(2, :, :))
931+ patch_ib(patch_id)%rotation_matrix(:, :) = matmul (rotation(1 , :, :), rotation(2 , :, :))
932+ patch_ib(patch_id)%rotation_matrix_inverse(:, :) = matmul (tranpose(rotation(2 , :, :)), transpose (rotation(1 , :, :)))
929933 end if
930934 ! z component first, since it applies in 2D and 3D
931935 angle = patch_ib(patch_id)%angles(3 )
932- rotation(3, 1, :) = ( cos(angle), -sin(angle), 0._wp)
933- rotation(3, 2, :) = ( sin(angle), cos(angle) , 0._wp)
934- rotation(3, 3, :) = ( 0._wp , 0._wp , 1._wp)
936+ rotation(3 , 1 , :) = [ cos (angle), - sin (angle), 0._wp ]
937+ rotation(3 , 2 , :) = [ sin (angle), cos (angle) , 0._wp ]
938+ rotation(3 , 3 , :) = [ 0._wp , 0._wp , 1._wp ]
935939
936940 if (num_dims == 3 ) then
937941 ! apply the z rotation to the xy rotation in 3D
938- patch_ib(patch_id)%rotation_matrix(:, :) = matmul(rotation(1, :, :), rotation(3, :, :))
942+ patch_ib(patch_id)%rotation_matrix(:, :) = matmul (patch_ib(patch_id)%rotation_matrix(:, :), rotation(3 , :, :))
943+ patch_ib(patch_id)%rotation_matrix_inverse(:, :) = matmul (transpose (rotation(3 , :, :)), patch_ib(patch_id)%rotation_matrix_inverse(:, :))
939944 else
940945 ! write out only the z rotation in 2D
941946 patch_ib(patch_id)%rotation_matrix(:, :) = rotation(3 , :, :)
947+ patch_ib(patch_id)%rotation_matrix_inverse(:, :) = transpose (rotation(3 , :, :))
942948 end if
943949
944- end subroutine s_update_mib_rotation_matrix
950+ end subroutine s_update_ib_rotation_matrix
945951
946952 !> Resets the current indexes of immersed boundaries and replaces them after updating
947953 !> the position of each moving immersed boundary
0 commit comments