AQUAgpusph 5.0.4
Loading...
Searching...
No Matches
Basic preset

Basic preset of tools to build more complex sets of tools later. More...

Files

file  Binormal.cl
 Compute the tangent vector in 2D sims, and the binormal in 3D sims.
file  deltaSPH.cl
 delta-SPH methods, including the correction terms
file  DensityClamp.cl
 Particles out of domain filter.
file  Domain.cl
 Particles out of domain filter.
file  EOS.cl
 Equation Of State (EOS) computation.
file  IdInverse.cl
 Permutations to move from the sorted indexes space to the unsorted one.
file  MLS.cl
 MLS kernel transformation matrix computation.
file  Coalesce.cl
 Splitting particles methods.
file  Cube.cl
 Splitting particles methods.
file  Remove.cl
 Set the mass of the particles according to the iterations since they were split/coalesced.
file  SetMass.cl
 Set the mass of the particles according to the iterations since they were split/coalesced.
file  Sort.cl
 Sort the multiresolution involved particle properties.
file  Sphere.cl
 Splitting particles methods.
file  Split.cl
 Splitting particles methods.
file  neighs.cl
 Compute the number of neighbours of each particle.
file  SetBuffer.cl
 Buffer particles identify and usage.
file  Shepard.cl
 Shepard renormalization factor computation.
file  Sort.cl
 Sort all the particle variables by the cell indexes.
file  adam_bashforth.cl
 Improved Euler time integration scheme.
file  euler.cl
 1st order Euler time integration scheme
file  improved_euler.cl
 Improved Euler time integration scheme.
file  midpoint.cl
 Semi-implicit Midpoint Euler time integration scheme.
file  deltaSPH.cl
 delta-SPH methods, including the correction terms
file  Shepard.cl
 Shepard renormalization factor computation, when variable kernel length is considered.
file  Sort.cl
 Sort all the particle variables by the cell indexes.
file  MLS.cl
 Shepard renormalization factor computation.
file  Shepard.cl
 Shepard renormalization factor computation.
file  Shepard.cl
 Shepard renormalization factor computation.

Macros

#define EXCLUDED_PARTICLE(index)
 Condition to exclude a particle from the delta-SPH model.
#define EXCLUDED_PARTICLE(index)
 Condition to exclude a particle from the EOS computation.
#define M_ITERS   10
 Number of iterations to complete the mass transfer.
#define CAPTURING_RADIUS   0.75f
#define CAPTURING_RADIUS2   (CAPTURING_RADIUS + 0.01f)
#define M_ITERS   10
 Number of iterations to complete the mass transfer.
#define M_ITERS   10
 Number of iterations to complete the mass transfer.
#define N_DAUGHTER   4
#define M_ITERS   10
#define EXCLUDED_PARTICLE(index)
 Excluded particles from the Shepard renormalization factor computation.
#define TSCHEME_ADAMS_BASHFORTH_STEPS   5u
#define DYDT_1(dydt_0)
#define DYDT_2(dydt_0, dydt_1)
#define DYDT_3(dydt_0, dydt_1, dydt_2)
#define DYDT_4(dydt_0, dydt_1, dydt_2, dydt_3)
#define DYDT_5(dydt_0, dydt_1, dydt_2, dydt_3, dydt_4)
#define EXCLUDED_PARTICLE(index)
 Condition to exclude a particle from the delta-SPH model.
#define EXCLUDED_PARTICLE(index)
 Excluded particles from the Shepard renormalization factor computation.

Functions

__kernel void entry (const __global vec *normal, __global vec *tangent, __global vec *binormal, usize N)
 Compute the tanget vector in 2D simulations, and the binormal vector in 3D simulations.
__kernel void simple (const __global unsigned int *iset, const __global int *imove, __global vec *lap_p_corr, __constant float *refd, usize N, vec g)
 Simple hidrostatic based correction term.
__kernel void full (const __global int *imove, const __global vec *r, const __global float *rho, const __global float *m, const __global float *p, __global vec *lap_p_corr, usize N, LINKLIST_LOCAL_PARAMS)
 MLS based correction term.
__kernel void full_mls (const __global int *imove, const __global matrix *mls, __global vec *lap_p_corr, usize N)
 MLS based correction term.
__kernel void lapp (const __global int *imove, const __global vec *r, const __global float *rho, const __global float *m, const __global float *p, __global float *lap_p, usize N, LINKLIST_LOCAL_PARAMS)
 Laplacian of the pressure computation.
__kernel void lapp_corr (const __global int *imove, const __global vec *r, const __global float *rho, const __global float *m, const __global vec *lap_p_corr, __global float *lap_p, usize N, LINKLIST_LOCAL_PARAMS)
 Laplacian of the pressure correction.
__kernel void deltaSPH (const __global unsigned int *iset, const __global int *imove, const __global float *rho, const __global float *lap_p, __global float *drhodt, __constant float *refd, __constant float *delta, usize N, float dt)
 Density variation rates delta-SPH term.
__kernel void entry (__global float *rho_in, usize N, float rho_min, float rho_max)
 Clamp the density.
__kernel void entry (__global int *imove, __global vec *r_in, __global vec *u_in, __global vec *dudt_in, __global float *m, usize N, vec domain_min, vec domain_max)
 Check and destroy the particles out of the domain.
__kernel void entry (__global unsigned int *iset, __global int *imove, __global float *rho, __global float *p, __constant float *refd, usize N, float cs, float p0)
 Stiff Equation Of State (EOS) computation.
__kernel void entry (__global usize *id, __global usize *id_inverse, usize N)
 Compute the permutations to move from the sorted indexes space to the unsorted one.
__kernel void entry (const __global int *imove, const __global vec *r, const __global float *rho, const __global float *m, __global matrix *mls, usize N, uint mls_imove, LINKLIST_LOCAL_PARAMS)
 Compute the MLS transformation matrix inverse, \( L_i^{-1} \).
__kernel void mls_inv (const __global int *imove, __global matrix *mls, usize N, uint mls_imove)
 Invert the matrix computed in entry() to get the final MLS transformation matrix, \( L_i \).
__kernel void seed_candidates (__global const unsigned int *iset, __global const int *imove, __global const unsigned int *ilevel, __global const unsigned int *level, __global const float *m0, __global int *miter, __global const vec *r, __global unsigned int *isplit, __global svec *split_cell, __global float *split_dist, __constant float *dr_level0, usize N)
 Look for all the seed candidates, i.e. all the particles which have a refinement level target lower than their current value.
__kernel void seeds (__global const unsigned int *iset, __global const unsigned int *isplit_in, __global unsigned int *isplit, __global int *miter, __global const svec *split_cell, __global const float *split_dist, usize N, LINKLIST_LOCAL_PARAMS)
 Get only one seed per cell.
__kernel void set_isplit_in (__global const unsigned int *isplit, __global unsigned int *isplit_in, usize N)
 Create a copy of isplit, where everything is 0 except the seeds, which take the value 1. Such array can be used to count the number of new particles to become generated.
__kernel void children (__global const int *imove, __global const unsigned int *iset, __global const vec *r, __global const unsigned int *ilevel, __global unsigned int *isplit, __global int *miter, __constant float *dr_level0, usize N, LINKLIST_LOCAL_PARAMS)
 Look for all children, close enough to the seed.
__kernel void weights (__global const unsigned int *iset, __global const unsigned int *ilevel, __global const vec *r, __global const unsigned int *isplit, __global float *split_weight, __constant float *dr_level0, usize N, LINKLIST_LOCAL_PARAMS)
 Compute the contribution weight of each children particle.
__kernel void generate (__global int *imove, __global int *iset, __global const unsigned int *isplit, __global usize *split_invperm, __global unsigned int *ilevel, __global unsigned int *level, __global int *miter, __global usize *mybuffer, usize N, usize nbuffer)
 Associate a buffer particle to a seed.
__kernel void fields (__global const unsigned int *iset, __global const uint *isplit, __global const usize *mybuffer, __global const unsigned int *ilevel, __global const float *split_weight, __global float *m0, __global float *m, __global vec *r, __global vec *u, __global vec *dudt, __global float *rho, __global float *drhodt, __constant float *dr_level0, usize N, LINKLIST_LOCAL_PARAMS)
 Collect the children, and the seed itself, in order to compute the field values of the buffer partner particle.
__kernel void entry (__global const int *imove, __global const unsigned int *ilevel, __global const vec *r, __global unsigned int *level, usize N, vec multiresolution_cube_min, vec multiresolution_cube_max, unsigned int multiresolution_cube_level)
 Set the refinement level of the particles inside.
__kernel void entry (__global int *imove, __global const int *miter, __global vec *r, vec domain_max, usize N)
 Set the mass of the particles according to their gamma value.
