17 Create the cell marker that is used by all statistics
19 You can either create such a cell marker yourself, or you can make the
20 particle tree analysis create one for you.
22 @see ParticleTreeAnalysis.__init__()
40 This action set implements an analysed tree grammar
42 The grammar goes down to the finest level and writes into each
43 leaf cell of the tree the following data:
45 - Number of particles within this cell
46 - The flag ParentOfRefinedCell is set to false
48 We then run through the tree bottom-up and set these two flags
49 on each spacetree cell along the following rules:
51 - Number of particles of a refined cell in the spacetree equals
52 the number of all the children cells plus the local particles,
53 i.e. those particles stored on the present level.
54 - ParentOfRefinedCell becomes true if one of the children is
55 refined. If none of the children is refined, the flag is false.
57 I use the analysed tree data to determine if a tree's has to be
58 refined further as it hosts too many particles. I also use it to
59 steer if a tree has to be coarsened if there are not enough
60 particles. Finally, I use the flag ParentOfRefinedCell to ensure
61 that we always remove at most one level from the tree in one
62 tree sweep, as I only erase refined tree nodes for which
63 ParentOfRefinedCell does not hold.
69 I need a particle set to work properly. You also have to
70 invoke add the tree cell properties to the tree and tell
71 every observer that invokes this particle set to handle
75 my_Peano_project = ...
77 my_tree_analysis = ParticleTreeAnalysis(...)
78 my_Peano_project.add_cell(my_tree_analysis.cell_marker)
82 my_algorithmic_step = peano4.solversteps.Step( ... )
83 my_algorithmic_step.use_cell(my_tree_analysis.cell_marker)
89 particle_set: ParticleSet
90 This is the particle set which is to be analysed.
92 cell_marker: peano4.datamodel.DaStGen2 or None
93 If you pass in None, the class will create an appropriate
94 cell marker itself. You can also add in a cell marker that
95 shall be used. In both cases, you have to ensure that your
96 code handles the cell marker accordingly, i.e. ensures that
97 the markers are streamed properly.
103 super(ParticleTreeAnalysis,self).
__init__(descend_invocation_order=1,parallel=
False)
104 if cell_marker!=
None:
113 "PARTICLE_SET_NAME": particle_set.name,
114 "PARTICLE_NAME": particle_set.particle_model.name
119 __Template_TouchCellFirstTime = jinja2.Template(
"""
120 fineGridCell{{CELL_DATA_NAME}}.setNumberOfParticles( fineGridCell{{CELL_DATA_NAME}}.getNewNumberOfParticles() );
121 fineGridCell{{CELL_DATA_NAME}}.setParentOfRefinedCell( fineGridCell{{CELL_DATA_NAME}}.getNewParentOfRefinedCell() );
122 fineGridCell{{CELL_DATA_NAME}}.setNewNumberOfParticles(0);
123 fineGridCell{{CELL_DATA_NAME}}.setNewParentOfRefinedCell( false );
127 __Template_CreateCell = jinja2.Template(
"""
128 fineGridCell{{CELL_DATA_NAME}}.setNumberOfParticles( std::numeric_limits<int>::max() );
129 fineGridCell{{CELL_DATA_NAME}}.setNewNumberOfParticles( 0 );
130 fineGridCell{{CELL_DATA_NAME}}.setParentOfRefinedCell( true );
131 fineGridCell{{CELL_DATA_NAME}}.setNewParentOfRefinedCell( true );
135 __Template_TouchCellLastTime = jinja2.Template(
"""
137 for (int i=0; i<TwoPowerD; i++) {
138 count += fineGridVertices{{PARTICLE_SET_NAME}}(i).size();
141 fineGridCell{{CELL_DATA_NAME}}.setNewNumberOfParticles(
142 fineGridCell{{CELL_DATA_NAME}}.getNewNumberOfParticles()
147 coarseGridCell{{CELL_DATA_NAME}}.setNewNumberOfParticles(
148 coarseGridCell{{CELL_DATA_NAME}}.getNewNumberOfParticles()
150 fineGridCell{{CELL_DATA_NAME}}.getNewNumberOfParticles()
153 if ( marker.willBeRefined() ) {
154 coarseGridCell{{CELL_DATA_NAME}}.setNewParentOfRefinedCell( true );
168 return " return std::vector< peano4::grid::GridControlEvent >();\n"
172 return __name__.replace(
".py",
"").replace(
".",
"_")
183 __Template_Includes = jinja2.Template(
"""
184#include "../vertexdata/{{PARTICLE_SET_NAME}}.h"
185#include "../globaldata/{{PARTICLE_NAME}}.h"
195 if operation_name==ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
197 if operation_name==ActionSet.OPERATION_TOUCH_CELL_LAST_TIME:
199 if operation_name==ActionSet.OPERATION_CREATE_CELL:
Default superclass for any data model in Peano which is stored within the grid.
Action set (reactions to events)
This action set implements an analysed tree grammar.
get_action_set_name(self)
Return unique action set name.
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
get_constructor_body(self)
Define a tailored constructor body.
__Template_TouchCellLastTime
get_includes(self)
Return include statements that you need.
get_body_of_getGridControlEvents(self)
get_attributes(self)
Return attributes as copied and pasted into the generated class.
user_should_modify_template(self)
Is the user allowed to modify the output.
get_destructor_body(self)
__init__(self, particle_set, cell_marker=None)
__Template_TouchCellFirstTime
create_cell_marker(name)
Create the cell marker that is used by all statistics.