@@ -46,19 +46,22 @@ int main (int argc, char* argv[])
4646 auto const & cxa = cx.const_arrays ();
4747 auto const & cya = cy.const_arrays ();
4848 auto const & cza = cz.const_arrays ();
49- ParallelFor (vx , [=] AMREX_GPU_DEVICE (int b, int i, int j, int k)
49+ ParallelFor (cx , [=] AMREX_GPU_DEVICE (int b, int i, int j, int k)
5050 {
51- int ki = (i <= nx/ 2 ) ? i : nx- i;
51+ int ki = i;
5252 int kj = (j <= ny/2 ) ? j : ny-j;
5353 int kk = (k <= nz/2 ) ? k : nz-k;
5454 Real d = std::sqrt (Real (ki*ki+kj*kj+kk*kk));
5555 int di = int (std::round (d));
5656 if (di < nk) {
57- // Hermitian symmetry Y[nx-i,j,k] = Y[i,j,k]*
58- i = (i <= nx/2 ) ? i : nx-i;
5957 Real value = amrex::norm (cxa[b](i,j,k))
6058 + amrex::norm (cya[b](i,j,k))
6159 + amrex::norm (cza[b](i,j,k));
60+ // Account for Hermitian symmetry in x-direction
61+ // Hermitian symmetry Y[nx-i,j,k] = Y[i,j,k]*
62+ if (i > 0 ) { // Avoid double-counting at kx = 0
63+ value *= 2.0 ; // Multiply by 2 because we have kx and -kx
64+ }
6265 HostDevice::Atomic::Add (pke+di, value);
6366 }
6467 });
0 commit comments