Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
AnalysisDisc.hpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
10#pragma once
11
23#include "shambackends/vec.hpp"
27#include <shambackends/sycl.hpp>
28
30
31 template<class Tvec, template<class> class SPHKernel>
33 public:
34 using Tscal = shambase::VecComponent<Tvec>;
36 using Kernel = SPHKernel<Tscal>;
37
40
41 ShamrockCtx &context;
42 Config &solver_config;
43 Storage &storage;
44
45 AnalysisDisc(ShamrockCtx &context, Config &solver_config, Storage &storage)
46 : context(context), solver_config(solver_config), storage(storage) {}
47
49 u32 mybin(Tscal radius, const Tscal *__restrict bin_edges, u32 Nbin) {
50 u32 bini = 0;
51 for (u32 bini = 0; bini < Nbin; bini++) {
52 if (radius >= bin_edges[bini] && radius < bin_edges[bini + 1]) {
53 break;
54 }
55 }
56 return bini;
57 }
58
71
73 sham::DeviceBuffer<Tscal> buf_radius; // all radius for all particles
75 sham::DeviceBuffer<Tscal> radius; // binned radius
81 };
82
90
96
97 analysis_basis compute_analysis_basis(
98 Tscal pmass, Tscal Rmin, Tscal Rmax, u32 Nbin, const ShamrockCtx &ctx);
99 analysis_stage0 compute_analysis_stage0(analysis_basis &basis, u32 Nbin);
100 analysis_stage1 compute_analysis_stage1(
101 analysis_basis &basis, analysis_stage0 &stage0, u32 Nbin);
102
103 analysis compute_analysis(Tscal Rmin, Tscal Rmax, u32 Nbin, const ShamrockCtx &ctx);
104
105 private:
106 inline PatchScheduler &scheduler() { return shambase::get_check_ref(context.sched); }
107 };
108
109} // namespace shammodels::sph::modules
std::uint32_t u32
32 bit unsigned integer
The MPI scheduler.
A buffer allocated in USM (Unified Shared Memory)
u32 mybin(Tscal radius, const Tscal *__restrict bin_edges, u32 Nbin)
TODO: make this a dichotomic search.
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...
Definition memory.hpp:110
namespace for the sph model modules
The configuration for a sph solver.