Peano
Loading...
Searching...
No Matches
ScatterGlobalMemory.py
Go to the documentation of this file.
1# This file is part of the Peano project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3from peano4.solversteps.ActionSet import ActionSet
4
5
6import jinja2
7import dastgen2
8import peano4
9
10
12 """!
13
14 Scatter all data
15
16 Memory pools can ask the system to scatter all data to start from a clean
17 plate again. This is notably important for the global memory pool.
18
19 The action set is kind of the antidote to peano4.toolbox.particles.GatherParticlesInMemoryPool.
20 It should be used within dummy sweeps typically.
21
22 """
24 self,
25 particle_set
26 ):
27 """!
28
29 Construct the action set
30
31 ## Arguments
32
33 particle_set: peano4.toolbox.particles.ParticleSet
34 Instance of the particle set that is to be scattered.
35
36
37 """
38 super(ScatterGlobalMemory,self).__init__()
39 self._particle_set = particle_set
40 self.d = {}
41 self.d["PARTICLE"] = particle_set.particle_model.name
42 self.d["PARTICLES_CONTAINER"] = particle_set.name
43 pass
44
46 return False
47
48 __Template_TouchVertexLastTime = jinja2.Template(
49 """
50 if ( vertexdata::{{PARTICLES_CONTAINER}}::MemoryPool::requestCompleteScatter() ) {
51 fineGridVertex{{PARTICLES_CONTAINER}}.scatter();
52 }
53"""
54 )
55
57 return jinja2.Template(
58 """
59 if ( vertexdata::{{PARTICLES_CONTAINER}}::MemoryPool::requestCompleteScatter() ) {
60 logInfo( "prepareTraversal(...)", "start to scatter all memory to allow for a data rearrangement" );
61 }
62"""
63 ).render(**self.d)
64
65 def get_body_of_operation(self, operation_name):
66 result = "\n"
67 if operation_name == ActionSet.OPERATION_TOUCH_VERTEX_LAST_TIME:
68 result = self.__Template_TouchVertexLastTime.render(**self.d)
69 return result
70
71
73 return __name__.replace(".py", "").replace(".", "_")
74
75
76 def get_includes(self):
77 result = jinja2.Template(
78 """
79#include "vertexdata/{{PARTICLES_CONTAINER}}.h"
80#include "globaldata/{{PARTICLE}}.h"
81"""
82 )
83 return result.render(**self.d)
Action set (reactions to events)
Definition ActionSet.py:6
__init__(self, particle_set)
Construct the action set.
user_should_modify_template(self)
Is the user allowed to modify the output.
get_includes(self)
Return include statements that you need.
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.