Skip to content

Commit d9c437e

Browse files
PhilMillerdpgrote
authored andcommitted
BLAST-WarpX#2534: Don't access position vector values beyond the configured dimension (BLAST-WarpX#2536)
* BLAST-WarpX#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
1 parent 8326309 commit d9c437e

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

Source/EmbeddedBoundary/ParticleScraper.H

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,17 +168,27 @@ scrapeParticles (PC& pc, const amrex::Vector<const amrex::MultiFab*>& distance_t
168168
compute_weights_nodal(xp, yp, zp, plo, dxi, i, j, k, W);
169169

170170
amrex::Real phi_value = interp_field_nodal(i, j, k, W, phi);
171-
amrex::RealVect normal = DistanceToEB::interp_normal(i, j, k, W, phi, dxi);
172171

173-
// the closest point on the surface to pos is pos - grad phi(pos) * phi(pos)
174-
amrex::RealVect pos;
175-
pos[0] = xp - normal[0]*phi_value;
176-
pos[1] = yp - normal[1]*phi_value;
177-
pos[2] = zp - normal[2]*phi_value;
172+
if (phi_value < 0.0)
173+
{
174+
amrex::RealVect normal = DistanceToEB::interp_normal(i, j, k, W, phi, dxi);
178175

179-
DistanceToEB::normalize(normal);
176+
// the closest point on the surface to pos is pos - grad phi(pos) * phi(pos)
177+
amrex::RealVect pos;
178+
#if (defined WARPX_DIM_3D)
179+
pos[0] = xp - normal[0]*phi_value;
180+
pos[1] = yp - normal[1]*phi_value;
181+
pos[2] = zp - normal[2]*phi_value;
182+
#elif (defined WARPX_DIM_XZ)
183+
pos[0] = xp - normal[0]*phi_value;
184+
pos[1] = zp - normal[1]*phi_value;
185+
#elif (defined WARPX_DIM_1D_Z)
186+
pos[0] = zp - normal[0]*phi_value;
187+
#elif (defined WARPX_DIM_RZ)
188+
amrex::Abort("Scraping from an EB is not supported in RZ");
189+
#endif
190+
DistanceToEB::normalize(normal);
180191

181-
if (phi_value < 0.0) {
182192
f(ptd, ip, pos, normal, engine);
183193
}
184194
});

0 commit comments

Comments
 (0)