2 #include "exahype2/RefinementControl.h"
11 #include "tarch/NonCriticalAssertions.h"
13 #ifdef IncludeTwoPunctures
19 #ifdef IncludeTwoPunctures
50 if (CCZ4swi==2 and CCZ4BBHType==0){
63 if (CCZ4swi==2 and CCZ4BBHType==1){
77 if (CCZ4swi==2 and CCZ4BBHType==2){
92 double D=10.0, q=36.0/29.0, chip=0.31, chim=-0.46, M=1.0;
93 double Pr=-0.00084541526517121, Pphi=0.09530152296974252;
94 double mp=M*q/(1+q), mm=M*1/(1+q);
114 const char*
name =
"GaugeWave";
115 int length = strlen(
name);
118 #ifdef IncludeTwoPunctures
131 const tarch::la::Vector<DIMENSIONS,double>& volumeX,
132 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
133 bool gridIsConstructed
135 logTraceInWith3Arguments(
"initialCondition(...)", volumeX, volumeH, gridIsConstructed );
149 #ifdef IncludeTwoPunctures
157 logError(
"initialCondition(...)",
"initial scenario " <<
Scenario <<
" is not supported" );
160 for (
int i=0; i<NumberOfUnknowns; i++) {
161 assertion2( std::isfinite(Q[i]), volumeX, i );
164 for (
int i=NumberOfUnknowns; i<NumberOfUnknowns+NumberOfAuxiliaryVariables; i++) {
174 logTraceOut(
"initialCondition(...)" );
179 const double * NOALIAS Q,
180 const tarch::la::Vector<DIMENSIONS,double>& volumeX,
181 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
186 #if !defined(WITH_GPU_OMP_TARGET)
187 logTraceInWith4Arguments(
"sourceTerm(...)", volumeX, volumeH,
t,
dt );
188 for(
int i=0; i<NumberOfUnknowns; i++){
189 assertion3( std::isfinite(Q[i]), i, volumeX,
t );
222 #if !defined(WITH_GPU_OMP_TARGET)
223 for(
int i=0; i<NumberOfUnknowns; i++){
224 nonCriticalAssertion3( std::isfinite(S[i]), i, volumeX,
t );
226 logTraceOut(
"sourceTerm(...)" );
232 const double * NOALIAS Qinside,
233 double * NOALIAS Qoutside,
234 const tarch::la::Vector<DIMENSIONS,double>& faceCentre,
235 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
239 logTraceInWith4Arguments(
"boundaryConditions(...)", faceCentre, volumeH,
t, normal );
240 for(
int i=0; i<NumberOfUnknowns+NumberOfAuxiliaryVariables; i++) {
241 assertion4( Qinside[i]==Qinside[i], faceCentre,
t, normal, i );
242 Qoutside[i]=Qinside[i];
244 logTraceOut(
"boundaryConditions(...)" );
249 const double * NOALIAS Q,
250 const tarch::la::Vector<DIMENSIONS,double>& faceCentre,
251 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
257 return maxEigenvalue(Q, faceCentre, volumeH,
t,
dt, normal, Offloadable::Yes);
262 const double * NOALIAS Q,
263 const double * NOALIAS deltaQ,
264 const tarch::la::Vector<DIMENSIONS,double>& faceCentre,
265 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
269 double * NOALIAS BgradQ
271 #if !defined(WITH_GPU_OMP_TARGET)
272 logTraceInWith4Arguments(
"nonconservativeProduct(...)", faceCentre, volumeH,
t, normal );
273 assertion( normal>=0 );
274 assertion( normal<DIMENSIONS );
276 nonconservativeProduct(Q, deltaQ, faceCentre, volumeH,
t,
dt, normal, BgradQ, Offloadable::Yes);
278 #if !defined(WITH_GPU_OMP_TARGET)
279 for (
int i=0; i<NumberOfUnknowns; i++) {
280 nonCriticalAssertion4( std::isfinite(BgradQ[i]), i, faceCentre,
t, normal );
282 logTraceOut(
"nonconservativeProduct(...)" );
286 #if defined(WITH_GPU_OMP_TARGET)
287 #pragma omp declare target
290 const double * NOALIAS Q,
291 const double * NOALIAS deltaQ,
292 const tarch::la::Vector<DIMENSIONS,double>& faceCentre,
293 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
297 double * NOALIAS BgradQ,
301 double gradQSerialised[NumberOfUnknowns*3];
302 for (
int i=0; i<NumberOfUnknowns; i++) {
303 gradQSerialised[i+0*NumberOfUnknowns] = 0.0;
304 gradQSerialised[i+1*NumberOfUnknowns] = 0.0;
305 gradQSerialised[i+2*NumberOfUnknowns] = 0.0;
307 gradQSerialised[i+normal*NumberOfUnknowns] = deltaQ[i];
312 ncp(BgradQ, Q, gradQSerialised, normal, CCZ4LapseType, CCZ4ds, CCZ4c, CCZ4e, CCZ4f, CCZ4bs, CCZ4sk, CCZ4xi, CCZ4mu, CCZ4SO);
314 #if defined(WITH_GPU_OMP_TARGET)
315 #pragma omp end declare target
319 const double * NOALIAS Q,
320 const tarch::la::Vector<DIMENSIONS,double>& volumeCentre,
321 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
324 ::exahype2::RefinementCommand result = ::exahype2::RefinementCommand::Keep;
332 result=::exahype2::RefinementCommand::Refine;
336 if (tarch::la::equals(
t,0.0)){
337 constexpr
int NumberOfRefinementLayers = 2;
339 double Radius[NumberOfRefinementLayers] = {8, 6};
340 double MaxH[NumberOfRefinementLayers] = {0.15,0.04};
341 result = ::exahype2::RefinementCommand::Keep;
342 for (
int i=0; i<NumberOfRefinementLayers; i++) {
343 if (radius<Radius[i] and tarch::la::max(volumeH)>MaxH[i]) {
344 result=::exahype2::RefinementCommand::Refine;
350 tarch::la::Vector<DIMENSIONS,double> leftBH = {-4.241, 0.0, 0.0};
351 tarch::la::Vector<DIMENSIONS,double> rightBH = { 4.241, 0.0, 0.0};
356 if (tarch::la::equals(
t,0.0)){
357 if ( ((radius1<5) or (radius2<5)) and (volumeH(0)>1.0)) { result=::exahype2::RefinementCommand::Refine; }
358 else if ((radius1<2.5) or (radius2<2.5)) { result=::exahype2::RefinementCommand::Refine; }
359 else {result = ::exahype2::RefinementCommand::Keep;}
361 if ((Q[65]>0.1) and (volumeH(0)>1.0)) { result=::exahype2::RefinementCommand::Refine; }
362 else if (Q[65]>0.2) { result=::exahype2::RefinementCommand::Refine; }
363 else {result = ::exahype2::RefinementCommand::Keep;}
367 if (tarch::la::equals(
t,0.0)){
368 constexpr
int NumberOfRefinementLayers = 2;
369 double Radius[NumberOfRefinementLayers] = {4, 3};
370 double MaxH[NumberOfRefinementLayers] = {0.17,0.06};
372 result = ::exahype2::RefinementCommand::Keep;
373 for (
int i=0; i<NumberOfRefinementLayers; i++) {
374 if (radius<Radius[i] and tarch::la::max(volumeH)>MaxH[i]) {
375 result=::exahype2::RefinementCommand::Refine;
381 if (tarch::la::equals(
t,0.0)){
382 constexpr
int NumberOfRefinementLayers = 2;
383 double Radius[NumberOfRefinementLayers] = {4, 3};
384 double MaxH[NumberOfRefinementLayers] = {0.15,0.04};
386 result = ::exahype2::RefinementCommand::Keep;
387 for (
int i=0; i<NumberOfRefinementLayers; i++) {
388 if (radius<Radius[i] and tarch::la::max(volumeH)>MaxH[i]) {
389 result=::exahype2::RefinementCommand::Refine;
395 if (tarch::la::equals(
t,0.0)){
396 constexpr
int NumberOfRefinementLayers = 2;
397 double Radius[NumberOfRefinementLayers] = {4, 3};
398 double MaxH[NumberOfRefinementLayers] = {0.1,0.035};
400 result = ::exahype2::RefinementCommand::Keep;
401 for (
int i=0; i<NumberOfRefinementLayers; i++) {
402 if (radius<Radius[i] and tarch::la::max(volumeH)>MaxH[i]) {
403 result=::exahype2::RefinementCommand::Refine;
409 if (tarch::la::equals(
t,0.0)){
410 constexpr
int NumberOfRefinementLayers = 2;
411 double Radius[NumberOfRefinementLayers] = {3.0, 1.5};
412 double MaxH[NumberOfRefinementLayers] = {0.15,0.04};
413 result = ::exahype2::RefinementCommand::Keep;
414 for (
int i=0; i<NumberOfRefinementLayers; i++) {
415 if (radius<Radius[i] and tarch::la::max(volumeH)>MaxH[i]) {
416 result=::exahype2::RefinementCommand::Refine;
::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.
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
void prepare(TP::TwoPunctures *tp)
static tarch::logging::Log _log
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
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
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.
void initialCondition(double *NOALIAS Q, const tarch::la::Vector< DIMENSIONS, double > &volumeCentre, const tarch::la::Vector< DIMENSIONS, double > &volumeH, bool gridIsConstructed) override
double norm2(double *v, int n)
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)
std::string grid_setup_method