Skip to content

Commit

Permalink
#2534: Don't access position vector values beyond the configured dime…
Browse files Browse the repository at this point in the history
…nsion (#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
  • Loading branch information
PhilMiller authored Nov 10, 2021
1 parent 9341e09 commit 02726b5
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions Source/EmbeddedBoundary/ParticleScraper.H
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
Expand Down

0 comments on commit 02726b5

Please sign in to comment.