summaryrefslogtreecommitdiff
path: root/c++/particle/particle.hpp
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2025-04-29 17:36:16 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2025-04-29 17:36:16 +0200
commit0786c15aa982d37d12ff9fdc40c02c8b0a65c917 (patch)
tree5036cc932bc20a12de27c30bc327038e375ec589 /c++/particle/particle.hpp
parent1dc57770fe88b0564463d67a77a4c35f403c5d7f (diff)
wip dangling changes
Diffstat (limited to 'c++/particle/particle.hpp')
-rw-r--r--c++/particle/particle.hpp32
1 files changed, 27 insertions, 5 deletions
diff --git a/c++/particle/particle.hpp b/c++/particle/particle.hpp
index f893b9b..d253e64 100644
--- a/c++/particle/particle.hpp
+++ b/c++/particle/particle.hpp
@@ -10,10 +10,12 @@ using namespace saw::schema;
template<typename T, uint64_t D>
using ParticleRigidBody = Struct<
Member<FixedArray<T,D>, "position">,
- Member<FixedArray<T,D>, "velocity">,
+ Member<FixedArray<T,D>, "position_old">,
+ Member<FixedArray<T,D>, "rotation">,
+ Member<FixedArray<T,D>, "rotation_old">,
+
Member<FixedArray<T,D>, "acceleration">,
- Member<FixedArray<T,D>, "rotate_velocity">,
- Member<FixedArray<T,D>, "rotate_acceleration">
+ Member<FixedArray<T,D>, "rotational_acceleration">
>;
template<typename T, uint64_t D>
@@ -32,6 +34,27 @@ template<typename T, uint64_t D, typename Particle>
class particle_system {
private:
saw::data<sch::Array<Particle, 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::FixedArray<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:
void step(T time_step_delta){
@@ -41,9 +64,8 @@ public:
}
template<typename LbmLattice>
- void update_mask(saw::data<LbmLattice>& latt){
+ void update_particle_border(saw::data<LbmLattice>& latt){
for(auto& iter : particles_){
-
}
}
};