Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
AddForceShearingBoxInertialPart.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 "shamcomm/logs.hpp"
27
28namespace shammodels::common::modules {
29 template<class Tvec>
31
32 using Tscal = shambase::VecComponent<Tvec>;
33
34 public:
36
43
44 inline void set_edges(
45 std::shared_ptr<shamrock::solvergraph::IDataEdge<Tscal>> eta,
46 std::shared_ptr<shamrock::solvergraph::IFieldSpan<Tvec>> spans_positions,
47 std::shared_ptr<shamrock::solvergraph::Indexes<u32>> sizes,
48 std::shared_ptr<shamrock::solvergraph::IFieldSpan<Tvec>> spans_accel_ext) {
49 __internal_set_ro_edges({eta, spans_positions, sizes});
50 __internal_set_rw_edges({spans_accel_ext});
51 }
52
53 inline Edges get_edges() {
54 return Edges{
55 get_ro_edge<shamrock::solvergraph::IDataEdge<Tscal>>(0),
57 get_ro_edge<shamrock::solvergraph::Indexes<u32>>(2),
59 }
60
62
64
65 auto edges = get_edges();
66
67 edges.spans_positions.check_sizes(edges.sizes.indexes);
68 edges.spans_accel_ext.ensure_sizes(edges.sizes.indexes);
69
70 Tscal eta = edges.eta.data;
71
73 shamsys::instance::get_compute_scheduler_ptr(),
74 sham::DDMultiRef{edges.spans_positions.get_spans()},
75 sham::DDMultiRef{edges.spans_accel_ext.get_spans()},
76 edges.sizes.indexes,
77 [two_eta = 2 * eta](u32 gid, const Tvec *xyz, Tvec *axyz_ext) {
78 Tvec r_a = xyz[gid];
79 axyz_ext[gid] += Tvec{r_a.x() * two_eta, 0, 0};
80 });
81 }
82
83 inline virtual std::string _impl_get_label() const {
84 return "AddForceShearingBoxInertialPart";
85 };
86
87 virtual std::string _impl_get_tex() const { return "TODO"; }
88 };
89} // 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
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.