Peano 4
No Matches
swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius Class Reference
Inheritance diagram for swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius:
Collaboration diagram for swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius:

Public Member Functions

 __init__ (self, name, dimensions_hydro=2, cfl_factor=0.1, initial_time_step_size=1e-4, constant_time_step_size=True, swift_project_namespace="SPH", particles_per_cell=0, min_h=0.3, max_h=0.3, SPHParticle.ParticleKernelRealisation particle_interaction_kernel_realisation=SPHParticle.ParticleKernelRealisation.USE_OUTER_GUARDS)
 Initialise the particle.
 set_parameters (self)
 This function translates "global" particle parameters which are constant throughout the simulation (like CFL factor, minimal time step size, viscosity parameters...) into dastgen attributes of the C++ particle class.
 alpha_av (self)
 Viscosity parameters of the Minimal SPH model.
 alpha_av (self, alpha_av)
 beta_av (self)
 beta_av (self, beta_av)
 get_cpp_namespace_from_project_namespace (self)
 Transform namespace into cpp format.
 readme_descriptor (self)
 Create default readme descriptor.
- Public Member Functions inherited from swift2.particle.SPHParticle.SPHParticle
 algorithm_steps (self)
 Return algorithm steps: A list of AlgorithmStep objects to be executed in that order for this particle.
 initialisation_steps (self)
 Return the list of algorithm steps to be executed during initialisation.
 hydro_dimensions (self)
 Forbid users to modify hydro dimensions on-the-fly.
 hydro_dimensions (self, hydro_dimensions)
 eta_factor (self)
 Set the eta factor used by the SPH kernel to target a certain number of neighbour particles.
 eta_factor (self, eta_factor)
 h_hydro_min (self)
 Set the limits allowed for the SPH smoothing length.
 h_hydro_min (self, h_hydro_min)
 h_hydro_max (self)
 h_hydro_max (self, h_hydro_max)
 h_tolerance (self)
 Tolerance for Newton-Raphson convergence criterion.
 h_tolerance (self, h_tolerance)
 h_max_iterations (self)
 Max number of iterations to adapt the SPH smoothing length.
 h_max_iterations (self, h_max_iterations)
 mantissa_size (self)
 Set the mantissa size of doubles and Peano double arrays if we want to use reduced precission via Clang annotations.
 mantissa_size (self, mantissa_size)
- Public Member Functions inherited from peano4.datamodel.DaStGen2.DaStGen2
 configure (self, namespace, association)
 I always need the MPI aspect, but I can't add the right one before I don't know whether this DaStGen model is used for vertices, faces or cells.
 additional_load_and_store_arguments (self)
 additional_load_and_store_arguments (self, new_arguments)
- Public Member Functions inherited from peano4.datamodel.DoF.DoF
 get_full_qualified_type (self)
 get_logical_type_name (self)
 What should the data type be called within the data repository, or within action sets.
 get_enumeration_type (self)
 What should the data type be called within the data repository.
 additional_load_and_store_arguments_for_other_dof (self, argument_name, use_dof_association=None)
 You can make Peano's store and load arguments of any DoF depend on other DoFs that you have loaded before.

Data Fields

- Data Fields inherited from swift2.particle.SPHParticle.SPHParticle
- Data Fields inherited from swift2.particle.Particle.Particle
- Data Fields inherited from peano4.toolbox.particles.Particle.Particle
- Data Fields inherited from peano4.datamodel.DaStGen2.DaStGen2
- Data Fields inherited from peano4.datamodel.DoF.DoF

Protected Member Functions

 _setup_algorithm_steps (self)
 Set up the internal list of algorithm steps for this particle.
 _setup_initialisation_steps (self)
 Define the algorithm steps to be taken during initialization here.
- Protected Member Functions inherited from swift2.particle.Particle.Particle
 _dependency_checks_modify_steps (self, steplist, step_type_name, peano4_event_enum)
 Add dependency checks as well as mesh consistency checks to the algorithm steps.
 _add_dependency_checks (self)
 Add dependency (particle consistency) checks.

Protected Attributes

