1*9ba83ac0SJeremy L Thompson // Copyright (c) 2017-2026, Lawrence Livermore National Security, LLC and other CEED contributors. 29f844368SJames Wright // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 39f844368SJames Wright // 49f844368SJames Wright // SPDX-License-Identifier: BSD-2-Clause 59f844368SJames Wright // 69f844368SJames Wright // This file is part of CEED: http://github.com/ceed 79f844368SJames Wright 89f844368SJames Wright /// @file 99f844368SJames Wright /// Helper functions for solving the Riemann problem. 109f844368SJames Wright // The left and right states are specified from the perspective of an outward-facing normal vector pointing left to right: 119f844368SJames Wright // 129f844368SJames Wright // (domain) 139f844368SJames Wright // / (outward facing normal) 149f844368SJames Wright // |------------| / 159f844368SJames Wright // | | / 169f844368SJames Wright // | Left |----> Right 179f844368SJames Wright // | (Interior) | (Exterior) 189f844368SJames Wright // |------------| 199f844368SJames Wright // 209f844368SJames Wright // The right state is exterior to the domain and the left state is the interior to the domain. 219f844368SJames Wright // Much of the work references Eleuterio F. Toro's "Riemann Solvers and Numerical Methods for Fluid Dynamics", 2009 229f844368SJames Wright #include "newtonian_state.h" 239f844368SJames Wright #include "newtonian_types.h" 249f844368SJames Wright 259f844368SJames Wright enum RiemannFluxType_ { RIEMANN_HLL, RIEMANN_HLLC }; 269f844368SJames Wright typedef enum RiemannFluxType_ RiemannFluxType; 279f844368SJames Wright 289f844368SJames Wright typedef struct { 299f844368SJames Wright CeedScalar left, right; 309f844368SJames Wright } RoeWeights; 319f844368SJames Wright 329f844368SJames Wright CEED_QFUNCTION_HELPER RoeWeights RoeSetup(CeedScalar rho_left, CeedScalar rho_right) { 339f844368SJames Wright CeedScalar sqrt_left = sqrt(rho_left), sqrt_right = sqrt(rho_right); 349f844368SJames Wright RoeWeights w = {sqrt_left / (sqrt_left + sqrt_right), sqrt_right / (sqrt_left + sqrt_right)}; 359f844368SJames Wright return w; 369f844368SJames Wright } 379f844368SJames Wright 389f844368SJames Wright CEED_QFUNCTION_HELPER RoeWeights RoeSetup_fwd(CeedScalar rho_left, CeedScalar rho_right, CeedScalar drho_left, CeedScalar drho_right) { 399f844368SJames Wright CeedScalar sqrt_left = sqrt(rho_left), sqrt_right = sqrt(rho_right); 409f844368SJames Wright CeedScalar square_sum_root = Square(sqrt_left + sqrt_right); 419f844368SJames Wright CeedScalar r_right = (sqrt_left / (2 * sqrt_right * square_sum_root)) * drho_right - (sqrt_right / (2 * sqrt_left * square_sum_root)) * drho_left; 429f844368SJames Wright CeedScalar r_left = (sqrt_right / (2 * sqrt_left * square_sum_root)) * drho_left - (sqrt_left / (2 * sqrt_right * square_sum_root)) * drho_right; 439f844368SJames Wright RoeWeights dw = {r_left, r_right}; 449f844368SJames Wright return dw; 459f844368SJames Wright } 469f844368SJames Wright 479f844368SJames Wright CEED_QFUNCTION_HELPER CeedScalar RoeAverage(RoeWeights r, CeedScalar q_left, CeedScalar q_right) { return r.left * q_left + r.right * q_right; } 489f844368SJames Wright 499f844368SJames Wright CEED_QFUNCTION_HELPER CeedScalar RoeAverage_fwd(RoeWeights r, RoeWeights dr, CeedScalar q_left, CeedScalar q_right, CeedScalar dq_left, 509f844368SJames Wright CeedScalar dq_right) { 519f844368SJames Wright return q_right * dr.right + q_left * dr.left + r.right * dq_right + r.left * dq_left; 529f844368SJames Wright } 539f844368SJames Wright 549f844368SJames Wright CEED_QFUNCTION_HELPER StateConservative Flux_HLL(State left, State right, StateConservative flux_left, StateConservative flux_right, 559f844368SJames Wright CeedScalar s_left, CeedScalar s_right) { 569f844368SJames Wright CeedScalar U_left[5], U_right[5], F_right[5], F_left[5], F_hll[5]; 579f844368SJames Wright UnpackState_U(left.U, U_left); 589f844368SJames Wright UnpackState_U(right.U, U_right); 599f844368SJames Wright UnpackState_U(flux_left, F_left); 609f844368SJames Wright UnpackState_U(flux_right, F_right); 619f844368SJames Wright for (int i = 0; i < 5; i++) { 629f844368SJames Wright F_hll[i] = (s_right * F_left[i] - s_left * F_right[i] + s_left * s_right * (U_right[i] - U_left[i])) / (s_right - s_left); 639f844368SJames Wright } 649f844368SJames Wright StateConservative F = { 659f844368SJames Wright F_hll[0], 669f844368SJames Wright {F_hll[1], F_hll[2], F_hll[3]}, 679f844368SJames Wright F_hll[4], 689f844368SJames Wright }; 699f844368SJames Wright return F; 709f844368SJames Wright } 719f844368SJames Wright 729f844368SJames Wright CEED_QFUNCTION_HELPER StateConservative Flux_HLL_fwd(State left, State right, State dleft, State dright, StateConservative flux_left, 739f844368SJames Wright StateConservative flux_right, StateConservative dflux_left, StateConservative dflux_right, 749f844368SJames Wright CeedScalar S_l, CeedScalar S_r, CeedScalar dS_l, CeedScalar dS_r) { 759f844368SJames Wright CeedScalar U_l[5], U_r[5], F_r[5], F_l[5]; 769f844368SJames Wright UnpackState_U(left.U, U_l); 779f844368SJames Wright UnpackState_U(right.U, U_r); 789f844368SJames Wright UnpackState_U(flux_left, F_l); 799f844368SJames Wright UnpackState_U(flux_right, F_r); 809f844368SJames Wright 819f844368SJames Wright CeedScalar dU_l[5], dU_r[5], dF_r[5], dF_l[5], dF_hll[5] = {0.}; 829f844368SJames Wright UnpackState_U(dleft.U, dU_l); 839f844368SJames Wright UnpackState_U(dright.U, dU_r); 849f844368SJames Wright UnpackState_U(dflux_left, dF_l); 859f844368SJames Wright UnpackState_U(dflux_right, dF_r); 869f844368SJames Wright for (int i = 0; i < 5; i++) { 879f844368SJames Wright const CeedScalar S_diff = S_r - S_l; 889f844368SJames Wright 8954f81801SJames Wright dF_hll[i] += (S_l * (-F_l[i] + F_r[i] + S_l * U_l[i] - S_l * U_r[i]) / Square(S_diff)) * dS_r; 9054f81801SJames Wright dF_hll[i] += (S_r * (F_l[i] - F_r[i] - S_r * U_l[i] + S_r * U_r[i]) / Square(S_diff)) * dS_l; 9154f81801SJames Wright dF_hll[i] += (S_r * dF_l[i] - S_l * dF_r[i] + S_r * S_l * (dU_r[i] - dU_l[i])) / S_diff; 929f844368SJames Wright } 939f844368SJames Wright StateConservative dF = { 949f844368SJames Wright dF_hll[0], 959f844368SJames Wright {dF_hll[1], dF_hll[2], dF_hll[3]}, 969f844368SJames Wright dF_hll[4], 979f844368SJames Wright }; 989f844368SJames Wright return dF; 999f844368SJames Wright } 1009f844368SJames Wright 1019f844368SJames Wright CEED_QFUNCTION_HELPER void ComputeHLLSpeeds_Roe(NewtonianIdealGasContext gas, State left, CeedScalar u_left, State right, CeedScalar u_right, 1029f844368SJames Wright CeedScalar *s_left, CeedScalar *s_right) { 1039f844368SJames Wright const CeedScalar gamma = HeatCapacityRatio(gas); 1049f844368SJames Wright 1059f844368SJames Wright RoeWeights r = RoeSetup(left.U.density, right.U.density); 1069f844368SJames Wright // Speed estimate 1079f844368SJames Wright // Roe average eigenvalues for left and right non-linear waves. 1089f844368SJames Wright // Stability requires that these speed estimates are *at least* as fast as the physical wave speeds. 1099f844368SJames Wright CeedScalar u_roe = RoeAverage(r, u_left, u_right); 1109f844368SJames Wright 1119f844368SJames Wright CeedScalar H_left = TotalSpecificEnthalpy(gas, left); 1129f844368SJames Wright CeedScalar H_right = TotalSpecificEnthalpy(gas, right); 1139f844368SJames Wright CeedScalar H_roe = RoeAverage(r, H_left, H_right); 1149f844368SJames Wright CeedScalar a_roe = sqrt((gamma - 1) * (H_roe - 0.5 * Square(u_roe))); 1159f844368SJames Wright 1169f844368SJames Wright // Einfeldt (1988) justifies (and Toro's book repeats) that Roe speeds can be used here. 1179f844368SJames Wright *s_left = u_roe - a_roe; 1189f844368SJames Wright *s_right = u_roe + a_roe; 1199f844368SJames Wright } 1209f844368SJames Wright 1219f844368SJames Wright CEED_QFUNCTION_HELPER void ComputeHLLSpeeds_Roe_fwd(NewtonianIdealGasContext gas, State left, State dleft, CeedScalar u_left, CeedScalar du_left, 1229f844368SJames Wright State right, State dright, CeedScalar u_right, CeedScalar du_right, CeedScalar *s_left, 1239f844368SJames Wright CeedScalar *ds_left, CeedScalar *s_right, CeedScalar *ds_right) { 1249f844368SJames Wright const CeedScalar gamma = HeatCapacityRatio(gas); 1259f844368SJames Wright 1269f844368SJames Wright RoeWeights r = RoeSetup(left.U.density, right.U.density); 1279f844368SJames Wright RoeWeights dr = RoeSetup_fwd(left.U.density, right.U.density, dleft.U.density, dright.U.density); 1289f844368SJames Wright // Speed estimate 1299f844368SJames Wright // Roe average eigenvalues for left and right non-linear waves. 1309f844368SJames Wright // Stability requires that these speed estimates are *at least* as fast as the physical wave speeds. 1319f844368SJames Wright CeedScalar u_roe = RoeAverage(r, u_left, u_right); 1329f844368SJames Wright CeedScalar du_roe = RoeAverage_fwd(r, dr, u_left, u_right, du_left, du_right); 1339f844368SJames Wright 1349f844368SJames Wright CeedScalar H_left = TotalSpecificEnthalpy(gas, left); 1359f844368SJames Wright CeedScalar H_right = TotalSpecificEnthalpy(gas, right); 1369f844368SJames Wright CeedScalar dH_left = TotalSpecificEnthalpy_fwd(gas, left, dleft); 1379f844368SJames Wright CeedScalar dH_right = TotalSpecificEnthalpy_fwd(gas, right, dright); 1389f844368SJames Wright 1399f844368SJames Wright CeedScalar H_roe = RoeAverage(r, H_left, H_right); 1409f844368SJames Wright CeedScalar dH_roe = RoeAverage_fwd(r, dr, H_left, H_right, dH_left, dH_right); 1419f844368SJames Wright CeedScalar a_roe = sqrt((gamma - 1) * (H_roe - 0.5 * Square(u_roe))); 14254f81801SJames Wright CeedScalar da_roe = 0.5 * sqrt((gamma - 1) / (H_roe - 0.5 * Square(u_roe))) * dH_roe; // (da/dH) dH 14354f81801SJames Wright da_roe -= 0.5 * sqrt(gamma - 1) * u_roe / sqrt(H_roe - 0.5 * Square(u_roe)) * du_roe; // (da/du) du 1449f844368SJames Wright 1459f844368SJames Wright *s_left = u_roe - a_roe; 1469f844368SJames Wright *ds_left = du_roe - da_roe; 1479f844368SJames Wright *s_right = u_roe + a_roe; 1489f844368SJames Wright *ds_right = du_roe + da_roe; 1499f844368SJames Wright } 1509f844368SJames Wright 1519f844368SJames Wright // ***************************************************************************** 1529f844368SJames Wright // @brief Harten Lax VanLeer (HLL) approximate Riemann solver. 1539f844368SJames Wright // Taking in two states (left, right) and returns RiemannFlux_HLL. 1549f844368SJames Wright // The left and right states are specified from the perspective of an outward-facing normal vector pointing left to right. 1559f844368SJames Wright // 1569f844368SJames Wright // @param[in] gas NewtonianIdealGasContext for the fluid 1579f844368SJames Wright // @param[in] left Fluid state of the domain interior (the current solution) 1589f844368SJames Wright // @param[in] right Fluid state of the domain exterior (free stream conditions) 1599f844368SJames Wright // @param[in] normal Normalized, outward facing boundary normal vector 1609f844368SJames Wright // 1619f844368SJames Wright // @return StateConservative with HLL Riemann Flux 1629f844368SJames Wright // ***************************************************************************** 1639f844368SJames Wright CEED_QFUNCTION_HELPER StateConservative RiemannFlux_HLL(NewtonianIdealGasContext gas, State left, State right, const CeedScalar normal[3]) { 1649f844368SJames Wright StateConservative flux_left = FluxInviscidDotNormal(gas, left, normal); 1659f844368SJames Wright StateConservative flux_right = FluxInviscidDotNormal(gas, right, normal); 1669f844368SJames Wright 1679f844368SJames Wright CeedScalar u_left = Dot3(left.Y.velocity, normal); 1689f844368SJames Wright CeedScalar u_right = Dot3(right.Y.velocity, normal); 1699f844368SJames Wright 1709f844368SJames Wright CeedScalar s_left, s_right; 1719f844368SJames Wright ComputeHLLSpeeds_Roe(gas, left, u_left, right, u_right, &s_left, &s_right); 1729f844368SJames Wright 1739f844368SJames Wright // Compute HLL flux 1749f844368SJames Wright if (0 <= s_left) { 1759f844368SJames Wright return flux_left; 1769f844368SJames Wright } else if (s_right <= 0) { 1779f844368SJames Wright return flux_right; 1789f844368SJames Wright } else { 1799f844368SJames Wright return Flux_HLL(left, right, flux_left, flux_right, s_left, s_right); 1809f844368SJames Wright } 1819f844368SJames Wright } 1829f844368SJames Wright 1839f844368SJames Wright // ***************************************************************************** 1849f844368SJames Wright // @brief Forward-mode Derivative of Harten Lax VanLeer (HLL) approximate Riemann solver. 1859f844368SJames Wright // 1869f844368SJames Wright // @param gas NewtonianIdealGasContext for the fluid 1879f844368SJames Wright // @param left Fluid state of the domain interior (the current solution) 1889f844368SJames Wright // @param right Fluid state of the domain exterior (free stream conditions) 1899f844368SJames Wright // @param dleft Derivative of fluid state of the domain interior (the current solution) 1909f844368SJames Wright // @param dright Derivative of fluid state of the domain exterior (free stream conditions) 1919f844368SJames Wright // @param normal Normalized, outward facing boundary normal vector 1929f844368SJames Wright // 1939f844368SJames Wright // @return StateConservative with derivative of HLL Riemann Flux 1949f844368SJames Wright // ***************************************************************************** 1959f844368SJames Wright CEED_QFUNCTION_HELPER StateConservative RiemannFlux_HLL_fwd(NewtonianIdealGasContext gas, State left, State dleft, State right, State dright, 1969f844368SJames Wright const CeedScalar normal[3]) { 1979f844368SJames Wright StateConservative flux_left = FluxInviscidDotNormal(gas, left, normal); 1989f844368SJames Wright StateConservative flux_right = FluxInviscidDotNormal(gas, right, normal); 1999f844368SJames Wright StateConservative dflux_left = FluxInviscidDotNormal_fwd(gas, left, dleft, normal); 2009f844368SJames Wright StateConservative dflux_right = FluxInviscidDotNormal_fwd(gas, right, dright, normal); 2019f844368SJames Wright 2029f844368SJames Wright CeedScalar u_left = Dot3(left.Y.velocity, normal); 2039f844368SJames Wright CeedScalar u_right = Dot3(right.Y.velocity, normal); 2049f844368SJames Wright CeedScalar du_left = Dot3(dleft.Y.velocity, normal); 2059f844368SJames Wright CeedScalar du_right = Dot3(dright.Y.velocity, normal); 2069f844368SJames Wright 2079f844368SJames Wright CeedScalar s_left, ds_left, s_right, ds_right; 2089f844368SJames Wright ComputeHLLSpeeds_Roe_fwd(gas, left, dleft, u_left, du_left, right, dright, u_right, du_right, &s_left, &ds_left, &s_right, &ds_right); 2099f844368SJames Wright 2109f844368SJames Wright if (0 <= s_left) { 2119f844368SJames Wright return dflux_left; 2129f844368SJames Wright } else if (s_right <= 0) { 2139f844368SJames Wright return dflux_right; 2149f844368SJames Wright } else { 2159f844368SJames Wright return Flux_HLL_fwd(left, right, dleft, dright, flux_left, flux_right, dflux_left, dflux_right, s_left, s_right, ds_left, ds_right); 2169f844368SJames Wright } 2179f844368SJames Wright } 2189f844368SJames Wright 2199f844368SJames Wright CEED_QFUNCTION_HELPER StateConservative RiemannFlux_HLLC_Star(NewtonianIdealGasContext gas, State side, StateConservative F_side, 2209f844368SJames Wright const CeedScalar normal[3], CeedScalar u_side, CeedScalar s_side, CeedScalar s_star) { 2219f844368SJames Wright CeedScalar fact = side.U.density * (s_side - u_side) / (s_side - s_star); 2229f844368SJames Wright CeedScalar denom = side.U.density * (s_side - u_side); 2239f844368SJames Wright // U_* = fact * star 2249f844368SJames Wright StateConservative star = { 2259f844368SJames Wright 1.0, 2269f844368SJames Wright { 2279f844368SJames Wright side.Y.velocity[0] + (s_star - u_side) * normal[0], 2289f844368SJames Wright side.Y.velocity[1] + (s_star - u_side) * normal[1], 2299f844368SJames Wright side.Y.velocity[2] + (s_star - u_side) * normal[2], 2309f844368SJames Wright }, 2319f844368SJames Wright side.U.E_total / side.U.density // 2329f844368SJames Wright + (s_star - u_side) * (s_star + side.Y.pressure / denom) 2339f844368SJames Wright }; 2349f844368SJames Wright return StateConservativeAXPBYPCZ(1, F_side, s_side * fact, star, -s_side, side.U); 2359f844368SJames Wright } 2369f844368SJames Wright 2379f844368SJames Wright CEED_QFUNCTION_HELPER StateConservative RiemannFlux_HLLC_Star_fwd(NewtonianIdealGasContext gas, State side, State dside, StateConservative F_side, 2389f844368SJames Wright StateConservative dF_side, const CeedScalar normal[3], CeedScalar u_side, 2399f844368SJames Wright CeedScalar du_side, CeedScalar s_side, CeedScalar ds_side, CeedScalar s_star, 2409f844368SJames Wright CeedScalar ds_star) { 2419f844368SJames Wright CeedScalar fact = side.U.density * (s_side - u_side) / (s_side - s_star); 2429f844368SJames Wright CeedScalar dfact = (side.U.density * (ds_side - du_side) + dside.U.density * (s_side - u_side)) / (s_side - s_star) // 2439f844368SJames Wright - fact / (s_side - s_star) * (ds_side - ds_star); 2449f844368SJames Wright CeedScalar denom = side.U.density * (s_side - u_side); 2459f844368SJames Wright CeedScalar ddenom = side.U.density * (ds_side - du_side) + dside.U.density * (s_side - u_side); 2469f844368SJames Wright 2479f844368SJames Wright StateConservative star = { 2489f844368SJames Wright 1.0, 2499f844368SJames Wright { 2509f844368SJames Wright side.Y.velocity[0] + (s_star - u_side) * normal[0], 2519f844368SJames Wright side.Y.velocity[1] + (s_star - u_side) * normal[1], 2529f844368SJames Wright side.Y.velocity[2] + (s_star - u_side) * normal[2], 2539f844368SJames Wright }, 2549f844368SJames Wright side.U.E_total / side.U.density // 2559f844368SJames Wright + (s_star - u_side) * (s_star + side.Y.pressure / denom) 2569f844368SJames Wright }; 2579f844368SJames Wright StateConservative dstar = { 2589f844368SJames Wright 0., 2599f844368SJames Wright { 2609f844368SJames Wright dside.Y.velocity[0] + (ds_star - du_side) * normal[0], 2619f844368SJames Wright dside.Y.velocity[1] + (ds_star - du_side) * normal[1], 2629f844368SJames Wright dside.Y.velocity[2] + (ds_star - du_side) * normal[2], 2639f844368SJames Wright }, 2649f844368SJames Wright dside.U.E_total / side.U.density - side.U.E_total / Square(side.U.density) * dside.U.density // 2659f844368SJames Wright + (ds_star - du_side) * (s_star + side.Y.pressure / denom) // 2669f844368SJames Wright + (s_star - u_side) * (ds_star + dside.Y.pressure / denom - side.Y.pressure / Square(denom) * ddenom) // 2679f844368SJames Wright }; 2689f844368SJames Wright 2699f844368SJames Wright const CeedScalar a[] = {1, ds_side * fact + s_side * dfact, s_side * fact, -ds_side, -s_side}; 2709f844368SJames Wright const StateConservative U[] = {dF_side, star, dstar, side.U, dside.U}; 2719f844368SJames Wright return StateConservativeMult(5, a, U); 2729f844368SJames Wright } 2739f844368SJames Wright 2749f844368SJames Wright // HLLC Riemann solver (from Toro's book) 2759f844368SJames Wright CEED_QFUNCTION_HELPER StateConservative RiemannFlux_HLLC(NewtonianIdealGasContext gas, State left, State right, const CeedScalar normal[3]) { 2769f844368SJames Wright StateConservative flux_left = FluxInviscidDotNormal(gas, left, normal); 2779f844368SJames Wright StateConservative flux_right = FluxInviscidDotNormal(gas, right, normal); 2789f844368SJames Wright 2799f844368SJames Wright CeedScalar u_left = Dot3(left.Y.velocity, normal); 2809f844368SJames Wright CeedScalar u_right = Dot3(right.Y.velocity, normal); 2819f844368SJames Wright CeedScalar s_left, s_right; 2829f844368SJames Wright ComputeHLLSpeeds_Roe(gas, left, u_left, right, u_right, &s_left, &s_right); 2839f844368SJames Wright 2849f844368SJames Wright // Contact wave speed; Toro (10.37) 2859f844368SJames Wright CeedScalar rhou_left = left.U.density * u_left, rhou_right = right.U.density * u_right; 2869f844368SJames Wright CeedScalar numer = right.Y.pressure - left.Y.pressure + rhou_left * (s_left - u_left) - rhou_right * (s_right - u_right); 2879f844368SJames Wright CeedScalar denom = left.U.density * (s_left - u_left) - right.U.density * (s_right - u_right); 2889f844368SJames Wright CeedScalar s_star = numer / denom; 2899f844368SJames Wright 2909f844368SJames Wright // Compute HLLC flux 2919f844368SJames Wright if (0 <= s_left) { 2929f844368SJames Wright return flux_left; 2939f844368SJames Wright } else if (0 <= s_star) { 2949f844368SJames Wright return RiemannFlux_HLLC_Star(gas, left, flux_left, normal, u_left, s_left, s_star); 2959f844368SJames Wright } else if (0 <= s_right) { 2969f844368SJames Wright return RiemannFlux_HLLC_Star(gas, right, flux_right, normal, u_right, s_right, s_star); 2979f844368SJames Wright } else { 2989f844368SJames Wright return flux_right; 2999f844368SJames Wright } 3009f844368SJames Wright } 3019f844368SJames Wright 3029f844368SJames Wright CEED_QFUNCTION_HELPER StateConservative RiemannFlux_HLLC_fwd(NewtonianIdealGasContext gas, State left, State dleft, State right, State dright, 3039f844368SJames Wright const CeedScalar normal[3]) { 3049f844368SJames Wright StateConservative flux_left = FluxInviscidDotNormal(gas, left, normal); 3059f844368SJames Wright StateConservative flux_right = FluxInviscidDotNormal(gas, right, normal); 3069f844368SJames Wright StateConservative dflux_left = FluxInviscidDotNormal_fwd(gas, left, dleft, normal); 3079f844368SJames Wright StateConservative dflux_right = FluxInviscidDotNormal_fwd(gas, right, dright, normal); 3089f844368SJames Wright 3099f844368SJames Wright CeedScalar u_left = Dot3(left.Y.velocity, normal); 3109f844368SJames Wright CeedScalar u_right = Dot3(right.Y.velocity, normal); 3119f844368SJames Wright CeedScalar du_left = Dot3(dleft.Y.velocity, normal); 3129f844368SJames Wright CeedScalar du_right = Dot3(dright.Y.velocity, normal); 3139f844368SJames Wright 3149f844368SJames Wright CeedScalar s_left, ds_left, s_right, ds_right; 3159f844368SJames Wright ComputeHLLSpeeds_Roe_fwd(gas, left, dleft, u_left, du_left, right, dright, u_right, du_right, &s_left, &ds_left, &s_right, &ds_right); 3169f844368SJames Wright 3179f844368SJames Wright // Contact wave speed; Toro (10.37) 3189f844368SJames Wright CeedScalar rhou_left = left.U.density * u_left, drhou_left = left.U.density * du_left + dleft.U.density * u_left; 3199f844368SJames Wright CeedScalar rhou_right = right.U.density * u_right, drhou_right = right.U.density * du_right + dright.U.density * u_right; 3209f844368SJames Wright CeedScalar numer = right.Y.pressure - left.Y.pressure // 3219f844368SJames Wright + rhou_left * (s_left - u_left) // 3229f844368SJames Wright - rhou_right * (s_right - u_right); 3239f844368SJames Wright CeedScalar dnumer = dright.Y.pressure - dleft.Y.pressure // 3249f844368SJames Wright + rhou_left * (ds_left - du_left) + drhou_left * (s_left - u_left) // 3259f844368SJames Wright - rhou_right * (ds_right - du_right) - drhou_right * (s_right - u_right); 3269f844368SJames Wright CeedScalar denom = left.U.density * (s_left - u_left) - right.U.density * (s_right - u_right); 3279f844368SJames Wright CeedScalar ddenom = left.U.density * (ds_left - du_left) + dleft.U.density * (s_left - u_left) // 3289f844368SJames Wright - right.U.density * (ds_right - du_right) - dright.U.density * (s_right - u_right); 3299f844368SJames Wright CeedScalar s_star = numer / denom; 3309f844368SJames Wright CeedScalar ds_star = dnumer / denom - numer / Square(denom) * ddenom; 3319f844368SJames Wright 3329f844368SJames Wright // Compute HLLC flux 3339f844368SJames Wright if (0 <= s_left) { 3349f844368SJames Wright return dflux_left; 3359f844368SJames Wright } else if (0 <= s_star) { 3369f844368SJames Wright return RiemannFlux_HLLC_Star_fwd(gas, left, dleft, flux_left, dflux_left, normal, u_left, du_left, s_left, ds_left, s_star, ds_star); 3379f844368SJames Wright } else if (0 <= s_right) { 3389f844368SJames Wright return RiemannFlux_HLLC_Star_fwd(gas, right, dright, flux_right, dflux_right, normal, u_right, du_right, s_right, ds_right, s_star, ds_star); 3399f844368SJames Wright } else { 3409f844368SJames Wright return dflux_right; 3419f844368SJames Wright } 3429f844368SJames Wright } 343