39#ifndef TRIUMVIRATE_INCLUDE_FIELD_HPP_INCLUDED_
40#define TRIUMVIRATE_INCLUDE_FIELD_HPP_INCLUDED_
42#if defined(TRV_USE_HIP)
43#include <hipfft/hipfftXt.h>
44#elif defined(TRV_USE_CUDA)
65#define PURE __attribute__((pure))
107 bool plan_ini =
true,
108 const std::string&
name =
"mesh-field"
126 fftw_plan& transform, fftw_plan& inv_transform,
127 const std::string&
name =
"mesh-field"
153 PURE
const fftw_complex&
operator[](
long long gid);
240 double alpha,
int ell,
int m
257 double alpha,
int ell,
int m
294 double alpha,
int ell,
int m
311 double alpha,
int ell,
int m
379 MeshField& field_fourier, std::vector< std::complex<double> >& ylm,
380 double k_band,
double dk_band,
381 double& k_eff,
int& nmodes
406 std::vector< std::complex<double> >& ylm,
430 std::vector<double> window;
432 int window_assign_order = -1;
435 fftw_complex* field_s =
nullptr;
438 fftw_plan transform{};
439 fftw_plan transform_s{};
440 fftw_plan inv_transform{};
441#if defined(TRV_USE_HIP) || defined(TRV_USE_CUDA)
442 fftHandle transform_gpu{};
446#if defined(TRV_USE_HIP) || defined(TRV_USE_CUDA)
447 fft_double_complex* d_field =
nullptr;
451 cudaLibXtDesc* field_desc =
nullptr;
456 cudaStream_t custream{};
459 bool plan_ini =
false;
460 bool plan_ext =
false;
474 PURE
long long ret_grid_index(
int i,
int j,
int k);
481 void shift_grid_indices_fourier(
int& i,
int& j,
int& k);
489 void get_grid_pos_vector(
int i,
int j,
int k,
double rvec[3]);
497 void get_grid_wavevector(
int i,
int j,
int k,
double kvec[3]);
510 void assign_weighted_field_to_mesh_ngp(
521 void assign_weighted_field_to_mesh_cic(
532 void assign_weighted_field_to_mesh_tsc(
543 void assign_weighted_field_to_mesh_pcs(
556 double calc_assignment_window_in_fourier(
int i,
int j,
int k,
int order = 0);
566 void compute_assignment_window_in_fourier(
int order = 0);
586 std::vector<double>
k;
587 std::vector<double>
r;
589 std::vector< std::complex<double> >
sn;
591 std::vector< std::complex<double> >
pk;
593 std::vector< std::complex<double> >
xi;
713 std::vector< std::complex<double> >& ylm_a,
714 std::vector< std::complex<double> >& ylm_b,
715 std::complex<double> shotnoise_amp,
758 std::vector< std::complex<double> >& ylm_a,
759 std::vector< std::complex<double> >& ylm_b,
762 std::complex<double> shotnoise_amp,
763 double k_a,
double k_b
784 fftw_plan inv_transform{};
785#if defined(TRV_USE_HIP) || defined(TRV_USE_CUDA)
786 fftHandle inv_transform_gpu{};
790 fftw_complex* twopt_3d =
nullptr;
791#if defined(TRV_USE_HIP) || defined(TRV_USE_CUDA)
792 fft_double_complex* d_twopt_3d =
nullptr;
796 cudaLibXtDesc* twopt_3d_desc =
nullptr;
801 cudaStream_t custream{};
805 bool plan_ini =
false;
808 std::vector<double> alias_sn;
811 bool alias_ini =
false;
824 PURE
bool if_fields_compatible(MeshField& field_a, MeshField& field_b);
831 void resize_stats(
int num_bins);
841 PURE
long long ret_grid_index(
int i,
int j,
int k);
850 void shift_grid_indices_fourier(
int& i,
int& j,
int&
k);
867 std::function<double(
int,
int,
int)> ret_calc_shotnoise_aliasing();
876 void get_shotnoise_aliasing_sin2(
877 int i,
int j,
int k,
double& sx2,
double& sy2,
double& sz2
887 void get_shotnoise_aliasing_sin2_cos2_isoapprox(
888 int i,
int j,
int k,
double& s2h,
double& c2h
898 double calc_shotnoise_aliasing_ngp(
int i,
int j,
int k);
907 double calc_shotnoise_aliasing_cic(
int i,
int j,
int k);
916 double calc_shotnoise_aliasing_tsc(
int i,
int j,
int k);
925 double calc_shotnoise_aliasing_pcs(
int i,
int j,
int k);
935 double calc_shotnoise_aliasing_interlaced_isoapprox(
936 int i,
int j,
int k,
int order
943 void compute_shotnoise_aliasing();
Isotropic coordinate binning.
std::vector< std::complex< double > > sn
shot-noise power in bins
void reset_stats()
Reset two-point statistics.
std::vector< std::complex< double > > pk
pseudo power spectrum in bins
void compute_uncoupled_shotnoise_for_3pcf(MeshField &field_a, MeshField &field_b, std::vector< std::complex< double > > &ylm_a, std::vector< std::complex< double > > &ylm_b, std::complex< double > shotnoise_amp, trv::Binning &rbinning)
Compute binned uncoupled three-point correlation function shot noise.
std::complex< double > compute_uncoupled_shotnoise_for_bispec_per_bin(MeshField &field_a, MeshField &field_b, std::vector< std::complex< double > > &ylm_a, std::vector< std::complex< double > > &ylm_b, trvm::SphericalBesselCalculator &sj_a, trvm::SphericalBesselCalculator &sj_b, std::complex< double > shotnoise_amp, double k_a, double k_b)
Compute unbinned uncoupled bispectrum shot noise on the FFT mesh grid.
~FieldStats()
Destruct two-point statistics.
std::vector< int > nmodes
number of wavevector modes in bins
FieldStats(trv::ParameterSet ¶ms, bool plan_ini=true)
Construct pseudo two-point statistics.
std::vector< double > k
average wavenumber in bins
std::vector< std::complex< double > > xi
pseudo two-point correlation function in bins
std::vector< int > npairs
number of separation pairs in bins
void compute_ylm_wgtd_2pt_stats_in_fourier(MeshField &field_a, MeshField &field_b, std::complex< double > shotnoise_amp, int ell, int m, trv::Binning &kbinning)
Compute binned two-point statistics in Fourier space.
trv::BinnedVectors record_binned_vectors(trv::Binning &binning, const std::string &save_file)
Record binned vectors given a binning scheme.
void compute_ylm_wgtd_2pt_stats_in_config(MeshField &field_a, MeshField &field_b, std::complex< double > shotnoise_amp, int ell, int m, trv::Binning &rbinning)
Compute binned two-point statistics in configuration space.
Discretely sampled field on a mesh grid from particle catalogues.
trv::ParameterSet params
parameter set
void inv_fourier_transform()
Inverse Fourier transform the (FFT-transformed) field.
void inv_fourier_transform_sjl_ylm_wgtd_field(MeshField &field_fourier, std::vector< std::complex< double > > &ylm, trvm::SphericalBesselCalculator &sjl, double r)
Inverse Fourier transform a field weighted by the spherical Bessel function and reduced spherical ha...
std::string name
field name
void assign_weighted_field_to_mesh(ParticleCatalogue &particles, fftw_complex *weights)
Assign a weighted field to a mesh by interpolation scheme.
double calc_grid_based_powlaw_norm(ParticleCatalogue &particles, int order)
void reset_density_field()
(Re-)initialise the complex field (and its shadow) on mesh.
void inv_fourier_transform_ylm_wgtd_field_band_limited(MeshField &field_fourier, std::vector< std::complex< double > > &ylm, double k_band, double dk_band, double &k_eff, int &nmodes)
Inverse Fourier transform a field weighted by the reduced spherical harmonics restricted to a wavenu...
double dr[3]
grid size in each dimension
void fourier_transform()
Fourier transform the field.
void compute_ylm_wgtd_field(ParticleCatalogue &particles_data, ParticleCatalogue &particles_rand, LineOfSight *los_data, LineOfSight *los_rand, double alpha, int ell, int m)
Compute the weighted field (fluctuations) further weighted by the reduced spherical harmonics.
void compute_unweighted_field(ParticleCatalogue &particles)
Compute the unweighted field.
void apply_wide_angle_pow_law_kernel()
Apply wide-angle correction kernel in configuration space.
void compute_ylm_wgtd_quad_field(ParticleCatalogue &particles_data, ParticleCatalogue &particles_rand, LineOfSight *los_data, LineOfSight *los_rand, double alpha, int ell, int m)
Compute the quadratic weighted field (fluctuations) further weighted by the reduced spherical harmoni...
fftw_complex * field
complex field on mesh
MeshField(trv::ParameterSet ¶ms, bool plan_ini=true, const std::string &name="mesh-field")
Construct the mesh field.
void compute_unweighted_field_fluctuations_insitu(ParticleCatalogue &particles)
Compute the unweighted field fluctuations.
double dk[3]
fundamental wavenumber in each dimension
~MeshField()
Destruct the mesh field.
double vol_cell
mesh grid cell volume
void apply_assignment_compensation()
Apply compensation needed after Fourier transform for assignment schemes.
const fftw_complex & operator[](long long gid)
Return mesh field grid cell value.
Interpolated spherical Bessel function of the first kind.
Clustering measurement data objects.
I/O support including custom exceptions and utility functions.
Mathematical calculations.
Provide tracking of program resources and exceptions.
Program parameter configuration.
Particle containers with I/O methods and operations.