Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
RenderFieldGetter.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
18
21#include "shambackends/vec.hpp"
26#include <pybind11/pytypes.h>
27
29
30 template<class Tvec, class Tfield, template<class> class SPHKernel>
31 class RenderFieldGetter {
32 public:
33 using Tscal = shambase::VecComponent<Tvec>;
34 static constexpr u32 dim = shambase::VectorProperties<Tvec>::dimension;
35 using Kernel = SPHKernel<Tscal>;
36
37 using Config = SolverConfig<Tvec, SPHKernel>;
38 using Storage = SolverStorage<Tvec, u32>;
39
40 ShamrockCtx &context;
41 Config &solver_config;
42 Storage &storage;
43
44 RenderFieldGetter(ShamrockCtx &context, Config &solver_config, Storage &storage)
45 : context(context), solver_config(solver_config), storage(storage) {}
46
47 using field_getter_t = const sham::DeviceBuffer<Tfield> &(
49
50 using lamda_runner
51 = std::function<sham::DeviceBuffer<Tfield>(std::function<field_getter_t>)>;
52
54 std::string field_name,
55 std::optional<
56 std::function<py::array_t<Tfield>(size_t, shamrock::PatchDataLazyGetter &)>>
57 custom_getter = std::nullopt);
58
59 sham::DeviceBuffer<Tfield> runner_function(
60 std::string field_name,
61 lamda_runner lambda,
62 std::optional<
63 std::function<py::array_t<Tfield>(size_t, shamrock::PatchDataLazyGetter &)>>
64 custom_getter = std::nullopt);
65
66 private:
67 inline PatchScheduler &scheduler() { return shambase::get_check_ref(context.sched); }
68 };
69
70} // namespace shammodels::sph::modules
std::uint32_t u32
32 bit unsigned integer
The MPI scheduler.
A buffer allocated in USM (Unified Shared Memory).
Lazily fetches a single named field of a patch as a numpy array, on demand.
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:112
namespace for the sph model modules
The configuration for a sph solver.
Patch object that contain generic patch information.
Definition Patch.hpp:33