@@ -1237,6 +1237,100 @@ end
12371237 u[5 ])
12381238end
12391239
1240+ @inline function (dissipation:: DissipationMatrixWintersEtal )(u_ll, u_rr,
1241+ normal_direction:: AbstractVector ,
1242+ equations:: CompressibleEulerEquations3D )
1243+ (; gamma) = equations
1244+
1245+ # Step 1:
1246+ # Rotate solution into the appropriate direction
1247+
1248+ norm_ = norm (normal_direction)
1249+ # Normalize the vector without using `normalize` since we need to multiply by the `norm_` later
1250+ normal_vector = normal_direction / norm_
1251+
1252+ # Some vector that can't be identical to normal_vector (unless normal_vector == 0)
1253+ tangent1 = SVector (normal_direction[2 ], normal_direction[3 ], - normal_direction[1 ])
1254+ # Orthogonal projection
1255+ tangent1 -= dot (normal_vector, tangent1) * normal_vector
1256+ tangent1 = normalize (tangent1)
1257+
1258+ # Third orthogonal vector
1259+ tangent2 = normalize (cross (normal_direction, tangent1))
1260+
1261+ u_ll_rotated = rotate_to_x (u_ll, normal_vector, tangent1, tangent2, equations)
1262+ u_rr_rotated = rotate_to_x (u_rr, normal_vector, tangent1, tangent2, equations)
1263+
1264+ # Step 2:
1265+ # Compute the averages using the rotated variables
1266+ rho_ll, v1_ll, v2_ll, v3_ll, p_ll = cons2prim (u_ll_rotated, equations)
1267+ rho_rr, v1_rr, v2_rr, v3_rr, p_rr = cons2prim (u_rr_rotated, equations)
1268+
1269+ b_ll = rho_ll / (2 * p_ll)
1270+ b_rr = rho_rr / (2 * p_rr)
1271+
1272+ rho_log = ln_mean (rho_ll, rho_rr)
1273+ b_log = ln_mean (b_ll, b_rr)
1274+ v1_avg = 0.5f0 * (v1_ll + v1_rr)
1275+ v2_avg = 0.5f0 * (v2_ll + v2_rr)
1276+ v3_avg = 0.5f0 * (v3_ll + v3_rr)
1277+ p_avg = 0.5f0 * (rho_ll + rho_rr) / (b_ll + b_rr)
1278+ v_squared_bar = v1_ll * v1_rr + v2_ll * v2_rr + v3_ll * v3_rr
1279+ h_bar = gamma / (2 * b_log * (gamma - 1 )) + 0.5f0 * v_squared_bar
1280+ c_bar = sqrt (gamma * p_avg / rho_log)
1281+
1282+ # Step 3:
1283+ # Build the dissipation term as given in Appendix A of the paper
1284+ # - A. R. Winters, D. Derigs, G. Gassner, S. Walch, A uniquely defined entropy stable matrix dissipation operator
1285+ # for high Mach number ideal MHD and compressible Euler simulations (2017). Journal of Computational Physics.
1286+ # [DOI: 10.1016/j.jcp.2016.12.006](https://doi.org/10.1016/j.jcp.2016.12.006).
1287+
1288+ # Get entropy variables jump in the rotated variables
1289+ w_jump = cons2entropy (u_rr_rotated, equations) -
1290+ cons2entropy (u_ll_rotated, equations)
1291+
1292+ # Entries of the diagonal scaling matrix where D = ABS(\Lambda)T
1293+ lambda_1 = abs (v1_avg - c_bar) * rho_log / (2 * gamma)
1294+ lambda_2 = abs (v1_avg) * rho_log * (gamma - 1 ) / gamma
1295+ lambda_3 = abs (v1_avg) * p_avg # scaled repeated eigenvalue in the tangential direction
1296+ lambda_5 = abs (v1_avg + c_bar) * rho_log / (2 * gamma)
1297+ D = SVector (lambda_1, lambda_2, lambda_3, lambda_3, lambda_5)
1298+
1299+ # Entries of the right eigenvector matrix (others have already been precomputed)
1300+ r21 = v1_avg - c_bar
1301+ r25 = v1_avg + c_bar
1302+ r51 = h_bar - v1_avg * c_bar
1303+ r52 = 0.5f0 * v_squared_bar
1304+ r55 = h_bar + v1_avg * c_bar
1305+
1306+ # Build R and transpose of R matrices
1307+ R = @SMatrix [[1 ;; 1 ;; 0 ;; 0 ;; 1 ];
1308+ [r21;; v1_avg;; 0 ;; 0 ;; r25];
1309+ [v2_avg;; v2_avg;; 1 ;; 0 ;; v2_avg];
1310+ [v3_avg;; v3_avg;; 0 ;; 1 ;; v3_avg];
1311+ [r51;; r52;; v2_avg;; v3_avg;; r55]]
1312+
1313+ RT = @SMatrix [[1 ;; r21;; v2_avg;; v3_avg;; r51];
1314+ [1 ;; v1_avg;; v2_avg;; v3_avg;; r52];
1315+ [0 ;; 0 ;; 1 ;; 0 ;; v2_avg];
1316+ [0 ;; 0 ;; 0 ;; 1 ;; v3_avg];
1317+ [1 ;; r25;; v2_avg;; v3_avg;; r55]]
1318+
1319+ # Compute the dissipation term R * D * R^T * [[w]] from right-to-left
1320+
1321+ # First comes R^T * [[w]]
1322+ diss = RT * w_jump
1323+ # Next multiply with the eigenvalues and Barth scaling
1324+ diss = D .* diss
1325+ # Finally apply the remaining eigenvector matrix
1326+ diss = R * diss
1327+
1328+ # Step 4:
1329+ # Do not forget to backrotate and then return with proper normalization scaling
1330+ return - 0.5f0 * rotate_from_x (diss, normal_vector, tangent1, tangent2, equations) *
1331+ norm_
1332+ end
1333+
12401334# Rotate x-axis to normal vector; normal, tangent1 and tangent2 need to be orthonormal
12411335# Called inside `FluxRotated` in `numerical_fluxes.jl` so the directions
12421336# has been normalized prior to this back-rotation of the state vector
0 commit comments