32 class AnalysisDustMass {
34 using Tscal = shambase::VecComponent<Tvec>;
35 static constexpr u32 dim = shambase::VectorProperties<Tvec>::dimension;
37 using Solver = Solver<Tvec, SPHKernel>;
39 using Kernel = SPHKernel<Tscal>;
46 : model(model), ctx(model.ctx), solver(model.solver) {};
48 auto get_dust_mass() -> std::vector<Tscal> {
51 auto dev_sched_ptr = shamsys::instance::get_compute_scheduler_ptr();
54 u64 ndust = solver.solver_config.dust_config.get_dust_nvar();
56 const u32 ihpart = sched.pdl_old().template get_field_idx<Tscal>(
"hpart");
57 const u32 is_j = sched.pdl_old().template get_field_idx<Tscal>(
"s_j");
59 Tscal pmass = solver.solver_config.gpart_mass;
61 std::vector<Tscal> dust_mass(ndust, 0.0);
65 sched.for_each_patchdata_nonempty(
67 u32 len = pdat.get_obj_cnt();
69 dust_mass_j_part.
resize(len);
74 for (
u32 jdust = 0; jdust < ndust; jdust++) {
80 [pmass, jdust, ndust](
82 const Tscal *__restrict hpart,
83 const Tscal *__restrict s_j,
84 Tscal *__restrict dust_mass_j_part) {
86 Tscal rho_a = shamrock::sph::rho_h(pmass, h_a, Kernel::hfactd);
87 Tscal s_ja = s_j[i * ndust + jdust];
88 Tscal epsilon_ja = s_ja * s_ja / rho_a;
90 dust_mass_j_part[i] = pmass * epsilon_ja;
98 for (
u32 jdust = 0; jdust < ndust; jdust++) {
99 dust_mass[jdust] = shamalgs::collective::allreduce_sum(dust_mass[jdust]);
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...