Core Types and Functions#

Here we describe the core types and functions of NESO::Particles.

Particle Initialisation#

Types and functions for creating particles and initialising the particle state.

void parallel_advection_initialisation(
ParticleGroupSharedPtr particle_group,
const int num_steps = 20
)#

Initialisation utility to aid parallel creation of particle distributions. This function performs the all-to-all movement that occurs when a ParticleGroup contains particles with positions (far) outside the owned region of space. For example consider if each MPI rank creates N particles uniformly distributed over the entire simulation domain then the call to hybrid_move would have a cost equal to the number of MPI ranks squared.

This function gives each particle a temporary position in the owned subdomain then moves the particles in a straight line to the original positions in the positions ParticleDat. It is assumed that the simulation domain is convex.

This function is used by adding particles with ParticleGroup.add_particles_local on each rank then collectively calling this function.

Parameters:
  • particle_groupParticleGroup to initialise by moving particles to the positions in the position ParticleDat.

  • num_steps – optional number of steps to move particles over.

template<typename RNG>
inline std::vector<std::vector<double>> uniform_within_extents(
const int N,
const int ndim,
const double *extents,
RNG &rng
)#

Create a uniform distribution of particle positions within a set of extents.

Parameters:
  • N – Number of points to generate.

  • ndim – Number of dimensions.

  • extents – Extent of each of the dimensions.

  • rng – RNG to use.

Returns:

(N)x(ndim) set of positions stored for each column.

template<typename RNG>
inline std::vector<std::vector<double>> normal_distribution(
const int N,
const int ndim,
const double mu,
const double sigma,
RNG &rng
)#

Create (N)x(ndim) set of samples from a Gaussian distribution.

Parameters:
  • N – Number of points to generate.

  • ndim – Number of dimensions.

  • mu – Mean to use for Gaussian distribution.

  • sigma – Sigma to use for Gaussian distribution.

  • rng – RNG to use.

Returns:

(N)x(ndim) set of samples stored per column.

std::vector<std::vector<double>> uniform_within_extents(
const int N,
const int ndim,
const double *extents
)#

Create a uniform distribution of particle positions within a set of extents.

Parameters:
  • N – Number of points to generate.

  • ndim – Number of dimensions.

  • extents – Extent of each of the dimensions.

Returns:

(N)x(ndim) set of positions stored for each column.

std::vector<std::vector<double>> normal_distribution(
const int N,
const int ndim,
const double mu,
const double sigma
)#

Create (N)x(ndim) set of samples from a Gaussian distribution.

Parameters:
  • N – Number of points to generate.

  • ndim – Number of dimensions.

  • mu – Mean to use for Gaussian distribution.

  • sigma – Sigma to use for Gaussian distribution.

Returns:

(N)x(ndim) set of samples stored per column.

template<typename GROUP_TYPE>
inline INT get_npart_global(
std::shared_ptr<GROUP_TYPE> particle_group
)#

Get the total number of particles. This method must be called collectively on the communicator.

Parameters:

particle_groupParticleGroup or ParticleSubGroup to sum local particle counts of.

Returns:

Global particle count.

Domain#

The Domain is where particles exist.

class Domain#
#include <domain.hpp>

A domain wraps a mesh with a method to map particles into cells on that mesh. This allows there to be multiple different methods for binning particles into cells for each mesh type. Typically shared pointers to Domains are used to construct ParticleGroups.

Public Functions

inline Domain(
HMeshSharedPtr mesh,
LocalMapperSharedPtr local_mapper = DummyLocalMapper()
)#

Construct a new Domain.

Parameters:
  • mesh – HMesh derived mesh object.

  • local_mapper – Object to map particle positions into mesh cells.

Public Members

HMeshSharedPtr mesh#

HMesh derived mesh instance.

LocalMapperSharedPtr local_mapper#

LocalMapper derived class instance to bin particles into mesh cells.

ParticleGroup#

The ParticleGroup is the main container for particles.

class ParticleGroup#
#include <particle_group.hpp>

Fundamentally a ParticleGroup is a collection of ParticleDats, domain and a compute device. This is the main container for particles.

Public Functions

ParticleGroup(const ParticleGroup &st) = delete#

