30 auto edges = get_edges();
32 auto dev_sched = shamsys::instance::get_compute_scheduler_ptr();
35 auto &sink_positions = edges.sink_positions.data;
36 auto &sink_radii = edges.sink_accr_radii.data;
38 if (sink_positions.size() != sink_radii.size()) {
40 "Sink positions and accretion radii must have the same size");
44 sink_pos = std::make_unique<sham::DeviceBuffer<Tvec>>(sink_positions.size(), dev_sched);
46 if (!sink_accr_radii) {
48 = std::make_unique<sham::DeviceBuffer<Tscal>>(sink_radii.size(), dev_sched);
51 sink_pos->resize(sink_positions.size());
52 sink_accr_radii->resize(sink_radii.size());
54 sink_pos->copy_from_stdvec(sink_positions);
55 sink_accr_radii->copy_from_stdvec(sink_radii);
57 edges.positions.check_sizes(edges.part_counts.indexes);
58 edges.sink_accretion_table.ensure_sizes(edges.part_counts.indexes);
60 auto &pos_spans = edges.positions.get_spans();
61 auto &table_acc_spans = edges.sink_accretion_table.get_spans();
63 u32 sink_count = shambase::narrow_or_throw<u32>(sink_positions.size());
65 edges.part_counts.indexes.for_each([&](
u64 id_patch,
u32 part_count) {
68 sham::MultiRef{pos_spans.get(id_patch), *sink_pos, *sink_accr_radii},
73 const Tvec *__restrict part_pos,
74 const Tvec *__restrict sink_pos,
75 const Tscal *__restrict sink_accr_radii,
76 u32 *__restrict sink_accretion_table) {
77 Tvec r_a = part_pos[id_a];
81 for (
u32 i_sink = 0; i_sink < sink_count; i_sink++) {
82 Tscal acc_radii = sink_accr_radii[i_sink];
83 Tvec d = r_a - sink_pos[i_sink];
85 bool should_accrete = sycl::dot(d, d) <= acc_radii * acc_radii;
92 sink_accretion_table[id_a] = result;
Flag SPH particles inside sink accretion radii into an accretion table.
virtual std::string _impl_get_tex() const
get the tex of the node
void _impl_evaluate_internal()
evaluate the node
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...