Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
compute_field.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 "shamrock/legacy/patch/base/patchdata_field.hpp"
21#include <unordered_map>
22#include <memory>
23#include <vector>
24
25template<class T>
27 public:
28
29 public:
30 std::unordered_map<u64, PatchDataField<T>> field_data;
31
32 inline void generate(PatchScheduler &sched) {
33
34 using namespace shamrock::patch;
35 // sched.for_each_patch_buf([&](u64 id_patch, Patch cur_p, PatchDataBuffer & pdat_buf) {
36 // field_data.insert({id_patch,PatchDataField<T>("comp_field",1)});
37 // field_data.at(id_patch).resize(pdat_buf.element_count);
38 // });
39
40 sched.for_each_patch_data([&](u64 id_patch, Patch cur_p, PatchDataLayer &pdat) {
41 field_data.insert({id_patch, PatchDataField<T>("comp_field", 1)});
42 field_data.at(id_patch).resize(pdat.get_obj_cnt());
43 });
44 }
45
46 inline void generate(PatchScheduler &sched, std::unordered_map<u64, u32> &size_map) {
47
48 using namespace shamrock::patch;
49
50 sched.for_each_patch([&](u64 id_patch, Patch cur_p) {
51 field_data.insert({id_patch, PatchDataField<T>("comp_field", 1)});
52 field_data.at(id_patch).resize(size_map[id_patch]);
53 });
54 }
55
56 private:
57 // std::unordered_map<u64, std::unique_ptr<sycl::buffer<T>>> field_data_buf;
58
59 public:
60 inline const std::unique_ptr<sycl::buffer<T>> &get_buf(u64 id_patch) const {
61 return field_data.at(id_patch).get_buf();
62 }
63
64 [[deprecated]]
65 inline std::unique_ptr<sycl::buffer<T>> get_sub_buf(u64 id_patch) {
66 return field_data.at(id_patch).get_sub_buf();
67 }
68
69 inline PatchDataField<T> &get_field(u64 id_patch) { return field_data.at(id_patch); }
70
71 // inline void to_sycl(){
72 // for (auto & [key,dat] : field_data) {
73 // //field_data_buf[key] = dat.get_sub_buf();
74 // }
75 // }
76 //
77 // inline void to_map(){
78 // //field_data_buf.clear();
79 // }
80};
81
82template<class T>
84 public:
85 std::unordered_map<u64, std::vector<std::tuple<u64, std::unique_ptr<PatchDataField<T>>>>>
86 interface_map;
87};
MPI scheduler.
std::uint64_t u64
64 bit unsigned integer
The MPI scheduler.
void for_each_patch_data(Function &&fct)
for each macro for patchadata example usage
PatchDataLayer container class, the layout is described in patchdata_layout.
header for PatchData related function and declaration
Patch object that contain generic patch information.
Definition Patch.hpp:33