summaryrefslogtreecommitdiff
path: root/lib/core/c++/particle/particle.hpp
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2026-04-22 16:49:30 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2026-04-22 16:49:30 +0200
commit1aee54ea763a19590f4aa41f991cef8f91cf6a93 (patch)
tree7e45e43e9152520d97f991d62dd86362c27cd054 /lib/core/c++/particle/particle.hpp
parent0f0af5c3e095637c7ede1c8dc20b248a3471dc3a (diff)
parent45ebf7411d687ab5530431ab1bcc74edb0499c69 (diff)
downloadlibs-lbm-1aee54ea763a19590f4aa41f991cef8f91cf6a93.tar.gz
Merge branch 'dev'
Diffstat (limited to 'lib/core/c++/particle/particle.hpp')
-rw-r--r--lib/core/c++/particle/particle.hpp35
1 files changed, 9 insertions, 26 deletions
diff --git a/lib/core/c++/particle/particle.hpp b/lib/core/c++/particle/particle.hpp
index c0d115f..7af43dc 100644
--- a/lib/core/c++/particle/particle.hpp
+++ b/lib/core/c++/particle/particle.hpp
@@ -40,9 +40,8 @@ using ParticleRigidBody = Struct<
Member<typename impl::rotation_type_helper<T,D>::Schema, "angular_acceleration">
>;
-template<typename T>
+template<typename T, typename saw::native_data_type<T>::type radius = 1.0f>
using ParticleCollisionSpheroid = Struct<
- Member<Scalar<T>, "radius">
>;
template<typename T, uint64_t D>
@@ -52,42 +51,26 @@ using Particle = Struct<
// Member<Array<Float64,D>, "mask">,
>;
-template<typename T, uint64_t D, typename CollisionType = ParticleCollisionSpheroid<T>>
+template<typename T, uint64_t D, typename CollisionType = ParticleCollisionSpheroid<T,2.0f>>
using ParticleGroup = Struct<
Member<Array<T,D>, "mask">,
- Member<CollisionType, "collision">,
- Member<Scalar<T>, "mass">,
+ Member<FixedArray<Scalar<T>,1u>, "density">,
Member<Array<Particle<T,D>>, "particles">
>;
}
-template<typename T, uint64_t D>
-saw::data<sch::ParticleGroup<T,D, sch::ParticleCollisionSpheroid<T>>> create_spheroid_particle_group(
- saw::data<sch::Scalar<T>> rad_p,
+template<typename T, uint64_t D, typename saw::native_data_type<T>::type radius>
+saw::data<sch::ParticleGroup<T,D, sch::ParticleCollisionSpheroid<T,radius>>> create_spheroid_particle_group(
saw::data<sch::Scalar<T>> density_p,
const saw::data<sch::UInt64>& mask_resolution
){
- saw::data<sch::ParticleGroup<T,D,sch::ParticleCollisionSpheroid<T>>> part;
+ saw::data<sch::ParticleGroup<T,D,sch::ParticleCollisionSpheroid<T,2.0f>>> part;
auto& mask = part.template get<"mask">();
- auto& collision = part.template get<"collision">();
- auto& mass = part.template get<"mass">();
+ auto& density = part.template get<"density">().at({{0u}});
- if constexpr ( D == 1u ){
- saw::data<sch::Scalar<T>> c;
- c.at({}).set(2.0);
- mass = rad_p * c * density_p;
- } else if constexpr ( D == 2u){
- saw::data<sch::Scalar<T>> pi;
- pi.at({}).set(3.14159);
- mass = rad_p * rad_p * pi * density_p;
- } else if constexpr ( D == 3u ){
- saw::data<sch::Scalar<T>> c;
- c.at({}).set(3.14159 * 4.0 / 3.0);
- mass = rad_p * rad_p * rad_p * c * density_p;
- } else {
- static_assert(D == 0u or D > 3u, "Dimensions only supported for Dim 1,2 & 3.");
- }
+ static_assert(D >= 1u and D <= 3u, "Dimensions only supported for Dim 1,2 & 3.");
+ density = density_p;
saw::data<sch::FixedArray<sch::UInt64,D>> mask_dims;
for(uint64_t i = 0u; i < D; ++i){