Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
contract_grav_moment.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
21
22namespace shamphys {
23
30 template<class T, u32 order>
31 inline sycl::vec<T, 3> contract_grav_moment_to_force(
34
35 using vec = sycl::vec<T, 3>;
36
37 auto tensor_to_sycl = [](shammath::SymTensor3d_1<T> a) {
38 return sycl::vec<T, 3>{a.v_0, a.v_1, a.v_2};
39 };
40
41 auto force_val = tensor_to_sycl(dM_k.t1 * a_k.t0);
42 if constexpr (order >= 2) {
43 force_val += tensor_to_sycl(dM_k.t2 * a_k.t1) / 1;
44 }
45 if constexpr (order >= 3) {
46 force_val += tensor_to_sycl(dM_k.t3 * a_k.t2) / 2;
47 }
48 if constexpr (order >= 4) {
49 force_val += tensor_to_sycl(dM_k.t4 * a_k.t3) / 6;
50 }
51 if constexpr (order >= 5) {
52 force_val += tensor_to_sycl(dM_k.t5 * a_k.t4) / 24;
53 }
54
55 return force_val;
56 }
57} // namespace shamphys
sycl::vec< T, 3 > contract_grav_moment_to_force(const shammath::SymTensorCollection< T, 0, order - 1 > &a_k, const shammath::SymTensorCollection< T, 1, order > &dM_k)
Contract the gravitational moment and the displacement to get a force.