From 94953f367542c81d162ff31fb60567143e258c24 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Mon, 6 Jul 2026 18:07:55 +0200 Subject: Managed finally to kick myself enough to fix the aabb checks --- modules/core/c++/particle/aabb.hpp | 4 ++-- modules/core/tests/particles.cpp | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/core/c++/particle/aabb.hpp b/modules/core/c++/particle/aabb.hpp index 1773dea..18426d5 100644 --- a/modules/core/c++/particle/aabb.hpp +++ b/modules/core/c++/particle/aabb.hpp @@ -35,13 +35,13 @@ public: auto& a = aabb.template get<"a">(); auto& b = aabb.template get<"b">(); - const saw::data>& rad_d = p_grp.template get<"collision">().template get<"radius">().at({0u}); + const saw::data>& rad_d = p_grp.template get<"collision">().at({0u}).template get<"radius">(); saw::data> lower; saw::data> 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{0}; + lower.at({{i}}) = ((pirb_pos.at({{i}}) >= rad_d.at({})) ? (pirb_pos.at({{i}}) - rad_d.at({})) : saw::data{0}); a.at({i}) = lower.at({{i}}).template cast_to(); upper.at({{i}}) = pirb_pos.at({{i}}) + rad_d.at({}); b.at({i}) = (upper.at({{i}})+saw::data{1}).template cast_to(); diff --git a/modules/core/tests/particles.cpp b/modules/core/tests/particles.cpp index 8c21608..d11fa4f 100644 --- a/modules/core/tests/particles.cpp +++ b/modules/core/tests/particles.cpp @@ -280,13 +280,42 @@ SAW_TEST("Spheroid Particle / AABB"){ constexpr uint64_t D = 2u; saw::data> radi,dense; - radi.at({}) = 2.0f; + radi.at({}) = 2.2f; dense.at({}) = 1.0f; auto spheroid_pgrp = lbm::create_spheroid_particle_group(radi,dense,{8u}); - // auto res = lbm::particle_aabb>>::calculate(spheroid_pgrp,{{0u}},{}); + 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">(); + { + rb_pos.at({{0u}}).set(4.1f); + rb_pos.at({{1u}}).set(2.9f); + } + + auto res = lbm::particle_aabb>>::calculate(spheroid_pgrp,{{0u}},{{64u,32u}}); + + { + auto res_check = [&](const auto& tbp){ + lbm::iterator<1u>::apply([&](const auto& index){ + std::cout<()); + res_check(res.template get<"b">()); + } + auto& rva = res.template get<"a">(); + auto& rvb = res.template get<"b">(); + + SAW_EXPECT(rva.at({{0u}}).get() == 1, std::string{"Expected another value for rva at 0: "} + std::to_string(rva.at({{0u}}).get())); + SAW_EXPECT(rva.at({{1u}}).get() == 0, std::string{"Expected another value for rva at 1: "} + std::to_string(rva.at({{1u}}).get())); + + SAW_EXPECT(rvb.at({{0u}}).get() == 7, std::string{"Expected another value for rvb at 0: "} + std::to_string(rvb.at({{0u}}).get())); + SAW_EXPECT(rvb.at({{1u}}).get() == 6, std::string{"Expected another value for rvb at 1: "} + std::to_string(rvb.at({{1u}}).get())); // std::cout<