From 4f3f21f72602ab4ce49caa6e7264d369afc98977 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Mon, 18 May 2026 18:55:12 +0200 Subject: Particle --- lib/core/c++/iterator.hpp | 28 ++++++++++++++++++++++++++++ lib/core/c++/particle/particle.hpp | 7 +++++++ lib/core/tests/iterator.cpp | 17 +++++++++++++++++ 3 files changed, 52 insertions(+) (limited to 'lib/core') diff --git a/lib/core/c++/iterator.hpp b/lib/core/c++/iterator.hpp index 866543a..696c521 100644 --- a/lib/core/c++/iterator.hpp +++ b/lib/core/c++/iterator.hpp @@ -50,6 +50,34 @@ public: } }; +template +struct ct_tuple_iterator final { +private: + template + static constexpr saw::error_or apply_i( + Func& func, + saw::data>& tup + ){ + if constexpr ( i < sizeof...(Tup) ){ + auto eov = func(tup.template get()); + if(eov.is_error()){ + return eov; + } + return apply_i(func,tup); + } + + return saw::make_void(); + } +public: + template + static constexpr saw::error_or apply( + Func&& func, + saw::data>& tup + ){ + return apply_i(func,tup); + } +}; + /* Ambiguous template void iterate_over(Func&& func, const saw::data>& start, const saw::data>& end, const saw::data>& dist = {{{0u,0u,0u}}}){ diff --git a/lib/core/c++/particle/particle.hpp b/lib/core/c++/particle/particle.hpp index 7af43dc..01429b2 100644 --- a/lib/core/c++/particle/particle.hpp +++ b/lib/core/c++/particle/particle.hpp @@ -238,5 +238,12 @@ constexpr auto broadphase_collision_check = []( ) -> bool{ return broadphase_collision_distance_squared(left,coll_l,right,coll_r).first; }; + + + +namespace impl { + +} + } } diff --git a/lib/core/tests/iterator.cpp b/lib/core/tests/iterator.cpp index 261765a..919c12c 100644 --- a/lib/core/tests/iterator.cpp +++ b/lib/core/tests/iterator.cpp @@ -20,6 +20,23 @@ SAW_TEST("Old Iterate"){ }, start, end); } +SAW_TEST("CT Tuple Iterator"){ + using namespace kel; + + saw::data< + sch::Tuple< + sch::Float32, + sch::Int16, + sch::Float64, + sch::UInt32 + > + > tup; + + lbm::ct_tuple_iterator::Schema>::apply([](auto& val) -> saw::error_or { + return saw::make_void(); + },tup); +} + SAW_TEST("Old Iterate with Distance 1"){ using namespace kel; -- cgit v1.2.3 From 81b7d6d2c09bbff6d9c1738fbb52f7c9a90b10de Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Tue, 19 May 2026 15:04:59 +0200 Subject: IBM reimplement --- lib/core/c++/iterator.hpp | 5 ++++- lib/core/c++/term_renderer.hpp | 6 ------ 2 files changed, 4 insertions(+), 7 deletions(-) delete mode 100644 lib/core/c++/term_renderer.hpp (limited to 'lib/core') diff --git a/lib/core/c++/iterator.hpp b/lib/core/c++/iterator.hpp index 696c521..7fd6f58 100644 --- a/lib/core/c++/iterator.hpp +++ b/lib/core/c++/iterator.hpp @@ -50,8 +50,11 @@ public: } }; +template +struct ct_tuple_iterator; + template -struct ct_tuple_iterator final { +struct ct_tuple_iterator> final { private: template static constexpr saw::error_or apply_i( diff --git a/lib/core/c++/term_renderer.hpp b/lib/core/c++/term_renderer.hpp deleted file mode 100644 index 5cbb551..0000000 --- a/lib/core/c++/term_renderer.hpp +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -namespace kel { -namespace lbm { -} -} -- cgit v1.2.3 From 8e22658bf3791fb5b1f9a11b5a5408d5e4e3f732 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Tue, 19 May 2026 15:05:59 +0200 Subject: Adding particle to hlbm --- lib/core/c++/hlbm.hpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'lib/core') diff --git a/lib/core/c++/hlbm.hpp b/lib/core/c++/hlbm.hpp index 41e2e27..7af4f7e 100644 --- a/lib/core/c++/hlbm.hpp +++ b/lib/core/c++/hlbm.hpp @@ -8,6 +8,7 @@ namespace kel { namespace lbm { namespace cmpt { struct HLBM {}; +struct HlbmParticle {}; } /** @@ -65,5 +66,29 @@ public: } }; +template +class component final { +private: + typename saw::native_data_type::type relaxation_; + saw::data frequency_; +public: + + template + void apply(const saw::data& field, const saw::data& macros, const saw::data& particles, saw::data> index, saw::data time_step) const { + /// Figure out how to access the particle list + auto& p = particles.at(i); + + /// Iterate over the grid bounds + auto& grid = p.template get<"grid">(); + + iterator::apply([&](const auto& index){ + auto& g_i = grid.at(index); + + /// Pick up forces and calculate to rigid body TODO + + }); + + } +}; } } -- cgit v1.2.3 From f07f88088cfacaad3f94dc667f08ee2c2f38a093 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 20 May 2026 14:06:41 +0200 Subject: Particle issues in hlbm --- lib/core/c++/hlbm.hpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'lib/core') diff --git a/lib/core/c++/hlbm.hpp b/lib/core/c++/hlbm.hpp index 7af4f7e..196de73 100644 --- a/lib/core/c++/hlbm.hpp +++ b/lib/core/c++/hlbm.hpp @@ -7,7 +7,7 @@ namespace kel { namespace lbm { namespace cmpt { -struct HLBM {}; +struct Hlbm {}; struct HlbmParticle {}; } @@ -15,7 +15,7 @@ struct HlbmParticle {}; * HLBM collision operator for LBM */ template -class component final { +class component final { private: typename saw::native_data_type::type relaxation_; saw::data frequency_; @@ -73,20 +73,13 @@ private: saw::data frequency_; public: - template + template void apply(const saw::data& field, const saw::data& macros, const saw::data& particles, saw::data> index, saw::data time_step) const { /// Figure out how to access the particle list - auto& p = particles.at(i); + // auto& p = particles.at(i); /// Iterate over the grid bounds - auto& grid = p.template get<"grid">(); - - iterator::apply([&](const auto& index){ - auto& g_i = grid.at(index); - - /// Pick up forces and calculate to rigid body TODO - - }); + // auto& grid = p.template get<"grid">(); } }; -- cgit v1.2.3 From b5d8593b9a2f0f58cb228444dcd09a2c5002e039 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Thu, 21 May 2026 15:00:09 +0200 Subject: Prep for proper com in circle group --- lib/core/c++/math/n_linear.hpp | 3 +++ lib/core/c++/particle/particle.hpp | 14 +++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'lib/core') diff --git a/lib/core/c++/math/n_linear.hpp b/lib/core/c++/math/n_linear.hpp index 8fb0600..b378440 100644 --- a/lib/core/c++/math/n_linear.hpp +++ b/lib/core/c++/math/n_linear.hpp @@ -122,6 +122,9 @@ auto n_linear_interpolate( } }, {}, ones_ind); + + /// TODO I need to actually calc stuff + return field.at({}); } template diff --git a/lib/core/c++/particle/particle.hpp b/lib/core/c++/particle/particle.hpp index 01429b2..5110893 100644 --- a/lib/core/c++/particle/particle.hpp +++ b/lib/core/c++/particle/particle.hpp @@ -55,6 +55,8 @@ template, "mask">, Member,1u>, "density">, + Member, "center_of_mass">, + Member, "total_mass">, Member>, "particles"> >; } @@ -76,10 +78,20 @@ saw::data>> cre for(uint64_t i = 0u; i < D; ++i){ mask_dims.at({i}) = mask_resolution; } + saw::data> mask_step; + saw::data dia_d{radius*2}; + mask_step.at({}) = dia_d / mask_resolution.template cast_to(); mask = {mask_dims}; + + auto& com = part.template get<"center_of_mass">(); + for(uint64_t i = 0u; i < D; ++i){ + com.at({{i}}) = {}; + } + saw::data ele_ctr{0u}; iterator::apply([&](const auto& index){ - + ++ele_ctr; + },{},mask_dims); return part; -- cgit v1.2.3