54 using Tscal = shambase::VecComponent<Tvec>;
55 using Kernel = SPHKernel<Tscal>;
56 static constexpr Tscal Rkern = Kernel::Rkern;
57 static constexpr Tscal Rker2 = Rkern * Rkern;
62 inline void operator()(
65 const Tvec *__restrict xyz,
66 const Tscal *__restrict hpart,
67 const Tvec *__restrict vxyz,
68 const Tscal *__restrict omega,
69 const Tscal *__restrict pressure,
70 const Tscal *__restrict s_j,
71 const Tscal *__restrict Ttilde_sj,
74 Tscal *__restrict ds_j_dt)
const {
76 u32 id_a = thread_id / ndust;
77 u32 jdust = thread_id % ndust;
79 Tscal h_a = hpart[id_a];
80 Tvec xyz_a = xyz[id_a];
81 Tvec vxyz_a = vxyz[id_a];
82 Tscal P_a = pressure[id_a];
83 Tscal omega_a = omega[id_a];
84 Tscal s_j_a = s_j[thread_id];
85 Tscal Ttilde_sj_a = Ttilde_sj[thread_id];
87 using namespace shamrock::sph;
88 Tscal rho_a = rho_h(pmass, h_a, Kernel::hfactd);
94 particle_looper.for_each_object(id_a, [&](
u32 id_b) {
95 Tvec dr = xyz_a - xyz[id_b];
96 Tscal rab2 = sycl::dot(dr, dr);
97 Tscal h_b = hpart[id_b];
99 if (rab2 > h_a * h_a * Rker2 && rab2 > h_b * h_b * Rker2) {
103 Tvec vxyz_b = vxyz[id_b];
104 Tscal P_b = pressure[id_b];
105 Tscal s_j_b = s_j[id_b * ndust + jdust];
106 Tscal Ttilde_sj_b = Ttilde_sj[id_b * ndust + jdust];
108 Tscal rab = sycl::sqrt(rab2);
111 Tscal rho_b = rho_h(pmass, h_b, Kernel::hfactd);
113 Tscal Fab_a = Kernel::dW_3d(rab, h_a);
114 Tscal Fab_b = Kernel::dW_3d(rab, h_b);
116 Tvec v_ab = vxyz_a - vxyz_b;
118 Tvec r_ab_unit = dr * rab_inv_sat;
120 Tscal F_ab_bar = (Fab_a + Fab_b) / 2;
121 Tscal delta_P = P_a - P_b;
122 Tscal Ts_weighted = (Ttilde_sj_a / rho_a + Ttilde_sj_b / rho_b);
124 Tscal g_ab = Ts_weighted * delta_P * F_ab_bar * rab_inv_sat;
126 if constexpr (pair_gate) {
128 term1 += gate * (pmass * s_j_b / rho_b) * g_ab;
130 term1 += (pmass * s_j_b / rho_b) * g_ab;
132 term2 += pmass * sham::dot(v_ab, r_ab_unit * Fab_a);
136 ds_j_dt[thread_id] = Tscal{-0.5} * term1 + (s_j_a / (2 * rho_a * omega_a)) * term2;
146 auto edges = get_edges();
148 auto &part_counts_with_ghost = edges.part_counts_with_ghost.indexes;
149 auto &part_counts = edges.part_counts.indexes;
152 edges.xyz.check_sizes(part_counts_with_ghost);
153 edges.hpart.check_sizes(part_counts_with_ghost);
154 edges.vxyz.check_sizes(part_counts_with_ghost);
155 edges.omega.check_sizes(part_counts_with_ghost);
156 edges.pressure.check_sizes(part_counts_with_ghost);
157 edges.s_j.check_sizes(part_counts_with_ghost);
158 edges.Ttilde_sj.check_sizes(part_counts_with_ghost);
161 edges.ds_j_dt.ensure_sizes(part_counts);
163 const Tscal pmass = edges.gpart_mass.data;
165 auto total_specie_count = part_counts.template map<u32>([&](
u64 id,
u32 count) {
166 return count * ndust;
169 auto launch = [&](
auto kernel) {
172 shamsys::instance::get_compute_scheduler_ptr(),
174 edges.xyz.get_spans(),
175 edges.hpart.get_spans(),
176 edges.vxyz.get_spans(),
177 edges.omega.get_spans(),
178 edges.pressure.get_spans(),
179 edges.s_j.get_spans(),
180 edges.Ttilde_sj.get_spans(),
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.