12 particle_cell_update_kernel=None,
13 touch_vertex_first_time_compute_particle_update_kernel=None,
14 touch_vertex_last_time_compute_particle_update_kernel=None,
15 prepare_traversal_kernel="",
16 unprepare_traversal_kernel="",
17 additional_includes="",
18 active_particle_set=None,
22 Update particles without non-local interaction
24 This action set is very similar to UpdateParticle_SingleLevelInteraction,
25 but it assumes that data are stored @ref toolbox_particles_memorypool "continuously in memory".
26 Therefore, we can provide meta information how many particles we have per
27 vertex stored en bloc.
29 Per cell, there's a @f$ 2^d @f$ vector over integers called
30 numberOfActiveParticles. It encodes how many particles are contributed
31 towards the active set from each vertex. If you employ contiguous particle
32 storage schemes, you can loop over this integer range rather than the
33 particle set, and you can exploit the fact that data within the index set
36 A cell update then resembles
38 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
39 auto localParticlesIterator = activeParticles.begin();
40 // There is some parallelism here if you wanna exploit it
41 for (int vertex=0; vertex<TwoPowerD; vertex++) {
42 auto* firstParticle = *localParticlesIterator;
43 std::advance( localParticlesIterator, numberOfActiveParticles[vertex] );
44 // This loop encodes vector-level parallelism (SIMD)
45 for (int currentParticleNo = 0; currentParticleNo < numberOfActiveParticles[vertex]; currentParticleNo++) {
46 doSomethingFancy( firstParticle+currentParticleNo );
49 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
52 A vertex update resembles
53 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
54 auto* firstParticle = *localParticles.begin();
55 // This loop encodes vector-level parallelism (SIMD)
56 for (int currentParticleNo = 0; currentParticleNo < numberOfActiveParticles; currentParticleNo++) {
57 doSomethingFancy( firstParticle+currentParticleNo );
59 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
61 ## Validity if particles change their position of cut-off radius
63 If particles change their position or cut-off radius, you have to resort
64 them. See also UpdateParticle_MultiLevelInteraction_StackOfLists_ContiguousParticles
65 for a discussion of the data validity.
69 super(UpdateParticle_SingleLevelInteraction_ContiguousParticles, self).
__init__(
70 descend_invocation_order=1, parallel=
False
75 self.
d[
"LOCAL_PARTICLE"] = particle_set.particle_model.name
76 self.
d[
"LOCAL_PARTICLES_CONTAINER"] = particle_set.name
77 if active_particle_set ==
None:
78 self.
d[
"ACTIVE_PARTICLE"] = particle_set.particle_model.name
79 self.
d[
"ACTIVE_PARTICLES_CONTAINER"] = particle_set.name
81 self.
d[
"ACTIVE_PARTICLE"] = active_particle_set.particle_model.name
82 self.
d[
"ACTIVE_PARTICLES_CONTAINER"] = active_particle_set.name
83 self.
d[
"PARTICLE_CELL_UPDATE_KERNEL"] = particle_cell_update_kernel
85 "TOUCH_VERTEX_FIRST_COMPUTE_KERNEL"
86 ] = touch_vertex_first_time_compute_particle_update_kernel
88 "TOUCH_VERTEX_LAST_COMPUTE_KERNEL"
89 ] = touch_vertex_last_time_compute_particle_update_kernel
90 self.
d[
"ADDITIONAL_INCLUDES"] = additional_includes
91 self.
d[
"PREPARE_TRAVERSAL_KERNEL"] = prepare_traversal_kernel
92 self.
d[
"UNPREPARE_TRAVERSAL_KERNEL"] = unprepare_traversal_kernel