Prevent segfault in distance to boundary calculation (#2659)

This commit is contained in:
Paul Romano 2023-09-01 08:52:51 -05:00 committed by GitHub
parent d21b653d32
commit 1cae2f712a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 1 deletions

View file

@ -419,13 +419,14 @@ BoundaryInfo distance_to_boundary(Particle& p)
double& d = info.distance;
if (d_surf < d_lat - FP_COINCIDENT) {
if (d == INFINITY || (d - d_surf) / d >= FP_REL_PRECISION) {
// Update closest distance
d = d_surf;
// If the cell is not simple, it is possible that both the negative and
// positive half-space were given in the region specification. Thus, we
// have to explicitly check which half-space the particle would be
// traveling into if the surface is crossed
if (c.is_simple()) {
if (c.is_simple() || d == INFTY) {
info.surface_index = level_surf_cross;
} else {
Position r_hit = r + d_surf * u;