Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
AddForceLenseThirring.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#include "shambackends/math.hpp"
22#include "shamcomm/logs.hpp"
28
29namespace shammodels::common::modules {
30 template<class Tvec>
32
33 using Tscal = shambase::VecComponent<Tvec>;
34
35 public:
36 AddForceLenseThirring() = default;
37
51
52 inline void set_edges(
53 std::shared_ptr<shamrock::solvergraph::IDataEdge<Tscal>> constant_G,
54 std::shared_ptr<shamrock::solvergraph::IDataEdge<Tscal>> constant_c,
55 std::shared_ptr<shamrock::solvergraph::IDataEdge<Tscal>> central_mass,
56 std::shared_ptr<shamrock::solvergraph::IDataEdge<Tvec>> central_pos,
57 std::shared_ptr<shamrock::solvergraph::IDataEdge<Tscal>> a_spin,
58 std::shared_ptr<shamrock::solvergraph::IDataEdge<Tvec>> dir_spin,
59 std::shared_ptr<shamrock::solvergraph::IFieldSpan<Tvec>> spans_positions,
60 std::shared_ptr<shamrock::solvergraph::IFieldSpan<Tvec>> spans_velocities,
61 std::shared_ptr<shamrock::solvergraph::Indexes<u32>> sizes,
62 std::shared_ptr<shamrock::solvergraph::IFieldSpan<Tvec>> spans_accel_ext) {
64 {constant_G,
65 constant_c,
66 central_mass,
67 central_pos,
68 a_spin,
69 dir_spin,
70 spans_positions,
71 spans_velocities,
72 sizes});
73 __internal_set_rw_edges({spans_accel_ext});
74 }
75
76 inline Edges get_edges() {
77 return Edges{
78 get_ro_edge<shamrock::solvergraph::IDataEdge<Tscal>>(0),
80 get_ro_edge<shamrock::solvergraph::IDataEdge<Tscal>>(2),
82 get_ro_edge<shamrock::solvergraph::IDataEdge<Tscal>>(4),
84 get_ro_edge<shamrock::solvergraph::IFieldSpan<Tvec>>(6),
86 get_ro_edge<shamrock::solvergraph::Indexes<u32>>(8),
88 }
89
91
93
94 auto edges = get_edges();
95
96 edges.spans_positions.check_sizes(edges.sizes.indexes);
97 edges.spans_accel_ext.ensure_sizes(edges.sizes.indexes);
98
99 Tscal G = edges.constant_G.data;
100 Tscal c = edges.constant_c.data;
101 Tscal cmass = edges.central_mass.data;
102 Tvec cpos = edges.central_pos.data;
103 Tscal a_spin = edges.a_spin.data;
104 Tvec dir_spin = edges.dir_spin.data;
105
106 Tscal GM = cmass * G;
107 Tvec S = a_spin * GM * GM * dir_spin / (c * c * c);
108
110 shamsys::instance::get_compute_scheduler_ptr(),
112 edges.spans_positions.get_spans(), edges.spans_velocities.get_spans()},
113 sham::DDMultiRef{edges.spans_accel_ext.get_spans()},
114 edges.sizes.indexes,
115 [cpos, S](u32 gid, const Tvec *xyz, const Tvec *vxyz, Tvec *axyz_ext) {
116 Tvec r_a = xyz[gid];
117 Tvec v_a = vxyz[gid];
118 Tscal abs_ra = sycl::length(r_a);
119 Tscal abs_ra_2 = abs_ra * abs_ra;
120 Tscal abs_ra_3 = abs_ra_2 * abs_ra;
121 Tscal abs_ra_5 = abs_ra_2 * abs_ra_2 * abs_ra;
122
123 Tvec omega_a = (S * (2 / abs_ra_3)) - (6 * sham::dot(S, r_a) * r_a) / abs_ra_5;
124 Tvec acc_lt = sycl::cross(v_a, omega_a);
125 axyz_ext[gid] += acc_lt;
126 });
127 }
128
129 inline virtual std::string _impl_get_label() const { return "AddForceLenseThirring"; };
130
131 virtual std::string _impl_get_tex() const { return "TODO"; }
132 };
133} // namespace shammodels::common::modules
Header file describing a Node Instance.
Source location utility.
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
Interface for a solver graph edge representing a field as spans.
Inode is node between data edges, takes multiple inputs, multiple outputs.
Definition INode.hpp:30
T & get_rw_edge(int slot)
Get a read write edge and cast it to the type T.
Definition INode.hpp:86
void __internal_set_rw_edges(std::vector< std::shared_ptr< IEdge > > new_rw_edges)
Set the read write edges.
Definition INode.hpp:181
void __internal_set_ro_edges(std::vector< std::shared_ptr< IEdge > > new_ro_edges)
Set the read only edges.
Definition INode.hpp:171
const T & get_ro_edge(int slot)
Get a read only edge and cast it to the type T.
Definition INode.hpp:80
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.