#pragma once #include "descriptor.hpp" namespace kel { namespace lbm { /** * 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().at({}).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().at({}) = rho().at({}) + dfs.at({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.at({j}); } } for(size_t i = 0; i < Desc::D; ++i){ vel().at({{i}}) = vel().at({{i}}) / rho().at({}); } } } }