Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
ComputeCFLDivBCleaning.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::ScalarEdge<Tscal>, C_cour) \
29 X_RO(shamrock::solvergraph::IFieldSpan<Tscal>, hpart) \
30 X_RO(shamrock::solvergraph::IFieldSpan<Tscal>, vclean) \
31 X_RW(shamrock::solvergraph::IFieldSpan<Tscal>, cfl_dt)
32
33template<class Tscal>
34class ComputeCFLDivBCleaning : public shamrock::solvergraph::INode {
35
36 public:
37 ComputeCFLDivBCleaning() {}
38
39 EXPAND_NODE_EDGES(NODE_EDGES)
40
42 auto edges = get_edges();
43
44 auto dev_sched = shamsys::instance::get_compute_scheduler_ptr();
45
46 Tscal C_cour = edges.C_cour.value;
47
49 dev_sched,
50 sham::DDMultiRef{edges.hpart.get_spans(), edges.vclean.get_spans()},
51 sham::DDMultiRef{edges.cfl_dt.get_spans()},
52 edges.part_counts.indexes,
53 [C_cour](u32 id_a, const Tscal *hpart, const Tscal *vclean, Tscal *cfl_dt) {
54 Tscal h_a = hpart[id_a];
55 Tscal vclean_a = vclean[id_a];
56
57 Tscal dt_divB_cleaning = C_cour * h_a / vclean_a;
58
59 cfl_dt[id_a] = sycl::min(cfl_dt[id_a], dt_divB_cleaning);
60 });
61 }
62
63 inline virtual std::string _impl_get_label() const { return "ComputeCFLDivBCleaning"; };
64
65 inline virtual std::string _impl_get_tex() const { return "C_{divB_cleaning}"; };
66};
67
68#undef NODE_EDGES
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
void _impl_evaluate_internal()
evaluate 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.
A variant of sham::MultiRef for distributed data.