@@ -85,7 +85,7 @@ contains
8585 call s_ib_3D_airfoil(i, ib_markers)
8686 ! STL+ IBM patch
8787 elseif (patch_ib(i)%geometry == 12 ) then
88- call s_ib_model (i, ib_markers)
88+ call s_ib_3d_model (i, ib_markers)
8989 end if
9090 end do
9191 !> @}
@@ -274,8 +274,8 @@ contains
274274
275275 $:GPU_PARALLEL_LOOP(private=' [i,j]' ,&
276276 & copyin=' [patch_id,center,radius]' , collapse=2)
277- do j = 0 , n
278- do i = 0 , m
277+ do j = -gp_layers , n+gp_layers
278+ do i = -gp_layers , m+gp_layers
279279 if ((x_cc(i) - center(1))**2 &
280280 + (y_cc(j) - center(2))**2 <= radius**2) &
281281 then
@@ -378,8 +378,8 @@ contains
378378
379379 $:GPU_PARALLEL_LOOP(private=' [i,j,xy_local,k,f]' , &
380380 & copyin=' [patch_id,center,inverse_rotation,offset,ma,ca_in,airfoil_grid_u,airfoil_grid_l]' , collapse=2)
381- do j = 0 , n
382- do i = 0 , m
381+ do j = -gp_layers , n+gp_layers
382+ do i = -gp_layers , m+gp_layers
383383 xy_local = [x_cc(i) - center(1), y_cc(j) - center(2), 0._wp] ! get coordinate frame centered on IB
384384 xy_local = matmul(inverse_rotation, xy_local) ! rotate the frame into the IB' s coordinates
385385 xy_local = xy_local - offset ! airfoils are a patch that require a centroid offset
@@ -529,9 +529,9 @@ contains
529529
530530 $:GPU_PARALLEL_LOOP(private= ' [i,j,l,xyz_local,k,f]' ,&
531531 & copyin= ' [patch_id,center,inverse_rotation,offset,ma,ca_in,airfoil_grid_u,airfoil_grid_l,z_min,z_max]' , collapse= 3 )
532- do l = 0 , p
533- do j = 0 , n
534- do i = 0 , m
532+ do l = - gp_layers , p+ gp_layers
533+ do j = - gp_layers , n+ gp_layers
534+ do i = - gp_layers , m+ gp_layers
535535 xyz_local = [x_cc(i) - center(1 ), y_cc(j) - center(2 ), z_cc(l) - center(3 )] ! get coordinate frame centered on IB
536536 xyz_local = matmul (inverse_rotation, xyz_local) ! rotate the frame into the IB' s coordinates
537537 xyz_local = xyz_local - offset ! airfoils are a patch that require a centroid offset
@@ -623,8 +623,8 @@ contains
623623 ! variables of the current patch are assigned to this cell.
624624 $:GPU_PARALLEL_LOOP(private= ' [i,j, xy_local]' ,&
625625 & copyin= ' [patch_id,center,length,inverse_rotation,x_cc,y_cc]' , collapse= 2 )
626- do j = 0 , n
627- do i = 0 , m
626+ do j = - gp_layers , n+ gp_layers
627+ do i = - gp_layers , m+ gp_layers
628628 ! get the x and y coordinates in the local IB frame
629629 xy_local = [x_cc(i) - center(1 ), y_cc(j) - center(2 ), 0._wp ]
630630 xy_local = matmul (inverse_rotation, xy_local)
@@ -678,9 +678,9 @@ contains
678678 ! the current patch are assigned to this cell.
679679 $:GPU_PARALLEL_LOOP(private=' [i,j,k,cart_y,cart_z]' ,&
680680 & copyin=' [patch_id,center,radius]' , collapse=3)
681- do k = 0 , p
682- do j = 0 , n
683- do i = 0 , m
681+ do k = -gp_layers , p+gp_layers
682+ do j = -gp_layers , n+gp_layers
683+ do i = -gp_layers , m+gp_layers
684684 if (grid_geometry == 3) then
685685 call s_convert_cylindrical_to_cartesian_coord(y_cc(j), z_cc(k))
686686 else
@@ -734,9 +734,9 @@ contains
734734 ! of the current patch are assigned to this cell.
735735 $:GPU_PARALLEL_LOOP(private= ' [i,j,k,xyz_local,cart_y,cart_z]' ,&
736736 & copyin= ' [patch_id,center,length,inverse_rotation]' , collapse= 3 )
737- do k = 0 , p
738- do j = 0 , n
739- do i = 0 , m
737+ do k = - gp_layers , p+ gp_layers
738+ do j = - gp_layers , n+ gp_layers
739+ do i = - gp_layers , m+ gp_layers
740740
741741 if (grid_geometry == 3 ) then
742742 ! TODO :: This does not work and is not covered by any tests. This should be fixed
@@ -804,9 +804,9 @@ contains
804804 ! variables of the current patch are assigned to this cell.
805805 $:GPU_PARALLEL_LOOP(private=' [i,j,k,xyz_local,cart_y,cart_z]' ,&
806806 & copyin=' [patch_id,center,length,radius,inverse_rotation]' , collapse=3)
807- do k = 0 , p
808- do j = 0 , n
809- do i = 0 , m
807+ do k = -gp_layers , p+gp_layers
808+ do j = -gp_layers , n+gp_layers
809+ do i = -gp_layers , m+gp_layers
810810
811811 if (grid_geometry == 3) then
812812 call s_convert_cylindrical_to_cartesian_coord(y_cc(j), z_cc(k))
@@ -867,8 +867,8 @@ contains
867867 ! domain
868868 $:GPU_PARALLEL_LOOP(private=' [i,j, xy_local]' ,&
869869 & copyin=' [patch_id,center,ellipse_coeffs,inverse_rotation,x_cc,y_cc]' , collapse=2)
870- do j = 0 , n
871- do i = 0 , m
870+ do j = -gp_layers , n+gp_layers
871+ do i = -gp_layers , m+gp_layers
872872 ! get the x and y coordinates in the local IB frame
873873 xy_local = [x_cc(i) - center(1), y_cc(j) - center(2), 0._wp]
874874 xy_local = matmul(inverse_rotation, xy_local)
@@ -884,11 +884,9 @@ contains
884884
885885 end subroutine s_ib_ellipse
886886
887- !> The STL patch is a 2/3D geometry that is imported from an STL file.
887+ !> The STL patch is a 2D geometry that is imported from an STL file.
888888 !! @param patch_id is the patch identifier
889889 !! @param ib_markers Array to track patch ids
890- !! @param STL_levelset STL levelset
891- !! @param STL_levelset_norm STL levelset normals
892890 subroutine s_ib_model(patch_id, ib_markers)
893891
894892 integer, intent(in) :: patch_id
@@ -900,37 +898,77 @@ contains
900898
901899 real(wp) :: eta
902900 real(wp), dimension(1:3) :: point, local_point, offset
903- real(wp), dimension(1:3) :: center, xyz_local
901+ real(wp), dimension(1:3) :: center, xy_local
904902 real(wp), dimension(1:3, 1:3) :: inverse_rotation
905903
906904 model => models(patch_id)%model
907905 center = 0._wp
908906 center(1) = patch_ib(patch_id)%x_centroid
909907 center(2) = patch_ib(patch_id)%y_centroid
910- if (p > 0) center(3) = patch_ib(patch_id)%z_centroid
911908 inverse_rotation(:, :) = patch_ib(patch_id)%rotation_matrix_inverse(:, :)
912909 offset(:) = patch_ib(patch_id)%centroid_offset(:)
913910
914- do i = 0, m
915- do j = 0, n
916- do k = 0, p
911+ do i = 0-gp_layers, m+gp_layers
912+ do j = -gp_layers, n+gp_layers
917913
918- xyz_local = [x_cc(i) - center(1), y_cc(j) - center(2), 0._wp]
919- if (p > 0) then
920- xyz_local(3) = z_cc(k) - center(3)
914+ xy_local = [x_cc(i) - center(1), y_cc(j) - center(2), 0._wp]
915+ xy_local = matmul(inverse_rotation, xy_local)
916+ xy_local = xy_local - offset
917+
918+ if (grid_geometry == 3) then
919+ xy_local = f_convert_cyl_to_cart(xy_local)
921920 end if
921+
922+ eta = f_model_is_inside(model, xy_local, (/dx(i), dy(j), 0._wp/), patch_ib(patch_id)%model_spc)
923+
924+ ! Reading STL boundary vertices and compute the levelset and levelset_norm
925+ if (eta > patch_ib(patch_id)%model_threshold) then
926+ ib_markers%sf(i, j, 0) = patch_id
927+ end if
928+
929+ end do
930+ end do
931+
932+ end subroutine s_ib_model
933+
934+ !> The STL patch is a 3D geometry that is imported from an STL file.
935+ !! @param patch_id is the patch identifier
936+ !! @param ib_markers Array to track patch ids
937+ subroutine s_ib_3d_model(patch_id, ib_markers)
938+
939+ integer, intent(in) :: patch_id
940+ type(integer_field), intent(inout) :: ib_markers
941+
942+ integer :: i, j, k !< Generic loop iterators
943+
944+ type(t_model), pointer :: model
945+
946+ real(wp) :: eta
947+ real(wp), dimension(1:3) :: point, local_point, offset
948+ real(wp), dimension(1:3) :: center, xyz_local
949+ real(wp), dimension(1:3, 1:3) :: inverse_rotation
950+
951+ model => models(patch_id)%model
952+ center = 0._wp
953+ center(1) = patch_ib(patch_id)%x_centroid
954+ center(2) = patch_ib(patch_id)%y_centroid
955+ center(3) = patch_ib(patch_id)%z_centroid
956+ inverse_rotation(:, :) = patch_ib(patch_id)%rotation_matrix_inverse(:, :)
957+ offset(:) = patch_ib(patch_id)%centroid_offset(:)
958+
959+ do i = 0-gp_layers, m+gp_layers
960+ do j = -gp_layers, n+gp_layers
961+ do k = -gp_layers, p+gp_layers
962+
963+ xyz_local = [x_cc(i) - center(1), y_cc(j) - center(2), z_cc(k) - center(3)]
922964 xyz_local = matmul(inverse_rotation, xyz_local)
923965 xyz_local = xyz_local - offset
924966
925967 if (grid_geometry == 3) then
926968 xyz_local = f_convert_cyl_to_cart(xyz_local)
927969 end if
928970
929- if (p == 0) then
930- eta = f_model_is_inside(model, xyz_local, (/dx(i), dy(j), 0._wp/), patch_ib(patch_id)%model_spc)
931- else
932- eta = f_model_is_inside(model, xyz_local, (/dx(i), dy(j), dz(k)/), patch_ib(patch_id)%model_spc)
933- end if
971+ eta = f_model_is_inside(model, xyz_local, (/dx(i), dy(j), dz(k)/), patch_ib(patch_id)%model_spc)
934972
935973 ! Reading STL boundary vertices and compute the levelset and levelset_norm
936974 if (eta > patch_ib(patch_id)%model_threshold) then
@@ -941,7 +979,7 @@ contains
941979 end do
942980 end do
943981
944- end subroutine s_ib_model
982+ end subroutine s_ib_3d_model
945983
946984 !> Subroutine that computes a rotation matrix for converting to the rotating frame of the boundary
947985 subroutine s_update_ib_rotation_matrix(patch_id)
0 commit comments