Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
AddForceShearingBoxNonInertial.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:
37
47
48 inline void set_edges(
49 std::shared_ptr<shamrock::solvergraph::IDataEdge<Tscal>> omega_0,
51 std::shared_ptr<shamrock::solvergraph::IFieldSpan<Tvec>> spans_positions,
52 std::shared_ptr<shamrock::solvergraph::IFieldSpan<Tvec>> spans_velocities,
53 std::shared_ptr<shamrock::solvergraph::Indexes<u32>> sizes,
54 std::shared_ptr<shamrock::solvergraph::IFieldSpan<Tvec>> spans_accel_ext) {
55 __internal_set_ro_edges({omega_0, q, spans_positions, spans_velocities, sizes});
56 __internal_set_rw_edges({spans_accel_ext});
57 }
58
59 inline Edges get_edges() {
60 return Edges{
61 get_ro_edge<shamrock::solvergraph::IDataEdge<Tscal>>(0),
63 get_ro_edge<shamrock::solvergraph::IFieldSpan<Tvec>>(2),
65 get_ro_edge<shamrock::solvergraph::Indexes<u32>>(4),
67 }
68
70
72
73 auto edges = get_edges();
74
75 edges.spans_positions.check_sizes(edges.sizes.indexes);
76 edges.spans_accel_ext.ensure_sizes(edges.sizes.indexes);
77
78 Tscal Omega_0 = edges.omega_0.data;
79 Tscal q = edges.q.data;
80
81 Tscal Omega_0_sq = Omega_0 * Omega_0;
82
84 shamsys::instance::get_compute_scheduler_ptr(),
86 edges.spans_positions.get_spans(), edges.spans_velocities.get_spans()},
87 sham::DDMultiRef{edges.spans_accel_ext.get_spans()},
88 edges.sizes.indexes,
89 [Omega_0, Omega_0_sq, q](
90 u32 gid, const Tvec *xyz, const Tvec *vxyz, Tvec *axyz_ext) {
91 Tvec r_a = xyz[gid];
92 Tvec v_a = vxyz[gid];
93 axyz_ext[gid] += Tvec{
94 2 * Omega_0 * (q * Omega_0 * r_a.x() + v_a.y()),
95 -2 * Omega_0 * v_a.x(),
96 -Omega_0_sq * r_a.z()};
97 });
98 }
99
100 inline virtual std::string _impl_get_label() const {
101 return "AddForceShearingBoxNonInertial";
102 };
103
104 virtual std::string _impl_get_tex() const { return "TODO"; }
105 };
106} // 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.