From 44cb41bbe6128f2c7ca92b06e2267d52e3121721 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 15 Jul 2026 15:39:41 +0200 Subject: Preping two way --- modules/core/c++/hlbm.hpp | 2 +- modules/core/c++/particle/aabb.hpp | 14 +++++++++----- modules/core/c++/particle/particle.hpp | 6 +++--- modules/core/c++/particle/particle_opa.hpp | 2 +- modules/core/c++/particle/porosity.hpp | 12 ++++++------ modules/core/c++/particle/schema.hpp | 4 ++-- modules/core/tests/particles.cpp | 10 +++++----- 7 files changed, 27 insertions(+), 23 deletions(-) (limited to 'modules') diff --git a/modules/core/c++/hlbm.hpp b/modules/core/c++/hlbm.hpp index 9a89697..9ddc6c6 100644 --- a/modules/core/c++/hlbm.hpp +++ b/modules/core/c++/hlbm.hpp @@ -125,7 +125,7 @@ public: auto& mvel = macros.template get<"velocity">(); { auto& parts = part_spheroid_group.template get<"particles">(); - auto parts_size = parts.meta().at({0u}); + auto parts_size = parts.dims().at({0u}); auto& pi = parts.at(index); auto& pirb = pi.template get<"rigid_body">(); diff --git a/modules/core/c++/particle/aabb.hpp b/modules/core/c++/particle/aabb.hpp index 18426d5..a838401 100644 --- a/modules/core/c++/particle/aabb.hpp +++ b/modules/core/c++/particle/aabb.hpp @@ -10,12 +10,12 @@ class particle_aabb final { static_assert(saw::always_false, "Not supported"); }; -template +template class particle_aabb< - sch::ParticleGroup> + sch::ParticleGroup> > final { public: - using Schema = sch::ParticleGroup>; + using Schema = sch::ParticleGroup>; using AABB = sch::Struct< sch::Member,"a">, @@ -23,7 +23,11 @@ public: >; public: template - static constexpr saw::data calculate(const saw::data& p_grp, const saw::data>& i, const saw::data>& meta){ + static constexpr saw::error_or> calculate(const saw::data& p_grp, const saw::data>& i, const saw::data>& meta){ + static_assert(PC > 0u, "Can't calculate from no particles"); + if(not (i.at({0u}).get() < PC) ){ + return saw::make_error("Too large i in particle_aabb"); + } saw::data aabb; auto& parts = p_grp.template get<"particles">(); @@ -35,7 +39,7 @@ public: auto& a = aabb.template get<"a">(); auto& b = aabb.template get<"b">(); - const saw::data>& rad_d = p_grp.template get<"collision">().at({0u}).template get<"radius">(); + const saw::data>& rad_d = p_grp.template get<"collision">().at(i).template get<"radius">(); saw::data> lower; saw::data> upper; diff --git a/modules/core/c++/particle/particle.hpp b/modules/core/c++/particle/particle.hpp index 8e75e5a..3c3630a 100644 --- a/modules/core/c++/particle/particle.hpp +++ b/modules/core/c++/particle/particle.hpp @@ -13,13 +13,13 @@ namespace kel { namespace lbm { -template -saw::data>> create_spheroid_particle_group( +template +saw::data>> create_spheroid_particle_group( saw::data> radius_p, saw::data> density_p, const saw::data& mask_resolution ){ - saw::data>> part; + saw::data>> part; auto& rad_s = part.template get<"collision">().at({0u}).template get<"radius">(); rad_s = radius_p; diff --git a/modules/core/c++/particle/particle_opa.hpp b/modules/core/c++/particle/particle_opa.hpp index 30a8ade..ce1ecb7 100644 --- a/modules/core/c++/particle/particle_opa.hpp +++ b/modules/core/c++/particle/particle_opa.hpp @@ -41,7 +41,7 @@ public: // Write out value auto diff = pos_ind.template cast_to() - pos_; auto diff_dot = saw::math::dot(diff,diff); - porous = particle_porosity>::calculate(diff, rad_, eps_); + porous = particle_porosity>::calculate(diff, rad_, eps_); } }; } diff --git a/modules/core/c++/particle/porosity.hpp b/modules/core/c++/particle/porosity.hpp index 2f39d2e..353cd58 100644 --- a/modules/core/c++/particle/porosity.hpp +++ b/modules/core/c++/particle/porosity.hpp @@ -11,11 +11,11 @@ template struct ParticleSpheroid {}; } -template +template class particle_porosity { public: - static saw::data> calculate(const saw::data>& part_group, uint64_t p_i, const saw::data>& lbm_pos){ + static saw::data> calculate(const saw::data>& part_group, uint64_t p_i, const saw::data>& lbm_pos){ auto& mask = part_group.template get<"mask">(); auto& particles = part_group.template get<"particles">(); @@ -33,7 +33,7 @@ public: }; template -class particle_porosity> final { +class particle_porosity> final { public: static saw::data> calculate(const saw::data>& lbm_rel_dist, saw::data> rad, saw::data> eps){ saw::data> por; @@ -68,10 +68,10 @@ public: }; -template -class particle_porosity> final { +template +class particle_porosity> final { public: - static saw::data> calculate(const saw::data > >& part_group, uint64_t i, const saw::data>& lbm_pos) { + static saw::data> calculate(const saw::data > >& part_group, uint64_t i, const saw::data>& lbm_pos) { saw::data> por; auto& parts = part_group.template get<"particles">(); diff --git a/modules/core/c++/particle/schema.hpp b/modules/core/c++/particle/schema.hpp index 714a16f..221137a 100644 --- a/modules/core/c++/particle/schema.hpp +++ b/modules/core/c++/particle/schema.hpp @@ -52,7 +52,7 @@ using Particle = Struct< // Member, "mask">, >; -template> +template> using ParticleGroup = Struct< Member, "mask">, Member, "collision">, @@ -61,7 +61,7 @@ using ParticleGroup = Struct< Member,1u>, "density">, Member,1u>, "center_of_mass">, Member,1u>, "total_mass">, - Member,1u>, "particles"> + Member,PartAmount>, "particles"> >; } } diff --git a/modules/core/tests/particles.cpp b/modules/core/tests/particles.cpp index d11fa4f..e060097 100644 --- a/modules/core/tests/particles.cpp +++ b/modules/core/tests/particles.cpp @@ -278,15 +278,14 @@ SAW_TEST("Spheroid Particle / AABB"){ using T = sch::Float64; constexpr uint64_t D = 2u; + constexpr uint64_t PC = 1u; saw::data> radi,dense; radi.at({}) = 2.2f; dense.at({}) = 1.0f; - auto spheroid_pgrp = lbm::create_spheroid_particle_group(radi,dense,{8u}); + auto spheroid_pgrp = lbm::create_spheroid_particle_group(radi,dense,{8u}); auto& rb_array = spheroid_pgrp.template get<"particles">(); - rb_array = {1u}; - auto& rb = rb_array.at({0u}).template get<"rigid_body">(); auto& rb_pos = rb.template get<"position">(); @@ -295,8 +294,9 @@ SAW_TEST("Spheroid Particle / AABB"){ rb_pos.at({{1u}}).set(2.9f); } - auto res = lbm::particle_aabb>>::calculate(spheroid_pgrp,{{0u}},{{64u,32u}}); - + auto eo_res = lbm::particle_aabb>>::calculate(spheroid_pgrp,{{0u}},{{64u,32u}}); + SAW_EXPECT(eo_res.is_value(), "particle_aabb has error value"); + auto& res = eo_res.get_value(); { auto res_check = [&](const auto& tbp){ lbm::iterator<1u>::apply([&](const auto& index){ -- cgit v1.2.3 From aedeb28b41ffbe0229d065c69f7d2e4570968ace Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 15 Jul 2026 16:55:56 +0200 Subject: Reworking particle_aabb --- modules/core/c++/hlbm.hpp | 4 +++- modules/core/c++/particle/aabb.hpp | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/core/c++/hlbm.hpp b/modules/core/c++/hlbm.hpp index 9ddc6c6..eccc2cd 100644 --- a/modules/core/c++/hlbm.hpp +++ b/modules/core/c++/hlbm.hpp @@ -105,7 +105,7 @@ class component final { private: template void apply_i(const saw::data& field, const saw::data& macros, const saw::data& part_groups, saw::data> index, saw::data time_step) const { - + // if constexpr ( i < ) } public: /* @@ -136,6 +136,8 @@ public: auto aabb = particle_aabb::calculate(part_spheroid_group,index,mvel.meta()); /// Ok, I iterate over the space which covers our particle? So lower bounds to upper bounds + start = aabb.template get<"a">(); + stop = aabb.template get<"b">(); iterator::apply([&](const auto& index){ // ask for the d_k value here. diff --git a/modules/core/c++/particle/aabb.hpp b/modules/core/c++/particle/aabb.hpp index a838401..983fd97 100644 --- a/modules/core/c++/particle/aabb.hpp +++ b/modules/core/c++/particle/aabb.hpp @@ -22,8 +22,8 @@ public: sch::Member,"b"> >; public: - template - static constexpr saw::error_or> calculate(const saw::data& p_grp, const saw::data>& i, const saw::data>& meta){ + template + static constexpr saw::error_or> calculate(const saw::data& p_grp, const saw::data>& i, const saw::data>& meta){ static_assert(PC > 0u, "Can't calculate from no particles"); if(not (i.at({0u}).get() < PC) ){ return saw::make_error("Too large i in particle_aabb"); @@ -55,5 +55,6 @@ public: } }; + } } -- cgit v1.2.3