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
98 if ( not marker.hasBeenRefined() and not marker.willBeRefined() ) {
100 tarch::la::Vector<2,double> domainOffset = { {{DOMAIN_OFFSET[0]}}, {{DOMAIN_OFFSET[1]}} };
101 tarch::la::Vector<2,double> domainSize = { {{DOMAIN_SIZE[0]}}, {{DOMAIN_SIZE[1]}} };
103 tarch::la::Vector<3,double> domainOffset = { {{DOMAIN_OFFSET[0]}}, {{DOMAIN_OFFSET[1]}}, {{DOMAIN_OFFSET[2]}} };
104 tarch::la::Vector<3,double> domainSize = { {{DOMAIN_SIZE[0]}}, {{DOMAIN_SIZE[1]}}, {{DOMAIN_SIZE[2]}} };
106 std::vector< globaldata::{{PARTICLE}}* > newParticles = toolbox::particles::createParticlesAlignedWithGlobalCartesianMesh<globaldata::{{PARTICLE}}>(
115 for (auto* particle: newParticles) {
117 // See documentation of constructor on initialisation snippet
118 {{INITIALISATION_CALL}}
119 toolbox::particles::insertParticleIntoCell(
122 fineGridVertices{{PARTICLES_CONTAINER}},
132 // End of template in python/peano4/toolbox/particles/InsertParticlesAlongCartesianLayoutIntoUnrefinedCells.py
138 if operation_name == ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
143 return " return std::vector< peano4::grid::GridControlEvent >();\n"
146 return __name__.replace(
".py",
"").replace(
".",
"_")
152 result = jinja2.Template(
154#include "vertexdata/{{PARTICLES_CONTAINER}}.h"
155#include "globaldata/{{PARTICLE}}.h"
156#include "toolbox/particles/particles.h"
157#include "toolbox/particles/ParticleFactory.h"
169 _spacetreeId = treeNumber;
Action set (reactions to events)
user_should_modify_template(self)
Is the user allowed to modify the output.
get_action_set_name(self)
Return unique action set name.
get_body_of_getGridControlEvents(self)
get_includes(self)
Return include statements that you need.
__Template_TouchCellFirstTime
get_constructor_body(self)
Define a tailored constructor body.
get_attributes(self)
Return attributes as copied and pasted into the generated class.
__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_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.