From 595cdfd51594af7cee4258a1ed92b06c6bf0171d Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 11 Feb 2026 17:27:59 +0100 Subject: Fixing --- lib/core/c++/hlbm.hpp | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'lib/core/c++/hlbm.hpp') diff --git a/lib/core/c++/hlbm.hpp b/lib/core/c++/hlbm.hpp index f8f0118..8f267d5 100644 --- a/lib/core/c++/hlbm.hpp +++ b/lib/core/c++/hlbm.hpp @@ -14,16 +14,49 @@ struct HLBM {}; * HLBM collision operator for LBM */ template -class component { +class component final { private: + typename saw::native_data_type::type relaxation_; + saw::data frequency_; public: - component() = default; + component(typename saw::native_data_type::type relaxation__): + relaxation_{relaxation__}, + frequency_{typename saw::native_data_type::type(1) / relaxation_} + {} template void apply(const saw::data& field, const saw::data& macros, saw::data> index, saw::data time_step) const { bool is_even = ((time_step.get() % 2) == 0); + auto& dfs_old_f = (is_even) ? field.template get<"dfs_old">() : field.template get<"dfs">(); + auto& particle_N_f = field.template get<"particle_N">(); + auto& particle_D_f = field.template get<"particle_D">(); + + auto& porosity_f = macros.template get<"porosity">(); + auto& rho_f = macros.template get<"density">(); + auto& vel_f = macros.template get<"velocity">(); + + saw::data>& rho = rho_f.at(index); + saw::data> vel = vel_f.at(index); + + compute_rho_u(dfs_old_f.at(index), rho, vel); + + auto& porosity = porosity_f.at(index); + auto flip_porosity = saw::data>{1.0} - porosity; + + auto& N = particle_N_f.at(index); + auto& D = particle_D_f.at(index); + // Convex combination of velocities + vel = vel * flip_porosity + N * porosity / D; + // Equilibrium + auto eq = equilibrium(rho,vel); + + for(uint64_t i = 0u; i < Descriptor::Q; ++i){ + dfs_old_f.at(index).at({i}) = dfs_old_f.at(index).at({i}) + frequency_ * (eq.at(i) - dfs_old_f.at(index).at({i})); + } + + porosity.at({}) = 1.0; } }; -- cgit v1.2.3