__kernel void set_mass (__global const int *imove, __global const float *m0, __global int *miter, __global float *m, usize N)
 Set the mass of the particles according to their gamma value.
__kernel void entry (const __global float *m0_in, __global float *m0, const __global int *miter_in, __global int *miter, const __global uint *ilevel_in, __global uint *ilevel, const __global uint *level_in, __global uint *level, const __global usize *id_sorted, usize N)
 Sort the multiresolution involved particle properties.
__kernel void entry (__global const int *imove, __global const unsigned int *ilevel, __global const vec *r, __global unsigned int *level, usize N, vec multiresolution_sphere_center, float multiresolution_sphere_radius, unsigned int multiresolution_sphere_level)
 Set the refinement level of the particles inside.
__kernel void check_split (__global const int *imove, __global const float *m, __global const int *miter, __global const unsigned int *ilevel, __global const unsigned int *level, __global unsigned int *isplit, usize N)
 Check and store wether a particle should become split or not.
__kernel void generate (__global int *imove, __global int *iset, __global unsigned int *isplit, __global usize *split_invperm, __global unsigned int *ilevel, __global unsigned int *level, __global float *m0, __global int *miter, __global float *m, __global vec *r, __global vec *u, __global vec *dudt, __global float *rho, __global float *drhodt, usize N, usize nbuffer)
 Split a particle in a set of daughter particles.
__kernel void entry (const __global int *imove, __global uint *n_neighs, uint neighs_limit, usize N, LINKLIST_LOCAL_PARAMS)
 Number of neighbours of each particle.
__kernel void count (__global const int *imove, __global unsigned int *ibuffer, usize N)
 Identify the buffer particles.
__kernel void set_imove (__global int *imove, usize N)
 Replace the particles with the imove flag imove=-256 by imove=-255.
__kernel void entry (const __global int *imove, const __global vec *r, const __global float *rho, const __global float *m, __global float *shepard, usize N, LINKLIST_LOCAL_PARAMS)
 Shepard factor computation.
__kernel void stage1 (const __global usize *id_in, __global usize *id, const __global uint *iset_in, __global uint *iset, const __global int *imove_in, __global int *imove, const __global vec *r_in, __global vec *r, const __global vec *normal_in, __global vec *normal, const __global vec *tangent_in, __global vec *tangent, const __global usize *id_sorted, usize N)
 Sort all the particle variables by the cell indexes.
__kernel void stage2 (const __global float *rho_in, __global float *rho, const __global float *m_in, __global float *m, const __global vec *u_in, __global vec *u, const __global vec *dudt, __global vec *dudt_in, const __global float *drhodt, __global float *drhodt_in, const __global usize *id_sorted, usize N)
 Sort all the particle variables by the cell indexes.
__kernel void predictor (__global vec *r, __global vec *u, __global vec *dudt, __global float *rho, __global float *drhodt, __global vec *r_in, __global vec *u_in, __global vec *dudt_in, __global float *rho_in, __global float *drhodt_in, usize N)
 Adams-Bashforth time integration scheme predictor stage.
__kernel void sort (const __global vec *dudt_as1_in, __global vec *dudt_as1, const __global vec *dudt_as2_in, __global vec *dudt_as2, const __global vec *dudt_as3_in, __global vec *dudt_as3, const __global vec *dudt_as4_in, __global vec *dudt_as4, const __global float *drhodt_as1_in, __global float *drhodt_as1, const __global float *drhodt_as2_in, __global float *drhodt_as2, const __global float *drhodt_as3_in, __global float *drhodt_as3, const __global float *drhodt_as4_in, __global float *drhodt_as4, const __global usize *id_sorted, usize N)
 Sort the stored Adams-Bashforth stored variation rates.
__kernel void corrector (__global int *imove, __global unsigned int *iset, __global vec *r, __global vec *u, __global vec *dudt, __global float *rho, __global float *drhodt, __global vec *dudt_as1, __global float *drhodt_as1, __global vec *dudt_as2, __global float *drhodt_as2, __global vec *dudt_as3, __global float *drhodt_as3, __global vec *dudt_as4, __global float *drhodt_as4, usize N, float dt, unsigned int iter)
 Improved Euler time integration scheme corrector stage.
__kernel void postcorrector (const __global vec *dudt_as1, const __global float *drhodt_as1, const __global vec *dudt_as2, const __global float *drhodt_as2, const __global vec *dudt_as3, const __global float *drhodt_as3, const __global vec *dudt, const __global float *drhodt, __global vec *dudt_as1_in, __global float *drhodt_as1_in, __global vec *dudt_as2_in, __global float *drhodt_as2_in, __global vec *dudt_as3_in, __global float *drhodt_as3_in, __global vec *dudt_as4_in, __global float *drhodt_as4_in, usize N)
 Backup de data for the sorting algorithm.
__kernel void corrector (__global int *imove, __global unsigned int *iset, __global vec *r, __global vec *u, __global vec *dudt, __global float *rho, __global float *drhodt, usize N, float dt)
 1st orderv Euler time integration scheme corrector stage
__kernel void predictor (__global int *imove, __global vec *r, __global vec *u, __global vec *dudt, __global float *rho, __global float *drhodt, __global vec *r_in, __global vec *u_in, __global vec *dudt_in, __global float *rho_in, __global float *drhodt_in, usize N, float dt)
 Improved Euler time integration scheme predictor stage.
__kernel void corrector (__global int *imove, __global unsigned int *iset, __global vec *r, __global vec *u, __global vec *dudt, __global float *rho, __global float *drhodt, __global vec *dudt_in, __global float *drhodt_in, usize N, float dt)
 Improved Euler time integration scheme corrector stage.
__kernel void predictor (const __global vec *r, const __global vec *u, const __global vec *dudt, const __global float *rho, const __global float *drhodt, __global vec *r_in, __global vec *u_in, __global vec *dudt_in, __global float *rho_in, __global float *drhodt_in, usize N)
 Semi-implicit Midpoint Euler time integration scheme predictor stage.
__kernel void midpoint (const __global int *imove, const __global vec *u_in, __global vec *u, const __global vec *dudt, const __global float *rho_in, __global float *rho, const __global float *drhodt, usize N, float dt)
 Advance to the time step midpoint.
__kernel void midpoint_r (const __global int *imove, const __global vec *r_in, __global vec *r, const __global vec *u, usize N, float dt)
 Advance the position to the time step midpoint.
__kernel void relax (const __global int *imove, __global vec *dudt_in, __global vec *dudt, __global float *drhodt_in, __global float *drhodt, usize N, float relax_midpoint)
__kernel void residuals (const __global int *imove, const __global float *m, const __global vec *u, const __global vec *dudt_in, const __global vec *dudt, const __global float *rho, const __global float *p, const __global float *drhodt_in, const __global float *drhodt, __global float *residual_midpoint, usize N)
__kernel void corrector (const __global int *imove, const __global vec *r_in, __global vec *r, const __global vec *u_in, __global vec *u, const __global vec *dudt, const __global float *rho_in, __global float *rho, const __global float *drhodt, usize N, float dt)
 1st order Semi-implicit Euler time integration scheme corrector stage
__kernel void lapp (const __global int *imove, const __global vec *r, const __global float *rho, const __global float *m, const __global float *p, const __global float *h_var, __global float *lap_p, usize N, LINKLIST_LOCAL_PARAMS)
 Laplacian of the pressure computation.
__kernel void entry (const __global int *imove, const __global vec *r, const __global float *rho, const __global float *m, const __global float *h_var, __global float *shepard, usize N, LINKLIST_LOCAL_PARAMS)
 Shepard factor computation.
__kernel void entry (const __global float *h_var_in, __global float *h_var, const __global usize *id_sorted, usize N)
 Sort all the particle variables by the cell indexes.
__kernel void entry (const __global int *imove, const __global int *imirrored, const __global vec *r, const __global float *rho, const __global float *m, __global matrix *mls, usize N, uint mls_imove, LINKLIST_LOCAL_PARAMS)
 Compute the MLS transformation matrix inverse, \( L_i^{-1} \), due to the particles at the other portal side.
__kernel void entry (const __global int *imove, const __global int *imirrored, const __global vec *r, const __global float *rho, const __global float *m, __global float *shepard, usize N, LINKLIST_LOCAL_PARAMS)
 Shepard factor computation, due to the particles at the other portal side.
__kernel void entry (const __global int *imove, const __global int *imirrored, const __global vec *r, const __global float *rho, const __global float *m, const __global float *h_var, __global float *shepard, usize N, LINKLIST_LOCAL_PARAMS)
 Shepard factor computation, due to the particles at the other portal side.

Detailed Description

Basic preset of tools to build more complex sets of tools later.

Macro Definition Documentation

◆ CAPTURING_RADIUS

