aboutsummaryrefslogtreecommitdiff
path: root/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp
diff options
context:
space:
mode:
authorGravatar Olga Shapoval <30510597+oshapoval@users.noreply.github.com> 2020-05-29 09:00:30 -0700
committerGravatar GitHub <noreply@github.com> 2020-05-29 09:00:30 -0700
commitb75932d3a1439f19d5b6b697c69fbe72cfb60044 (patch)
treeaa1b4e1ea74e3773b3c8b90d9781210ae627c5c8 /Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp
parentdb44e998eaf19ebbb52209a5f8c4123635f474be (diff)
downloadWarpX-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.cpp18
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;
}