aboutsummaryrefslogtreecommitdiff
path: root/Source/Parallelization
diff options
context:
space:
mode:
authorGravatar Luca Fedeli <luca.fedeli@cea.fr> 2023-07-26 20:55:34 +0200
committerGravatar GitHub <noreply@github.com> 2023-07-26 18:55:34 +0000
commit766d71146a8314a48db88f29b0e0548d1d9c5397 (patch)
tree630ae577a1856ae0f5fb2e236a4e85b9346566d2 /Source/Parallelization
parent4783ad60809fc5fdff164a4ed0cacca4b3fffa70 (diff)
downloadWarpX-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/Parallelization')
-rw-r--r--Source/Parallelization/WarpXComm_K.H10
1 files changed, 3 insertions, 7 deletions
diff --git a/Source/Parallelization/WarpXComm_K.H b/Source/Parallelization/WarpXComm_K.H
index 269827496..b97773af2 100644
--- a/Source/Parallelization/WarpXComm_K.H
+++ b/Source/Parallelization/WarpXComm_K.H
@@ -47,10 +47,6 @@ void warpx_interp (int j, int k, int l,
const int kc = (sk == 0) ? amrex::coarsen(k - rk/2, rk) : amrex::coarsen(k, rk);
const int lc = (sl == 0) ? amrex::coarsen(l - rl/2, rl) : amrex::coarsen(l, rl);
- amrex::Real wj;
- amrex::Real wk;
- amrex::Real wl;
-
// Interpolate from coarse grid to fine grid using 2 points
// with weights depending on the distance, for both nodal and cell-centered grids
const amrex::Real hj = (sj == 0) ? 0.5_rt : 0._rt;
@@ -62,9 +58,9 @@ void warpx_interp (int j, int k, int l,
for (int jj = 0; jj < nj; jj++) {
for (int kk = 0; kk < nk; kk++) {
for (int ll = 0; ll < nl; ll++) {
- wj = (rj - amrex::Math::abs(j + hj - (jc + jj + hj) * rj)) / static_cast<amrex::Real>(rj);
- wk = (rk - amrex::Math::abs(k + hk - (kc + kk + hk) * rk)) / static_cast<amrex::Real>(rk);
- wl = (rl - amrex::Math::abs(l + hl - (lc + ll + hl) * rl)) / static_cast<amrex::Real>(rl);
+ const amrex::Real wj = (rj - amrex::Math::abs(j + hj - (jc + jj + hj) * rj)) / static_cast<amrex::Real>(rj);
+ const amrex::Real wk = (rk - amrex::Math::abs(k + hk - (kc + kk + hk) * rk)) / static_cast<amrex::Real>(rk);
+ const amrex::Real wl = (rl - amrex::Math::abs(l + hl - (lc + ll + hl) * rl)) / static_cast<amrex::Real>(rl);
res += wj * wk * wl * arr_coarse_zeropad(jc+jj,kc+kk,lc+ll);
}
}