Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
ComputeCFLNIMHD.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
18
25
26#define NODE_EDGES(X_RO, X_RW) \
27 X_RO(shamrock::solvergraph::Indexes<u32>, part_counts) \
28 X_RO(shamrock::solvergraph::IDataEdge<Tscal>, C_nimhd) \
29 X_RO(shamrock::solvergraph::IDataEdge<Tscal>, eta_o) \
30 X_RO(shamrock::solvergraph::IDataEdge<Tscal>, eta_ad) \
31 X_RO(shamrock::solvergraph::IDataEdge<Tscal>, eta_h) \
32 X_RO(shamrock::solvergraph::IFieldSpan<Tscal>, hpart) \
33 X_RW(shamrock::solvergraph::IFieldSpan<Tscal>, cfl_dt)
34
35template<class Tvec>
36class ComputeCFLNIMHD : public shamrock::solvergraph::INode {
37
38 using Tscal = shambase::VecComponent<Tvec>;
39
40 public:
41 ComputeCFLNIMHD() {}
42
43 EXPAND_NODE_EDGES(NODE_EDGES)
44
46 auto edges = get_edges();
47
48 auto dev_sched = shamsys::instance::get_compute_scheduler_ptr();
49
50 Tscal C_nimhd = edges.C_nimhd.data;
51 Tscal eta_o = edges.eta_o.data;
52 Tscal eta_ad = edges.eta_ad.data;
53 Tscal eta_h = edges.eta_h.data;
54
56 dev_sched,
57 sham::DDMultiRef{edges.hpart.get_spans()},
58 sham::DDMultiRef{edges.cfl_dt.get_spans()},
59 edges.part_counts.indexes,
60 [C_nimhd, eta_o, eta_ad, eta_h](u32 id_a, const Tscal *hpart, Tscal *cfl_dt) {
61 Tscal h_a = hpart[id_a];
62 Tscal max_eta = sycl::max(
63 sycl::max(sycl::fabs(eta_o), sycl::fabs(eta_ad)), sycl::fabs(eta_h));
64
65 Tscal dt_nimhd = C_nimhd * h_a * h_a / max_eta;
66
67 cfl_dt[id_a] = sycl::min(cfl_dt[id_a], dt_nimhd);
68 });
69 }
70
71 inline virtual std::string _impl_get_label() const { return "ComputeCFLNIMHD"; };
72
73 inline virtual std::string _impl_get_tex() const { return "C_{NIMHD}"; };
74};
75
76#undef NODE_EDGES
Header file describing a Node Instance.
std::uint32_t u32
32 bit unsigned integer
virtual std::string _impl_get_tex() const
get the tex of the node
virtual std::string _impl_get_label() const
get the label of the node
void _impl_evaluate_internal()
evaluate the node
Inode is node between data edges, takes multiple inputs, multiple outputs.
Definition INode.hpp:31
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.