Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
riemann_hll.hpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
10#pragma once
11
20
22
23namespace shammath {
24
28 template<FluidStateSpec FSpec>
29 inline constexpr typename FSpec::Tcons hll_flux(
30 const FSpec &fspec,
31 const typename FSpec::Tprim &prim_l,
32 const typename FSpec::Tprim &prim_r,
33 const typename FSpec::Tvec &n) {
34 const auto cs_l = fspec.sound_speed(prim_l);
35 const auto cs_r = fspec.sound_speed(prim_r);
36
37 const auto vn_l = fspec.vn(prim_l, n);
38 const auto vn_r = fspec.vn(prim_r, n);
39
40 // NOLINTBEGIN(readability-identifier-naming)
41
42 // Teyssier form
43 // const auto S_l = sham::min(vn_l, vn_r) - sham::max(cs_l, cs_r);
44 // const auto S_r = sham::max(vn_l, vn_r) + sham::max(cs_l, cs_r);
45
46 // Toro form Equation (10.48)
47 const auto S_l = sham::min(vn_l - cs_l, vn_r - cs_r);
48 const auto S_r = sham::max(vn_l + cs_l, vn_r + cs_r);
49
50 // NOLINTEND(readability-identifier-naming)
51
52 const auto flux_l = fspec.flux(prim_l, n, vn_l);
53 const auto flux_r = fspec.flux(prim_r, n, vn_r);
54
55 // Equation (10.26) from Toro 3rd Edition , Springer 2009
56 // const auto S_l_upwind = sham::min(S_l, 0.0);
57 // const auto S_r_upwind = sham::max(S_r, 0.0);
58 // const auto S_norm = 1.0 / (S_r_upwind - S_l_upwind);
59 // return (flux_l * S_r_upwind - flux_r * S_l_upwind
60 // + (cons_r - cons_l) * S_r_upwind * S_l_upwind)
61 // * S_norm;
62
63 if (S_l >= 0)
64 return flux_l;
65 else if (S_r <= 0)
66 return flux_r;
67 else {
68 // Only the intermediate (star) state needs the conservative form, so it is
69 // formed here rather than at the call site (which only has primitives).
70 const auto cons_l = fspec.prim_to_cons(prim_l);
71 const auto cons_r = fspec.prim_to_cons(prim_r);
72 // NOLINTNEXTLINE(readability-identifier-naming)
73 const auto S_norm = 1.0 / (S_r - S_l);
74 return (flux_l * S_r - flux_r * S_l + (cons_r - cons_l) * S_r * S_l) * S_norm;
75 }
76 }
77
78} // namespace shammath
namespace for math utility
Definition AABB.hpp:26
constexpr FSpec::Tcons hll_flux(const FSpec &fspec, const typename FSpec::Tprim &prim_l, const typename FSpec::Tprim &prim_r, const typename FSpec::Tvec &n)
HLL flux across a face with unit normal n.
Gas and dust conservative/primitive states and axis-transform helpers shared by every gas and dust Ri...