diff options
author | 2020-05-29 09:00:30 -0700 | |
---|---|---|
committer | 2020-05-29 09:00:30 -0700 | |
commit | b75932d3a1439f19d5b6b697c69fbe72cfb60044 (patch) | |
tree | aa1b4e1ea74e3773b3c8b90d9781210ae627c5c8 /Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp | |
parent | db44e998eaf19ebbb52209a5f8c4123635f474be (diff) | |
download | WarpX-b75932d3a1439f19d5b6b697c69fbe72cfb60044.tar.gz WarpX-b75932d3a1439f19d5b6b697c69fbe72cfb60044.tar.zst WarpX-b75932d3a1439f19d5b6b697c69fbe72cfb60044.zip |
Set particular modified wavenumbers to 0 for spectral (nodal). (#1030)
* Set particular modified wavenumbers to 0 for spectral (nodal).
* Add comments
Co-authored-by: Remi Lehe <remi.lehe@normalesup.org>
Diffstat (limited to 'Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp')
-rw-r--r-- | Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp b/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp index c53070827..89771a3f7 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp @@ -205,6 +205,24 @@ SpectralKSpace::getModifiedKComponent( const DistributionMapping& dm, } } } + + // By construction, at finite order and for a nodal grid, + // the *modified* k corresponding to the Nyquist frequency + // (i.e. highest *real* k) is 0. However, the above calculation + // based on stencil coefficients does not give 0 to machine precision. + // Therefore, we need to enforce the fact that the modified k be 0 here. + if (nodal){ + if (i_dim == 0){ + // Because of the real-to-complex FFTs, the first axis (idim=0) + // contains only the positive k, and the Nyquist frequency is + // the last element of the array. + modified_k[k.size()-1] = 0.0_rt; + } else { + // The other axes contains both positive and negative k ; + // the Nyquist frequency is in the middle of the array. + modified_k[k.size()/2] = 0.0_rt; + } + } } return modified_k_comp; } |