aboutsummaryrefslogtreecommitdiff
path: root/Source/Parallelization
diff options
context:
space:
mode:
authorGravatar Prabhat Kumar <89051199+prkkumar@users.noreply.github.com> 2023-01-13 12:30:05 -0800
committerGravatar GitHub <noreply@github.com> 2023-01-13 20:30:05 +0000
commit8679bf599a4c90cc47cf4e25fa5b4aeaad1f4adc (patch)
tree4703b684c199095558245a84a335a9cfaaf602ef /Source/Parallelization
parentbaa4ea98926652632c2e5ff7f3edad70a9405380 (diff)
downloadWarpX-8679bf599a4c90cc47cf4e25fa5b4aeaad1f4adc.tar.gz
WarpX-8679bf599a4c90cc47cf4e25fa5b4aeaad1f4adc.tar.zst
WarpX-8679bf599a4c90cc47cf4e25fa5b4aeaad1f4adc.zip
Fix segfault in interpolation with anisotropic ref ratio (#3613)
* Fix segfault in interpolation with anisotropic ref ratio * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update Source/ablastr/coarsen/average.cpp Co-authored-by: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> * Update Source/ablastr/coarsen/average.cpp Co-authored-by: Weiqun Zhang <WeiqunZhang@lbl.gov> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> Co-authored-by: Weiqun Zhang <WeiqunZhang@lbl.gov>
Diffstat (limited to 'Source/Parallelization')
-rw-r--r--Source/Parallelization/WarpXComm_K.H8
1 files changed, 7 insertions, 1 deletions
diff --git a/Source/Parallelization/WarpXComm_K.H b/Source/Parallelization/WarpXComm_K.H
index f3b39bc3e..6dc51183a 100644
--- a/Source/Parallelization/WarpXComm_K.H
+++ b/Source/Parallelization/WarpXComm_K.H
@@ -20,6 +20,12 @@ void warpx_interp (int j, int k, int l,
{
using namespace amrex;
+ // Pad arr_coarse with zeros beyond ghost cells for out-of-bound accesses
+ const auto arr_coarse_zeropad = [arr_coarse] (const int jj, const int kk, const int ll) noexcept
+ {
+ return arr_coarse.contains(jj,kk,ll) ? arr_coarse(jj,kk,ll) : 0.0_rt;
+ };
+
// NOTE Indices (j,k,l) in the following refer to (z,-,-) in 1D, (x,z,-) in 2D, and (x,y,z) in 3D
// Refinement ratio
@@ -57,7 +63,7 @@ void warpx_interp (int j, int k, int l,
/ static_cast<amrex::Real>(rk);
wl = (sl == 0) ? 1.0_rt : (rl - amrex::Math::abs(l - (lc + ll) * rl))
/ static_cast<amrex::Real>(rl);
- res += wj * wk * wl * arr_coarse(jc+jj,kc+kk,lc+ll);
+ res += wj * wk * wl * arr_coarse_zeropad(jc+jj,kc+kk,lc+ll);
}
}
}