diff options
author | 2023-07-26 20:55:34 +0200 | |
---|---|---|
committer | 2023-07-26 18:55:34 +0000 | |
commit | 766d71146a8314a48db88f29b0e0548d1d9c5397 (patch) | |
tree | 630ae577a1856ae0f5fb2e236a4e85b9346566d2 /Source/Diagnostics/ReducedDiags/ParticleEnergy.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/Diagnostics/ReducedDiags/ParticleEnergy.cpp')
-rw-r--r-- | Source/Diagnostics/ReducedDiags/ParticleEnergy.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/Source/Diagnostics/ReducedDiags/ParticleEnergy.cpp b/Source/Diagnostics/ReducedDiags/ParticleEnergy.cpp index 47b90e099..ebf280e8f 100644 --- a/Source/Diagnostics/ReducedDiags/ParticleEnergy.cpp +++ b/Source/Diagnostics/ReducedDiags/ParticleEnergy.cpp @@ -99,9 +99,6 @@ void ParticleEnergy::ComputeDiags (int step) // Get number of species const int nSpecies = mypc.nSpecies(); - // Some useful offsets to fill m_data below - int offset_total_species, offset_mean_species, offset_mean_all; - amrex::Real Wtot = 0.0_rt; // Loop over species @@ -169,7 +166,7 @@ void ParticleEnergy::ComputeDiags (int step) // Offset: // 1 value of total energy for all species + // 1 value of total energy for each species - offset_total_species = 1 + i_s; + const int offset_total_species = 1 + i_s; m_data[offset_total_species] = Etot; // Offset: @@ -177,7 +174,7 @@ void ParticleEnergy::ComputeDiags (int step) // 1 value of total energy for each species + // 1 value of mean energy for all species + // 1 value of mean energy for each species - offset_mean_species = 1 + nSpecies + 1 + i_s; + const int offset_mean_species = 1 + nSpecies + 1 + i_s; if (Ws > std::numeric_limits<Real>::min()) { m_data[offset_mean_species] = Etot / Ws; @@ -197,14 +194,14 @@ void ParticleEnergy::ComputeDiags (int step) // Offset: // 1 value of total energy for all species + // 1 value of total energy for each species - offset_total_species = 1 + i_s; + const int offset_total_species = 1 + i_s; m_data[0] += m_data[offset_total_species]; } // Total mean energy. Offset: // 1 value of total energy for all species + // 1 value of total energy for each species - offset_mean_all = 1 + nSpecies; + const int offset_mean_all = 1 + nSpecies; if (Wtot > std::numeric_limits<Real>::min()) { m_data[offset_mean_all] = m_data[0] / Wtot; |