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