Peano
Loading...
Searching...
No Matches
CCZ4.cpp
Go to the documentation of this file.
1#include "CCZ4.h"
2#include "exahype2/RefinementControl.h"
3#include <algorithm>
4
5#include "Constants.h"
6
7#include <limits>
8
9#include <stdio.h>
10#include <string.h>
11#include "tarch/NonCriticalAssertions.h"
12
13#ifdef IncludeTwoPunctures
15#endif
16
17tarch::logging::Log applications::exahype2::ccz4::CCZ4::_log( "applications::exahype2::ccz4::CCZ4" );
18
19#ifdef IncludeTwoPunctures
20//pre-process, solve the puncture equations
22 //first we set the parameter. TODO:find a way to read parameter from python script
23 //int swi=0;//0--single black hole, 2--BBH hoc, 2--BBH rotation, 3--GW150914
24 //bbhtype=0 head on, 1-b=3, 2-b=2
25
26 if (CCZ4swi==0){
27 tp->par_b=1.0;
28 tp->center_offset[0]=-1.0; tp->center_offset[1]=0.0; tp->center_offset[2]=0.0;
29 tp->target_M_plus=1.0;//adm mass
30 tp->par_P_plus[0]=0.0; tp->par_P_plus[1]=0.0; tp->par_P_plus[2]=0.0;//linear momentum
31 tp->par_S_plus[0]=0.0; tp->par_S_plus[1]=0.0; tp->par_S_plus[2]=0.0;//spin
32 tp->target_M_minus=0.0;//adm mass
33 tp->par_P_minus[0]=0.0; tp->par_P_minus[1]=0.0; tp->par_P_minus[2]=0.0;//linear momentum
34 tp->par_S_minus[0]=0.0; tp->par_S_minus[1]=0.0; tp->par_S_minus[2]=0.0; //spin
35 tp->grid_setup_method="evaluation"; //evaluation or Taylor expansion
36 tp->TP_epsilon=1e-6;}
37
38 if (CCZ4swi==4){
39 tp->par_b=1.0;
40 tp->center_offset[0]=-3.0; tp->center_offset[1]=-2.0; tp->center_offset[2]=0.0;
41 tp->target_M_plus=1.0;//adm mass
42 tp->par_P_plus[0]=0.1; tp->par_P_plus[1]=0.1; tp->par_P_plus[2]=0.0;//linear momentum
43 tp->par_S_plus[0]=0.0; tp->par_S_plus[1]=0.0; tp->par_S_plus[2]=0.0;//spin
44 tp->target_M_minus=0.0;//adm mass
45 tp->par_P_minus[0]=0.0; tp->par_P_minus[1]=0.0; tp->par_P_minus[2]=0.0;//linear momentum
46 tp->par_S_minus[0]=0.0; tp->par_S_minus[1]=0.0; tp->par_S_minus[2]=0.0; //spin
47 tp->grid_setup_method="evaluation"; //evaluation or Taylor expansion
48 tp->TP_epsilon=1e-6;}
49
50 if (CCZ4swi==2 and CCZ4BBHType==0){
51 tp->par_b=2.0;
52 tp->center_offset[0]=0.0; tp->center_offset[1]=0.0; tp->center_offset[2]=0.0;
53 tp->target_M_plus=0.5;//adm mass
54 tp->par_P_plus[0]=0.0; tp->par_P_plus[1]=0.0; tp->par_P_plus[2]=0.0;//linear momentum
55 tp->par_S_plus[0]=0.0; tp->par_S_plus[1]=0.0; tp->par_S_plus[2]=0.0;//spin
56 tp->target_M_minus=0.5;//adm mass
57 tp->par_P_minus[0]=0.0; tp->par_P_minus[1]=0.0; tp->par_P_minus[2]=0.0;//linear momentum
58 tp->par_S_minus[0]=0.0; tp->par_S_minus[1]=0.0; tp->par_S_minus[2]=0.0; //spin
59 tp->grid_setup_method="evaluation"; //evaluation or Taylor expansion
60 tp->TP_epsilon=1e-6;}
61
62 //following data reference: https://journals.aps.org/prd/pdf/10.1103/PhysRevD.69.024006
63 if (CCZ4swi==2 and CCZ4BBHType==1){
64 tp->par_b=5.0;
65 tp->center_offset[0]=0.0; tp->center_offset[1]=0.0; tp->center_offset[2]=0.0;
66 tp->give_bare_mass=true;//use puncture mass instead of adm mass
67 tp->par_m_plus=0.48595; tp->par_m_minus=0.48595;
68 //tp->target_M_plus=999;//adm mass
69 tp->par_P_plus[0]=0.0; tp->par_P_plus[1]=0.095433; tp->par_P_plus[2]=0.0;//linear momentum
70 tp->par_S_plus[0]=0.0; tp->par_S_plus[1]=0.0; tp->par_S_plus[2]=0.0;//spin
71 //tp->target_M_minus=999;//adm mass
72 tp->par_P_minus[0]=0.0; tp->par_P_minus[1]=-0.095433; tp->par_P_minus[2]=0.0;//linear momentum
73 tp->par_S_minus[0]=0.0; tp->par_S_minus[1]=0.0; tp->par_S_minus[2]=0.0; //spin
74 tp->grid_setup_method="evaluation"; //evaluation or Taylor expansion
75 tp->TP_epsilon=1e-6;}
76
77 if (CCZ4swi==2 and CCZ4BBHType==2){
78 tp->par_b=2.0;
79 tp->center_offset[0]=0.0; tp->center_offset[1]=0.0; tp->center_offset[2]=0.0;
80 tp->give_bare_mass=true;//use puncture mass instead of adm mass
81 tp->par_m_plus=0.46477; tp->par_m_minus=0.46477;
82 //tp->target_M_plus=999;//adm mass
83 tp->par_P_plus[0]=0.0; tp->par_P_plus[1]=0.19243; tp->par_P_plus[2]=0.0;//linear momentum
84 tp->par_S_plus[0]=0.0; tp->par_S_plus[1]=0.0; tp->par_S_plus[2]=0.0;//spin
85 //tp->target_M_minus=999;//adm mass
86 tp->par_P_minus[0]=0.0; tp->par_P_minus[1]=-0.19243; tp->par_P_minus[2]=0.0;//linear momentum
87 tp->par_S_minus[0]=0.0; tp->par_S_minus[1]=0.0; tp->par_S_minus[2]=0.0; //spin
88 tp->grid_setup_method="evaluation"; //evaluation or Taylor expansion
89 tp->TP_epsilon=1e-6;}
90
91 if (CCZ4swi==2 and CCZ4BBHType==3){
92 tp->par_b=3.5;
93 tp->center_offset[0]=0.0; tp->center_offset[1]=0.0; tp->center_offset[2]=0.0;
94 tp->give_bare_mass=true;//use puncture mass instead of adm mass
95 tp->par_m_plus=0.47992; tp->par_m_minus=0.47992;
96 //tp->target_M_plus=999;//adm mass
97 tp->par_P_plus[0]=0.0; tp->par_P_plus[1]=0.12287; tp->par_P_plus[2]=0.0;//linear momentum
98 tp->par_S_plus[0]=0.0; tp->par_S_plus[1]=0.0; tp->par_S_plus[2]=0.0;//spin
99 //tp->target_M_minus=999;//adm mass
100 tp->par_P_minus[0]=0.0; tp->par_P_minus[1]=-0.12287; tp->par_P_minus[2]=0.0;//linear momentum
101 tp->par_S_minus[0]=0.0; tp->par_S_minus[1]=0.0; tp->par_S_minus[2]=0.0; //spin
102 tp->grid_setup_method="evaluation"; //evaluation or Taylor expansion
103 tp->TP_epsilon=1e-6;}
104
105 if (CCZ4swi==3){
106 double D=10.0, q=36.0/29.0, chip=0.31, chim=-0.46, M=1.0;
107 double Pr=-0.00084541526517121, Pphi=0.09530152296974252;
108 double mp=M*q/(1+q), mm=M*1/(1+q);
109 tp->par_b=5.0;
110 tp->center_offset[0]=D*mm-D/2; tp->center_offset[1]=0.0; tp->center_offset[2]=0.0;
111 tp->target_M_plus=mp;//adm mass
112 tp->par_P_plus[0]=Pr; tp->par_P_plus[1]=Pphi; tp->par_P_plus[2]=0.0;//linear momentum
113 tp->par_S_plus[0]=0.0; tp->par_S_plus[1]=0.0; tp->par_S_plus[2]=chip*mp*mp;//spin
114 tp->target_M_minus=1/(1+q);//adm mass
115 tp->par_P_minus[0]=-Pr; tp->par_P_minus[1]=-Pphi; tp->par_P_minus[2]=0.0;//linear momentum
116 tp->par_S_minus[0]=0.0; tp->par_S_minus[1]=0.0; tp->par_S_minus[2]=chim*mm*mm; //spin
117 tp->grid_setup_method="evaluation"; //evaluation or Taylor expansion
118 tp->TP_epsilon=1e-6;}
119 tp->PrintParameters();
120
121 //then solve the equation
122 tp->Run();
123}
124#endif
125
127 if ( Scenario==0 || Scenario==1 ) {
128 const char* name = "GaugeWave";//nothing to do here for now
129 int length = strlen(name);
130 //initparameters_(&length, name);
131 }
132 #ifdef IncludeTwoPunctures
133 if ( Scenario==2 ) {
134 prepare(_tp);//we solve the puncture equation here.
135 //exit(0);
136 }
137 #endif
138 else {
139 //std::cerr << "initial scenario " << Scenario << " is not supported" << std::endl << std::endl << std::endl;
140 }
141}
142
144 double * NOALIAS Q,
145 const tarch::la::Vector<DIMENSIONS,double>& volumeX,
146 const tarch::la::Vector<DIMENSIONS,double>& volumeH
147) {
148 if ( Scenario==0 ) {
150 }
151 else if ( Scenario==3 ) {
153 }
154 else if ( Scenario==1 ) {
156 }
157 else if ( Scenario==4 ) {
159 }
160 #ifdef IncludeTwoPunctures
161 else if ( Scenario==2 ) {
162
163 applications::exahype2::ccz4::ApplyTwoPunctures(Q, volumeX, 0, _tp, false); //we interpolate for real IC here.
164 }
165 #endif
166 else {
167 logError( "initialCondition(...)", "initial scenario " << Scenario << " is not supported" );
168 }
169
170 for (int i=0; i<NumberOfUnknowns; i++) {
171 assertion2( std::isfinite(Q[i]), volumeX, i );
172 }
173
174 for (int i=NumberOfUnknowns; i<NumberOfUnknowns+NumberOfAuxiliaryVariables; i++) {
175 Q[i] = 0.0;
176 }
177}
178
179
181 const double * NOALIAS Q, // Q[59+0]
182 const tarch::la::Vector<DIMENSIONS,double>& volumeX,
183 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
184 double t,
185 double dt,
186 double * NOALIAS S // S[59
187) {
188 logTraceInWith4Arguments( "sourceTerm(...)", volumeX, volumeH, t, dt );
189 for(int i=0; i<NumberOfUnknowns; i++){
190 assertion3( std::isfinite(Q[i]), i, volumeX, t );
191 }
192#endif
193 applications::exahype2::ccz4::CCZ4::sourceTerm(Q, volumeX, volumeH, t, dt, S, Offloadable::Yes);
194
195 for(int i=0; i<NumberOfUnknowns; i++){
196 nonCriticalAssertion3( std::isfinite(S[i]), i, volumeX, t );
197 }
198 logTraceOut( "sourceTerm(...)" );
199}
200
201
203 const double * NOALIAS Qinside, // Qinside[59+0]
204 double * NOALIAS Qoutside, // Qoutside[59+0]
205 const tarch::la::Vector<DIMENSIONS,double>& faceCentre,
206 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
207 double t,
208 int normal
209) {
210 logTraceInWith4Arguments( "boundaryConditions(...)", faceCentre, volumeH, t, normal );
211 for(int i=0; i<NumberOfUnknowns+NumberOfAuxiliaryVariables; i++) {
212 assertion4( Qinside[i]==Qinside[i], faceCentre, t, normal, i );
213 Qoutside[i]=Qinside[i];
214 }
215 logTraceOut( "boundaryConditions(...)" );
216}
217
218
220 const double * NOALIAS Q, // Q[59+0],
221 const tarch::la::Vector<DIMENSIONS,double>& faceCentre,
222 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
223 double t,
224 double dt,
225 int normal
226)
227{
228 return maxEigenvalue(Q, faceCentre, volumeH, t, dt, normal, Offloadable::Yes);
229}
230
231
233 const double * NOALIAS Q, // Q[59+0],
234 const double * NOALIAS deltaQ, // [59+0]
235 const tarch::la::Vector<DIMENSIONS,double>& faceCentre,
236 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
237 double t,
238 double dt,
239 int normal,
240 double * NOALIAS BgradQ // BgradQ[59]
241) {
242 logTraceInWith4Arguments( "nonconservativeProduct(...)", faceCentre, volumeH, t, normal );
243 assertion( normal>=0 );
244 assertion( normal<DIMENSIONS );
245 nonconservativeProduct(Q, deltaQ, faceCentre, volumeH, t, dt, normal, BgradQ, Offloadable::Yes);
246
247 for (int i=0; i<NumberOfUnknowns; i++) {
248 nonCriticalAssertion4( std::isfinite(BgradQ[i]), i, faceCentre, t, normal );
249 }
250 logTraceOut( "nonconservativeProduct(...)" );
251}
252
254 const double * NOALIAS Q, // Q[59+0],
255 const double * NOALIAS deltaQ, // [59+0]
256 const tarch::la::Vector<DIMENSIONS,double>& faceCentre,
257 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
258 double t,
259 double dt,
260 int normal,
261 double * NOALIAS BgradQ, // BgradQ[59]
262 Offloadable
263)
264{
265 double gradQSerialised[NumberOfUnknowns*3];
266 for (int i=0; i<NumberOfUnknowns; i++) {
267 gradQSerialised[i+0*NumberOfUnknowns] = 0.0;
268 gradQSerialised[i+1*NumberOfUnknowns] = 0.0;
269 gradQSerialised[i+2*NumberOfUnknowns] = 0.0;
270
271 gradQSerialised[i+normal*NumberOfUnknowns] = deltaQ[i];
272 }
273 ncp(BgradQ, Q, gradQSerialised, normal, CCZ4LapseType, CCZ4ds, CCZ4c, CCZ4e, CCZ4f, CCZ4bs, CCZ4sk, CCZ4xi, CCZ4mu, CCZ4SO);
274}
275
277 const double * NOALIAS Q,
278 const tarch::la::Vector<DIMENSIONS,double>& volumeCentre,
279 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
280 double t
281) {
282 ::exahype2::RefinementCommand result = ::exahype2::RefinementCommand::Keep;
283
284 const double radius = tarch::la::norm2( volumeCentre );
285 //
286 // see documentation in header file
287 // current options: 1, 2, 3, 6, 7
288 //
289 if (CCZ4ReSwi==1) { //radius based
290 if (radius<0.1) {
291 result=::exahype2::RefinementCommand::Refine;
292 }
293 }
294 if (CCZ4ReSwi==2) { //
295 if (tarch::la::equals(t,0.0)){ //static AMR, for bbh, type==1
296 constexpr int NumberOfRefinementLayers = 2;
297// current "standard" refinement pattern
298 double Radius[NumberOfRefinementLayers] = {6, 4.5};
299 double MaxH[NumberOfRefinementLayers] = {0.15,0.04};
300 result = ::exahype2::RefinementCommand::Keep;
301 for (int i=0; i<NumberOfRefinementLayers; i++) {
302 if (radius<Radius[i] and tarch::la::max(volumeH)>MaxH[i]) {
303 result=::exahype2::RefinementCommand::Refine;
304 }
305 }
306 }
307 }
308 if (CCZ4ReSwi==3) { //not used
309 tarch::la::Vector<DIMENSIONS,double> leftBH = {-4.241, 0.0, 0.0};
310 tarch::la::Vector<DIMENSIONS,double> rightBH = { 4.241, 0.0, 0.0};
311
312 const double radius1 = tarch::la::norm2( volumeCentre - leftBH );
313 const double radius2 = tarch::la::norm2( volumeCentre - rightBH );
314
315 if (tarch::la::equals(t,0.0)){ //as we use a quantity calculated in postpocessing, we need to provide criterion at the first timestep
316 if ( ((radius1<5) or (radius2<5)) and (volumeH(0)>1.0)) { result=::exahype2::RefinementCommand::Refine; }
317 else if ((radius1<2.5) or (radius2<2.5)) { result=::exahype2::RefinementCommand::Refine; }
318 else {result = ::exahype2::RefinementCommand::Keep;}
319 } else {
320 if ((Q[65]>0.1) and (volumeH(0)>1.0)) { result=::exahype2::RefinementCommand::Refine; }
321 else if (Q[65]>0.2) { result=::exahype2::RefinementCommand::Refine; }
322 else {result = ::exahype2::RefinementCommand::Keep;}
323 }
324 }
325 if (CCZ4ReSwi==6){
326 if (tarch::la::equals(t,0.0)){ //static AMR, for bbh, type==0, 2
327 constexpr int NumberOfRefinementLayers = 2;
328 double Radius[NumberOfRefinementLayers] = {4, 3};
329 double MaxH[NumberOfRefinementLayers] = {0.15,0.04}; // {0.17,0.06}; {0.1,0.035};
330
331 result = ::exahype2::RefinementCommand::Keep;
332 for (int i=0; i<NumberOfRefinementLayers; i++) {
333 if (radius<Radius[i] and tarch::la::max(volumeH)>MaxH[i]) {
334 result=::exahype2::RefinementCommand::Refine;
335 }
336 }
337 }
338 }
339 if (CCZ4ReSwi==7){
340 if (tarch::la::equals(t,0.0)){ //static AMR, for sbh
341 constexpr int NumberOfRefinementLayers = 2;
342 double Radius[NumberOfRefinementLayers] = {3.0, 1.5};
343 double MaxH[NumberOfRefinementLayers] = {0.15,0.04};
344 result = ::exahype2::RefinementCommand::Keep;
345 for (int i=0; i<NumberOfRefinementLayers; i++) {
346 if (radius<Radius[i] and tarch::la::max(volumeH)>MaxH[i]) {
347 result=::exahype2::RefinementCommand::Refine;
348 }
349 }
350 }
351 }
352 return result;
353}
354
TP::TwoPunctures * _tp
Definition CCZ4.cpp:14
::exahype2::RefinementCommand refinementCriterion(const double *NOALIAS Q, const tarch::la::Vector< DIMENSIONS, double > &volumeCentre, const tarch::la::Vector< DIMENSIONS, double > &volumeH, double t) override
Refinement criterion.
Definition CCZ4.cpp:276
virtual void boundaryConditions(const double *NOALIAS Qinside, double *NOALIAS Qoutside, const tarch::la::Vector< DIMENSIONS, double > &faceCentre, const tarch::la::Vector< DIMENSIONS, double > &volumeH, double t, int normal) override
Definition CCZ4.cpp:202
void prepare(TP::TwoPunctures *tp)
Definition CCZ4.cpp:21
static tarch::logging::Log _log
Definition CCZ4.h:32
void initialCondition(double *NOALIAS Q, const tarch::la::Vector< DIMENSIONS, double > &volumeCentre, const tarch::la::Vector< DIMENSIONS, double > &volumeH) override
Definition CCZ4.cpp:143
void sourceTerm(const double *NOALIAS Q, const tarch::la::Vector< DIMENSIONS, double > &volumeCentre, const tarch::la::Vector< DIMENSIONS, double > &volumeH, double t, double dt, double *NOALIAS S) override
Definition CCZ4.cpp:180
virtual void nonconservativeProduct(const double *NOALIAS Q, const double *NOALIAS deltaQ, const tarch::la::Vector< DIMENSIONS, double > &faceCentre, const tarch::la::Vector< DIMENSIONS, double > &volumeH, double t, double dt, int normal, double *NOALIAS BgradQ) override
Definition CCZ4.cpp:232
virtual double maxEigenvalue(const double *NOALIAS Q, const tarch::la::Vector< DIMENSIONS, double > &faceCentre, const tarch::la::Vector< DIMENSIONS, double > &volumeH, double t, double dt, int normal) override
Determine max eigenvalue over Jacobian in a given point with solution values (states) Q.
Definition CCZ4.cpp:219
void diagonal_gaugeWave(double *NOALIAS Q, const tarch::la::Vector< DIMENSIONS, double > &x, double t)
static void ncp(double *BgradQ, const double *const Q, const double *const gradQSerialised, const int normal, const int CCZ4LapseType, const double CCZ4ds, const double CCZ4c, const double CCZ4e, const double CCZ4f, const double CCZ4bs, const double CCZ4sk, const double CCZ4xi, const double CCZ4mu, const double CCZ4SO)
void linearWave(double *NOALIAS Q, const tarch::la::Vector< DIMENSIONS, double > &X, double t)
void ApplyTwoPunctures(double *NOALIAS Q, const tarch::la::Vector< DIMENSIONS, double > &X, double t, TP::TwoPunctures *tp, bool low_res)
void flat(double *NOALIAS Q, const tarch::la::Vector< DIMENSIONS, double > &X, double t)
static double maxEigenvalue(const double *const Q, int normal, const double CCZ4e, const double CCZ4ds, const double CCZ4GLMc, const double CCZ4GLMd)
void gaugeWave(double *NOALIAS Q, const tarch::la::Vector< DIMENSIONS, double > &x, double t)
double par_S_plus[3]
std::string grid_setup_method
double par_P_plus[3]
double par_S_minus[3]
double center_offset[3]
double target_M_minus
double par_P_minus[3]