#define CAPTURING_RADIUS   0.75f

◆ CAPTURING_RADIUS2

#define CAPTURING_RADIUS2   (CAPTURING_RADIUS + 0.01f)

◆ DYDT_1

#define DYDT_1 ( dydt_0)
Value:
dydt_0

◆ DYDT_2

#define DYDT_2 ( dydt_0,
dydt_1 )
Value:
1.5f * dydt_0 - 0.5f * dydt_1

◆ DYDT_3

#define DYDT_3 ( dydt_0,
dydt_1,
dydt_2 )
Value:
23.f / 12.f * dydt_0 - 4.f / 3.f * dydt_1 + 5.f / 12.f * dydt_2

◆ DYDT_4

#define DYDT_4 ( dydt_0,
dydt_1,
dydt_2,
dydt_3 )
Value:
55.f / 24.f * dydt_0 - 59.f / 24.f * dydt_1 + 37.f / 24.f * dydt_2 - \
3.f / 8.f * dydt_3

◆ DYDT_5

#define DYDT_5 ( dydt_0,
dydt_1,
dydt_2,
dydt_3,
dydt_4 )
Value:
1901.f / 720.f * dydt_0 - 1387.f / 360.f * dydt_1 + 109.f / 30.f * dydt_2 - \
637.f / 360.f * dydt_3 + 251.f / 720.f * dydt_4

◆ EXCLUDED_PARTICLE [1/5]

#define EXCLUDED_PARTICLE ( index)
Value:
imove[index] <= 0

Condition to exclude a particle from the delta-SPH model.

Excluded particles from the Shepard renormalization factor computation.

Condition to exclude a particle from the EOS computation.

By default all the boundary elements are excluded. Even though it is enough for simulation where fluid and solid mechanics are not combined, it is strongly recommended to conveniently overload this macro.

Note
Redefining this macro this OpenCL script can be recicled

By default all the boundary elements are excluded, excepting the fixed particles (imove = -1)

Note
Redefining this macro this OpenCL script can be recicled for different particle types.

By default all the particles are included. Therefore it is strongly recommended to redefine this macro to specify whether the fluid particles (imove != 1) or the solid particles (imove != 2) are used

Note
Redefining this macro this OpenCL script can be recicled
Remarks
The Shepard renormalization factor is ever computed at the boundary elements and sensors (imove <= 0)

◆ EXCLUDED_PARTICLE [2/5]

#define EXCLUDED_PARTICLE ( index)
Value:
(imove[index] <= 0) && (imove[index] != -1)

Condition to exclude a particle from the EOS computation.

Condition to exclude a particle from the delta-SPH model.

Excluded particles from the Shepard renormalization factor computation.

By default all the boundary elements are excluded, excepting the fixed particles (imove = -1)

Note
Redefining this macro this OpenCL script can be recicled for different particle types.

By default all the particles are included. Therefore it is strongly recommended to redefine this macro to specify whether the fluid particles (imove != 1) or the solid particles (imove != 2) are used

Note
Redefining this macro this OpenCL script can be recicled
Remarks
The Shepard renormalization factor is ever computed at the boundary elements and sensors (imove <= 0)

By default all the boundary elements are excluded. Even though it is enough for simulation where fluid and solid mechanics are not combined, it is strongly recommended to conveniently overload this macro.

Note
Redefining this macro this OpenCL script can be recicled

◆ EXCLUDED_PARTICLE [3/5]

#define EXCLUDED_PARTICLE ( index)
Value:
imove[index] >= 3

Excluded particles from the Shepard renormalization factor computation.

Condition to exclude a particle from the delta-SPH model.

By default all the particles are included. Therefore it is strongly recommended to redefine this macro to specify whether the fluid particles (imove != 1) or the solid particles (imove != 2) are used

Note
Redefining this macro this OpenCL script can be recicled
Remarks
The Shepard renormalization factor is ever computed at the boundary elements and sensors (imove <= 0)

By default all the boundary elements are excluded. Even though it is enough for simulation where fluid and solid mechanics are not combined, it is strongly recommended to conveniently overload this macro.

Note
Redefining this macro this OpenCL script can be recicled

◆ EXCLUDED_PARTICLE [4/5]

#define EXCLUDED_PARTICLE ( index)
Value:
imove[index] <= 0

Condition to exclude a particle from the delta-SPH model.

Excluded particles from the Shepard renormalization factor computation.

By default all the boundary elements are excluded. Even though it is enough for simulation where fluid and solid mechanics are not combined, it is strongly recommended to conveniently overload this macro.

Note
Redefining this macro this OpenCL script can be recicled

By default all the particles are included. Therefore it is strongly recommended to redefine this macro to specify whether the fluid particles (imove != 1) or the solid particles (imove != 2) are used

Note
Redefining this macro this OpenCL script can be recicled
Remarks
The Shepard renormalization factor is ever computed at the boundary elements and sensors (imove <= 0)

◆ EXCLUDED_PARTICLE [5/5]

#define EXCLUDED_PARTICLE ( index)
Value:
imove[index] >= 3

Excluded particles from the Shepard renormalization factor computation.

By default all the particles are included. Therefore it is strongly recommended to redefine this macro to specify whether the fluid particles (imove != 1) or the solid particles (imove != 2) are used

Note
Redefining this macro this OpenCL script can be recicled
Remarks
The Shepard renormalization factor is ever computed at the boundary elements and sensors (imove <= 0)

◆ M_ITERS [1/4]

#define M_ITERS   10

Number of iterations to complete the mass transfer.

When a particle is split or coalesced, its mass is not inmediately removed, but a smooth transition is carried out

◆ M_ITERS [2/4]

#define M_ITERS   10

Number of iterations to complete the mass transfer.

When a particle is split or coalesced, its mass is not inmediately removed, but a smooth transition is carried out

◆ M_ITERS [3/4]

#define M_ITERS   10

Number of iterations to complete the mass transfer.

When a particle is split or coalesced, its mass is not inmediately removed, but a smooth transition is carried out

◆ M_ITERS [4/4]

#define M_ITERS   10

◆ N_DAUGHTER

#define N_DAUGHTER   4

◆ TSCHEME_ADAMS_BASHFORTH_STEPS

#define TSCHEME_ADAMS_BASHFORTH_STEPS   5u

Function Documentation

◆ check_split()

__kernel void check_split ( __global const int * imove,
__global const float * m,
__global const int * miter,
__global const unsigned int * ilevel,
__global const unsigned int * level,
__global unsigned int * isplit,
usize N )

Check and store wether a particle should become split or not.

A particle should be split if the target refinement level is bigger than its current one, and it is not already spliting/coalescing.

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid/solid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
mCurrent mass \( m \).
miterMass transfer iteration (Positive for growing particles, negative for shrinking particles).
ilevelCurrent refinement level of the particle.
levelTarget refinement level of the particle.
isplit0 if the particle should not become split, 1 otherwise
NNumber of particles.

◆ children()

__kernel void children ( __global const int * imove,
__global const unsigned int * iset,
__global const vec * r,
__global const unsigned int * ilevel,
__global unsigned int * isplit,
__global int * miter,
__constant float * dr_level0,
usize N,
LINKLIST_LOCAL_PARAMS  )

Look for all children, close enough to the seed.

When a particle is not already splitting or coalescing, and is close enough to one or more seeds (which should has the same refinement level and belongs to the same particles set), then it is marked as coalescing child.

Hence, since a particle may be close enough to several partner particles, later we should compute contribution weights.

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid/solid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
isetSet of particles index.
rPosition \( \mathbf{r} \).
ilevelCurrent refinement level of the particle.
isplit0 if the particle should not become coalesced, 1 for the coalescing particles, 2 for the seeds.
miterMass transfer iteration (Positive for growing particles, negative for shrinking particles).
icellCell where each particle is located.
ihocHead of chain for each cell (first particle found).
dr_level0Theoretical distance between particles at the lowest refinement level.
NNumber of particles.
n_cellsNumber of cells in each direction

◆ corrector() [1/4]

__kernel void corrector ( __global int * imove,
__global unsigned int * iset,
__global vec * r,
__global vec * u,
__global vec * dudt,
__global float * rho,
__global float * drhodt,
__global vec * dudt_as1,
__global float * drhodt_as1,
__global vec * dudt_as2,
__global float * drhodt_as2,
__global vec * dudt_as3,
__global float * drhodt_as3,
__global vec * dudt_as4,
__global float * drhodt_as4,
usize N,
float dt,
unsigned int iter )

