aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles/WarpXParticleContainer.cpp
diff options
context:
space:
mode:
authorGravatar Axel Huebl <axel.huebl@plasma.ninja> 2019-11-26 17:27:15 -0700
committerGravatar GitHub <noreply@github.com> 2019-11-26 17:27:15 -0700
commita9c76d8e2f2f45877862d41dd8a3bd2954883d27 (patch)
tree823523be4842e0f765e8426b5b273bb228549a57 /Source/Particles/WarpXParticleContainer.cpp
parent4a7625bb87a60d32c67812d1317226a572fea515 (diff)
parent3ad7f72470374320a8681543f1a1efab457dd717 (diff)
downloadWarpX-a9c76d8e2f2f45877862d41dd8a3bd2954883d27.tar.gz
WarpX-a9c76d8e2f2f45877862d41dd8a3bd2954883d27.tar.zst
WarpX-a9c76d8e2f2f45877862d41dd8a3bd2954883d27.zip
Merge pull request #531 from levinem/for-loop-fix
Move finestLevel() calculation outside of for loop condition statements
Diffstat (limited to 'Source/Particles/WarpXParticleContainer.cpp')
-rw-r--r--Source/Particles/WarpXParticleContainer.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/Source/Particles/WarpXParticleContainer.cpp b/Source/Particles/WarpXParticleContainer.cpp
index 7b5bf16d1..9f02da338 100644
--- a/Source/Particles/WarpXParticleContainer.cpp
+++ b/Source/Particles/WarpXParticleContainer.cpp
@@ -1,4 +1,3 @@
-
#include <limits>
#include <MultiParticleContainer.H>
@@ -631,7 +630,8 @@ Real WarpXParticleContainer::sumParticleCharge(bool local) {
amrex::Real total_charge = 0.0;
- for (int lev = 0; lev < finestLevel(); ++lev)
+ const int nLevels = finestLevel();
+ for (int lev = 0; lev < nLevels; ++lev)
{
#ifdef _OPENMP
@@ -661,7 +661,8 @@ std::array<Real, 3> WarpXParticleContainer::meanParticleVelocity(bool local) {
amrex::Real inv_clight_sq = 1.0/PhysConst::c/PhysConst::c;
- for (int lev = 0; lev <= finestLevel(); ++lev) {
+ const int nLevels = finestLevel();
+ for (int lev = 0; lev <= nLevels; ++lev) {
#ifdef _OPENMP
#pragma omp parallel reduction(+:vx_total, vy_total, vz_total, np_total)
@@ -705,7 +706,8 @@ Real WarpXParticleContainer::maxParticleVelocity(bool local) {
amrex::ParticleReal max_v = 0.0;
- for (int lev = 0; lev <= finestLevel(); ++lev)
+ const int nLevels = finestLevel();
+ for (int lev = 0; lev <= nLevels; ++lev)
{
#ifdef _OPENMP
@@ -731,7 +733,7 @@ WarpXParticleContainer::PushXES (Real dt)
{
BL_PROFILE("WPC::PushXES()");
- int num_levels = finestLevel() + 1;
+ const int num_levels = finestLevel() + 1;
for (int lev = 0; lev < num_levels; ++lev) {
const auto& gm = m_gdb->Geom(lev);
@@ -760,7 +762,8 @@ WarpXParticleContainer::PushXES (Real dt)
void
WarpXParticleContainer::PushX (Real dt)
{
- for (int lev = 0; lev <= finestLevel(); ++lev) {
+ const int nLevels = finestLevel();
+ for (int lev = 0; lev <= nLevels; ++lev) {
PushX(lev, dt);
}
}