Disable (implicit) copies.

ParticleGroup &operator=(ParticleGroup const &a) = delete#

Disable (implicit) copies.

inline void free()#

Used to be required to be called. Kept to not break API.

ParticleGroup(
DomainSharedPtr domain,
ParticleSpec &particle_spec,
SYCLTargetSharedPtr sycl_target,
const bool is_temporary
)#

Construct a new ParticleGroup.

Parameters:
  • domainDomain instance containing these particles.

  • particle_specParticleSpec that describes the ParticleDat instances required.

  • sycl_target – SYCLTargetSharedPtr to use as compute device.

  • is_temporary – The constructed ParticleGroup is a short lived temporary.

inline ParticleGroup(
DomainSharedPtr domain,
ParticleSpec &particle_spec,
SYCLTargetSharedPtr sycl_target
)#

Construct a new ParticleGroup.

Parameters:
  • domainDomain instance containing these particles.

  • particle_specParticleSpec that describes the ParticleDat instances required.

  • sycl_target – SYCLTargetSharedPtr to use as compute device.

void add_particle_dat(ParticleDatSharedPtr<REAL> particle_dat)#

Add a ParticleDat to the ParticleGroup after construction.

Parameters:

particle_dat – New ParticleDat to add.

void add_particle_dat(ParticleDatSharedPtr<INT> particle_dat)#

Add a ParticleDat to the ParticleGroup after construction.

Parameters:

particle_dat – New ParticleDat to add.

void add_particle_dat(const Sym<REAL> sym, const int ncomp)#

Add a new ParticleDat by specifying the Sym and number of components.

Parameters:
  • symSym<REAL> for new ParticleDat.

  • ncomp – Number of components for the new ParticleDat.

void add_particle_dat(const Sym<INT> sym, const int ncomp)#

Add a new ParticleDat by specifying the Sym and number of components.

Parameters:
  • symSym<INT> for new ParticleDat.

  • ncomp – Number of components for the new ParticleDat.

inline void add_particles()#

Add particles to the ParticleGroup. Any rank may add particles that exist anywhere in the domain. This call is collective across the ParticleGroup and ranks that do not add particles should not pass any new particle data.

template<typename U>
inline void add_particles(U particle_data)#

Add particles to the ParticleGroup. Any rank may add particles that exist anywhere in the domain. This call is collective across the ParticleGroup and ranks that do not add particles should not pass any new particle data.

Parameters:

particle_data – New particle data to add to the ParticleGroup.

void add_particles_local(ParticleSet &particle_data)#

Add particles only to this MPI rank. It is assumed that the added particles are in the domain region owned by this MPI rank. If not, see ParticleGroup::add_particles.

Parameters:

particle_data – New particles to add.

void add_particles_local(ParticleSetSharedPtr particle_data)#

Add particles only to this MPI rank. It is assumed that the added particles are in the domain region owned by this MPI rank. If not, see ParticleGroup::add_particles.

Parameters:

particle_data – New particles to add.

void add_particles_local(
std::shared_ptr<ProductMatrix> product_matrix
)#

Add particles only to this MPI rank. It is assumed that the added particles are in the domain region owned by this MPI rank. If not, see ParticleGroup::add_particles. Particle properties which exist on the ParticleGroup and not in the ProductMatrix will be zero initialised. Particle properties which exist on the ProductMatrix and not in the ParticleGroup will be ignored.

Parameters:

product_matrix – New particles to add.

void add_particles_local(
std::shared_ptr<DescendantProducts> descendant_products,
std::shared_ptr<ParticleGroup> source_particle_group = nullptr
)#

Add new particles to this ParticleGroup via a DescendantProducts instance. If no alternative source ParticleGroup is provided then properties are either defined in the DescendantProducts, from which they are copied, or if the property is not defined in the DescendantProducts then the property values are copied from the parent particle.

When a source ParticleGroup is provided: Properties which are defined in the DescendantProducts are copied from the DescendantProducts. If a property is defined in the source ParticleGroup and not in this ParticleGroup then it is ignored. If a property is defined in this ParticleGroup and not in the source ParticleGroup then the values are zero initialised. Properties not defined in the DescendantProducts which exist as particle properties in both the source ParticleGroup and this ParticleGroup are copied from the parent particles. When the source ParticleGroup is specified the parent indices in DescendantProducts always refer to particles in the parent ParticleGroup.

