The "exact" generation of particles seemed a bit slow to me, hence the creation of #23.
The former method of particle seeding involved nested loops which are known to be slow in Python. This PR changes the implementation by taking advantage of the list data format to more rapidly do the "exact" particle seeding. To do this, the divmod() function is used to get the number of particles per location (the number of particles that evenly divide across the seed locations). If the number of seed particles doesn't divide evenly into the seed locations, the "remainder" particles are seeded via loop.
To do before merge
[x] test on example domains - tried out the seeding and the min/max values of seed indices are being correctly set.
[x] time some of those demos to get an idea of what the speed-up is - for the examples the number of particles is so small that looping is not very costly. I did test "exact" seeding of 50,000 particles, and found that the new method took <0.1s while the nested-loop took about 8 seconds. So there is definitely a benefit to switching to this method.
Speeding up the "exact" particle generation
The "exact" generation of particles seemed a bit slow to me, hence the creation of #23.
The former method of particle seeding involved nested loops which are known to be slow in Python. This PR changes the implementation by taking advantage of the list data format to more rapidly do the "exact" particle seeding. To do this, the
divmod()
function is used to get the number of particles per location (the number of particles that evenly divide across the seed locations). If the number of seed particles doesn't divide evenly into the seed locations, the "remainder" particles are seeded via loop.To do before merge
Edit: This closes #23