Class ParticleCatalogue#
Defined in File particles.hpp
Class Documentation#
-
class ParticleCatalogue#
Particle catalogue.
The catalogue object contains particle data and summary information, as well as methods for computing its attributes.
Public Functions
-
explicit ParticleCatalogue(int verbose = -1)#
Construct the particle catalogue with initial values.
Note
verboseis optional and used to control the logging level when an instance is created as a standalone withoutParameterSet.- Parameters:
verbose – Logger verbosity (default is -1 for no change).
-
~ParticleCatalogue()#
Destruct the particle catalogue.
-
void initialise_particles(const int num)#
Initialise particle data container.
- Attention
This method does not set the values of trv::ParticleCatalogue::pdata, trv::ParticleCatalogue::wtotal, trv::ParticleCatalogue::wstotal, trv::ParticleCatalogue::pos_min or trv::ParticleCatalogue::pos_max, or trv::ParticleCatalogue::pos_span.
- Parameters:
num – Number of data units (i.e. particles).
-
void finalise_particles()#
Finalise particle data container.
-
void reset_particles()#
Reset particle data container.
This is an explicit method to free the resources occupied by trv::ParticleCatalogue::pdata and may be called outside the class destructor.
-
ParticleData &operator[](const int pid)#
Return individual particle information.
- Parameters:
pid – Particle index.
- Returns:
Individual particle data.
-
int load_catalogue_file(const std::string &catalogue_filepath, const std::string &catalogue_columns, const std::string &catalogue_dataset = "", double volume = 0.)#
Read in a catalogue file.
Note
If
catalogue_datasetis empty for HDF5 files, the first dataset found is used (which may not be the intended one).Note
If
catalogue_columnsis empty for HDF5 files, the first dataset attribute found is used (which may not be the intended one).- Parameters:
catalogue_filepath – Catalogue file path.
catalogue_columns – Catalogue data column names (as a comma-separated list without space or an attribute name prefixed by “attr:”).
catalogue_dataset – Catalogue dataset name/path (default is empty; for HDF5 files only).
volume – Catalogue volume (default is 0.) used for computing the default ‘nz’ value when the field is missing.
- Returns:
Exit status.
-
int load_particle_data(std::vector<double> x, std::vector<double> y, std::vector<double> z, std::vector<double> nz, std::vector<double> ws, std::vector<double> wc)#
Read in particle data.
- Parameters:
x, y, z, nz, ws, wc – Particle data by column.
- Returns:
Exit status.
-
void calc_total_weights()#
Calculate total overall weight of particles.
- Attention
This method resets trv::ParticleCatalogue::wtotal and trv::ParticleCatalogue::wstotal.
-
void calc_pos_extents(bool init = true)#
Calculate the extents of particle positions.
- Attention
This method resets trv::ParticleCatalogue::pos_min, trv::ParticleCatalogue::pos_max and trv::ParticleCatalogue::pos_span.
- Parameters:
init – Initialisation flag (default is
true).
-
void offset_coords(const double dpos[3])#
Offset particle positions by a given vector.
The position specified by the input vector is the new origin.
- Parameters:
dpos – (Subtractive) offset position vector.
-
void offset_coords_for_periodicity(const double boxsize[3])#
Offset particle positions for periodic boundary conditions.
- Parameters:
boxsize – Periodic box size in each dimension.
Public Members
-
std::string source#
catalogue source
-
ParticleData *pdata = nullptr#
particle data
-
int ntotal = 0#
total number of particles
-
double wtotal = 0.#
total overall weight of particles
-
double wstotal = 0.#
total sample weight of particles
-
double pos_min[3] = {0., 0., 0.}#
minimum particle coordinates
-
double pos_max[3] = {0., 0., 0.}#
maximum particle coordinates
-
double pos_span[3] = {0., 0., 0.}#
span of particle coordinates
Public Static Functions
-
static void centre_in_box(ParticleCatalogue &catalogue, const double boxsize[3])#
Centre a catalogue in a box.
- Parameters:
catalogue – Particle catalogue.
boxsize – Box size in each dimension.
-
static void centre_in_box(ParticleCatalogue &catalogue, ParticleCatalogue &catalogue_ref, const double boxsize[3])#
Centre a pair of catalogues in a box.
The secondary catalogue’s centre is used as the reference point to also offset the primary catalogue’s particle positions.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
catalogue – Primary particle catalogue.
catalogue_ref – Secondary reference particle catalogue.
boxsize – Box size in each dimension.
-
static void pad_in_box(ParticleCatalogue &catalogue, const double boxsize[3], const double boxsize_pad[3])#
Pad a catalogue in a box.
The amount of padding is a fraction of the box size.
- Parameters:
catalogue – Particle catalogue.
boxsize – Box size in each dimension.
boxsize_pad – Box size padding factor in each dimension.
-
static void pad_in_box(ParticleCatalogue &catalogue, ParticleCatalogue &catalogue_ref, const double boxsize[3], const double boxsize_pad[3])#
Pad a pair of catalogues in a box.
The amount of padding is a fraction of the box size.
The secondary catalogue’s extents are used as the reference points to also offset the primary catalogue’s particle positions.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
catalogue – Primary particle catalogue.
catalogue_ref – Secondary reference particle catalogue.
boxsize – Box size in each dimension.
boxsize_pad – Box size padding factor in each dimension.
-
static void pad_grids(ParticleCatalogue &catalogue, const double boxsize[3], const int ngrid[3], const double ngrid_pad[3])#
Pad a catalogue in a box.
The amount of padding is a multiple of the mesh grid size.
- Parameters:
catalogue – Particle catalogue.
boxsize – Box size in each dimension.
ngrid – Grid cell number in each dimension.
ngrid_pad – Grid cell number factor for padding.
-
static void pad_grids(ParticleCatalogue &catalogue, ParticleCatalogue &catalogue_ref, const double boxsize[3], const int ngrid[3], const double ngrid_pad[3])#
Pad a catalogue in a box.
The amount of padding is a multiple of the mesh grid size.
The secondary catalogue’s extents are used as the reference points to also offset the primary catalogue’s particle positions.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
catalogue – Primary particle catalogue.
catalogue_ref – Secondary reference particle catalogue.
boxsize – Box size in each dimension.
ngrid – Grid cell number in each dimension.
ngrid_pad – Grid cell number factor for padding.
-
explicit ParticleCatalogue(int verbose = -1)#