diff options
author | 2023-07-26 20:55:34 +0200 | |
---|---|---|
committer | 2023-07-26 18:55:34 +0000 | |
commit | 766d71146a8314a48db88f29b0e0548d1d9c5397 (patch) | |
tree | 630ae577a1856ae0f5fb2e236a4e85b9346566d2 /Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp | |
parent | 4783ad60809fc5fdff164a4ed0cacca4b3fffa70 (diff) | |
download | WarpX-766d71146a8314a48db88f29b0e0548d1d9c5397.tar.gz WarpX-766d71146a8314a48db88f29b0e0548d1d9c5397.tar.zst WarpX-766d71146a8314a48db88f29b0e0548d1d9c5397.zip |
Initialize variables at declaration if it improves readability (#4117)
* init some variables at declaration
* make code more readable
* avoid lossy function result cast
* Update Source/Initialization/WarpXInitData.cpp
Co-authored-by: Weiqun Zhang <WeiqunZhang@lbl.gov>
* replace with equality
* Revert "replace with equality"
This reverts commit e3164f9e053d345b153d770ae107a7f68c4bb260.
* Update Source/Diagnostics/ComputeDiagFunctors/ParticleReductionFunctor.cpp
Co-authored-by: Weiqun Zhang <WeiqunZhang@lbl.gov>
---------
Co-authored-by: Weiqun Zhang <WeiqunZhang@lbl.gov>
Diffstat (limited to 'Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp')
-rw-r--r-- | Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp b/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp index 7320b7cf1..b8d81000c 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp @@ -68,14 +68,9 @@ SpectralKSpace::SpectralKSpace( const BoxArray& realspace_ba, spectralspace_ba.define( spectral_bl ); // Allocate the components of the k vector: kx, ky (only in 3D), kz - bool only_positive_k; for (int i_dim=0; i_dim<AMREX_SPACEDIM; i_dim++) { - if (i_dim==0) { - // Real-to-complex FFTs: first axis contains only the positive k - only_positive_k = true; - } else { - only_positive_k = false; - } + // Real-to-complex FFTs: first axis contains only the positive k + const auto only_positive_k = (i_dim==0); k_vec[i_dim] = getKComponent(dm, realspace_ba, i_dim, only_positive_k); } } |