Peano
Loading...
Searching...
No Matches
riemannsolver_isotropic.h
Go to the documentation of this file.
1// #include "../../../ExaHyPE/kernels/KernelUtils.h"
2// #include "exahype2/aderdg/kernels/Utils/KernelUtils.h"
3
4namespace Numerics {
5
6 // Getter routines
7 template <class Shortcuts>
8 inline void compute_parameters(const double* Q, double& rho, double& cp, double& cs, double& mu, double& lam) {
9 Shortcuts s;
10 rho = Q[s.rho];
11 cp = Q[s.cp];
12 cs = Q[s.cs];
13 mu = cs * cs * rho;
14 lam = rho * cp * cp - 2.0 * mu;
15 }
16
18 int faceIndex,
19 double r,
20 double vn,
21 double vm,
22 double vl,
23 double Tn,
24 double Tm,
25 double Tl,
26 double zp,
27 double zs,
28 double& vn_hat,
29 double& vm_hat,
30 double& vl_hat,
31 double& Tn_hat,
32 double& Tm_hat,
33 double& Tl_hat
34 ) {
35 // if (faceIndex % 2 == 0) { //left face
36 if (faceIndex < Dimensions) { //left face
40 }
41
42 // if (faceIndex % 2 == 1) { //right face
43 else { //right face
47 }
48 }
49
50 template <class Shortcuts, int basisSize, int numberOfVariables, int numberOfData, int surface = 2>
52 double* FL,
53 double* FR,
54 const double* const QL,
55 const double* const QR,
56 const double dt,
57 const int direction,
58 bool isBoundaryFace,
59 int faceIndex
60 ) {
61
62 kernels::idx3 idx_QLR(basisSize, basisSize, numberOfData);
63 kernels::idx3 idx_FLR(basisSize, basisSize, numberOfVariables);
64
65 double FLn, FLm, FLl, FRn, FRm, FRl;
66 double FLx, FLy, FLz, FRx, FRy, FRz;
67 double FL_n, FL_m, FL_l, FR_n, FR_m, FR_l;
68 double FL_x, FL_y, FL_z, FR_x, FR_y, FR_z;
69
70 Shortcuts s;
71 for (int i = 0; i < basisSize; i++) {
72#pragma simd
73 for (int j = 0; j < basisSize; j++) {
74
75 const double* Q_p = QR + idx_QLR(i, j, 0);
76 const double* Q_m = QL + idx_QLR(i, j, 0);
77
78 double* F_m = FL + idx_FLR(i, j, 0);
79 double* F_p = FR + idx_FLR(i, j, 0);
80 double rho_m, cp_m, cs_m, mu_m, lam_m;
81 double rho_p, cp_p, cs_p, mu_p, lam_p;
82
85
86 double n_m[3], m_m[3], l_m[3];
87 double n_p[3], m_p[3], l_p[3];
88 double norm_p, norm_m;
89
92
93 double Tx_m, Ty_m, Tz_m;
94 double Tx_p, Ty_p, Tz_p;
97
98 double vx_m, vy_m, vz_m;
99 double vx_p, vy_p, vz_p;
102
105
106 double Tn_m, Tm_m, Tl_m;
107 double Tn_p, Tm_p, Tl_p;
108
109 // rotate fields into l, m, n basis
112
113 double vn_m, vm_m, vl_m;
114 double vn_p, vm_p, vl_p;
117
118 // extract local s-wave and p-wave impedances
119 double zs_m = rho_m * cs_m;
120 double zs_p = rho_p * cs_p;
121
122 double zp_m = rho_m * cp_m;
123 double zp_p = rho_p * cp_p;
124
125 // impedance must be greater than zero !
126 assertion3(!(zp_p <= 0.0 || zp_m <= 0.0), "Impedance must be greater than zero !", zp_p, zp_m);
127
128 // generate interface data preserving the amplitude of the outgoing charactertritics
129 // and satisfying interface conditions exactly.
130 double vn_hat_p, vm_hat_p, vl_hat_p;
131 double Tn_hat_p, Tm_hat_p, Tl_hat_p;
132 double vn_hat_m, vm_hat_m, vl_hat_m;
133 double Tn_hat_m, Tm_hat_m, Tl_hat_m;
134
135 if (isBoundaryFace) {
136 // 0 absorbing 1 free surface
137 double r = faceIndex == surface ? 1 : 0;
138 // double r=1.;
140 faceIndex,
141 r,
142 vn_m,
143 vm_m,
144 vl_m,
145 Tn_m,
146 Tm_m,
147 Tl_m,
148 zp_m,
149 zs_m,
150 vn_hat_m,
151 vm_hat_m,
152 vl_hat_m,
153 Tn_hat_m,
154 Tm_hat_m,
156 );
158 faceIndex,
159 r,
160 vn_p,
161 vm_p,
162 vl_p,
163 Tn_p,
164 Tm_p,
165 Tl_p,
166 zp_p,
167 zs_p,
168 vn_hat_p,
169 vm_hat_p,
170 vl_hat_p,
171 Tn_hat_p,
172 Tm_hat_p,
174 );
175 } else {
179 }
180
181 // generate fluctuations in the local basis coordinates: n, m, l
185
189
190 // Consider acoustic boundary
191 FL_n = FLn / zp_m;
192 if (zs_m > 0) {
193 FL_m = FLm / zs_m;
194 FL_l = FLl / zs_m;
195 } else {
196 FL_m = 0;
197 FL_l = 0;
198 }
199
200 FR_n = FRn / zp_p;
201 if (zs_p > 0) {
202 FR_m = FRm / zs_p;
203 FR_l = FRl / zs_p;
204 } else {
205 FR_m = 0;
206 FR_l = 0;
207 }
208
209 // rotate back to the physical coordinates x, y, z
214
215 // construct flux fluctuation vectors obeying the eigen structure of the PDE
216 // and choose physically motivated penalties such that we can prove
217 // numerical stability.
218 F_p[s.v + 0] = norm_p / rho_p * FRx;
219 F_m[s.v + 0] = norm_m / rho_m * FLx;
220
221 F_p[s.v + 1] = norm_p / rho_p * FRy;
222 F_m[s.v + 1] = norm_m / rho_m * FLy;
223
224 F_p[s.v + 2] = norm_p / rho_p * FRz;
225 F_m[s.v + 2] = norm_m / rho_m * FLz;
226
227 F_m[s.sigma + 0] = norm_m * ((2 * mu_m + lam_m) * n_m[0] * FL_x + lam_m * n_m[1] * FL_y + lam_m * n_m[2] * FL_z);
228 F_m[s.sigma + 1] = norm_m * ((2 * mu_m + lam_m) * n_m[1] * FL_y + lam_m * n_m[0] * FL_x + lam_m * n_m[2] * FL_z);
229 F_m[s.sigma + 2] = norm_m * ((2 * mu_m + lam_m) * n_m[2] * FL_z + lam_m * n_m[0] * FL_x + lam_m * n_m[1] * FL_y);
230
231 F_p[s.sigma + 0] = -norm_p
232 * ((2 * mu_p + lam_p) * n_p[0] * FR_x + lam_p * n_p[1] * FR_y + lam_p * n_p[2] * FR_z);
233 F_p[s.sigma + 1] = -norm_p
234 * ((2 * mu_p + lam_p) * n_p[1] * FR_y + lam_p * n_p[0] * FR_x + lam_p * n_p[2] * FR_z);
235 F_p[s.sigma + 2] = -norm_p
236 * ((2 * mu_p + lam_p) * n_p[2] * FR_z + lam_p * n_p[0] * FR_x + lam_p * n_p[1] * FR_y);
237
238 F_m[s.sigma + 3] = norm_m * mu_m * (n_m[1] * FL_x + n_m[0] * FL_y);
239 F_m[s.sigma + 4] = norm_m * mu_m * (n_m[2] * FL_x + n_m[0] * FL_z);
240 F_m[s.sigma + 5] = norm_m * mu_m * (n_m[2] * FL_y + n_m[1] * FL_z);
241
242 F_p[s.sigma + 3] = -norm_p * mu_p * (n_p[1] * FR_x + n_p[0] * FR_y);
243 F_p[s.sigma + 4] = -norm_p * mu_p * (n_p[2] * FR_x + n_p[0] * FR_z);
244 F_p[s.sigma + 5] = -norm_p * mu_p * (n_p[2] * FR_y + n_p[1] * FR_z);
245 }
246 }
247 }
248
249 /*
250 template<class Shortcuts,int basisSize, int numberOfVariables, int numberOfData, int surface = 2>
251 void riemannSolver_vect(double* FL,double* FR,const double* const QL,const double* const QR,const double dt,const
252 int direction, bool isBoundaryFace, int faceIndex){
253
254 Shortcuts s;
255 constexpr int num_nodes = basisSize*basisSize;
256
257 double j_m[num_nodes][3][3];
258 double j_p[num_nodes][3][3];
259
260 kernels::idx2 idx_normal(num_nodes,3);
261 double norm_p[num_nodes],norm_m[num_nodes];
262
263 for (int n = 0; n < num_nodes; n++) {
264 const double* Q_p = QR+idx_QLR(i,j,0);
265 const double* Q_m = QL+idx_QLR(i,j,0);
266
267 norm_p[n] = std::sqrt(Q_p[s.metric_derivative + 0 + direction * 3] * Q_p[s.metric_derivative + 0 + direction * 3]
268 + Q_p[s.metric_derivative + 1 + direction * 3] * Q_p[s.metric_derivative + 1 + direction * 3] +
269 Q_p[s.metric_derivative + 2 + direction * 3] * Q_p[s.metric_derivative + 2 + direction * 3]);
270 j_p[n][0][0] = Q_p[s.metric_derivative + 0 + direction * 3];
271 j_p[n][0][1] = Q_p[s.metric_derivative + 1 + direction * 3];
272 j_p[n][0][2] = Q_p[s.metric_derivative + 2 + direction * 3];
273
274 norm_m[n] = std::sqrt(Q_m[s.metric_derivative + 0 + direction * 3] * Q_m[s.metric_derivative + 0 + direction * 3]
275 + Q_m[s.metric_derivative + 1 + direction * 3] * Q_m[s.metric_derivative + 1 + direction * 3] +
276 Q_m[s.metric_derivative + 2 + direction * 3] * Q_m[s.metric_derivative + 2 + direction * 3]);
277
278 j_m[n][0][0] = Q_m[s.metric_derivative + 0 + direction * 3];
279 j_m[n][0][1] = Q_m[s.metric_derivative + 1 + direction * 3];
280 j_m[n][0][2] = Q_m[s.metric_derivative + 2 + direction * 3];
281 }
282
283
284 //compute tractions
285 double Tractions_arr[*3];
286 double* Tractions[3];
287 Tractions[0] = Tractions_arr;
288 Tractions[1] = Tractions_arr + basisSize * basisSize;
289 Tractions[2] = Tractions_arr + basisSize * basisSize * 2;
290
291 for (int i = 0; i < basisSize; i++) {
292 for (int j = 0; j < basisSize; j++) {
293 const double* Q_p = QR+idx_QLR(i,j,0);
294 const double* Q_m = QL+idx_QLR(i,j,0);
295
296
297
298
299 }
300 }
301 }
302 */
303} // namespace Numerics
#define assertion3(expr, param0, param1, param2)
void compute_fluctuations_left(double z, double T, double T_hat, double v, double v_hat, double &F)
void get_stiffness_tensor(const double *Q, double &c11, double &c22, double &c33, double &c44, double &c55, double &c66, double &c12, double &c13, double &c23)
Definition anisotropic.h:4
void rotate_into_orthogonal_basis(double *n, double *m, double *l, double Tx, double Ty, double Tz, double &Tn, double &Tm, double &Tl)
void riemannSolver_BC0(double v, double sigma, double z, double r, double &v_hat, double &sigma_hat)
void riemannSolver_BCn(double v, double sigma, double z, double r, double &v_hat, double &sigma_hat)
void riemannSolver_boundary(int faceIndex, double r, double vn, double vm, double vl, double Tn, double Tm, double Tl, double zp, double zs[2], double &vn_hat, double &vm_hat, double &vl_hat, double &Tn_hat, double &Tm_hat, double &Tl_hat)
void compute_parameters(const double *Q, double &rho, double &cp, double cs[], int direction)
void riemannSolver_Nodal(double v_p, double v_m, double sigma_p, double sigma_m, double z_p, double z_m, double &v_hat_p, double &v_hat_m, double &sigma_hat_p, double &sigma_hat_m)
void compute_fluctuations_right(double z, double T, double T_hat, double v, double v_hat, double &F)
void riemannSolver(double *FL, double *FR, const double *const QL, const double *const QR, const double dt, const int direction, bool isBoundaryFace, int faceIndex)
void create_local_basis(double *n, double *m, double *l)
void rotate_into_physical_basis(double *n, double *m, double *l, double Fn, double Fm, double Fl, double &Fx, double &Fy, double &Fz)