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){
91 if (CCZ4swi==2 and CCZ4BBHType==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);
128 const char* name =
"GaugeWave";
129 int length = strlen(name);
132 #ifdef IncludeTwoPunctures
145 const tarch::la::Vector<DIMENSIONS,double>& volumeX,
146 const tarch::la::Vector<DIMENSIONS,double>& volumeH
160 #ifdef IncludeTwoPunctures
167 logError(
"initialCondition(...)",
"initial scenario " <<
Scenario <<
" is not supported" );
170 for (
int i=0; i<NumberOfUnknowns; i++) {
171 assertion2( std::isfinite(Q[i]), volumeX, i );
174 for (
int i=NumberOfUnknowns; i<NumberOfUnknowns+NumberOfAuxiliaryVariables; i++) {
181 const double * NOALIAS Q,
182 const tarch::la::Vector<DIMENSIONS,double>& volumeX,
183 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
188 logTraceInWith4Arguments(
"sourceTerm(...)", volumeX, volumeH, t, dt );
189 for(
int i=0; i<NumberOfUnknowns; i++){
190 assertion3( std::isfinite(Q[i]), i, volumeX, t );
195 for(
int i=0; i<NumberOfUnknowns; i++){
196 nonCriticalAssertion3( std::isfinite(S[i]), i, volumeX, t );
198 logTraceOut(
"sourceTerm(...)" );
203 const double * NOALIAS Qinside,
204 double * NOALIAS Qoutside,
205 const tarch::la::Vector<DIMENSIONS,double>& faceCentre,
206 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
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];
215 logTraceOut(
"boundaryConditions(...)" );
220 const double * NOALIAS Q,
221 const tarch::la::Vector<DIMENSIONS,double>& faceCentre,
222 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
228 return maxEigenvalue(Q, faceCentre, volumeH, t, dt, normal, Offloadable::Yes);
233 const double * NOALIAS Q,
234 const double * NOALIAS deltaQ,
235 const tarch::la::Vector<DIMENSIONS,double>& faceCentre,
236 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
240 double * NOALIAS BgradQ
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);
247 for (
int i=0; i<NumberOfUnknowns; i++) {
248 nonCriticalAssertion4( std::isfinite(BgradQ[i]), i, faceCentre, t, normal );
250 logTraceOut(
"nonconservativeProduct(...)" );
254 const double * NOALIAS Q,
255 const double * NOALIAS deltaQ,
256 const tarch::la::Vector<DIMENSIONS,double>& faceCentre,
257 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
261 double * NOALIAS BgradQ,
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;
271 gradQSerialised[i+normal*NumberOfUnknowns] = deltaQ[i];
273 ncp(BgradQ, Q, gradQSerialised, normal, CCZ4LapseType, CCZ4ds, CCZ4c, CCZ4e, CCZ4f, CCZ4bs, CCZ4sk, CCZ4xi, CCZ4mu, CCZ4SO);
277 const double * NOALIAS Q,
278 const tarch::la::Vector<DIMENSIONS,double>& volumeCentre,
279 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
282 ::exahype2::RefinementCommand result = ::exahype2::RefinementCommand::Keep;
284 const double radius = tarch::la::norm2( volumeCentre );
291 result=::exahype2::RefinementCommand::Refine;
295 if (tarch::la::equals(t,0.0)){
296 constexpr int NumberOfRefinementLayers = 2;
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;
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};
312 const double radius1 = tarch::la::norm2( volumeCentre - leftBH );
313 const double radius2 = tarch::la::norm2( volumeCentre - rightBH );
315 if (tarch::la::equals(t,0.0)){
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;}
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;}
326 if (tarch::la::equals(t,0.0)){
327 constexpr int NumberOfRefinementLayers = 2;
328 double Radius[NumberOfRefinementLayers] = {4, 3};
329 double MaxH[NumberOfRefinementLayers] = {0.15,0.04};
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;
340 if (tarch::la::equals(t,0.0)){
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;
::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 initialCondition(double *NOALIAS Q, const tarch::la::Vector< DIMENSIONS, double > &volumeCentre, const tarch::la::Vector< DIMENSIONS, double > &volumeH) override
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 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