Skip to content

Commit 07b9cea

Browse files
Correction of the computation of the energy spectrum (#154)
--------- Co-authored-by: Weiqun Zhang <[email protected]>
1 parent b1473ac commit 07b9cea

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

ExampleCodes/FFT/EnergySpectrum/main.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ int main (int argc, char* argv[])
2222

2323
cMultiFab cx, cy, cz;
2424
{
25+
// Note that the complex Hermitian output array Y has (nx/2+1,ny,nz) elements.
26+
// Y[nx-i,j,k] = Y[i,j,k]*
2527
FFT::R2C<Real,FFT::Direction::forward> fft(geom.Domain());
2628
auto const& [ba, dm] = fft.getSpectralDataLayout();
2729
cx.define(ba,dm,1,0);
@@ -55,6 +57,12 @@ int main (int argc, char* argv[])
5557
Real value = amrex::norm(cxa[b](i,j,k))
5658
+ amrex::norm(cya[b](i,j,k))
5759
+ 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) && (2*i != nx)) {
63+
// Multiply by 2 because we have +ki and -ki
64+
value *= Real(2.0);
65+
}
5866
HostDevice::Atomic::Add(pke+di, value);
5967
}
6068
});

0 commit comments

Comments
 (0)