From f5d88c1ae8948724f11d30c1c2af385cc093eed2 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Mon, 24 Aug 2026 19:02:51 +0200 Subject: Fixing FpLBM, because I messed up guo forcing --- modules/core/c++/fplbm.hpp | 2 +- modules/core/c++/macroscopic.hpp | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'modules/core') diff --git a/modules/core/c++/fplbm.hpp b/modules/core/c++/fplbm.hpp index c9ed6e9..d8c075b 100644 --- a/modules/core/c++/fplbm.hpp +++ b/modules/core/c++/fplbm.hpp @@ -92,7 +92,7 @@ public: auto& force_f = macros.template get<"force">(); auto& force = force_f.at(index); - vel = vel + force * half; + vel = vel + force * half / rho; // compute_rho_u(dfs,rho,vel); auto eq = equilibrium(rho,vel); diff --git a/modules/core/c++/macroscopic.hpp b/modules/core/c++/macroscopic.hpp index 768fef0..9db1538 100644 --- a/modules/core/c++/macroscopic.hpp +++ b/modules/core/c++/macroscopic.hpp @@ -33,5 +33,30 @@ void compute_rho_u ( vel().at({{i}}) = vel().at({{i}}) / rho().at({}); } } + +/** + * Calculate the macroscopic variables rho and u in Lattice Units. + */ +template +void compute_rho_momentum ( + const saw::data>& dfs, + saw::ref>> rho, + saw::ref>> mom + ) +{ + using dfi = df_info; + + rho().at({}).set(0); + for(uint64_t i = 0; i < Desc::D; ++i){ + mom().at({{i}}).set(0); + } + + for(size_t j = 0; j < Desc::Q; ++j){ + rho().at({}) = rho().at({}) + dfs.at({j}); + for(size_t i = 0; i < Desc::D; ++i){ + mom().at({{i}}) = mom().at({{i}}) + saw::data{static_cast::type>(dfi::directions[j][i])} * dfs.at({j}); + } + } +} } } -- cgit v1.2.3