Improved Euler time integration scheme corrector stage.

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
isetSet of particles index.
rPosition \( \mathbf{r}_{n+1/2} \).
uVelocity \( \mathbf{u}_{n+1/2} \).
dudtVelocity rate of change \( \left. \frac{d \mathbf{u}}{d t} \right\vert_{n+1/2} \).
rhoDensity \( \rho_{n+1/2} \).
drhodtDensity rate of change \( \left. \frac{d \rho}{d t} \right\vert_{n+1/2} \).
dudt_as1Velocity rate of change of previous step \( \left. \frac{d \mathbf{u}}{d t} \right\vert_{n-1/2} \).
drhodt_as1Density rate of change of previous step \( \left. \frac{d \rho}{d t} \right\vert_{n-1/2} \).
NNumber of particles.
dtTime step \( \Delta t \).
iterCurrent iteration.

◆ corrector() [2/4]

__kernel void corrector ( __global int * imove,
__global unsigned int * iset,
__global vec * r,
__global vec * u,
__global vec * dudt,
__global float * rho,
__global float * drhodt,
__global vec * dudt_in,
__global float * drhodt_in,
usize N,
float dt )

Improved Euler time integration scheme corrector stage.

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
isetSet of particles index.
rPosition \( \mathbf{r}_{n+1/2} \).
uVelocity \( \mathbf{u}_{n+1/2} \).
dudtVelocity rate of change \( \left. \frac{d \mathbf{u}}{d t} \right\vert_{n+1/2} \).
rhoDensity \( \rho_{n+1/2} \).
drhodtDensity rate of change \( \left. \frac{d \rho}{d t} \right\vert_{n+1/2} \).
dudt_inVelocity rate of change \( \left. \frac{d \mathbf{u}}{d t} \right\vert_{n-1/2} \).
drhodt_inDensity rate of change \( \left. \frac{d \rho}{d t} \right\vert_{n-1/2} \).
NNumber of particles.
dtTime step \( \Delta t \).

◆ corrector() [3/4]

__kernel void corrector ( __global int * imove,
__global unsigned int * iset,
__global vec * r,
__global vec * u,
__global vec * dudt,
__global float * rho,
__global float * drhodt,
usize N,
float dt )

1st orderv Euler time integration scheme corrector stage

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
isetSet of particles index.
rPosition \( \mathbf{r}_{n+1/2} \).
uVelocity \( \mathbf{u}_{n+1/2} \).
dudtVelocity rate of change \( \left. \frac{d \mathbf{u}}{d t} \right\vert_{n+1/2} \).
rhoDensity \( \rho_{n+1/2} \).
drhodtDensity rate of change \( \left. \frac{d \rho}{d t} \right\vert_{n+1/2} \).
NNumber of particles.
dtTime step \( \Delta t \).

◆ corrector() [4/4]

__kernel void corrector ( const __global int * imove,
const __global vec * r_in,
__global vec * r,
const __global vec * u_in,
__global vec * u,
const __global vec * dudt,
const __global float * rho_in,
__global float * rho,
const __global float * drhodt,
usize N,
float dt )

1st order Semi-implicit Euler time integration scheme corrector stage

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
r_inPosition \( \mathbf{r}_{n} \).
rPosition \( \mathbf{r}_{n+1} \).
u_inVelocity \( \mathbf{u}_{n} \).
uVelocity \( \mathbf{u}_{n+1} \).
dudtVelocity rate of change \( \left. \frac{d \mathbf{u}}{d t} \right\vert_{n+1/2} \).
rho_inDensity \( \rho_{n} \).
rhoDensity \( \rho_{n+1} \).
drhodtDensity rate of change \( \left. \frac{d \rho}{d t} \right\vert_{n+1/2} \).
NNumber of particles.
dtTime step \( \Delta t \).

◆ count()

__kernel void count ( __global const int * imove,
__global unsigned int * ibuffer,
usize N )

Identify the buffer particles.

The buffer particles are signaled with an imove=-255 flag.

Parameters
imoveMoving flags (imove = -255 for buffer particles).
ibuffer0 if the particle is not a buffer particle, 1 otherwise.
NNumber of particles.

◆ deltaSPH()

__kernel void deltaSPH ( const __global unsigned int * iset,
const __global int * imove,
const __global float * rho,
const __global float * lap_p,
__global float * drhodt,
__constant float * refd,
__constant float * delta,
usize N,
float dt )

Density variation rates delta-SPH term.

Parameters
isetSet of particles index.
imoveMoving flags.
  • imove = 2 for regular solid particles.
  • imove = 0 for sensors (ignored by this preset).
  • imove < 0 for boundary elements/particles.
rhoDensity \( \rho_{n+1} \).
lap_pPressure laplacian \( \Delta p \).
drhodtDensity rate of change \( \frac{d \rho}{d t} \).
refdDensity of reference of the fluid \( \rho_0 \).
deltaDiffusive term \( \delta \) multiplier.
NNumber of particles.
dtTime step \( \Delta t \).

◆ entry() [1/17]

__kernel void entry ( __global const int * imove,
__global const unsigned int * ilevel,
__global const vec * r,
__global unsigned int * level,
usize N,
vec multiresolution_cube_min,
vec multiresolution_cube_max,
unsigned int multiresolution_cube_level )

Set the refinement level of the particles inside.

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid/solid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
ilevelCurrent refinement level of the particle.
rPosition \( \mathbf{r} \).
levelTarget refinement level of the particle.
NNumber of particles.
multiresolution_cube_minMinimum point of the refinement area.
multiresolution_cube_maxMaximum point of the refinement area.
multiresolution_cube_levelRefinement level inside the area.

◆ entry() [2/17]

__kernel void entry ( __global const int * imove,
__global const unsigned int * ilevel,
__global const vec * r,
__global unsigned int * level,
usize N,
vec multiresolution_sphere_center,
float multiresolution_sphere_radius,
unsigned int multiresolution_sphere_level )

Set the refinement level of the particles inside.

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid/solid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
ilevelCurrent refinement level of the particle.
rPosition \( \mathbf{r} \).
levelTarget refinement level of the particle.
NNumber of particles.
multiresolution_sphere_centerCenter of the refinement area.
multiresolution_sphere_radiusRadius of the refinement area.
multiresolution_sphere_levelRefinement level inside the area.

◆ entry() [3/17]

__kernel void entry ( __global float * rho_in,
usize N,
float rho_min,
float rho_max )

Clamp the density.

In some situations it can be convenient to define a minimum or maximum density values in order to avoid that a crazy particle may cause the simulation blow up. Use this tool only if you know exactly what you are doing

Parameters
rho_inDensity \( \rho_{n+1/2} \).
NNumber of particles.
rho_minMinimum tolerated density value \( \rho_{min} \).
rho_maxMaximum tolerated density value \( \rho_{max} \).

◆ entry() [4/17]

__kernel void entry ( __global int * imove,
__global const int * miter,
__global vec * r,
vec domain_max,
usize N )

Set the mass of the particles according to their gamma value.

When a particle is split in a set of daughter particles, in order to avoid shocks, its effect is smoothly transfered to the daughters, using for that a \( \gamma_m \) mass multiplier.

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid/solid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
miterMass transfer iteration (Positive for growing particles, negative for shrinking particles).
rPosition \( \mathbf{r} \).
domain_maxMaximum point of the computational domain.
NNumber of particles.

◆ entry() [5/17]

__kernel void entry ( __global int * imove,
__global vec * r_in,
__global vec * u_in,
__global vec * dudt_in,
__global float * m,
usize N,
vec domain_min,
vec domain_max )

Check and destroy the particles out of the domain.

Usually is a good methodology to impose a computational domain, such that a single lost particle will not cause the simulation blow up. Since the particles out of the domain will take 0 mass, you can control how many particles are lost controlling the total mass

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid/solid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
r_inPosition \( \mathbf{r} \).
u_inVelocity \( \mathbf{u} \).
dudt_inVelocity rate of change \( \frac{d \mathbf{u}}{d t} \).
mMass \( m \).
NNumber of particles.
domain_minMinimum point of the domain.
domain_maxMaximum point of the domain.

◆ entry() [6/17]

__kernel void entry ( __global unsigned int * iset,
__global int * imove,
__global float * rho,
__global float * p,
__constant float * refd,
usize N,
float cs,
float p0 )

Stiff Equation Of State (EOS) computation.

The equation of state relates the pressure and the density fields, \( p = p_0 + c_s^2 \left(\rho - \rho_0 \right) \)

Parameters
isetSet of particles index.
imoveMoving flags.
  • imove > 0 for regular fluid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
rhoDensity \( \rho_{n+1/2} \).
pPressure \( p_{n+1/2} \).
refdDensity of reference of the fluid \( \rho_0 \).
NNumber of particles.
csSpeed of sound \( c_s \).
p0Background pressure \( p_0 \).

◆ entry() [7/17]

__kernel void entry ( __global usize * id,
__global usize * id_inverse,
usize N )

Compute the permutations to move from the sorted indexes space to the unsorted one.