Parameters:
  • descendant_products – New particles to add.

  • source_particle_group – Alternative ParticleGroup to use as the set of parent particles. The descendant_products parent indices must have been created with this ParticleGroup. By default no alternative ParticleGroup is specified and the parents are assumed to be in the ParticleGroup on which add_particles_local was called.

void add_particles_local(
std::shared_ptr<ParticleGroup> particle_group
)#

Add particles to this ParticleGroup from another ParticleGroup. Properties which exist in the destination ParticleGroup and not the source ParticleGroup are zero initialised. Properties which exist in both ParticleGroups are copied. Properties which only exist in the source ParticleGroup are ignored.

Particle properties will be copied cell-wise from the source to destination ParticleGroups. This cell-wise copy requires that the source and destination domains share the same number of cells on each MPI rank.

Parameters:

particle_group – New particles to add.

void add_particles_local(
std::shared_ptr<ParticleSubGroup> particle_sub_group
)#

Add particles to this ParticleGroup from another ParticleGroup. Properties which exist in the destination ParticleGroup and not the source ParticleGroup are zero initialised. Properties which exist in both ParticleGroups are copied. Properties which only exist in the source ParticleGroup are ignored.

Particle properties will be copied cell-wise from the source to destination ParticleGroups. This cell-wise copy requires that the source and destination domains share the same number of cells on each MPI rank.

Parameters:

particle_sub_group – New particles to add.

inline INT get_npart_local()#

Get the total number of particles on this MPI rank.

Returns:

Local particle count.

bool contains_dat(Sym<REAL> sym)#

Determine if the ParticleGroup contains a ParticleDat of a given name.

Parameters:

sym – Symbol of ParticleDat.

Returns:

True if ParticleDat exists on this ParticleGroup.

bool contains_dat(Sym<INT> sym)#

Determine if the ParticleGroup contains a ParticleDat of a given name.

Parameters:

sym – Symbol of ParticleDat.

Returns:

True if ParticleDat exists on this ParticleGroup.

bool contains_dat(Sym<REAL> sym, const int ncomp)#

Determine if the ParticleGroup contains a ParticleDat with a given sym and number of components.

Parameters:
  • symSym<REAL> or Sym<INT> to check existence of.

  • ncomp – Number of components the dat should have.

Returns:

True if a dat with the specified number of components is held.

bool contains_dat(Sym<INT> sym, const int ncomp)#

Determine if the ParticleGroup contains a ParticleDat with a given sym and number of components.

Parameters:
  • symSym<REAL> or Sym<INT> to check existence of.

  • ncomp – Number of components the dat should have.

Returns:

True if a dat with the specified number of components is held.

ParticleDatSharedPtr<REAL> get_dat(
Sym<REAL> sym,
const bool check_exists = true
)#

ParticleGroup::get_dat(Sym<REAL>(“POS”)) for a real valued ParticleDat.

Parameters:
  • symSym of ParticleDat to retrieve.

  • check_exists – Check if the dat exists, default true.

Returns:

ParticleDatSharedPtr<T> particle dat.

ParticleDatSharedPtr<INT> get_dat(
Sym<INT> sym,
const bool check_exists = true
)#

ParticleGroup::get_dat(Sym<REAL>(“POS”)) for a real valued ParticleDat.

Parameters:
  • symSym of ParticleDat to retrieve.

  • check_exists – Check if the dat exists, default true.

Returns:

ParticleDatSharedPtr<T> particle dat.

ParticleDatSharedPtr<REAL> &operator[](Sym<REAL> sym)#

Users are recomended to use “get_dat” instead. Enables access to the ParticleDat instances using the subscript operators.

Parameters:

symSym<REAL> of ParticleDat to access.

ParticleDatSharedPtr<INT> &operator[](Sym<INT> sym)#

Users are recomended to use “get_dat” instead. Enables access to the ParticleDat instances using the subscript operators.

Parameters:

symSym<INT> of ParticleDat to access.

CellData<REAL> get_cell(Sym<REAL> sym, const int cell)#

