65 initial_time_step_size,
66 constant_time_step_size,
67 particle_particle_interaction_over_particle_sets_kernel="",
68 touch_particles_of_set_first_time_kernel="",
69 touch_particles_of_set_last_time_kernel="",
74 super(testLeapfrogFixedTimeStepSize, self).
__init__(
84 if constant_time_step_size ==
True:
85 adjustTimeStepSize =
"true"
87 adjustTimeStepSize =
"false"
107 self.
data.add_attribute(self.
_u)
117 particle_particle_interaction_over_particle_sets_kernel
120 touch_particles_of_set_first_time_kernel
123 touch_particles_of_set_last_time_kernel
133 This function translates "global" particle parameters which are
134 constant throughout the simulation (like CFL factor, minimal time step
135 size, viscosity parameters...) into dastgen attributes of the C++
137 If you modify any of the attributes manually outside of the particle
138 initialisation, e.g. by invoking
141 particle = SPHLeapfrogFixedSearchRadius(initial_time_step_size=ABC, ...)
142 particle.initial_time_step_size = XYZ
145 you need to call this function manually so your changes propagate
146 into the generated C++ files.
149 const_static = dastgen2.attributes.Attribute.Qualifier.CONST_STATIC
152 "cfl", qualifier=const_static, initval=self.
_cfl_factor
154 self.
data.add_or_replace_attribute(cfl_attr)
157 "initialTimeStepSize",
158 qualifier=const_static,
161 self.
data.add_or_replace_attribute(initial_time_step_size_attr)
164 "adjustTimeStepSize",
165 qualifier=const_static,
168 self.
data.add_or_replace_attribute(adjust_time_step_size_attr)
175 Leapfrog consists basically of four steps per particle. We first
176 determine the force. Then we update the velocity by half a timestep and move
177 the particle by a full timestep. Then the force is re-computed and the
178 second half of the velocity update is done.
179 Some variations of this KDK form re-arrange the steps executed per timestep
180 to avoid a second force loop.
184 name=
"ForceCalculation",
185 dependencies=AlgorithmStep.Dependencies.NEIGHBOURS,
186 effect=AlgorithmStep.Effect.ALTER_LOCAL_STATE,
189 ::swift2::kernels::genericInteraction<globaldata::{}>(
193 [&] (globaldata::{}* localParticle, const globaldata::{} * const globalParticle) -> void {{
205 #include "Constants.h"
206 #include "swift2/kernels/ParticleParticleInteraction.h"
211 dependencies=AlgorithmStep.Dependencies.SELF,
212 effect=AlgorithmStep.Effect.ALTER_LOCAL_STATE,
213 touch_vertex_first_time_kernel=
"""::swift2::timestepping::resetMovedParticleMarker(assignedParticles);""",
214 touch_vertex_last_time_kernel=
"""::swift2::timestepping::computeLeapfrogKickWithGlobalTimeStepSize(
215 assignedParticles);""",
216 prepare_traversal_kernel=
"""::swift2::timestepping::computeCFLTimeStepSizeSPH<globaldata::{}>();""".format(
220 #include "Constants.h"
221 #include "swift2/timestepping/Leapfrog.h"
222 #include "swift2/timestepping/GlobalTimeStepping.h"
223 #include "swift2/timestepping/TimeStepping.h"
225 #include "swift2/kernels/kernel_hydro.h"
226 #include "swift2/kernels/equation_of_state.h"
231 dependencies=AlgorithmStep.Dependencies.SELF,
232 effect=AlgorithmStep.Effect.CHANGE_POSITION_OR_INTERACTION_RADIUS_BUT_NEVER_RERUN,
233 touch_vertex_first_time_kernel=
"""::swift2::timestepping::resetMovedParticleMarker(assignedParticles);""",
234 touch_vertex_last_time_kernel=
"""::swift2::timestepping::computeLeapfrogDriftWithGlobalTimeStepSize( assignedParticles );""",
236 #include "Constants.h"
237 #include "swift2/timestepping/Leapfrog.h"
238 #include "swift2/timestepping/GlobalTimeStepping.h"
239 #include "swift2/timestepping/TimeStepping.h"
243 name=
"ForceCalculation",
244 dependencies=AlgorithmStep.Dependencies.NEIGHBOURS,
245 effect=AlgorithmStep.Effect.ALTER_LOCAL_STATE,
248 ::swift2::kernels::genericInteraction<globaldata::{}>(
252 [&] (globaldata::{}* localParticle, const globaldata::{} * const globalParticle) -> void {{
264 #include "Constants.h"
265 #include "swift2/kernels/ParticleParticleInteraction.h"
270 dependencies=AlgorithmStep.Dependencies.SELF,
271 effect=AlgorithmStep.Effect.ALTER_LOCAL_STATE,
272 touch_vertex_first_time_kernel=
"""::swift2::timestepping::resetMovedParticleMarker(assignedParticles);""",
273 touch_vertex_last_time_kernel=
"""::swift2::timestepping::computeLeapfrogKickWithGlobalTimeStepSize(
274 assignedParticles);""",
276 #include "Constants.h"
277 #include "swift2/timestepping/Leapfrog.h"
278 #include "swift2/timestepping/GlobalTimeStepping.h"
279 #include "swift2/timestepping/TimeStepping.h"
281 #include "swift2/kernels/kernel_hydro.h"
282 #include "swift2/kernels/equation_of_state.h"
286 name=
"ReduceGlobalQuantities",
287 dependencies=AlgorithmStep.Dependencies.SELF,
288 effect=AlgorithmStep.Effect.ALTER_GLOBAL_STATE,
289 cell_kernel=
"""::swift2::statistics::reduceVelocityAndSearchRadius( localParticles );""",
290 prepare_traversal_kernel=
"""
291 globaldata::{PARTICLE}::getSpecies().clearSearchRadius();
292 globaldata::{PARTICLE}::getSpecies().clearVelocity();
296 unprepare_traversal_kernel=
"""
297 globaldata::{PARTICLE}::getSpecies().setTimeStamp( globaldata::{PARTICLE}::getSpecies().getMinTimeStamp() + globaldata::{PARTICLE}::getSpecies().getMinTimeStepSize(), false );
298 ::swift2::statistics::reportSearchRadiusVTDt<globaldata::{PARTICLE}>( "{PARTICLE}" );
303 #include "Constants.h"
304 #include "swift2/statistics/Reports.h"
305 #include "swift2/statistics/Statistics.h"