Report Typos and Errors    
Semi-Lagrangian Library
Modular library for kinetic and gyrokinetic simulations of plasmas in fusion energy devices.
Derived types and interfaces | Functions/Subroutines | Variables
sll_m_particle_group_2d2v_lbf Module Reference

Description

Module for a particle group with linearized-backward-flow (lbf) resamplings.

Author
MCP

Derived types and interfaces

type  sll_t_int_list_element
 linked lists of integers, used in some of the module routines More...
 
type  sll_t_int_list_element_ptr
 a pointer type is needed for arrays of lists More...
 
type  sll_t_particle_group_2d2v_lbf
 Group of sll_t_particle_group_2d2v_lbf. More...
 

Functions/Subroutines

pure real(kind=f64) function, dimension(3) get_x_2d2v_lbf (self, i)
 Getters ----------------------------------------------------------------------------------------------------------------—. More...
 
pure real(kind=f64) function, dimension(3) get_v_2d2v_lbf (self, i)
 Get the velocity of a particle. More...
 
pure real(kind=f64) function get_charge_2d2v_lbf (self, i, i_weight)
 Get charge of a particle (q * particle_weight) More...
 
pure real(kind=f64) function get_mass_2d2v_lbf (self, i, i_weight)
 Get mass of a particle ( m * particle_weight) More...
 
pure real(kind=f64) function, dimension(self%n_weights) get_weights_2d2v_lbf (self, i)
 Get weights of a particle. More...
 
pure real(kind=f64) function get_common_weight_2d2v_lbf (self)
 Set the common weight. More...
 
subroutine set_x_2d2v_lbf (self, i, x)
 Setters ----------------------------------------------------------------------------------------------------------------—. More...
 
subroutine set_v_2d2v_lbf (self, i, x)
 Set the velocity of a particle. More...
 
subroutine set_weights_2d2v_lbf (self, i, x)
 Set the weights of a particle. More...
 
subroutine set_common_weight_2d2v_lbf (self, x)
 Set the common weight. More...
 
subroutine initialize_particle_group_2d2v_lbf (self, species_charge, species_mass, domain_is_x_periodic, domain_is_y_periodic, remap_degree, remapping_grid_eta_min, remapping_grid_eta_max, remapping_sparse_grid_max_levels, n_particles_x, n_particles_y, n_particles_vx, n_particles_vy, n_weights)
 Initializer ------------------------------------------------------------------------------------------------------------— Initialize particle group. More...
 
subroutine, public sll_s_new_particle_group_2d2v_lbf_ptr (particle_group, species_charge, species_mass, domain_is_x_periodic, domain_is_y_periodic, remap_degree, remapping_grid_eta_min, remapping_grid_eta_max, remapping_sparse_grid_max_levels, n_particles_x, n_particles_y, n_particles_vx, n_particles_vy)
 Constructor for abstract type. More...
 
subroutine delete_particle_group_2d2v_lbf (self)
 Destructor -------------------------------------------------------------------------------------------------------------—. More...
 
subroutine sample (self, target_total_charge, enforce_total_charge, init_f_params, rand_seed, rank, world_size)
 sample (layer for resample procedure) ----------------------------------------------------------------------------------— this routine essentially does 2 things: More...
 
subroutine resample (self, target_total_charge, enforce_total_charge, init_f_params, rand_seed, rank, world_size)
 resample (and sample) --------------------------------------------------------------------------------------------------— this routine essentially does 2 things: More...
 
subroutine write_known_density_on_remapping_grid (self, distribution_params)
 write_known_density_on_remapping_grid ----------------------------------------------------------------------------------— this routine writes a given distribution on the interpolation (sparse grid) nodes to further approximate it More...
 
subroutine reset_particles_positions (self)
 reset_particles_positions ----------------------------------------------------------------------------------------------— reset the particles on the initial (cartesian) grid – we use the (multi-purpose) lbf grid – NOTE: particles will be located at the center of each cell (to avoid a particular treatment of periodic domains) More...
 
integer(kind=i32) function get_neighbor_index (self, k, dim, dir)
 get_neighbor_index -----------------------------------------------------------------------------------------------------— returns the index of the specified particle neighbor (defines the particle connectivity) More...
 
subroutine reset_particles_weights_with_direct_interpolation (self, target_total_charge, enforce_total_charge)
 reset_particles_weights_with_direct_interpolation ----------------------------------------------------------------------— compute (and set) the particle weights using a direct interpolation (here, sparse grid) – does not change the position of the deposition particles More...
 
real(kind=f64) function interpolate_value_of_remapped_f (self, eta)
 interpolate_value_of_remapped_f ----------------------------------------------------------------------------------------— computes the value of the (last) remapped density f using the interpolation tool – for now, assuming only sparse grid interpolation More...
 
subroutine reconstruct_f_lbf (self, reconstruction_set_type, given_grid_4d, given_array_4d, reconstruct_f_on_last_node, target_total_charge, enforce_total_charge)
 macro for the lbf approximation of a transported density (reconstruct_f_lbf) below -------------------------------------— More...
 
