Skip to content

Commit 7392d85

Browse files
committed
fix?
1 parent 30fcf3f commit 7392d85

File tree

1 file changed

+8
-74
lines changed

1 file changed

+8
-74
lines changed

channel/main.f90

Lines changed: 8 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ program main
5454
!real(kind=8), parameter :: beta(3) = (/ 0.0d0, -0.122243120495896d0, -0.377756879504104d0 /)
5555

5656
! Enable or disable phase field
57-
#define phiflag 0
57+
#define phiflag 1
5858
! Enable or disable temperature field
5959
#define thetaflag 0
6060

@@ -410,8 +410,6 @@ program main
410410
! compute distance function psi (used to compute normals)
411411
val = min(phi(i,j,k),1.0d0) ! avoid machine precision overshoots in phi that leads to problem with log
412412
psidi(i,j,k) = eps*log((val+enum)/(1.d0-val+enum))
413-
! compute here the tanh of distance function psi (used in the sharpening term) to avoid multiple computations of tanh
414-
tanh_psi(i,j,k) = tanh(0.5d0*psidi(i,j,k)*epsi)
415413
enddo
416414
enddo
417415
enddo
@@ -463,19 +461,6 @@ program main
463461
!$acc end host_data
464462

465463
! Substep 2: Compute normals (1.e-16 is a numerical tollerance to avoid 0/0) for surface tension force computation later
466-
!$acc kernels
467-
do k=1, piX%shape(3)
468-
do j=1, piX%shape(2)
469-
do i=1,nx
470-
normag = 1.d0/(sqrt(normx(i,j,k)*normx(i,j,k) + normy(i,j,k)*normy(i,j,k) + normz(i,j,k)*normz(i,j,k)) + enum)
471-
normx_f(i,j,k) = normx(i,j,k)*normag
472-
normy_f(i,j,k) = normy(i,j,k)*normag
473-
normz_f(i,j,k) = normz(i,j,k)*normag
474-
enddo
475-
enddo
476-
enddo
477-
!$acc end kernels
478-
479464
! Compute sharpening term flux split
480465
!$acc kernels
481466
do k=1+halo_ext, piX%shape(3)-halo_ext
@@ -528,26 +513,14 @@ program main
528513

529514
! second stage of RK4 - saved in rhsphik2
530515
!$acc parallel loop collapse(3) present(phi, phi_tmp, rhsphi)
531-
do k=1, piX%shape(3)
532-
do j=1, piX%shape(2)
516+
do k=1+halo_ext, piX%shape(3)-halo_ext
517+
do j=1+halo_ext, piX%shape(2)-halo_ext
533518
do i=1,nx
534519
phi_tmp(i,j,k) = phi(i,j,k) + 0.5d0 * dt * rhsphi(i,j,k)
535520
enddo
536521
enddo
537522
enddo
538-
!$acc end parallel loop
539-
! apply BC on phi_tmp (no-flux)
540-
!$acc parallel loop collapse(3)
541-
do k=1, piX%shape(3)
542-
do j=1, piX%shape(2)
543-
do i=1,nx
544-
kg = piX%lo(3) + k - 1 - halo_ext
545-
if (kg .eq. 1) phi_tmp(i,j,k-1) = phi_tmp(i,j,k)
546-
if (kg .eq. nz) phi_tmp(i,j,k+1) = phi_tmp(i,j,k)
547-
enddo
548-
enddo
549-
enddo
550-
! 4.3 Call halo exchanges along Y and Z for phi
523+
551524
!$acc host_data use_device(phi_tmp)
552525
CHECK_CUDECOMP_EXIT(cudecompUpdateHalosX(handle, grid_desc, phi_tmp, work_halo_d, CUDECOMP_DOUBLE, piX%halo_extents, halo_periods, 2))
553526
CHECK_CUDECOMP_EXIT(cudecompUpdateHalosX(handle, grid_desc, phi_tmp, work_halo_d, CUDECOMP_DOUBLE, piX%halo_extents, halo_periods, 3))
@@ -560,8 +533,6 @@ program main
560533
! compute distance function psi (used to compute normals)
561534
val = min(phi_tmp(i,j,k),1.0d0) ! avoid machine precision overshoots in phi that leads to problem with log
562535
psidi(i,j,k) = eps*log((val+enum)/(1.d0-val+enum))
563-
! compute here the tanh of distance function psi (used in the sharpening term) to avoid multiple computations of tanh
564-
tanh_psi(i,j,k) = tanh(0.5d0*psidi(i,j,k)*epsi)
565536
enddo
566537
enddo
567538
enddo
@@ -662,25 +633,14 @@ program main
662633