- Protected Attributes inherited from swift2.particle.SPHParticle.SPHParticle
- Protected Attributes inherited from swift2.particle.Particle.Particle
- Protected Attributes inherited from peano4.datamodel.DaStGen2.DaStGen2
- Protected Attributes inherited from peano4.datamodel.DoF.DoF

Additional Inherited Members

- Static Public Attributes inherited from swift2.particle.Particle.Particle
str DependencyChecks_Attribute_Prefix = "dependencyChecks"
list DependencyChecks_Ifdefs = ["PeanoDebug > 0"]
- Static Public Attributes inherited from peano4.datamodel.DaStGen2.DaStGen2
str readme_package_descriptor

Detailed Description

SPH particle with fixed search radius

Same as LeapfrogFixedSearchRadius but augmented for full SPH.
Implements the Minimal SPH scheme.

Simple particle with a fixed search radius h which moves according
to leapfrog KDK scheme.
By default, it uses global time stepping,
i.e. the combination of maximum velocity and minimal mesh size determines
the time step size of the subsequent time step. Besides the default
variables x and h, the particle has the following properties:

- a vector a which is the acceleration;
- a vector v which is the velocity.

You can add further properties via peano4.dastgen2.Peano4DoubleArray("myFancyArray","Dimensions") )

in your code. Or you can create a subclass which adds additional fields
after it has called the baseline constructor.

You will need to add further properties for any SPH project.

## Force calculation

particle_particle_interaction_over_particle_sets_kernel is a C++ string which defines a force between two
particles. It has access to three important objects:

- localParticles is a container (list) over pointers to local particles
- activeParticles is a container (list) over pointers to active particles
- marker is a cell marker which identifies the current cell.

Please consult the guidebook for a definition of local and active particles
but take into account that the local particles always are a subset of the
active particles.

Besides the actual particle-to-particle calculation, i.e. a force
calculation, users can also provide kernels that kick in when you touch
particles for the first time before you actually compute any
particle-particle interaction, and there is a plug-in point what you do
just once the particle-particle interaction has terminated. The latter
point is reached before we do the actual time stepping. In both plug-in
points, you have a vertex marker which gives you the position of the
vertex to which a particular is associated, and you have the localParticles.
This is a vector of pointers in this particular case.

The force calculation does exist in two variants: There's the default one
and then we have one that is aggressively optimised. The latter one requires
us to have properly sorted particle-mesh associations.

## Precision

By default, all particle attributes are modelled as doubles or arrays of
doubles. This might be overly precise. You can alter the precision through
our LLVM compiler modifications if you invoke the following commands on a
particle species:

particle.mass.valid_mantissa_bits         = args.mantissa_size
particle.velocity.valid_mantissa_bits     = args.mantissa_size
particle.acceleration.valid_mantissa_bits = args.mantissa_size
particle.density.valid_mantissa_bits      = args.mantissa_size
particle.pressure.valid_mantissa_bits     = args.mantissa_size
particle.smoothL.valid_mantissa_bits      = args.mantissa_size
particle.u.valid_mantissa_bits            = args.mantissa_size
particle.uDot.valid_mantissa_bits         = args.mantissa_size
particle.f.valid_mantissa_bits            = args.mantissa_size
particle.wcount_dh.valid_mantissa_bits    = args.mantissa_size
particle.rho_dh.valid_mantissa_bits       = args.mantissa_size
particle.wcount.valid_mantissa_bits       = args.mantissa_size
particle.hDot.valid_mantissa_bits         = args.mantissa_size
particle.balsara.valid_mantissa_bits      = args.mantissa_size
particle.rot_v.valid_mantissa_bits        = args.mantissa_size
particle.div_v.valid_mantissa_bits        = args.mantissa_size
particle.v_sig_AV.valid_mantissa_bits     = args.mantissa_size
particle.soundSpeed.valid_mantissa_bits   = args.mantissa_size
particle.v_full.valid_mantissa_bits       = args.mantissa_size
particle.u_full.valid_mantissa_bits       = args.mantissa_size

This is an example. You can also add ony a few of these fields, and picking
a value for args.mantissa_size is obviously up to you. We refrain from
illustrating that you can also alter the precision of the position and
maximum search radius of a particle this way. This is on purpose: We have
made bad experience with such modifications.

