BLOCKS, BOUNDARIES: Simplify the block_info structure.

Signed-off-by: Grzegorz Kowal <grzegorz@amuncode.org>
This commit is contained in:
Grzegorz Kowal 2022-02-05 23:18:25 -03:00
parent db537fd635
commit c268109465
2 changed files with 70 additions and 107 deletions

View File

@ -280,16 +280,9 @@ module blocks
!
integer(kind=4) :: direction
! the corner index determining the position of
! the corner boundary and when direction is
! specified also the face or edge boundaries
! the boundary region location
!
integer(kind=4) :: corner(NDIMS)
! the level difference between the block and
! its neighbor
!
integer(kind=4) :: level_difference
integer(kind=4) :: location(NDIMS)
end type block_info

View File

@ -651,7 +651,7 @@ module boundaries
select case(pinfo%direction)
case(1)
s = 3 - pinfo%corner(1)
s = 3 - pinfo%location(1)
#if NDIMS == 3
sbuf(:,:,:,l) = 2.5d-01 * ((pdata%fx(:,nb:nem:2,nb:nem:2,s) &
+ pdata%fx(:,nbp:ne:2,nbp:ne:2,s)) &
@ -664,7 +664,7 @@ module boundaries
case(2)
s = 3 - pinfo%corner(2)
s = 3 - pinfo%location(2)
#if NDIMS == 3
sbuf(:,:,:,l) = 2.5d-01 * ((pdata%fy(:,nb:nem:2,nb:nem:2,s) &
@ -679,7 +679,7 @@ module boundaries
case(3)
s = 3 - pinfo%corner(3)
s = 3 - pinfo%location(3)
sbuf(:,:,:,l) = 2.5d-01 * ((pdata%fz(:,nb:nem:2,nb:nem:2,s) &
+ pdata%fz(:,nbp:ne:2,nbp:ne:2,s)) &
@ -713,10 +713,10 @@ module boundaries
pdata => pmeta%data
n = pinfo%direction
i = pinfo%corner(1)
j = pinfo%corner(2)
i = pinfo%location(1)
j = pinfo%location(2)
#if NDIMS == 3
k = pinfo%corner(3)
k = pinfo%location(3)
#endif /* NDIMS == 3 */
select case(n)
@ -1159,9 +1159,9 @@ module boundaries
pdata => pinfo%neigh%data
i = pinfo%corner(1)
j = pinfo%corner(2)
k = pinfo%corner(3)
i = pinfo%location(1)
j = pinfo%location(2)
k = pinfo%location(3)
if (idir == 1) then
is = dlims(i,1)
@ -1201,9 +1201,9 @@ module boundaries
pdata => pinfo%meta%data
i = pinfo%corner(1)
j = pinfo%corner(2)
k = pinfo%corner(3)
i = pinfo%location(1)
j = pinfo%location(2)
k = pinfo%location(3)
if (idir == 1) then
il = nlims(i,1)
@ -1454,7 +1454,7 @@ module boundaries
pdata => pinfo%neigh%data
call block_face_restrict(idir, pinfo%corner, &
call block_face_restrict(idir, pinfo%location, &
pdata%q, sbuf(:,:,:,:,l))
pinfo => pinfo%prev
@ -1474,7 +1474,7 @@ module boundaries
pmeta => pinfo%meta
pm(:) = pinfo%corner(:)
pm(:) = pinfo%location(:)
if (idir == 1) then
il = nlims(pm(1),1)
@ -1718,7 +1718,7 @@ module boundaries
pdata => pinfo%neigh%data
call block_face_prolong(idir, pinfo%corner, pdata%q, &
call block_face_prolong(idir, pinfo%location, pdata%q, &
sbuf(:,:,:,:,l), status)
pinfo => pinfo%prev
@ -1738,7 +1738,7 @@ module boundaries
pdata => pinfo%meta%data
pm(:) = pinfo%corner(:)
pm(:) = pinfo%location(:)
if (idir == 1) then
il = nlims(pm(1),1)
@ -2022,10 +2022,10 @@ module boundaries
pneigh => pinfo%neigh
i = pinfo%corner(1)
j = pinfo%corner(2)
i = pinfo%location(1)
j = pinfo%location(2)
#if NDIMS == 3
k = pinfo%corner(3)
k = pinfo%location(3)
#endif /* NDIMS == 3 */
if (idir == 1) then
@ -2069,10 +2069,10 @@ module boundaries
pmeta => pinfo%meta
i = pinfo%corner(1)
j = pinfo%corner(2)
i = pinfo%location(1)
j = pinfo%location(2)
#if NDIMS == 3
k = pinfo%corner(3)
k = pinfo%location(3)
#endif /* NDIMS == 3 */
if (idir == 1) then
@ -2339,10 +2339,10 @@ module boundaries
pneigh => pinfo%neigh
i = pinfo%corner(1)
j = pinfo%corner(2)
i = pinfo%location(1)
j = pinfo%location(2)
#if NDIMS == 3
k = pinfo%corner(3)
k = pinfo%location(3)
#endif /* NDIMS == 3 */
call block_edge_restrict(idir, [ i, j, k ], pneigh%data%q, &
@ -2366,10 +2366,10 @@ module boundaries
pmeta => pinfo%meta
i = pinfo%corner(1)
j = pinfo%corner(2)
i = pinfo%location(1)
j = pinfo%location(2)
#if NDIMS == 3
k = pinfo%corner(3)
k = pinfo%location(3)
#endif /* NDIMS == 3 */
if (idir == 1) then
@ -2637,7 +2637,7 @@ module boundaries
pmeta => pinfo%meta
pneigh => pinfo%neigh
pm(1:NDIMS) = pinfo%corner(1:NDIMS)
pm(1:NDIMS) = pinfo%location(1:NDIMS)
call block_edge_prolong(idir, pm, pneigh%data%q, &
sbuf(:,:,:,:,l), status)
@ -2661,7 +2661,7 @@ module boundaries
pmeta => pinfo%meta
pm(1:NDIMS) = pinfo%corner(1:NDIMS)
pm(1:NDIMS) = pinfo%location(1:NDIMS)
if (idir == 1) then
il = nb
@ -2917,13 +2917,13 @@ module boundaries
pneigh => pinfo%neigh
is = dlims(pinfo%corner(1),1)
it = dlims(pinfo%corner(1),2)
js = dlims(pinfo%corner(2),1)
jt = dlims(pinfo%corner(2),2)
is = dlims(pinfo%location(1),1)
it = dlims(pinfo%location(1),2)
js = dlims(pinfo%location(2),1)
jt = dlims(pinfo%location(2),2)
#if NDIMS == 3
ks = dlims(pinfo%corner(3),1)
kt = dlims(pinfo%corner(3),2)
ks = dlims(pinfo%location(3),1)
kt = dlims(pinfo%location(3),2)
#endif /* NDIMS == 3 */
buf(:,:,:,:,l) = pneigh%data%q(1:nv,is:it,js:jt,ks:kt)
@ -2943,13 +2943,13 @@ module boundaries
pmeta => pinfo%meta
il = blims(pinfo%corner(1),1)
iu = blims(pinfo%corner(1),2)
jl = blims(pinfo%corner(2),1)
ju = blims(pinfo%corner(2),2)
il = blims(pinfo%location(1),1)
iu = blims(pinfo%location(1),2)
jl = blims(pinfo%location(2),1)
ju = blims(pinfo%location(2),2)
#if NDIMS == 3
kl = blims(pinfo%corner(3),1)
ku = blims(pinfo%corner(3),2)
kl = blims(pinfo%location(3),1)
ku = blims(pinfo%location(3),2)
#endif /* NDIMS == 3 */
pmeta%data%q(1:nv,il:iu,jl:ju,kl:ku) = buf(:,:,:,:,l)
@ -3168,10 +3168,10 @@ module boundaries
pneigh => pinfo%neigh
i = pinfo%corner(1)
j = pinfo%corner(2)
i = pinfo%location(1)
j = pinfo%location(2)
#if NDIMS == 3
k = pinfo%corner(3)
k = pinfo%location(3)
#endif /* NDIMS == 3 */
call block_corner_restrict([ i, j, k ], pneigh%data%q, &
@ -3197,13 +3197,13 @@ module boundaries
pmeta => pinfo%meta
il = nlims(pinfo%corner(1),1)
iu = nlims(pinfo%corner(1),2)
jl = nlims(pinfo%corner(2),1)
ju = nlims(pinfo%corner(2),2)
il = nlims(pinfo%location(1),1)
iu = nlims(pinfo%location(1),2)
jl = nlims(pinfo%location(2),1)
ju = nlims(pinfo%location(2),2)
#if NDIMS == 3
kl = nlims(pinfo%corner(3),1)
ku = nlims(pinfo%corner(3),2)
kl = nlims(pinfo%location(3),1)
ku = nlims(pinfo%location(3),2)
#endif /* NDIMS == 3 */
pmeta%data%q(1:nv,il:iu,jl:ju,kl:ku) = rbuf(:,:,:,:,l)
@ -3424,10 +3424,10 @@ module boundaries
pneigh => pinfo%neigh
i = pinfo%corner(1)
j = pinfo%corner(2)
i = pinfo%location(1)
j = pinfo%location(2)
#if NDIMS == 3
k = pinfo%corner(3)
k = pinfo%location(3)
#endif /* NDIMS == 3 */
call block_corner_prolong([ i, j, k ], pneigh%data%q, &
@ -3452,13 +3452,13 @@ module boundaries
pdata => pinfo%meta%data
il = nlims(pinfo%corner(1),1)
iu = nlims(pinfo%corner(1),2)
jl = nlims(pinfo%corner(2),1)
ju = nlims(pinfo%corner(2),2)
il = nlims(pinfo%location(1),1)
iu = nlims(pinfo%location(1),2)
jl = nlims(pinfo%location(2),1)
ju = nlims(pinfo%location(2),2)
#if NDIMS == 3
kl = nlims(pinfo%corner(3),1)
ku = nlims(pinfo%corner(3),2)
kl = nlims(pinfo%location(3),1)
ku = nlims(pinfo%location(3),2)
#endif /* NDIMS == 3 */
pdata%q(:,il:iu,jl:ju,kl:ku) = rbuf(:,:,:,:,l)
@ -5238,8 +5238,8 @@ module boundaries
! subroutine APPEND_EXCHANGE_BLOCK:
! ---------------------------------
!
! Subroutine appends an info block to the element of array of block
! exchange lists. The element is determined by the processes of the meta
! Subroutine appends an info block to the array of the lists of the block
! exchange. The element is determined by the process numbers of the meta
! and neighbor blocks.
!
! Arguments:
@ -5253,68 +5253,38 @@ module boundaries
!
subroutine append_exchange_block(pmeta, pneigh, dir, pos)
! include external variables
!
use blocks, only : block_info, block_meta
! local variables are not implicit by default
!
implicit none
! subroutine arguments
!
type(block_meta), pointer, intent(inout) :: pmeta, pneigh
integer , intent(in) :: dir
integer, dimension(3) , intent(in) :: pos
! local variables
!
integer :: icol, irow
! local pointers
!
type(block_info), pointer :: pinfo
!
!-------------------------------------------------------------------------------
!
! get the column and row indices
!
irow = pneigh%process
icol = pmeta%process
! increase the counter for the number of blocks to exchange
!
bcount(irow,icol) = bcount(irow,icol) + 1
! allocate a new info object
!
allocate(pinfo)
! fill out its fields
!
pinfo%meta => pmeta
pinfo%neigh => pneigh
pinfo%direction = dir
pinfo%corner(1:NDIMS) = pos(1:NDIMS)
pinfo%level_difference = pmeta%level - pneigh%level
pinfo%meta => pmeta
pinfo%neigh => pneigh
pinfo%direction = dir
pinfo%location(1:NDIMS) = pos(1:NDIMS)
! nullify pointer fields
!
nullify(pinfo%prev)
nullify(pinfo%next)
! check if the list is empty
!
if (associated(barray(irow,icol)%ptr)) then
! if it is, associate the newly created block with it
!
if (associated(barray(irow,icol)%ptr)) &
pinfo%prev => barray(irow,icol)%ptr
end if ! %ptr associated
! point the list to the newly created block
!
barray(irow,icol)%ptr => pinfo
!-------------------------------------------------------------------------------