diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2025-06-27 10:00:10 +0200 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2025-06-27 10:00:10 +0200 |
commit | bffab324ca4d71c0eacb2389f1441638ac465b2e (patch) | |
tree | 27261440a161d52429e8f74bea82359c7d7d58f1 | |
parent | 7e4d50062f0d5eec2f59d4113beedf282c3e2da4 (diff) |
Moving towards poiseulle
-rw-r--r-- | c++/lbm.hpp | 1 | ||||
-rw-r--r-- | examples/cavity_2d.cpp | 19 | ||||
-rw-r--r-- | examples/particle_ibm.cpp | 94 | ||||
-rw-r--r-- | examples/poiseulle_2d.cpp | 12 |
4 files changed, 8 insertions, 118 deletions
diff --git a/c++/lbm.hpp b/c++/lbm.hpp index e5799b5..3f46776 100644 --- a/c++/lbm.hpp +++ b/c++/lbm.hpp @@ -3,6 +3,7 @@ #include "descriptor.hpp" #include "converter.hpp" #include "config.hpp" +#include "component.hpp" #include "write_vtk.hpp" #include <forstio/codec/unit/unit_print.hpp> diff --git a/examples/cavity_2d.cpp b/examples/cavity_2d.cpp index 2860674..6ecdb23 100644 --- a/examples/cavity_2d.cpp +++ b/examples/cavity_2d.cpp @@ -105,25 +105,8 @@ 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. @@ -244,8 +227,6 @@ 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}; diff --git a/examples/particle_ibm.cpp b/examples/particle_ibm.cpp index 0ce034e..d54dbdc 100644 --- a/examples/particle_ibm.cpp +++ b/examples/particle_ibm.cpp @@ -49,100 +49,6 @@ using MacroStruct = Struct< using CavityFieldD2Q9 = CellField<D2Q9, CellStruct<D2Q9>>; } -namespace cmpt { -struct BounceBack{}; -struct MovingWall {}; -struct BGK {}; -struct ConstRhoBGK {}; -} - -/** - * 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<typename Kind, typename Desc> -class component; - -/** - * Full-Way BounceBack. I suspect that the moving wall requires half-way bounce back. - */ -template<typename Desc> -class component<cmpt::BounceBack,Desc> { -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. - */ -template<typename Desc> -class component<cmpt::MovingWall, Desc> { -public: - std::array<typename saw::native_data_type<sch::T>::type, Desc::D> lid_vel; - -public: - void apply( - saw::data<sch::DfCell<Desc>>& dfs - ){ - using dfi = df_info<sch::T,Desc>; - - // Technically use .copy() - /* - auto dfs_cpy = dfs; - - for(uint64_t i = 0u; i < Desc::Q; ++i){ - dfs({dfi::opposite_index.at(i)}) = dfs_cpy({i}) - 2.0 * dfi::weights[i] * 1.0 * ( lid_vel[0] * dfi::directions[i][0] + lid_vel[1] * dfi::directions[i][1]) * dfi::inv_cs2; - } - */ - } -}; - -template<typename Desc> -class component<cmpt::BGK, Desc> { -public: - typename saw::native_data_type<sch::T>::type relaxation_; -public: - void apply(saw::data<sch::DfCell<Desc>>& dfs){ - typename saw::native_data_type<sch::T>::type rho; - std::array<typename saw::native_data_type<sch::T>::type, Desc::D> vel; - compute_rho_u<sch::T,Desc>(dfs,rho,vel); - auto eq = equilibrium<Desc>(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())); - } - } -}; - -template<typename Desc> -class component<cmpt::ConstRhoBGK, Desc> { -public: - typename saw::native_data_type<sch::T>::type relaxation_; - typename saw::native_data_type<sch::T>::type rho_; -public: - void apply(saw::data<sch::DfCell<Desc>>& dfs){ - std::array<typename saw::native_data_type<sch::T>::type, Desc::D> vel; - compute_const_rho_u<Desc>(dfs,rho_,vel); - auto eq = equilibrium<Desc>(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())); - } - } -}; - } } diff --git a/examples/poiseulle_2d.cpp b/examples/poiseulle_2d.cpp index f5a7981..0ec4fc0 100644 --- a/examples/poiseulle_2d.cpp +++ b/examples/poiseulle_2d.cpp @@ -1,4 +1,6 @@ -#include "../c++/descriptor.hpp" +#include "../c++/lbm.hpp" +#include "../c++/collision.hpp" +#include "../c++/boundary.hpp" #include <forstio/codec/data.hpp> @@ -17,14 +19,14 @@ using namespace saw::schema; * Q factor */ using T = Float32; -using D2Q5 = Descriptor<2,5>; -using D2Q9 = Descriptor<2,9>; +using D2Q5 = Descriptor<2u,5u>; +using D2Q9 = Descriptor<2u,9u>; template<typename Desc> -using DfCell = Cell<T, Desc, 0, 0, 1>; +using DfCell = Cell<T, Desc, 0u, 0u, 1u>; template<typename Desc> -using CellInfo = Cell<UInt8, D2Q9, 1, 0, 0>; +using CellInfo = Cell<UInt8, D2Q9, 1u, 0u, 0u>; /** * Basic type for simulation |