summaryrefslogtreecommitdiff
path: root/c++/particle/particle.hpp
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2025-10-18 18:01:14 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2025-10-18 18:01:14 +0200
commit24bf28a8fb9cc8c3a90b77de9b60728bece7885d (patch)
treedfcbfcb8775bf96847d4a187695158b968902889 /c++/particle/particle.hpp
parenta980da34513a9ad41e309e66432fcb80ddaf2e31 (diff)
downloadlibs-lbm-24bf28a8fb9cc8c3a90b77de9b60728bece7885d.tar.gz
Moving project structure for more less compilation
Diffstat (limited to 'c++/particle/particle.hpp')
-rw-r--r--c++/particle/particle.hpp113
1 files changed, 0 insertions, 113 deletions
diff --git a/c++/particle/particle.hpp b/c++/particle/particle.hpp
deleted file mode 100644
index 39aadfb..0000000
--- a/c++/particle/particle.hpp
+++ /dev/null
@@ -1,113 +0,0 @@
-#pragma once
-
-#include <forstio/codec/data.hpp>
-#include <forstio/codec/data_math.hpp>
-#include <forstio/codec/math.hpp>
-
-namespace kel {
-namespace lbm {
-namespace sch {
-using namespace saw::schema;
-
-template<typename T, uint64_t D>
-using ParticleRigidBody = Struct<
- Member<Vector<T,D>, "position">,
- Member<Vector<T,D>, "position_old">,
- Member<T, "rotation">,
- Member<T, "rotation_old">,
-
- Member<Vector<T,D>, "acceleration">,
- Member<T, "rotational_acceleration">
->;
-
-template<typename T, uint64_t D>
-using ParticleMask = Struct<
- Member<Array<T,D>, "grid">,
- Member<Vector<T,D>, "center_of_mass">
->;
-
-template<typename T, uint64_t D>
-using Particle = Struct<
- Member<ParticleRigidBody<T,D>, "rigid_body">,
- Member<ParticleMask<T,D>, "mask">,
- Member<T, "mass">,
- Member<T, "size">
->;
-}
-
-template<typename T, uint64_t D, typename ParticleCollision = sch::ParticleMask<T,D> >
-class particle_system {
-private:
- saw::data<sch::Array<sch::Particle<T,D>>> particles_;
-
- void verlet_step(saw::data<sch::Particle<T,D>>& particle, saw::data<T> time_step_delta){
- auto& body = particle.template get<"rigid_body">();
-
- auto& pos = body.template get<"position">();
- auto& pos_old = body.template get<"position_old">();
-
- // auto& rot = body.template get<"rotation">();
- auto& acc = body.template get<"acceleration">();
-
- auto tsd_squared = time_step_delta * time_step_delta;
-
- saw::data<sch::Vector<T,D>> pos_new;
- // Actual step
- for(uint64_t i = 0u; i < D; ++i){
- pos_new.at({{i}}) = saw::data<T>{2.0} * pos.at({{i}}) - pos_old.at({{i}}) + acc.at({{i}}) * tsd_squared;
- }
-
- pos_old = pos;
- pos = pos_new;
- }
-public:
- /**
- * Add particle to this class and return an id representing this particle
- */
- saw::error_or<saw::data<sch::UInt64>> add_particle(saw::data<sch::Particle<T,D>> particle__){
- auto size = particles_.size();
- auto eov = particles_.add(std::move(particle__));
- if(eov.is_error()){
- return std::move(eov.get_error());
- }
-
- return size;
- }
-
- /*
- saw::data<sch::Particle<T,D>>& get_particle(saw::data<sch::UInt64> id){
- }
- */
-
- void step(saw::data<T> time_step_delta){
- for(saw::data<sch::UInt64> i{0u}; i < particles_.size(); ++i){
- verlet_step(particles_.at(i), time_step_delta);
- }
- }
-
- template<typename LbmLattice>
- void update_particle_border(saw::data<LbmLattice>& latt){
- (void) latt;
- for(auto& iter : particles_){
- auto& par = iter;
-
- auto& body = par.template get<"rigid_body">();
- auto& size = par.template get<"size">();
-
-
- }
- }
-
- saw::data<sch::UInt64> size() const {
- return particles_.size();
- }
-
- /**
- * Mostly meant for unforeseen use cases.
- */
- saw::data<sch::Particle<T,D>>& at(saw::data<sch::UInt64> i){
- return particles_.at(i);
- }
-};
-}
-}