diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-06-03 09:58:54 +0200 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-06-03 09:58:54 +0200 |
| commit | 42338efc99190d4f3362ecbc326a740cb7bd0479 (patch) | |
| tree | 13b94bd8cfb17be13b35f7b2539bf03c7ad9592c /lib/core/c++/particle/aabb.hpp | |
| parent | 1c9d05a7cf13b4bd4ebe5583d10cae85d507ea9c (diff) | |
| parent | d7c88d561d4e2b7a2706d14c11ea5fa4cd6ceaf3 (diff) | |
| download | libs-lbm-42338efc99190d4f3362ecbc326a740cb7bd0479.tar.gz | |
Merge branch 'fb-ibm-coupling' into dev
Diffstat (limited to 'lib/core/c++/particle/aabb.hpp')
| -rw-r--r-- | lib/core/c++/particle/aabb.hpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/core/c++/particle/aabb.hpp b/lib/core/c++/particle/aabb.hpp new file mode 100644 index 0000000..aec95ca --- /dev/null +++ b/lib/core/c++/particle/aabb.hpp @@ -0,0 +1,49 @@ +#pragma once + +#include "particle.hpp" + +namespace kel { +namespace lbm { +template<typename T, uint64_t D, typename PColl> +class particle_aabb final { +}; + +template<typename T, uint64_t D, typename saw::native_data_type<T>::type radius> +class particle_aabb<ParticleGroup<T,D,sch::ParticleCollisionSpheroid<T,radius> > > final { +public: + using Schema = sch::ParticleGroup<T,D,sch::ParticleCollisionSpheroid<T,radius>>; + + using AABB = Struct< + Member<sch::FixedArray<sch::UInt64,D>"a">, + Member<sch::FixedArray<sch::UInt64,D>"b"> + >; +public: + static constexpr saw::data<AABB> get(const saw::data<Schema>& p_grp, const saw::data<sch::FixedArray<sch::UInt64,1u>>& i, const saw::data<sch::FixedArray<sch::UInt64,D>>& meta){ + auto& parts = p_grp.template get<"particles">(); + + auto& pi = parts.at(i); + auto& pirb = pi.template get<"rigid_body">(); + auto& pirb_pos = pirb.template get<"position">(); + + saw::data<AABB> aabb; + auto& a = aabb.template get<"a">(); + auto& b = aabb.template get<"b">(); + + saw::data<sch::Scalar<T>> rad_d; + rad_d.at({}).set(radius); + + saw::data<sch::Vector<T,D>> lower; + saw::data<sch::Vector<T,D>> upper; + + for(uint64_t i{0u}; i < D; ++i){ + lower.at({{i}}) = pirb_pos.at({{i}}) >= rad_d.at({}) ? (pirb_pos.at({{i}}) - rad_d.at({})) : saw::data<T>{0}; + a.at({i}) = lower.at({{i}}).template cast_to<sch::UInt64>(); + upper.at({{i}}) = pirb_pos.at({{i}}) + rad_d.at({}); + b.at({i}) = (upper.at({{i}})+saw::data<T>{1}).template cast_to<sch::UInt64>() + } + + return aabb; + } +}; +} +} |
