I did not manage to use createParticles with a min_dist option (to prevent overlapping particles) when using multiple threads. At first I expected an incorrect usage on my end, but there appears to be a bug in the unit test for this functionality. The checkRandomDistances function has the following two issues:
After correcting for these, the ParticleInit unit test fails. Therefore, it looks like the insertion with a minimum distance is not thread safe: the id used here, might not match the actual position where the particle is inserted in the particle_list (here). If so, some particles accepted for insertion might overlap with others inserted around the same time.
I did not manage to use
createParticles
with amin_dist
option (to prevent overlapping particles) when using multiple threads. At first I expected an incorrect usage on my end, but there appears to be a bug in the unit test for this functionality. ThecheckRandomDistances
function has the following two issues:The
min_dist
is converted to anint
, which casts the 0.47 value to 0 (which is why the check never fails) see: https://github.com/ECP-copa/Cabana/blob/master/core/unit_test/tstParticleInit.hpp#L52The inner loop over
j
should start at i+1, to prevent checks fori==j
and duplicate checks see: https://github.com/ECP-copa/Cabana/blob/master/core/unit_test/tstParticleInit.hpp#L59After correcting for these, the
ParticleInit
unit test fails. Therefore, it looks like the insertion with a minimum distance is not thread safe: theid
used here, might not match the actual position where the particle is inserted in theparticle_list
(here). If so, some particles accepted for insertion might overlap with others inserted around the same time.