19 char const *suffix[] = {
"B",
"KB",
"MB",
"GB",
"TB"};
20 char length =
sizeof(suffix) /
sizeof(suffix[0]);
23 double dblBytes = bytes;
26 for (i = 0; (bytes / 1024) > 0 && i<length-1; i++, bytes /= 1024)
27 dblBytes = bytes / 1024.0;
30 static char output[200];
31 sprintf(output,
"%.02lf %s", dblBytes, suffix[i]);
37 BOOST_LOG_TRIVIAL(debug) <<
"Allocated " <<
humanSize(memory_alloc) <<
" of memory.";
49 Tracking(
size_t sqr_num_track_par,
size_t par_num_per_dim)
51 set_par_ids(sqr_num_track_par, par_num_per_dim);
57 return par_ids.size();
62 return par_pos.size();
67 std::vector<Particle_x<FTYPE_t>> par_pos_step;
68 par_pos_step.reserve(par_ids.size());
69 for (
size_t i=0; i < par_ids.size(); i++){
70 par_pos_step.emplace_back(particles[par_ids[i]].position);
72 par_pos.push_back(par_pos_step);
77 out_dir +=
"par_cut/";
78 std::string file_name = out_dir +
"track_par_pos" + suffix +
".dat";
82 const FTYPE_t x_0 = sim.
x_0();
83 BOOST_LOG_TRIVIAL(debug) <<
"Writing positons of " << par_ids.size() <<
" tracked particles into file " << file_name;
84 File <<
"# This file contains positions of particles in units [Mpc/h].\n" 85 "# x [Mpc/h]\tz [Mpc/h]";
86 for (
size_t i=0; i < par_ids.size(); i++){
87 for (
const auto& par_pos_step : par_pos){
88 x = par_pos_step[i].position[0];
89 y = par_pos_step[i].position[1];
90 z = par_pos_step[i].position[2];
91 File << x*x_0 <<
"\t" << z*x_0 <<
"\t" << y*x_0 <<
"\n";
98 void set_par_ids(
size_t sqr_num_track_par,
size_t par_num_per_dim)
100 size_t num_track_par = sqr_num_track_par*sqr_num_track_par;
101 par_ids.reserve(num_track_par);
104 y = par_num_per_dim / 2;
105 s = par_num_per_dim / FTYPE_t(4*(sqr_num_track_par+1));
106 for (
size_t i=1; i<=sqr_num_track_par;i++)
109 for (
size_t j=1; j<=sqr_num_track_par;j++)
112 par_ids.push_back(x*par_num_per_dim*par_num_per_dim+y*par_num_per_dim+z);
119 std::vector<std::vector<Particle_x<FTYPE_t>>>
par_pos;
136 Impl(
const Sim_Param &sim,
const std::string& app_short,
const std::string& app_long):
137 step(0), print_every(sim.out_opt.print_every),
138 app_str(app_short), app_long(app_long), z_suffix_const(
"_" + app_short +
"_"), out_dir_app(
std_out_dir(app_short +
"_run/", sim)),
139 track(4, sim.box_opt.par_num_1d),
140 a(sim.integ_opt.a_in), a_out(sim.integ_opt.a_out), da(sim.integ_opt.db),
141 is_init_pwr_spec_0(false), is_init_vel_pwr_spec_0(false)
149 for(
size_t i = 0; i < 3; i++){
186 throw std::runtime_error(
"Errors during multi-thread initialization");
225 BOOST_LOG_TRIVIAL(debug) <<
"Computing displacement in q-space...";
237 std::string app_long_upper(app_long);
238 std::transform(app_long_upper.begin(), app_long_upper.end(), app_long_upper.begin(), ::toupper);
239 BOOST_LOG_TRIVIAL(info) <<
"Starting: " << app_long_upper;
244 BOOST_LOG_TRIVIAL(info) << app_long <<
" ended successfully.";
249 std::stringstream z_suffix_num;
250 z_suffix_num << std::fixed << std::setprecision(2) <<
z();
251 return z_suffix_const +
"z" + z_suffix_num.str();
277 if (out_opt.
get_pwr) get_binned_power_spec(APP);
280 if (out_opt.
print_pwr) print_power_spec(APP);
323 FTYPE_t a, a_out,
da;
330 BOOST_LOG_TRIVIAL(info) <<
"Starting computing step with z = " <<
z() <<
" (a = " << a <<
")";
341 unsigned int print_every,
step;
347 return print_every ? ((step % print_every) == 0) or (a == a_out) : false ;
358 track.print_track_par(APP.
sim, out_dir_app, z_suffix());
378 if (!is_init_pwr_spec_0){
381 is_init_pwr_spec_0 =
true;
387 out_dir_app,
"_hybrid" + z_suffix());
411 if (!is_init_vel_pwr_spec_0){
413 is_init_vel_pwr_spec_0 =
true;
433 return (a <= a_out) && (da > 0);
439 if ((a_out - a) < da) da = a_out - a;
452 m_impl(new
Impl(sim, app_short, app_long)), sim(sim), dens_binned(500)
487 m_impl->set_init_cond(*
this);
493 m_impl->integration(*
this);
512 BOOST_LOG_TRIVIAL(debug) <<
"Computing force in q-space...";
519 m_impl->print_output(*
this);
531 return a() -
da()/2.;
543 return m_impl->out_dir_app;
549 return m_impl->z_suffix();
void print_rho_map(const Mesh &delta, const Sim_Param &sim, std::string out_dir, std::string suffix)
void gen_pow_spec_binned_from_extrap(const Sim_Param &sim, const P &P_k, Data_Vec< T, N > &pwr_spec_binned)
class containing core variables and methods for approximations
virtual void pot_corr(std::vector< Mesh > &vel_field, Mesh &pot_k)
Interp_obj pwr_spec_input
void print_vel_pow_spec_diff(const Data_Vec< double, 2 > &pwr_spec_binned, const Data_Vec< double, 2 > &pwr_spec_binned_0, double dDda, std::string out_dir, std::string suffix)
bool is_init_vel_pwr_spec_0
bool get_vel_from_par(const std::vector< Particle_v< double >> &particles, std::vector< Mesh > &vel_field, const Sim_Param &sim)
void print_output(App_Var< T > &APP)
std::string std_out_dir(const std::string &pre_subdir, const Sim_Param &sim)
void get_rho_from_par(const std::vector< T > &particles, Mesh &rho, const Sim_Param &sim)
void print_position(const App_Var< T > &APP) const
void gen_rho_dist_k(const Sim_Param &sim, Mesh &rho, const FFTW_PLAN_TYPE &p_F)
Generate density distributions in k-space.
void gen_corr_func_binned_gsl_qawf_lin(const Sim_Param &sim, double a, Data_Vec< double, 2 > &corr_func_binned)
compute linear correlation function and store results
void print_vel_pwr(App_Var< T > &APP)
functions handling output of the program
void print_init(App_Var< T > &APP)
void print_mem(uint64_t memory_alloc)
App_Var(const Sim_Param &sim, const std::string &app_short, const std::string &app_long)
: linear interpolation (Steffen) of data [x, y]
void set_pert_pos(const Sim_Param &sim, const double a, std::vector< Particle_x< double >> &particles, const std::vector< Mesh > &vel_field)
void print_power_spec(App_Var< T > &APP)
void gen_displ_k(std::vector< Mesh > &vel_field, const Mesh &pot_k)
: class storing simulation parameters
size_t size() const noexcept
size_t get_num_steps() const
void fftw_execute_dft_r2c(const FFTW_PLAN_TYPE &p_F, Mesh &rho)
compute forward (real to complex) FFT on mesh (inplace)
uint64_t alloc_bin_spec(App_Var< T > &APP)
uint64_t alloc_particles(App_Var< T > &APP)
void gen_corr_func_binned_gsl_qawf(const Sim_Param &sim, const P &P_k, Data_Vec< double, 2 > &corr_func_binned)
compute correlation function and store results
Data_Vec< double, 2 > vel_pwr_spec_binned_0
void print_dens_bin(const std::vector< size_t > &dens_binned, std::string out_dir, std::string suffix)
: creates a mesh of N*N*(N+2) cells
void fftw_prep(App_Var< T > &APP)
std::string z_suffix() const
void fftw_execute_dft_c2r_triple(const FFTW_PLAN_TYPE &p_B, std::vector< Mesh > &rho)
compute three backward (complex to real) FFTs on vector of meshes (inplace)
std::vector< std::vector< Particle_x< double > > > par_pos
void print_pow_spec(const Data_Vec< double, 2 > &pwr_spec_binned, std::string out_dir, std::string suffix)
void print_info(const Sim_Param &sim) const
void print_vel_pow_spec(const Data_Vec< double, 2 > &pwr_spec_binned, std::string out_dir, std::string suffix)
std::vector< size_t > dens_binned
Impl(const Sim_Param &sim, const std::string &app_short, const std::string &app_long)
void print_corr(App_Var< T > &APP, const Extrap_Pk< double, 2 > &P_k) const
void gen_pot_k(const Mesh &rho_k, Mesh &pot_k)
std::vector< Mesh > app_field
Data_Vec< double, 2 > pwr_spec_binned
size_t get_num_track_par() const
void gen_pow_spec_binned(const Sim_Param &sim, const Mesh &power_aux, Data_Vec< double, 2 > &pwr_spec_binned)
cosmological & CCL parameters
std::string get_z_suffix() const
#define FFTW_PLAN_OMP_CLEAN
void create_dir(const std::string &out_dir)
interface for common functions for all types of approximations
void print_extrap_pwr(App_Var< T > &APP, const Extrap_Pk< double, 2 > &P_k) const
Data_Vec< double, 2 > corr_func_binned
static CCL_BEGIN_DECLS double x[111][8]
void set_par_ids(size_t sqr_num_track_par, size_t par_num_per_dim)
std::string get_out_dir() const
void print_pow_spec_diff(const Data_Vec< double, 2 > &pwr_spec_binned, const Data_Vec< double, 2 > &pwr_spec_binned_0, double growth, std::string out_dir, std::string suffix)
const char * humanSize(uint64_t bytes)
void gen_dens_binned(const Mesh &rho, std::vector< size_t > &dens_binned, const Sim_Param &sim)
std::vector< size_t > par_ids
classes handling approximations data
std::vector< T > particles
void get_binned_power_spec(App_Var< T > &APP) const
void print_track_par(const Sim_Param &sim, std::string out_dir, std::string suffix) const
void vel_pwr_spec_k(const std::vector< Mesh > &vel_field, Mesh &power_aux)
void pwr_spec_k(const Mesh &rho_k, Mesh &power_aux)
void print_corr_func(const Data_Vec< double, 2 > &pwr_spec_binned, std::string out_dir, std::string suffix)
Tracking(size_t sqr_num_track_par, size_t par_num_per_dim)
void gen_pow_spec_binned_init(const Sim_Param &sim, const Mesh &power_aux, const size_t half_length, Data_Vec< double, 2 > &pwr_spec_binned)
void update_track_par(const std::vector< T > &particles)
void set_init_cond(App_Var< T > &APP)
const std::unique_ptr< Impl > m_impl
void create_work_dir(const Out_Opt &out_opt)
void set_init_pos(App_Var< T > &APP)
void print_par_pos_cut_small(const std::vector< T > &particles, const Sim_Param &sim, std::string out_dir, std::string suffix)
void print_sim_name() const
basic functions to work with mesh
void pwr_spec_k_init(const Mesh &rho_k, Mesh &power_aux)
#define FFTW_PLAN_OMP_INIT
Data_Vec< double, 2 > pwr_spec_binned_0
virtual void print_output()
void print_input_realisation(App_Var< T > &APP)
void print_info(std::string out, std::string app) const
: class storing info about tracked particles
void fftw_execute_dft_r2c_triple(const FFTW_PLAN_TYPE &p_F, std::vector< Mesh > &rho)
compute three forward (real to complex) FFTs on vector of meshes (inplace)
void gen_displ_k_cic(std::vector< Mesh > &vel_field, const Mesh &pot_k)
const std::string z_suffix_const
std::vector< Mesh > power_aux
void integration(App_Var< T > &APP)
void print_density(App_Var< T > &APP) const
uint64_t alloc_mesh_vec(App_Var< T > &APP)
virtual void update_cosmo(Cosmo_Param &cosmo)
no truncation by default
size_t dim() const noexcept
double growth_change(double a, const Cosmo_Param &cosmo)
uint64_t alloc_bin_corr(App_Var< T > &APP)