Get a CellData instance that holds all the particle data for a ParticleDat for a cell.

Parameters:
  • symSym<REAL> indicating which ParticleDat to access.

  • cell – Cell index to access.

Returns:

CellData for requested cell.

CellData<INT> get_cell(Sym<INT> sym, const int cell)#

Get a CellData instance that holds all the particle data for a ParticleDat for a cell.

Parameters:
  • symSym<INT> indicating which ParticleDat to access.

  • cell – Cell index to access.

Returns:

CellData for requested cell.

void clear()#

Clear all particles from the ParticleGroup on the calling MPI rank.

void remove_particles(
const int npart,
const std::vector<INT> &cells,
const std::vector<INT> &layers
)#

Remove particles from the ParticleGroup.

Parameters:
  • npart – Number of particles to remove.

  • cells – Vector of particle cells.

  • layers – Vector of particle layers(rows).

template<typename T>
inline void remove_particles(
const int npart,
T *usm_cells,
T *usm_layers
)#

Remove particles from the ParticleGroup.

Parameters:
  • npart – Number of particles to remove.

  • usm_cells – Device accessible array of particle cells.

  • usm_layers – Device accessible array of particle layers(rows).

void remove_particles(
std::shared_ptr<ParticleSubGroup> particle_sub_group
)#

Remove all the particles particles from the ParticleGroup which are members of a ParticleSubGroup.

Parameters:

particle_sub_group – Description of particles to remove.

inline INT get_npart_cell(const int cell)#

Get the number of particles in a cell.

Parameters:

cell – Cell to query.

Returns:

Number of particles in queried cell.

inline ParticleSpec &get_particle_spec()#

Get the ParticleSpec of the ParticleDats stored in this ParticleGroup.

Returns:

ParticleSpec of stored particles.

void global_move()#

Use the MPI ranks in the first component of the MPI rank dat to move particles globally using the MeshHierarchy of the mesh in the domain.

Must be called collectively on the ParticleGroup.

void local_move()#

Use the MPI ranks in the second component of the MPI rank dat to move particles to neighbouring ranks using the neighbouring ranks defined on the mesh.

Must be called collectively on the ParticleGroup.

void hybrid_move()#

Perform a global move using non-negative MPI ranks in the first component of the MPI rank dat. Then bin moved particles into local cells to obtain any required ranks for the local move. Second perform a local move to move particles based on the MPI rank stored in the second component of the MPI rank dat.

Must be called collectively on the ParticleGroup.

size_t particle_size()#

Number of bytes required to store the data for one particle.

Returns:

Number of bytes required to store one particle.

void cell_move()#

Move particles between cells using the cell ids stored in the cell id dat.

void set_npart_cell_from_dat()#

Copy the particle counts per cell from the position ParticleDat to the npart cell array of the ParticleGroup.

void print(std::ostream &os, SymStore print_spec)#

Print particle data for all particles for the specified ParticleDats. Empty cells are not printed.

Parameters:
  • os – Output stream to print to.

  • print_specSymStore of data to print.

template<typename ...T>
inline void print(
std::ostream &os,
T&&... args
)#

Print particle data for all particles for the specified ParticleDats. Empty cells are not printed.

Parameters:
  • os – Output stream to print to.

  • argsSym<REAL> or Sym<INT> instances that indicate which particle data to print.

template<typename ...T>
inline void print(
std::ofstream &os,
T&&... args
)#

Print particle data for all particles for the specified ParticleDats. Empty cells are not printed.

Parameters:
  • os – Output stream to print to.

  • argsSym<REAL> or Sym<INT> instances that indicate which particle data to print.

template<typename ...T>
inline void print(T&&... args)#

Print particle data for all particles for the specified ParticleDats. Empty cells are not printed.

Parameters:

argsSym<REAL> or Sym<INT> instances that indicate which particle data to print.

void print(SymStore print_spec)#

Print particle data for all particles for the specified ParticleDats. Empty cells are not printed.

Parameters:

print_specSymStore of data to print.

void print_particle(
std::ostream &os,
const int cell,
const int layer
)#

Print all particle data for a particle.

Parameters:
  • os – Output stream to print to.

  • cell – Cell of particle.

  • layer – Layer of particle.

