diff options
author | 2019-05-01 21:35:19 -0700 | |
---|---|---|
committer | 2019-05-01 21:35:19 -0700 | |
commit | df4a98c23e8dab97b32398ef2998e3f80e0c6475 (patch) | |
tree | 0269d31a77dc95d282639733fc8e8c7e62ffe31f /Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp | |
parent | 581510ffdd5134700fb30bbab3eb8abc294d9ab7 (diff) | |
download | WarpX-df4a98c23e8dab97b32398ef2998e3f80e0c6475.tar.gz WarpX-df4a98c23e8dab97b32398ef2998e3f80e0c6475.tar.zst WarpX-df4a98c23e8dab97b32398ef2998e3f80e0c6475.zip |
Correct error in calculation of k vector
Diffstat (limited to 'Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp')
-rw-r--r-- | Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp b/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp index 71073eb3f..2fe78cedd 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp @@ -30,13 +30,14 @@ SpectralKSpace::SpectralKSpace( const BoxArray& realspace_ba, // (cell-centered) real space box // TODO: this will be different for the hybrid FFT scheme Box realspace_bx = realspace_ba[i]; - IntVect spectral_bx_size = realspace_bx.length(); + IntVect fft_size = realspace_bx.length(); // Because the spectral solver uses real-to-complex FFTs, we only // need the positive k values along the fastest axis // (first axis for AMReX Fortran-order arrays) in spectral space. // This effectively reduces the size of the spectral space by half // see e.g. the FFTW documentation for real-to-complex FFTs - spectral_bx_size[0] = spectral_bx_size[0]/2 + 1; + IntVect spectral_bx_size = fft_size; + spectral_bx_size[0] = fft_size[0]/2 + 1; // Define the corresponding box Box spectral_bx = Box( IntVect::TheZeroVector(), spectral_bx_size - IntVect::TheUnitVector() ); @@ -48,13 +49,12 @@ SpectralKSpace::SpectralKSpace( const BoxArray& realspace_ba, bool only_positive_k; for (int i_dim=0; i_dim<AMREX_SPACEDIM; i_dim++) { if (i_dim==0) { - // For real-to-complex FFTs, the first axis contains - // only the positive k + // Real-to-complex FFTs: first axis contains only the positive k only_positive_k = true; } else { only_positive_k = false; } - k_vec[i_dim] = getKComponent( dm, i_dim, only_positive_k ); + k_vec[i_dim] = getKComponent(dm, realspace_ba, i_dim, only_positive_k); } } @@ -64,6 +64,7 @@ SpectralKSpace::SpectralKSpace( const BoxArray& realspace_ba, */ KVectorComponent SpectralKSpace::getKComponent( const DistributionMapping& dm, + const BoxArray& realspace_ba, const int i_dim, const bool only_positive_k ) const { @@ -80,7 +81,8 @@ SpectralKSpace::getKComponent( const DistributionMapping& dm, k.resize( N ); // Fill the k vector - const Real dk = 2*MathConst::pi/(N*dx[i_dim]); + IntVect fft_size = realspace_ba[mfi].length(); + const Real dk = 2*MathConst::pi/(fft_size[i_dim]*dx[i_dim]); AMREX_ALWAYS_ASSERT_WITH_MESSAGE( bx.smallEnd(i_dim) == 0, "Expected box to start at 0, in spectral space."); AMREX_ALWAYS_ASSERT_WITH_MESSAGE( bx.bigEnd(i_dim) == N-1, |