Skip to content

Commit

Permalink
fix comments in fft unpacking and shifting routines
Browse files Browse the repository at this point in the history
  • Loading branch information
ajnonaka committed Jul 31, 2023
1 parent 14f8277 commit 996f376
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src_analysis/StructFact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,20 @@ void StructFact::ComputeFFT(const MultiFab& variables,
amrex::ParallelFor(bx,
[=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
/*
Unpacking rules:
For domains from (0,0,0) to (Nx-1,Ny-1,Nz-1)
For any cells with i index > Nx/2, these values are complex conjugates of the corresponding
entry where (Nx-i,Ny-j,Nz-k) UNLESS that index is zero, in which case you use 0.
e.g. for an 8^3 domain, any cell with i index
Cell (6,2,3) is complex conjugate of (2,6,5)
Cell (4,1,0) is complex conjugate of (4,7,0) (note that the FFT is computed for 0 <= i <= Nx/2)
*/
if (i <= bx.length(0)/2) {
// copy value
realpart(i,j,k) = spectral(i,j,k).real();
Expand Down Expand Up @@ -733,18 +747,13 @@ void StructFact::ShiftFFT(MultiFab& dft_out, const Geometry& geom, const int& ze
/*
Shifting rules:
For domains from (0,0,0) to (Nx-1,Ny-1,Nz-1)
For any cells with i index >= Nx/2, these values are complex conjugates of the corresponding
entry where (Nx-i,Ny-j,Nz-k) UNLESS that index is zero, in which case you use 0.
For each direction d, shift the data in the +d direction by n_cell[d]/2 and then modulo by n_cell[d].
e.g. for an 8^3 domain, any cell with i index
e.g. for an 8^3 domain
Cell (6,2,3) is complex conjugate of (2,6,5)
Cell (7,2,3) is shifted to ( (7+4)%8, (2+4)%8, (3+4)%8 ) = (3,6,7)
Cell (4,1,0) is complex conjugate of (4,7,0) (note that the FFT is computed for 0 <= i <= Nx/2)
*/

BoxArray ba_onegrid;
{
Box domain = geom.Domain();
Expand Down

0 comments on commit 996f376

Please sign in to comment.