From ead51f9c6f6d640dceda5107793cef24a337c1cd Mon Sep 17 00:00:00 2001 From: Rene Gassmoeller Date: Thu, 13 Jan 2022 15:31:27 -0500 Subject: [PATCH] Fix lost signal --- source/particles/particle_handler.cc | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/source/particles/particle_handler.cc b/source/particles/particle_handler.cc index caa254fece..1d7a9b703d 100644 --- a/source/particles/particle_handler.cc +++ b/source/particles/particle_handler.cc @@ -1312,8 +1312,12 @@ namespace Particles // Reuse these vectors below, but only with a single element. // Avoid resizing for every particle. - reference_locations.resize(1); - real_locations.resize(1); + Point invalid_reference_point; + Point invalid_point; + invalid_reference_point[0] = std::numeric_limits::infinity(); + invalid_point[0] = std::numeric_limits::infinity(); + reference_locations.resize(1, invalid_reference_point); + real_locations.resize(1, invalid_point); // Find the cells that the particles moved to. for (auto &out_particle : particles_out_of_cell) @@ -1409,19 +1413,20 @@ namespace Particles reference_locations[0])) { current_cell = cell; + found_cell = true; break; } } + } - if (current_cell.state() != IteratorState::valid) - { - // We can find no cell for this particle. It has left the - // domain due to an integration error or an open boundary. - // Signal the loss and move on. - signals.particle_lost(out_particle, - out_particle->get_surrounding_cell()); - continue; - } + if (!found_cell) + { + // We can find no cell for this particle. It has left the + // domain due to an integration error or an open boundary. + // Signal the loss and move on. + signals.particle_lost(out_particle, + out_particle->get_surrounding_cell()); + continue; } // If we are here, we found a cell and reference position for this -- 2.39.5