## Boundary conditions

Boundary conditions for Swift are @ref swift_boundary_conditions "discussed on a separate page".
If you decide that you want to plug into the drift mechanism of
this SPH flavour, you typically add something similar to the
code snippet below to your code:


particle.algorithm_steps_dict["Drift"].touch_vertex_last_time_kernel += " " " if (::swift2::boundaryconditions::isVertexOnGlobalBoundary(marker,DomainOffset,DomainSize)) { ::swift2::kernels::forAllParticles( marker, assignedParticles, [&](const peano4::datamanagement::VertexMarker& marker, globaldata::" " " + name + " " "& assignedParticle)->void { ::swift2::boundaryconditions::applyFixedBoundaryCondition( assignedParticle, marker, DomainOffset, DomainSize, 0.1, _spacetreeId ); } ); } " " " particle.algorithm_steps_dict["Drift"].includes += " " " #include "swift2/boundaryconditions/FixedBoundary.h" #include "swift2/boundaryconditions/Utils.h" " " " particle._setup_algorithm_steps() particle._setup_initialisation_steps() ~~~~~~~~~~~~~~~~~~~~~~

The spaced-out syntax is just there to ensure that the Python documentation syntax is not broken.

## Attributes

name: String
To be in line with other conventions, I recommend you start with an
uppercase letter. This has to be a valid C++ identifier, i.e. don't
use any special symbols besides an underscore.

## Vectorisation

This type can be used with aggressively optimised kernels if you follow
@ref page_swift_performance_optimisation Performance optimisation and use
the map_particle_steps_onto_separate_mesh_traversals_insert_dummy_sweeps_for_coalesced_memory_access
graph compiler from the Sequential suite; or literally any other
flavour which yields coalesced memory.

@param particle_interaction_kernel_realisation: ParticleKernelRealisation
  Switch through various interaction variants.

@see peano4::datamanagement::CellMarker
@see peano4::datamanagement::VertexMarker

Definition at line 18 of file

Constructor & Destructor Documentation

◆ __init__()

swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius.__init__ ( self,
particles_per_cell = 2,
min_h = 0.1,
max_h = 1e-4,
constant_time_step_size = True,
swift_project_namespace = "SPH",
particles_per_cell = 0,
min_h = 0.3,
max_h = 0.3,
SPHParticle.ParticleKernelRealisation particle_interaction_kernel_realisation = SPHParticle.ParticleKernelRealisation.USE_OUTER_GUARDS )

Initialise the particle.

This is the baseclass for a particle, i.e. we only add the absolute minimum of information to a particle. As we inherit from the toolbox particle, we already have some attributes defined. These are the guys which are not explicitly visible from the code snippet below, i.e. they are introduced by the superclass constructor.

Here's an overview of pre-defined attributes that each and every particle hosts:

  • A position which is a double vector with Dimension entries.
  • A search radius which describes the range with which other particles a particle might theoretically interact. The effective interaction might be smaller if a code decides to ignore potential interaction partners, i.e. this is an absolute maximum. The search radius will decide on which resolution level within the tree a particle is held.
  • A MoveState flag. This flag is essential. We use it later to label those particles that have been moved to avoid that we move particles multiple times.
  • A flag that indicates if a particle has been updated within a cell. Consult our code release papers: In short, a particle does not uniquely belong to one cell but can belong to many cells. We nevertheless want to update them only once.
See also

Reimplemented from swift2.particle.SPHParticle.SPHParticle.

Reimplemented in swift2.particle.tests.testDensityCalculation.testDensityCalculation.

Definition at line 170 of file

References swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius.__init__().

Referenced by swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius.__init__().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ _setup_algorithm_steps()

swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius._setup_algorithm_steps ( self)

Set up the internal list of algorithm steps for this particle.

We need to maintain an individual instance of this list for cases where we modify the algorithm steps later on. This can happen for example when adding debugging/dependency checks later on.

The algorithm steps shall be a list of AlgorithmStep objects to be executed in that order.

