From 0786c15aa982d37d12ff9fdc40c02c8b0a65c917 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Tue, 29 Apr 2025 17:36:16 +0200 Subject: wip dangling changes --- c++/config.hpp | 3 +-- c++/particle/geometry/circle.hpp | 30 ++++++++++++++++++------------ c++/particle/particle.hpp | 32 +++++++++++++++++++++++++++----- 3 files changed, 46 insertions(+), 19 deletions(-) (limited to 'c++') diff --git a/c++/config.hpp b/c++/config.hpp index aefd833..64f7a0f 100644 --- a/c++/config.hpp +++ b/c++/config.hpp @@ -16,8 +16,7 @@ template using LbmConfig = Struct< Member, Member, - Member, - Member, "dims"> + Member >; } diff --git a/c++/particle/geometry/circle.hpp b/c++/particle/geometry/circle.hpp index 65b8966..e7b78f1 100644 --- a/c++/particle/geometry/circle.hpp +++ b/c++/particle/geometry/circle.hpp @@ -1,15 +1,15 @@ #pragma once +#include "../particle.hpp" + namespace kel { namespace lbm { template class particle_circle_geometry { private: - saw::data radius_; public: - particle_circle_geometry(saw::data radius__): - radius_{radius__} + particle_circle_geometry() {} template @@ -18,19 +18,25 @@ public: auto& grid = mask.template get<"grid">(); - uint64_t size = resolution + 2*boundary_nodes; - grid = {{size,size}}; - - saw::data radius_squared = radius_ * radius_; - + //uint64_t rad_i = static_cast(resolution * radius_.get())+1u; + uint64_t rad_i = resolution; + uint64_t size = rad_i + 2*boundary_nodes; + grid = {{{size,size}}}; + saw::data delta_x{2.0 / rad_i}; + saw::data center = (saw::data{1.0} + saw::data{2.0} * saw::data{static_cast::type>(boundary_nodes)/rad_i}); for(uint64_t i = 0; i < size; ++i){ for(uint64_t j = 0; j < size; ++j){ - if(i < boundary_nodes || j < boundary_nodes || i >= resolution+boundary_nodes || j >= resolution + boundary_nodes ){ - grid.at({i,j}).set(0); - }else{ - + grid.at({{i,j}}).set(0); + if(i >= boundary_nodes and j >= boundary_nodes and i < (rad_i + boundary_nodes) and j < (rad_i + boundary_nodes) ){ + saw::data fi = saw::data{0.5+static_cast::type>(i)} * delta_x - center; + saw::data fj = saw::data{0.5+static_cast::type>(j)} * delta_x - center; + + auto norm_f_ij = fi*fi + fj*fj; + if(norm_f_ij.get() <= 1){ + grid.at({{i,j}}).set(1); + } } } } 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 using ParticleRigidBody = Struct< Member, "position">, - Member, "velocity">, + Member, "position_old">, + Member, "rotation">, + Member, "rotation_old">, + Member, "acceleration">, - Member, "rotate_velocity">, - Member, "rotate_acceleration"> + Member, "rotational_acceleration"> >; template @@ -32,6 +34,27 @@ template class particle_system { private: saw::data> particles_; + + void verlet_step(saw::data& particle, saw::data 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> pos_new; + // Actual step + for(uint64_t i = 0u; i < D; ++i){ + pos_new.at({i}) = saw::data{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 - void update_mask(saw::data& latt){ + void update_particle_border(saw::data& latt){ for(auto& iter : particles_){ - } } }; -- cgit v1.2.3