Peano
ADERDGMGCCZ4.cpp
Go to the documentation of this file.
1 #include "ADERDGMGCCZ4.h"
2 #include "InitialValues.h"
3 #include "exahype2/RefinementControl.h"
4 #include "Constants.h"
5 #include "MGCCZ4Kernels.h"
6 #include <algorithm>
7 #include <limits>
8 
9 #include <stdio.h>
10 #include <string.h>
11 #include "tarch/NonCriticalAssertions.h"
12 
13 
14 tarch::logging::Log examples::exahype2::mgccz4::ADERDGMGCCZ4::_log( "examples::exahype2::ADERDGMGCCZ4::MGCCZ4" );
15 
16 
17 
19  if ( Scenario=="gaugewave-c++" || Scenario=="linearwave-c++" ) {
20  const char* name = "GaugeWave";
21  int length = strlen(name);
22  //initparameters_(&length, name);
23  }
24  else {
25  std::cerr << "initial scenario " << Scenario << " is not supported" << std::endl << std::endl << std::endl;
26  }
27 }
28 
30  double * NOALIAS Q,
31  const tarch::la::Vector<DIMENSIONS,double>& x,
32  double t
33 ) {
34  logTraceInWith2Arguments( "adjustSolution(...)", x, t);
35  if (tarch::la::equals(t,0.0) ) {
36  if ( Scenario=="gaugewave-c++" ) {
38  }
39  else if ( Scenario=="linearwave-c++" ) {
41  }
42  else {
43  logError( "adjustSolution(...)", "initial scenario " << Scenario << " is not supported" );
44  }
45 
46  for (int i=0; i<NumberOfUnknowns; i++) {
47  assertion3( std::isfinite(Q[i]), x, t, i );
48  }
49 
50  for (int i=NumberOfUnknowns; i<NumberOfUnknowns+NumberOfAuxiliaryVariables; i++) {
51  Q[i] = 0.0;
52  }
53  }
54  else {
56  }
57  logTraceOut( "adjustSolution(...)" );
58 }
59 
61  const double * NOALIAS Q,
62  const tarch::la::Vector<DIMENSIONS,double>& x,
63  const tarch::la::Vector<DIMENSIONS,double>& h,
64  double t,
65  double dt,
66  double * NOALIAS S
67 ) {
68  constexpr int nVars = 59;
69  for(int i=0; i<nVars; i++){
70  assertion3( std::isfinite(Q[i]), i, x, t );
71  }
72  memset(S, 0, nVars*sizeof(double));
73  //pdesource_(S,Q); // S(Q)
74  source(S,Q); // S(Q)
75  for(int i=0; i<nVars; i++){
76  nonCriticalAssertion3( std::isfinite(S[i]), i, x, t );
77  }
78 }
79 
81  const double * NOALIAS Q, // Q[64+0],
82  const tarch::la::Vector<DIMENSIONS,double>& x,
83  double t,
84  int normal
85 ) {
86 #if defined(MGCCZ4EINSTEIN)
87  const double qmin = std::min({Q[0],Q[3],Q[5]});
88  const double alpha = std::max({1.0, std::exp(Q[16])}) * std::max({1.0, std::exp(Q[54])}) / std::sqrt(qmin);
89 #else
90  const double alpha = 1.0;
91 #endif
92 
93  constexpr double sqrtwo = 1.4142135623730951;
94  // NOTE parameters are stored in Constants.h
95  const double tempA = alpha * std::max({sqrtwo, MGCCZ4e, MGCCZ4ds, MGCCZ4GLMc/alpha, MGCCZ4GLMd/alpha});
96  const double tempB = Q[17+normal];//DOT_PRODUCT(Q(18:20),nv(:))
98  return std::max({1.0, std::abs(-tempA-tempB), std::abs(tempA-tempB)});
99  /*
100  logTraceInWith3Arguments( "eigenvalues(...)", x, t, normal );
101  // helper data structure
102  constexpr int Unknowns = 59;
103  double lambda[Unknowns];
104  for (int i=0; i<Unknowns; i++) {
105  nonCriticalAssertion4( std::isfinite(Q[i]), i, x, t, normal );
106  lambda[i] = 1.0;
107  }
108 
109  // routine requires explicit normal vector
110  double normalVector[3];
111  normalVector[0] = normal % 3 == 0 ? 1.0 : 0.0;
112  normalVector[1] = normal % 3 == 1 ? 1.0 : 0.0;
113  normalVector[2] = normal % 3 == 2 ? 1.0 : 0.0;
114 
115  // actual method invocation
116  pdeeigenvalues_(lambda, Q, normalVector);
117 
118  // we are only interested in the maximum eigenvalue
119  double result = 0.0;
120  for (int i=0; i<Unknowns; i++) {
121  result = std::max(result,std::abs(lambda[i]));
122  }
123 
124  // @todo Raus
125  assertion3( std::isfinite(result), x, t, normal );
126  //nonCriticalAssertion3( std::isfinite(result), x, t, normal );
127 
128  logTraceOut( "eigenvalues(...)" );
129  return result;*/
130 }
131 
132 
134  const double * NOALIAS Q, // Q[64+0],
135  const double * NOALIAS deltaQ, // [64+0]
136  const tarch::la::Vector<DIMENSIONS,double>& x,
137  double t,
138  int normal,
139  double * NOALIAS BgradQ // BgradQ[64]
140 ) {
141  logTraceInWith3Arguments( "nonconservativeProduct(...)", x, t, normal );
142 
143  assertion( normal>=0 );
144  assertion( normal<DIMENSIONS );
145  constexpr int nVars = 59;
146  double gradQSerialised[nVars*3];
147  for (int i=0; i<nVars; i++) {
148  gradQSerialised[i+0*nVars] = 0.0;
149  gradQSerialised[i+1*nVars] = 0.0;
150  gradQSerialised[i+2*nVars] = 0.0;
151 
152  gradQSerialised[i+normal*nVars] = deltaQ[i];
153  }
154  //pdencp_(BgradQ, Q, gradQSerialised);
155  ncp(BgradQ, Q, gradQSerialised, normal);
156 
157  for (int i=0; i<nVars; i++) {
158  nonCriticalAssertion4( std::isfinite(BgradQ[i]), i, x, t, normal );
159  }
160 
161  logTraceOut( "nonconservativeProduct(...)" );
162 }
163 
165  const double * NOALIAS Qinside,
166  double * NOALIAS Qoutside,
167  const tarch::la::Vector<DIMENSIONS,double>& x,
168  double t,
169  int normal
170 ) {
171  logTraceInWith3Arguments( "boundaryConditions(...)", x, t, normal );
172  for(int i=0; i<NumberOfUnknowns+NumberOfAuxiliaryVariables; i++) {
173  assertion4( Qinside[i]==Qinside[i], x, t, normal, i );
174  Qoutside[i]=Qinside[i];
175  }
176  logTraceOut( "boundaryConditions(...)" );
177 }
178 
void nonconservativeProduct(const double *NOALIAS Q, const double *NOALIAS deltaQ, const tarch::la::Vector< DIMENSIONS, double > &x, double t, int normal, double *NOALIAS BgradQ) override
void adjustSolution(double *NOALIAS Q, const tarch::la::Vector< DIMENSIONS, double > &x, double t) override
static tarch::logging::Log _log
Definition: ADERDGMGCCZ4.h:25
double maxEigenvalue(const double *NOALIAS Q, const tarch::la::Vector< DIMENSIONS, double > &x, double t, int normal) override
virtual void boundaryConditions(const double *NOALIAS Qinside, double *NOALIAS Qoutside, const tarch::la::Vector< DIMENSIONS, double > &x, double t, int normal) override
virtual void algebraicSource(const double *NOALIAS Q, const tarch::la::Vector< DIMENSIONS, double > &x, const tarch::la::Vector< DIMENSIONS, double > &h, double t, double dt, double *NOALIAS S) override
static double min(double const x, double const y)
void ncp(double *BgradQ, const double *const Q, const double *const gradQSerialised, const int normal, const int MGCCZ4LapseType, const double MGCCZ4ds, const double MGCCZ4c, const double MGCCZ4e, const double MGCCZ4f, const double MGCCZ4bs, const double MGCCZ4sk, const double MGCCZ4xi, const double MGCCZ4mu)
void source(double *S, const double *const Q, const int MGCCZ4LapseType, const double MGCCZ4ds, const double MGCCZ4c, const double MGCCZ4e, const double MGCCZ4f, const double MGCCZ4bs, const double MGCCZ4sk, const double MGCCZ4xi, const double MGCCZ4itau, const double MGCCZ4eta, const double MGCCZ4k1, const double MGCCZ4k2, const double MGCCZ4k3)
void linearWave(double *NOALIAS Q, const tarch::la::Vector< DIMENSIONS, double > &X, double t)
void enforceMGCCZ4constraints(double *luh)
void gaugeWave(double *NOALIAS Q, const tarch::la::Vector< DIMENSIONS, double > &x, double t)
h
Definition: swe.py:79