Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
ComputeCFLForce.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_force) \
29 X_RO(shamrock::solvergraph::IFieldSpan<Tscal>, hpart) \
30 X_RO(shamrock::solvergraph::IFieldSpan<Tvec>, axyz) \
31 X_RW(shamrock::solvergraph::IFieldSpan<Tscal>, cfl_dt)
32
33template<class Tvec>
34class ComputeCFLForce : public shamrock::solvergraph::INode {
35
36 using Tscal = shambase::VecComponent<Tvec>;
37
38 public:
39 ComputeCFLForce() {}
40
41 EXPAND_NODE_EDGES(NODE_EDGES)
42
44 auto edges = get_edges();
45
46 auto dev_sched = shamsys::instance::get_compute_scheduler_ptr();
47
48 Tscal C_force = edges.C_force.value;
49
51 dev_sched,
52 sham::DDMultiRef{edges.hpart.get_spans(), edges.axyz.get_spans()},
53 sham::DDMultiRef{edges.cfl_dt.get_spans()},
54 edges.part_counts.indexes,
55 [C_force](u32 id_a, const Tscal *hpart, const Tvec *axyz, Tscal *cfl_dt) {
56 Tscal h_a = hpart[id_a];
57 Tscal abs_a_a = sycl::length(axyz[id_a]);
58
59 Tscal dt_f = C_force * sycl::sqrt(h_a / abs_a_a);
60
61 cfl_dt[id_a] = sycl::min(cfl_dt[id_a], dt_f);
62 });
63 }
64
65 inline virtual std::string _impl_get_label() const { return "ComputeCFLForce"; };
66
67 inline virtual std::string _impl_get_tex() const { return "C_{force}"; };
68};
69
70#undef NODE_EDGES
Header file describing a Node Instance.
std::uint32_t u32
32 bit unsigned integer
void _impl_evaluate_internal()
evaluate the node
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.
A variant of sham::MultiRef for distributed data.