27 using Tscal = shambase::VecComponent<Tvec>;
28 using Kernel = SPHKernel<Tscal>;
29 static constexpr Tscal hfactd = Kernel::hfactd;
30 static constexpr Tscal Rkern = Kernel::Rkern;
31 static constexpr Tscal Rker2 = Rkern * Rkern;
35 inline void operator()(
37 const Tvec *__restrict xyz,
38 const Tscal *__restrict hpart,
39 const Tscal *__restrict omega,
40 const Tscal *__restrict pressure,
42 Tvec *__restrict grad_P_on_rho)
const {
44 using namespace shamrock::sph;
48 Tvec xyz_a = xyz[id_a];
49 Tscal h_a = hpart[id_a];
50 Tscal omega_a = omega[id_a];
51 Tscal P_a = pressure[id_a];
53 Tscal rho_a = rho_h(pmass, h_a, hfactd);
54 Tscal rho_a_sq = rho_a * rho_a;
55 Tscal rho_a_inv = 1. / rho_a;
57 Tscal omega_a_rho_a_inv = 1 / (omega_a * rho_a);
59 Tvec force_pressure = Tvec{0, 0, 0};
61 particle_looper.for_each_object(id_a, [&](
u32 id_b) {
62 Tvec dr = xyz_a - xyz[id_b];
63 Tscal rab2 = sycl::dot(dr, dr);
64 Tscal h_b = hpart[id_b];
66 if (rab2 > h_a * h_a * Rker2 && rab2 > h_b * h_b * Rker2) {
70 Tscal P_b = pressure[id_b];
71 Tscal omega_b = omega[id_b];
73 Tscal rab = sycl::sqrt(rab2);
75 Tscal rho_b = rho_h(pmass, h_b, hfactd);
77 Tscal Fab_a = Kernel::dW_3d(rab, h_a);
78 Tscal Fab_b = Kernel::dW_3d(rab, h_b);
94 grad_P_on_rho[id_a] = force_pressure;
103 auto edges = get_edges();
105 auto &part_counts_with_ghost = edges.part_counts_with_ghost.indexes;
106 auto &part_counts = edges.part_counts.indexes;
109 edges.xyz.check_sizes(part_counts_with_ghost);
110 edges.hpart.check_sizes(part_counts_with_ghost);
111 edges.omega.check_sizes(part_counts_with_ghost);
112 edges.pressure.check_sizes(part_counts_with_ghost);
115 edges.grad_P_on_rho.ensure_sizes(part_counts);
117 const Tscal pmass = edges.gpart_mass.value;
123 shamsys::instance::get_compute_scheduler_ptr(),
125 edges.xyz.get_spans(),
126 edges.hpart.get_spans(),
127 edges.omega.get_spans(),
128 edges.pressure.get_spans(),
132 ComputeKernel{pmass});
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.
Tvec sph_pressure_symetric(const Tscal &m_b, const Tscal &rho_a_sq, const Tscal &rho_b_sq, const Tscal &P_a, const Tscal &P_b, const Tscal &omega_a, const Tscal &omega_b, const Tvec &nabla_Wab_ha, const Tvec &nabla_Wab_hb)
phantom_2018 eq.34, with