subroutine reconstruct_f_lbf_on_remapping_grid (self)
 reconstruct_f_lbf_on_remapping_grid ------------------------------------------------------------------------------------— layer for reconstruct_f_lbf, when reconstructing f on the remapping grid More...
 
subroutine reconstruct_f_lbf_on_given_grid (self, given_grid_4d, given_array_4d, reconstruct_f_on_last_node, target_total_charge, enforce_total_charge)
 reconstruct_f_lbf_on_remapping_grid ------------------------------------------------------------------------------------— layer for reconstruct_f_lbf, when reconstructing f on a given grid More...
 
subroutine get_ltp_deformation_matrix (self, k, mesh_period_x, mesh_period_y, h_particles_x, h_particles_y, h_particles_vx, h_particles_vy, x_k, y_k, vx_k, vy_k, d11, d12, d13, d14, d21, d22, d23, d24, d31, d32, d33, d34, d41, d42, d43, d44)
 get_ltp_deformation_matrix ---------------------------------------------------------------------------------------------— Compute the coefficients of the particle 'deformation' matrix which actually approximates the Jacobian matrix of the exact backward flow (defined between the current time and that of the particle initialization – or the last particle remapping) at the current particle position. More...
 
subroutine periodic_correction (p_group, x, y)
 periodic_correction ----------------------------------------------------------------------------------------------------— puts the point (x,y) back into the computational domain if periodic in x or y (or both) otherwise, does nothing More...
 
type(sll_t_int_list_element) function, pointer sll_f_add_element_in_int_list (head, new_element)
 sll_f_add_element_in_int_list ------------------------------------------------------------------------------------------— list management More...
 
subroutine convert_4d_index_to_1d (k, j_x, j_y, j_vx, j_vy, n_parts_x, n_parts_y, n_parts_vx, n_parts_vy)
 convert_4d_index_to_1d -------------------------------------------------------------------------------------------------— given the 4d index of a node on a cartesian grid, returns its 1d index in some assumed order see inverse function convert_1d_index_to_4d More...
 
subroutine convert_1d_index_to_4d (j_x, j_y, j_vx, j_vy, k, n_parts_x, n_parts_y, n_parts_vx, n_parts_vy)
 convert_1d_index_to_4d -------------------------------------------------------------------------------------------------— given the 1d index of a node on a cartesian grid (with some assumed order), returns its 4d index see inverse function convert_4d_index_to_1d More...
 
subroutine get_1d_cell_containing_point (j, x, x_min, h)
 get_1d_cell_containing_point -------------------------------------------------------------------------------------------— elementary function to compute the index j of the 1d cell containing a point x, ie x_min + (j-1)*h <= x < x_min + j*h bounds check should be performed outside this routine More...
 
subroutine update_closest_particle_arrays (k_part, x_aux, y_aux, vx_aux, vy_aux, i, j, l, m, h_cell_x, h_cell_y, h_cell_vx, h_cell_vy, closest_particle, closest_particle_distance)
 update_closest_particle_arrays -----------------------------------------------------------------------------------------— update the arrays closest_particle and closest_particle_distance with the index of the given particle if closer to what had been stored up to now. More...
 

Variables

integer(kind=i32), parameter sll_p_lbf_remapping_grid = 1
 possible values for the parameter reconstruction_set_type in the reconstruction routine More...
 
integer(kind=i32), parameter sll_p_lbf_given_grid = 2
 

Function/Subroutine Documentation

◆ convert_1d_index_to_4d()

subroutine sll_m_particle_group_2d2v_lbf::convert_1d_index_to_4d ( integer(kind=i32), intent(out)  j_x,
integer(kind=i32), intent(out)  j_y,
integer(kind=i32), intent(out)  j_vx,
integer(kind=i32), intent(out)  j_vy,
integer(kind=i32), intent(in)  k,
integer(kind=i32), intent(in)  n_parts_x,
integer(kind=i32), intent(in)  n_parts_y,
integer(kind=i32), intent(in)  n_parts_vx,
integer(kind=i32), intent(in)  n_parts_vy 
)
private

convert_1d_index_to_4d -------------------------------------------------------------------------------------------------— given the 1d index of a node on a cartesian grid (with some assumed order), returns its 4d index see inverse function convert_4d_index_to_1d

here, k_aux = (j_vy-1) + (j_vx-1) * n_parts_vy + (j_y-1) * n_parts_vy * n_parts_vx + (j_x-1) * n_parts_vy * n_parts_vx * n_parts_y

here, k_aux = (j_vx-1) + (j_y-1) * n_parts_vx + (j_x-1) * n_parts_vx * n_parts_y

here, k_aux = (j_y-1) + (j_x-1) * n_parts_y

here, k_aux = (j_x-1)

Definition at line 2094 of file sll_m_particle_group_2d2v_lbf.F90.

Here is the caller graph for this function:

◆ convert_4d_index_to_1d()

