Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
density.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/sycl.hpp"
20namespace shamrock::sph {
21
22 template<class flt>
23 inline flt rho_h(flt m, flt h, flt hfact) {
24 return m * (hfact / h) * (hfact / h) * (hfact / h);
25 }
26
27 template<class flt, i32 dim = 3>
28 inline flt h_rho(flt m, flt rho, flt hfact) {
29 return hfact / sycl::rootn(rho / m, dim);
30 }
31
32 template<class flt, i32 dim = 3>
33 inline flt newton_iterate_new_h(flt rho_ha, flt rho_sum, flt sumdWdh, flt h_a) {
34 flt f_iter = rho_sum - rho_ha;
35 flt df_iter = sumdWdh + dim * rho_ha / h_a;
36
37 // flt omega_a = 1 + (h_a/(3*rho_ha))*sumdWdh;
38 // flt new_h = h_a - (rho_ha - rho_sum)/((-3*rho_ha/h_a)*omega_a);
39
40 return h_a - f_iter / df_iter;
41 }
42} // namespace shamrock::sph