Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
NodeHadamardProd.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_in1.check_sizes(edges.sizes.indexes);
32 edges.spans_in2.check_sizes(edges.sizes.indexes);
33 edges.spans_out.ensure_sizes(edges.sizes.indexes);
34
36 = edges.sizes.indexes.template map<u32>([&](u64 id, u32 obj_cnt) {
37 return obj_cnt * nvar;
38 });
39
41 shamsys::instance::get_compute_scheduler_ptr(),
42 sham::DDMultiRef{edges.spans_in1.get_spans(), edges.spans_in2.get_spans()},
43 sham::DDMultiRef{edges.spans_out.get_spans()},
44 val_cnts,
45 [](u32 i, const T *__restrict in1, const T *__restrict in2, T *__restrict out) {
46 out[i] = in1[i] * in2[i];
47 });
48 }
49
50 template<class T>
52 std::string tex = R"tex(
53 Hadamard (elementwise) product
54 \begin{equation}
55 {spans_out}_i = {spans_in1}_i \, {spans_in2}_i
56 \end{equation}
57 )tex";
58
59 replace_edges_tex_symbols(tex);
60
61 return tex;
62 }
63
64} // namespace shamrock::solvergraph
65
Node computing the elementwise (Hadamard) product of two 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 out <- in1 * in2 (elementwise) on every value of every patch.
void _impl_evaluate_internal()
evaluate the node
virtual std::string _impl_get_tex() const
get the tex of the node
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.