Fast Methods for Cosmological Simulations
FastSim serves as a tool for quick N-body simulations in modified gravity.
App_Var< T > Class Template Referenceabstract

class containing core variables and methods for approximations More...

#include <app_var.hpp>

Collaboration diagram for App_Var< T >:

Classes

class  Impl
 

Public Member Functions

 App_Var (const Sim_Param &sim, const std::string &app_short, const std::string &app_long)
 
virtual ~App_Var ()
 
void run_simulation ()
 
virtual void update_cosmo (Cosmo_Param &cosmo)
 no truncation by default More...
 
std::string get_out_dir () const
 

Protected Member Functions

double a ()
 
double a_half ()
 
double da ()
 
std::string get_z_suffix () const
 
virtual void print_output ()
 
virtual void pot_corr (std::vector< Mesh > &vel_field, Mesh &pot_k)
 

Protected Attributes

const Sim_Paramsim
 
uint64_t memory_alloc
 
std::vector< Meshapp_field
 
std::vector< Meshpower_aux
 
std::vector< T > particles
 
Data_Vec< double, 2 > corr_func_binned
 
Data_Vec< double, 2 > pwr_spec_binned
 
Data_Vec< double, 2 > pwr_spec_binned_0
 
Data_Vec< double, 2 > vel_pwr_spec_binned_0
 
FFTW_PLAN_TYPE p_F
 
FFTW_PLAN_TYPE p_B
 
FFTW_PLAN_TYPE p_F_pwr
 
FFTW_PLAN_TYPE p_B_pwr
 
std::vector< size_t > dens_binned
 

Private Member Functions

virtual void upd_pos ()=0
 

Private Attributes

const std::unique_ptr< Implm_impl
 

Friends

class Impl
 

Detailed Description

template<class T>
class App_Var< T >

class containing core variables and methods for approximations

Template Parameters
Ttype of particle, implemented Particle_x and Particle_v

Definition at line 41 of file app_var.hpp.

Constructor & Destructor Documentation

template<class T >
App_Var< T >::App_Var ( const Sim_Param sim,
const std::string &  app_short,
const std::string &  app_long 
)

Definition at line 451 of file app_var.cpp.

References App_Var< T >::m_impl, App_Var< T >::memory_alloc, and Sim_Param::out_opt.

451  :
452  m_impl(new Impl(sim, app_short, app_long)), sim(sim), dens_binned(500)
453 {
454  // EFFICIENTLY ALLOCATE MEMORY
455  memory_alloc = m_impl->alloc_mesh_vec(*this); // app_field, power_aux
456  memory_alloc += m_impl->alloc_bin_spec(*this); // pwr_spec_binned, pwr_spec_binned_0, vel_pwr_spec_binned_0
457  memory_alloc += m_impl->alloc_bin_corr(*this); // corr_func_binned
458  memory_alloc += m_impl->alloc_particles(*this); // particles
459 
460  // CREAT SUBDIR STRUCTURE
461  m_impl->create_work_dir(sim.out_opt);
462 
463  // FFTW PREPARATION
464  m_impl->fftw_prep(*this); // fftw omp, fftw plans
465 }
uint64_t memory_alloc
Definition: app_var.hpp:60
std::vector< size_t > dens_binned
Definition: app_var.hpp:70
friend class Impl
Definition: app_var.hpp:85
Out_Opt out_opt
Definition: params.hpp:204
const std::unique_ptr< Impl > m_impl
Definition: app_var.hpp:87
const Sim_Param & sim
Definition: app_var.hpp:59
template<class T >
App_Var< T >::~App_Var ( )
virtual

Definition at line 468 of file app_var.cpp.

References FFTW_DEST_PLAN, FFTW_PLAN_OMP_CLEAN, App_Var< T >::p_B, App_Var< T >::p_B_pwr, App_Var< T >::p_F, and App_Var< T >::p_F_pwr.

469 { // FFTW CLEANUP
475 }
FFTW_PLAN_TYPE p_F_pwr
Definition: app_var.hpp:69
FFTW_PLAN_TYPE p_F
Definition: app_var.hpp:69
#define FFTW_PLAN_OMP_CLEAN
Definition: precision.hpp:33
FFTW_PLAN_TYPE p_B
Definition: app_var.hpp:69
FFTW_PLAN_TYPE p_B_pwr
Definition: app_var.hpp:69
#define FFTW_DEST_PLAN
Definition: precision.hpp:27

Member Function Documentation

template<class T >
double App_Var< T >::a ( )
protected

Definition at line 523 of file app_var.cpp.

References App_Var< T >::m_impl.

Referenced by App_Var< T >::a_half().

524 {
525  return m_impl->a;
526 }
const std::unique_ptr< Impl > m_impl
Definition: app_var.hpp:87
template<class T >
double App_Var< T >::a_half ( )
protected

Definition at line 529 of file app_var.cpp.

References App_Var< T >::a(), and App_Var< T >::da().

Referenced by App_Var_AA::AAImpl::aa_convolution().

530 {
531  return a() - da()/2.;
532 }
double a()
Definition: app_var.cpp:523
double da()
Definition: app_var.cpp:535
template<class T >
double App_Var< T >::da ( )
protected