void print_particle(const int cell, const int layer)#

Print all particle data for a particle.

Parameters:
  • cell – Cell of particle.

  • layer – Layer of particle.

void remove_particle_dat(Sym<REAL> sym)#

Remove a ParticleDat from the ParticleGroup

Parameters:

symSym object that refers to a ParticleDat

void remove_particle_dat(Sym<INT> sym)#

Remove a ParticleDat from the ParticleGroup

Parameters:

symSym object that refers to a ParticleDat

ParticleSetSharedPtr get_particles(
std::vector<INT> &cells,
std::vector<INT> &layers
)#

Create a ParticleSet containing the data from particles held in the ParticleGroup. e.g. to Extract the first two particles from the second cell:

cells = [1, 1] layers = [0, 1]

Parameters:
  • cells – Vector of cell indices of particles to extract.

  • layers – Vector of layer indices of particles to extract.

Returns:

ParticleSet of particle data.

Public Members

DomainSharedPtr domain#

Domain this instance is defined over.

SYCLTargetSharedPtr sycl_target#

Compute device used by the instance.

std::map<Sym<REAL>, ParticleDatSharedPtr<REAL>> particle_dats_real = {}#

Map from Sym instances to REAL valued ParticleDat instances.

std::map<Sym<INT>, ParticleDatSharedPtr<INT>> particle_dats_int = {}#

Map from Sym instances to INT valued ParticleDat instances.

std::shared_ptr<Sym<REAL>> position_sym#

Sym of ParticleDat storing particle positions.

ParticleDatSharedPtr<REAL> position_dat#

ParticleDat storing particle positions.

std::shared_ptr<Sym<INT>> cell_id_sym#

Sym of ParticleDat storing particle cell ids.

ParticleDatSharedPtr<INT> cell_id_dat#

ParticleDat storing particle cell ids.

std::shared_ptr<Sym<INT>> mpi_rank_sym#

Sym of ParticleDat storing particle MPI ranks.

ParticleDatSharedPtr<INT> mpi_rank_dat#

ParticleDat storing particle MPI ranks.

ParticleSpec particle_spec#

ParticleSpec of all the ParticleDats of this ParticleGroup.

LayerCompressor layer_compressor#

Layer compression instance for dats when particles are removed from cells.

Advanced#

More advanced components of the core library.

template<typename GROUP_TYPE>
inline void get_vtk_trajectory_line(
std::shared_ptr<GROUP_TYPE> particle_sub_group,
Sym<REAL> sym_start,
Sym<REAL> sym_end,
std::vector<VTK::UnstructuredCell> &trajectory
)#

Get VTK representation of the trajectory between two particle positions. This function is not efficient and is for debugging.

Parameters:
  • particle_sub_group[in] Particle{Sub}Group of particles.

  • sym_start[in] Sym that determines start of the trajectory.

  • sym_end[in] Sym that determines end of the trajectory.

  • trajectory[inout] Output trajectory.

class ParticleGroupTemporary#
#include <particle_group_temporary.hpp>

Container to efficiently create and store temporary ParticleGroup instances that have the same properties as a source ParticleGroup.

Public Functions

ParticleGroupSharedPtr get(
const ParticleGroupSharedPtr &particle_group
)#

Get a temporary ParticleGroup containing zero particles with the same SYCLTarget, Domain and particle properties as a source ParticleGroup. This function is collective on the communicator of the ParticleGroup.

Parameters:

particle_group – Source ParticleGroup which specifies the temporary returned ParticleGroup. This source ParticleGroup is unmodified.

Returns:

A temporary ParticleGroup. ParticleGroupTemporary::restore must be called with the original source ParticleGroup and the temporary ParticleGroup that this function returns.

void restore(
const ParticleGroupSharedPtr &particle_group,
ParticleGroupSharedPtr &temporary_particle_group
)#

Return a previously provided temporary ParticleGroup. This method must be called for all ParticleGroups which were provided by this class. This method is collective on the communicator of the ParticleGroup.

Parameters:
class VTKMeshHierarchyCellsWriter#
#include <utility_mesh_hierarchy_plotting.hpp>

