blob: 19ab3e9463e5a86b5fd2002fad6596ce8926698b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#pragma once
#include "descriptor.hpp"
namespace kel {
namespace lbm {
/**
* Calculate the macroscopic variables rho and u in Lattice Units.
*/
template<typename T, typename Desc>
void compute_rho_u (
const saw::data<sch::FixedArray<T,Desc::Q>>& dfs,
saw::ref<saw::data<sch::Scalar<T>>> rho,
saw::ref<saw::data<sch::Vector<T,Desc::D>>> vel
)
{
using dfi = df_info<T, Desc>;
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<T>{static_cast<typename saw::native_data_type<T>::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({});
}
}
}
}
|