Skip to content

Commit

Permalink
fix offset in spectral space
Browse files Browse the repository at this point in the history
  • Loading branch information
Nanoseb committed Jan 15, 2025
1 parent e45dd7f commit cf161e9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/omp/kernels/spectral_processing.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ module m_omp_spectral

contains
subroutine process_spectral_div_u( &
div_u, waves, nx_spec, ny_spec, nz_spec, y_sp_st, z_sp_st, &
div_u, waves, nx_spec, ny_spec, nz_spec, x_sp_st, y_sp_st, z_sp_st, &
nx, ny, nz, ax, bx, ay, by, az, bz &
)

complex(dp), intent(inout), dimension(:, :, :) :: div_u
complex(dp), intent(in), dimension(:, :, :) :: waves
real(dp), intent(in), dimension(:) :: ax, bx, ay, by, az, bz
integer, intent(in) :: nx_spec, ny_spec, nz_spec
integer, intent(in) :: y_sp_st, z_sp_st
integer, intent(in) :: x_sp_st, y_sp_st, z_sp_st
integer, intent(in) :: nx, ny, nz

integer :: i, j, k, ix, iy, iz
Expand All @@ -25,7 +25,7 @@ subroutine process_spectral_div_u( &
div_r = real(div_u(i, j, k), kind=dp)/nx/ny/nz
div_c = aimag(div_u(i, j, k))/nx/ny/nz

ix = i
ix = i + x_sp_st
iy = j + y_sp_st
iz = k + z_sp_st

Expand Down
4 changes: 3 additions & 1 deletion src/omp/poisson_fft.f90
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ function init(mesh, xdirps, ydirps, zdirps) result(poisson_fft)

call decomp_2d_fft_init(PHYSICAL_IN_X)
call decomp_2d_fft_get_size(istart, iend, isize)
! Converts a start position into an offset
istart(:) = istart(:) - 1
call poisson_fft%spec_init(mesh, xdirps, ydirps, zdirps, isize, istart)

allocate (poisson_fft%c_x(poisson_fft%nx_spec, poisson_fft%ny_spec, &
Expand Down Expand Up @@ -78,7 +80,7 @@ subroutine fft_postprocess_omp(self)
class(omp_poisson_fft_t) :: self

call process_spectral_div_u( &
self%c_x, self%waves, self%nx_spec, self%ny_spec, self%nz_spec, &
self%c_x, self%waves, self%nx_spec, self%ny_spec, self%nz_spec, self%x_sp_st, &
self%y_sp_st, self%z_sp_st, self%nx_glob, self%ny_glob, self%nz_glob, &
self%ax, self%bx, self%ay, self%by, self%az, self%bz &
)
Expand Down
7 changes: 4 additions & 3 deletions src/poisson_fft.f90
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module m_poisson_fft
!> Local dimensions in the permuted slabs in spectral space
integer :: nx_spec, ny_spec, nz_spec
!> Offset in y and z directions in the permuted slabs in spectral space
integer :: y_sp_st, z_sp_st
integer :: x_sp_st, y_sp_st, z_sp_st
!> Local domain sized array storing the spectral equivalence constants
complex(dp), allocatable, dimension(:, :, :) :: waves
!> Wave numbers in x, y, and z
Expand Down Expand Up @@ -89,12 +89,13 @@ subroutine spec_init(self, mesh, xdirps, ydirps, zdirps, n_spec, n_sp_st)
type(mesh_t), intent(in) :: mesh
type(dirps_t), intent(in) :: xdirps, ydirps, zdirps
integer, dimension(3), intent(in) :: n_spec ! Size of the spectral pencil
integer, dimension(3), intent(in) :: n_sp_st ! Start of the spectral pencil (=offset)
integer, dimension(3), intent(in) :: n_sp_st ! Offset of the spectral pencil

self%nx_spec = n_spec(1)
self%ny_spec = n_spec(2)
self%nz_spec = n_spec(3)

self%x_sp_st = n_sp_st(1)
self%y_sp_st = n_sp_st(2)
self%z_sp_st = n_sp_st(3)

Expand Down Expand Up @@ -209,7 +210,7 @@ subroutine waves_set(self, geo, xdirps, ydirps, zdirps)
do k = 1, self%nz_spec
do j = 1, self%ny_spec
do i = 1, self%nx_spec
ix = i; iy = j + self%y_sp_st; iz = k + self%z_sp_st
ix = i + self%x_sp_st; iy = j + self%y_sp_st; iz = k + self%z_sp_st
rlexs = real(exs(ix), kind=dp)*geo%d(1)
rleys = real(eys(iy), kind=dp)*geo%d(2)
rlezs = real(ezs(iz), kind=dp)*geo%d(3)
Expand Down

0 comments on commit cf161e9

Please sign in to comment.