Skip to content

Commit

Permalink
Mark particles as visited as soon as they are
Browse files Browse the repository at this point in the history
There was a delay between particles being visited, and being marked as
such (the loop for marking particles as visited came right after the
loop using particles). This worked well when individual calls to
SearchBallPos returned lists of indices without repetitions; if a list
of indices contains repetitions though (and the SearchBallPos algorithm
doesn't prevent this) then the nexport variable could be increased
beyond the extents of the PartDataIn allocation and cause problems,
which is exactly what happens in #73.

This commit moves the marking of visited particles to be within the same
loop where that particle is visited, right after the check.

Signed-off-by: Rodrigo Tobar <rtobar@icrar.org>
  • Loading branch information
rtobar authored and pelahi committed Nov 1, 2021
1 parent d1f511a commit 6f4b760
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/mpiroutines.cxx
Expand Up @@ -3835,14 +3835,14 @@ Int_t MPIBuildParticleNNImportList(Options &opt, const Int_t nbodies, KDTree *tr
if (taggedindex.size()==0) continue;
for (auto &index:taggedindex) {
if (iflagged[index]) continue;
iflagged[index] = true;
#ifdef STRUCDEN
if (iallflag==0 && Part[index].GetType()<0) continue;
#endif
PartDataIn[nexport]=Part[index];
nexport++;
nsend_local[j]++;
}
for (auto &index:taggedindex) iflagged[index]=true;
}
}
delete[] iflagged;
Expand Down

0 comments on commit 6f4b760

Please sign in to comment.