31 auto edges = get_edges();
33 auto &thread_counts = edges.sizes.indexes;
35 edges.neigh_cache.check_sizes(thread_counts);
36 edges.positions.check_sizes(thread_counts);
37 edges.old_h.check_sizes(thread_counts);
38 edges.new_h.check_sizes(thread_counts);
39 edges.eps_h.check_sizes(thread_counts);
41 auto &neigh_cache = edges.neigh_cache.neigh_cache;
42 auto &positions = edges.positions.get_spans();
43 auto &old_h = edges.old_h.get_spans();
44 auto &new_h = edges.new_h.get_spans();
45 auto &eps_h = edges.eps_h.get_spans();
47 auto dev_sched = shamsys::instance::get_compute_scheduler_ptr();
49 static constexpr Tscal Rkern = SPHKernel::Rkern;
56 [gpart_mass = this->gpart_mass,
57 h_evol_max = this->h_evol_max,
58 h_evol_iter_max = this->h_evol_iter_max](
61 const Tvec *__restrict r,
62 const Tscal *__restrict h_old,
63 Tscal *__restrict h_new,
64 Tscal *__restrict eps) {
68 Tscal part_mass = gpart_mass;
69 Tscal h_max_tot_max_evol = h_evol_max;
70 Tscal h_max_evol_p = h_evol_iter_max;
71 Tscal h_max_evol_m = 1 / h_evol_iter_max;
74 if (eps[id_a] > 1e-6) {
78 Tscal h_a = h_new[id_a];
79 Tscal dint = h_a * h_a * Rkern * Rkern;
84 particle_looper.for_each_object(id_a, [&](
u32 id_b) {
85 Tvec dr = xyz_a - r[id_b];
86 Tscal rab2 = sycl::dot(dr, dr);
92 Tscal rab = sycl::sqrt(rab2);
94 rho_sum += part_mass * SPHKernel::W_3d(rab, h_a);
95 sumdWdh += part_mass * SPHKernel::dhW_3d(rab, h_a);
98 using namespace shamrock::sph;
100 Tscal rho_ha = rho_h(part_mass, h_a, SPHKernel::hfactd);
101 Tscal new_h = newton_iterate_new_h(rho_ha, rho_sum, sumdWdh, h_a);
103 if (new_h < h_a * h_max_evol_m)
104 new_h = h_max_evol_m * h_a;
105 if (new_h > h_a * h_max_evol_p)
106 new_h = h_max_evol_p * h_a;
108 Tscal ha_0 = h_old[id_a];
110 if (new_h < ha_0 * h_max_tot_max_evol) {
112 eps[id_a] = sycl::fabs(new_h - h_a) / ha_0;
114 h_new[id_a] = ha_0 * h_max_tot_max_evol;
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.