From 530bd236a0aee9c22b87de236164c59afe6adae7 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sat, 25 Jul 2026 23:17:18 +0200 Subject: dangling --- modules/core/c++/hlbm.hpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'modules') diff --git a/modules/core/c++/hlbm.hpp b/modules/core/c++/hlbm.hpp index bb21ae5..fc19728 100644 --- a/modules/core/c++/hlbm.hpp +++ b/modules/core/c++/hlbm.hpp @@ -17,6 +17,9 @@ struct HlbmOneParticle {}; struct HlbmParticle {}; struct HlbmOneParticleMomentumExchange {}; } +namespace method { +struct Hlbm {}; +} template class component final { -- cgit v1.2.3 From a826f7d9d4bb48565036dd665cb4c6a54622010d Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Mon, 27 Jul 2026 21:53:27 +0200 Subject: Dangling --- modules/core/c++/fplbm.hpp | 117 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) (limited to 'modules') diff --git a/modules/core/c++/fplbm.hpp b/modules/core/c++/fplbm.hpp index c974472..34806aa 100644 --- a/modules/core/c++/fplbm.hpp +++ b/modules/core/c++/fplbm.hpp @@ -5,9 +5,31 @@ namespace kel { namespace lbm { namespace cmpt { +struct FpLbmReset{}; struct FpLbm {}; +struct FpLbmOneParticle {}; struct FpLbmOneParticleNoVelocity{}; } +namespace method { +struct FpLbm {}; +} + +template +class component final { +public: + using Component = cmpt::FpLbmReset; +private: +public: + component() = default; + + template + void apply(const saw::data& field, const saw::data& macros, saw::data> index, saw::data time_step) const { + auto& por_f = macros.template get<"porosity">(); + + auto& por = por_f.at(index); + por.at({}) = 1.0; + } +}; template class component final { @@ -84,6 +106,101 @@ public: } }; +template +class component final { +public: + using Component = cmpt::FpLbmOneParticle; +private: +public: + component() = default; + + template + void apply(const saw::data& field, const saw::data& macros, saw::data> index, saw::data time_step) const { + // void apply(saw::data& field, saw::data> index, saw::data time_step){ + bool is_even = ((time_step.get() % 2) == 0); + + auto& dfs_old_f = (is_even) ? field.template get<"dfs_old">() : field.template get<"dfs">(); + auto& dfs = dfs_old_f.at(index); + + auto& rho_f = macros.template get<"density">(); + auto& vel_f = macros.template get<"velocity">(); + auto& por_f = macros.template get<"porosity">(); + + // Temporary find a better way + auto& force_f = macros.template get<"force">(); + + + /** + * The other methods all work with a flipped porosity. + * For compat reasons this is also flipped + */ + auto porosity = por_f.at(index); + saw::data> one; + one.at({}) = 1.0; + auto flip_porosity = one - porosity; + + saw::data>& rho = rho_f.at(index); + + saw::data> half; + half.at({}).set(0.5); + saw::data>& vel = vel_f.at(index);// + total_force * ( half / rho ); + + compute_rho_u(dfs_old_f.at(index),rho,vel); + auto eq = equilibrium(rho,vel); + + using dfi = df_info; + + saw::data> min_two; + min_two.at({}).set(-2); + + // Maybe ? + auto& force = force_f.at(index); + force = vel * rho * min_two * flip_porosity; + + saw::data> dfi_inv_cs2; + dfi_inv_cs2.at({}).set(dfi::inv_cs2); + + // auto vel = vel_f.at(index); + + for(uint64_t i = 0u; i < Descriptor::Q; ++i){ + // saw::data ci_min_u{0}; + saw::data> ci; + for(uint64_t d = 0u; d < Descriptor::D; ++d){ + ci.at({{d}}).set(static_cast::type>(dfi::directions[i][d])); + } + auto ci_dot_u = saw::math::dot(ci,vel); + + // saw::data> F_i; + // F_i = f * ((c_i - u) * ics2 + * c_i * ics2 * ics2) * w_i; + saw::data> w; + w.at({}).set(dfi::weights[i]); + + /* + saw::data> F_i_sum; + for(uint64_t d = 0u; d < Descriptor::D; ++d){ + saw::data> F_i_d; + F_i_d.at({}) = F_i.at({{d}}); + F_i_sum = F_i_sum + F_i_d; + } + */ + auto term1 = (ci-vel) * dfi_inv_cs2; + auto term2 = ci * (ci_dot_u * dfi_inv_cs2 * dfi_inv_cs2); + + auto force_projection = saw::math::dot(term1 + term2, force); + + auto F_i = w * force_projection; + + dfs.at({i}) = dfs.at({i}) + + frequency_ + * (eq.at(i) - dfs.at({i}) ) + + F_i.at({}) + * (saw::data{1} - saw::data{0.5f} * frequency_); + } + } + + +}; + template class component final { private: -- cgit v1.2.3