13 distance_between_particles,
14 computational_domain_offset,
15 computational_domain_size,
16 initialisation_call="",
19 additional_includes="",
29 I take this as particle set.
31 average_distance_between_particles: Float
32 Some positive floating point value.
34 initialisation_call: String (C code)
35 Within this code snippet, you have a variable particle which is a pointer to
36 your particle type. You can use it to set the particle attributes.
39 If True, add noise to particle coordinates
42 If noise=True, the noise added to particle coordinates is +-0.5 * particle
43 distance multiplied by this factor
45 computational_domain_offset: [Float]
46 Has to be an array with Dimensions entries that specifies the global domain
47 offset. You can pass in an array of floats, and this is definitely the
48 default use case. However, you can also pass in an arbitrary array of
49 strings, as long as these strings make sense in the generated C++ code
50 and eventually return a double each.
52 computational_domain_size: [Float]
53 Defines size of domain.
55 guard: String (C code)
56 A simple boolean expression. You can decide if a particle is inserted or not.
58 initialisation_call: String (C++ code snippet)
59 Arbitrary code snippet which can work over a pointer particle. The object
60 to which this pointer points to is properly allocated, and its
61 coordinates are set. Furthermore, the object's search radius is
62 initialised with zero. You can alter the particle attributes now, i.e.
63 initialise the domain-specific data. Please also ensure you assign the
64 particle a proper search (interaction) radius if the radius is of
65 relevance for your application.
67 Please note that we create a lot of particles and then decide if we
68 actually insert them. Only those particles where we come to the
69 conclusion that we should insert them (as they overlap with the cell)
70 are actually then initialised through this code snippet.
73 super(InsertParticlesAlongCartesianLayoutIntoUnrefinedCells, self).
__init__(
74 descend_invocation_order=1, parallel=
False
78 self.
d[
"PARTICLE"] = particle_set.particle_model.name
79 self.
d[
"PARTICLES_CONTAINER"] = particle_set.name
80 self.
d[
"INITIALISATION_CALL"] = initialisation_call
81 self.
d[
"DOMAIN_OFFSET"] = computational_domain_offset
82 self.
d[
"DOMAIN_SIZE"] = computational_domain_size
83 self.
d[
"H"] = distance_between_particles
84 self.
d[
"GUARD"] = guard
86 self.
d[
"NOISE"] =
"true"
87 self.
d[
"NOISE_SCALE"] = noise_scale
89 self.
d[
"NOISE"] =
"false"
90 self.
d[
"NOISE_SCALE"] =
"1."
93 __Template_TouchCellFirstTime = jinja2.Template(
96 // Start of template in python/peano4/toolbox/particles/InsertParticlesAlongCartesianLayoutIntoUnrefinedCells.py
99 tarch::la::Vector<2,double> domainOffset = { {{DOMAIN_OFFSET[0]}}, {{DOMAIN_OFFSET[1]}} };
100 tarch::la::Vector<2,double> domainSize = { {{DOMAIN_SIZE[0]}}, {{DOMAIN_SIZE[1]}} };
102 tarch::la::Vector<3,double> domainOffset = { {{DOMAIN_OFFSET[0]}}, {{DOMAIN_OFFSET[1]}}, {{DOMAIN_OFFSET[2]}} };
103 tarch::la::Vector<3,double> domainSize = { {{DOMAIN_SIZE[0]}}, {{DOMAIN_SIZE[1]}}, {{DOMAIN_SIZE[2]}} };
105 std::vector< globaldata::{{PARTICLE}}* > newParticles = toolbox::particles::createParticlesAlignedWithGlobalCartesianMesh<globaldata::{{PARTICLE}}>(
114 for (auto* particle: newParticles) {
116 // See documentation of constructor on initialisation snippet
117 {{INITIALISATION_CALL}}
118 toolbox::particles::insertParticleIntoCell(
121 fineGridVertices{{PARTICLES_CONTAINER}},
130 // End of template in python/peano4/toolbox/particles/InsertParticlesAlongCartesianLayoutIntoUnrefinedCells.py
136 if operation_name == ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
141 if operation_name == ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
142 return "not marker.hasBeenRefined() and not marker.willBeRefined()"
146 return " return std::vector< peano4::grid::GridControlEvent >();\n"
149 return __name__.replace(
".py",
"").replace(
".",
"_")
155 result = jinja2.Template(
157#include "vertexdata/{{PARTICLES_CONTAINER}}.h"
158#include "globaldata/{{PARTICLE}}.h"
159#include "toolbox/particles/particles.h"
160#include "toolbox/particles/ParticleFactory.h"
172 _spacetreeId = treeNumber;
Action set (reactions to events)
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.
get_action_set_name(self)
Return unique action set name.
get_attributes(self)
Return attributes as copied and pasted into the generated class.
__Template_TouchCellFirstTime
get_body_of_createGridControlEventsForNextTraversal(self)
Return the grid control events that this action set wants to trigger.
__init__(self, particle_set, distance_between_particles, computational_domain_offset, computational_domain_size, initialisation_call="", noise=True, noise_scale=1.0, additional_includes="", guard="true")
Insert particles.
get_guard_of_operation(self, operation_name)
Return the guard of an operation.
user_should_modify_template(self)
Is the user allowed to modify the output.
get_includes(self)
Return include statements that you need.