Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
SPHUtilities.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
24
25namespace shammodels::sph {
26
27 template<class vec, class SPHKernel, class u_morton>
29
30 public:
31 using flt = shambase::VecComponent<vec>;
32
33 static constexpr flt Rkern = SPHKernel::Rkern;
34
38
39 PatchScheduler &sched;
40
41 SPHTreeUtilities(PatchScheduler &sched) : sched(sched) {}
42
43 static void iterate_smoothing_length_tree(
44
45 sycl::buffer<vec> &merged_r,
46 sycl::buffer<flt> &hnew,
47 sycl::buffer<flt> &hold,
48 sycl::buffer<flt> &eps_h,
49 sycl::range<1> update_range,
51
52 flt gpart_mass,
53 flt h_evol_max,
54 flt h_evol_iter_max
55
56 );
57 };
58
64 template<class vec, class SPHKernel>
66 public:
67 using flt = shambase::VecComponent<vec>;
68
69 static constexpr flt Rkern = SPHKernel::Rkern;
70
74
75 PatchScheduler &sched;
76
77 SPHUtilities(PatchScheduler &sched) : sched(sched) {}
78
79 inline InterfBuildCache build_interf_cache(
80 GhostHndl &interf_handle, SerialPatchTree<vec> &sptree, flt h_evol_max) {
81
82 using namespace shamrock::patch;
83
84 const u32 ihpart = sched.pdl_old().template get_field_idx<flt>("hpart");
85
86 PatchField<flt> interactR_patch = sched.map_owned_to_patch_field_simple<flt>(
87 [&](const Patch p, PatchDataLayer &pdat) -> flt {
88 if (!pdat.is_empty()) {
89 return pdat.get_field<flt>(ihpart).compute_max() * h_evol_max * Rkern;
90 } else {
92 }
93 });
94
95 PatchtreeField<flt> interactR_mpi_tree = sptree.make_patch_tree_field(
96 sched,
97 shamsys::instance::get_compute_queue(),
98 interactR_patch,
99 [](flt h0, flt h1, flt h2, flt h3, flt h4, flt h5, flt h6, flt h7) {
100 return sham::max_8points(h0, h1, h2, h3, h4, h5, h6, h7);
101 });
102
103 return interf_handle.make_interface_cache(sptree, interactR_mpi_tree, interactR_patch);
104 }
105
106 static void iterate_smoothing_length_cache(
107
108 sham::DeviceBuffer<vec> &merged_r,
112 sycl::range<1> update_range,
113 shamrock::tree::ObjectCache &neigh_cache,
114
115 flt gpart_mass,
116 flt h_evol_max,
117 flt h_evol_iter_max
118
119 );
120
121 template<class u_morton>
122 static void iterate_smoothing_length_tree(
123
124 sycl::buffer<vec> &merged_r,
125 sycl::buffer<flt> &hnew,
126 sycl::buffer<flt> &hold,
127 sycl::buffer<flt> &eps_h,
128 sycl::range<1> update_range,
130
131 flt gpart_mass,
132 flt h_evol_max,
133 flt h_evol_iter_max
134
135 ) {
137 merged_r,
138 hnew,
139 hold,
140 eps_h,
141 update_range,
142 tree,
143 gpart_mass,
144 h_evol_max,
145 h_evol_iter_max);
146 }
147
148 static void compute_omega(
149 sham::DeviceBuffer<vec> &merged_r,
152 sycl::range<1> part_range,
153 shamrock::tree::ObjectCache &neigh_cache,
154 flt gpart_mass);
155 };
156
157} // namespace shammodels::sph
MPI scheduler.
std::uint32_t u32
32 bit unsigned integer
The MPI scheduler.
The radix tree.
Definition RadixTree.hpp:50
A buffer allocated in USM (Unified Shared Memory)
Container for objects shared between two distributed data elements.
CacheMap make_interface_cache(SerialPatchTree< vec > &sptree, shamrock::patch::PatchtreeField< flt > &int_range_max_tree, shamrock::patch::PatchField< flt > &int_range_max)
utility to generate both the metadata and index tables
handle basic utilities dealing with SPH
PatchDataLayer container class, the layout is described in patchdata_layout.
namespace for the sph model
Patch object that contain generic patch information.
Definition Patch.hpp:33