Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
NodeAYPX.cpp
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
18
19#include "shambase/string.hpp"
24
25namespace shamrock::solvergraph {
26
27 template<class T>
29 auto edges = get_edges();
30
31 edges.spans_x.check_sizes(edges.sizes.indexes);
32 edges.spans_y.check_sizes(edges.sizes.indexes);
33
34 Tscal alpha = edges.alpha.data;
35
37 = edges.sizes.indexes.template map<u32>([&](u64 id, u32 obj_cnt) {
38 return obj_cnt * nvar;
39 });
40
42 shamsys::instance::get_compute_scheduler_ptr(),
43 sham::DDMultiRef{edges.spans_x.get_spans()},
44 sham::DDMultiRef{edges.spans_y.get_spans()},
45 val_cnts,
46 [alpha](u32 i, const T *__restrict x, T *__restrict y) {
47 y[i] = alpha * y[i] + x[i];
48 });
49 }
50
51 template<class T>
52 std::string NodeAYPX<T>::_impl_get_tex() const {
53 std::string tex = R"tex(
54 AYPX update
55 \begin{equation}
56 {spans_y}_i \leftarrow {alpha} \, {spans_y}_i + {spans_x}_i
57 \end{equation}
58 )tex";
59
60 replace_edges_tex_symbols(tex);
61
62 return tex;
63 }
64
65} // namespace shamrock::solvergraph
66
Node computing the in place update y <- alpha * y + x on fields.
Header file describing a Node Instance.
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
Represents a collection of objects distributed across patches identified by a u64 id.
Compute y <- alpha * y + x on every value of every patch.
Definition NodeAYPX.hpp:46
void _impl_evaluate_internal()
evaluate the node
Definition NodeAYPX.cpp:28
virtual std::string _impl_get_tex() const
get the tex of the node
Definition NodeAYPX.cpp:52
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.
A variant of sham::MultiRef for distributed data.