Shamrock
2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
shammodels
sph
include
shammodels
sph
modules
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
20
#include "
shamalgs/details/numeric/numeric.hpp
"
21
#include "
shambackends/Device.hpp
"
22
#include "
shambackends/typeAliasVec.hpp
"
23
#include "
shambackends/vec.hpp
"
24
#include "
shammodels/sph/SolverConfig.hpp
"
25
#include "
shammodels/sph/modules/SolverStorage.hpp
"
26
#include "
shamrock/scheduler/ShamrockCtx.hpp
"
27
#include <
shambackends/sycl.hpp
>
28
29
namespace
shammodels::sph::modules
{
30
31
template
<
class
Tvec,
template
<
class
>
class
SPHKernel>
32
class
AnalysisDisc
{
33
public
:
34
using
Tscal = shambase::VecComponent<Tvec>;
35
static
constexpr
u32
dim =
shambase::VectorProperties<Tvec>::dimension
;
36
using
Kernel = SPHKernel<Tscal>;
37
38
using
Config
=
SolverConfig<Tvec, SPHKernel>
;
39
using
Storage
=
SolverStorage<Tvec, u32>
;
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
59
struct
analysis
{
60
sham::DeviceBuffer<Tscal>
radius;
61
sham::DeviceBuffer<u64>
counter;
62
sham::DeviceBuffer<Tscal>
Sigma;
63
sham::DeviceBuffer<Tscal>
lx;
64
sham::DeviceBuffer<Tscal>
ly;
65
sham::DeviceBuffer<Tscal>
lz;
66
sham::DeviceBuffer<Tscal>
tilt;
67
sham::DeviceBuffer<Tscal>
twist;
68
sham::DeviceBuffer<Tscal>
psi;
69
sham::DeviceBuffer<Tscal>
Hsq;
70
};
71
72
struct
analysis_basis
{
73
sham::DeviceBuffer<Tscal>
buf_radius;
// all radius for all particles
74
sham::DeviceBuffer<Tscal>
bin_edges;
75
sham::DeviceBuffer<Tscal>
radius;
// binned radius
76
sham::DeviceBuffer<u64>
counter;
77
sham::DeviceBuffer<Tscal>
binned_Jx;
78
sham::DeviceBuffer<Tscal>
binned_Jy;
79
sham::DeviceBuffer<Tscal>
binned_Jz;
80
sham::DeviceBuffer<Tscal>
Sigma;
81
};
82
83
struct
analysis_stage0
{
84
sham::DeviceBuffer<Tscal>
lx;
85
sham::DeviceBuffer<Tscal>
ly;
86
sham::DeviceBuffer<Tscal>
lz;
87
sham::DeviceBuffer<Tscal>
zmean;
88
sham::DeviceBuffer<Tscal>
Hsq;
89
};
90
91
struct
analysis_stage1
{
92
sham::DeviceBuffer<Tscal>
tilt;
93
sham::DeviceBuffer<Tscal>
twist;
94
sham::DeviceBuffer<Tscal>
psi;
95
};
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
Device.hpp
ShamrockCtx.hpp
u32
std::uint32_t u32
32 bit unsigned integer
Definition
aliases_int.hpp:27
PatchScheduler
The MPI scheduler.
Definition
PatchScheduler.hpp:85
ShamrockCtx
Definition
ShamrockCtx.hpp:42
sham::DeviceBuffer
A buffer allocated in USM (Unified Shared Memory)
Definition
DeviceBuffer.hpp:106
shammodels::sph::SolverStorage
Definition
SolverStorage.hpp:48
shammodels::sph::modules::AnalysisDisc
Definition
AnalysisDisc.hpp:32
shammodels::sph::modules::AnalysisDisc::mybin
u32 mybin(Tscal radius, const Tscal *__restrict bin_edges, u32 Nbin)
TODO: make this a dichotomic search.
Definition
AnalysisDisc.hpp:49
numeric.hpp
shambase::get_check_ref
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
shammodels::sph::modules
namespace for the sph model modules
Definition
AnalysisAngularMomentum.hpp:28
SolverConfig.hpp
SolverStorage.hpp
sham::VectorProperties
Definition
vec.hpp:25
shammodels::sph::SolverConfig
The configuration for a sph solver.
Definition
SolverConfig.hpp:272
shammodels::sph::modules::AnalysisDisc::analysis_basis
Definition
AnalysisDisc.hpp:72
shammodels::sph::modules::AnalysisDisc::analysis_stage0
Definition
AnalysisDisc.hpp:83
shammodels::sph::modules::AnalysisDisc::analysis_stage1
Definition
AnalysisDisc.hpp:91
shammodels::sph::modules::AnalysisDisc::analysis
Definition
AnalysisDisc.hpp:59
sycl.hpp
typeAliasVec.hpp
vec.hpp
Generated on Wed May 13 2026 13:21:49 for Shamrock by
1.9.8