subroutine sll_m_particle_group_2d2v_lbf::convert_4d_index_to_1d ( integer(kind=i32), intent(out)  k,
integer(kind=i32), intent(in)  j_x,
integer(kind=i32), intent(in)  j_y,
integer(kind=i32), intent(in)  j_vx,
integer(kind=i32), intent(in)  j_vy,
integer(kind=i32), intent(in)  n_parts_x,
integer(kind=i32), intent(in)  n_parts_y,
integer(kind=i32), intent(in)  n_parts_vx,
integer(kind=i32), intent(in)  n_parts_vy 
)
private

convert_4d_index_to_1d -------------------------------------------------------------------------------------------------— given the 4d index of a node on a cartesian grid, returns its 1d index in some assumed order see inverse function convert_1d_index_to_4d

Definition at line 2064 of file sll_m_particle_group_2d2v_lbf.F90.

Here is the caller graph for this function:

◆ delete_particle_group_2d2v_lbf()

subroutine sll_m_particle_group_2d2v_lbf::delete_particle_group_2d2v_lbf ( class( sll_t_particle_group_2d2v_lbf ), intent(inout)  self)
private

Destructor -------------------------------------------------------------------------------------------------------------—.

Parameters
[in,out]selfparticle group

Definition at line 443 of file sll_m_particle_group_2d2v_lbf.F90.

◆ get_1d_cell_containing_point()

subroutine sll_m_particle_group_2d2v_lbf::get_1d_cell_containing_point ( integer(kind=i32), intent(out)  j,
real(kind=f64), intent(in)  x,
real(kind=f64), intent(in)  x_min,
real(kind=f64), intent(in)  h 
)
private

get_1d_cell_containing_point -------------------------------------------------------------------------------------------— elementary function to compute the index j of the 1d cell containing a point x, ie x_min + (j-1)*h <= x < x_min + j*h bounds check should be performed outside this routine

Definition at line 2133 of file sll_m_particle_group_2d2v_lbf.F90.

Here is the caller graph for this function:

◆ get_charge_2d2v_lbf()

pure real(kind=f64) function sll_m_particle_group_2d2v_lbf::get_charge_2d2v_lbf ( class( sll_t_particle_group_2d2v_lbf ), intent(in)  self,
integer(kind=i32), intent(in)  i,
integer(kind=i32), intent(in), optional  i_weight 
)
private

Get charge of a particle (q * particle_weight)

Parameters
[in]selfparticle group
[in]iparticle index
[in]i_weightweight index to be used (default: 1) - not needed now
Returns
charge of particle i

Definition at line 186 of file sll_m_particle_group_2d2v_lbf.F90.

◆ get_common_weight_2d2v_lbf()

pure real(kind=f64) function sll_m_particle_group_2d2v_lbf::get_common_weight_2d2v_lbf ( class( sll_t_particle_group_2d2v_lbf ), intent(in)  self)
private

Set the common weight.

Parameters
[in]selfparticle group
Returns
common weight

Definition at line 231 of file sll_m_particle_group_2d2v_lbf.F90.

◆ get_ltp_deformation_matrix()

subroutine sll_m_particle_group_2d2v_lbf::get_ltp_deformation_matrix ( class(sll_t_particle_group_2d2v_lbf), intent(inout)  self,
integer(kind=i32), intent(in)  k,
real(kind=f64), intent(in)  mesh_period_x,
real(kind=f64), intent(in)  mesh_period_y,
real(kind=f64), intent(in)  h_particles_x,
real(kind=f64), intent(in)  h_particles_y,
real(kind=f64), intent(in)  h_particles_vx,
real(kind=f64), intent(in)  h_particles_vy,
real(kind=f64), intent(out)  x_k,
real(kind=f64), intent(out)  y_k,
real(kind=f64), intent(out)  vx_k,
real(kind=f64), intent(out)  vy_k,
real(kind=f64), intent(out)  d11,
real(kind=f64), intent(out)  d12,
real(kind=f64), intent(out)  d13,
real(kind=f64), intent(out)  d14,
real(kind=f64), intent(out)  d21,
real(kind=f64), intent(out)  d22,
real(kind=f64), intent(out)  d23,
real(kind=f64), intent(out)  d24,
real(kind=f64), intent(out)  d31,
real(kind=f64), intent(out)  d32,
real(kind=f64), intent(out)  d33,
real(kind=f64), intent(out)  d34,
real(kind=f64), intent(out)  d41,
real(kind=f64), intent(out)  d42,
real(kind=f64), intent(out)  d43,
real(kind=f64), intent(out)  d44 
)
private

get_ltp_deformation_matrix ---------------------------------------------------------------------------------------------— Compute the coefficients of the particle 'deformation' matrix which actually approximates the Jacobian matrix of the exact backward flow (defined between the current time and that of the particle initialization – or the last particle remapping) at the current particle position.

Note: the 'deformation matrix' terminology comes from the LTP method, but with the lbf reconstruction method we are not deforming particles anymore. This matrix is just used as the approximate backward Jacobian matrix

