Triumvirate C++ API 0.5.0
Three-point clustering measurements in large-scale structure analyses.
Loading...
Searching...
No Matches
particles.hpp
Go to the documentation of this file.
1// Copyright (C) [GPLv3 Licence]
2//
3// This file is part of the Triumvirate program. See the COPYRIGHT
4// and LICENCE files at the top-level directory of this distribution
5// for details of copyright and licensing.
6//
7// This program is free software: you can redistribute it and/or modify it
8// under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15// See the GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program. If not, see <https://www.gnu.org/licenses/>.
19
32#ifndef TRIUMVIRATE_INCLUDE_PARTICLES_HPP_INCLUDED_
33#define TRIUMVIRATE_INCLUDE_PARTICLES_HPP_INCLUDED_
34
35#include <algorithm>
36#include <cmath>
37#include <cstddef>
38#include <cstdio>
39#include <fstream>
40#include <iterator>
41#include <sstream>
42#include <string>
43#include <vector>
44
45#include "monitor.hpp"
46
47namespace trv {
48
54 double pos[3];
55 double nz;
56 double ws;
57 double wc;
58 double w;
59};
60
69 public:
70 std::string source;
71
73
74 int ntotal;
75 double wtotal;
76 double wstotal;
77
78 double pos_min[3];
79 double pos_max[3];
80 double pos_span[3];
81
82 // ---------------------------------------------------------------------
83 // Life cycle
84 // ---------------------------------------------------------------------
85
95 explicit ParticleCatalogue(int verbose = -1);
96
101
115 void initialise_particles(const int num);
116
121 void finalise_particles();
122
130 void reset_particles();
131
132 // ---------------------------------------------------------------------
133 // Operators & reserved methods
134 // ---------------------------------------------------------------------
135
142 ParticleData& operator[](const int pid);
143
144 // ---------------------------------------------------------------------
145 // Data I/O
146 // ---------------------------------------------------------------------
147
159 const std::string& catalogue_filepath,
160 const std::string& catalogue_columns,
161 double volume = 0.
162 );
163
171 std::vector<double> x, std::vector<double> y, std::vector<double> z,
172 std::vector<double> nz, std::vector<double> ws, std::vector<double> wc
173 );
174
175 // ---------------------------------------------------------------------
176 // Catalogue properties
177 // ---------------------------------------------------------------------
178
185 void calc_total_weights();
186
196 void calc_pos_extents(bool init = true);
197
198 // ---------------------------------------------------------------------
199 // Catalogue operations
200 // ---------------------------------------------------------------------
201
209 void offset_coords(const double dpos[3]);
210
216 void offset_coords_for_periodicity(const double boxsize[3]);
217
224 static void centre_in_box(
225 ParticleCatalogue& catalogue,
226 const double boxsize[3]
227 );
228
241 static void centre_in_box(
242 ParticleCatalogue& catalogue, ParticleCatalogue& catalogue_ref,
243 const double boxsize[3]
244 );
245
255 static void pad_in_box(
256 ParticleCatalogue& catalogue,
257 const double boxsize[3], const double boxsize_pad[3]
258 );
259
275 static void pad_in_box(
276 ParticleCatalogue& catalogue, ParticleCatalogue& catalogue_ref,
277 const double boxsize[3], const double boxsize_pad[3]
278 );
279
290 static void pad_grids(
291 ParticleCatalogue& catalogue,
292 const double boxsize[3], const int ngrid[3], const double ngrid_pad[3]
293 );
294
311 static void pad_grids(
312 ParticleCatalogue& catalogue, ParticleCatalogue& catalogue_ref,
313 const double boxsize[3], const int ngrid[3], const double ngrid_pad[3]
314 );
315};
316
317} // namespace trv
318
319#endif // !TRIUMVIRATE_INCLUDE_PARTICLES_HPP_INCLUDED_
Particle catalogue.
Definition particles.hpp:68
void initialise_particles(const int num)
Initialise particle data container.
Definition particles.cpp:56
static void centre_in_box(ParticleCatalogue &catalogue, const double boxsize[3])
Centre a catalogue in a box.
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.
void calc_pos_extents(bool init=true)
Calculate the extents of particle positions.
~ParticleCatalogue()
Destruct the particle catalogue.
Definition particles.cpp:54
ParticleCatalogue(int verbose=-1)
Construct the particle catalogue with initial values.
Definition particles.cpp:37
std::string source
catalogue source
Definition particles.hpp:70
void reset_particles()
Reset particle data container.
Definition particles.cpp:81
void calc_total_weights()
Calculate total overall weight of particles.
ParticleData & operator[](const int pid)
Return individual particle information.
Definition particles.cpp:94
void offset_coords(const double dpos[3])
Offset particle positions by a given vector.
void finalise_particles()
Finalise particle data container.
Definition particles.cpp:77
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.
double pos_span[3]
span of particle coordinates
Definition particles.hpp:80
ParticleData * pdata
particle data
Definition particles.hpp:72
int load_catalogue_file(const std::string &catalogue_filepath, const std::string &catalogue_columns, double volume=0.)
Read in a catalogue file.
double pos_min[3]
minimum values of particle coordinates
Definition particles.hpp:78
int ntotal
total number of particles
Definition particles.hpp:74
void offset_coords_for_periodicity(const double boxsize[3])
Offset particle positions for periodic boundary conditions.
static void pad_in_box(ParticleCatalogue &catalogue, const double boxsize[3], const double boxsize_pad[3])
Pad a catalogue in a box.
double wtotal
total overall weight of particles
Definition particles.hpp:75
double wstotal
total sample weight of particles
Definition particles.hpp:76
double pos_max[3]
maximum values of particle coordinates
Definition particles.hpp:79
Provide tracking of program resources and exceptions.
Particle data container.
Definition particles.hpp:53
double pos[3]
particle position vector
Definition particles.hpp:54
double w
particle overall weight
Definition particles.hpp:58
double ws
particle sample weight
Definition particles.hpp:56
double nz
redshift-dependent expected number density
Definition particles.hpp:55
double wc
particle clustering weight
Definition particles.hpp:57