OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
ParticleBinning::CoordinateSelector< bunch_type > Struct Template Reference

Example struct used to access the binning variable for each particle. More...

#include <BinningTools.h>

Collaboration diagram for ParticleBinning::CoordinateSelector< bunch_type >:

Public Types

using value_type = typename bunch_type::Layout_t::value_type
 Type representing the value of the binning variable (e.g., position or velocity).
using size_type = typename bunch_type::size_type
 Type representing the size of the particle bunch.
using position_view_type = typename bunch_type::particle_position_type::view_type
 Type representing the view of particle positions.

Public Member Functions

 CoordinateSelector (int axis_)
 Constructs a CoordinateSelector for a specific axis.
void updateDataArr (std::shared_ptr< bunch_type > bunch)
 Updates the data array view with the latest particle data.
KOKKOS_INLINE_FUNCTION value_type operator() (const size_type &i) const
 Returns the value of the binning variable for a given particle index.

Public Attributes

position_view_type data_arr
 Kokkos view of the particle data array.
const int axis
 Index of the coordinate axis to use for binning.

Detailed Description

template<typename bunch_type>
struct ParticleBinning::CoordinateSelector< bunch_type >

Example struct used to access the binning variable for each particle.

This struct provides a flexible way to select a specific coordinate axis (e.g., position or velocity) for binning. It allows specifying the axis index, making it versatile for different coordinate-based binning operations. Alternatively, custom structs could be defined for other binning variables, such as calculating energy with saved mass and velocity values.

Requirement:

  • operator() must be defined with the exact signature shown below.

  • value_type must be defined in the struct.

  • If operator() does not return value_type, AdaptBins will not compile, and may cause segmentation faults.

Example usage:

CoordinateSelector<bunch_type> selector(bunch->R.getView(), 2); // Access z-axis of position
CoordinateSelector(int axis_)
Constructs a CoordinateSelector for a specific axis.
Note
Using a shared pointer does not work, since these are managed on host only! Using a simple passed Kokkos::View also does not work, since create() might be called which calls Kokkos::realloc(), which is a problem, since the copied view does not know the reallocated data. Therefore, the view is updated with updateDataArr!
Template Parameters
bunch_typeType of the particle bunch (derived from ParticleBase).

Definition at line 77 of file BinningTools.h.

Member Typedef Documentation

◆ position_view_type

template<typename bunch_type>
using ParticleBinning::CoordinateSelector< bunch_type >::position_view_type = typename bunch_type::particle_position_type::view_type

Type representing the view of particle positions.

Definition at line 85 of file BinningTools.h.

◆ size_type

template<typename bunch_type>
using ParticleBinning::CoordinateSelector< bunch_type >::size_type = typename bunch_type::size_type

Type representing the size of the particle bunch.

Definition at line 82 of file BinningTools.h.

◆ value_type

template<typename bunch_type>
using ParticleBinning::CoordinateSelector< bunch_type >::value_type = typename bunch_type::Layout_t::value_type

Type representing the value of the binning variable (e.g., position or velocity).

Definition at line 79 of file BinningTools.h.

Constructor & Destructor Documentation

◆ CoordinateSelector()

template<typename bunch_type>
ParticleBinning::CoordinateSelector< bunch_type >::CoordinateSelector ( int axis_)
inline

Constructs a CoordinateSelector for a specific axis.

Parameters
data_Kokkos view representing the particle data array.
axis_Index of the axis to use for binning (e.g., 0 for x, 1 for y, 2 for z).

Definition at line 96 of file BinningTools.h.

References axis.

Member Function Documentation

◆ operator()()

template<typename bunch_type>
KOKKOS_INLINE_FUNCTION value_type ParticleBinning::CoordinateSelector< bunch_type >::operator() ( const size_type & i) const
inline

Returns the value of the binning variable for a given particle index.

This function is called by AdaptBins to obtain the binning value for each particle.

Parameters
iIndex of the particle in the data array.
Returns
value_type Value of the specified coordinate axis for the particle at index i.

Definition at line 121 of file BinningTools.h.

References axis, and data_arr.

◆ updateDataArr()

template<typename bunch_type>
void ParticleBinning::CoordinateSelector< bunch_type >::updateDataArr ( std::shared_ptr< bunch_type > bunch)
inline

Updates the data array view with the latest particle data.

This function updates data_arr to reflect the latest particle data in the container by retrieving the view from bunch->R. This ensures data_arr is synchronized with any recent changes to the particle data (if bunch->create() is called between binnings!). AdaptBins calls this function automatically everytime the binning parameter is used.

Note
If you have your own class, you need to implement this signature and potentially update all data arrays that operator() uses (e.g. also velocity or E).

Definition at line 110 of file BinningTools.h.

References data_arr.

Member Data Documentation

◆ axis

template<typename bunch_type>
const int ParticleBinning::CoordinateSelector< bunch_type >::axis

Index of the coordinate axis to use for binning.

Definition at line 88 of file BinningTools.h.

Referenced by CoordinateSelector(), and operator()().

◆ data_arr

template<typename bunch_type>
position_view_type ParticleBinning::CoordinateSelector< bunch_type >::data_arr

Kokkos view of the particle data array.

Definition at line 87 of file BinningTools.h.

Referenced by operator()(), and updateDataArr().


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