It is computed in two steps:

  • first we compute a finite-difference approximation of the forward Jacobian matrix by using the fact that the initial (or remapped) particles were located on a cartesian grid in phase space. Specifically, the entries of the forward Jacobian matrix (say, (J^n_k)_xy = d(F^n_x)/dy (z^0_k) – with z is the phase space coordinate) are approximated by finite differences: here, by DF / 2*h_y with DF = F^n_x(z^0_k + (0,h_y,0,0)) - F^n_x(z^0_k - (0,h_y,0,0))
  • then we invert that approximated forward Jacobian matrix

Note: when computing finite differences in a periodic dimension (say x), one must be careful since two values of F_x can be close in the periodic interval but distant by almost L_x in the (stored) [0,L_x[ representation. To account for this (frequent) phenomenon we do the following: when the difference DF (see example above) is larger than L_x/2, we make it smaller by adding +/- L_x to it. Note that here we could very well be making the slope smaller than what it should actually be: indeed if the function F^n_x is having a steep slope at z^0_k which adds one (or several) periods L_x to DF then our modification will artificially lower the slope. But this is impossible to prevent in full generality (indeed: a steep slope crossing the 0 or L_x value will be lowered anyway in the [0,L_x[ representation) and should not be frequent (indeed it only happens when F^n_x has high derivatives and the particle grid is coarse, which will lead to bad approximations anyhow).

Parameters
[out]y_kparticle center in physical space
[out]vy_kparticle center in velocity space
[out]d14coefs of matrix D (backward Jacobian)

Compute the forward Jacobian matrix J_k

---— d/d_x terms

no right neighbor is available, use a non-centered finite difference

no left neighbor is available, use a non-centered finite difference

---— d/d_y terms

no right neighbor is available, use a non-centered finite difference

no left neighbor is available, use a non-centered finite difference

---— d/d_vx terms

no right neighbor is available, use a non-centered finite difference

no left neighbor is available, use a non-centered finite difference

---— d/d_vy terms

no right neighbor is available, use a non-centered finite difference

no left neighbor is available, use a non-centered finite difference

Compute D_k the inverse of J_k

Definition at line 1586 of file sll_m_particle_group_2d2v_lbf.F90.

◆ get_mass_2d2v_lbf()

pure real(kind=f64) function sll_m_particle_group_2d2v_lbf::get_mass_2d2v_lbf ( class( sll_t_particle_group_2d2v_lbf ), intent(in)  self,
integer(kind=i32), intent(in)  i,
integer(kind=i32), intent(in), optional  i_weight 
)
private

Get mass of a particle ( m * particle_weight)

Parameters
[in]selfparticle group
[in]iparticle index
[in]i_weightweight index to be used (default: 1) - not needed now
Returns
mass of particle i

Definition at line 203 of file sll_m_particle_group_2d2v_lbf.F90.

◆ get_neighbor_index()

integer(kind=i32) function sll_m_particle_group_2d2v_lbf::get_neighbor_index ( class(sll_t_particle_group_2d2v_lbf), intent(inout)  self,
integer(kind=i32), intent(in)  k,
integer(kind=i32), intent(in)  dim,
integer(kind=i32), intent(in)  dir 
)
private

get_neighbor_index -----------------------------------------------------------------------------------------------------— returns the index of the specified particle neighbor (defines the particle connectivity)

Parameters
[in]kparticle index
[in]dimneighbor dimension
[in]dirneighbor direction (-1: left, 1:right)
Returns
neighbor particle index

Definition at line 633 of file sll_m_particle_group_2d2v_lbf.F90.

Here is the call graph for this function:

◆ get_v_2d2v_lbf()

pure real(kind=f64) function, dimension(3) sll_m_particle_group_2d2v_lbf::get_v_2d2v_lbf ( class( sll_t_particle_group_2d2v_lbf ), intent(in)  self,
integer(kind=i32), intent(in)  i 
)
private

Get the velocity of a particle.

Parameters
[in]selfparticle group
[in]iparticle index
Returns
first two components hold the value of the particle velocity

Definition at line 172 of file sll_m_particle_group_2d2v_lbf.F90.

◆ get_weights_2d2v_lbf()

pure real(kind=f64) function, dimension(self%n_weights) sll_m_particle_group_2d2v_lbf::get_weights_2d2v_lbf ( class( sll_t_particle_group_2d2v_lbf ), intent(in)  self,
integer(kind=i32), intent(in)  i 
)
private

Get weights of a particle.

Parameters
[in]selfparticle group
[in]ino. of the particle
Returns
particle weight(s)

Definition at line 220 of file sll_m_particle_group_2d2v_lbf.F90.

◆ get_x_2d2v_lbf()

pure real(kind=f64) function, dimension(3) sll_m_particle_group_2d2v_lbf::get_x_2d2v_lbf ( class( sll_t_particle_group_2d2v_lbf ), intent(in)  self,
integer(kind=i32), intent(in)  i 
)
private

Getters ----------------------------------------------------------------------------------------------------------------—.

Get the physical coordinates of a particle

Parameters
[in]selfparticle group
[in]iparticle index
Returns
first two components hold the value of the particle position

Definition at line 160 of file sll_m_particle_group_2d2v_lbf.F90.

◆ initialize_particle_group_2d2v_lbf()

subroutine sll_m_particle_group_2d2v_lbf::initialize_particle_group_2d2v_lbf ( class( sll_t_particle_group_2d2v_lbf ), intent(inout)  self,
real(kind=f64), intent(in)  species_charge,
real(kind=f64), intent(in)  species_mass,
logical, intent(in)  domain_is_x_periodic,
logical, intent(in)  domain_is_y_periodic,
integer(kind=i32), intent(in)  remap_degree,
real(kind=f64), dimension(4), intent(in)  remapping_grid_eta_min,
real(kind=f64), dimension(4), intent(in)  remapping_grid_eta_max,
integer(kind=i32), dimension(4), intent(in)  remapping_sparse_grid_max_levels,
integer(kind=i32), intent(in)  n_particles_x,
integer(kind=i32), intent(in)  n_particles_y,
integer(kind=i32), intent(in)  n_particles_vx,
integer(kind=i32), intent(in)  n_particles_vy,
integer(kind=i32), intent(in)  n_weights 
)
private

Initializer ------------------------------------------------------------------------------------------------------------— Initialize particle group.

Parameters
[in,out]selfparticle group
[in]n_weightsnumber of weights per particle (only 1 for now)

create the species object for this particle group

A. discretization of the flow: the flow grid is the 4d cartesian grid where the backward flow is linearized in this deterministic case, the particles are initially located at the center of each flow cell

B. discretization of the remapped f, with sparse grids

C. array of sparse grid coefficients for remapped_f

this array is to store temporary values of remapped f, while those of previously remapped f still needed

Definition at line 287 of file sll_m_particle_group_2d2v_lbf.F90.

Here is the call graph for this function:

◆ interpolate_value_of_remapped_f()

real(kind=f64) function sll_m_particle_group_2d2v_lbf::interpolate_value_of_remapped_f ( class(sll_t_particle_group_2d2v_lbf), intent(inout)  self,
real(kind=f64), dimension(4), intent(in)  eta 
)
private

interpolate_value_of_remapped_f ----------------------------------------------------------------------------------------— computes the value of the (last) remapped density f using the interpolation tool – for now, assuming only sparse grid interpolation

Parameters
[in]etaPosition where to interpolate

Definition at line 798 of file sll_m_particle_group_2d2v_lbf.F90.

Here is the call graph for this function:

◆ periodic_correction()

subroutine sll_m_particle_group_2d2v_lbf::periodic_correction ( class(sll_t_particle_group_2d2v_lbf), intent(in)  p_group,
real(kind=f64), intent(inout)  x,
real(kind=f64), intent(inout)  y 
)
private

periodic_correction ----------------------------------------------------------------------------------------------------— puts the point (x,y) back into the computational domain if periodic in x or y (or both) otherwise, does nothing

Definition at line 2033 of file sll_m_particle_group_2d2v_lbf.F90.

Here is the caller graph for this function:

◆ reconstruct_f_lbf()

subroutine sll_m_particle_group_2d2v_lbf::reconstruct_f_lbf ( class(sll_t_particle_group_2d2v_lbf), intent(inout)  self,
integer(kind=i32), intent(in)  reconstruction_set_type,
type(sll_t_cartesian_mesh_4d), intent(in), pointer  given_grid_4d,
real(kind=f64), dimension(:,:,:,:), intent(inout), pointer  given_array_4d,
logical, dimension(4), intent(in)  reconstruct_f_on_last_node,
real(kind=f64), intent(in)  target_total_charge,
logical, intent(in)  enforce_total_charge 
)
private

macro for the lbf approximation of a transported density (reconstruct_f_lbf) below -------------------------------------—

reconstruct_f_lbf -------------------------------------------------------------------------------------------------------— reconstruct point values of the transported f using a bsl approximation based on linearized backward flows (lbf) values are reconstructed on different grids, depending on reconstruction_set_type:

  • sll_p_lbf_remapping_grid: the remapping grid (for now, a sparse grid)
  • sll_p_lbf_given_grid: a 4d cartesian grid

index of particle closest to the center of each flow cell

array of integer linked lists (declared below) useful when remapping on sparse grids (can also simplify the code when remapping on cartesian grids which do not match with the flow cells? but maybe too costly)

<<g>> cartesian grid pointer to the remapping grid

the flow cells are the cells where the flow will be linearized

results from [[get_ltp_deformation_matrix]]

coordinates of particle k at time n and time 0

coordinates of a reconstruction point at time 0, absolute

coordinates of a reconstruction point at time 0, relative to the nearby reference particle (= closest to cell center)

getting the parameters of the flow grid (where the bwd flow is linearized)

reconstruction will be done through local linearization of the bwd flow in flow cells. these flow cells are defined by the lbf_grid but we may not need all of them (if reconstructing f on a given grid, see below)

A. preparation of the point sets where f will be reconstructed, depending on the cases

=> prepare the array of linked lists that will store the node indices contained in the flow cells (one list per cell)

then loop to store the sparse grid node indices in linked lists corresponding to the flow cells that contain them

get node coordinates:

find the index (j_x,j_y,j_vx,j_vy) of the flow cell containing this node (same piece of code as below)

discard if flow cell is off-bounds

increment the proper linked list

then use the given 4d grid and write values in given array

if the given grid is strictly contained in the lbf grid, we can reduce the number of flow cells where f is reconstructed

B. Preparatory work for the linearization of the flow on the flow cells: find out the closest particle to each cell center, by looping over all particles and noting which flow cell contains it. (The leftmost flow cell in each dimension may not be complete.)

find absolute (x_k,y_k,vx_k,vy_k) coordinates for k-th particle.

which flow cell is this particle in?

discard this particle if off-bounds

C. loop on the flow cells (main loop): on each flow cell, we

  • C.1 linearize the flow using the position of the particles
  • C.2 find the relevant points where f should be reconstructed
  • C.3 reconstruct f on these points (using the affine backward flow and the interpolation tool for the remapped_f)
  • C.4 write the resulting f value on the proper place

here the domain corresponds to the Poisson mesh

here the domain corresponds to the Poisson mesh

Find the particle which is closest to the cell center – and if we do not have it yet, look on the neighboring cells

  • C.1 linearize the flow using the position of the particles

In this flow cell we will use the k-th backward flow, requires the deformation matrix of the k-th particle

Find position of particle k at time 0

initially the particles are on the center of the lbf cells (also the flow grid)

  • C.2 find the relevant points (x, y, vx, vy) where f should be reconstructed
    • C.2.a first we treat the case of [remapping with a sparse grid] or [computing the weights of a cloud of deposition particles]: nodes are stored in linked lists

node coordinates relative to current particle position

find z_t0 = (x_t0, y_t0, vx_t0, vy_t0), the position of the node at time = 0 using the affine bwd flow

put back z_t0 inside domain (if needed) to enforce periodic boundary conditions

now (x_t0, y_t0, vx_t0, vy_t0) is the (approx) position of the node at time t=0

interpolate and store nodal value on ad-hoc array

  • C.2.b next we treat the case of a remapping with splines or writing on a given grid (in both cases the nodes are on the g grid constructed above)

loop over the grid points inside this flow cell:

points in the grid are of the form d(i) = g_grid_d_min + (i-1) * h_g_grid_d, i = 1, .. g_num_points_d (with d = x, y, vx or vy and g_num_points_d = g_num_cells_d or g_num_cells_d+1 , depending on the periodicity) and this flow cell has the form [flow_grid_d_min + (j-1) * h_flow_grid_d, flow_grid_d_min + j * h_flow_grid_d[ so eta_d(i) is in this flow cell if i_min <= i <= i_max where i_min = ceiling( (flow_grid_min - g_grid_d_min + (j-1)*h_flow_grid_d)/h_g_grid_d + 1 ) and i_max = ceiling( (flow_grid_min - g_grid_d_min + (j) *h_flow_grid_d)/h_g_grid_d + 1 ) - 1

C.3 reconstruct the value of f at z_i = (x,y,vx,vy) for this we need z_t0, the position of the z_i at time = 0, using the affine backward flow

put back z_t0 inside domain (if needed) to enforce periodic boundary conditions

now (x_t0, y_t0, vx_t0, vy_t0) is the (approx) position of the node z_i at time t=0

interpolation here may use sparse grid or splines, depending on the method chosen for self

C.4 write the reconstructed value at proper place

this is the end of the (fourfold) loop on the grid nodes

and this is the end of (fourfold) loop on the flow cells

Definition at line 844 of file sll_m_particle_group_2d2v_lbf.F90.

Here is the call graph for this function:

◆ reconstruct_f_lbf_on_given_grid()

subroutine sll_m_particle_group_2d2v_lbf::reconstruct_f_lbf_on_given_grid ( class(sll_t_particle_group_2d2v_lbf), intent(inout)  self,
type(sll_t_cartesian_mesh_4d), intent(in), pointer  given_grid_4d,
real(kind=f64), dimension(:,:,:,:), intent(inout), pointer  given_array_4d,
logical, dimension(4), intent(in)  reconstruct_f_on_last_node,
real(kind=f64), intent(in)  target_total_charge,
logical, intent(in)  enforce_total_charge 
)
private

reconstruct_f_lbf_on_remapping_grid ------------------------------------------------------------------------------------— layer for reconstruct_f_lbf, when reconstructing f on a given grid

Definition at line 1533 of file sll_m_particle_group_2d2v_lbf.F90.

◆ reconstruct_f_lbf_on_remapping_grid()

subroutine sll_m_particle_group_2d2v_lbf::reconstruct_f_lbf_on_remapping_grid ( class(sll_t_particle_group_2d2v_lbf), intent(inout)  self)
private

reconstruct_f_lbf_on_remapping_grid ------------------------------------------------------------------------------------— layer for reconstruct_f_lbf, when reconstructing f on the remapping grid

Definition at line 1506 of file sll_m_particle_group_2d2v_lbf.F90.

◆ resample()

subroutine sll_m_particle_group_2d2v_lbf::resample ( class(sll_t_particle_group_2d2v_lbf), intent(inout)  self,
real(kind=f64), intent(in)  target_total_charge,
logical, intent(in)  enforce_total_charge,
class(sll_c_distribution_params), intent(in), optional  init_f_params,
integer(kind=i32), dimension(:), intent(in), optional  rand_seed,
integer(kind=i32), intent(in), optional  rank,
integer(kind=i32), intent(in), optional  world_size 
)
private

resample (and sample) --------------------------------------------------------------------------------------------------— this routine essentially does 2 things:

  • (re)set the particles on the initial grid
  • computes new interpolation (sparse grid) coefficients so that the remapped_f is an approximation of the target density f – note: if not initial step (true remap), the evaluation of the transported f relies on the lbf method

A. write the nodal values of the target density f, then compute the new interpolation coefs

  • A.1 write the nodal values of f on the arrays of interpolation coefs

write initial density f0 on remapping grid

reconstruct transported density fn on remapping grid with the lbf method

compute the sparse grid interpolation coefs for remapped_f, using the nodal values stored in the tmp array

B. reset the particles on the cartesian grid

since the remapping tool has been reset, computing the weights can be done with straightforward interpolation (flow = Id)

not needed for now, but prevents warnings

Definition at line 483 of file sll_m_particle_group_2d2v_lbf.F90.

◆ reset_particles_positions()

subroutine sll_m_particle_group_2d2v_lbf::reset_particles_positions ( class(sll_t_particle_group_2d2v_lbf), intent(inout)  self)
private

reset_particles_positions ----------------------------------------------------------------------------------------------— reset the particles on the initial (cartesian) grid – we use the (multi-purpose) lbf grid – NOTE: particles will be located at the center of each cell (to avoid a particular treatment of periodic domains)

Definition at line 556 of file sll_m_particle_group_2d2v_lbf.F90.

Here is the call graph for this function:

◆ reset_particles_weights_with_direct_interpolation()

subroutine sll_m_particle_group_2d2v_lbf::reset_particles_weights_with_direct_interpolation ( class( sll_t_particle_group_2d2v_lbf ), intent(inout)  self,
real(kind=f64), intent(in)  target_total_charge,
logical, intent(in)  enforce_total_charge 
)
private

reset_particles_weights_with_direct_interpolation ----------------------------------------------------------------------— compute (and set) the particle weights using a direct interpolation (here, sparse grid) – does not change the position of the deposition particles

set the particle group common_weight to 1 (will be a factor of each particle weight)

5 is the first weight index

5 is the first weight index

Definition at line 742 of file sll_m_particle_group_2d2v_lbf.F90.

◆ sample()

subroutine sll_m_particle_group_2d2v_lbf::sample ( class(sll_t_particle_group_2d2v_lbf), intent(inout)  self,
real(kind=f64), intent(in)  target_total_charge,
logical, intent(in)  enforce_total_charge,
class(sll_c_distribution_params), intent(in)  init_f_params,
integer(kind=i32), dimension(:), intent(in), optional  rand_seed,
integer(kind=i32), intent(in), optional  rank,
integer(kind=i32), intent(in), optional  world_size 
)
private

sample (layer for resample procedure) ----------------------------------------------------------------------------------— this routine essentially does 2 things:


Below this line are functions specific to the lbf particles with resampling --------------------------------------------— * locates the particles on an initial cartesian grid,

  • computes interpolation (sparse grid) coefficients to approximate the initial distribution
    Parameters
    [in]init_f_paramsparameters of the initial distribution

Definition at line 461 of file sll_m_particle_group_2d2v_lbf.F90.

◆ set_common_weight_2d2v_lbf()

subroutine sll_m_particle_group_2d2v_lbf::set_common_weight_2d2v_lbf ( class( sll_t_particle_group_2d2v_lbf ), intent(inout)  self,
real(kind=f64), intent(in)  x 
)
private

Set the common weight.

Parameters
[in,out]selfparticle group
[in]xcommon weight

Definition at line 276 of file sll_m_particle_group_2d2v_lbf.F90.

◆ set_v_2d2v_lbf()

subroutine sll_m_particle_group_2d2v_lbf::set_v_2d2v_lbf ( class( sll_t_particle_group_2d2v_lbf ), intent(inout)  self,
integer(kind=i32), intent(in)  i,
real(kind=f64), dimension(3), intent(in)  x 
)
private

Set the velocity of a particle.

Parameters
[in,out]selfparticle group
[in]iparticle index
[in]xcomponent 1 and 2 hold the particle velocity to be set

Definition at line 254 of file sll_m_particle_group_2d2v_lbf.F90.

◆ set_weights_2d2v_lbf()

subroutine sll_m_particle_group_2d2v_lbf::set_weights_2d2v_lbf ( class( sll_t_particle_group_2d2v_lbf ), intent(inout)  self,
integer(kind=i32), intent(in)  i,
real(kind=f64), dimension(self%n_weights), intent(in)  x 
)
private

Set the weights of a particle.

Parameters
[in,out]selfparticle group
[in]iparticle index
[in]xparticle weight(s) to be set

Definition at line 265 of file sll_m_particle_group_2d2v_lbf.F90.

◆ set_x_2d2v_lbf()

subroutine sll_m_particle_group_2d2v_lbf::set_x_2d2v_lbf ( class( sll_t_particle_group_2d2v_lbf ), intent(inout)  self,
integer(kind=i32), intent(in)  i,
real(kind=f64), dimension(3), intent(in)  x 
)
private

Setters ----------------------------------------------------------------------------------------------------------------—.

Set the position of a particle

Parameters
[in,out]selfparticle group
[in]iparticle index
[in]xcomponents 1 and 2 hold the particle position to be set

Definition at line 243 of file sll_m_particle_group_2d2v_lbf.F90.

◆ sll_f_add_element_in_int_list()

type( sll_t_int_list_element ) function, pointer sll_m_particle_group_2d2v_lbf::sll_f_add_element_in_int_list ( type( sll_t_int_list_element ), pointer  head,
type( sll_t_int_list_element ), pointer  new_element 
)
private

sll_f_add_element_in_int_list ------------------------------------------------------------------------------------------— list management

Definition at line 2054 of file sll_m_particle_group_2d2v_lbf.F90.

Here is the caller graph for this function:

◆ sll_s_new_particle_group_2d2v_lbf_ptr()

subroutine, public sll_m_particle_group_2d2v_lbf::sll_s_new_particle_group_2d2v_lbf_ptr ( class( sll_c_particle_group_base ), intent(out), pointer  particle_group,
real(kind=f64), intent(in)  species_charge,
real(kind=f64), intent(in)  species_mass,
logical, intent(in)  domain_is_x_periodic,
logical, intent(in)  domain_is_y_periodic,
integer(kind=i32), intent(in)  remap_degree,
real(kind=f64), dimension(4), intent(in)  remapping_grid_eta_min,
real(kind=f64), dimension(4), intent(in)  remapping_grid_eta_max,
integer(kind=i32), dimension(4), intent(in)  remapping_sparse_grid_max_levels,
integer(kind=i32), intent(in)  n_particles_x,
integer(kind=i32), intent(in)  n_particles_y,
integer(kind=i32), intent(in)  n_particles_vx,
integer(kind=i32), intent(in)  n_particles_vy 
)

Constructor for abstract type.

Definition at line 386 of file sll_m_particle_group_2d2v_lbf.F90.

◆ update_closest_particle_arrays()

subroutine sll_m_particle_group_2d2v_lbf::update_closest_particle_arrays ( integer(kind=i32), intent(in)  k_part,
real(kind=f64), intent(in)  x_aux,
real(kind=f64), intent(in)  y_aux,
real(kind=f64), intent(in)  vx_aux,
real(kind=f64), intent(in)  vy_aux,
integer(kind=i32), intent(in)  i,
integer(kind=i32), intent(in)  j,
integer(kind=i32), intent(in)  l,
integer(kind=i32), intent(in)  m,
real(kind=f64), intent(in)  h_cell_x,
real(kind=f64), intent(in)  h_cell_y,
real(kind=f64), intent(in)  h_cell_vx,
real(kind=f64), intent(in)  h_cell_vy,
integer(kind=i32), dimension(:,:,:,:), intent(inout)  closest_particle,
real(kind=f64), dimension(:,:,:,:), intent(inout)  closest_particle_distance 
)
private

update_closest_particle_arrays -----------------------------------------------------------------------------------------— update the arrays closest_particle and closest_particle_distance with the index of the given particle if closer to what had been stored up to now.

Parameters
[in]x_auxx_particle - flow_grid_x_min
[in]y_auxidem
[in]vx_auxidem
[in]vy_auxidem

if new particle is closer to center, keep the new one

Definition at line 2145 of file sll_m_particle_group_2d2v_lbf.F90.

Here is the caller graph for this function:

◆ write_known_density_on_remapping_grid()

subroutine sll_m_particle_group_2d2v_lbf::write_known_density_on_remapping_grid ( class(sll_t_particle_group_2d2v_lbf), intent(inout)  self,
class(sll_c_distribution_params), intent(in)  distribution_params 
)
private

write_known_density_on_remapping_grid ----------------------------------------------------------------------------------— this routine writes a given distribution on the interpolation (sparse grid) nodes to further approximate it

Definition at line 528 of file sll_m_particle_group_2d2v_lbf.F90.

Variable Documentation

◆ sll_p_lbf_given_grid

integer(kind=i32), parameter sll_p_lbf_given_grid = 2
private

Definition at line 61 of file sll_m_particle_group_2d2v_lbf.F90.

◆ sll_p_lbf_remapping_grid

integer(kind=i32), parameter sll_p_lbf_remapping_grid = 1
private

possible values for the parameter reconstruction_set_type in the reconstruction routine

Definition at line 60 of file sll_m_particle_group_2d2v_lbf.F90.

    Report Typos and Errors