Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
AddForceVelocityDissipation.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>, eta) \
31 X_RO(shamrock::solvergraph::IFieldSpan<Tvec>, spans_velocity) \
32 X_RO(shamrock::solvergraph::Indexes<u32>, sizes) \
33 \
34 /* outputs */ \
35 X_RW(shamrock::solvergraph::IFieldSpan<Tvec>, spans_accel_ext)
36
37namespace shammodels::common::modules {
38 template<class Tvec>
40
41 using Tscal = shambase::VecComponent<Tvec>;
42
43 public:
45
46 EXPAND_NODE_EDGES(NODE_EDGES)
47
49
51
52 auto edges = get_edges();
53
54 edges.spans_velocity.check_sizes(edges.sizes.indexes);
55 edges.spans_accel_ext.ensure_sizes(edges.sizes.indexes);
56
57 Tscal eta = edges.eta.data;
58
59 // call the GPU kernel for each patches
61 shamsys::instance::get_compute_scheduler_ptr(),
62 sham::DDMultiRef{edges.spans_velocity.get_spans()},
63 sham::DDMultiRef{edges.spans_accel_ext.get_spans()},
64 edges.sizes.indexes,
65 [eta](u32 gid, const Tvec *vxyz, Tvec *axyz_ext) {
66 axyz_ext[gid] -= eta * vxyz[gid];
67 });
68 }
69
70 inline virtual std::string _impl_get_label() const {
71 return "AddForceVelocityDissipation";
72 };
73
74 inline virtual std::string _impl_get_tex() const { return "TODO"; };
75 };
76
77} // namespace shammodels::common::modules
78
79// remove the macro before exiting
80#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.