31 using Tscal = shambase::VecComponent<Tvec>;
41 : model(model), ctx(model.ctx), solver(model.solver) {};
43 auto get_kinetic_energy() -> Tscal {
45 auto dev_sched_ptr = shamsys::instance::get_compute_scheduler_ptr();
48 const u32 ivxyz = sched.pdl_old().template get_field_idx<Tvec>(
"vxyz");
49 const Tscal pmass = solver.solver_config.
gpart_mass;
53 sched.for_each_patchdata_nonempty(
55 u32 len = pdat.get_obj_cnt();
65 [pmass](
u32 i,
const Tvec *__restrict vxyz, Tscal *__restrict ekin_part) {
66 ekin_part[i] = Tscal{0.5} * pmass * sham::dot(vxyz[i], vxyz[i]);
72 Tscal tot_ekin = shamalgs::collective::allreduce_sum(ekin);
74 if (!solver.storage.sinks.is_empty()) {
75 for (
auto &sink : solver.storage.sinks.get()) {
76 tot_ekin += Tscal{0.5} * sink.mass * sham::dot(sink.velocity, sink.velocity);
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 sum(const sham::DeviceScheduler_ptr &sched, const sham::DeviceBuffer< T > &buf1, u32 start_id, u32 end_id)
Compute the sum of elements in a device buffer within a specified range.
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...