Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
cfl_utils.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 "shamrock/legacy/patch/patchdata_buffer.hpp"
22
23//%Impl status : Good
24
25template<class flt>
27 public:
28 /*
29 template<class LambdaCFL>
30 inline static flt basic_cfl(PatchDataBuffer &pdat_buf,LambdaCFL && lambda_internal){
31
32
33
34 u32 npart_patch = pdat_buf.element_count;
35
36 std::unique_ptr<sycl::buffer<flt>> buf_cfl =
37 std::make_unique<sycl::buffer<flt>>(npart_patch);
38
39 sycl::range<1> range_npart{npart_patch};
40
41 auto ker_reduc_step_mincfl = [&](sycl::handler &cgh) {
42 auto arr = buf_cfl->template get_access<sycl::access::mode::discard_write>(cgh);
43
44 lambda_internal(cgh,*buf_cfl, range_npart);
45 };
46
47 shamsys::instance::get_compute_queue().submit(ker_reduc_step_mincfl);
48
49 flt min_cfl = syclalg::get_min<flt>(shamsys::instance::get_compute_queue(), buf_cfl);
50
51 return min_cfl;
52
53 }
54 */
55
56 template<class LambdaCFL>
57 inline static flt basic_cfl(shamrock::patch::PatchData &pdat, LambdaCFL &&lambda_internal) {
58
59 u32 npart_patch = pdat.get_obj_cnt();
60
61 std::unique_ptr<sycl::buffer<flt>> buf_cfl
62 = std::make_unique<sycl::buffer<flt>>(npart_patch);
63
64 sycl::range<1> range_npart{npart_patch};
65
66 auto ker_reduc_step_mincfl = [&](sycl::handler &cgh) {
67 auto arr = buf_cfl->template get_access<sycl::access::mode::discard_write>(cgh);
68
69 lambda_internal(cgh, *buf_cfl, range_npart);
70 };
71
72 shamsys::instance::get_compute_queue().submit(ker_reduc_step_mincfl);
73
74 flt min_cfl
75 = syclalg::get_min<flt>(shamsys::instance::get_compute_queue(), buf_cfl, npart_patch);
76
77 return min_cfl;
78 }
79};
std::uint32_t u32
32 bit unsigned integer
header for PatchData related function and declaration