From 70cb1110e935a9741ec8bf7aaa9e7df63a10b40b Mon Sep 17 00:00:00 2001 From: Gavin Ridley Date: Wed, 28 Apr 2021 18:10:02 -0400 Subject: [PATCH 1/2] make sure failed neighbor list searches trigger exhaustive searches --- src/geometry.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/geometry.cpp b/src/geometry.cpp index 06d35cacec..c100ebb5e7 100644 --- a/src/geometry.cpp +++ b/src/geometry.cpp @@ -91,11 +91,25 @@ find_cell_inner(Particle& p, const NeighborList* neighbor_list) break; } } + + // If we're attempting a neighbor list search and fail, we + // now know we should return false. This will trigger an + // exhaustive search from neighbor_list_find_cell and make + // the result from that be appended to the neighbor list. + if (!found) + return false; } // Check successively lower coordinate levels until finding material fill for (;;++p.n_coord_) { - // If neighbor lists did not find a cell, must do exhaustive search + // If we did not attempt to use neighbor lists, i_cell is still C_NONE. In + // that case, we should now do an exhaustive search to find the right value + // of i_cell. + // + // Alternatively, neighbor list searches could have succeeded, but we found + // that the fill of the neighbor cell was another universe. As such, in the + // code below this conditional, we set i_cell back to C_NONE to indicate + // that. if (i_cell == C_NONE) { int i_universe = p.coord_[p.n_coord_-1].universe; const auto& univ {*model::universes[i_universe]}; From 1155796253010f3cd9d9038131667209d2d4ccb8 Mon Sep 17 00:00:00 2001 From: Gavin Ridley Date: Thu, 29 Apr 2021 13:26:08 -0400 Subject: [PATCH 2/2] if unable to find cell, get helpful error message rather than segfault --- src/geometry.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/geometry.cpp b/src/geometry.cpp index c100ebb5e7..23622ebad0 100644 --- a/src/geometry.cpp +++ b/src/geometry.cpp @@ -96,8 +96,9 @@ find_cell_inner(Particle& p, const NeighborList* neighbor_list) // now know we should return false. This will trigger an // exhaustive search from neighbor_list_find_cell and make // the result from that be appended to the neighbor list. - if (!found) - return false; + if (!found) { + return found; + } } // Check successively lower coordinate levels until finding material fill @@ -252,6 +253,7 @@ find_cell_inner(Particle& p, const NeighborList* neighbor_list) } } i_cell = C_NONE; // trip non-neighbor cell search at next iteration + found = false; } return found;