Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
sphpatch.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
20// #include "shamrock/legacy/patch/patchdata_buffer.hpp"
23#include <type_traits>
24#include <stdexcept>
25
26namespace patchdata {
27 namespace sph {
28
29 template<class htype>
30 inline htype get_h_max(
32 sycl::queue &queue,
34
35 if (pdat.get_obj_cnt() == 0)
36 return 0;
37
38 htype tmp;
39
40 u32 nobj = pdat.get_obj_cnt();
41
42 if constexpr (std::is_same<htype, f32>::value) {
43
44 u32 ihpart = pdl.get_field_idx<f32>("hpart");
45 tmp = syclalg::get_max<f32>(pdat.get_field<f32>(ihpart).get_buf(), nobj);
46
47 } else if constexpr (std::is_same<htype, f64>::value) {
48 u32 ihpart = pdl.get_field_idx<f64>("hpart");
49 tmp = syclalg::get_max<f64>(pdat.get_field<f64>(ihpart).get_buf(), nobj);
50
51 } else {
53 "get_h_max -> current htype not handled");
54 }
55
56 return tmp;
57 }
58
59#if false
60
61 template<class htype>
62 [[deprecated]]
63 inline htype get_h_max(PatchDataLayerLayout & pdl,sycl::queue & queue, PatchDataBuffer & pdatbuf){
64
65 if(pdatbuf.element_count == 0) return 0;
66
67 htype tmp;
68
69
70 u32 & nobj = pdatbuf.element_count;
71
72 if constexpr (std::is_same<htype, f32>::value){
73
74 u32 ihpart = pdl.get_field_idx<f32>(::sph::field_names::field_hpart);
75 tmp = syclalg::get_max<f32>(queue, pdatbuf.fields_f32[ihpart],nobj);
76
77 } else if constexpr (std::is_same<htype, f64>::value){
78 u32 ihpart = pdl.get_field_idx<f64>(::sph::field_names::field_hpart);
79 tmp = syclalg::get_max<f64>(queue, pdatbuf.fields_f64[ihpart],nobj);
80
81 }else{
82 throw shamrock_exc("get_h_max -> current htype not handled");
83 }
84
85 return tmp;
86
87 }
88
89
90
91 template<class vec>
92 [[deprecated]]
93 inline std::tuple<vec,vec> get_patchdata_BBAA(sycl::queue & queue,PatchDataBuffer & pdatbuf);
94
95 template<>
96 inline std::tuple<f32_3,f32_3> get_patchdata_BBAA(sycl::queue & queue,PatchDataBuffer & pdatbuf){
97
98 u32 ihpart = pdatbuf.pdl.get_field_idx<f32_3>("xyz");
99 return syclalg::get_min_max<f32_3>(queue, pdatbuf.fields_f32_3[ihpart],pdatbuf.element_count);
100
101 }
102
103 template<>
104 inline std::tuple<f64_3,f64_3> get_patchdata_BBAA(sycl::queue & queue,PatchDataBuffer & pdatbuf){
105 u32 ihpart = pdatbuf.pdl.get_field_idx<f64_3>("xyz");
106 return syclalg::get_min_max<f64_3>(queue, pdatbuf.fields_f64_3[ihpart],pdatbuf.element_count);
107
108 }
109
110#endif
111
112 } // namespace sph
113} // namespace patchdata
double f64
Alias for double.
float f32
Alias for float.
std::uint32_t u32
32 bit unsigned integer
u32 get_field_idx(const std::string &field_name) const
Get the field id if matching name & type.
PatchDataLayer container class, the layout is described in patchdata_layout.
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
header for PatchData related function and declaration