Skip to content

Commit f2e5692

Browse files
committed
bug fixes and IBM halo exchange fix
1 parent 78043ab commit f2e5692

File tree

5 files changed

+37
-34
lines changed

5 files changed

+37
-34
lines changed

src/simulation/m_ibm.fpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ contains
8585
!$acc update device(levelset_norm%sf)
8686

8787
! Get neighboring IB variables from other processors
88-
call s_populate_ib_buffers(ib_markers, gp_layers)
88+
call s_populate_ib_buffers(ib_markers)
8989

9090
!$acc update host(ib_markers%sf)
9191

@@ -108,15 +108,14 @@ contains
108108

109109
end subroutine s_ibm_setup
110110

111-
subroutine s_populate_ib_buffers(ib_markers, gp_layers)
111+
subroutine s_populate_ib_buffers(ib_markers)
112112

113113
type(integer_field), intent(inout) :: ib_markers
114-
integer, intent(in) :: gp_layers
115114

116115
#:for DIRC, DIRI in [('x', 1), ('y', 2), ('z', 3)]
117116
#:for LOCC, LOCI in [('beg', -1), ('end', 1)]
118-
if (bc_${DIRC}$%${LOCC}$ > 0) then
119-
call s_mpi_sendrecv_ib_buffers(ib_markers, gp_layers, ${DIRI}$, ${LOCI}$)
117+
if (bc_${DIRC}$%${LOCC}$ >= 0) then
118+
call s_mpi_sendrecv_ib_buffers(ib_markers, ${DIRI}$, ${LOCI}$)
120119
end if
121120
#:endfor
122121
#:endfor

