Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
GridRender.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
21#include "shambackends/vec.hpp"
25
26namespace shammodels::ramses::modules {
27
28 template<class Tvec, class TgridVec, class Tfield>
29 class GridRender {
30 public:
31 using Tscal = shambase::VecComponent<Tvec>;
33
36
37 ShamrockCtx &context;
38 Config &solver_config;
39 Storage &storage;
40
41 GridRender(ShamrockCtx &context, Config &solver_config, Storage &storage)
42 : context(context), solver_config(solver_config), storage(storage) {}
43
44 using field_getter_t = const sham::DeviceBuffer<Tfield> &(
46
47 sham::DeviceBuffer<Tfield> compute_slice(
48 std::function<field_getter_t> field_getter, const sham::DeviceBuffer<Tvec> &positions);
49
50 sham::DeviceBuffer<Tfield> compute_slice(
51 std::string field_name, const sham::DeviceBuffer<Tvec> &positions);
52
53 inline sham::DeviceBuffer<Tfield> compute_slice(
54 std::string field_name, const std::vector<Tvec> &positions) {
55 sham::DeviceBuffer<Tvec> positions_buf{
56 positions.size(), shamsys::instance::get_compute_scheduler_ptr()};
57 positions_buf.copy_from_stdvec(positions);
58 return compute_slice(field_name, positions_buf);
59 }
60
61 private:
62 inline PatchScheduler &scheduler() { return shambase::get_check_ref(context.sched); }
63 };
64
65} // namespace shammodels::ramses::modules
std::uint32_t u32
32 bit unsigned integer
The MPI scheduler.
A buffer allocated in USM (Unified Shared Memory)
PatchDataLayer container class, the layout is described in patchdata_layout.
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
Patch object that contain generic patch information.
Definition Patch.hpp:33