From 8ff7003d3016b9e0295150aa4f91804eb00677fc Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sun, 5 Oct 2025 19:53:13 +0200 Subject: Center of mass calculation for grid --- c++/particle/geometry/circle.hpp | 6 ++++++ .../poiseulle_particles_channel_2d.cpp | 5 ++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/c++/particle/geometry/circle.hpp b/c++/particle/geometry/circle.hpp index 069a1a5..ef67fdd 100644 --- a/c++/particle/geometry/circle.hpp +++ b/c++/particle/geometry/circle.hpp @@ -17,6 +17,7 @@ public: saw::data> mask; auto& grid = mask.template get<"grid">(); + auto& com = mask.template get<"center_of_mass">(); //uint64_t rad_i = static_cast(resolution * radius_.get())+1u; uint64_t rad_i = resolution; @@ -41,6 +42,11 @@ public: } } + saw::data> com{{0,0}}; + iterate_over([&](saw::data>& index){ + + },{{0u,0u}}, grid.meta()); + return mask; } }; diff --git a/examples/poiseulle_particles_channel_2d/poiseulle_particles_channel_2d.cpp b/examples/poiseulle_particles_channel_2d/poiseulle_particles_channel_2d.cpp index e38710a..5ae3a11 100644 --- a/examples/poiseulle_particles_channel_2d/poiseulle_particles_channel_2d.cpp +++ b/examples/poiseulle_particles_channel_2d/poiseulle_particles_channel_2d.cpp @@ -347,10 +347,9 @@ void couple_particles_to_lattice( } saw::data> mask_shift; - { + for(uint64_t i = 0u; i < sch::D2Q9::D; ++i){ // Technically rotate and adjust here - mask_shift.at({{0u}}) = index_shift.at({{0u}}); - mask_shift.at({{1u}}) = index_shift.at({{1u}}); + mask_shift.at({{i}}) = index_shift.at({{i}}); } auto p_pos_lie = p_pos + mask_shift; -- cgit v1.2.3