Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
AddForceVerticalDiscPotential.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
21#include "shambackends/vec.hpp"
27
29#define NODE_EDGES(X_RO, X_RW) \
30 /* inputs */ \
31 X_RO(shamrock::solvergraph::IDataEdge<Tscal>, constant_G) \
32 X_RO(shamrock::solvergraph::IDataEdge<Tscal>, central_mass) \
33 X_RO(shamrock::solvergraph::IDataEdge<Tscal>, R0) \
34 X_RO(shamrock::solvergraph::IFieldSpan<Tvec>, spans_positions) \
35 X_RO(shamrock::solvergraph::Indexes<u32>, sizes) \
36 \
37 /* outputs */ \
38 X_RW(shamrock::solvergraph::IFieldSpan<Tvec>, spans_accel_ext)
39
40namespace shammodels::common::modules {
41 template<class Tvec>
42 class AddForceVerticalDiscPotential : public shamrock::solvergraph::INode {
43
44 using Tscal = shambase::VecComponent<Tvec>;
45
46 public:
47 AddForceVerticalDiscPotential() = default;
48
49 EXPAND_NODE_EDGES(NODE_EDGES)
50
52
54
55 auto edges = get_edges();
56
57 edges.spans_positions.check_sizes(edges.sizes.indexes);
58 edges.spans_accel_ext.ensure_sizes(edges.sizes.indexes);
59
60 Tscal cmass = edges.central_mass.data;
61 Tscal G = edges.constant_G.data;
62 Tscal R0 = edges.R0.data;
63
64 // call the GPU kernel for each patches
66 shamsys::instance::get_compute_scheduler_ptr(),
67 sham::DDMultiRef{edges.spans_positions.get_spans()},
68 sham::DDMultiRef{edges.spans_accel_ext.get_spans()},
69 edges.sizes.indexes,
70 [mGM_R02 = -cmass * G / (R0 * R0),
71 R02 = R0 * R0](u32 gid, const Tvec *xyz, Tvec *axyz_ext) {
72 // thin disc approx: a_z = -GM z / (R0^2 sqrt(R0^2 + z^2)) ~ -Omega_K^2 z
73 Tscal z_a = xyz[gid].z();
74 axyz_ext[gid].z() += mGM_R02 * z_a / sycl::sqrt(R02 + z_a * z_a);
75 });
76 }
77
78 inline virtual std::string _impl_get_label() const {
79 return "AddForceVerticalDiscPotential";
80 };
81
82 inline virtual std::string _impl_get_tex() const { return "TODO"; };
83 };
84
85} // namespace shammodels::common::modules
86
87// remove the macro before exiting
88#undef NODE_EDGES
Header file describing a Node Instance.
std::uint32_t u32
32 bit unsigned integer
virtual std::string _impl_get_label() const
get the label of the node
virtual std::string _impl_get_tex() const
get the tex of the node
Inode is node between data edges, takes multiple inputs, multiple outputs.
Definition INode.hpp:31
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.