From e7f5a1110bfafcd605b9330f9c7d3f5147298ed3 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 2 Apr 2025 23:36:32 +0200 Subject: Reworking the current structure --- c++/equilibrium.hpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 c++/equilibrium.hpp (limited to 'c++/equilibrium.hpp') diff --git a/c++/equilibrium.hpp b/c++/equilibrium.hpp new file mode 100644 index 0000000..8342ed4 --- /dev/null +++ b/c++/equilibrium.hpp @@ -0,0 +1,39 @@ +#pragma once + +#include "descriptor.hpp" + +namespace kel { +namespace lbm { +template +saw::data> equilibrium(saw::data rho, saw::data> vel){ + using dfi = df_info; + + saw::data> eq; + saw::data vel_vel{}; + for(uint64_t j = 0u; j < Descriptor::D; ++j){ + vel_vel = vel_vel + vel.at(j) * vel.at(j); + } + + for(uint64_t i = 0u; i < eq.get_dim_size<0u>(); ++i){ + saw::data vel_c{}; + for(uint64_t j = 0u; j < Descriptor::D; ++j){ + vel_c = vel_c + (vel.at(j) * {dfi::directions[i][j]}); + } + + auto vel_c_cs2 = vel_c * {dfi::inv_cs2}; + + eq.at(i).set( + dfi::weights[i] * rho.get() * + ( + 1.0 + + vel_c_cs2 + - dfi::inv_cs2 * 0.5 * vel_vel.get() + + vel_c_cs2 * vel_c_cs2 * 0.5 + ) + ); + + return eq; + } +} +} +} -- cgit v1.2.3