aboutsummaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorGravatar Phil Miller <phil@intensecomputing.com> 2021-11-10 15:09:39 -0500
committerGravatar GitHub <noreply@github.com> 2021-11-10 12:09:39 -0800
commit02726b58fa688ab321cc6da7ead30e79dca1cf60 (patch)
treefd66d3d996aa2f1b7396388f0cb329c86eae0853 /Source
parent9341e098ee8cbd1eb25d3f6e5078e73a045d1e26 (diff)
downloadWarpX-02726b58fa688ab321cc6da7ead30e79dca1cf60.tar.gz
WarpX-02726b58fa688ab321cc6da7ead30e79dca1cf60.tar.zst
WarpX-02726b58fa688ab321cc6da7ead30e79dca1cf60.zip
#2534: Don't access position vector values beyond the configured dimension (#2536)
* #2534: Don't access position vector values beyond the configured dimension * Fix particle position component used in XZ configuration * Handle 1D case * Move values only used in scraping function into inside-boundary condition * Error out if scraping from EB in RZ
Diffstat (limited to 'Source')
-rw-r--r--Source/EmbeddedBoundary/ParticleScraper.H26
1 files changed, 18 insertions, 8 deletions
diff --git a/Source/EmbeddedBoundary/ParticleScraper.H b/Source/EmbeddedBoundary/ParticleScraper.H
index 283bf62da..7d6d2f2ac 100644
--- a/Source/EmbeddedBoundary/ParticleScraper.H
+++ b/Source/EmbeddedBoundary/ParticleScraper.H
@@ -168,17 +168,27 @@ scrapeParticles (PC& pc, const amrex::Vector<const amrex::MultiFab*>& distance_t
compute_weights_nodal(xp, yp, zp, plo, dxi, i, j, k, W);
amrex::Real phi_value = interp_field_nodal(i, j, k, W, phi);
- amrex::RealVect normal = DistanceToEB::interp_normal(i, j, k, W, phi, dxi);
- // the closest point on the surface to pos is pos - grad phi(pos) * phi(pos)
- amrex::RealVect pos;
- pos[0] = xp - normal[0]*phi_value;
- pos[1] = yp - normal[1]*phi_value;
- pos[2] = zp - normal[2]*phi_value;
+ if (phi_value < 0.0)
+ {
+ amrex::RealVect normal = DistanceToEB::interp_normal(i, j, k, W, phi, dxi);
- DistanceToEB::normalize(normal);
+ // the closest point on the surface to pos is pos - grad phi(pos) * phi(pos)
+ amrex::RealVect pos;
+#if (defined WARPX_DIM_3D)
+ pos[0] = xp - normal[0]*phi_value;
+ pos[1] = yp - normal[1]*phi_value;
+ pos[2] = zp - normal[2]*phi_value;
+#elif (defined WARPX_DIM_XZ)
+ pos[0] = xp - normal[0]*phi_value;
+ pos[1] = zp - normal[1]*phi_value;
+#elif (defined WARPX_DIM_1D_Z)
+ pos[0] = zp - normal[0]*phi_value;
+#elif (defined WARPX_DIM_RZ)
+ amrex::Abort("Scraping from an EB is not supported in RZ");
+#endif
+ DistanceToEB::normalize(normal);
- if (phi_value < 0.0) {
f(ptd, ip, pos, normal, engine);
}
});