src/simulation/m_mpi_proxy.fpp

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ module m_mpi_proxy
4444
4545
!> @name Generic flags used to identify and report MPI errors
4646
!> @{
47-
integer, private :: err_code, ierr, i_halo_size
47+
integer, private :: err_code, ierr
4848
!> @}
49+
50+
integer :: i_halo_size
4951
!$acc declare create(i_halo_size)
5052
5153
contains
@@ -70,9 +72,7 @@ contains
7072
end if
7173
7274
!$acc declare create(i_halo_size)
73-
7475
@:ALLOCATE(ib_buff_send(0:i_halo_size), ib_buff_recv(0:i_halo_size))
75-
7676
end if
7777
#endif
7878
@@ -235,11 +235,11 @@ contains
235235
236236
end subroutine s_mpi_bcast_user_inputs
237237
238-
subroutine s_mpi_sendrecv_ib_buffers(ib_markers, gp_layers, mpi_dir, pbc_loc)
238+
subroutine s_mpi_sendrecv_ib_buffers(ib_markers, mpi_dir, pbc_loc)
239239
240240
type(integer_field), intent(inout) :: ib_markers
241241
242-
integer, intent(in) :: gp_layers, mpi_dir, pbc_loc
242+
integer, intent(in) :: mpi_dir, pbc_loc
243243
244244
integer :: i, j, k, l, r, q !< Generic loop iterators
245245
@@ -261,8 +261,8 @@ contains
261261
262262
buffer_counts = (/ &
263263
gp_layers*(n + 1)*(p + 1), &
264-
gp_layers*(m + 2*buff_size + 1)*(p + 1), &
265-
gp_layers*(m + 2*buff_size + 1)*(n + 2*buff_size + 1) &
264+
gp_layers*(m + 2*gp_layers + 1)*(p + 1), &
265+
gp_layers*(m + 2*gp_layers + 1)*(n + 2*gp_layers + 1) &
266266
/)
267267
268268
buffer_count = buffer_counts(mpi_dir)
@@ -312,8 +312,8 @@ contains
312312
!$acc parallel loop collapse(3) gang vector default(present) private(r)
313313
do l = 0, p
314314
do k = 0, gp_layers - 1
315-
do j = -buff_size, m + buff_size
316-
r = ((j + buff_size) + (m + 2*buff_size + 1)* &
315+
do j = -gp_layers, m + gp_layers
316+
r = ((j + gp_layers) + (m + 2*gp_layers+ 1)* &
317317
(k + gp_layers*l))
318318
ib_buff_send(r) = ib_markers%sf(j, k + pack_offset, l)
319319
end do
@@ -322,10 +322,10 @@ contains
322322
#:else
323323
!$acc parallel loop collapse(3) gang vector default(present) private(r)
324324
do l = 0, gp_layers - 1
325-
do k = -buff_size, n + buff_size
326-
do j = -buff_size, m + buff_size
327-
r = ((j + buff_size) + (m + 2*buff_size + 1)* &
328-
((k + buff_size) + (n + 2*buff_size + 1)*l))
325+
do k = -gp_layers, n + gp_layers
326+
do j = -gp_layers, m + gp_layers
327+
r = ((j + gp_layers) + (m + 2*gp_layers + 1)* &
328+
((k + gp_layers) + (n + 2*gp_layers + 1)*l))
329329
ib_buff_send(r) = ib_markers%sf(j, k, l + pack_offset)
330330
end do
331331
end do
@@ -389,8 +389,8 @@ contains
389389
!$acc parallel loop collapse(3) gang vector default(present) private(r)
390390
do l = 0, p
391391
do k = -gp_layers, -1
392-
do j = -buff_size, m + buff_size
393-
r = ((j + buff_size) + (m + 2*buff_size + 1)* &
392+
do j = -gp_layers, m + gp_layers
393+
r = ((j + gp_layers) + (m + 2*gp_layers + 1)* &
394394
((k + gp_layers) + gp_layers*l))
395395
ib_markers%sf(j, k + unpack_offset, l) = ib_buff_recv(r)
396396
end do
@@ -400,10 +400,10 @@ contains
400400
! Unpacking buffer from bc_z%beg
401401
!$acc parallel loop collapse(3) gang vector default(present) private(r)
402402
do l = -gp_layers, -1
403-
do k = -buff_size, n + buff_size
404-
do j = -buff_size, m + buff_size
405-
r = ((j + buff_size) + (m + 2*buff_size + 1)* &
406-
((k + buff_size) + (n + 2*buff_size + 1)* &
403+
do k = -gp_layers, n + gp_layers
404+
do j = -gp_layers, m + gp_layers
405+
r = ((j + gp_layers) + (m + 2*gp_layers + 1)* &
406+
((k + gp_layers) + (n + 2*gp_layers + 1)* &
407407
(l + gp_layers)))
408408
ib_markers%sf(j, k, l + unpack_offset) = ib_buff_recv(r)
409409
end do
@@ -420,9 +420,11 @@ contains
420420
subroutine s_mpi_send_random_number(phi_rn, num_freq)
421421
integer, intent(in) :: num_freq
422422
real(wp), intent(inout), dimension(1:num_freq) :: phi_rn
423+
423424
#ifdef MFC_MPI
424425
call MPI_BCAST(phi_rn, num_freq, mpi_p, 0, MPI_COMM_WORLD, ierr)
425426
#endif
427+
426428
end subroutine s_mpi_send_random_number
427429
428430
subroutine s_finalize_mpi_proxy_module()

src/simulation/m_start_up.fpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,6 +1480,7 @@ contains
14801480

14811481

14821482
call s_initialize_mpi_common_module()
1483+
call s_initialize_mpi_proxy_module()
14831484
call s_initialize_variables_conversion_module()
14841485
if (grid_geometry == 3) call s_initialize_fftw_module()
14851486
call s_initialize_riemann_solvers_module()
@@ -1686,6 +1687,7 @@ contains
16861687
if (viscous) then
16871688
call s_finalize_viscous_module()
16881689
end if
1690+
call s_finalize_mpi_proxy_module()
16891691

16901692
if (surface_tension) call s_finalize_surface_tension_module()
16911693
if (bodyForces) call s_finalize_body_forces_module()

src/simulation/m_viscous.fpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ contains
13921392
end if
13931393
end if
13941394

1395-
if (bc_x%beg <= BC_GHOST_EXTRAPOLATION) then
1395+
if (bc_x%beg <= BC_GHOST_EXTRAP) then
13961396
!$acc parallel loop collapse(2) gang vector default(present)
13971397
do l = idwbuff(3)%beg, idwbuff(3)%end
13981398
do k = idwbuff(2)%beg, idwbuff(2)%end
@@ -1401,7 +1401,7 @@ contains
14011401
end do
14021402
end do
14031403
end if
1404-
if (bc_x%end <= BC_GHOST_EXTRAPOLATION) then
1404+
if (bc_x%end <= BC_GHOST_EXTRAP) then
14051405
!$acc parallel loop collapse(2) gang vector default(present)
14061406
do l = idwbuff(3)%beg, idwbuff(3)%end
14071407
do k = idwbuff(2)%beg, idwbuff(2)%end
@@ -1411,7 +1411,7 @@ contains
14111411
end do
14121412
end if
14131413
if (n > 0) then
1414-
if (bc_y%beg <= BC_GHOST_EXTRAPOLATION .and. bc_y%beg /= BC_NULL) then
1414+
if (bc_y%beg <= BC_GHOST_EXTRAP .and. bc_y%beg /= BC_NULL) then
14151415
!$acc parallel loop collapse(2) gang vector default(present)
14161416
do l = idwbuff(3)%beg, idwbuff(3)%end
14171417
do j = idwbuff(1)%beg, idwbuff(1)%end
@@ -1420,7 +1420,7 @@ contains
14201420
end do
14211421
end do
14221422
end if
1423-
if (bc_y%end <= BC_GHOST_EXTRAPOLATION) then
1423+
if (bc_y%end <= BC_GHOST_EXTRAP) then
14241424
!$acc parallel loop collapse(2) gang vector default(present)
14251425
do l = idwbuff(3)%beg, idwbuff(3)%end
14261426
do j = idwbuff(1)%beg, idwbuff(1)%end
@@ -1430,7 +1430,7 @@ contains
14301430
end do
14311431
end if
14321432
if (p > 0) then
1433-
if (bc_z%beg <= BC_GHOST_EXTRAPOLATION) then
1433+
if (bc_z%beg <= BC_GHOST_EXTRAP) then
14341434
!$acc parallel loop collapse(2) gang vector default(present)
14351435
do k = idwbuff(2)%beg, idwbuff(2)%end
14361436
do j = idwbuff(1)%beg, idwbuff(1)%end
@@ -1440,7 +1440,7 @@ contains
14401440
end do
14411441
end do
14421442
end if
1443-
if (bc_z%end <= BC_GHOST_EXTRAPOLATION) then
1443+
if (bc_z%end <= BC_GHOST_EXTRAP) then
14441444
!$acc parallel loop collapse(2) gang vector default(present)
14451445
do k = idwbuff(2)%beg, idwbuff(2)%end
14461446
do j = idwbuff(1)%beg, idwbuff(1)%end

src/simulation/m_weno.fpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,12 @@ contains
272272
! any contributions from outside of the physical domain during
273273
! the WENO reconstruction
274274
if (null_weights) then
275-
if (bc_s%beg == BC_RIEMANN_EXTRAPOLATION) then
275+
if (bc_s%beg == BC_RIEMANN_EXTRAP) then
276276
d_cbR_${XYZ}$ (1, 0) = 0._wp; d_cbR_${XYZ}$ (0, 0) = 1._wp
277277
d_cbL_${XYZ}$ (1, 0) = 0._wp; d_cbL_${XYZ}$ (0, 0) = 1._wp
278278
end if
279279

280-
if (bc_s%end == BC_RIEMANN_EXTRAPOLATION) then
280+
if (bc_s%end == BC_RIEMANN_EXTRAP) then
281281
d_cbR_${XYZ}$ (0, s) = 0._wp; d_cbR_${XYZ}$ (1, s) = 1._wp
282282
d_cbL_${XYZ}$ (0, s) = 0._wp; d_cbL_${XYZ}$ (1, s) = 1._wp
283283
end if
@@ -418,14 +418,14 @@ contains
418418
! any contributions from outside of the physical domain during
419419
! the WENO reconstruction
420420
if (null_weights) then
421-
if (bc_s%beg == BC_RIEMANN_EXTRAPOLATION) then
421+
if (bc_s%beg == BC_RIEMANN_EXTRAP) then
422422
d_cbR_${XYZ}$ (1:2, 0) = 0._wp; d_cbR_${XYZ}$ (0, 0) = 1._wp
423423
d_cbL_${XYZ}$ (1:2, 0) = 0._wp; d_cbL_${XYZ}$ (0, 0) = 1._wp
424424
d_cbR_${XYZ}$ (2, 1) = 0._wp; d_cbR_${XYZ}$ (:, 1) = d_cbR_${XYZ}$ (:, 1)/sum(d_cbR_${XYZ}$ (:, 1))
425425
d_cbL_${XYZ}$ (2, 1) = 0._wp; d_cbL_${XYZ}$ (:, 1) = d_cbL_${XYZ}$ (:, 1)/sum(d_cbL_${XYZ}$ (:, 1))
426426
end if
427427

428-
if (bc_s%end == BC_RIEMANN_EXTRAPOLATION) then
428+
if (bc_s%end == BC_RIEMANN_EXTRAP) then
429429
d_cbR_${XYZ}$ (0, s - 1) = 0._wp; d_cbR_${XYZ}$ (:, s - 1) = d_cbR_${XYZ}$ (:, s - 1)/sum(d_cbR_${XYZ}$ (:, s - 1))
430430
d_cbL_${XYZ}$ (0, s - 1) = 0._wp; d_cbL_${XYZ}$ (:, s - 1) = d_cbL_${XYZ}$ (:, s - 1)/sum(d_cbL_${XYZ}$ (:, s - 1))
431431
d_cbR_${XYZ}$ (0:1, s) = 0._wp; d_cbR_${XYZ}$ (2, s) = 1._wp

0 commit comments

Comments
 (0)