Parameters
idOriginal index of each particle (sort -> unsort space)
id_inverseSorted index of each particle (unsort -> sort space)
NNumber of particles.

◆ entry() [8/17]

__kernel void entry ( const __global float * h_var_in,
__global float * h_var,
const __global usize * id_sorted,
usize N )

Sort all the particle variables by the cell indexes.

Due to the large number of registers consumed (21 global memory arrays are loaded), it is safer carrying out the sorting process in to stages. This is the first stage.

Parameters
h_var_inUnsorted variable kernel lenght \( h \).
h_varSorted variable kernel lenght \( h \).
id_sortedPermutations list from the unsorted space to the sorted one.
NNumber of particles.

◆ entry() [9/17]

__kernel void entry ( const __global float * m0_in,
__global float * m0,
const __global int * miter_in,
__global int * miter,
const __global uint * ilevel_in,
__global uint * ilevel,
const __global uint * level_in,
__global uint * level,
const __global usize * id_sorted,
usize N )

Sort the multiresolution involved particle properties.

Parameters
m0_inUnsorted original mass \( m_0 \).
m0Sorted original mass \( m_0 \).
miter_inUnsorted iteration of the mass transfer.
miterMass transfer iteration (Positive for shrinking particles, negative for growing particles).
ilevel_inUnsorted particle refinement level.
ilevelSorted particle refinement level.
level_inUnsorted target refinement level.
levelSorted target refinement level.
id_sortedPermutations list from the unsorted space to the sorted one.
NNumber of particles.

◆ entry() [10/17]

__kernel void entry ( const __global int * imove,
__global uint * n_neighs,
uint neighs_limit,
usize N,
LINKLIST_LOCAL_PARAMS  )

Number of neighbours of each particle.

One of the main targets of this kernel is checking that the number of neighbours is not excessively large. Along this line, if #neighs_limit neighbours are reached, the kernel will stop the execution.

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
rPosition \( \mathbf{r} \).
n_neighsNumber of neighbours per particle.
icellCell where each particle is located.
ihocHead of chain for each cell (first particle found).
neighs_limitThe largest number of neighbours accepted.
NNumber of particles.
n_cellsNumber of cells in each direction

◆ entry() [11/17]

__kernel void entry ( const __global int * imove,
const __global int * imirrored,
const __global vec * r,
const __global float * rho,
const __global float * m,
__global float * shepard,
usize N,
LINKLIST_LOCAL_PARAMS  )

Shepard factor computation, due to the particles at the other portal side.

\[ \gamma(\mathbf{x}) = \int_{\Omega} W(\mathbf{y} - \mathbf{x}) \mathrm{d}\mathbf{x} \]

The shepard renormalization factor is applied for several purposes:

  • To interpolate values
  • To recover the consistency with the Boundary Integrals formulation
  • Debugging

In the shepard factor computation the fluid extension particles are not taken into account.

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
imirrored0 if the particle has not been mirrored, 1 otherwise.
rPosition \( \mathbf{r} \).
rhoDensity \( \rho \).
mMass \( m \).
shepardShepard term \( \gamma(\mathbf{x}) = \int_{\Omega} W(\mathbf{y} - \mathbf{x}) \mathrm{d}\mathbf{x} \).
icellCell where each particle is located.
ihocHead of chain for each cell (first particle found).
NNumber of particles.
n_cellsNumber of cells in each direction
Here is the call graph for this function:

◆ entry() [12/17]

__kernel void entry ( const __global int * imove,
const __global int * imirrored,
const __global vec * r,
const __global float * rho,
const __global float * m,
__global matrix * mls,
usize N,
uint mls_imove,
LINKLIST_LOCAL_PARAMS  )

Compute the MLS transformation matrix inverse, \( L_i^{-1} \), due to the particles at the other portal side.

Such transformation matrix can be multiplied by the kernel gradient to produce a new kernel gradient, \( \nabla W^{L}_{ij} = L_i \cdot \nabla W_{ij} \), such that the lienar fields differential operators are consistently computed.

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
imirrored0 if the particle has not been mirrored, 1 otherwise.
rPosition \( \mathbf{r} \).
rhoDensity \( \rho \).
mMass \( m \).
mlsKernel MLS transformation matrix \( L \).
icellCell where each particle is located.
ihocHead of chain for each cell (first particle found).
NNumber of particles.
n_cellsNumber of cells in each direction
mls_imoveType of particles affected
Note
The MLS kernel transformation will be computed just for the particles with the moving flag mls_imove, and using just the information of the particles with the moving flag mls_imove
Here is the call graph for this function:

◆ entry() [13/17]

__kernel void entry ( const __global int * imove,
const __global int * imirrored,
const __global vec * r,
const __global float * rho,
const __global float * m,
const __global float * h_var,
__global float * shepard,
usize N,
LINKLIST_LOCAL_PARAMS  )

Shepard factor computation, due to the particles at the other portal side.

\[ \gamma(\mathbf{x}) = \int_{\Omega} W(\mathbf{y} - \mathbf{x}) \mathrm{d}\mathbf{x} \]

The shepard renormalization factor is applied for several purposes:

  • To interpolate values
  • To recover the consistency with the Boundary Integrals formulation
  • Debugging

In the shepard factor computation the fluid extension particles are not taken into account.

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
imirrored0 if the particle has not been mirrored, 1 otherwise.
rPosition \( \mathbf{r} \).
rhoDensity \( \rho \).
mMass \( m \).
h_varvariable kernel lenght \( h \).
shepardShepard term \( \gamma(\mathbf{x}) = \int_{\Omega} W(\mathbf{y} - \mathbf{x}) \mathrm{d}\mathbf{x} \).
icellCell where each particle is located.
ihocHead of chain for each cell (first particle found).
NNumber of particles.
n_cellsNumber of cells in each direction
Here is the call graph for this function:

◆ entry() [14/17]

__kernel void entry ( const __global int * imove,
const __global vec * r,
const __global float * rho,
const __global float * m,
__global float * shepard,
usize N,
LINKLIST_LOCAL_PARAMS  )

Shepard factor computation.

\[ \gamma(\mathbf{x}) = \int_{\Omega} W(\mathbf{y} - \mathbf{x}) \mathrm{d}\mathbf{y} \]

The shepard renormalization factor is applied for several purposes:

  • To interpolate values
  • To recover the consistency with the Boundary Integrals formulation
  • Debugging

In the shepard factor computation the fluid extension particles are not taken into account.

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
rPosition \( \mathbf{r} \).
rhoDensity \( \rho \).
mMass \( m \).
shepardShepard term \( \gamma(\mathbf{x}) = \int_{\Omega} W(\mathbf{y} - \mathbf{x}) \mathrm{d}\mathbf{y} \).
icellCell where each particle is located.
ihocHead of chain for each cell (first particle found).
NNumber of particles.
n_cellsNumber of cells in each direction
Here is the call graph for this function:

◆ entry() [15/17]

__kernel void entry ( const __global int * imove,
const __global vec * r,
const __global float * rho,
const __global float * m,
__global matrix * mls,
usize N,
uint mls_imove,
LINKLIST_LOCAL_PARAMS  )

Compute the MLS transformation matrix inverse, \( L_i^{-1} \).

Such transformation matrix can be multiplied by the kernel gradient to produce a new kernel gradient, \( \nabla W^{L}_{ij} = L_i \cdot \nabla W_{ij} \), such that the lienar fields differential operators are consistently computed.

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid/solid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
rPosition \( \mathbf{r}_{n+1} \).
rhoDensity \( \rho \).
mMass \( m \).
mlsKernel MLS transformation matrix \( L \).
icellCell where each particle is located.
ihocHead of chain for each cell (first particle found).
NNumber of particles.
n_cellsNumber of cells in each direction
mls_imoveType of particles affected
Note
The MLS kernel transformation will be computed just for the particles with the moving flag mls_imove, and using just the information of the particles with the moving flag mls_imove
Here is the call graph for this function:

◆ entry() [16/17]

__kernel void entry ( const __global int * imove,
const __global vec * r,
const __global float * rho,
const __global float * m,
const __global float * h_var,
__global float * shepard,
usize N,
LINKLIST_LOCAL_PARAMS  )

Shepard factor computation.

\[ \gamma(\mathbf{x}) = \int_{\Omega} W(\mathbf{y} - \mathbf{x}) \mathrm{d}\mathbf{x} \]

The shepard renormalization factor is applied for several purposes:

  • To interpolate values
  • To recover the consistency with the Boundary Integrals formulation
  • Debugging

