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
17
19#include "shambackends/sycl.hpp"
20#include <memory>
21#include <utility>
22namespace shamrock::patch {
23
24 template<class T>
25 class PatchField {
26 public:
28
29 PatchField(shambase::DistributedData<T> &&field_all) : field_all(std::move(field_all)) {}
30
31 T &get(u64 id) { return field_all.get(id); }
32 const T &get(u64 id) const { return field_all.get(id); }
33 };
34
35 template<class T>
37 public:
38 std::unique_ptr<sycl::buffer<T>> internal_buf;
39
40 inline void reset() { internal_buf.reset(); }
41
42 inline void allocate(u32 size) { internal_buf = std::make_unique<sycl::buffer<T>>(size); }
43 };
44} // 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.