Class to write MeshHierarchy cells to a vtk file as a collection of vertices and edges for visualisation in Paraview.

Public Functions

inline VTKMeshHierarchyCellsWriter(
std::shared_ptr<MeshHierarchy> mesh_hierarchy
)#

Create new instance of the writer.

Parameters:

mesh_hierarchy[in] MeshHierarchy instance to use as source for cells.

void push_back(const INT linear_index)#

Add a cell to the list of cells to be written to the output file.

Parameters:

linear_index[in] Index of cell.

void write(std::string filename)#

Write the output vtk file.

Parameters:

filename[in] Filename to write output to. Should end in .vtk.

void write_all_fine(std::string filename)#

Write all fine cells to the output file.

Parameters:

filename – Filename to write fine cells to.

void write_all_coarse(std::string filename)#

Write all coarse cells to the output file.

Parameters:

filename – Filename to write fine cells to.

IO#

Components for reading data from and writing particle data to files.

class H5Part#
#include <particle_io.hpp>

Read and write implementation of H5Part. This implementation is only available when the library is installed with HDF5 support.

Public Functions

H5Part(const H5Part &st) = delete#

Disable (implicit) copies.

H5Part &operator=(H5Part const &a) = delete#

Disable (implicit) copies.

inline H5Part(
std::string filename,
ParticleGroupSharedPtr particle_group,
SymStore syms
)#

Construct a H5Part writer for a given set of ParticleDats described by Sym<type>(name) instances. Must be called collectively on the communicator.

Parameters:
  • filename – Output filename, e.g. “foo.h5part”.

  • particle_group – ParticleGroupSharedPtr instance.

  • symsSymStore containing Sym<REAL> and Sym<INT> instances.

template<typename ...T>
inline H5Part(
std::string filename,
ParticleGroupSharedPtr particle_group,
T... args
)#

Construct a H5Part writer for a given set of ParticleDats described by Sym<type>(name) instances. Must be called collectively on the communicator.

Parameters:
  • filename – Output filename, e.g. “foo.h5part”.

  • particle_group – ParticleGroupSharedPtr instance.

  • args – Remaining arguments (variable length) should be sym instances indicating which ParticleDats are to be written.

template<typename ...T>
inline H5Part(
std::string filename,
ParticleSubGroupSharedPtr particle_sub_group,
T&&... args
)#

Construct a H5Part writer for a given set of ParticleDats described by Sym<type>(name) instances. Must be called collectively on the communicator.

Parameters:
  • filename – Output filename, e.g. “foo.h5part”.

  • particle_sub_group – ParticleSubGroupSharedPtr instance.

  • args – Remaining arguments (variable length) should be sym instances indicating which ParticleDats are to be written.

template<typename ...T>
inline H5Part(
std::string filename,
ParticleSubGroupSharedPtr particle_sub_group,
T... args
)#

Construct a H5Part writer for a given set of ParticleDats described by Sym<type>(name) instances. Must be called collectively on the communicator.

Parameters:
  • filename – Output filename, e.g. “foo.h5part”.

  • particle_sub_group – ParticleSubGroupSharedPtr instance.

  • args – Remaining arguments (variable length) should be sym instances indicating which ParticleDats are to be written.

inline void close()#

Close the H5Part writer. Must be called. Must be called collectively on the communicator.

inline void write(INT step_in = -1)#

Write the current particle data to the HDF5 file as a new time step. Must be called collectively on the communicator.

inline void set_rescale_coefficient(
Sym<REAL> sym,
const REAL value
)#

Set a rescale coefficient for a Sym. Particle data is multiplied by this coefficient before writing to the HDF5 file.

Parameters:
  • symSym for ParticleDat to set coefficient for.

  • value – Value of coefficient to set.

inline void set_rescale_coefficient(Sym<INT> sym, const INT value)#

Set a rescale coefficient for a Sym. Particle data is multiplied by this coefficient before writing to the HDF5 file.

Parameters:
  • symSym for ParticleDat to set coefficient for.

  • value – Value of coefficient to set.

inline ParticleSetSharedPtr read(
ParticleSpec &particle_spec,
INT step,
const bool use_xyz_positions
)#

Reads particle properties from the h5part file. Must be called collectively on the communicator.

