summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2026-06-11 14:07:27 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2026-06-11 14:07:27 +0200
commit4c9e43a42c15ce93ffded21dfcaa171f63d20d69 (patch)
tree13a8e06228070a1989be24ba09130a5ccbafeb45 /lib
parentad0efe4d0e43a2a4f122677578107c2a0398e53f (diff)
downloadlibs-lbm-4c9e43a42c15ce93ffded21dfcaa171f63d20d69.tar.gz
Fixing deduction issues from constexpr values
Diffstat (limited to 'lib')
-rw-r--r--lib/core/c++/hlbm.hpp11
-rw-r--r--lib/core/c++/particle/aabb.hpp30
-rw-r--r--lib/core/c++/particle/common.hpp3
-rw-r--r--lib/core/c++/particle/particle.hpp68
-rw-r--r--lib/core/c++/particle/schema.hpp67
-rw-r--r--lib/core/c++/schema.hpp10
6 files changed, 109 insertions, 80 deletions
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<typename CellFieldSchema, typename MacroFieldSchema, typename ParticleSchema>
- void apply(const saw::data<CellFieldSchema, Encode>& field, const saw::data<MacroFieldSchema,Encode>& macros, const saw::data<ParticleSchema,Encode>& part_groups, saw::data<sch::FixedArray<sch::UInt64,1u>> index, saw::data<sch::UInt64> time_step) const {
+ void apply(const saw::data<CellFieldSchema, Encode>& field, const saw::data<MacroFieldSchema,Encode>& macros, const saw::data<ParticleSchema,Encode>& part_group, saw::data<sch::FixedArray<sch::UInt64,1u>> index, saw::data<sch::UInt64> 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<sch::FixedArray<sch::UInt64,Desc::D>> start;
saw::data<sch::FixedArray<sch::UInt64,Desc::D>> stop;
+ auto aabb = particle_aabb<ParticleSchema>::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<Desc::D>::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<typename T, uint64_t D, typename PColl>
+template<typename PGroup>
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 {
+template<typename T, uint64_t D>
+class particle_aabb<
+ sch::ParticleGroup<T,D,coll::Spheroid<T>>
+> final {
public:
- using Schema = sch::ParticleGroup<T,D,sch::ParticleCollisionSpheroid<T,radius>>;
+ using Schema = sch::ParticleGroup<T,D,coll::Spheroid<T>>;
- using AABB = Struct<
- Member<sch::FixedArray<sch::UInt64,D>"a">,
- Member<sch::FixedArray<sch::UInt64,D>"b">
+ using AABB = sch::Struct<
+ sch::Member<sch::FixedArray<sch::UInt64,D>,"a">,
+ sch::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){
+ static constexpr saw::data<AABB> calculate(const saw::data<Schema>& p_grp, const saw::data<sch::FixedArray<sch::UInt64,1u>>& i, const saw::data<sch::FixedArray<sch::UInt64,D>>& meta){
+
+ saw::data<AABB> 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> 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);
+ const saw::data<sch::Scalar<T>>& rad_d = p_grp.template get<"collision">().template get<"radius">().at({0u});
saw::data<sch::Vector<T,D>> lower;
saw::data<sch::Vector<T,D>> 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<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>()
+ b.at({i}) = (upper.at({{i}})+saw::data<T>{1}).template cast_to<sch::UInt64>();
}
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<typename T,uint64_t D>
-struct rotation_type_helper;
-
-template<typename T>
-struct rotation_type_helper<T,2u> {
- using Schema = Scalar<T>;
-};
-
-template<typename T>
-struct rotation_type_helper<T,3u> {
- using Schema = Vector<T,3u>;
-};
-}
-
-template<typename T, uint64_t D>
-using ParticleRigidBody = Struct<
- Member<Vector<T,D>, "position">,
- Member<Vector<T,D>, "position_old">,
- Member<typename impl::rotation_type_helper<T,D>::Schema, "rotation">,
- Member<typename impl::rotation_type_helper<T,D>::Schema, "rotation_old">,
-
- Member<Vector<T,D>, "acceleration">,
- Member<typename impl::rotation_type_helper<T,D>::Schema, "angular_acceleration">
->;
-
-template<typename T, typename saw::native_data_type<T>::type radius = 1.0f>
-using ParticleCollisionSpheroid = Struct<
->;
template<typename T, uint64_t D>
-using Particle = Struct<
- Member<ParticleRigidBody<T,D>, "rigid_body">
- // Problem is that dynamic data would two layered
- // Member<Array<Float64,D>, "mask">,
->;
-
-template<typename T, uint64_t D, typename CollisionType = ParticleCollisionSpheroid<T>>
-using ParticleGroup = Struct<
- Member<Array<T,D>, "mask">,
- Member<FixedArray<Scalar<T>,1u>, "mask_step">,
- Member<FixedArray<Scalar<T>,1u>, "density">,
- Member<FixedArray<Vector<T,D>,1u>, "center_of_mass">,
- Member<FixedArray<Scalar<T>,1u>, "total_mass">,
- Member<Array<Particle<T,D>,1u>, "particles">
->;
-}
-
-template<typename T, uint64_t D, typename saw::native_data_type<T>::type radius>
-saw::data<sch::ParticleGroup<T,D, sch::ParticleCollisionSpheroid<T,radius>>> create_spheroid_particle_group(
+saw::data<sch::ParticleGroup<T,D, coll::Spheroid<T>>> create_spheroid_particle_group(
+ saw::data<sch::Scalar<T>> radius_p,
saw::data<sch::Scalar<T>> density_p,
const saw::data<sch::UInt64>& mask_resolution
){
- saw::data<sch::ParticleGroup<T,D,sch::ParticleCollisionSpheroid<T,radius>>> part;
+ saw::data<sch::ParticleGroup<T,D,coll::Spheroid<T>>> 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<sch::ParticleGroup<T,D, sch::ParticleCollisionSpheroid<T,radius>>> cre
for(uint64_t i = 0u; i < D; ++i){
mask_dims.at({i}) = mask_resolution;
}
- saw::data<T> rad_d{radius};
+ saw::data<T> rad_d = radius_p.at({});
saw::data<T> dia_d = rad_d * 2;
mask = {mask_dims};
@@ -104,7 +58,7 @@ saw::data<sch::ParticleGroup<T,D, sch::ParticleCollisionSpheroid<T,radius>>> cre
saw::data<sch::Vector<T,D>> center;
for(uint64_t i = 0u; i < D; ++i){
- center.at({{i}}).set(radius);
+ center.at({{i}}) = rad_d;
}
iterator<D>::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<typename T>
+struct Spheroid {
+ using ValueSchema = T;
+ using Schema = sch::Struct<
+ sch::Member<sch::Scalar<ValueSchema>,"radius">
+ >;
+};
+}
+
+namespace sch {
+using namespace saw::schema;
+
+namespace impl {
+template<typename T,uint64_t D>
+struct rotation_type_helper;
+
+template<typename T>
+struct rotation_type_helper<T,2u> {
+ using Schema = Scalar<T>;
+};
+
+template<typename T>
+struct rotation_type_helper<T,3u> {
+ using Schema = Vector<T,3u>;
+};
+}
+
+template<typename T, uint64_t D>
+using ParticleRigidBody = Struct<
+ Member<Vector<T,D>, "position">,
+ Member<Vector<T,D>, "position_old">,
+ Member<typename impl::rotation_type_helper<T,D>::Schema, "rotation">,
+ Member<typename impl::rotation_type_helper<T,D>::Schema, "rotation_old">,
+
+ Member<Vector<T,D>, "acceleration">,
+ Member<typename impl::rotation_type_helper<T,D>::Schema, "angular_acceleration">
+>;
+
+
+template<typename T, uint64_t D>
+using Particle = Struct<
+ Member<ParticleRigidBody<T,D>, "rigid_body">
+ // Problem is that dynamic data would two layered
+ // Member<Array<Float64,D>, "mask">,
+>;
+
+template<typename T, uint64_t D, typename CollisionType = coll::Spheroid<T>>
+using ParticleGroup = Struct<
+ Member<Array<T,D>, "mask">,
+ Member<FixedArray<typename CollisionType::Schema,1u>, "collision">,
+ Member<FixedArray<Scalar<T>,1u>, "mask_step">,
+ Member<FixedArray<Scalar<T>,1u>, "density">,
+ Member<FixedArray<Vector<T,D>,1u>, "center_of_mass">,
+ Member<FixedArray<Scalar<T>,1u>, "total_mass">,
+ Member<Array<Particle<T,D>,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 <forstio/codec/schema.hpp>
namespace kel {
- namespace lbm {
- namespace sch {
- using namespace saw::schema;
- }
- }
+namespace lbm {
+namespace sch {
+using namespace saw::schema;
+}
+}
}