Definition at line 535 of file app_var.cpp.

References App_Var< T >::m_impl.

Referenced by App_Var< T >::a_half().

536 {
537  return m_impl->da;
538 }
const std::unique_ptr< Impl > m_impl
Definition: app_var.hpp:87
template<class T >
std::string App_Var< T >::get_out_dir ( ) const

Definition at line 541 of file app_var.cpp.

References App_Var< T >::m_impl.

542 {
543  return m_impl->out_dir_app;
544 }
const std::unique_ptr< Impl > m_impl
Definition: app_var.hpp:87
template<class T >
std::string App_Var< T >::get_z_suffix ( ) const
protected

Definition at line 547 of file app_var.cpp.

References App_Var< T >::m_impl.

548 {
549  return m_impl->z_suffix();
550 }
const std::unique_ptr< Impl > m_impl
Definition: app_var.hpp:87
template<class T >
void App_Var< T >::pot_corr ( std::vector< Mesh > &  vel_field,
Mesh pot_k 
)
protectedvirtual

Reimplemented in App_Var_AA, App_Var_FP_mod, and App_Var_ZA.

Definition at line 506 of file app_var.cpp.

References fftw_execute_dft_c2r_triple(), gen_displ_k_cic(), and App_Var< T >::p_B.

Referenced by App_Var< T >::run_simulation().

507 {
508  /* Computing displacement in k-space with CIC opt */
509  gen_displ_k_cic(vel_field, pot_k);
510 
511  /* Computing force in q-space */
512  BOOST_LOG_TRIVIAL(debug) << "Computing force in q-space...";
513  fftw_execute_dft_c2r_triple(p_B, vel_field);
514 }
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)
Definition: core_mesh.cpp:263
FFTW_PLAN_TYPE p_B
Definition: app_var.hpp:69
void gen_displ_k_cic(std::vector< Mesh > &vel_field, const Mesh &pot_k)
Definition: core_app.cpp:625
template<class T >
void App_Var< T >::print_output ( )
protectedvirtual

Reimplemented in App_Var_Chi.

Definition at line 517 of file app_var.cpp.

References App_Var< T >::m_impl.

Referenced by App_Var< T >::Impl< T >::integration(), and App_Var< T >::Impl< T >::print_init().

518 {
519  m_impl->print_output(*this);
520 }
const std::unique_ptr< Impl > m_impl
Definition: app_var.hpp:87
template<class T >
void App_Var< T >::run_simulation ( )

Definition at line 478 of file app_var.cpp.

References App_Var< T >::app_field, App_Var< T >::m_impl, App_Var< T >::memory_alloc, App_Var< T >::pot_corr(), App_Var< T >::power_aux, and anonymous_namespace{app_var.cpp}::print_mem().

479 {
480  // print simulation name
481  m_impl->print_sim_name();
482 
483  // print memory usage
485 
486  // set initial conditions
487  m_impl->set_init_cond(*this);
488 
489  // CIC correction of potential (if not overriden)
491 
492  // integration
493  m_impl->integration(*this);
494 
495  // end of simulation
496  m_impl->print_end();
497 }
virtual void pot_corr(std::vector< Mesh > &vel_field, Mesh &pot_k)
Definition: app_var.cpp:506
uint64_t memory_alloc
Definition: app_var.hpp:60
void print_mem(uint64_t memory_alloc)
Definition: app_var.cpp:35
std::vector< Mesh > app_field
Definition: app_var.hpp:63
const std::unique_ptr< Impl > m_impl
Definition: app_var.hpp:87
std::vector< Mesh > power_aux
Definition: app_var.hpp:64
template<class T>
virtual void App_Var< T >::upd_pos ( )
privatepure virtual
template<class T >
void App_Var< T >::update_cosmo ( Cosmo_Param cosmo)
virtual

no truncation by default

Reimplemented in App_Var_TZA.

Definition at line 500 of file app_var.cpp.

References Cosmo_Param::truncated_pk.

501 {
502  cosmo.truncated_pk = false;
503 }
bool truncated_pk
Definition: params.hpp:41

Friends And Related Function Documentation

template<class T>
friend class Impl
friend

Definition at line 85 of file app_var.hpp.

Member Data Documentation

template<class T>
Data_Vec<double, 2> App_Var< T >::corr_func_binned
protected
template<class T>
std::vector<size_t> App_Var< T >::dens_binned
protected

Definition at line 70 of file app_var.hpp.

Referenced by App_Var< T >::Impl< T >::print_density().

template<class T>
uint64_t App_Var< T >::memory_alloc
protected

Definition at line 60 of file app_var.hpp.

Referenced by App_Var< T >::App_Var(), and App_Var< T >::run_simulation().

template<class T>
FFTW_PLAN_TYPE App_Var< T >::p_B_pwr
protected

Definition at line 69 of file app_var.hpp.

Referenced by App_Var< T >::Impl< T >::fftw_prep(), and App_Var< T >::~App_Var().

template<class T>
Data_Vec<double, 2> App_Var< T >::pwr_spec_binned_0
protected
template<class T>
Data_Vec<double, 2> App_Var< T >::vel_pwr_spec_binned_0
protected

The documentation for this class was generated from the following files: