Fast Methods for Cosmological Simulations
FastSim serves as a tool for quick N-body simulations in modified gravity.
app_var.hpp
Go to the documentation of this file.
1 
9 #pragma once
10 #include "stdafx.h"
11 #include "precision.hpp"
12 #include "class_data_vec.hpp"
13 #include "class_mesh.hpp"
14 
15 /********************/
19 class Sim_Param;
20 class Cosmo_Param;
21 
22 /**************/
26 /**************/
40 template <class T>
41 class App_Var
42 {
43 public:
44  // CONSTRUCTORS & DESTRUCTOR
45  App_Var(const Sim_Param &sim, const std::string& app_short, const std::string& app_long);
46  virtual ~App_Var();
47 
48  // RUN THE SIMULATION
49  void run_simulation();
50 
51  // UPDATE INITIAL POWER SPECTRUM -- TRUNCATION
52  virtual void update_cosmo(Cosmo_Param& cosmo);
53 
54  // get output directory
55  std::string get_out_dir() const;
56 
57 protected:
58  // VARIABLES
59  const Sim_Param &sim;
60  uint64_t memory_alloc; // only the largest chunks, NEED to increase in derived classes appropriately
61 
62  // LARGE FIELDS
63  std::vector<Mesh> app_field;
64  std::vector<Mesh> power_aux;
65  std::vector<T> particles;
66 
67  // OTHER FIELDS
70  std::vector<size_t> dens_binned;
71 
72  // METHODS
73  FTYPE_t a();
74  FTYPE_t a_half();
75  FTYPE_t da();
76  std::string get_z_suffix() const;
77 
78  // METHODS THAT NEED TO BE OVERRIDEN IN DERIVED CLASSES
79  virtual void print_output(); //< save info about simulation state
80  virtual void pot_corr(std::vector<Mesh>& vel_field, Mesh& pot_k); //< CIC correction by default
81 private:
82  virtual void upd_pos() = 0;
83 
84  // IMPLEMENTATION
85  class Impl;
86  friend class Impl;
87  const std::unique_ptr<Impl> m_impl;
88 };
class containing core variables and methods for approximations
Definition: app_var.hpp:41
virtual void pot_corr(std::vector< Mesh > &vel_field, Mesh &pot_k)
Definition: app_var.cpp:506
FFTW_PLAN_TYPE p_F_pwr
Definition: app_var.hpp:69
uint64_t memory_alloc
Definition: app_var.hpp:60
implementation of class App_Var<T>
App_Var(const Sim_Param &sim, const std::string &app_short, const std::string &app_long)
Definition: app_var.cpp:451
: class storing simulation parameters
Definition: params.hpp:193
Data_Vec< double, 2 > vel_pwr_spec_binned_0
Definition: app_var.hpp:68
: creates a mesh of N*N*(N+2) cells
Definition: class_mesh.hpp:95
define container Data_Vec
FFTW_PLAN_TYPE p_F
Definition: app_var.hpp:69
std::vector< size_t > dens_binned
Definition: app_var.hpp:70
void run_simulation()
Definition: app_var.cpp:478
std::vector< Mesh > app_field
Definition: app_var.hpp:63
Data_Vec< double, 2 > pwr_spec_binned
Definition: app_var.hpp:68
system include files and for project-specific include files that are used frequently but are changed ...
declaration in params.hpp
Definition: core_power.h:19
cosmological & CCL parameters
Definition: params.hpp:22
std::string get_z_suffix() const
Definition: app_var.cpp:547
Data_Vec< double, 2 > corr_func_binned
Definition: app_var.hpp:68
double a()
Definition: app_var.cpp:523
std::string get_out_dir() const
Definition: app_var.cpp:541
std::vector< T > particles
Definition: app_var.hpp:65
virtual ~App_Var()
Definition: app_var.cpp:468
FFTW_PLAN_TYPE p_B
Definition: app_var.hpp:69
#define FFTW_PLAN_TYPE
Definition: precision.hpp:26
single / double / long double definitions
virtual void upd_pos()=0
const std::unique_ptr< Impl > m_impl
Definition: app_var.hpp:87
double a_half()
Definition: app_var.cpp:529
Data_Vec< double, 2 > pwr_spec_binned_0
Definition: app_var.hpp:68
virtual void print_output()
Definition: app_var.cpp:517
double da()
Definition: app_var.cpp:535
FFTW_PLAN_TYPE p_B_pwr
Definition: app_var.hpp:69
std::vector< Mesh > power_aux
Definition: app_var.hpp:64
const Sim_Param & sim
Definition: app_var.hpp:59
virtual void update_cosmo(Cosmo_Param &cosmo)
no truncation by default
Definition: app_var.cpp:500
define container Mesh