From ae8711ba90ac2a47ea7654dc873927fb2783ff91 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Fri, 18 Apr 2025 16:25:30 +0200 Subject: wip rendering in terminal and extracting example code to files --- c++/macroscopic.hpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 c++/macroscopic.hpp (limited to 'c++/macroscopic.hpp') diff --git a/c++/macroscopic.hpp b/c++/macroscopic.hpp new file mode 100644 index 0000000..608b89e --- /dev/null +++ b/c++/macroscopic.hpp @@ -0,0 +1,32 @@ +#pragma once + +namespace kel { +namespace lbm { +/** + * Calculate the macroscopic variables rho and u in Lattice Units. + */ +template +void compute_rho_u ( + const saw::data>& dfs, + typename saw::native_data_type::type& rho, + std::array::type, 2>& vel + ) +{ + using dfi = df_info; + + rho = 0; + std::fill(vel.begin(), vel.end(), 0); + + for(size_t j = 0; j < Desc::Q; ++j){ + rho += dfs(j).get(); + for(size_t i = 0; i < Desc::D; ++i){ + vel[i] += dfi::directions[j][i] * dfs(j).get(); + } + } + + for(size_t i = 0; i < Desc::D; ++i){ + vel[i] /= rho; + } +} +} +} -- cgit v1.2.3