From b86c43b9f64704611be04810ba6f12d072f82ece Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sun, 5 Jul 2026 20:39:24 +0200 Subject: Momentum gather --- modules/core/c++/hlbm.hpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'modules/core') diff --git a/modules/core/c++/hlbm.hpp b/modules/core/c++/hlbm.hpp index 18c32a5..677d37a 100644 --- a/modules/core/c++/hlbm.hpp +++ b/modules/core/c++/hlbm.hpp @@ -102,10 +102,6 @@ public: } }; -namespace impl { - -} - template class component final { private: @@ -162,6 +158,26 @@ public: template void apply(const saw::data& field, const saw::data& macros, const saw::data& part_group, saw::data> index, saw::data time_step) const { // + bool is_even = ((time_step.get() % 2) == 0); + + auto& dfs_old_f = (is_even) ? field.template get<"dfs_old">() : field.template get<"dfs">(); + + saw::data> momentum; + for(uint64_t i = 0u; i < Desc::Q; ++i){ + + saw::data> e_i; + for(uint64_t k{0u}; k < Desc::D; ++k){ + e_i.at({{k}}) = dfi::directions[i][k]; + } + + uint64_t i_opp = dfi::opposite_index[i]; + + momentum = momentum + e_i * (dfs_old_f.at({{i}}) + dfs_old_f.at({{i_opp}})); + } + auto& force_f = macros.template get<"force">(); + + // Set Force + force.at(index) = momentum * macros.template get<"density">().at(index); } }; } -- cgit v1.2.3