diff options
Diffstat (limited to 'c++/particle/particle.hpp')
-rw-r--r-- | c++/particle/particle.hpp | 32 |
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_){ - } } }; |