From 04940fe64b714bcfad9026d54ee75a2fbdc7fe7b Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 17 Sep 2025 21:35:41 +0200 Subject: Streamlining and thoughts about changes in particle dynamics --- c++/macroscopic.hpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'c++/macroscopic.hpp') diff --git a/c++/macroscopic.hpp b/c++/macroscopic.hpp index 8a25248..51368e9 100644 --- a/c++/macroscopic.hpp +++ b/c++/macroscopic.hpp @@ -59,5 +59,34 @@ void compute_rho_u ( vel().at({i}) = vel().at({i}) / rho(); } } + +/** + * Calculate the macroscopic variables rho and u in Lattice Units. + */ +template +void compute_rho_u ( + const saw::data>& dfs, + saw::ref> rho, + saw::ref>> vel + ) +{ + using dfi = df_info; + + rho().set(0); + for(uint64_t i = 0; i < Desc::D; ++i){ + vel().at({{i}}).set(0); + } + + for(size_t j = 0; j < Desc::Q; ++j){ + rho() = rho() + dfs(j); + for(size_t i = 0; i < Desc::D; ++i){ + vel().at({{i}}) = vel().at({{i}}) + saw::data{static_cast::type>(dfi::directions[j][i])} * dfs(j); + } + } + + for(size_t i = 0; i < Desc::D; ++i){ + vel().at({{i}}) = vel().at({{i}}) / rho(); + } +} } } -- cgit v1.2.3