In the shepard factor computation the fluid extension particles are not taken into account.

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
rPosition \( \mathbf{r} \).
rhoDensity \( \rho \).
mMass \( m \).
h_varvariable kernel lenght \( h \).
shepardShepard term \( \gamma(\mathbf{x}) = \int_{\Omega} W(\mathbf{y} - \mathbf{x}) \mathrm{d}\mathbf{x} \).
icellCell where each particle is located.
ihocHead of chain for each cell (first particle found).
NNumber of particles.
n_cellsNumber of cells in each direction
Here is the call graph for this function:

◆ entry() [17/17]

__kernel void entry ( const __global vec * normal,
__global vec * tangent,
__global vec * binormal,
usize N )

Compute the tanget vector in 2D simulations, and the binormal vector in 3D simulations.

Parameters
normalNormal vector \( \mathbf{n} \).
tangentTangent vector \( \mathbf{t} \).
binormalBinormal vector \( \mathbf{t} \).
NNumber of particles.

◆ fields()

__kernel void fields ( __global const unsigned int * iset,
__global const uint * isplit,
__global const usize * mybuffer,
__global const unsigned int * ilevel,
__global const float * split_weight,
__global float * m0,
__global float * m,
__global vec * r,
__global vec * u,
__global vec * dudt,
__global float * rho,
__global float * drhodt,
__constant float * dr_level0,
usize N,
LINKLIST_LOCAL_PARAMS  )

Collect the children, and the seed itself, in order to compute the field values of the buffer partner particle.

Since each children may contribute to several partners, we are weighting their field values.

Parameters
isplit0 if the particle should not become coalesced, 1 for the coalescing particles, 2 for the seeds.
split_weightCoalescing contribution weight.
m0Target mass, \( m_0 \).
mCurrent mass, \( m \).
rPosition \( \mathbf{r} \).
uVelocity \( \mathbf{u} \).
dudtVelocity rate of change \( \frac{d \mathbf{u}}{d t} \).
rhoDensity \( \rho \).
drhodtDensity rate of change \( \frac{d \rho}{d t} \).
icellCell where each particle is located.
ihocHead of chain for each cell (first particle found).
NNumber of particles.
n_cellsNumber of cells in each direction

◆ full()

__kernel void full ( const __global int * imove,
const __global vec * r,
const __global float * rho,
const __global float * m,
const __global float * p,
__global vec * lap_p_corr,
usize N,
LINKLIST_LOCAL_PARAMS  )

MLS based correction term.

The term computed with this function should be later renormalized by MLS, using full_mls() function. Before calling such function the user must be sure that both lap_p_corr and mls have been computed (taking into account, for instance, the BCs)

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
rPosition \( \mathbf{r} \).
rhoDensity \( \rho \).
mMass \( m \).
pPressure \( p \).
lap_p_corrCorrection term for the Morris Laplacian formula.
icellCell where each particle is located.
ihocHead of chain for each cell (first particle found).
NNumber of particles.
n_cellsNumber of cells in each direction
Here is the call graph for this function:

◆ full_mls()

__kernel void full_mls ( const __global int * imove,
const __global matrix * mls,
__global vec * lap_p_corr,
usize N )

MLS based correction term.

Here the MLS renormalization is applied to the correction term

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
rPosition \( \mathbf{r} \).
mlsKernel MLS transformation matrix \( L \).
lap_p_corrCorrection term for the Morris Laplacian formula.
NNumber of particles.

◆ generate() [1/2]

__kernel void generate ( __global int * imove,
__global int * iset,
__global const unsigned int * isplit,
__global usize * split_invperm,
__global unsigned int * ilevel,
__global unsigned int * level,
__global int * miter,
__global usize * mybuffer,
usize N,
usize nbuffer )

Associate a buffer particle to a seed.

Later we are looking for the rest of children, used to compute the variable values of this buffer/partner particle

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid/solid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
isetIndex of the set of particles.
isplit0 if the particle should not become coalesced, 1 for the coalescing particles, 2 for the seeds.
split_invpermPermutation to find the index of the particle in the list of particles to become split.
mybufferIndex of the partner buffer particle.
ilevelCurrent refinement level of the particle.
levelTarget refinement level of the particle.
miterMass transfer iteration (Positive for growing particles, negative for shrinking particles).
mybufferPartner particle associated to the seed
NNumber of particles.
nbufferNumber of available buffer particles.

◆ generate() [2/2]

__kernel void generate ( __global int * imove,
__global int * iset,
__global unsigned int * isplit,
__global usize * split_invperm,
__global unsigned int * ilevel,
__global unsigned int * level,
__global float * m0,
__global int * miter,
__global float * m,
__global vec * r,
__global vec * u,
__global vec * dudt,
__global float * rho,
__global float * drhodt,
usize N,
usize nbuffer )

Split a particle in a set of daughter particles.

The daughter particles will be a duplicate of the mother split particle, but conveniently modifying the position and the mass (m0 and gamma_m).

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid/solid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
isetIndex of the set of particles.
isplit0 if the particle should not become split, 1 otherwise.
split_invpermPermutation to find the index of the particle in the list of particles to become split.
ilevelCurrent refinement level of the particle.
levelTarget refinement level of the particle.
m0Target mass, \( m_0 \).
miterMass transfer iteration (Positive for growing particles, negative for shrinking particles).
mCurrent mass, \( m \).
rPosition \( \mathbf{r} \).
uVelocity \( \mathbf{u} \).
dudtVelocity rate of change \( \frac{d \mathbf{u}}{d t} \).
rhoDensity \( \rho \).
drhodtDensity rate of change \( \frac{d \rho}{d t} \).
NNumber of particles.
nbufferNumber of available buffer particles.

◆ lapp() [1/2]

__kernel void lapp ( const __global int * imove,
const __global vec * r,
const __global float * rho,
const __global float * m,
const __global float * p,
__global float * lap_p,
usize N,
LINKLIST_LOCAL_PARAMS  )

Laplacian of the pressure computation.

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
rPosition \( \mathbf{r} \).
rhoDensity \( \rho \).
mMass \( m \).
pPressure \( p \).
lap_pPressure laplacian \( \Delta p \).
icellCell where each particle is located.
ihocHead of chain for each cell (first particle found).
NNumber of particles.
n_cellsNumber of cells in each direction
Here is the call graph for this function:

◆ lapp() [2/2]

__kernel void lapp ( const __global int * imove,
const __global vec * r,
const __global float * rho,
const __global float * m,
const __global float * p,
const __global float * h_var,
__global float * lap_p,
usize N,
LINKLIST_LOCAL_PARAMS  )

Laplacian of the pressure computation.

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
rPosition \( \mathbf{r} \).
rhoDensity \( \rho \).
mMass \( m \).
pPressure \( p \).
h_varvariable kernel lenght \( h \).
lap_pPressure laplacian \( \Delta p \).
icellCell where each particle is located.
ihocHead of chain for each cell (first particle found).
NNumber of particles.
n_cellsNumber of cells in each direction
Here is the call graph for this function:

◆ lapp_corr()

__kernel void lapp_corr ( const __global int * imove,
const __global vec * r,
const __global float * rho,
const __global float * m,
const __global vec * lap_p_corr,
__global float * lap_p,
usize N,
LINKLIST_LOCAL_PARAMS  )

Laplacian of the pressure correction.

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
rPosition \( \mathbf{r} \).
rhoDensity \( \rho \).
mMass \( m \).
pPressure \( p \).
lap_p_corrCorrection term for the Morris Laplacian formula.
lap_pPressure laplacian \( \Delta p \).
icellCell where each particle is located.
ihocHead of chain for each cell (first particle found).
NNumber of particles.
n_cellsNumber of cells in each direction
Here is the call graph for this function:

◆ midpoint()

__kernel void midpoint ( const __global int * imove,
const __global vec * u_in,
__global vec * u,
const __global vec * dudt,
const __global float * rho_in,
__global float * rho,
const __global float * drhodt,
usize N,
float dt )

Advance to the time step midpoint.

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
u_inVelocity \( \mathbf{u}_{n} \).
uVelocity \( \mathbf{u}_{n+1/2} \).
dudtVelocity rate of change \( \left. \frac{d \mathbf{u}}{d t} \right\vert_{n+1/2} \).
rho_inDensity \( \rho_{n} \).
rhoDensity \( \rho_{n+1/2} \).
drhodtDensity rate of change \( \left. \frac{d \rho}{d t} \right\vert_{n+1/2} \).
NNumber of particles.
dtTime step \( \Delta t \).

◆ midpoint_r()

__kernel void midpoint_r ( const __global int * imove,
const __global vec * r_in,
__global vec * r,
const __global vec * u,
usize N,
float dt )

Advance the position to the time step midpoint.

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
r_inPosition \( \mathbf{r}_{n} \).
rPosition \( \mathbf{r}_{n+1/2} \).
uVelocity \( \mathbf{u}_{n+1/2} \).
NNumber of particles.
dtTime step \( \Delta t \).

◆ mls_inv()

