27#include <experimental/mdspan>
29#define NODE_EDGES(X_RO, X_RW) \
31 X_RO(shamrock::solvergraph::Indexes<u32>, part_counts) \
32 X_RO(shamrock::solvergraph::ScalarEdge<Tscal>, rhodust_eps) \
35 X_RO(shamrock::solvergraph::IFieldSpan<Tscal>, S) \
36 X_RO(shamrock::solvergraph::IFieldSpan<Tscal>, s_j) \
39 X_RW(shamrock::solvergraph::IFieldSpan<Tscal>, ds_j_dt)
46 using Tscal = shambase::VecComponent<Tvec>;
51 NodeMonofluidTVIAddSourceTerm(
u32 nbins) : nbins(nbins) {}
53 EXPAND_NODE_EDGES(NODE_EDGES)
59 auto edges = get_edges();
61 edges.S.check_sizes(edges.part_counts.indexes);
62 edges.s_j.check_sizes(edges.part_counts.indexes);
63 edges.ds_j_dt.check_sizes(edges.part_counts.indexes);
65 auto rhodust_eps = edges.rhodust_eps.value;
68 [nbins = this->nbins](
u64 ,
u32 count) ->
u32 {
73 shamsys::instance::get_compute_scheduler_ptr(),
79 const Tscal *__restrict S,
80 const Tscal *__restrict s_j,
81 Tscal *__restrict ds_j_dt) {
84 Tscal ds_j_dt_val = 0;
86 if (sj * sj > rhodust_eps) {
87 ds_j_dt_val = S[id] / (2 * sham::abs(sj));
92 ds_j_dt_val = S[id] / (2 * (sham::abs(sj) + sycl::sqrt(rhodust_eps)));
95 ds_j_dt[id] += ds_j_dt_val;
100 return "NodeMonofluidTVIAddSourceTerm";
111 std::string tex = R
"tex(
112 Monofluid TVI: dust-density source term $\rightarrow$ ${s_j}$ time derivative
114 Per gas particle $a$ and mass bin $j$ (monofluid: $\rho_{{\rm d},j,a} = {s_j}_{j,a}^2$):
117 \rho_{{\rm d},j,a} &= {s_j}_{j,a}^2 \\
118 {S}_{j,a} &= \text{dust density source term } (\mathrm{d}\rho_{{\rm d},j,a}/\mathrm{d}t) \\
119 \delta_{j,a} &= \begin{cases}
120 {S}_{j,a} / (2 |{s_j}_{j,a}|) & |{s_j}_{j,a}|^2 > \rho_{\rm eps} \\
121 {S}_{j,a} / \bigl(2 (|{s_j}_{j,a}| + \sqrt{\rho_{\rm eps}})\bigr) & \text{otherwise}
123 {ds_j_dt}_{j,a} &\mathrel{+}= \delta_{j,a}
126 Unsaturated: $\mathrm{d}{s_j}_{j,a}^2/\mathrm{d}t = {S}_{j,a}
127 \Rightarrow \mathrm{d}{s_j}_{j,a}/\mathrm{d}t = {S}_{j,a}/(2|{s_j}_{j,a}|)$.
128 The floor ($\sqrt{\rho_{\rm eps}}$ in the denominator) lets bins with $|{s_j}_{j,a}|^2 \le \rho_{\rm eps}$ start accumulating.
130 $a \in [0, {part_counts})$, $j \in [0, N_{\rm bins})$,
131 $\rho_{\rm eps} = {rhodust_eps}$, $N_{\rm bins} = {nbins}$
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.
void _impl_evaluate_internal()
evaluate the node
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
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.