Peano 4
Loading...
Searching...
No Matches
FiniteVolumeMGCCZ4.cpp
Go to the documentation of this file.
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>
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 * __restrict__ Q,
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 * __restrict__ Q, // Q[64+0]
76 double t,
77 double dt,
78 double * __restrict__ 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 * __restrict__ Qinside, // Qinside[64+0]
98 double * __restrict__ Qoutside, // Qoutside[64+0]
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 * __restrict__ Q, // Q[64+0],
115 const tarch::la::Vector<Dimensions,double>& faceCentre,
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 * __restrict__ Q, // Q[64+0],
167 const double * __restrict__ deltaQ, // [64+0]
168 const tarch::la::Vector<Dimensions,double>& faceCentre,
170 double t,
171 int normal,
172 double * __restrict__ BgradQ // BgradQ[64]
173) {
174#if !defined(GPUOffloadingOMP)
175 logTraceInWith4Arguments( "nonconservativeProduct(...)", faceCentre, volumeH, t, normal );
176 assertion( normal>=0 );
177 assertion( normal<Dimensions );
178#endif
179 double gradQSerialised[NumberOfUnknowns*3];
180 for (int i=0; i<NumberOfUnknowns; i++) {
181 gradQSerialised[i+0*NumberOfUnknowns] = 0.0;
182 gradQSerialised[i+1*NumberOfUnknowns] = 0.0;
183 gradQSerialised[i+2*NumberOfUnknowns] = 0.0;
184
185 gradQSerialised[i+normal*NumberOfUnknowns] = deltaQ[i];
186 }
187 //ncp(BgradQ, Q, gradQSerialised, normal, MGCCZ4LapseType, MGCCZ4ds, MGCCZ4c, MGCCZ4e, MGCCZ4f, MGCCZ4bs, MGCCZ4sk, MGCCZ4xi, MGCCZ4mu);
188 pdencp_(BgradQ, Q, gradQSerialised);
189#if !defined(GPUOffloadingOMP)
190 for (int i=0; i<NumberOfUnknowns; i++) {
191 nonCriticalAssertion4( std::isfinite(BgradQ[i]), i, faceCentre, t, normal );
192 }
193 logTraceOut( "nonconservativeProduct(...)" );
194#endif
195}
#define assertion4(expr, param0, param1, param2, param3)
#define assertion3(expr, param0, param1, param2)
#define assertion(expr)
#define logError(methodName, logMacroMessageStream)
Wrapper macro around tarch::tarch::logging::Log to improve logging.
Definition Log.h:464
#define logTraceOut(methodName)
Definition Log.h:379
#define logTraceInWith4Arguments(methodName, argument0, argument1, argument2, argument3)
Definition Log.h:373
#define nonCriticalAssertion3(expr, param0, param1, param2)
#define nonCriticalAssertion4(expr, param0, param1, param2, param3)
virtual void boundaryConditions(const double *__restrict__ Qinside, double *__restrict__ Qoutside, const tarch::la::Vector< Dimensions, double > &faceCentre, const tarch::la::Vector< Dimensions, double > &volumeH, double t, int normal) override
void adjustSolution(double *__restrict__ Q, const tarch::la::Vector< Dimensions, double > &volumeCentre, const tarch::la::Vector< Dimensions, double > &volumeH, double t, double dt) override
double maxEigenvalue(const double *__restrict__ Q, const tarch::la::Vector< Dimensions, double > &faceCentre, const tarch::la::Vector< Dimensions, double > &volumeH, double t, int normal)
void sourceTerm(const double *__restrict__ Q, const tarch::la::Vector< Dimensions, double > &volumeCentre, const tarch::la::Vector< Dimensions, double > &volumeH, double t, double dt, double *__restrict__ S)
void nonconservativeProduct(const double *__restrict__ Q, const double *__restrict__ deltaQ, const tarch::la::Vector< Dimensions, double > &faceCentre, const tarch::la::Vector< Dimensions, double > &volumeH, double t, int normal, double *__restrict__ BgradQ)
Log Device.
Definition Log.h:516
void pdesource_(double *S, const double *const Q)
void pdencp_(double *BgradQ, const double *const Q, const double *const gradQ)
void enforceMGCCZ4constraints(double *luh)
void linearWave(double *__restrict__ Q, const tarch::la::Vector< Dimensions, double > &X, double t)
void forcedflat(double *__restrict__ Q, const tarch::la::Vector< Dimensions, double > &X, double t)
void gaugeWave(double *__restrict__ Q, const tarch::la::Vector< Dimensions, double > &x, double t)
bool equals(const Matrix< Rows, Cols, Scalar > &lhs, const Matrix< Rows, Cols, Scalar > &rhs, const Scalar &tolerance=NUMERICAL_ZERO_DIFFERENCE)
Compares to matrices on equality by means of a numerical accuracy.
Simple vector class.
Definition Vector.h:134