From c0549d71b2109f10c1238db8b22362e7826ba61b Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sun, 5 Jul 2026 15:59:23 +0200 Subject: Just rename from lib to modules --- modules/core/c++/equilibrium.hpp | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 modules/core/c++/equilibrium.hpp (limited to 'modules/core/c++/equilibrium.hpp') diff --git a/modules/core/c++/equilibrium.hpp b/modules/core/c++/equilibrium.hpp new file mode 100644 index 0000000..eb2b043 --- /dev/null +++ b/modules/core/c++/equilibrium.hpp @@ -0,0 +1,50 @@ +#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; + // Brain broken, here's an owl + // ^ + // 0.0 + // / \ + // | | + // + // Velocity * Velocity meaning || vel ||_2^2 or _2 + saw::data vel_vel{0.0}; + for(uint64_t j = 0u; j < Descriptor::D; ++j){ + vel_vel = vel_vel + vel.at({{j}}) * vel.at({{j}}); + } + + /** + * Calculate equilibrium + */ + for(uint64_t i = 0u; i < Descriptor::Q; ++i){ + saw::data vel_c{}; + for(uint64_t j = 0u; j < Descriptor::D; ++j){ + // _2 + vel_c = vel_c + (vel.at({{j}}) * saw::data{static_cast::type>(dfi::directions[i][j])}); + } + + auto vel_c_cs2 = vel_c * saw::data{dfi::inv_cs2}; + + eq.at(i).set( + dfi::weights[i] * rho.at({}).get() * + ( + 1.0 + + vel_c_cs2.get() + - dfi::inv_cs2 * 0.5 * vel_vel.get() + + vel_c_cs2.get() * vel_c_cs2.get() * 0.5 + ) + ); + } + + return eq; +} +} +} -- cgit v1.2.3