Peano
Loading...
Searching...
No Matches
FiniteVolumeMGCCZ4.cpp
Go to the documentation of this file.
2#include "exahype2/RefinementControl.h"
3#include "InitialValues.h"
4#include "MGCCZ4Kernels.h"
5#include "PDE.h"
6
7#include <algorithm>
8
9#include "Constants.h"
10
11#include <limits>
12
13#include <stdio.h>
14#include <string.h>
15#include "tarch/NonCriticalAssertions.h"
16
17
18
19tarch::logging::Log examples::exahype2::mgccz4::FiniteVolumeMGCCZ4::_log( "examples::exahype2::mgccz4::FiniteVolumeMGCCZ4" );
20
21
22
24 if ( Scenario==0 || Scenario==1 ) {
25 const char* name = "GaugeWave";
26 int length = strlen(name);
27 //initparameters_(&length, name);
28 }
29 else {
30 std::cerr << "initial scenario " << Scenario << " is not supported" << std::endl << std::endl << std::endl;
31 }
32}
33
34
36 double * NOALIAS Q,
37 const tarch::la::Vector<DIMENSIONS,double>& volumeX,
38 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
39 double t,
40 double dt
41) {
42 logTraceInWith4Arguments( "adjustSolution(...)", volumeX, volumeH, t, dt );
43 if (tarch::la::equals(t,0.0) ) {
44 if ( Scenario==0 ) {
46 }
47 else if ( Scenario==1 ) {
49 }
50 else if ( Scenario==2 ) {
52 }
53 else {
54 logError( "adjustSolution(...)", "initial scenario " << Scenario << " is not supported" );
55 }
56
57 for (int i=0; i<NumberOfUnknowns; i++) {
58 assertion3( std::isfinite(Q[i]), volumeX, t, i );
59 }
60
61 for (int i=NumberOfUnknowns; i<NumberOfUnknowns+NumberOfAuxiliaryVariables; i++) {
62 Q[i] = 0.0;
63 }
64 }
65 else {
67 }
68 logTraceOut( "adjustSolution(...)" );
69}
70
71
73 const double * NOALIAS Q, // Q[64+0]
74 const tarch::la::Vector<DIMENSIONS,double>& volumeX,
75 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
76 double t,
77 double dt,
78 double * NOALIAS S // S[64
79) {
80 logTraceInWith4Arguments( "sourceTerm(...)", volumeX, volumeH, t, dt );
81 for(int i=0; i<NumberOfUnknowns; i++){
82 assertion3( std::isfinite(Q[i]), i, x, t );
83 }
84
85 memset(S, 0, NumberOfUnknowns*sizeof(double));
86 pdesource_(S,Q); // S(Q)
87 //source(S,Q, MGCCZ4LapseType, MGCCZ4ds, MGCCZ4c, MGCCZ4e, MGCCZ4f, MGCCZ4bs, MGCCZ4sk, MGCCZ4xi, MGCCZ4itau, MGCCZ4eta, MGCCZ4k1, MGCCZ4k2, MGCCZ4k3);
88 for(int i=0; i<NumberOfUnknowns; i++){
89 nonCriticalAssertion3( std::isfinite(S[i]), i, volumeX, t );
90 }
91 logTraceOut( "sourceTerm(...)" );
92}
93
94
95
97 const double * NOALIAS Qinside, // Qinside[64+0]
98 double * NOALIAS Qoutside, // Qoutside[64+0]
99 const tarch::la::Vector<DIMENSIONS,double>& faceCentre,
100 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
101 double t,
102 int normal
103) {
104 logTraceInWith4Arguments( "boundaryConditions(...)", faceCentre, volumeH, t, normal );
105 for(int i=0; i<NumberOfUnknowns+NumberOfAuxiliaryVariables; i++) {
106 assertion4( Qinside[i]==Qinside[i], faceCentre, t, normal, i );
107 Qoutside[i]=Qinside[i];
108 }
109 logTraceOut( "boundaryConditions(...)" );
110}
111
112
114 const double * NOALIAS Q, // Q[64+0],
115 const tarch::la::Vector<DIMENSIONS,double>& faceCentre,
116 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
117 double t,
118 int normal
119)
120{
121#if defined(MGCCZ4EINSTEIN)
122 const double qmin = std::min({Q[0],Q[3],Q[5]});
123 const double alpha = std::max({1.0, std::exp(Q[16])}) * std::max({1.0, std::exp(Q[54])}) / std::sqrt(qmin);
124#else
125 const double alpha = 1.0;
126#endif
127
128 constexpr double sqrtwo = 1.4142135623730951;
129 // NOTE parameters are stored in Constants.h
130 const double tempA = alpha * std::max({sqrtwo, MGCCZ4e, MGCCZ4ds, MGCCZ4GLMc/alpha, MGCCZ4GLMd/alpha});
131 const double tempB = Q[17+normal];//DOT_PRODUCT(Q(18:20),nv(:))
132 return std::max({1.0, std::abs(-tempA-tempB), std::abs(tempA-tempB)});
133
135 //return std::max({1.0, std::abs(-tempA-tempB), std::abs(tempA-tempB)});
136
137 //logTraceInWith4Arguments( "maxEigenvalue(...)", faceCentre, volumeH, t, normal );
138 //constexpr int Unknowns = 64;
139 //double lambda[Unknowns];
140 //for (int i=0; i<Unknowns; i++) {
141 //nonCriticalAssertion4( std::isfinite(Q[i]), i, x, t, normal );
142 //lambda[i] = 1.0;
143 //}
144
146 //double normalVector[3];
147 //normalVector[0] = normal % 3 == 0 ? 1.0 : 0.0;
148 //normalVector[1] = normal % 3 == 1 ? 1.0 : 0.0;
149 //normalVector[2] = normal % 3 == 2 ? 1.0 : 0.0;
150
152 //pdeeigenvalues_(lambda, Q, normalVector);
153
155 //double result = 0.0;
156 //for (int i=0; i<Unknowns; i++) {
157 //result = std::max(result,std::abs(lambda[i]));
158 //}
159 //logTraceOut( "maxEigenvalue(...)" );
160 //printf("%f vs %f diff: %f alpha: %f tempA: %f\n\n", result, result2, result-result2, alpha, tempA/alpha);
161 //return result;
162}
163
164
166 const double * NOALIAS Q, // Q[64+0],
167 const double * NOALIAS deltaQ, // [64+0]
168 const tarch::la::Vector<DIMENSIONS,double>& faceCentre,
169 const tarch::la::Vector<DIMENSIONS,double>& volumeH,
170 double t,
171 int normal,
172 double * NOALIAS BgradQ // BgradQ[64]
173) {
174 logTraceInWith4Arguments( "nonconservativeProduct(...)", faceCentre, volumeH, t, normal );
175 assertion( normal>=0 );
176 assertion( normal<DIMENSIONS );
177 double gradQSerialised[NumberOfUnknowns*3];
178 for (int i=0; i<NumberOfUnknowns; i++) {
179 gradQSerialised[i+0*NumberOfUnknowns] = 0.0;
180 gradQSerialised[i+1*NumberOfUnknowns] = 0.0;
181 gradQSerialised[i+2*NumberOfUnknowns] = 0.0;
182
183 gradQSerialised[i+normal*NumberOfUnknowns] = deltaQ[i];
184 }
185 //ncp(BgradQ, Q, gradQSerialised, normal, MGCCZ4LapseType, MGCCZ4ds, MGCCZ4c, MGCCZ4e, MGCCZ4f, MGCCZ4bs, MGCCZ4sk, MGCCZ4xi, MGCCZ4mu);
186 pdencp_(BgradQ, Q, gradQSerialised);
187 for (int i=0; i<NumberOfUnknowns; i++) {
188 nonCriticalAssertion4( std::isfinite(BgradQ[i]), i, faceCentre, t, normal );
189 }
190 logTraceOut( "nonconservativeProduct(...)" );
191}
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, int normal, double *NOALIAS BgradQ)
double maxEigenvalue(const double *NOALIAS Q, const tarch::la::Vector< DIMENSIONS, double > &faceCentre, const tarch::la::Vector< DIMENSIONS, double > &volumeH, double t, int normal)
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)
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 adjustSolution(double *NOALIAS Q, const tarch::la::Vector< DIMENSIONS, double > &volumeCentre, const tarch::la::Vector< DIMENSIONS, double > &volumeH, double t, double dt) override
void pdesource_(double *S, const double *const Q)
void pdencp_(double *BgradQ, const double *const Q, const double *const gradQ)
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)
void forcedflat(double *NOALIAS Q, const tarch::la::Vector< DIMENSIONS, double > &X, double t)