From 5a166a02efe011931faa7a9ff9fe4043e3a8017a Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Mon, 23 Jun 2025 16:12:27 +0200 Subject: Upgrading the cavity example --- examples/cavity_2d.cpp | 43 ++++++++----------------------------------- 1 file changed, 8 insertions(+), 35 deletions(-) (limited to 'examples/cavity_2d.cpp') diff --git a/examples/cavity_2d.cpp b/examples/cavity_2d.cpp index a10276a..654a9ac 100644 --- a/examples/cavity_2d.cpp +++ b/examples/cavity_2d.cpp @@ -1,6 +1,7 @@ #include "../c++/descriptor.hpp" #include "../c++/macroscopic.hpp" #include "../c++/lbm.hpp" +#include "../c++/component.hpp" /** */ @@ -79,14 +80,6 @@ std::array::type,Desc::Q> equilibrium( return eq; } -/** - * A reason for why a component based design is really good can be seen in my LR solver example - * - * Add Expression Templates and you're golden. - */ -template -class component; - /* template class df_cell_view; @@ -122,7 +115,7 @@ struct ConstRhoBGK {}; * Full-Way BounceBack. I suspect that the moving wall requires half-way bounce back. */ template -class component { +class component { public: void apply(saw::data>& dfs){ @@ -142,7 +135,7 @@ public: * Technically it should reflect properly. */ template -class component { +class component { public: std::array::type, Desc::D> lid_vel; @@ -164,7 +157,7 @@ public: }; template -class component { +class component { public: typename saw::native_data_type::type relaxation_; public: @@ -179,23 +172,6 @@ public: } } }; - -template -class component { -public: - typename saw::native_data_type::type relaxation_; - typename saw::native_data_type::type rho_; -public: - void apply(saw::data>& dfs){ - std::array::type, Desc::D> vel; - compute_const_rho_u(dfs,rho_,vel); - auto eq = equilibrium(rho_,vel); - - for(uint64_t i = 0u; i < Desc::Q; ++i){ - dfs({i}).set(dfs({i}).get() + (1.0 / relaxation_) * (eq[i] - dfs({i}).get())); - } - } -}; } } @@ -284,14 +260,11 @@ void lbm_step( using namespace kel::lbm; using dfi = df_info; - component coll; + component coll; coll.relaxation_ = 0.5384; - component rho_coll; - rho_coll.relaxation_ = 0.5384; - rho_coll.rho_ = 1.0; - component bb; - component bb_lid; + component bb; + component bb_lid; bb_lid.lid_vel = {0.1,0.0}; // Collide @@ -505,7 +478,7 @@ int main(){ lbm_step(lattice, even_step); - even_step = !even_step; + even_step = not even_step; } /** -- cgit v1.2.3