Skip to content

Commit ddfcd0f

Browse files
Updated 2D airfoil
1 parent 007949d commit ddfcd0f

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

src/common/m_ib_patches.fpp

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,17 @@ contains
185185
integer :: i, j, k
186186
integer :: Np1, Np2
187187

188-
x0 = patch_ib(patch_id)%x_centroid
189-
y0 = patch_ib(patch_id)%y_centroid
188+
real(wp), dimension(1:3) :: xy_local !< x and y coordinates in local IB frame
189+
real(wp), dimension(1:3, 1:3) :: inverse_rotation
190+
191+
x_centroid = patch_ib(patch_id)%x_centroid
192+
y_centroid = patch_ib(patch_id)%y_centroid
190193
ca_in = patch_ib(patch_id)%c
191194
pa = patch_ib(patch_id)%p
192195
ma = patch_ib(patch_id)%m
193196
ta = patch_ib(patch_id)%t
194197
theta = pi*patch_ib(patch_id)%theta/180._wp
198+
inverse_rotation(:, :) = patch_ib(patch_id)%rotation_matrix_inverse(:, :)
195199

196200
! rank(dx) is not consistent between pre_process and simulation. This IFDEF prevents compilation errors
197201
#ifdef MFC_PRE_PROCESS
@@ -259,15 +263,17 @@ contains
259263

260264
do j = 0, n
261265
do i = 0, m
262-
263266
if (.not. f_is_default(patch_ib(patch_id)%theta)) then
264-
x_act = (x_cc(i) - x0)*cos(theta) - (y_cc(j) - y0)*sin(theta) + x0
265-
y_act = (x_cc(i) - x0)*sin(theta) + (y_cc(j) - y0)*cos(theta) + y0
267+
x_act = (x_cc(i) - x0)*cos(theta) - (y_cc(j) - y0)*sin(theta)
268+
y_act = (x_cc(i) - x0)*sin(theta) + (y_cc(j) - y0)*cos(theta)
266269
else
267-
x_act = x_cc(i)
270+
x_act = x_cc(i) -
268271
y_act = y_cc(j)
269272
end if
270273

274+
xyz_local = [x_act, y_act, 0._wp] ! get coordinate frame centered on IB
275+
xyz_local = matmul(inverse_rotation, xy_local) ! rotate the frame into the IB's coordiantes
276+
271277
if (x_act >= x0 .and. x_act <= x0 + ca_in) then
272278
xa = (x_act - x0)/ca_in
273279
if (xa <= pa) then
@@ -714,6 +720,8 @@ contains
714720
715721
integer :: i, j, k !< Generic loop iterators
716722
real(wp) :: radius
723+
real(wp), dimension(1:3) :: xyz_local !< x and y coordinates in local IB frame
724+
real(wp), dimension(1:3, 1:3) :: inverse_rotation
717725
718726
! Transferring the cylindrical patch's centroid, length, radius,
719727
! smoothing patch identity and smoothing coefficient information
@@ -725,15 +733,16 @@ contains
725733
length_y = patch_ib(patch_id)%length_y
726734
length_z = patch_ib(patch_id)%length_z
727735
radius = patch_ib(patch_id)%radius
736+
inverse_rotation(:, :) = patch_ib(patch_id)%rotation_matrix_inverse(:, :)
728737

729738
! Computing the beginning and the end x-, y- and z-coordinates of
730739
! the cylinder based on its centroid and lengths
731-
x_boundary%beg = x_centroid - 0.5_wp*length_x
732-
x_boundary%end = x_centroid + 0.5_wp*length_x
733-
y_boundary%beg = y_centroid - 0.5_wp*length_y
734-
y_boundary%end = y_centroid + 0.5_wp*length_y
735-
z_boundary%beg = z_centroid - 0.5_wp*length_z
736-
z_boundary%end = z_centroid + 0.5_wp*length_z
740+
x_boundary%beg = -0.5_wp*length_x
741+
x_boundary%end = 0.5_wp*length_x
742+
y_boundary%beg = -0.5_wp*length_y
743+
y_boundary%end = 0.5_wp*length_y
744+
z_boundary%beg = -0.5_wp*length_z
745+
z_boundary%end = 0.5_wp*length_z
737746

738747
! Initializing the pseudo volume fraction value to 1. The value will
739748
! be modified as the patch is laid out on the grid, but only in the

0 commit comments

Comments
 (0)