CosmoGRaPH v0.0
bssn.h
1 #ifndef COSMO_BSSN
2 #define COSMO_BSSN
3 
4 #include "../../cosmo_includes.h"
5 #include "../../cosmo_types.h"
6 #include "bssn_data.h"
7 #include "bssn_macros.h"
8 #include "BSSNGaugeHandler.h"
9 #include "../../utils/Array.h"
10 #include "../../utils/FRW.h"
11 #include "../../utils/Fourier.h"
12 #include "../../utils/ConfigParser.h"
13 
14 #if USE_COSMOTRACE
15 #include "../cosmotrace/raytrace.h"
16 #endif
17 
18 namespace cosmo
19 {
20 
24 class BSSN
25 {
26  /* arrays for storing fields */
27  BSSN_APPLY_TO_FIELDS(RK4_ARRAY_CREATE)
28  BSSN_APPLY_TO_SOURCES(GEN1_ARRAY_CREATE)
29  BSSN_APPLY_TO_GEN1_EXTRAS(GEN1_ARRAY_CREATE)
30 
31 
33  real_t k_damping_amp;
34  real_t a_adj_amp;
35  real_t gd_eta;
36  real_t rescale_metric;
37  int normalize_metric;
38 
39  Fourier * fourier;
40 
41 public:
42  BSSNGaugeHandler * gaugeHandler;
43  map_t fields;
44 
45  // Standard FRW spacetime integrator - for a reference metric
46  FRW<real_t> * frw;
47  // Average K, rho for reference
48  real_t K_avg, rho_avg, avg_vol;
49  real_t K_min;
50 
51  real_t cur_t;
52 
53  BSSN(ConfigParser * config, Fourier * fourier_in);
54  ~BSSN();
55 
56  void init();
57 
58  void setDt(real_t dt);
59  void setKODampingCoefficient(real_t KO_damping_coefficient_in);
60 
61  /* RK integrator functions */
62  void setExtraFieldData();
63  void stepInit();
64  void RKEvolve();
65  void RKEvolvePt(idx_t i, idx_t j, idx_t k, BSSNData * bd);
66  void K1Finalize();
67  void K2Finalize();
68  void K3Finalize();
69  void K4Finalize();
70  void clearSrc();
71  void step();
72 
73  void scaleMetricPerturbations(real_t multiplier);
74 
75  /* calculating quantities during an RK step */
76  void set_bd_values(idx_t i, idx_t j, idx_t k, BSSNData *bd);
77 
78  /* set current local field values */
79  void set_local_vals(BSSNData *bd);
80  void set_gammai_values(idx_t i, idx_t j, idx_t k, BSSNData *bd);
82 
83  /* Calculate quantities only dependent on FRW soln in bd*/
84  void calculate_Acont(BSSNData *bd);
85  void calculate_dgamma(BSSNData *bd);
86  void calculate_ddgamma(BSSNData *bd);
88  void calculate_dK(BSSNData *bd);
89 # if USE_Z4c_DAMPING
90  void calculate_dtheta(BSSNData *bd);
91 # endif
92 # if USE_BSSN_SHIFT
93  void calculate_dbeta(BSSNData *bd);
94  void calculate_dexpN(BSSNData *bd);
95 # endif
96 
97  /* Calculate "dependent" quantities (depend on previously calc'd vals) */
98  void calculate_conformal_christoffels(BSSNData *bd);
99 
100  /* Calculate doubly-"dependent" quantities (depend on previously calc'd vals) */
101  void calculateDDphi(BSSNData *bd);
102  void calculateRicciTF(BSSNData *bd);
103  void calculateDDalphaTF(BSSNData *bd);
104 
105  void enforceTFSIJ(BSSNData *bd);
106 
107  /* (optional) Calculations of additional quantities */
108  void set_full_metric(BSSNData *bd);
109  void set_full_metric_der(BSSNData *bd);
110 
111  /* Evolution functions */
112  real_t ev_DIFFgamma11(BSSNData *bd);
113  real_t ev_DIFFgamma12(BSSNData *bd);
114  real_t ev_DIFFgamma13(BSSNData *bd);
115  real_t ev_DIFFgamma22(BSSNData *bd);
116  real_t ev_DIFFgamma23(BSSNData *bd);
117  real_t ev_DIFFgamma33(BSSNData *bd);
118  real_t ev_A11(BSSNData *bd);
119  real_t ev_A12(BSSNData *bd);
120  real_t ev_A13(BSSNData *bd);
121  real_t ev_A22(BSSNData *bd);
122  real_t ev_A23(BSSNData *bd);
123  real_t ev_A33(BSSNData *bd);
124  real_t ev_DIFFK(BSSNData *bd);
125  real_t ev_DIFFphi(BSSNData *bd);
126  real_t ev_Gamma1(BSSNData *bd);
127  real_t ev_Gamma2(BSSNData *bd);
128  real_t ev_Gamma3(BSSNData *bd);
129 
130  real_t ev_DIFFalpha(BSSNData *bd);
131 
132 # if USE_Z4c_DAMPING
133  real_t ev_theta(BSSNData *bd);
134 # endif
135 
136 # if USE_BSSN_SHIFT
137  real_t ev_beta1(BSSNData *bd);
138  real_t ev_beta2(BSSNData *bd);
139  real_t ev_beta3(BSSNData *bd);
140  real_t ev_expN(BSSNData *bd);
141 # endif
142 
143 # if USE_GAMMA_DRIVER
144  real_t ev_auxB1(BSSNData *bd);
145  real_t ev_auxB2(BSSNData *bd);
146  real_t ev_auxB3(BSSNData *bd);
147 # endif
148 
149  /* constraint violation calculations */
150  void set1DConstraintOutput(
151  real_t H_values[], real_t M_values[], int axis, idx_t n1, idx_t n2);
152 
153  void setConstraintCalcs(real_t H_values[7], real_t M_values[7],
154  real_t G_values[7], real_t A_values[7], real_t S_values[7]);
155 
156  real_t hamiltonianConstraintCalc(BSSNData *bd);
157  real_t hamiltonianConstraintScale(BSSNData *bd);
158 
159  real_t momentumConstraintCalc(BSSNData *bd, idx_t d);
160  real_t momentumConstraintScale(BSSNData *bd, idx_t d);
161 
162  real_t christoffelConstraintCalc(BSSNData *bd, idx_t d);
163  real_t christoffelConstraintScale(BSSNData *bd, idx_t d);
164 
165  real_t AijTFConstraintCalc(BSSNData *bd);
166  real_t AijTFConstraintScale(BSSNData *bd);
167 
168  real_t unitDetConstraintCalc(BSSNData *bd);
169  real_t unitDetConstraintScale(BSSNData *bd);
170 
171 # if USE_COSMOTRACE
172  /* Raytracing functionality */
173  RaytracePrimitives<real_t> getRaytraceData(BSSNData *bd);
174  void setRaytraceCornerPrimitives(RayTrace<real_t, idx_t> *rt);
175  void setRaytracePrimitives(RayTrace<real_t, idx_t> *rt);
176 # endif
177 
178 };
179 
180 }
181 
182 #endif
Functions to determine gauge evolution for the BSSN class. Functions are determined via a config sett...
void calculate_Acont(BSSNData *bd)
Calculate contravariant version of conformal trace-free extrinsic curvature, .
Definition: bssn.cc:442
void K4Finalize()
Call RK4Register::K4Finalize finalization routine for BSSN fields, call FRW::RK_total_step for refere...
Definition: bssn.cc:280
real_t KO_damping_coefficient
KO_dissipation coefficient amplitude (default 0)
Definition: bssn.h:27
void RKEvolve()
Call BSSN::RKEvolvePt for all points.
Definition: bssn.cc:211
Definition: BSSNGaugeHandler.h:20
void stepInit()
Call RK4Register class step initialization; normalize Aij and DIFFgammaIJ fields. ...
Definition: bssn.cc:199
void K1Finalize()
Call RK4Register::K1Finalize finalization routine for BSSN fields, call FRW::P1_step for reference FR...
Definition: bssn.cc:247
real_t AijTFConstraintCalc(BSSNData *bd)
Compute statistics about algebraic constraint violation: {}^{ij} {A}_{ij} = 0.
Definition: bssn.cc:1147
real_t unitDetConstraintCalc(BSSNData *bd)
Compute statistics about algebraic constraint violation: det({}_{ij}) = 1 In terms of reference varia...
Definition: bssn.cc:1164
FRW< real_t > * frw
FRW reference metric instance.
Definition: bssn.h:41
void K3Finalize()
Call RK4Register::K3Finalize finalization routine for BSSN fields, call FRW::P3_step for reference FR...
Definition: bssn.cc:269
void calculate_dgamma(BSSNData *bd)
Compute partial derivatives of the conformal metric, store in a BSSNData instance.
Definition: bssn.cc:457
Definition: bardeen.cc:5
void clearSrc()
zero all BSSN source term fields
Definition: bssn.cc:290
void set_gammai_values(idx_t i, idx_t j, idx_t k, BSSNData *bd)
Compute and store inverse conformal difference metric components given the conformal difference metri...
Definition: bssn.cc:426
int normalize_metric
Normalize A_ij and ? Default: 1 (true)
Definition: bssn.h:32
void setKODampingCoefficient(real_t KO_damping_coefficient_in)
Set Kriess-Oliger damping coefficient (numerical dissipation strength) Default is zero (no dissipatio...
Definition: bssn.cc:140
void init()
Initialize fields in BSSN class to defaults.
Definition: bssn.cc:113
Definition: Fourier.h:21
BSSN Class: evolves BSSN metric fields, computes derived quantities.
Definition: bssn.h:24
map_t fields
Public map from names to internal arrays.
Definition: bssn.h:38
Structure containing BSSN metric variables and various derived quantities, such as derivatives of BSS...
Definition: bssn_data.h:18
Definition: ConfigParser.h:10
void calculate_ddgamma(BSSNData *bd)
Compute second partial derivatives of the conformal metric, store in a BSSNData instance.
Definition: bssn.cc:467
void set_local_vals(BSSNData *bd)
Set "local values"; set BSSNData values corresponding to field values at a point. ...
Definition: bssn.cc:409
real_t gd_eta
Gamma driver "eta" parameter.
Definition: bssn.h:30
void scaleMetricPerturbations(real_t multiplier)
scale all metric fields by a multiplier: f -> f_avg + mlt*(f-f_avg)
Definition: bssn.cc:912
void set_bd_values(idx_t i, idx_t j, idx_t k, BSSNData *bd)
Populate values in a BSSNData struct.
Definition: bssn.cc:340
real_t k_damping_amp
Additional "K"-damping (default 0)
Definition: bssn.h:28
void calculate_dK(BSSNData *bd)
Compute partial derivatives of the trace of the extrinsic curvature, store in a BSSNData instance...
Definition: bssn.cc:504
void RKEvolvePt(idx_t i, idx_t j, idx_t k, BSSNData *bd)
Compute the BSSN evolution functions.
Definition: bssn.cc:237
void set_DIFFgamma_Aij_norm()
Normalize the conformal difference metric, make sure the conformal extrinsic curvature is trace-free...
Definition: bssn.cc:48
void setDt(real_t dt)
Set integration timestep (eg, raytracing code calls this with negative dt when beginning to integrate...
Definition: bssn.cc:131
real_t christoffelConstraintCalc(BSSNData *bd, idx_t d)
Compute statistics about algebraic constraint violation: {}^i = {}^{jk} {}^i_{jk}.
Definition: bssn.cc:1107
void step()
Call Perform a full RK4 step, minus initialization.
Definition: bssn.cc:306
void calculate_dalpha_dphi(BSSNData *bd)
Compute partial derivatives of the lapse and conformal factor, store in a BSSNData instance...
Definition: bssn.cc:477
void K2Finalize()
Call RK4Register::K2Finalize finalization routine for BSSN fields, call FRW::P2_step for reference FR...
Definition: bssn.cc:258
real_t a_adj_amp
A-adjusted term amplitude (default 0)
Definition: bssn.h:29
Definition: FRW.h:12