__kernel void mls_inv ( const __global int * imove,
__global matrix * mls,
usize N,
uint mls_imove )

Invert the matrix computed in entry() to get the final MLS transformation matrix, \( L_i \).

Such transformation matrix can be multiplied by the kernel gradient to produce a new kernel gradient, \( \nabla W^{L}_{ij} = L_i \cdot \nabla W_{ij} \), such that the lienar fields differential operators are consistently computed.

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid/solid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
mlsKernel MLS transformation matrix \( L \).
NNumber of particles.
mls_imoveType of particles affected

◆ postcorrector()

__kernel void postcorrector ( const __global vec * dudt_as1,
const __global float * drhodt_as1,
const __global vec * dudt_as2,
const __global float * drhodt_as2,
const __global vec * dudt_as3,
const __global float * drhodt_as3,
const __global vec * dudt,
const __global float * drhodt,
__global vec * dudt_as1_in,
__global float * drhodt_as1_in,
__global vec * dudt_as2_in,
__global float * drhodt_as2_in,
__global vec * dudt_as3_in,
__global float * drhodt_as3_in,
__global vec * dudt_as4_in,
__global float * drhodt_as4_in,
usize N )

Backup de data for the sorting algorithm.

Parameters
dudt_as1Velocity rate of change of previous step \( \left. \frac{d \mathbf{u}}{d t} \right\vert_{n-1/2} \).
drhodt_as1Density rate of change of previous step \( \left. \frac{d \rho}{d t} \right\vert_{n-1/2} \).
dudt_as2Velocity rate of change of 2 steps ago \( \left. \frac{d \mathbf{u}}{d t} \right\vert_{n-1/2} \).
drhodt_as2Density rate of change of 2 steps ago \( \left. \frac{d \rho}{d t} \right\vert_{n-1/2} \).
dudt_as3Velocity rate of change of 3 steps ago \( \left. \frac{d \mathbf{u}}{d t} \right\vert_{n-1/2} \).
drhodt_as3Density rate of change of 3 steps ago \( \left. \frac{d \rho}{d t} \right\vert_{n-1/2} \).
dudtVelocity rate of change \( \left. \frac{d \mathbf{u}}{d t} \right\vert_{n+1/2} \).
drhodtDensity rate of change \( \left. \frac{d \rho}{d t} \right\vert_{n+1/2} \).
dudt_as1_inVelocity rate of change of previous step \( \left. \frac{d \mathbf{u}}{d t} \right\vert_{n-1/2} \).
drhodt_as1_inDensity rate of change of previous step \( \left. \frac{d \rho}{d t} \right\vert_{n-1/2} \).
dudt_as2_inVelocity rate of change of 2 steps ago \( \left. \frac{d \mathbf{u}}{d t} \right\vert_{n-1/2} \).
drhodt_as2_inDensity rate of change of 2 steps ago \( \left. \frac{d \rho}{d t} \right\vert_{n-1/2} \).
dudt_as3_inVelocity rate of change of 3 steps ago \( \left. \frac{d \mathbf{u}}{d t} \right\vert_{n-1/2} \).
drhodt_as3_inDensity rate of change of 3 steps ago \( \left. \frac{d \rho}{d t} \right\vert_{n-1/2} \).
dudt_as4_inVelocity rate of change of 4 steps ago \( \left. \frac{d \mathbf{u}}{d t} \right\vert_{n-1/2} \).
drhodt_as4_inDensity rate of change of 4 steps ago \( \left. \frac{d \rho}{d t} \right\vert_{n-1/2} \).
NNumber of particles.

◆ predictor() [1/3]

__kernel void predictor ( __global int * imove,
__global vec * r,
__global vec * u,
__global vec * dudt,
__global float * rho,
__global float * drhodt,
__global vec * r_in,
__global vec * u_in,
__global vec * dudt_in,
__global float * rho_in,
__global float * drhodt_in,
usize N,
float dt )

Improved Euler time integration scheme predictor stage.

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid/solid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
rPosition \( \mathbf{r}_{n+1} \).
uVelocity \( \mathbf{u}_{n+1} \).
dudtVelocity rate of change \( \left. \frac{d \mathbf{u}}{d t} \right\vert_{n+1} \).
rhoDensity \( \rho_{n+1} \).
drhodtDensity rate of change \( \left. \frac{d \rho}{d t} \right\vert_{n+1} \).
r_inPosition \( \mathbf{r}_{n+1/2} \).
u_inVelocity \( \mathbf{u}_{n+1/2} \).
dudt_inVelocity rate of change \( \left. \frac{d \mathbf{u}}{d t} \right\vert_{n+1/2} \).
rho_inDensity \( \rho_{n+1/2} \).
drhodt_inDensity rate of change \( \left. \frac{d \rho}{d t} \right\vert_{n+1/2} \).
NNumber of particles.
dtTime step \( \Delta t \).

◆ predictor() [2/3]

__kernel void predictor ( __global vec * r,
__global vec * u,
__global vec * dudt,
__global float * rho,
__global float * drhodt,
__global vec * r_in,
__global vec * u_in,
__global vec * dudt_in,
__global float * rho_in,
__global float * drhodt_in,
usize N )

Adams-Bashforth time integration scheme predictor stage.

1st order Euler time integration scheme predictor stage

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid/solid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
rPosition \( \mathbf{r}_{n+1} \).
uVelocity \( \mathbf{u}_{n+1} \).
dudtVelocity rate of change \( \left. \frac{d \mathbf{u}}{d t} \right\vert_{n+1} \).
rhoDensity \( \rho_{n+1} \).
drhodtDensity rate of change \( \left. \frac{d \rho}{d t} \right\vert_{n+1} \).
r_inPosition \( \mathbf{r}_{n+1/2} \).
u_inVelocity \( \mathbf{u}_{n+1/2} \).
dudt_inVelocity rate of change \( \left. \frac{d \mathbf{u}}{d t} \right\vert_{n+1/2} \).
rho_inDensity \( \rho_{n+1/2} \).
drhodt_inDensity rate of change \( \left. \frac{d \rho}{d t} \right\vert_{n+1/2} \).
NNumber of particles.

◆ predictor() [3/3]

__kernel void predictor ( const __global vec * r,
const __global vec * u,
const __global vec * dudt,
const __global float * rho,
const __global float * drhodt,
__global vec * r_in,
__global vec * u_in,
__global vec * dudt_in,
__global float * rho_in,
__global float * drhodt_in,
usize N )

Semi-implicit Midpoint Euler time integration scheme predictor stage.

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid/solid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
rPosition \( \mathbf{r}_{n+1} \).
uVelocity \( \mathbf{u}_{n+1} \).
dudtVelocity rate of change \( \left. \frac{d \mathbf{u}}{d t} \right\vert_{n+1} \).
rhoDensity \( \rho_{n+1} \).
drhodtDensity rate of change \( \left. \frac{d \rho}{d t} \right\vert_{n+1} \).
r_inPosition \( \mathbf{r}_{n+1/2} \).
u_inVelocity \( \mathbf{u}_{n+1/2} \).
dudt_inVelocity rate of change \( \left. \frac{d \mathbf{u}}{d t} \right\vert_{n+1/2} \).
rho_inDensity \( \rho_{n+1/2} \).
drhodt_inDensity rate of change \( \left. \frac{d \rho}{d t} \right\vert_{n+1/2} \).
NNumber of particles.

◆ relax()

__kernel void relax ( const __global int * imove,
__global vec * dudt_in,
__global vec * dudt,
__global float * drhodt_in,
__global float * drhodt,
usize N,
float relax_midpoint )

◆ residuals()

__kernel void residuals ( const __global int * imove,
const __global float * m,
const __global vec * u,
const __global vec * dudt_in,
const __global vec * dudt,
const __global float * rho,
const __global float * p,
const __global float * drhodt_in,
const __global float * drhodt,
__global float * residual_midpoint,
usize N )

◆ seed_candidates()

__kernel void seed_candidates ( __global const unsigned int * iset,
__global const int * imove,
__global const unsigned int * ilevel,
__global const unsigned int * level,
__global const float * m0,
__global int * miter,
__global const vec * r,
__global unsigned int * isplit,
__global svec * split_cell,
__global float * split_dist,
__constant float * dr_level0,
usize N )

Look for all the seed candidates, i.e. all the particles which have a refinement level target lower than their current value.

This tool is also placing the particles into cells with the volume of the partner particle to become generated

Parameters
isetSet of particles index.
imoveMoving flags.
  • imove > 0 for regular fluid/solid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
