Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
ModifierOffset.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
21
22template<class Tvec>
24
25 ShamrockCtx &ctx = context;
26 PatchScheduler &sched = shambase::get_check_ref(ctx.sched);
27 shamrock::patch::PatchDataLayer tmp = parent->next_n(nmax);
28
29 // No objects to offset
30 if (tmp.get_obj_cnt() == 0) {
31 return tmp;
32 }
33
35 = tmp.get_field_buf_ref<Tvec>(sched.pdl_old().get_field_idx<Tvec>("xyz"));
37 = tmp.get_field_buf_ref<Tvec>(sched.pdl_old().get_field_idx<Tvec>("vxyz"));
38
39 auto &q = shamsys::instance::get_compute_scheduler().get_queue();
40
41 Tvec positional_offset = this->positional_offset;
42 Tvec velocity_offset = this->velocity_offset;
43
45 q,
47 sham::MultiRef{buf_xyz, buf_vxyz},
48 tmp.get_obj_cnt(),
49 [positional_offset,
50 velocity_offset](u32 i, Tvec *__restrict__ xyz_a, Tvec *__restrict__ vxyz_a) {
51 xyz_a[i] += positional_offset;
52 vxyz_a[i] += velocity_offset;
53 });
54
55 return tmp;
56}
57
58using namespace shammath;
std::uint32_t u32
32 bit unsigned integer
The MPI scheduler.
A buffer allocated in USM (Unified Shared Memory)
DeviceQueue & get_queue(u32 id=0)
Get a reference to a DeviceQueue.
shamrock::patch::PatchDataLayer next_n(u32 nmax)
This function generate patchdata with at most nmax per MPI ranks This function is always assumed as c...
u32 get_field_idx(const std::string &field_name) const
Get the field id if matching name & type.
PatchDataLayer container class, the layout is described in patchdata_layout.
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 & 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
A class that references multiple buffers or similar objects.