Skip to content

Commit

Permalink
Refactor the use of ix, iy, and iz
Browse files Browse the repository at this point in the history
  • Loading branch information
henryleberre committed Oct 27, 2024
1 parent 77cc57e commit fb60811
Show file tree
Hide file tree
Showing 7 changed files with 275 additions and 372 deletions.
11 changes: 1 addition & 10 deletions src/simulation/m_bubbles.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,6 @@ contains
subroutine s_initialize_bubbles_module

integer :: i, j, k, l, q
type(int_bounds_info) :: ix, iy, iz

! Configuring Coordinate Direction Indexes =========================
ix%beg = -buff_size; iy%beg = 0; iz%beg = 0

if (n > 0) iy%beg = -buff_size; if (p > 0) iz%beg = -buff_size

ix%end = m - ix%beg; iy%end = n - iy%beg; iz%end = p - iz%beg
! ==================================================================

@:ALLOCATE_GLOBAL(rs(1:nb))
@:ALLOCATE_GLOBAL(vs(1:nb))
Expand All @@ -89,7 +80,7 @@ contains
!$acc update device(ps, ms)
end if

@:ALLOCATE(divu%sf(ix%beg:ix%end, iy%beg:iy%end, iz%beg:iz%end))
@:ALLOCATE(divu%sf(idwbuff(1)%beg:idwbuff(1)%end, idwbuff(2)%beg:idwbuff(2)%end, idwbuff(3)%beg:idwbuff(3)%end))
@:ACC_SETUP_SFs(divu)

@:ALLOCATE_GLOBAL(bub_adv_src(0:m, 0:n, 0:p))
Expand Down
15 changes: 4 additions & 11 deletions src/simulation/m_chemistry.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ module m_chemistry

implicit none

type(int_bounds_info), private :: ix, iy, iz
type(scalar_field), private :: grads(1:3)

!$acc declare create(ix, iy, iz)
!$acc declare create(grads)

contains
Expand All @@ -29,16 +27,11 @@ contains

integer :: i

ix%beg = -buff_size
if (n > 0) then; iy%beg = -buff_size; else; iy%beg = 0; end if
if (p > 0) then; iz%beg = -buff_size; else; iz%beg = 0; end if

ix%end = m - ix%beg; iy%end = n - iy%beg; iz%end = p - iz%beg

!$acc update device(ix, iy, iz)

do i = 1, 3
@:ALLOCATE(grads(i)%sf(ix%beg:ix%end, iy%beg:iy%end, iz%beg:iz%end))
@:ALLOCATE(grads(i)%sf(&
& idwbuff(1)%beg:idwbuff(1)%end, &
& idwbuff(2)%beg:idwbuff(2)%end, &
& idwbuff(3)%beg:idwbuff(3)%end))
end do

!$acc kernels
Expand Down
39 changes: 27 additions & 12 deletions src/simulation/m_global_parameters.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,14 @@ module m_global_parameters

!$acc declare create(bub_idx)

! Cell Indices for the interior points (O-m, O-n, 0-p).
type(int_bounds_info) :: idwint(1:3)
!$acc declare create(idwint)

! Cell Indices for the entire domain, including the buffer region.
type(int_bounds_info) :: idwbuff(1:3)
!$acc declare create(idwbuff)

!> @name The number of fluids, along with their identifying indexes, respectively,
!! for which viscous effects, e.g. the shear and/or the volume Reynolds (Re)
!! numbers, will be non-negligible.
Expand Down Expand Up @@ -703,8 +711,6 @@ contains
integer :: i, j, k
integer :: fac

type(int_bounds_info) :: ix, iy, iz

#:if not MFC_CASE_OPTIMIZATION
! Determining the degree of the WENO polynomials
weno_polyn = (weno_order - 1)/2
Expand Down Expand Up @@ -1038,18 +1044,27 @@ contains
end if

! Configuring Coordinate Direction Indexes =========================
if (bubbles) then
ix%beg = -buff_size; iy%beg = 0; iz%beg = 0
if (n > 0) then
iy%beg = -buff_size
if (p > 0) then
iz%beg = -buff_size
end if
end if
idwint(1)%beg = 0; idwint(2)%beg = 0; idwint(3)%beg = 0
idwint(1)%end = m; idwint(2)%end = n; idwint(3)%end = p

ix%end = m - ix%beg; iy%end = n - iy%beg; iz%end = p - iz%beg
idwbuff(1)%beg = -buff_size
if (num_dims > 1) then; idwbuff(2)%beg = -buff_size; else; idwbuff(2)%beg = 0; end if
if (num_dims > 2) then; idwbuff(3)%beg = -buff_size; else; idwbuff(3)%beg = 0; end if

@:ALLOCATE_GLOBAL(ptil(ix%beg:ix%end, iy%beg:iy%end, iz%beg:iz%end))
idwbuff(1)%end = idwint(1)%end - idwbuff(1)%beg
idwbuff(2)%end = idwint(2)%end - idwbuff(2)%beg
idwbuff(3)%end = idwint(3)%end - idwbuff(3)%beg

!$acc update device(idwint, idwbuff)

! ==================================================================

! Configuring Coordinate Direction Indexes =========================
if (bubbles) then
@:ALLOCATE_GLOBAL(ptil(&
& idwbuff(1)%beg:idwbuff(1)%end, &
& idwbuff(2)%beg:idwbuff(2)%end, &
& idwbuff(3)%beg:idwbuff(3)%end))
end if

if (probe_wrt) then
Expand Down
Loading

0 comments on commit fb60811

Please sign in to comment.