Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
PatchField.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
19#include "shambackends/sycl.hpp"
20#include <memory>
21namespace shamrock::patch {
22
23 template<class T>
24 class PatchField {
25 public:
27
28 PatchField(shambase::DistributedData<T> &&field_all) : field_all(field_all) {}
29
30 T &get(u64 id) { return field_all.get(id); }
31 };
32
33 template<class T>
35 public:
36 std::unique_ptr<sycl::buffer<T>> internal_buf;
37
38 inline void reset() { internal_buf.reset(); }
39
40 inline void allocate(u32 size) { internal_buf = std::make_unique<sycl::buffer<T>>(size); }
41 };
42} // namespace shamrock::patch
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
Represents a collection of objects distributed across patches identified by a u64 id.
T & get(u64 id)
Returns a reference to an object in the collection.