Parameters:
  • particle_spec – Defines which properties should be read from the file by specifying the Sym and number of components.

  • step – Specify which time step to read from the h5part file.

  • use_xyz_positions – If set to true then the particle property with a Sym<REAL> and positions=true can be populated from the x,y,z entries of the h5part file.

Returns:

ParticleSet containing the values read from the h5part file on this MPI rank.

Particle Data#

Containers for particle data and describing particle data.

class ParticleSet#
#include <particle_set.hpp>

Container to hold particle data for a set of particles on the host. For example to stage particle data before it is added to a ParticleGroup.

Public Functions

ParticleSet(const int npart, ParticleSpec particle_spec)#

Constructor for a set of particles.

Parameters:
  • npart – Number of particles required.

  • particle_specParticleSpec instance that describes the particle properties.

ColumnMajorRowAccessor<std::vector, REAL> operator[](
Sym<REAL> sym
)#

Access the std::vectors that correspond to a Sym<REAL>.

ColumnMajorRowAccessor<std::vector, INT> operator[](Sym<INT> sym)#

Access the std::vectors that correspond to a Sym<INT>.

REAL &at(
Sym<REAL> sym,
const int particle_index,
const int component_index
)#

Access REAL elements for a particle.

Parameters:
  • symSym of particle property to access.

  • particle_index – Index of particle to access.

  • component_index – Index of component to access.

Returns:

modifiable reference to element.

INT &at(
Sym<INT> sym,
const int particle_index,
const int component_index
)#

Access REAL elements for a particle.

Parameters:
  • symSym of particle property to access.

  • particle_index – Index of particle to access.

  • component_index – Index of component to access.

Returns:

modifiable reference to element.

std::vector<REAL> &get(Sym<REAL> const &sym)#

Get the vector of values describing the particle data for a given Sym<REAL>. Will return an empty std::vector if the passed Sym is not a stored property.

Parameters:

symSym<REAL> to access.

Returns:

std::vector of data or empty std::vector.

std::vector<INT> &get(Sym<INT> const &sym)#

Get the vector of values describing the particle data for a given Sym<INT>. Will return an empty std::vector if the passed Sym is not a stored property.

Parameters:

symSym<INT> to access.

Returns:

std::vector of data or empty std::vector.

bool contains(Sym<REAL> const &sym)#

Test to see if this ParticleSet contains data for a given Sym<REAL>

Parameters:

symSym<REAL> to test for.

Returns:

Bool indicating if data exists.

bool contains(Sym<INT> const &sym)#

Test to see if this ParticleSet contains data for a given Sym<INT>

Parameters:

symSym<INT> to test for.

Returns:

Bool indicating if data exists.

void set(
Sym<INT> sym,
const int component,
std::vector<INT> &values
)#

Set all values of a Sym from a std::vector.

Parameters:
  • symSym to set values for.

  • component – Component to set values for.

  • values – Vector of values to set.

void set(
Sym<REAL> sym,
const int component,
std::vector<REAL> &values
)#

Set all values of a Sym from a std::vector.

Parameters:
  • symSym to set values for.

  • component – Component to set values for.

  • values – Vector of values to set.

void set(ParticleSet &particle_set)#

Set all values in this ParticleSet from a another ParticleSet. This will copy the values from the intersection of the properties defined in this ParticleSet and the properties defined in the provided ParticleSet. Component counts must agree between the ParticleSets. The number of particles in the provided ParticleSet must be the same as this ParticleSet.

Parameters:

particle_setParticleSet to copy values from.

void set(std::shared_ptr<ParticleSet> particle_set)#

Set all values in this ParticleSet from a another ParticleSet. This will copy the values from the intersection of the properties defined in this ParticleSet and the properties defined in the provided ParticleSet. Component counts must agree between the ParticleSets. The number of particles in the provided ParticleSet must be the same as this ParticleSet.

Parameters:

particle_setParticleSet to copy values from.

Public Members

const int npart#

Number of particles stored in the container.

template<typename U>
class Sym#
#include <particle_spec.hpp>

Symbol describing a type of data and a name.

Public Functions

inline Sym(const std::string name)#

Construct a new Sym object.

