CosmoGRaPH v0.0
BSSNGaugeHandler.h
Go to the documentation of this file.
1 
7 #ifndef COSMO_BSSN_GAUGE_FNS
8 #define COSMO_BSSN_GAUGE_FNS
9 
10 #include "bssn_data.h"
11 #include <string>
12 #include <iostream>
13 #include "../../utils/ConfigParser.h"
14 
15 namespace cosmo
16 {
17 
18 class BSSN; // forward declaration of BSSN class
19 
21 {
22 private:
23  typedef real_t (BSSNGaugeHandler::*bssn_gauge_func_t)(BSSNData *bd);
24 
25  // Reference to BSSN instance
26  BSSN * bssn;
27 
28  // Maps to available functions
29  std::map<std::string, bssn_gauge_func_t> lapse_gauge_map;
30  std::map<std::string, std::map<std::string, bssn_gauge_func_t>> shift_gauge_map;
31 
32  // pointers to functions being used
37 
38  // Generic, not evolving gauge
39  real_t Static(BSSNData *bd);
40 
41  // Harmonic gauge lapse
42  real_t HarmonicLapse(BSSNData *bd);
43 
44  // Conformal FLRW-like lapse (~comoving synchronous with non-constant timestep)
45  real_t ConformalFLRWLapse(BSSNData *bd);
46 
47  // 1+log gauge slicing
48  real_t gd_c;
49  real_t exp_sync_gauge_c;
50  real_t OnePlusLogLapse(BSSNData *bd);
51 
52  // Generalized Newtonian
53  real_t GN_eta;
54  real_t GeneralizedNewton(BSSNData *bd);
55 
56  // Untested/experimental lapses
57  real_t AnharmonicLapse(BSSNData *bd);
58  real_t ConformalSyncLapse(BSSNData *bd);
59 
60  // Gamma driver shift function
61  real_t GammaDriverShift1(BSSNData *bd);
62  real_t GammaDriverShift2(BSSNData *bd);
63  real_t GammaDriverShift3(BSSNData *bd);
64 
65  // Damped wave gauge
66  real_t dw_mu_l;
67  real_t dw_mu_s;
68  real_t dw_p;
69  real_t DampedWaveLapse(BSSNData *bd);
70  real_t DampedWaveShift1(BSSNData *bd);
71  real_t DampedWaveShift2(BSSNData *bd);
72  real_t DampedWaveShift3(BSSNData *bd);
73 
74  // AwA Gauge Wave test lapse
75  real_t gauge_wave_dir;
76  real_t AwAGaugeWaveLapse(BSSNData *bd);
77 
78  // AwA Shifted Gauge Wave test gauge
79  // also uses gauge_wave_dir
80  real_t AwAShiftedWaveLapse(BSSNData *bd);
81  real_t AwAShiftedWaveShift1(BSSNData *bd);
82  real_t AwAShiftedWaveShift2(BSSNData *bd);
83  real_t AwAShiftedWaveShift3(BSSNData *bd);
84 
85  real_t k_driver_coeff;
86  real_t TestKDriverLapse(BSSNData *bd);
87  real_t TestAijDriverLapse(BSSNData *bd);
88  real_t AijDriverShift1(BSSNData *bd);
89  real_t AijDriverShift2(BSSNData *bd);
90  real_t AijDriverShift3(BSSNData *bd);
91 
92  // Map of strings to functions
93  void _initGaugeMaps()
94  {
95  // Lapse functions
96  lapse_gauge_map["Static"] = &BSSNGaugeHandler::Static;
97  lapse_gauge_map["Harmonic"] = &BSSNGaugeHandler::HarmonicLapse;
98  lapse_gauge_map["ConformalFLRW"] = &BSSNGaugeHandler::ConformalFLRWLapse;
99 #if USE_GENERALIZED_NEWTON
100  // shouldn't be using this gauge w/o extra fields
101  lapse_gauge_map["GeneralizedNewton"] = &BSSNGaugeHandler::GeneralizedNewton;
102 #endif
103  lapse_gauge_map["Anharmonic"] = &BSSNGaugeHandler::AnharmonicLapse;
104  lapse_gauge_map["OnePlusLog"] = &BSSNGaugeHandler::OnePlusLogLapse;
105  lapse_gauge_map["DampedWave"] = &BSSNGaugeHandler::DampedWaveLapse;
106  lapse_gauge_map["ConformalSync"] = &BSSNGaugeHandler::ConformalSyncLapse;
107  lapse_gauge_map["AwAGaugeWave"] = &BSSNGaugeHandler::AwAGaugeWaveLapse;
108  lapse_gauge_map["AwAShiftedWave"] = &BSSNGaugeHandler::AwAShiftedWaveLapse;
109 
110  lapse_gauge_map["TestKDriverLapse"] = &BSSNGaugeHandler::TestKDriverLapse;
111  lapse_gauge_map["TestAijDriverLapse"] = &BSSNGaugeHandler::TestAijDriverLapse;
112 
113  // Shift functions
114  // Static gauge
115  shift_gauge_map["Static"]["1"] = &BSSNGaugeHandler::Static;
116  shift_gauge_map["Static"]["2"] = &BSSNGaugeHandler::Static;
117  shift_gauge_map["Static"]["3"] = &BSSNGaugeHandler::Static;
118  // gamma driver
119  shift_gauge_map["GammaDriver"]["1"] = &BSSNGaugeHandler::GammaDriverShift1;
120  shift_gauge_map["GammaDriver"]["2"] = &BSSNGaugeHandler::GammaDriverShift2;
121  shift_gauge_map["GammaDriver"]["3"] = &BSSNGaugeHandler::GammaDriverShift3;
122  // Damped wave
123  shift_gauge_map["DampedWave"]["1"] = &BSSNGaugeHandler::DampedWaveShift1;
124  shift_gauge_map["DampedWave"]["2"] = &BSSNGaugeHandler::DampedWaveShift2;
125  shift_gauge_map["DampedWave"]["3"] = &BSSNGaugeHandler::DampedWaveShift3;
126  // AwA shifted wave test
127  shift_gauge_map["AwAShiftedWave"]["1"] = &BSSNGaugeHandler::AwAShiftedWaveShift1;
128  shift_gauge_map["AwAShiftedWave"]["2"] = &BSSNGaugeHandler::AwAShiftedWaveShift2;
129  shift_gauge_map["AwAShiftedWave"]["3"] = &BSSNGaugeHandler::AwAShiftedWaveShift3;
130 
131 
132  shift_gauge_map["AijDriverShift"]["1"] = &BSSNGaugeHandler::AijDriverShift1;
133  shift_gauge_map["AijDriverShift"]["2"] = &BSSNGaugeHandler::AijDriverShift2;
134  shift_gauge_map["AijDriverShift"]["3"] = &BSSNGaugeHandler::AijDriverShift3;
135  }
136 
137  void _initDefaultParameters(ConfigParser *config)
138  {
139  gauge_wave_dir = std::stoi((*config)("gauge_wave_dir", "1"));
140  dw_mu_l = std::stod((*config)("dw_mu_l", "0.0"));
141  dw_mu_s = std::stod((*config)("dw_mu_s", "0.0"));
142  dw_p = std::stod((*config)("dw_p", "0.0"));
143  gd_c = std::stod((*config)("gd_c", "1.0"));
144 
145  exp_sync_gauge_c = std::stod((*config)("exp_sync_gauge_c", "1.0"));
146 
147  k_driver_coeff = std::stod((*config)("k_driver_coeff", "0.04"));
148 
149  GN_eta = std::stod((*config)("GN_eta", "0.001"));
150  }
151 
152 public:
153 
158  {
159  ConfigParser emptyConfig;
160  _initGaugeMaps();
161  _initDefaultParameters(&emptyConfig);
162  setLapseFn("Static");
163  setShiftFn("Static");
164  }
165 
169  BSSNGaugeHandler(ConfigParser *config, BSSN *bssnSim)
170  {
171  bssn = bssnSim;
172 
173  _initGaugeMaps();
174  _initDefaultParameters(config);
175  setLapseFn((*config)("lapse", "Static"));
176  setShiftFn((*config)("shift", "Static"));
177 
178  }
179 
183  void setLapseFn(std::string name)
184  {
185  if ( lapse_gauge_map.find(name) == lapse_gauge_map.end() )
186  {
187  std::cout << "Error: Lapse gauge not found: `" << name << "`!\n";
188  throw -1;
189  }
190 
191  std::cout << "Using lapse: `" << name << "`.\n";
192  lapse_fn = lapse_gauge_map[name];
193 
194  }
195 
196 
200  void setShiftFn(std::string name)
201  {
202  // Shift needs to be enabled for non-trivial evolution
203  if(name != "Static" && !USE_BSSN_SHIFT)
204  {
205  std::cerr << "Code must be compiled with shift enabled to use non-Static shift!";
206  throw -1;
207  }
208 
209  // Gamma driver needs an extra field compiled in
210  if(name == "gammadriver" && !USE_GAMMA_DRIVER)
211  {
212  std::cerr << "Code must be compiled with gamma driver enabled to use the gamma driver gauge.";
213  throw -1;
214  }
215 
216 
217  if ( shift_gauge_map.find(name) == shift_gauge_map.end() )
218  {
219  std::cout << "Error: Shift gauge not found: `" << name << "`!\n";
220  throw -1;
221  }
222 
223  shift_fn1 = shift_gauge_map[name]["1"];
224  shift_fn2 = shift_gauge_map[name]["2"];
225  shift_fn3 = shift_gauge_map[name]["3"];
226  }
227 
231  real_t ev_lapse(BSSNData *bd)
232  {
233  return (*this.*lapse_fn)(bd);
234  }
235 
239  real_t ev_shift1(BSSNData *bd)
240  {
241  return (*this.*shift_fn1)(bd);
242  }
243 
247  real_t ev_shift2(BSSNData *bd)
248  {
249  return (*this.*shift_fn2)(bd);
250  }
251 
255  real_t ev_shift3(BSSNData *bd)
256  {
257  return (*this.*shift_fn3)(bd);
258  }
259 
260 };
261 
262 }
263 
264 #endif
real_t gauge_wave_dir
wave direction of prop. ( {1,2,3})
Definition: BSSNGaugeHandler.h:75
bssn_gauge_func_t shift_fn3
Shift evolution function.
Definition: BSSNGaugeHandler.h:36
real_t GammaDriverShift1(BSSNData *bd)
Gamma driver shift in x-dir.
Definition: BSSNGaugeHandler.cc:117
Definition: BSSNGaugeHandler.h:20
real_t AwAShiftedWaveShift2(BSSNData *bd)
AwA shifted gauge wave test shift in y-dir.
Definition: BSSNGaugeHandler.cc:238
real_t ev_lapse(BSSNData *bd)
Lapse evolution function for BSSN class to call.
Definition: BSSNGaugeHandler.h:231
real_t ev_shift2(BSSNData *bd)
Shift in y-dir evolution function for BSSN class to call.
Definition: BSSNGaugeHandler.h:247
real_t dw_mu_l
damped wave "mu_l" parameter
Definition: BSSNGaugeHandler.h:66
real_t OnePlusLogLapse(BSSNData *bd)
1 + log slicing
Definition: BSSNGaugeHandler.cc:64
real_t AwAShiftedWaveShift3(BSSNData *bd)
AwA shifted gauge wave test shift in z-dir.
Definition: BSSNGaugeHandler.cc:249
real_t HarmonicLapse(BSSNData *bd)
Hamonic gauge lapse.
Definition: BSSNGaugeHandler.cc:32
real_t GammaDriverShift3(BSSNData *bd)
Gamma driver shift in z-dir.
Definition: BSSNGaugeHandler.cc:139
real_t(BSSNGaugeHandler::* bssn_gauge_func_t)(BSSNData *bd)
internal function pointer type
Definition: BSSNGaugeHandler.h:23
real_t GammaDriverShift2(BSSNData *bd)
Gamma driver shift in y-dir.
Definition: BSSNGaugeHandler.cc:128
Definition: bardeen.cc:5
real_t Static(BSSNData *bd)
Don&#39;t evolve anything.
Definition: BSSNGaugeHandler.cc:16
BSSNGaugeHandler()
Initialize with static, non-evolving gauge.
Definition: BSSNGaugeHandler.h:157
real_t DampedWaveShift2(BSSNData *bd)
Damped wave gauge shift in y-dir.
Definition: BSSNGaugeHandler.cc:176
bssn_gauge_func_t shift_fn2
Shift evolution function.
Definition: BSSNGaugeHandler.h:35
void setShiftFn(std::string name)
Set the shift function.
Definition: BSSNGaugeHandler.h:200
real_t AwAGaugeWaveLapse(BSSNData *bd)
AwA gauge wave test lapse.
Definition: BSSNGaugeHandler.cc:211
BSSNGaugeHandler(ConfigParser *config, BSSN *bssnSim)
Initialize with gauge determined by config file (default to a "static", non-evolving gauge) ...
Definition: BSSNGaugeHandler.h:169
real_t ConformalFLRWLapse(BSSNData *bd)
Locally conformal FLRW-type lapse.
Definition: BSSNGaugeHandler.cc:24
real_t TestAijDriverLapse(BSSNData *bd)
Trial Lapse function in cosmology.
Definition: BSSNGaugeHandler.cc:107
real_t AnharmonicLapse(BSSNData *bd)
Generalized Newton, see notes.
Definition: BSSNGaugeHandler.cc:51
BSSN Class: evolves BSSN metric fields, computes derived quantities.
Definition: bssn.h:24
real_t AwAShiftedWaveLapse(BSSNData *bd)
AwA shifted gauge wave test lapse.
Definition: BSSNGaugeHandler.cc:219
Structure containing BSSN metric variables and various derived quantities, such as derivatives of BSS...
Definition: bssn_data.h:18
Definition: ConfigParser.h:10
real_t gd_c
Tunable gauge parameter.
Definition: BSSNGaugeHandler.h:48
real_t TestKDriverLapse(BSSNData *bd)
Trial Lapse function in cosmology Assumes reference metric is not used / minkowski.
Definition: BSSNGaugeHandler.cc:93
bssn_gauge_func_t lapse_fn
Lapse evolution function.
Definition: BSSNGaugeHandler.h:33
real_t AijDriverShift1(BSSNData *bd)
Aij driver test gauge.
Definition: BSSNGaugeHandler.cc:262
real_t DampedWaveLapse(BSSNData *bd)
Damped wave gauge lapse.
Definition: BSSNGaugeHandler.cc:150
real_t dw_mu_s
damped wave "mu_s" parameter
Definition: BSSNGaugeHandler.h:67
void setLapseFn(std::string name)
Set the lapse function.
Definition: BSSNGaugeHandler.h:183
real_t ev_shift3(BSSNData *bd)
Shift in z-dir evolution function for BSSN class to call.
Definition: BSSNGaugeHandler.h:255
real_t ConformalSyncLapse(BSSNData *bd)
Untested/experimental gauge choice; conformal synchronous gauge Relies on having reference metric for...
Definition: BSSNGaugeHandler.cc:83
bssn_gauge_func_t shift_fn1
Shift evolution function.
Definition: BSSNGaugeHandler.h:34
real_t dw_p
damped wave "p" parameter
Definition: BSSNGaugeHandler.h:68
real_t DampedWaveShift1(BSSNData *bd)
Damped wave gauge shift in x-dir.
Definition: BSSNGaugeHandler.cc:159
real_t ev_shift1(BSSNData *bd)
Shift in x-dir evolution function for BSSN class to call.
Definition: BSSNGaugeHandler.h:239
real_t AwAShiftedWaveShift1(BSSNData *bd)
AwA shifted gauge wave test shift in x-dir.
Definition: BSSNGaugeHandler.cc:227
real_t DampedWaveShift3(BSSNData *bd)
Damped wave gauge shift in z-dir.
Definition: BSSNGaugeHandler.cc:193