Definitions of the algorithm steps stored in the algorithm_steps_dict are placed in get_algorithm_steps_dict(self). The dict is set up during instantiation of this class, and reads in all available algorithm steps defined in

Leapfrog consists basically of four steps per particle. We first determine the force. Then we update the velocity by half a timestep and move the particle by a full timestep. Then the force is re-computed and the second half of the velocity update is done. Some variations of this KDK form re-arrange the steps executed per timestep to avoid a second force loop. We can't do this here because we're not planning on running with fixed time step sizes throughout the run.

Reimplemented from swift2.particle.SPHParticle.SPHParticle.

Reimplemented in swift2.particle.tests.testDensityCalculation.testDensityCalculation.

Definition at line 286 of file

References swift2.particle.ExplicitEulerFixedSearchRadius.ExplicitEulerFixedSearchRadius._algorithm_steps, swift2.particle.LeapfrogFixedSearchRadius.LeapfrogFixedSearchRadius._algorithm_steps, swift2.particle.Particle.Particle._algorithm_steps, swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius._algorithm_steps, swift2.particle.tests.testDensityCalculation.testDensityCalculation._algorithm_steps, and swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius.algorithm_steps_dict.

Referenced by swift2.particle.tests.testDensityCalculation.testDensityCalculation.__init__().

Here is the caller graph for this function:

◆ _setup_initialisation_steps()

swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius._setup_initialisation_steps ( self)

Define the algorithm steps to be taken during initialization here.

This follows the same logic as _setup_algorithm_steps. See documentation there for more info.

Make sure get_algorithm_steps_dict(self) has been called before.

Reimplemented from swift2.particle.SPHParticle.SPHParticle.

Reimplemented in swift2.particle.tests.testDensityCalculation.testDensityCalculation.

Definition at line 327 of file

References swift2.particle.Particle.Particle._initialisation_steps, swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius._initialisation_steps, swift2.particle.tests.testDensityCalculation.testDensityCalculation._initialisation_steps, and swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius.algorithm_steps_dict.

Referenced by swift2.particle.tests.testDensityCalculation.testDensityCalculation.__init__().

Here is the caller graph for this function:

◆ alpha_av() [1/2]

swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius.alpha_av ( self)

Viscosity parameters of the Minimal SPH model.

Default SWIFT values are alpha_av=0.8 and beta_av=3.

Definition at line 352 of file

References swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius._alpha_av.

◆ alpha_av() [2/2]

swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius.alpha_av ( self,
alpha_av )

◆ beta_av() [1/2]

swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius.beta_av ( self)

◆ beta_av() [2/2]

swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius.beta_av ( self,
beta_av )

◆ get_cpp_namespace_from_project_namespace()

swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius.get_cpp_namespace_from_project_namespace ( self)

Transform namespace into cpp format.

Could be used to append namespace to constants in kernels (not used currently).

Reimplemented from swift2.particle.SPHParticle.SPHParticle.

Definition at line 377 of file

References swift2.particle.SPHParticle.SPHParticle._swift_project_namespace.

◆ readme_descriptor()

swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius.readme_descriptor ( self)

Create default readme descriptor.

You might want to overwrite this for your particular particle species to get more detailed info the the file generated by Peano.

Reimplemented from swift2.particle.SPHParticle.SPHParticle.

Definition at line 389 of file

◆ set_parameters()

swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius.set_parameters ( self)

This function translates "global" particle parameters which are constant throughout the simulation (like CFL factor, minimal time step size, viscosity parameters...) into dastgen attributes of the C++ particle class.

If you modify any of the attributes manually outside of the particle initialisation, e.g. by invoking

particle = SPHLeapfrogFixedSearchRadius(initial_time_step_size=ABC, ...)
particle.initial_time_step_size = XYZ

you need to call this function manually so your changes propagate into the generated C++ files.

Reimplemented from swift2.particle.SPHParticle.SPHParticle.

Definition at line 252 of file

References swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius._alpha_av, swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius._beta_av,,,,,,, kernels::array< T >.data, kernels::shadow< T >.data,, tarch::la::Matrix< Rows, Cols, Scalar >.data(), tarch::la::Vector< Dimensions, int >.data(), tarch::la::Vector< Dimensions, double >.data(), tarch::la::Vector< TwoTimesD, int >.data(), tarch::la::Vector< TwoPowerD, int >.data(), tarch::la::Vector< Size, Scalar >.data(), tarch::la::Vector< DimensionsTimesTwo, int >.data(), tarch::la::Matrix< Rows, Cols, Scalar >.data(), tarch::la::Vector< TwoPowerD, int >.data(), tarch::la::Vector< DimensionsTimesTwo, int >.data(), tarch::la::Vector< Size, Scalar >.data(), tarch::la::Vector< Dimensions, int >.data(), tarch::la::Vector< Dimensions, double >.data(), tarch::la::Vector< TwoTimesD, int >.data(),, toolbox::particles::memorypool::GlobalContinuousMemoryPool< T >,, and swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius.set_parameters().

Referenced by swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius.set_parameters().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ _algorithm_steps


Definition at line 234 of file

Referenced by swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius._setup_algorithm_steps(), swift2.particle.ExplicitEulerFixedSearchRadius.ExplicitEulerFixedSearchRadius.add_to_reduction(), swift2.particle.LeapfrogFixedSearchRadius.LeapfrogFixedSearchRadius.add_to_reduction(), swift2.particle.ExplicitEulerFixedSearchRadius.ExplicitEulerFixedSearchRadius.algorithm_steps(), swift2.particle.LeapfrogFixedSearchRadius.LeapfrogFixedSearchRadius.algorithm_steps(), swift2.particle.ExplicitEulerFixedSearchRadius.ExplicitEulerFixedSearchRadius.cell_kernel(), swift2.particle.LeapfrogFixedSearchRadius.LeapfrogFixedSearchRadius.cell_kernel(), swift2.particle.ExplicitEulerFixedSearchRadius.ExplicitEulerFixedSearchRadius.cell_kernel(), swift2.particle.LeapfrogFixedSearchRadius.LeapfrogFixedSearchRadius.cell_kernel(), swift2.particle.ExplicitEulerFixedSearchRadius.ExplicitEulerFixedSearchRadius.initialisation_steps(), swift2.particle.LeapfrogFixedSearchRadius.LeapfrogFixedSearchRadius.initialisation_steps(), swift2.particle.ExplicitEulerFixedSearchRadius.ExplicitEulerFixedSearchRadius.touch_particles_of_set_first_time_kernel(), swift2.particle.LeapfrogFixedSearchRadius.LeapfrogFixedSearchRadius.touch_particles_of_set_first_time_kernel(), swift2.particle.ExplicitEulerFixedSearchRadius.ExplicitEulerFixedSearchRadius.touch_particles_of_set_first_time_kernel(), swift2.particle.LeapfrogFixedSearchRadius.LeapfrogFixedSearchRadius.touch_particles_of_set_first_time_kernel(), swift2.particle.ExplicitEulerFixedSearchRadius.ExplicitEulerFixedSearchRadius.touch_particles_of_set_last_time_kernel(), swift2.particle.LeapfrogFixedSearchRadius.LeapfrogFixedSearchRadius.touch_particles_of_set_last_time_kernel(), swift2.particle.ExplicitEulerFixedSearchRadius.ExplicitEulerFixedSearchRadius.touch_particles_of_set_last_time_kernel(), and swift2.particle.LeapfrogFixedSearchRadius.LeapfrogFixedSearchRadius.touch_particles_of_set_last_time_kernel().

◆ _alpha_av

◆ _beta_av


◆ _cfl_factor


◆ _hydro_dimensions


◆ _initial_time_step_size


◆ _initialisation_steps


◆ _sph_flavour


Definition at line 200 of file

◆ algorithm_steps_dict

◆ balsara


Definition at line 216 of file

◆ div_v


Definition at line 223 of file

◆ rot_v


Definition at line 218 of file

◆ soundSpeed


Definition at line 225 of file

◆ v_sig_AV


Definition at line 224 of file

The documentation for this class was generated from the following file: