From 4c9e43a42c15ce93ffded21dfcaa171f63d20d69 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Thu, 11 Jun 2026 14:07:27 +0200 Subject: Fixing deduction issues from constexpr values --- lib/core/c++/hlbm.hpp | 11 +++--- lib/core/c++/particle/aabb.hpp | 30 +++++++++-------- lib/core/c++/particle/common.hpp | 3 ++ lib/core/c++/particle/particle.hpp | 68 ++++++-------------------------------- lib/core/c++/particle/schema.hpp | 67 +++++++++++++++++++++++++++++++++++++ lib/core/c++/schema.hpp | 10 +++--- 6 files changed, 109 insertions(+), 80 deletions(-) create mode 100644 lib/core/c++/particle/common.hpp create mode 100644 lib/core/c++/particle/schema.hpp (limited to 'lib/core/c++') diff --git a/lib/core/c++/hlbm.hpp b/lib/core/c++/hlbm.hpp index 6ae7d80..85e5357 100644 --- a/lib/core/c++/hlbm.hpp +++ b/lib/core/c++/hlbm.hpp @@ -4,6 +4,8 @@ #include "component.hpp" #include "equilibrium.hpp" +#include "particle/particle.hpp" + namespace kel { namespace lbm { namespace cmpt { @@ -114,14 +116,15 @@ public: */ template - void apply(const saw::data& field, const saw::data& macros, const saw::data& part_groups, saw::data> index, saw::data time_step) const { + void apply(const saw::data& field, const saw::data& macros, const saw::data& part_group, 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">(); - auto& part_spheroid_group = part_groups.template get<0>(); + auto& part_spheroid_group = part_group; + auto& mvel = macros.template get<"velocity">(); { auto& parts = part_spheroid_group.template get<"particles">(); auto parts_size = parts.size(); @@ -133,10 +136,8 @@ public: saw::data> start; saw::data> stop; + 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 - for(uint64_t i{0u}; i < Desc::D; ++i){ - - } iterator::apply([&](const auto& index){ // ask for the d_k value here. diff --git a/lib/core/c++/particle/aabb.hpp b/lib/core/c++/particle/aabb.hpp index aec95ca..8579695 100644 --- a/lib/core/c++/particle/aabb.hpp +++ b/lib/core/c++/particle/aabb.hpp @@ -1,36 +1,39 @@ #pragma once -#include "particle.hpp" +#include "common.hpp" +#include "schema.hpp" namespace kel { namespace lbm { -template +template class particle_aabb final { }; -template::type radius> -class particle_aabb > > final { +template +class particle_aabb< + sch::ParticleGroup> +> final { public: - using Schema = sch::ParticleGroup>; + using Schema = sch::ParticleGroup>; - using AABB = Struct< - Member"a">, - Member"b"> + using AABB = sch::Struct< + sch::Member,"a">, + sch::Member,"b"> >; public: - static constexpr saw::data get(const saw::data& p_grp, const saw::data>& i, const saw::data>& meta){ + static constexpr saw::data calculate(const saw::data& p_grp, const saw::data>& i, const saw::data>& meta){ + + saw::data aabb; 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; auto& a = aabb.template get<"a">(); auto& b = aabb.template get<"b">(); - saw::data> rad_d; - rad_d.at({}).set(radius); + const saw::data>& rad_d = p_grp.template get<"collision">().template get<"radius">().at({0u}); saw::data> lower; saw::data> upper; @@ -39,10 +42,11 @@ public: 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() + b.at({i}) = (upper.at({{i}})+saw::data{1}).template cast_to(); } return aabb; + } }; } diff --git a/lib/core/c++/particle/common.hpp b/lib/core/c++/particle/common.hpp new file mode 100644 index 0000000..9e673c2 --- /dev/null +++ b/lib/core/c++/particle/common.hpp @@ -0,0 +1,3 @@ +#pragma once + +#include "../common.hpp" diff --git a/lib/core/c++/particle/particle.hpp b/lib/core/c++/particle/particle.hpp index 1a99dcd..13ed37b 100644 --- a/lib/core/c++/particle/particle.hpp +++ b/lib/core/c++/particle/particle.hpp @@ -6,68 +6,22 @@ #include "../iterator.hpp" +#include "schema.hpp" +#include "aabb.hpp" + namespace kel { namespace lbm { -namespace coll { -struct Spheroid{}; -} -namespace sch { -using namespace saw::schema; - -namespace impl { -template -struct rotation_type_helper; - -template -struct rotation_type_helper { - using Schema = Scalar; -}; - -template -struct rotation_type_helper { - using Schema = Vector; -}; -} - -template -using ParticleRigidBody = Struct< - Member, "position">, - Member, "position_old">, - Member::Schema, "rotation">, - Member::Schema, "rotation_old">, - - Member, "acceleration">, - Member::Schema, "angular_acceleration"> ->; - -template::type radius = 1.0f> -using ParticleCollisionSpheroid = Struct< ->; template -using Particle = Struct< - Member, "rigid_body"> - // Problem is that dynamic data would two layered - // Member, "mask">, ->; - -template> -using ParticleGroup = Struct< - Member, "mask">, - Member,1u>, "mask_step">, - Member,1u>, "density">, - Member,1u>, "center_of_mass">, - Member,1u>, "total_mass">, - Member,1u>, "particles"> ->; -} - -template::type radius> -saw::data>> create_spheroid_particle_group( +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; auto& mask = part.template get<"mask">(); auto& density = part.template get<"density">().at({{0u}}); @@ -83,7 +37,7 @@ saw::data>> cre for(uint64_t i = 0u; i < D; ++i){ mask_dims.at({i}) = mask_resolution; } - saw::data rad_d{radius}; + saw::data rad_d = radius_p.at({}); saw::data dia_d = rad_d * 2; mask = {mask_dims}; @@ -104,7 +58,7 @@ saw::data>> cre saw::data> center; for(uint64_t i = 0u; i < D; ++i){ - center.at({{i}}).set(radius); + center.at({{i}}) = rad_d; } iterator::apply([&](const auto& index){ diff --git a/lib/core/c++/particle/schema.hpp b/lib/core/c++/particle/schema.hpp new file mode 100644 index 0000000..18a697a --- /dev/null +++ b/lib/core/c++/particle/schema.hpp @@ -0,0 +1,67 @@ +#pragma once + +#include "common.hpp" + +namespace kel { +namespace lbm { + +namespace coll { +template +struct Spheroid { + using ValueSchema = T; + using Schema = sch::Struct< + sch::Member,"radius"> + >; +}; +} + +namespace sch { +using namespace saw::schema; + +namespace impl { +template +struct rotation_type_helper; + +template +struct rotation_type_helper { + using Schema = Scalar; +}; + +template +struct rotation_type_helper { + using Schema = Vector; +}; +} + +template +using ParticleRigidBody = Struct< + Member, "position">, + Member, "position_old">, + Member::Schema, "rotation">, + Member::Schema, "rotation_old">, + + Member, "acceleration">, + Member::Schema, "angular_acceleration"> +>; + + +template +using Particle = Struct< + Member, "rigid_body"> + // Problem is that dynamic data would two layered + // Member, "mask">, +>; + +template> +using ParticleGroup = Struct< + Member, "mask">, + Member, "collision">, + Member,1u>, "mask_step">, + Member,1u>, "density">, + Member,1u>, "center_of_mass">, + Member,1u>, "total_mass">, + Member,1u>, "particles"> +>; +} +} +} diff --git a/lib/core/c++/schema.hpp b/lib/core/c++/schema.hpp index 0c92ae6..7712f99 100644 --- a/lib/core/c++/schema.hpp +++ b/lib/core/c++/schema.hpp @@ -3,9 +3,9 @@ #include namespace kel { - namespace lbm { - namespace sch { - using namespace saw::schema; - } - } +namespace lbm { +namespace sch { +using namespace saw::schema; +} +} } -- cgit v1.2.3