diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2025-06-25 18:21:43 +0200 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2025-06-25 18:21:43 +0200 |
commit | 3a1401dff3839ade801eb09598985d318e514350 (patch) | |
tree | 26a2f9e99532cac115ee3cd448b0801c657382bc | |
parent | 210b04098cfc12e0fdcff0578d39cc9ccafb3b37 (diff) |
Somethings broken and I don't know what
-rw-r--r-- | c++/collision.hpp | 7 | ||||
-rw-r--r-- | examples/cavity_2d.cpp | 36 |
2 files changed, 35 insertions, 8 deletions
diff --git a/c++/collision.hpp b/c++/collision.hpp index 451e4bb..4c28712 100644 --- a/c++/collision.hpp +++ b/c++/collision.hpp @@ -9,6 +9,9 @@ namespace cmpt { struct BGK {}; } +/** + * Standard BGK collision operator for LBM + */ template<typename T, typename Descriptor> class component<T, Descriptor, cmpt::BGK> { private: @@ -42,8 +45,8 @@ public: bool is_even = ((time_step % 2) == 0); auto& cell = field(index); - auto& dfs_old = is_even ? cell.template get<"dfs_old">() : cell.template get<"dfs">(); - auto& dfs = (!is_even) ? cell.template get<"dfs_old">() : cell.template get<"dfs">(); + auto& dfs_old = (is_even) ? cell.template get<"dfs_old">() : cell.template get<"dfs">(); + auto& dfs = (not is_even) ? cell.template get<"dfs_old">() : cell.template get<"dfs">(); saw::data<T> rho; saw::data<sch::FixedArray<T,Descriptor::D>> vel; diff --git a/examples/cavity_2d.cpp b/examples/cavity_2d.cpp index e2b28c9..ca291d3 100644 --- a/examples/cavity_2d.cpp +++ b/examples/cavity_2d.cpp @@ -105,8 +105,25 @@ public: */ namespace cmpt { struct MovingWall {}; +struct BBTwo {}; } +template<typename Desc> +class component<sch::T, Desc,cmpt::BBTwo> { +public: + + void apply(saw::data<sch::DfCell<Desc>>& dfs){ + using dfi = df_info<sch::T,Desc>; + + // Technically use .copy() + auto df_cpy = dfs; + + for(uint64_t i = 1u; i < Desc::Q; ++i){ + dfs({i}) = df_cpy({dfi::opposite_index.at(i)}); + } + } +}; + /** * Full-Way moving wall Bounce back, something is not right here. * Technically it should reflect properly. @@ -227,6 +244,8 @@ void lbm_step( component<sch::T, sch::D2Q9, cmpt::BGK> coll{0.5384}; component<sch::T, sch::D2Q9, cmpt::BounceBack> bb; + component<sch::T, sch::D2Q9, cmpt::BBTwo> bb_two; + component<sch::T, sch::D2Q9, cmpt::MovingWall> bb_lid; bb_lid.lid_vel = {0.1,0.0}; @@ -241,21 +260,26 @@ void lbm_step( switch(info({0u}).get()){ case 1u: { coll.apply(latt, {{i,j}}, time_step); - }; break; + break; + } case 2u: { auto& df = even_step ? cell.template get<"dfs_old">() : cell.template get<"dfs">(); - bb_lid.apply(df); - }; break; + // bb_lid.apply(df); + break; + } case 3u: { + auto& df = even_step ? cell.template get<"dfs_old">() : cell.template get<"dfs">(); + // bb_two.apply(df); bb.apply(latt, {{i,j}}, time_step); - }; break; + break; + } } } } // Stream - for(uint64_t i = 1; (i+1) < latt.template get_dim_size<0>().get(); ++i){ - for(uint64_t j = 1; (j+1) < latt.template get_dim_size<1>().get(); ++j){ + for(uint64_t i = 1u; (i+1u) < latt.template get_dim_size<0>().get(); ++i){ + for(uint64_t j = 1u; (j+1u) < latt.template get_dim_size<1>().get(); ++j){ auto& cell = latt({{i,j}}); auto& df_new = even_step ? cell.template get<"dfs">() : cell.template get<"dfs_old">(); auto& info_new = cell.template get<"info">(); |