@@ -27,7 +27,7 @@ module m_ib_patches
2727
2828 implicit none
2929
30- private; public :: s_apply_ib_patches
30+ private; public :: s_apply_ib_patches, s_update_ib_rotation_matrix
3131
3232 real (wp) :: x_centroid, y_centroid, z_centroid
3333 real (wp) :: length_x, length_y, length_z
@@ -546,7 +546,7 @@ contains
546546 do j = 0, n
547547 do i = 0, m
548548 ! get the x and y coodinates in the local IB frame
549- xy_local = [x_cc(i) - x_centroid, y_cc(j) - y_centroid]
549+ xy_local = [x_cc(i) - x_centroid, y_cc(j) - y_centroid, 0._wp ]
550550 xy_local = matmul(inverse_rotation, xy_local)
551551 if (x_boundary%beg <= xy_local(1) .and. &
552552 x_boundary%end >= xy_local(1) .and. &
@@ -993,6 +993,51 @@ contains
993993
994994 end subroutine s_ib_model
995995
996+ !> Subroutine that computes a rotation matrix for converting to the rotating frame of the boundary
997+ subroutine s_update_ib_rotation_matrix(patch_id)
998+
999+ integer, intent(in) :: patch_id
1000+ integer :: i
1001+
1002+ real(wp), dimension(3, 3, 3) :: rotation
1003+ real(wp) :: angle
1004+
1005+ ! construct the x, y, and z rotation matrices
1006+ if (num_dims == 3) then
1007+ ! also compute the x and y axes in 3D
1008+ angle = patch_ib(patch_id)%angles(1)
1009+ rotation(1, 1, :) = [1._wp, 0._wp , 0._wp ]
1010+ rotation(1, 2, :) = [0._wp, cos(angle), -sin(angle)]
1011+ rotation(1, 3, :) = [0._wp, sin(angle), cos(angle) ]
1012+
1013+ angle = patch_ib(patch_id)%angles(2)
1014+ rotation(2, 1, :) = [cos(angle) , 0._wp, sin(angle)]
1015+ rotation(2, 2, :) = [0._wp , 1._wp, 0._wp ]
1016+ rotation(2, 3, :) = [-sin(angle), 0._wp, cos(angle)]
1017+
1018+ ! apply the y rotation to the x rotation
1019+ patch_ib(patch_id)%rotation_matrix(:, :) = matmul(rotation(1, :, :), rotation(2, :, :))
1020+ patch_ib(patch_id)%rotation_matrix_inverse(:, :) = matmul(transpose(rotation(2, :, :)), transpose(rotation(1, :, :)))
1021+ end if
1022+
1023+ ! z component first, since it applies in 2D and 3D
1024+ angle = patch_ib(patch_id)%angles(3)
1025+ rotation(3, 1, :) = [cos(angle), -sin(angle), 0._wp]
1026+ rotation(3, 2, :) = [sin(angle), cos(angle) , 0._wp]
1027+ rotation(3, 3, :) = [0._wp , 0._wp , 1._wp]
1028+
1029+ if (num_dims == 3) then
1030+ ! apply the z rotation to the xy rotation in 3D
1031+ patch_ib(patch_id)%rotation_matrix(:, :) = matmul(patch_ib(patch_id)%rotation_matrix(:, :), rotation(3, :, :))
1032+ patch_ib(patch_id)%rotation_matrix_inverse(:, :) = matmul(transpose(rotation(3, :, :)), patch_ib(patch_id)%rotation_matrix_inverse(:, :))
1033+ else
1034+ ! write out only the z rotation in 2D
1035+ patch_ib(patch_id)%rotation_matrix(:, :) = rotation(3, :, :)
1036+ patch_ib(patch_id)%rotation_matrix_inverse(:, :) = transpose(rotation(3, :, :))
1037+ end if
1038+
1039+ end subroutine s_update_ib_rotation_matrix
1040+
9961041 subroutine s_convert_cylindrical_to_cartesian_coord(cyl_y, cyl_z)
9971042 $:GPU_ROUTINE(parallelism=' [seq]' )
9981043
0 commit comments