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 static TP::TwoPunctures tp;
16 return tp;
17}
18#endif
19
20tarch::logging::Log benchmarks::exahype2::ccz4::CCZ4::_log( "benchmarks::exahype2::ccz4::CCZ4" );
21
22#ifdef IncludeTwoPunctures
23//pre-process, solve the puncture equations
25 //first we set the parameter. TODO:find a way to read parameter from python script
26 //int swi=0;//0--single black hole, 2--BBH hoc, 2--BBH rotation, 3--GW150914
27 //bbhtype=0 head on, 1-b=3, 2-b=2
28
29 if constexpr (CCZ4swi==0){
30 tp->par_b=1.0;
31 tp->center_offset[0]=-1.0; tp->center_offset[1]=0.0; tp->center_offset[2]=0.0;
32 tp->target_M_plus=1.0;//adm mass
33 tp->par_P_plus[0]=0.0; tp->par_P_plus[1]=0.0; tp->par_P_plus[2]=0.0;//linear momentum
34 tp->par_S_plus[0]=0.0; tp->par_S_plus[1]=0.0; tp->par_S_plus[2]=0.0;//spin
35 tp->target_M_minus=0.0;//adm mass
36 tp->par_P_minus[0]=0.0; tp->par_P_minus[1]=0.0; tp->par_P_minus[2]=0.0;//linear momentum
37 tp->par_S_minus[0]=0.0; tp->par_S_minus[1]=0.0; tp->par_S_minus[2]=0.0; //spin
38 tp->grid_setup_method="evaluation"; //evaluation or Taylor expansion
39 tp->TP_epsilon=1e-6;}
40
41 if constexpr (CCZ4swi==4){
42 tp->par_b=1.0;
43 tp->center_offset[0]=-3.0; tp->center_offset[1]=-2.0; tp->center_offset[2]=0.0;
44 tp->target_M_plus=1.0;//adm mass
45 tp->par_P_plus[0]=0.1; tp->par_P_plus[1]=0.1; tp->par_P_plus[2]=0.0;//linear momentum
46 tp->par_S_plus[0]=0.0; tp->par_S_plus[1]=0.0; tp->par_S_plus[2]=0.0;//spin
47 tp->target_M_minus=0.0;//adm mass
48 tp->par_P_minus[0]=0.0; tp->par_P_minus[1]=0.0; tp->par_P_minus[2]=0.0;//linear momentum
49 tp->par_S_minus[0]=0.0; tp->par_S_minus[1]=0.0; tp->par_S_minus[2]=0.0; //spin
50 tp->grid_setup_method="evaluation"; //evaluation or Taylor expansion
51 tp->TP_epsilon=1e-6;}
52
53 if constexpr (CCZ4swi==2 and CCZ4BBHType==0){
54 tp->par_b=2.0;
55 tp->center_offset[0]=0.0; tp->center_offset[1]=0.0; tp->center_offset[2]=0.0;
56 tp->target_M_plus=0.5;//adm mass
57 tp->par_P_plus[0]=0.0; tp->par_P_plus[1]=0.0; tp->par_P_plus[2]=0.0;//linear momentum
58 tp->par_S_plus[0]=0.0; tp->par_S_plus[1]=0.0; tp->par_S_plus[2]=0.0;//spin
59 tp->target_M_minus=0.5;//adm mass
60 tp->par_P_minus[0]=0.0; tp->par_P_minus[1]=0.0; tp->par_P_minus[2]=0.0;//linear momentum
61 tp->par_S_minus[0]=0.0; tp->par_S_minus[1]=0.0; tp->par_S_minus[2]=0.0; //spin
62 tp->grid_setup_method="evaluation"; //evaluation or Taylor expansion
63 tp->TP_epsilon=1e-6;}
64
65 //following data reference: https://journals.aps.org/prd/pdf/10.1103/PhysRevD.69.024006
66 if constexpr (CCZ4swi==2 and CCZ4BBHType==1){
67 tp->par_b=5.0;
68 tp->center_offset[0]=0.0; tp->center_offset[1]=0.0; tp->center_offset[2]=0.0;
69 tp->give_bare_mass=true;//use puncture mass instead of adm mass
70 tp->par_m_plus=0.48595; tp->par_m_minus=0.48595;
71 //tp->target_M_plus=999;//adm mass
72 tp->par_P_plus[0]=0.0; tp->par_P_plus[1]=0.095433; tp->par_P_plus[2]=0.0;//linear momentum
73 tp->par_S_plus[0]=0.0; tp->par_S_plus[1]=0.0; tp->par_S_plus[2]=0.0;//spin
74 //tp->target_M_minus=999;//adm mass
75 tp->par_P_minus[0]=0.0; tp->par_P_minus[1]=-0.095433; tp->par_P_minus[2]=0.0;//linear momentum
76 tp->par_S_minus[0]=0.0; tp->par_S_minus[1]=0.0; tp->par_S_minus[2]=0.0; //spin
77 tp->grid_setup_method="evaluation"; //evaluation or Taylor expansion
78 tp->TP_epsilon=1e-6;}
79
80 if constexpr (CCZ4swi==2 and CCZ4BBHType==2){
81 tp->par_b=2.0;
82 tp->center_offset[0]=0.0; tp->center_offset[1]=0.0; tp->center_offset[2]=0.0;
83 tp->give_bare_mass=true;//use puncture mass instead of adm mass
84 tp->par_m_plus=0.46477; tp->par_m_minus=0.46477;
85 //tp->target_M_plus=999;//adm mass
86 tp->par_P_plus[0]=0.0; tp->par_P_plus[1]=0.19243; tp->par_P_plus[2]=0.0;//linear momentum
87 tp->par_S_plus[0]=0.0; tp->par_S_plus[1]=0.0; tp->par_S_plus[2]=0.0;//spin
88 //tp->target_M_minus=999;//adm mass
89 tp->par_P_minus[0]=0.0; tp->par_P_minus[1]=-0.19243; tp->par_P_minus[2]=0.0;//linear momentum
90 tp->par_S_minus[0]=0.0; tp->par_S_minus[1]=0.0; tp->par_S_minus[2]=0.0; //spin
91 tp->grid_setup_method="evaluation"; //evaluation or Taylor expansion
92 tp->TP_epsilon=1e-6;}
93
94 if constexpr (CCZ4swi==3){
95 double D=10.0, q=36.0/29.0, chip=0.31, chim=-0.46, M=1.0;
96 double Pr=-0.00084541526517121, Pphi=0.09530152296974252;
97 double mp=M*q/(1+q), mm=M*1/(1+q);
98 tp->par_b=5.0;
99 tp->center_offset[0]=D*mm-D/2; tp->center_offset[1]=0.0; tp->center_offset[2]=0.0;
100 tp->target_M_plus=mp;//adm mass
101 tp->par_P_plus[0]=Pr; tp->par_P_plus[1]=Pphi; tp->par_P_plus[2]=0.0;//linear momentum
102 tp->par_S_plus[0]=0.0; tp->par_S_plus[1]=0.0; tp->par_S_plus[2]=chip*mp*mp;//spin
103 tp->target_M_minus=1/(1+q);//adm mass
104 tp->par_P_minus[0]=-Pr; tp->par_P_minus[1]=-Pphi; tp->par_P_minus[2]=0.0;//linear momentum
105 tp->par_S_minus[0]=0.0; tp->par_S_minus[1]=0.0; tp->par_S_minus[2]=chim*mm*mm; //spin
106 tp->grid_setup_method="evaluation"; //evaluation or Taylor expansion
107 tp->TP_epsilon=1e-6;}
108 tp->PrintParameters();
109
110 //then solve the equation
111 tp->Run();
112}
113#endif
114
116 if constexpr ( Scenario==0 || Scenario==1 ) {
117 const char* name = "GaugeWave";//nothing to do here for now
118 int length = strlen(name);
119 //initparameters_(&length, name);
120 }
121 #ifdef IncludeTwoPunctures
122 if constexpr ( Scenario==2 ) {
123 prepare(&getTP());//we solve the puncture equation here.
124 //exit(0);
125 }
126 #endif
127 else {
128 //std::cerr << "initial scenario " << Scenario << " is not supported" << std::endl << std::endl << std::endl;
129 }
130}
131
133 double * NOALIAS Q,
134 const tarch::la::Vector<DIMENSIONS,double>& volumeX,
135 const tarch::la::Vector<DIMENSIONS,double>& volumeH
136) {
137 if ( Scenario==0 ) {
139 }
140 else if ( Scenario==3 ) {
142 }
143 else if ( Scenario==1 ) {
145 }
146 else if ( Scenario==4 ) {
148 }
149 #ifdef IncludeTwoPunctures
150 else if ( Scenario==2 ) {
151
152 applications::exahype2::ccz4::ApplyTwoPunctures(Q, volumeX, 0, &getTP(), false); //we interpolate for real IC here.
153 }
154 #endif
155 else {
156 logError( "initialCondition(...)", "initial scenario " << Scenario << " is not supported" );
157 }
158
159 for (int i=0; i<NumberOfUnknowns; i++) {
160 assertion2( std::isfinite(Q[i]), volumeX, i );
161 }
162
163 for (int i=NumberOfUnknowns; i<NumberOfUnknowns+NumberOfAuxiliaryVariables; i++) {
164 Q[i] = 0.0;
165 }
166}
167
168
170 const double * NOALIAS Q, // Q[59+0]
171 const tarch::la::Vector<DIMENSIONS,double>& volumeX,
172 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
173 double t,
174 double dt,
175 double * NOALIAS S // S[59
176) {
177 logTraceInWith4Arguments( "sourceTerm(...)", volumeX, volumeH, t, dt );
178 for(int i=0; i<NumberOfUnknowns; i++){
179 assertion3( std::isfinite(Q[i]), i, volumeX, t );
180 }
181
182 benchmarks::exahype2::ccz4::CCZ4::sourceTerm(Q, volumeX, volumeH, t, dt, S, Offloadable::Yes);
183
184 for(int i=0; i<NumberOfUnknowns; i++){
185 nonCriticalAssertion3( std::isfinite(S[i]), i, volumeX, t );
186 }
187 logTraceOut( "sourceTerm(...)" );
188}
189
190
192 const double * NOALIAS Qinside, // Qinside[59+0]
193 double * NOALIAS Qoutside, // Qoutside[59+0]
194 const tarch::la::Vector<DIMENSIONS,double>& faceCentre,
195 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
196 double t,
197 int normal
198) {
199 logTraceInWith4Arguments( "boundaryConditions(...)", faceCentre, volumeH, t, normal );
200 for(int i=0; i<NumberOfUnknowns+NumberOfAuxiliaryVariables; i++) {
201 assertion4( Qinside[i]==Qinside[i], faceCentre, t, normal, i );
202 Qoutside[i]=Qinside[i];
203 }
204 logTraceOut( "boundaryConditions(...)" );
205}
206
207
209 const double * NOALIAS Q, // Q[59+0],
210 const tarch::la::Vector<DIMENSIONS,double>& faceCentre,
211 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
212 double t,
213 double dt,
214 int normal
215)
216{
217 return maxEigenvalue(Q, faceCentre, volumeH, t, dt, normal, Offloadable::Yes);
218}
219
220
222 const double * NOALIAS Q, // Q[59+0],
223 const double * NOALIAS deltaQ, // [59+0]
224 const tarch::la::Vector<DIMENSIONS,double>& faceCentre,
225 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
226 double t,
227 double dt,
228 int normal,
229 double * NOALIAS BgradQ // BgradQ[59]
230) {
231 logTraceInWith4Arguments( "nonconservativeProduct(...)", faceCentre, volumeH, t, normal );
232 assertion( normal>=0 );
233 assertion( normal<DIMENSIONS );
234 nonconservativeProduct(Q, deltaQ, faceCentre, volumeH, t, dt, normal, BgradQ, Offloadable::Yes);
235
236 for (int i=0; i<NumberOfUnknowns; i++) {
237 nonCriticalAssertion4( std::isfinite(BgradQ[i]), i, faceCentre, t, normal );
238 }
239 logTraceOut( "nonconservativeProduct(...)" );
240}
241
243 const double * NOALIAS Q, // Q[59+0],
244 const double * NOALIAS deltaQ, // [59+0]
245 const tarch::la::Vector<DIMENSIONS,double>& faceCentre,
246 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
247 double t,
248 double dt,
249 int normal,
250 double * NOALIAS BgradQ, // BgradQ[59]
251 Offloadable
252)
253{
254 double gradQSerialised[NumberOfUnknowns*3];
255 for (int i=0; i<NumberOfUnknowns; i++) {
256 gradQSerialised[i+0*NumberOfUnknowns] = 0.0;
257 gradQSerialised[i+1*NumberOfUnknowns] = 0.0;
258 gradQSerialised[i+2*NumberOfUnknowns] = 0.0;
259
260 gradQSerialised[i+normal*NumberOfUnknowns] = deltaQ[i];
261 }
262 //for (int i=NumberOfUnknowns; i<NumberOfUnknowns+NumberOfAuxiliaryVariables; i++) {
263 // BgradQ[i] = 0.0;
264 //}
265 applications::exahype2::ccz4::ncp(BgradQ, Q, gradQSerialised, normal, CCZ4LapseType, CCZ4ds, CCZ4c, CCZ4e, CCZ4f, CCZ4bs, CCZ4sk, CCZ4xi, CCZ4mu, CCZ4SO);
266}
267
269 const double * NOALIAS Q,
270 const tarch::la::Vector<DIMENSIONS,double>& volumeCentre,
271 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
272 double t
273) {
274 ::exahype2::RefinementCommand result = ::exahype2::RefinementCommand::Keep;
275
276 const double radius = tarch::la::norm2( volumeCentre );
277 //
278 // see documentation in header file
279 //
280 if (CCZ4ReSwi==1) { //radius based
281 if (radius<0.1) {
282 result=::exahype2::RefinementCommand::Refine;
283 }
284 }
285 if (CCZ4ReSwi==2) { //
286 if (tarch::la::equals(t,0.0)){ //static AMR, for bbh, type==1
287 constexpr int NumberOfRefinementLayers = 2;
288// current "standard" refinement pattern
289 double Radius[NumberOfRefinementLayers] = {3.0, 1.5};
290 double MaxH[NumberOfRefinementLayers] = {0.15,0.04};
291 result = ::exahype2::RefinementCommand::Keep;
292 for (int i=0; i<NumberOfRefinementLayers; i++) {
293 if (radius<Radius[i] and tarch::la::max(volumeH)>MaxH[i]) {
294 result=::exahype2::RefinementCommand::Refine;
295 }
296 }
297 }
298 }
299 return result;
300}
301
TP::TwoPunctures & getTP()
Definition CCZ4.cpp:14
void initialCondition(double *NOALIAS Q, const tarch::la::Vector< DIMENSIONS, double > &volumeCentre, const tarch::la::Vector< DIMENSIONS, double > &volumeH) override
Definition CCZ4.cpp:17
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:221
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:208
::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:69
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:55
static tarch::logging::Log _log
Definition CCZ4.h:32
void prepare(TP::TwoPunctures *tp)
Definition CCZ4.cpp:24
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:169
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)
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]