27 return parent->next_n(nmax);
30 if (nmax >= n_split && nmax != 0) {
31 nmax = nmax / n_split;
34 using namespace shamrock::patch;
36 auto dev_sched = shamsys::instance::get_compute_scheduler_ptr();
39 u32 npart = original_pdat.get_obj_cnt();
44 std::vector<Tvec> xyz = original_pdat.get_field_buf_ref<Tvec>(ixyz).copy_to_stdvec();
45 std::vector<Tscal> hpart = original_pdat.get_field_buf_ref<Tscal>(ihpart).copy_to_stdvec();
50 for (
u64 i = 0; i < n_split; i++) {
53 std::vector<u64> seeds = generator.next_n(npart);
55 std::vector<Tvec> new_xyz(npart);
57 for (
u64 j = 0; j < npart; j++) {
58 std::mt19937_64 eng(seeds[j]);
59 new_xyz[j] = xyz[j] + hpart[j] * shamalgs::random::mock_gaussian_multidim<Tvec>(eng);
62 tmp_pdat.get_field<Tvec>(ixyz).
override(new_xyz, npart);
63 tmp.insert_elements(tmp_pdat);
67 std::tuple<Tvec, Tvec> box = sched.get_box_volume<Tvec>();
70 auto idx_to_remove = xyz_field.get_ids_where(
71 [bmin = std::get<0>(box), bmax = std::get<1>(box)](
const Tvec *__restrict pos,
u32 i) {
72 return !Patch::is_in_patch_converted(pos[i], bmin, bmax);
74 tmp.
remove_ids(idx_to_remove, idx_to_remove.get_size());
80 Tscal h_scaling_fact = sycl::pow(Tscal(n_split), -1. / 3.) * h_scaling;
84 dev_sched->get_queue(),
88 [h_scaling_fact](
u32 i, Tscal *__restrict hpart) {
89 hpart[i] *= h_scaling_fact;
void kernel_call(sham::DeviceQueue &q, RefIn in, RefOut in_out, u32 n, Functor &&func, SourceLocation &&callsite=SourceLocation{})
Submit a kernel to a SYCL queue.
T & get_check_ref(const std::unique_ptr< T > &ptr, SourceLocation loc=SourceLocation())
Takes a std::unique_ptr and returns a reference to the object it holds. It throws a std::runtime_erro...