Shamrock
2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
shammodels
sph
src
modules
GetParticlesOutsideSphere.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
18
#include "
shambase/stacktrace.hpp
"
19
#include "
shambase/string.hpp
"
20
#include "
shammodels/sph/modules/GetParticlesOutsideSphere.hpp
"
21
22
namespace
shammodels::sph::modules
{
23
24
template
<
typename
Tvec>
25
void
GetParticlesOutsideSphere<Tvec>::_impl_evaluate_internal
() {
26
StackEntry
stack_loc{};
27
auto
edges = get_edges();
28
29
const
shamrock::solvergraph::DDPatchDataFieldRef<Tvec>
&pos_refs = edges.pos.get_refs();
30
31
edges.part_ids_outside_sphere.ensure_allocated(pos_refs.
get_ids
());
32
33
pos_refs.
for_each
([&](
u64
id_patch,
const
PatchDataField<Tvec>
&pos) {
34
auto
tmp = pos.
get_ids_where
(
35
[](
const
Tvec *__restrict pos,
u32
i, Tvec sphere_center, Tscal sphere_radius) {
36
return
sycl::length(pos[i] - sphere_center) > sphere_radius;
37
},
38
sphere_center,
39
sphere_radius);
40
41
edges.part_ids_outside_sphere.buffers.get(id_patch).
append
(tmp);
42
});
43
}
44
45
template
<
typename
Tvec>
46
std::string
GetParticlesOutsideSphere<Tvec>::_impl_get_tex
()
const
{
47
auto
pos = get_ro_edge_base(0).get_tex_symbol();
48
auto
part_ids_outside_sphere = get_rw_edge_base(0).get_tex_symbol();
49
50
std::string tex = R
"tex(
51
Get particles outside of the sphere
52
53
\begin{align}
54
{part_ids_outside_sphere} &= \{i \text{ where } \vert\vert{pos}_i - c\vert\vert > r\}\\
55
c &= {center}\\
56
r &= {radius}
57
\end{align}
58
)tex";
59
60
shambase::replace_all
(tex,
"{pos}"
, pos);
61
shambase::replace_all
(tex,
"{part_ids_outside_sphere}"
, part_ids_outside_sphere);
62
shambase::replace_all
(tex,
"{center}"
, shambase::format(
"{}"
, sphere_center));
63
shambase::replace_all
(tex,
"{radius}"
, shambase::format(
"{}"
, sphere_radius));
64
65
return
tex;
66
}
67
68
}
// namespace shammodels::sph::modules
69
70
template
class
shammodels::sph::modules::GetParticlesOutsideSphere<f64_3>
;
GetParticlesOutsideSphere.hpp
Declares the GetParticlesOutsideSphere module for removing particles.
u32
std::uint32_t u32
32 bit unsigned integer
Definition
aliases_int.hpp:27
u64
std::uint64_t u64
64 bit unsigned integer
Definition
aliases_int.hpp:26
PatchDataField
Definition
PatchDataField.hpp:43
PatchDataField::get_ids_where
sham::DeviceBuffer< u32 > get_ids_where(Lambdacd &&cd_true, Args... args) const
Same function as.
Definition
PatchDataField.hpp:405
sham::DeviceBuffer::append
void append(const DeviceBuffer &other)
Append the content of another buffer to this one.
Definition
DeviceBuffer.hpp:1223
shambase::DistributedData
Represents a collection of objects distributed across patches identified by a u64 id.
Definition
DistributedData.hpp:43
shambase::DistributedData::get_ids
std::vector< u64 > get_ids() const
Returns a vector of all the ids of the objects in the collection.
Definition
DistributedData.hpp:111
shambase::DistributedData::for_each
void for_each(std::function< void(u64, T &)> &&f)
Applies a function to each object in the collection.
Definition
DistributedData.hpp:93
shammodels::sph::modules::GetParticlesOutsideSphere
Definition
GetParticlesOutsideSphere.hpp:27
shammodels::sph::modules::GetParticlesOutsideSphere::_impl_get_tex
virtual std::string _impl_get_tex() const
get the tex of the node
Definition
GetParticlesOutsideSphere.cpp:46
shammodels::sph::modules::GetParticlesOutsideSphere::_impl_evaluate_internal
void _impl_evaluate_internal()
evaluate the node
Definition
GetParticlesOutsideSphere.cpp:25
shambase::replace_all
void replace_all(std::string &inout, std::string_view what, std::string_view with)
replace all occurence of a search string with another
Definition
string.hpp:183
shammodels::sph::modules
namespace for the sph model modules
Definition
AnalysisAngularMomentum.hpp:28
stacktrace.hpp
This file contains the definition for the stacktrace related functionality.
string.hpp
shambase::details::BasicStackEntry
Definition
stacktrace.hpp:106
Generated on Wed May 13 2026 13:21:49 for Shamrock by
1.9.8