ilevelCurrent refinement level of the particle.
levelTarget refinement level of the particle.
m0Mass \( m_0 \).
miterMass transfer iteration (Positive for growing particles, negative for shrinking particles).
rPosition \( \mathbf{r} \).
isplit0 if the particle should not become coalesced, 1 for the coalescing particles, 2 for the seeds.
split_cellSeed cell where the particle is located.
split_distDistance to the center of the cell. Just the closest particle to the cell center will be kept as seed
dr_level0Theoretical distance between particles at the lowest refinement level.
NNumber of particles.

◆ seeds()

__kernel void seeds ( __global const unsigned int * iset,
__global const unsigned int * isplit_in,
__global unsigned int * isplit,
__global int * miter,
__global const svec * split_cell,
__global const float * split_dist,
usize N,
LINKLIST_LOCAL_PARAMS  )

Get only one seed per cell.

To do that, all the seed candidates will inspect their neighbours, and in case they find another seed candidate closer to the cell center, they are desisting to become a seed.

Parameters
isetSet of particles index.
isplit_in0 if the particle should not become coalesced, 1 for the coalescing particles, 2 for the seeds. This array is used to read.
isplit0 if the particle should not become coalesced, 1 for the coalescing particles, 2 for the seeds. This array is used to write.
miterMass transfer iteration (Positive for growing particles, negative for shrinking particles).
split_cellSeed cell where the particle is located.
split_distDistance to the center of the cell. Just the closest particle to the cell center will be kept as seed
icellCell where each particle is located.
ihocHead of chain for each cell (first particle found).
NNumber of particles.
n_cellsNumber of cells in each direction

◆ set_imove()

__kernel void set_imove ( __global int * imove,
usize N )

Replace the particles with the imove flag imove=-256 by imove=-255.

The particles with imove=-256 are "invalid particles", i.e. particles which has been removed (e.g. particles out of the computational domain), while imove=-255 are buffer particles.

In that way, the removed particles in a time step are not taken into account as buffer particles until they are sorted at the next time step.

Parameters
imoveMoving flags (imove = -255 for buffer particles).
ibuffer0 if the particle is not a buffer particle, 1 otherwise.
NNumber of particles.

◆ set_isplit_in()

__kernel void set_isplit_in ( __global const unsigned int * isplit,
__global unsigned int * isplit_in,
usize N )

Create a copy of isplit, where everything is 0 except the seeds, which take the value 1. Such array can be used to count the number of new particles to become generated.

Create a copy of isplit, where the data "out of bounds" is set to 0, instead of 2. Such array can be used to count the number of new particles to become generated.

Parameters
isplit0 if the particle should not become split, 1 otherwise
isplit_in0 if the particle should not become split, 1 otherwise
NNumber of particles.

◆ set_mass()

__kernel void set_mass ( __global const int * imove,
__global const float * m0,
__global int * miter,
__global float * m,
usize N )

Set the mass of the particles according to their gamma value.

When a particle is split in a set of daughter particles, in order to avoid shocks, its effect is smoothly transfered to the daughters, using for that a \( \gamma_m \) mass multiplier.

Parameters
imoveMoving flags.
  • imove > 0 for regular fluid/solid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
m0Target mass, \( m_0 \). When a particle is split/coalesced, its mass is progressively transfered to its children.
miterMass transfer iteration (Positive for growing particles, negative for shrinking particles).
mCurrent mass \( m \).
NNumber of particles.

◆ simple()

__kernel void simple ( const __global unsigned int * iset,
const __global int * imove,
__global vec * lap_p_corr,
__constant float * refd,
usize N,
vec g )

Simple hidrostatic based correction term.

Parameters
isetSet of particles index.
imoveMoving flags.
  • imove = 2 for regular solid particles.
  • imove = 0 for sensors (ignored by this preset).
  • imove < 0 for boundary elements/particles.
lap_p_corrCorrection term for the Morris Laplacian formula.
refdDensity of reference of the fluid \( \rho_0 \).
NNumber of particles.
gGravity acceleration \( \mathbf{g} \).

◆ sort()

__kernel void sort ( const __global vec * dudt_as1_in,
__global vec * dudt_as1,
const __global vec * dudt_as2_in,
__global vec * dudt_as2,
const __global vec * dudt_as3_in,
__global vec * dudt_as3,
const __global vec * dudt_as4_in,
__global vec * dudt_as4,
const __global float * drhodt_as1_in,
__global float * drhodt_as1,
const __global float * drhodt_as2_in,
__global float * drhodt_as2,
const __global float * drhodt_as3_in,
__global float * drhodt_as3,
const __global float * drhodt_as4_in,
__global float * drhodt_as4,
const __global usize * id_sorted,
usize N )

Sort the stored Adams-Bashforth stored variation rates.

Parameters
id_inUnsorted particle indexes
idSorted particle indexes
iset_inUnsorted set of particles indexes.
isetSorted set of particles indexes.
imove_inUnsorted moving flags.
  • imove > 0 for regular fluid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
imoveSorted moving flags.
  • imove > 0 for regular fluid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
r_inUnsorted position \( \mathbf{r} \).
rSorted position \( \mathbf{r} \).
normal_inUnsorted normal \( \mathbf{n} \).
normalSorted normal \( \mathbf{n} \).
u_inUnsorted velocity \( \mathbf{u} \).
uSorted velocity \( \mathbf{u} \).
id_sortedPermutations list from the unsorted space to the sorted one.
NNumber of particles.

◆ stage1()

__kernel void stage1 ( const __global usize * id_in,
__global usize * id,
const __global uint * iset_in,
__global uint * iset,
const __global int * imove_in,
__global int * imove,
const __global vec * r_in,
__global vec * r,
const __global vec * normal_in,
__global vec * normal,
const __global vec * tangent_in,
__global vec * tangent,
const __global usize * id_sorted,
usize N )

Sort all the particle variables by the cell indexes.

Due to the large number of registers consumed (21 global memory arrays are loaded), it is safer carrying out the sorting process in to stages. This is the first stage.

Parameters
id_inUnsorted particle indexes
idSorted particle indexes
iset_inUnsorted set of particles indexes.
isetSorted set of particles indexes.
imove_inUnsorted moving flags.
  • imove > 0 for regular fluid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
imoveSorted moving flags.
  • imove > 0 for regular fluid particles.
  • imove = 0 for sensors.
  • imove < 0 for boundary elements/particles.
r_inUnsorted position \( \mathbf{r} \).
rSorted position \( \mathbf{r} \).
normal_inUnsorted normal \( \mathbf{n} \).
normalSorted normal \( \mathbf{n} \).
tangent_inUnsorted tangent \( \mathbf{t} \).
tangentSorted tangent \( \mathbf{t} \).
id_sortedPermutations list from the unsorted space to the sorted one.
NNumber of particles.

◆ stage2()

__kernel void stage2 ( const __global float * rho_in,
__global float * rho,
const __global float * m_in,
__global float * m,
const __global vec * u_in,
__global vec * u,
const __global vec * dudt,
__global vec * dudt_in,
const __global float * drhodt,
__global float * drhodt_in,
const __global usize * id_sorted,
usize N )

Sort all the particle variables by the cell indexes.

Due to the large number of registers consumed (21 global memory arrays are loaded), it is safer carrying out the sorting process in to stages. This is the first stage.

Parameters
rho_inUnsorted density \( \rho \).
rhoSorted density \( \rho \).
m_inUnsorted mass \( m \).
mSorted mass \( m \).
u_inUnsorted velocity \( \mathbf{u} \).
uSorted velocity \( \mathbf{u} \).
dudtUnsorted velocity rate of change \( \frac{d \mathbf{u}}{d t} \).
dudt_inSorted velocity rate of change \( \frac{d \mathbf{u}}{d t} \).
drhodtUnsorted density rate of change \( \frac{d \rho}{d t} \).
drhodt_inSorted density rate of change \( \frac{d \rho}{d t} \).
id_sortedPermutations list from the unsorted space to the sorted one.
NNumber of particles.

◆ weights()

__kernel void weights ( __global const unsigned int * iset,
__global const unsigned int * ilevel,
__global const vec * r,
__global const unsigned int * isplit,
__global float * split_weight,
__constant float * dr_level0,
usize N,
LINKLIST_LOCAL_PARAMS  )

Compute the contribution weight of each children particle.

The children particles (including the seed itself) may be close enough to several partner particles, such that, at the time of computing the partner particles properties, it is eventually contributing to several partners. Hence, the contributions should be conveniently weighted

See also
children()
Parameters
isetSet of particles index.
ilevelCurrent refinement level of the particle.
rPosition \( \mathbf{r} \).
isplit0 if the particle should not become coalesced, 1 for the coalescing particles, 2 for the seeds.
split_weightCoalescing contribution weight.
icellCell where each particle is located.
ihocHead of chain for each cell (first particle found).
dr_level0Theoretical distance between particles at the lowest refinement level.
NNumber of particles.
n_cellsNumber of cells in each direction