Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
ParticleReordering.cpp
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
20
21template<class Tvec, class Tmorton, template<class> class SPHKernel>
23
24 using namespace shamrock;
25 using namespace shamrock::patch;
26
28 = scheduler().get_sim_box().template get_patch_transform<Tvec>();
29
30 scheduler().for_each_patchdata_nonempty([&](Patch cur_p, PatchDataLayer &pdat) {
31 u32 obj_count = pdat.get_obj_cnt();
32
33 if (obj_count > 0) {
34 PatchDataField<Tvec> &pos_field = pdat.get_field<Tvec>(0);
35
36 shammath::CoordRange<Tvec> box = transf.to_obj_coord(cur_p);
37
39 builder.build(
40 shamsys::instance::get_compute_scheduler_ptr(),
41 box,
42 obj_count,
43 pos_field.get_buf());
44
45 pdat.index_remap(shambase::get_check_ref(builder.buf_particle_index_map), obj_count);
46 }
47 });
48}
49
50using namespace shammath;
54
std::uint32_t u32
32 bit unsigned integer
Module for reordering particles to improve cache locality.
void reorder_particles()
Reorders particles by Morton code for improved memory access patterns.
PatchDataLayer container class, the layout is described in patchdata_layout.
void index_remap(sycl::buffer< u32 > &index_map, u32 len)
this function remaps the patchdatafield like so val[id] = val[index_map[id]] This function can be use...
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 math utility
Definition AABB.hpp:26
namespace for the main framework
Definition __init__.py:1
sph kernels
Patch object that contain generic patch information.
Definition Patch.hpp:33