Skip to content

Commit

Permalink
Fix mapping bug for equivalent grids
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrack committed Nov 21, 2019
1 parent ff4aae0 commit 924dffb
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/pw/pw_grids.F
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,8 @@ END SUBROUTINE pw_grid_distribute
!> \param pw_grid ...
!> \param yz_mask ...
!> \param ref_grid ...
!> \par History
!> - Fix mapping bug for pw_grid eqv to ref_grid (21.11.2019, MK)
! **************************************************************************************************
SUBROUTINE pre_tag(pw_grid, yz_mask, ref_grid)

Expand All @@ -1206,8 +1208,6 @@ SUBROUTINE pre_tag(pw_grid, yz_mask, ref_grid)
INTEGER :: gmax, ig, ip, lby, lbz, my, mz, ny, nz, &
uby, ubz, y, yp, z, zp

!------------------------------------------------------------------------------

ny = ref_grid%npts(2)
nz = ref_grid%npts(3)
lby = pw_grid%bounds(1, 2)
Expand All @@ -1221,11 +1221,11 @@ SUBROUTINE pre_tag(pw_grid, yz_mask, ref_grid)
DO ip = 0, ref_grid%para%group_size - 1
DO ig = 1, ref_grid%para%nyzray(ip)
! go from mapped coordinates to original coordinates
! 0 .. N-1 -> -n/2 .. (n+1)/2
! 1, 2, ..., n-1, n -> 0, 1, ..., (n/2)-1, -(n/2), -(n/2)+1, ..., -2, -1
y = ref_grid%para%yzp(1, ig, ip) - 1
IF (y > ny/2) y = y - ny
IF (y >= ny/2) y = y - ny
z = ref_grid%para%yzp(2, ig, ip) - 1
IF (z > nz/2) z = z - nz
IF (z >= nz/2) z = z - nz
! check if this is inside the realm of the new grid
IF (y < lby .OR. y > uby .OR. z < lbz .OR. z > ubz) CYCLE
! go to shifted coordinates
Expand All @@ -1235,7 +1235,7 @@ SUBROUTINE pre_tag(pw_grid, yz_mask, ref_grid)
IF (pw_grid%grid_span == HALFSPACE) THEN
yp = -y - 2*lby + 2
zp = -z - 2*lbz + 2
! if the referenz grid is larger than the mirror point may be
! if the reference grid is larger than the mirror point may be
! outside the new grid even if the original point is inside
IF (yp < 1 .OR. yp > my .OR. zp < 1 .OR. zp > mz) CYCLE
gmax = MAX(yz_mask(y, z), yz_mask(yp, zp))
Expand All @@ -1258,8 +1258,6 @@ SUBROUTINE pre_tag(pw_grid, yz_mask, ref_grid)

END SUBROUTINE pre_tag

!------------------------------------------------------------------------------

! **************************************************************************************************
!> \brief ...
!> \param yz_mask ...
Expand Down

0 comments on commit 924dffb

Please sign in to comment.