summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2026-01-13 16:31:02 +0100
committerClaudius "keldu" Holeksa <mail@keldu.de>2026-01-13 16:31:02 +0100
commit1b8ff0752a7622534199e0d8e8c2801967eed4ba (patch)
tree0c1b03bb796c5e649e681aa3339dd6b9f7f84cd2
parent49a8fc2ebe34b3f45db4295b3e01b47af9773ab6 (diff)
downloadlibs-lbm-1b8ff0752a7622534199e0d8e8c2801967eed4ba.tar.gz
Reworking the packages sets
-rw-r--r--default.nix54
-rw-r--r--lib/core/c++/particle/particle.hpp19
-rw-r--r--lib/core/tests/particles.cpp44
3 files changed, 85 insertions, 32 deletions
diff --git a/default.nix b/default.nix
index 8422877..168cd08 100644
--- a/default.nix
+++ b/default.nix
@@ -47,73 +47,75 @@ let
}).forstio;
pname = "kel-lbm";
- version = "0.0.3";
+ version = "0.0.4";
in rec {
- kel-lbm = {
- core = pkgs.callPackage ./lib/core/.nix/derivation.nix {
- inherit forstio stdenv clang-tools pname version;
+ kel = {
+ lbm = {
+ core = pkgs.callPackage ./lib/core/.nix/derivation.nix {
+ inherit forstio stdenv clang-tools pname version;
+ };
+ sycl = pkgs.callPackage ./lib/sycl/.nix/derivation.nix {
+ inherit forstio stdenv clang-tools pname version kel adaptive-cpp;
+ };
};
- sycl = pkgs.callPackage ./lib/sycl/.nix/derivation.nix {
- inherit forstio stdenv clang-tools pname version kel-lbm adaptive-cpp;
- };
- };
+ };
- util = {
- lbm_ogl_renderer = pkgs.callPackage ./util/ogl_renderer/.nix/derivation.nix {
- inherit forstio stdenv clang-tools pname version kel-lbm;
- kel-glad = glad_opengl_33_core;
- };
- };
+ util = {
+ lbm_ogl_renderer = pkgs.callPackage ./util/ogl_renderer/.nix/derivation.nix {
+ inherit forstio stdenv clang-tools pname version kel;
+ kel-glad = glad_opengl_33_core;
+ };
+ };
examples = {
cavity_2d_gpu = pkgs.callPackage ./examples/cavity_2d_gpu/.nix/derivation.nix {
inherit pname version stdenv forstio adaptive-cpp;
- inherit kel-lbm;
+ inherit kel;
};
poiseulle_2d_gpu = pkgs.callPackage ./examples/poiseulle_2d_gpu/.nix/derivation.nix {
inherit pname version stdenv forstio adaptive-cpp;
- inherit kel-lbm;
+ inherit kel;
};
cavity_2d = pkgs.callPackage ./examples/cavity_2d/.nix/derivation.nix {
inherit pname version stdenv forstio;
- inherit kel-lbm;
+ inherit kel;
};
poiseulle_particles_channel_2d = pkgs.callPackage ./examples/poiseulle_particles_channel_2d/.nix/derivation.nix {
inherit pname version stdenv forstio;
- inherit kel-lbm;
+ inherit kel;
};
meta_2d = pkgs.callPackage ./examples/meta_2d/.nix/derivation.nix {
inherit pname version stdenv forstio;
- inherit kel-lbm;
+ inherit kel;
};
planetary_3d = pkgs.callPackage ./examples/planetary_3d/.nix/derivation.nix {
inherit pname version stdenv forstio adaptive-cpp;
- inherit kel-lbm;
+ inherit kel;
};
poiseulle_2d = pkgs.callPackage ./examples/poiseulle_3d/.nix/derivation.nix {
inherit pname version stdenv forstio;
- inherit kel-lbm;
+ inherit kel;
};
poiseulle_3d = pkgs.callPackage ./examples/poiseulle_3d/.nix/derivation.nix {
inherit pname version stdenv forstio adaptive-cpp;
- inherit kel-lbm;
+ inherit kel;
};
particles_gpu = pkgs.callPackage ./examples/particles_gpu/.nix/derivation.nix {
inherit pname version stdenv forstio adaptive-cpp;
- inherit kel-lbm;
+ inherit kel;
};
heterogeneous_computing = pkgs.callPackage ./examples/heterogeneous_computing/.nix/derivation.nix {
inherit pname version stdenv forstio adaptive-cpp;
- inherit kel-lbm;
+ inherit kel;
};
};
@@ -123,13 +125,13 @@ in rec {
release = {
dev = {
- inherit kel-lbm;
+ inherit kel;
};
examples = pkgs.symlinkJoin {
name = "kel-lbm-sims-${version}";
paths = [
- kel-lbm.core
+ kel.lbm.core
examples.cavity_2d_gpu
];
};
diff --git a/lib/core/c++/particle/particle.hpp b/lib/core/c++/particle/particle.hpp
index cea80f0..557707d 100644
--- a/lib/core/c++/particle/particle.hpp
+++ b/lib/core/c++/particle/particle.hpp
@@ -91,6 +91,25 @@ constexpr auto verlet_step_lambda = [](saw::data<sch::Particle<T,D>>& particle,
pos = pos_new;
};
+template<typename T, uint64_t D>
+constexpr auto handle_collision = [](saw::data<sch::Particle<T,D>>& left, saw::data<sch::Particle<T,D>>& right){
+ auto& rb_l = left.template get<"rigid_body">();
+ auto& rb_r = right.template get<"rigid_body">();
+
+ auto& pos_l = rb_l.template get<"position">();
+ auto& pos_old_l = rb_l.template get<"position_old">();
+ auto vel_l = pos_l - pos_old_l;
+ auto& mass_l = left.template get<"mass">();
+
+
+ /**
+ * E to 0
+ */
+
+
+
+};
+
template<typename T, uint64_t D>
constexpr auto broadphase_collision_distance = [](saw::data<sch::Particle<T,D>>& left, saw::data<sch::Particle<T,D>>& right) -> std::pair<bool,saw::data<sch::Scalar<T>>>{
diff --git a/lib/core/tests/particles.cpp b/lib/core/tests/particles.cpp
index 7c0c748..366c2a2 100644
--- a/lib/core/tests/particles.cpp
+++ b/lib/core/tests/particles.cpp
@@ -1,9 +1,7 @@
#include <forstio/test/suite.hpp>
#include <iostream>
-//#include "../c++/particle/geometry/circle.hpp"
#include "../c++/particle/particle.hpp"
-#include <forstio/codec/data.hpp>
namespace {
namespace sch {
@@ -143,15 +141,49 @@ SAW_TEST("Moving particles 2D"){
std::cout<<"Collided at: "<<i<<std::endl;
break;
}
- std::cout<<part_a.template get<"rigid_body">().template get<"position">().at({{0u}}).get();
- std::cout<<" ";
- std::cout<<part_b.template get<"rigid_body">().template get<"position">().at({{0u}}).get();
- std::cout<<std::endl;
}
SAW_EXPECT(has_collided, "Expecting collision within those steps");
}
+SAW_TEST("Particle Collision Impulse"){
+ using namespace kel;
+
+ saw::data<sch::Particle<sch::T,2u>> part_a;
+ {
+ auto& body = part_a.template get<"rigid_body">();
+ auto& pos = body.template get<"position">();
+ auto& pos_old = body.template get<"position_old">();
+ auto& coll = part_a.template get<"collision">();
+ auto& radius = coll.template get<"radius">();
+ auto& acc = body.template get<"acceleration">();
+
+ radius.set(1.0);
+
+ pos.at({{0u}}) = -5.0;
+ pos.at({{1u}}) = 0.2;
+ pos_old = pos;
+ acc.at({{0u}}) = 0.1;
+
+ }
+ saw::data<sch::Particle<sch::T,2u>> part_b;
+ {
+ auto& body = part_b.template get<"rigid_body">();
+ auto& pos = body.template get<"position">();
+ auto& pos_old = body.template get<"position_old">();
+ auto& coll = part_b.template get<"collision">();
+ auto& radius = coll.template get<"radius">();
+ auto& acc = body.template get<"acceleration">();
+
+ radius.set(1.5);
+
+ pos.at({{0u}}) = 5.0;
+ pos.at({{1u}}) = 0.0;
+ pos_old = pos;
+ acc.at({{0u}}) = -0.1;
+ }
+}
+
/*
SAW_TEST("Minor Test for mask"){
using namespace kel;