Peano 4
Loading...
Searching...
No Matches
riemannSolverLinear.cpph
Go to the documentation of this file.
1
14#include <algorithm>
15
17
18namespace kernels {
19namespace aderdg {
20namespace generic {
21namespace c {
22
23template <bool useFlux, bool useNCP, bool useMM, typename SolverType>
24void riemannSolverLinear(SolverType& solver, double* FL, double* FR,
25 const double* const QL, const double* const QR,
26 const double t,
27 const double dt,
30 const int direction) {
31 /*
32 * For the linear kernels, we need the material parameters in the
33 * extrapolated predictor.
34 * We compute the averages of the material parameters but
35 * do not use them in the max eigenvalue calculation.
36 *
37 * Consider numberOfParameters in:
38 * QL,QR,QavL,QavR,Qdiff
39 *
40 * Not necessary to consider numberOfParameters in
41 * FL,FR,LL,LR
42 */
43
44 constexpr int numberOfVariables = SolverType::NumberOfVariables;
45
46 constexpr int numberOfParameters = SolverType::NumberOfParameters;
47 constexpr int numberOfData = numberOfVariables+numberOfParameters;
48
49 constexpr int basisSize = SolverType::Order+1;
50 constexpr int basisSize2 = basisSize*basisSize;
51 constexpr int order = basisSize - 1;
52
53
54 // Compute the average variables and parameters from the left and the right
55 double QavL[numberOfData] = {0.0}; // size: numberOfVariables+numberOfParameters
56 double QavR[numberOfData] = {0.0}; // size: numberOfVariables+numberOfParameters
57 kernels::riemannsolvers::util::averageRiemannInputs<basisSize,numberOfData>(
59 kernels::riemannsolvers::util::averageRiemannInputs<basisSize,numberOfData>(
61
62 //get abs max eigenvalue
63 const double maxHyperbolicEigenvalueL = solver.maxEigenvalue(QavL, faceCentre, dx, t, dt, direction);
64 const double maxHyperbolicEigenvalueR = solver.maxEigenvalue(QavR, faceCentre, dx, t, dt, direction);
65 const double smax = std::max(maxHyperbolicEigenvalueL, maxHyperbolicEigenvalueR);
66
67 double Qdiff[numberOfData] = {0.0};
68 double Qavg[numberOfData] = {0.0};
69
70 idx2 idx_2d(Dimensions, numberOfVariables);
71
72 double flux[numberOfVariables];
73
74 double ncp[numberOfVariables] = {0.0};
75
76 for(int l = 0; l < numberOfData; l++) {
77 Qavg[l] = 0.5 * (QavR[l] + QavL[l]);
78 }
79
80 //We copy the averaged material parameters to Qdiff as they are used in the flux term
81 //These must not be overritten !
82 for(int l = numberOfVariables; l < numberOfData; l++) {
83 Qdiff[l] = Qavg[l];
84 }
85
86 {
87 idx3 idx_FLR(basisSize,basisSize, numberOfVariables);
88 idx3 idx_QLR(basisSize,basisSize, numberOfData);
89
90 std::fill_n (FL, basisSize2 * numberOfVariables, 0.0);
91 std::fill_n (FR, basisSize2 * numberOfVariables, 0.0);
92 for (int i = 0; i < basisSize; i++) {
93 for (int j = 0; j < basisSize; j++) {
94 for(int l = 0 ; l< numberOfVariables ; l++){
95 Qdiff[l] = 0.5 * (QR[idx_QLR(i, j, l)] - QL[idx_QLR(i ,j, l)]);
96 }
97
98 if(useNCP) {
99
100 solver.nonconservativeProduct(
101 Qavg,
102 Qdiff,
103 faceCentre,
104 dx,
105 t,
106 dt,
107 direction,
108 ncp
109 );
110/*
111 if(useMM){
112 solver.multiplyMaterialParameterMatrix(Qavg, ncp);
113 }
114*/
115 for(int l=0; l < numberOfVariables; l++) {
116 FL[idx_FLR(i, j, l)] += ncp[l];
117 FR[idx_FLR(i, j, l)] += ncp[l];
118 }
119 }
120
121
122 if(useFlux){
123
124 solver.flux(
125 Qdiff,
126 faceCentre,
127 dx,
128 t,
129 dt,
130 direction,
131 flux
132 );
133
134// if(useMM){
135// solver.multiplyMaterialParameterMatrix(Qavg, flux);
136// }
137
138 for(int l=0; l < numberOfVariables; l++) {
139 FL[idx_FLR(i, j, l)] += flux[l];
140 FR[idx_FLR(i, j, l)] += flux[l];
141 }
142 }
143
144 for(int l=0; l < numberOfVariables; l++) {
145 FL[idx_FLR(i, j, l)] -= smax*Qdiff[l];
146 FR[idx_FLR(i, j, l)] += smax*Qdiff[l];
147 }
148 }
149 }
150 }
151
152}
153
154
155} // namespace c
156} // namespace generic
157} // namespace aderdg
158} // namespace kernels
And from this we can write down f$ nabla phi_i nabla phi_i dx but since we are constructing matrix let s investigate the f$ j
we integrate over each cell and then take the sum across each of the cells We also consider the terms that enter the f$ so we are integrating with f$ phi_k phi_k dx
-with-ExaHyPE2-benchmark
void riemannSolverLinear(SolverType &solver, double *FL, double *FR, const double *const QL, const double *const QR, const double t, const double dt, const tarch::la::Vector< Dimensions, double > &faceCentre, const tarch::la::Vector< Dimensions, double > &dx, const int direction)
This file is part of the ExaHyPE project.
int i
Definition makeIC.py:51
ncp
Definition swe.py:182
Simple vector class.
Definition Vector.h:134