Parameters:

name – Name of new symbol.

inline bool operator<(const Sym &sym) const#

Comparison of Sym types.

std::map uses std::less as default comparison operator

Parameters:

sym – Other Sym to compare against.

Public Members

std::string name#

Name of the symbol.

template<typename T>
class ParticleProp#
#include <particle_spec.hpp>

Class to describe a property of a particle.

Public Functions

inline ParticleProp(
const Sym<T> sym,
int ncomp,
bool positions = false
)#

Constructor for particle properties.

Parameters:
  • symSym<T> instance for the property.

  • ncomp – Number of components for the property.

  • positions – Bool to indicate if the property hold positions or cells ids.

Public Members

Sym<T> sym#

Symbol giving a label to the property.

std::string name#

Name of the property.

int ncomp#

Number of components required by this property.

bool positions#

Bool to indicate if this property is a particle position or cell id.

class ParticleSpec#
#include <particle_spec.hpp>

A ParticleSpec is a particle specification described by a collection of particle properties.

Public Functions

inline int get_max_ncomp_int()#
Returns:

The maximum number of components of INT properties.

inline int get_max_ncomp_real()#
Returns:

The maximum number of components of REAL properties.

template<typename ...T>
inline ParticleSpec(T... args)#

Constructor to create a particle specification.

Parameters:

argsParticleSpec is called with a set of ParticleProp arguments.

inline ParticleSpec(
std::vector<ParticleProp<REAL>> &properties_real,
std::vector<ParticleProp<INT>> &properties_int
)#

Create a particle specification from a vector of REAL properties and a vector of INT properties.

Parameters:
  • properties_real – REAL particle properties.

  • properties_int – INT particle properties.

inline void push(ParticleProp<REAL> pp)#

Push a ParticleProp<REAL> property onto the specification.

Parameters:

pp – ParticleProp<REAL> to add to the specification.

inline void push(ParticleProp<INT> pp)#

Push a ParticleProp<INT> property onto the specification.

Parameters:

pp – ParticleProp<INT> to add to the specification.

template<typename T>
inline bool contains(ParticleProp<T> pp)#

Determine if a ParticleProp is contained in this specification.

Parameters:

ppParticleProp to search for.

Returns:

True if passed ParticleProp is in this ParticleSpec.

inline bool contains(ParticleSpec &ps)#

Determine if a passed ParticleSpec is a subset of this ParticleSpec.

Parameters:

psParticleSpec to compare with.

Returns:

True if the passed particle spec is a subset of this particle spec.

template<typename T>
inline void remove(ParticleProp<T> pp)#

Remove a particle property from the specification.

Parameters:

ppParticleProp to remove from the specification.

Public Members

std::vector<ParticleProp<REAL>> properties_real#

Collection of REAL ParticleProp.

std::vector<ParticleProp<INT>> properties_int#

Collection of INT ParticleProp.

class SymStore#
#include <particle_spec.hpp>

Helper class to hold a collection of Sym instances for ParticleGroup::print.

Public Functions

template<typename ...T>
inline SymStore(T&&... args)#

Constructor for SymStore should be called with a list of arguments which are Sym instances.

Parameters:

args – Passed arguments should be Sym<REAL>, std::vector<Sym<REAL>>, Sym<INT> or std::vector<Sym<INT>>.

inline SymStore(SymStore &sym_store)#
Parameters:

sym_storeSymStore to copy.

inline SymStore(ParticleSpec &particle_spec)#
Parameters:

particle_specParticleSpec instance to create SymStore from.

inline void push(Sym<REAL> sym)#

Push Sym into store.

Parameters:

symSym to push into the store.

inline void push(Sym<INT> sym)#

Push Sym into store.

Parameters:

symSym to push into the store.

inline bool contains(Sym<REAL> sym)#
Parameters:

symSym to test existance of.

Returns:

True if sym is in the SymStore.

inline bool contains(Sym<INT> sym)#
Parameters:

symSym to test existance of.

Returns:

True if sym is in the SymStore.

Public Members

std::vector<Sym<REAL>> syms_real#

Container of Sym<REAL> symbols.

std::vector<Sym<INT>> syms_int#

Container of Sym<INT> symbols.