Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
ComputeFluxUtilities.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
19
20#include "shambackends/sycl.hpp"
21#include "shammath/riemann.hpp"
24
26
27 using RiemannSolverMode = shammodels::basegodunov::RiemannSolverMode;
28 using DustRiemannSolverMode = shammodels::basegodunov::DustRiemannSolverMode;
29 using Direction = shammodels::basegodunov::modules::Direction;
30
34 template<class Tvec, Direction dir>
35 inline constexpr Tvec dir_normal() {
36 if constexpr (dir == Direction::xp) {
37 return Tvec{1, 0, 0};
38 } else if constexpr (dir == Direction::xm) {
39 return Tvec{-1, 0, 0};
40 } else if constexpr (dir == Direction::yp) {
41 return Tvec{0, 1, 0};
42 } else if constexpr (dir == Direction::ym) {
43 return Tvec{0, -1, 0};
44 } else if constexpr (dir == Direction::zp) {
45 return Tvec{0, 0, 1};
46 } else if constexpr (dir == Direction::zm) {
47 return Tvec{0, 0, -1};
48 } else {
49 static_assert(shambase::always_false_v<decltype(dir)>, "non-exhaustive visitor!");
50 }
51 return Tvec{};
52 }
53
59 template<shammath::FluidStateAdiabaticSpec FSpec, RiemannSolverMode mode, Direction dir>
60 inline constexpr typename FSpec::Tcons riemann_flux(
61 const FSpec &fspec,
62 const typename FSpec::Tprim &prim_l,
63 const typename FSpec::Tprim &prim_r) {
64 const typename FSpec::Tvec n = dir_normal<typename FSpec::Tvec, dir>();
65
66 if constexpr (mode == RiemannSolverMode::Rusanov) {
67 return shammath::rusanov_flux(fspec, prim_l, prim_r, n);
68 }
69 if constexpr (mode == RiemannSolverMode::HLL) {
70 return shammath::hll_flux(fspec, prim_l, prim_r, n);
71 }
72 if constexpr (mode == RiemannSolverMode::HLLC) {
73 return shammath::hllc_adiab_toro_flux(fspec, prim_l, prim_r, n);
74 }
75 }
76
82 template<shammath::DustFluidStateSpec FSpec, DustRiemannSolverMode mode, Direction dir>
83 inline constexpr typename FSpec::Tcons riemann_dust_flux(
84 const FSpec &fspec,
85 const typename FSpec::Tprim &prim_l,
86 const typename FSpec::Tprim &prim_r) {
87 const typename FSpec::Tvec n = dir_normal<typename FSpec::Tvec, dir>();
88
89 if constexpr (mode == DustRiemannSolverMode::HB) {
90 return shammath::huang_bai_flux(fspec, prim_l, prim_r, n);
91 }
92 if constexpr (mode == DustRiemannSolverMode::DHLL) {
93 return shammath::d_hll_flux(fspec, prim_l, prim_r, n);
94 }
95 }
96
97} // namespace shammodels::basegodunov::modules
constexpr bool always_false_v
Helper variable template that is always false. Especially useful to perform static asserts based on t...
constexpr FSpec::Tcons huang_bai_flux(const FSpec &fspec, const typename FSpec::Tprim &prim_l, const typename FSpec::Tprim &prim_r, const typename FSpec::Tvec &n)
Huang & Bai dust flux across a face with unit normal n.
constexpr FSpec::Tcons rusanov_flux(const FSpec &fspec, const typename FSpec::Tprim &prim_l, const typename FSpec::Tprim &prim_r, const typename FSpec::Tvec &n)
Rusanov flux across a face with unit normal n.
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.
constexpr FSpec::Tcons hllc_adiab_toro_flux(const FSpec &fspec, const typename FSpec::Tprim &prim_l, const typename FSpec::Tprim &prim_r, const typename FSpec::Tvec &n)
HLLC solver based on section 10.4 from Toro 3rd Edition , Springer 2009. The wave speeds estimates ar...
constexpr FSpec::Tcons d_hll_flux(const FSpec &fspec, const typename FSpec::Tprim &prim_l, const typename FSpec::Tprim &prim_r, const typename FSpec::Tvec &n)
Dust HLL flux across a face with unit normal n.
namespace for the basegodunov model modules
constexpr FSpec::Tcons riemann_dust_flux(const FSpec &fspec, const typename FSpec::Tprim &prim_l, const typename FSpec::Tprim &prim_r)
Dispatch to the dust Riemann solver selected by mode, for a face with unit normal along dir....
constexpr FSpec::Tcons riemann_flux(const FSpec &fspec, const typename FSpec::Tprim &prim_l, const typename FSpec::Tprim &prim_r)
Dispatch to the gas Riemann solver selected by mode, for a face with unit normal along dir....
constexpr Tvec dir_normal()
Unit normal vector of a face pointing in the given direction.
DustRiemannSolverMode
Dust Riemann solver mode enum.
@ HB
Huang and Bai. Pressureless Riemann solver by Huang and Bai (2022) in Athena++.
@ DHLL
Dust HLL. This is merely the HLL solver for dust. It's then a Rusanov like.
Umbrella header pulling in the gas states and all gas Riemann solvers (Rusanov, HLL,...
Umbrella header pulling in the dust states and all dust Riemann solvers (HLL, Huang & Bai).