27#define NODE_EDGES(X_RO, X_RW) \
29 X_RO(shamrock::solvergraph::Indexes<u32>, part_counts) \
32 X_RO(shamrock::solvergraph::IFieldSpan<Tscal>, s_j) \
33 X_RO(shamrock::solvergraph::IFieldSpan<Tscal>, Ttilde_sj) \
36 X_RW(shamrock::solvergraph::IFieldSpan<Tscal>, ds_j_dt)
43 using Tscal = shambase::VecComponent<Tvec>;
48 NodeMonofluidTVASmoothSPositivityLimiter(
u32 ndust) : ndust(ndust) {}
50 EXPAND_NODE_EDGES(NODE_EDGES)
56 auto edges = get_edges();
58 auto &part_counts = edges.part_counts.indexes;
60 edges.ds_j_dt.ensure_sizes(part_counts);
62 auto total_specie_count = part_counts.template map<u32>([&](
u64 id,
u32 count) {
67 shamsys::instance::get_compute_scheduler_ptr(),
72 const Tscal *__restrict s_j,
73 const Tscal *__restrict Ttilde_sj,
74 Tscal *__restrict ds_j_dt) {
75 Tscal s_j_a = s_j[thread_id];
76 Tscal Ttilde_sj_a = Ttilde_sj[thread_id];
77 Tscal ds_j_dt_a = ds_j_dt[thread_id];
80 ds_j_dt_a *= (s_j_a < 0 && ds_j_dt_a < 0) ? 0 : 1;
83 ds_j_dt_a += (s_j_a < 0) ? -s_j_a / (10 * Ttilde_sj_a) : 0;
85 ds_j_dt[thread_id] = ds_j_dt_a;
90 return "NodeMonofluidTVASmoothSPositivityLimiter";
100 std::string tex = R
"tex(
101 NodeMonofluidTVASmoothSPositivityLimiter
103 For gas particle $a$ and dust bin $j$:
106 {ds_j_dt}_{j,a} &\leftarrow
108 0 & {s_j}_{j,a} < 0 \land {ds_j_dt}_{j,a} < 0 \\
109 {ds_j_dt}_{j,a} & \text{otherwise}
111 {ds_j_dt}_{j,a} &\mathrel{+}=
113 -{s_j}_{j,a} / (10\, {Ttilde_sj}_{j,a}) & {s_j}_{j,a} < 0 \\
118 $a \in [0,{part_counts})$, $j \in [0,{ndust})$.
Header file describing a Node Instance.
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 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.
IEdge & get_rw_edge_base(int slot)
Get a reference to a read write edge and cast it to the type IEdge.
const IEdge & get_ro_edge_base(int slot)
Get a reference to a read only edge.
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.
void replace_all(std::string &inout, std::string_view what, std::string_view with)
replace all occurence of a search string with another
namespace for the sph model modules
#define __shamrock_stack_entry()
Macro to create a stack entry.
A variant of sham::MultiRef for distributed data.