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
20#include "shambackends/vec.hpp"
26
28#define NODE_EDGES(X_RO, X_RW) \
29 /* inputs */ \
30 X_RO(shamrock::solvergraph::IDataEdge<Tscal>, constant_G) \
31 X_RO(shamrock::solvergraph::IDataEdge<Tscal>, central_mass) \
32 X_RO(shamrock::solvergraph::IDataEdge<Tscal>, R0) \
33 X_RO(shamrock::solvergraph::IFieldSpan<Tvec>, spans_positions) \
34 X_RO(shamrock::solvergraph::Indexes<u32>, sizes) \
35 \
36 /* outputs */ \
37 X_RW(shamrock::solvergraph::IFieldSpan<Tvec>, spans_accel_ext)
38
39namespace shammodels::common::modules {
40 template<class Tvec>
42
43 using Tscal = shambase::VecComponent<Tvec>;
44
45 public:
47
48 EXPAND_NODE_EDGES(NODE_EDGES)
49
51
53
54 auto edges = get_edges();
55
56 edges.spans_positions.check_sizes(edges.sizes.indexes);
57 edges.spans_accel_ext.ensure_sizes(edges.sizes.indexes);
58
59 Tscal cmass = edges.central_mass.data;
60 Tscal G = edges.constant_G.data;
61 Tscal R0 = edges.R0.data;
62
63 // call the GPU kernel for each patches
65 shamsys::instance::get_compute_scheduler_ptr(),
66 sham::DDMultiRef{edges.spans_positions.get_spans()},
67 sham::DDMultiRef{edges.spans_accel_ext.get_spans()},
68 edges.sizes.indexes,
69 [mGM = -cmass * G, R02 = R0 * R0](u32 gid, const Tvec *xyz, Tvec *axyz_ext) {
70 Tscal y_a = xyz[gid].y();
71 axyz_ext[gid].y() += mGM * y_a / sycl::sqrt(R02 + y_a * y_a);
72 });
73 }
74
75 inline virtual std::string _impl_get_label() const {
76 return "AddForceVerticalDiscPotential";
77 };
78
79 inline virtual std::string _impl_get_tex() const { return "TODO"; };
80 };
81
82} // namespace shammodels::common::modules
83
84// remove the macro before exiting
85#undef NODE_EDGES
#define NODE_EDGES(X_RO, X_RW)
declare the list of edges for this node
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:30
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.