Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
CartesianRender.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#include <pybind11/numpy.h>
26#include <pybind11/pytypes.h>
27
29
30 template<class Tvec, class Tfield, template<class> class SPHKernel>
32 public:
33 using Tscal = shambase::VecComponent<Tvec>;
35 using Kernel = SPHKernel<Tscal>;
36
39
40 ShamrockCtx &context;
41 Config &solver_config;
42 Storage &storage;
43
44 CartesianRender(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 sham::DeviceBuffer<Tfield> compute_slice(
51 std::function<field_getter_t> field_getter, const sham::DeviceBuffer<Tvec> &positions);
52
53 sham::DeviceBuffer<Tfield> compute_column_integ(
54 std::function<field_getter_t> field_getter,
56
57 sham::DeviceBuffer<Tfield> compute_azymuthal_integ(
58 std::function<field_getter_t> field_getter,
60
61 sham::DeviceBuffer<Tfield> compute_slice(
62 std::string field_name,
63 const sham::DeviceBuffer<Tvec> &positions,
64 std::optional<std::function<pybind11::array_t<Tfield>(size_t, pybind11::dict &)>>
65 custom_getter);
66
67 sham::DeviceBuffer<Tfield> compute_column_integ(
68 std::string field_name,
70 std::optional<std::function<pybind11::array_t<Tfield>(size_t, pybind11::dict &)>>
71 custom_getter);
72
73 sham::DeviceBuffer<Tfield> compute_azymuthal_integ(
74 std::string field_name,
76 std::optional<std::function<pybind11::array_t<Tfield>(size_t, pybind11::dict &)>>
77 custom_getter);
78
79 sham::DeviceBuffer<Tfield> compute_slice(
80 std::function<field_getter_t> field_getter,
81 Tvec center,
82 Tvec delta_x,
83 Tvec delta_y,
84 u32 nx,
85 u32 ny);
86
87 sham::DeviceBuffer<Tfield> compute_column_integ(
88 std::function<field_getter_t> field_getter,
89 Tvec center,
90 Tvec delta_x,
91 Tvec delta_y,
92 u32 nx,
93 u32 ny);
94
95 sham::DeviceBuffer<Tfield> compute_slice(
96 std::string field_name,
97 Tvec center,
98 Tvec delta_x,
99 Tvec delta_y,
100 u32 nx,
101 u32 ny,
102 std::optional<std::function<pybind11::array_t<Tfield>(size_t, pybind11::dict &)>>
103 custom_getter);
104
105 sham::DeviceBuffer<Tfield> compute_column_integ(
106 std::string field_name,
107 Tvec center,
108 Tvec delta_x,
109 Tvec delta_y,
110 u32 nx,
111 u32 ny,
112 std::optional<std::function<pybind11::array_t<Tfield>(size_t, pybind11::dict &)>>
113 custom_getter);
114
115 inline sham::DeviceBuffer<Tfield> compute_slice(
116 std::string field_name,
117 const std::vector<Tvec> &positions,
118 std::optional<std::function<pybind11::array_t<Tfield>(size_t, pybind11::dict &)>>
119 custom_getter) {
120 sham::DeviceBuffer<Tvec> positions_buf{
121 positions.size(), shamsys::instance::get_compute_scheduler_ptr()};
122 positions_buf.copy_from_stdvec(positions);
123 return compute_slice(field_name, positions_buf, custom_getter);
124 }
125
126 inline sham::DeviceBuffer<Tfield> compute_column_integ(
127 std::string field_name,
128 const std::vector<shammath::Ray<Tvec>> &rays,
129 std::optional<std::function<pybind11::array_t<Tfield>(size_t, pybind11::dict &)>>
130 custom_getter) {
132 rays.size(), shamsys::instance::get_compute_scheduler_ptr()};
133 rays_buf.copy_from_stdvec(rays);
134 return compute_column_integ(field_name, rays_buf, custom_getter);
135 }
136
137 inline sham::DeviceBuffer<Tfield> compute_azymuthal_integ(
138 std::string field_name,
139 const std::vector<shammath::RingRay<Tvec>> &ring_rays,
140 std::optional<std::function<pybind11::array_t<Tfield>(size_t, pybind11::dict &)>>
141 custom_getter) {
143 ring_rays.size(), shamsys::instance::get_compute_scheduler_ptr()};
144 ring_rays_buf.copy_from_stdvec(ring_rays);
145 return compute_azymuthal_integ(field_name, ring_rays_buf, custom_getter);
146 }
147
148 private:
149 inline PatchScheduler &scheduler() { return shambase::get_check_ref(context.sched); }
150 };
151
152} // namespace shammodels::sph::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
namespace for the sph model modules
Ray representation for intersection testing.
Definition AABB.hpp:34
Ring ray representation for intersection testing.
Definition AABB.hpp:67
The configuration for a sph solver.
Patch object that contain generic patch information.
Definition Patch.hpp:33