Triumvirate C++ API 0.5.0.post1.dev301+g026f21751
Three-point clustering measurements in large-scale structure analyses.
Loading...
Searching...
No Matches
particles.hpp
Go to the documentation of this file.
1// Triumvirate: Three-Point Clustering Measurements in LSS
2//
3// Copyright (C) 2023 Mike S Wang & Naonori S Sugiyama [GPL-3.0-or-later]
4//
5// This file is part of the Triumvirate program. See the COPYRIGHT
6// and LICENCE files at the top-level directory of this distribution
7// for details of copyright and licensing.
8//
9// This program is free software: you can redistribute it and/or modify it
10// under the terms of the GNU General Public License as published by
11// the Free Software Foundation, either version 3 of the License, or
12// (at your option) any later version.
13//
14// This program is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17// See the GNU General Public License for more details.
18//
19// You should have received a copy of the GNU General Public License
20// along with this program. If not, see <https://www.gnu.org/licenses/>.
21
33
34#ifndef TRIUMVIRATE_INCLUDE_PARTICLES_HPP_INCLUDED_
35#define TRIUMVIRATE_INCLUDE_PARTICLES_HPP_INCLUDED_
36
37#include <algorithm>
38#include <cmath>
39#include <cstddef>
40#include <cstdio>
41#include <fstream>
42#include <iterator>
43#include <sstream>
44#include <string>
45#include <vector>
46
47#include "monitor.hpp"
48
50#ifdef __GNUC__
51#define PURE __attribute__((pure))
52#else
53#define PURE
54#endif
56
57namespace trv {
58
64 double pos[3];
65 double nz;
66 double ws;
67 double wc;
68 double w;
69};
70
79 public:
80 std::string source;
81
82 ParticleData* pdata = nullptr;
83
84 int ntotal = 0;
85 double wtotal = 0.;
86 double wstotal = 0.;
87
88 double pos_min[3] = {0., 0., 0.};
89 double pos_max[3] = {0., 0., 0.};
90 double pos_span[3] = {0., 0., 0.};
91
92 // ---------------------------------------------------------------------
93 // Life cycle
94 // ---------------------------------------------------------------------
95
105 explicit ParticleCatalogue(int verbose = -1);
106
111
125 void initialise_particles(const int num);
126
131 void finalise_particles();
132
140 void reset_particles();
141
142 // ---------------------------------------------------------------------
143 // Operators & reserved methods
144 // ---------------------------------------------------------------------
145
152 PURE ParticleData& operator[](const int pid);
153
154 // ---------------------------------------------------------------------
155 // Data I/O
156 // ---------------------------------------------------------------------
157
177 const std::string& catalogue_filepath,
178 const std::string& catalogue_columns,
179 const std::string& catalogue_dataset = "",
180 double volume = 0.
181 );
182
190 std::vector<double> x, std::vector<double> y, std::vector<double> z,
191 std::vector<double> nz, std::vector<double> ws, std::vector<double> wc
192 );
193
194 // ---------------------------------------------------------------------
195 // Catalogue properties
196 // ---------------------------------------------------------------------
197
204 void calc_total_weights();
205
215 void calc_pos_extents(bool init = true);
216
217 // ---------------------------------------------------------------------
218 // Catalogue operations
219 // ---------------------------------------------------------------------
220
228 void offset_coords(const double dpos[3]);
229
235 void offset_coords_for_periodicity(const double boxsize[3]);
236
243 static void centre_in_box(
244 ParticleCatalogue& catalogue,
245 const double boxsize[3]
246 );
247
260 static void centre_in_box(
261 ParticleCatalogue& catalogue, ParticleCatalogue& catalogue_ref,
262 const double boxsize[3]
263 );
264
274 static void pad_in_box(
275 ParticleCatalogue& catalogue,
276 const double boxsize[3], const double boxsize_pad[3]
277 );
278
294 static void pad_in_box(
295 ParticleCatalogue& catalogue, ParticleCatalogue& catalogue_ref,
296 const double boxsize[3], const double boxsize_pad[3]
297 );
298
309 static void pad_grids(
310 ParticleCatalogue& catalogue,
311 const double boxsize[3], const int ngrid[3], const double ngrid_pad[3]
312 );
313
330 static void pad_grids(
331 ParticleCatalogue& catalogue, ParticleCatalogue& catalogue_ref,
332 const double boxsize[3], const int ngrid[3], const double ngrid_pad[3]
333 );
334};
335
336} // namespace trv
337
338#endif // !TRIUMVIRATE_INCLUDE_PARTICLES_HPP_INCLUDED_
Particle catalogue.
Definition particles.hpp:78
void initialise_particles(const int num)
Initialise particle data container.
Definition particles.cpp:47
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:45
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.
Definition particles.cpp:94
ParticleCatalogue(int verbose=-1)
Construct the particle catalogue with initial values.
Definition particles.cpp:39
std::string source
catalogue source
Definition particles.hpp:80
void reset_particles()
Reset particle data container.
Definition particles.cpp:72
void calc_total_weights()
Calculate total overall weight of particles.
ParticleData & operator[](const int pid)
Return individual particle information.
Definition particles.cpp:85
void offset_coords(const double dpos[3])
Offset particle positions by a given vector.
void finalise_particles()
Finalise particle data container.
Definition particles.cpp:68
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:90
ParticleData * pdata
particle data
Definition particles.hpp:82
double pos_min[3]
minimum particle coordinates
Definition particles.hpp:88
int ntotal
total number of particles
Definition particles.hpp:84
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:85
double wstotal
total sample weight of particles
Definition particles.hpp:86
double pos_max[3]
maximum particle coordinates
Definition particles.hpp:89
Provide tracking of program resources and exceptions.
Particle data container.
Definition particles.hpp:63
double pos[3]
particle position vector
Definition particles.hpp:64
double w
particle overall weight
Definition particles.hpp:68
double ws
particle sample weight
Definition particles.hpp:66
double nz
redshift-dependent expected number density
Definition particles.hpp:65
double wc
particle clustering weight
Definition particles.hpp:67