Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
ComputeOmega.cpp
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
24
25template<class Tvec, template<class> class SPHKernel>
27
29
30 auto edges = get_edges();
31
32 auto dev_sched = shamsys::instance::get_compute_scheduler_ptr();
33
34 edges.omega.ensure_sizes(edges.part_counts.indexes);
35
37 dev_sched,
39 edges.xyz.get_spans(), edges.hpart.get_spans(), edges.neigh_cache.neigh_cache},
40 sham::DDMultiRef{edges.omega.get_spans()},
41 edges.part_counts.indexes,
42 [part_mass = this->part_mass, Rkern = kernel_radius](
43 u32 id_a, const Tvec *r, const Tscal *hpart, const auto ploop_ptrs, Tscal *omega) {
44 shamrock::tree::ObjectCacheIterator particle_looper(ploop_ptrs);
45
46 Tvec xyz_a = r[id_a]; // could be recovered from lambda
47
48 Tscal h_a = hpart[id_a];
49 Tscal dint = h_a * h_a * Rkern * Rkern;
50
51 Tscal rho_sum = 0;
52 Tscal part_omega_sum = 0;
53
54 particle_looper.for_each_object(id_a, [&](u32 id_b) {
55 Tvec dr = xyz_a - r[id_b];
56 Tscal rab2 = sycl::dot(dr, dr);
57
58 if (rab2 > dint) {
59 return;
60 }
61
62 Tscal rab = sycl::sqrt(rab2);
63
64 rho_sum += part_mass * SPHKernel<Tscal>::W_3d(rab, h_a);
65 part_omega_sum += part_mass * SPHKernel<Tscal>::dhW_3d(rab, h_a);
66 });
67
68 using namespace shamrock::sph;
69
70 Tscal rho_ha = rho_h(part_mass, h_a, SPHKernel<Tscal>::hfactd);
71 Tscal omega_a = 1 + (h_a / (3 * rho_ha)) * part_omega_sum;
72 omega[id_a] = omega_a;
73 });
74}
75
76template<class Tvec, template<class> class SPHKernel>
80
81template<class T>
84
85 auto edges = get_edges();
86
87 auto dev_sched = shamsys::instance::get_compute_scheduler_ptr();
88
89 edges.mask.check_sizes(edges.part_counts.indexes);
90 edges.field_to_set.ensure_sizes(edges.part_counts.indexes);
91
93 dev_sched,
94 sham::DDMultiRef{edges.mask.get_spans()},
95 sham::DDMultiRef{edges.field_to_set.get_spans()},
96 edges.part_counts.indexes,
97 [val_to_set = this->val_to_set](u32 id, const u32 *mask, T *field_to_set) {
98 if (mask[id] == 1) {
99 field_to_set[id] = val_to_set;
100 }
101 });
102}
103
104template<class T>
106 return "TODO";
107}
108
110
111using namespace shammath;
115
std::uint32_t u32
32 bit unsigned integer
virtual std::string _impl_get_tex() const
get the tex of the node
void _impl_evaluate_internal()
evaluate the node
void _impl_evaluate_internal()
evaluate the node
virtual std::string _impl_get_tex() const
get the tex of the node
void distributed_data_kernel_call(sham::DeviceScheduler_ptr dev_sched, RefIn in, RefOut in_out, const shambase::DistributedData< index_t > &thread_counts, Functor &&func)
A variant of sham::kernel_call for distributed data.
namespace for math utility
Definition AABB.hpp:26
This file contains the definition for the stacktrace related functionality.
#define __shamrock_stack_entry()
Macro to create a stack entry.
A variant of sham::MultiRef for distributed data.