From bff15d076515b93621a66fe93f58d4d3221c23c7 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 12 Aug 2026 09:49:29 +0200 Subject: Preparing cleanup of boundarz and yesterdays changes --- modules/core/c++/boundary.hpp | 58 ++++++++++++++++++++++++++++++++++-- modules/core/c++/boundary/common.hpp | 8 +++++ modules/core/c++/fplbm.hpp | 2 +- 3 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 modules/core/c++/boundary/common.hpp (limited to 'modules') diff --git a/modules/core/c++/boundary.hpp b/modules/core/c++/boundary.hpp index 22a6f34..ae53c04 100644 --- a/modules/core/c++/boundary.hpp +++ b/modules/core/c++/boundary.hpp @@ -169,8 +169,8 @@ public: * 0 - 2 - 2 * */ -template -class component, Encode> final { +template +class component, cmpt::ZouHeHorizontal, Encode> final { private: saw::data rho_setting_; public: @@ -179,7 +179,7 @@ public: {} template - void apply(const saw::data& field, saw::data> index, saw::data time_step) const { + void apply(const saw::data& field, saw::data> index, saw::data time_step) const { using dfi = df_info; bool is_even = ((time_step.get() % 2) == 0); @@ -207,6 +207,58 @@ public: return {}; }(); + // static_assert(Descriptor::D == 2u and Descriptor::Q == 9u, "Some parts are hard coded sadly"); + + if constexpr (Dir) { + dfs_old.at({2u}) = dfs_old.at({1u}) + saw::data{2.0 / 3.0} * rho_vel_x; + dfs_old.at({6u}) = dfs_old.at({5u}) + saw::data{1.0 / 6.0} * rho_vel_x + saw::data{0.5} * (dfs_old.at({3u}) - dfs_old.at({4u})); + dfs_old.at({8u}) = dfs_old.at({7u}) + saw::data{1.0 / 6.0} * rho_vel_x + saw::data{0.5} * (dfs_old.at({4u}) - dfs_old.at({3u})); + }else if constexpr (not Dir){ + dfs_old.at({1u}) = dfs_old.at({2u}) - saw::data{2.0 / 3.0} * rho_vel_x; + dfs_old.at({5u}) = dfs_old.at({6u}) - saw::data{1.0 / 6.0} * rho_vel_x + saw::data{0.5} * (dfs_old.at({4u}) - dfs_old.at({3u})); + dfs_old.at({7u}) = dfs_old.at({8u}) - saw::data{1.0 / 6.0} * rho_vel_x + saw::data{0.5} * (dfs_old.at({3u}) - dfs_old.at({4u})); + } + } +}; + +template +class component, cmpt::ZouHeHorizontal, Encode> final { +private: + saw::data rho_setting_; +public: + component(const saw::data& rho_setting__): + rho_setting_{rho_setting__} + {} + + template + void apply(const saw::data& field, saw::data> index, saw::data time_step) const { + using dfi = df_info; + + bool is_even = ((time_step.get() % 2) == 0); + + auto& info_f = field.template get<"info">(); + + // auto& dfs_f = (is_even) ? field.template get<"dfs">() : field.template get<"dfs_old">(); + auto& dfs_old_f = (is_even) ? field.template get<"dfs_old">() : field.template get<"dfs">(); + + auto& dfs_old = dfs_old_f.at(index); + + auto rho_vel_x = [&]() -> saw::data { + if constexpr (Dir){ + auto S = dfs_old.at({0u}) + + dfs_old.at({3u}) + dfs_old.at({4u}) + + (dfs_old.at({1u}) + dfs_old.at({5u}) + dfs_old.at({7u})) * 2u; + return rho_setting_ - S; + } + else if constexpr (not Dir) { + auto S = dfs_old.at({0u}) + + dfs_old.at({3u}) + dfs_old.at({4u}) + + (dfs_old.at({2u}) + dfs_old.at({6u}) + dfs_old.at({8u})) * 2u; + return S - rho_setting_; + } + return {}; + }(); + static_assert(Descriptor::D == 2u and Descriptor::Q == 9u, "Some parts are hard coded sadly"); if constexpr (Dir) { diff --git a/modules/core/c++/boundary/common.hpp b/modules/core/c++/boundary/common.hpp new file mode 100644 index 0000000..3feb451 --- /dev/null +++ b/modules/core/c++/boundary/common.hpp @@ -0,0 +1,8 @@ +#pragma once + +#include "../common.hpp" + +namespace kel { +namespace lbm { +} +} diff --git a/modules/core/c++/fplbm.hpp b/modules/core/c++/fplbm.hpp index 37074b0..e2527ce 100644 --- a/modules/core/c++/fplbm.hpp +++ b/modules/core/c++/fplbm.hpp @@ -204,7 +204,7 @@ public: // vel_s is technically time the density of the particle? - force = ( vel_s * rho - vel * rho ) * two * flip_por; + force = ( vel_s * rho - vel * rho ) /* two */ * flip_por; force_p = force_p - force; }, aabb.template get<"a">(), aabb.template get<"b">()); -- cgit v1.2.3