CosmoGRaPH v0.0
sheets.h
1 
19 #ifndef COSMO_SHEET_H
20 #define COSMO_SHEET_H
21 
22 #include "../../utils/RK4Register.h"
23 #include "../../utils/Array.h"
24 #include "../../utils/Timer.h"
25 #include "../../cosmo_types.h"
26 #include "../bssn/bssn.h"
27 #include "../../utils/TriCubicInterpolator.h"
28 #include "../Lambda/lambda.h"
29 #include <cmath>
30 #include <algorithm>
31 #include <iostream>
32 #include <string>
33 #include "zlib.h"
34 #include <limits>
35 #include <sstream>
36 #include <iomanip>
37 #include <fstream>
38 #include <vector>
39 
40 namespace cosmo
41 {
42 
43 
47 class Sheet
48 {
49 public:
50  // Simulation information
51  idx_t nx, ny, nz;
52  idx_t ns1, ns2, ns3;
53  real_t lx, ly, lz;
54  real_t dx, dy, dz;
55 
56  register_t Dx, Dy, Dz;
57  register_t vx, vy, vz;
58 
60 
61  bool follow_null_geodesics;
62  real_t rescale_sheet;
63  real_t ray_bundle_epsilon, det_g_obs;
64 
65  idx_t step;
66 
67  // internal types
68  enum carrierCountScheme { per_dx = 0, per_ds = 1};
69  carrierCountScheme carrier_count_scheme;
70 
71  enum depositScheme { CIC = 0, PCS = 1, CINT = 2 };
72  depositScheme deposit;
73 
74  idx_t carriers_per_dx,
75  carriers_per_dy,
76  carriers_per_dz;
77 
78  Sheet();
79  ~Sheet();
80 
81  void setDt(real_t dt);
82 
86  real_t _S1IDXtoX0(idx_t s1) { return (real_t)s1*lx/ns1; }
87  real_t _S2IDXtoY0(idx_t s2) { return (real_t)s2*ly/ns2; }
88  real_t _S3IDXtoZ0(idx_t s3) { return (real_t)s3*lz/ns3; }
89  real_t _S1IDXtoX0(real_t s1) { return (real_t)s1*lx/(real_t)ns1; }
90  real_t _S2IDXtoY0(real_t s2) { return (real_t)s2*ly/(real_t)ns2; }
91  real_t _S3IDXtoZ0(real_t s3) { return (real_t)s3*lz/(real_t)ns3; }
92 
93  void _MassDeposit(real_t weight, real_t x_idx, real_t y_idx, real_t z_idx,
94  arr_t &rho);
95 
96  void _CICDeposit(real_t weight, real_t x_idx, real_t y_idx, real_t z_idx,
97  arr_t &rho);
98 
99  void _PCSDeposit(real_t weight, real_t x_idx, real_t y_idx, real_t z_idx,
100  arr_t &rho);
101 
102  void _CINTDeposit(real_t weight, real_t x_idx, real_t y_idx, real_t z_idx,
103  arr_t &rho);
104 
105  void _deconvolve(arr_t &field);
106 
113  void _pushSheetMassToRho(idx_t s1, idx_t s2, idx_t s3);
114 
118  void _setMetricPotentials();
119 
123  void _RK4Calc();
124 
125  void _stepInit();
126 
127  void _K1Finalize();
128 
129  void _K2Finalize();
130 
131  void _K3Finalize();
132 
133  void _K4Finalize();
134 
135  real_t _getXRangeInSVoxel(register_t & DX, idx_t s1_idx, idx_t s2_idx,
136  idx_t s3_idx, real_t X0_lower, real_t X0_upper);
137 
138  void addBSSNSource(BSSN *bssn, real_t tot_mass);
139 
140  void rescaleFieldPerturbations(arr_t & field, real_t multiplier);
141  void rescaleVelocityPerturbations(arr_t & ux, arr_t & uy, arr_t & uz, real_t multiplier);
142  void rescalePositionPerturbations(arr_t & dx, arr_t & dy, arr_t & dz, real_t multiplier);
143  void rescaleAllFieldPerturbations(BSSN *bssn, real_t multiplier);
144 
145  void RKStep(BSSN *bssn);
146 
147  void stepInit();
148 
149  void K1Finalize();
150  void K2Finalize();
151  void K3Finalize();
152  void K4Finalize();
153 
154  arr_t d1alpha_a, d2alpha_a, d3alpha_a;
155 
156  arr_t d1gammai11_a, d1gammai22_a, d1gammai33_a,
157  d1gammai12_a, d1gammai13_a, d1gammai23_a;
158 
159  arr_t d2gammai11_a, d2gammai22_a, d2gammai33_a,
160  d2gammai12_a, d2gammai13_a, d2gammai23_a;
161 
162  arr_t d3gammai11_a, d3gammai22_a, d3gammai33_a,
163  d3gammai12_a, d3gammai13_a, d3gammai23_a;
164 
165  arr_t d1beta1_a, d1beta2_a, d1beta3_a;
166  arr_t d2beta1_a, d2beta2_a, d2beta3_a;
167  arr_t d3beta1_a, d3beta2_a, d3beta3_a;
168 
169  std::vector<real_t> getgammaiIJ(idx_t s1, idx_t s2, idx_t s3, BSSN *bssnSim);
170  std::vector<real_t> getgammaIJ(idx_t s1, idx_t s2, idx_t s3, BSSN *bssnSim);
171  std::vector<real_t> getRayDataAtS(idx_t s, BSSN *bssnSim, Lambda * lambda);
172 
173 };
174 
175 real_t dot_cov_spatial_vectors(real_t * v1, real_t * v2, std::vector<real_t> gammaiIJ);
176 real_t mag_cov_spatial_vector(real_t * v1, std::vector<real_t> gammaiIJ);
177 real_t dot_cont_spatial_vectors(real_t * v1, real_t * v2, std::vector<real_t> gammaIJ);
178 real_t mag_cont_spatial_vector(real_t * v1, std::vector<real_t> gammaIJ);
179 real_t dot_4_vectors_vvg(real_t v1[4], real_t v2[4], real_t g[4][4]);
180 real_t dot_4_vectors_vv(real_t v1[4], real_t v2[4]);
181 
182 
183 } //namespace cosmo
184 #endif // include guard
real_t _getXRangeInSVoxel(register_t &DX, idx_t s1_idx, idx_t s2_idx, idx_t s3_idx, real_t X0_lower, real_t X0_upper)
Definition: sheets.cc:291
void _setMetricPotentials()
real_t lz
Metric grid physical dimensions.
Definition: sheets.h:53
void addBSSNSource(BSSN *bssn, real_t tot_mass)
Definition: sheets.cc:323
void _pushSheetMassToRho(idx_t s1, idx_t s2, idx_t s3)
Definition: bardeen.cc:5
real_t dz
Metric grid physical spacing.
Definition: sheets.h:54
void _PCSDeposit(real_t weight, real_t x_idx, real_t y_idx, real_t z_idx, arr_t &rho)
Piecewise cubic spline deposition.
Definition: sheets.cc:159
void _CINTDeposit(real_t weight, real_t x_idx, real_t y_idx, real_t z_idx, arr_t &rho)
Deposition based on cubic interoplation (CINT)
Definition: sheets.cc:257
BSSN Class: evolves BSSN metric fields, computes derived quantities.
Definition: bssn.h:24
std::vector< real_t > getRayDataAtS(idx_t s, BSSN *bssnSim, Lambda *lambda)
Function to get metric/data for a particular particle; Currently only ok for zero shift (maybe ok in ...
Definition: sheets.cc:1074
real_t _S1IDXtoX0(idx_t s1)
Definition: sheets.h:86
idx_t ns3
Phase-space sheet resolution.
Definition: sheets.h:52
register_t vz
Phase-space velocity fields.
Definition: sheets.h:57
void _RK4Calc()
register_t Dz
Metric-space displacements.
Definition: sheets.h:56
Definition: sheets.h:47
Definition: lambda.h:11
arr_t tmp
Array for misc. tmp storage (such as deconvolving)
Definition: sheets.h:59