Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
q_ab.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#include "shambackends/math.hpp"
22#include "shambackends/vec.hpp"
23#include "shamphys/mhd.hpp"
24
25namespace shamrock::sph {
26
36 template<class Tscal>
37 inline constexpr Tscal q_av(const Tscal &rho, const Tscal &vsig, const Tscal &v_scal_rhat) {
38 return sham::max(-Tscal(0.5) * rho * vsig * v_scal_rhat, Tscal(0));
39 }
40
41 template<class Tscal>
42 inline constexpr Tscal q_av_disc(
43 const Tscal &rho,
44 const Tscal &h,
45 const Tscal &rab,
46 const Tscal &alpha_av,
47 const Tscal &cs,
48 const Tscal &vsig,
49 const Tscal &v_scal_rhat) {
50 Tscal q_av_d;
51 Tscal rho1 = 1. / rho;
52 Tscal rabinv = sham::inv_sat_positive(rab);
53
54 Tscal prefact = -Tscal(0.5) * rho * sham::abs(rabinv) * h;
55
56 Tscal vsig_disc = (v_scal_rhat < Tscal(0)) ? vsig : (alpha_av * cs);
57
58 q_av_d = prefact * vsig_disc * v_scal_rhat;
59
60 return q_av_d;
61 }
62
63} // namespace shamrock::sph
T inv_sat_positive(T v, T minvsat=T{1e-9}, T satval=T{0.}) noexcept
inverse saturated (positive numbers only)
Definition math.hpp:841
constexpr Tscal q_av(const Tscal &rho, const Tscal &vsig, const Tscal &v_scal_rhat)
eq.40
Definition q_ab.hpp:37