663634
! third stage of RK4 - saved in rhsphik3
664635
!$acc parallel loop collapse(3) present(phi, phi_tmp, rhsphik2)
665-
do k=1, piX%shape(3)
666-
do j=1, piX%shape(2)
636+
do k=1+halo_ext, piX%shape(3)-halo_ext
637+
do j=1+halo_ext, piX%shape(2)-halo_ext
667638
do i=1,nx
668639
phi_tmp(i,j,k) = phi(i,j,k) + 0.5d0*dt*rhsphik2(i,j,k)
669640
enddo
670641
enddo
671642
enddo
672643
!$acc end parallel loop
673-
! apply BC on phi_tmp (no-flux)
674-
!$acc parallel loop collapse(3)
675-
do k=1, piX%shape(3)
676-
do j=1, piX%shape(2)
677-
do i=1,nx
678-
kg = piX%lo(3) + k - 1 - halo_ext
679-
if (kg .eq. 1) phi_tmp(i,j,k-1) = phi_tmp(i,j,k)
680-
if (kg .eq. nz) phi_tmp(i,j,k+1) = phi_tmp(i,j,k)
681-
enddo
682-
enddo
683-
enddo
684644
! 4.3 Call halo exchanges along Y and Z for phi
685645
!$acc host_data use_device(phi_tmp)
686646
CHECK_CUDECOMP_EXIT(cudecompUpdateHalosX(handle, grid_desc, phi_tmp, work_halo_d, CUDECOMP_DOUBLE, piX%halo_extents, halo_periods, 2))
@@ -694,8 +654,6 @@ program main
694654
! compute distance function psi (used to compute normals)
695655
val = min(phi_tmp(i,j,k),1.0d0) ! avoid machine precision overshoots in phi that leads to problem with log
696656
psidi(i,j,k) = eps*log((val+enum)/(1.d0-val+enum))
697-
! compute here the tanh of distance function psi (used in the sharpening term) to avoid multiple computations of tanh
698-
tanh_psi(i,j,k) = tanh(0.5d0*psidi(i,j,k)*epsi)
699657
enddo
700658
enddo
701659
enddo
@@ -796,25 +754,14 @@ program main
796754

797755
! forth stage of RK4 - saved in rhsphik4
798756
!$acc parallel loop collapse(3) present(phi, phi_tmp, rhsphik3)
799-
do k=1, piX%shape(3)
800-
do j=1, piX%shape(2)
757+
do k=1+halo_ext, piX%shape(3)-halo_ext
758+
do j=1+halo_ext, piX%shape(2)-halo_ext
801759
do i=1,nx
802760
phi_tmp(i,j,k) = phi(i,j,k) + dt * rhsphik3(i,j,k)
803761
enddo
804762
enddo
805763
enddo
806764
!$acc end parallel loop
807-
! apply BC on phi_tmp (no-flux)
808-
!$acc parallel loop collapse(3)
809-
do k=1, piX%shape(3)
810-
do j=1, piX%shape(2)
811-
do i=1,nx
812-
kg = piX%lo(3) + k - 1 - halo_ext
813-
if (kg .eq. 1) phi_tmp(i,j,k-1) = phi_tmp(i,j,k)
814-
if (kg .eq. nz) phi_tmp(i,j,k+1) = phi_tmp(i,j,k)
815-
enddo
816-
enddo
817-
enddo
818765
! 4.3 Call halo exchanges along Y and Z for phi
819766
!$acc host_data use_device(phi_tmp)
820767
CHECK_CUDECOMP_EXIT(cudecompUpdateHalosX(handle, grid_desc, phi_tmp, work_halo_d, CUDECOMP_DOUBLE, piX%halo_extents, halo_periods, 2))
@@ -828,8 +775,6 @@ program main
828775
! compute distance function psi (used to compute normals)
829776
val = min(phi_tmp(i,j,k),1.0d0) ! avoid machine precision overshoots in phi that leads to problem with log
830777
psidi(i,j,k) = eps*log((val+enum)/(1.d0-val+enum))
831-
! compute here the tanh of distance function psi (used in the sharpening term) to avoid multiple computations of tanh
832-
tanh_psi(i,j,k) = tanh(0.5d0*psidi(i,j,k)*epsi)
833778
enddo
834779
enddo
835780
enddo
@@ -939,17 +884,6 @@ program main
939884
enddo
940885
enddo
941886
!$acc end kernels
942-
! apply BC on phi_tmp (no-flux)
943-
!$acc parallel loop collapse(3)
944-
do k=1, piX%shape(3)
945-
do j=1, piX%shape(2)
946-
do i=1,nx
947-
kg = piX%lo(3) + k - 1 - halo_ext
948-
if (kg .eq. 1) phi(i,j,k-1) = phi(i,j,k)
949-
if (kg .eq. nz) phi(i,j,k+1) = phi(i,j,k)
950-
enddo
951-
enddo
952-
enddo
953887
! 4.3 Call halo exchanges along Y and Z for phi
954888
!$acc host_data use_device(phi)
955889
CHECK_CUDECOMP_EXIT(cudecompUpdateHalosX(handle, grid_desc, phi, work_halo_d, CUDECOMP_DOUBLE, piX%halo_extents, halo_periods, 2))

0 commit comments

Comments
 (0)