Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
slopeLimiter.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#include "shambackends/math.hpp"
20
21namespace shammath {
22
39 template<class T>
40 inline T van_leer_slope(T f, T g) {
41 T tmp = f * g;
42 if (tmp > 0) {
43 return 2 * tmp / (f + g);
44 } else {
45 return 0;
46 }
47 }
48
49 template<class T>
50 inline T van_leer_slope_symetric(T sR, T sL) {
51 T abs_sR = sham::abs(sR);
52 T abs_sL = sham::abs(sL);
53 T sgn_sR = sycl::sign(sR);
54 T sgn_sL = sycl::sign(sL);
55
56 T tmp = abs_sR * abs_sL;
57
58 if (tmp > 0) {
59 return tmp * (sgn_sL + sgn_sR) / (abs_sL + abs_sR);
60 } else {
61 return 0;
62 }
63 }
64
65 template<class T>
66 inline T minmod(T sR, T sL) {
67 T r = sL / sR;
68 return ((r > 0) ? ((r < 1) ? r : 1) : 0) * sR;
69 }
70
71} // namespace shammath
namespace for math utility
Definition AABB.hpp:26
T van_leer_slope(T f, T g)
Van leer slope limiter.