Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
AddForceCentralGravPotential.cpp
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
16
21
22namespace shammodels::common::modules {
23
24 template<class Tvec>
26
28
29 auto edges = get_edges();
30
31 edges.spans_positions.check_sizes(edges.sizes.indexes);
32 edges.spans_accel_ext.ensure_sizes(edges.sizes.indexes);
33
34 Tscal cmass = edges.central_mass.data;
35 Tscal G = edges.constant_G.data;
36 Tvec cpos = edges.central_pos.data;
37
39 shamsys::instance::get_compute_scheduler_ptr(),
40 sham::DDMultiRef{edges.spans_positions.get_spans()},
41 sham::DDMultiRef{edges.spans_accel_ext.get_spans()},
42 edges.sizes.indexes,
43 [mGM = -cmass * G, cpos](u32 gid, const Tvec *xyz, Tvec *axyz_ext) {
44 Tvec r_a = xyz[gid] - cpos;
45 Tscal abs_ra = sycl::length(r_a);
46 Tscal abs_ra_3 = abs_ra * abs_ra * abs_ra;
47 axyz_ext[gid] += mGM * r_a / abs_ra_3;
48 });
49 }
50
51 template<class Tvec>
53 std::string tex = R"tex(
54 Add force (central gravitational potential)
55
56 \begin{align}
57 {spans_accel_ext}_i = -{constant_G} * {central_mass} * {central_pos}_i / {spans_positions}_i^3
58 \end{align}
59 )tex";
60
61 replace_edges_tex_symbols(tex);
62
63 return tex;
64 }
65
67
68} // namespace shammodels::common::modules
Adds the acceleration from a central gravitational potential (point mass).
Header file describing a Node Instance.
std::uint32_t u32
32 bit unsigned integer
virtual std::string _impl_get_tex() const
get the tex of the node
void distributed_data_kernel_call(sham::DeviceScheduler_ptr dev_sched, RefIn in, RefOut in_out, const shambase::DistributedData< index_t > &thread_counts, Functor &&func)
A variant of sham::kernel_call for distributed data.
#define __shamrock_stack_entry()
Macro to create a stack entry.
A variant of sham::MultiRef for distributed data.