From 7abcc7c96ce891128858089e34afc2e986b1ab19 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Mon, 3 Mar 2025 14:01:10 +0100 Subject: wip --- c++/examples/cavity_2d.cpp | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) (limited to 'c++/examples') diff --git a/c++/examples/cavity_2d.cpp b/c++/examples/cavity_2d.cpp index aaf6ba3..90799ad 100644 --- a/c++/examples/cavity_2d.cpp +++ b/c++/examples/cavity_2d.cpp @@ -6,7 +6,8 @@ namespace kel { namespace lbm { -namespace schema { +namespace sch { +using namespace saw::schema; /** * Basic distribution function @@ -18,6 +19,7 @@ namespace schema { * Q factor */ using T = Float32; +using D2Q5 = Descriptor<2,5>; using DfCell2D = Field; using CellInfo2D = Field; @@ -34,7 +36,7 @@ using Cell = CellData< template struct cell_type { - using Type = schema::Field; + using Type = sch::Field; }; template @@ -44,11 +46,11 @@ class df_cell_view; * Minor helper for the AA-Pull Pattern */ template -class df_cell_view> { +class df_cell_view> { private: - std::array::type>*, QN> view_; + std::array::type>*, QN> view_; public: - df_cell_view(const std::array::type>*, QN>& view): + df_cell_view(const std::array::type>*, QN>& view): view_{view} {} }; @@ -56,15 +58,15 @@ public: template class collision { public: - typename saw::native_data_type::type relaxation_; + typename saw::native_data_type::type relaxation_; public: - std::array::type,Desc::Q> equilibrium( - typename saw::native_data_type::type rho, - std::array::type, Desc::D> vel + std::array::type,Desc::Q> equilibrium( + typename saw::native_data_type::type rho, + std::array::type, Desc::D> vel ){ - using dfi = df_info; + using dfi = df_info; - typename std::array::type,Desc::Q> eq; + typename std::array::type,Desc::Q> eq; for(std::size_t i = 0; i < eq.size(); ++i){ auto vel_c = (vel[0]*dfi::directions[i][0] + vel[1]*dfi::directions[i][1]); @@ -82,15 +84,15 @@ public: void compute_rho_u( saw::data& dfs, - typename saw::native_data_type::type& rho, - std::array::type, 2>& vel + typename saw::native_data_type::type& rho, + std::array::type, 2>& vel ){ - using dfi = df_info>; + using dfi = df_info; rho = 0; std::fill(vel.begin(), vel.end(), 0); - for(size_t i = 0; i < Q; ++i){ + for(size_t i = 0; i < Desc::Q; ++i){ rho += dfs.at(i).get(); vel[0] += dfi::directions[i][0] * dfs.at(i).get(); vel[1] += dfi::directions[i][1] * dfs.at(i).get(); @@ -120,7 +122,7 @@ struct rectangle { }; template -void apply_for_cells(Func&& func, saw::data>& dat){ +void apply_for_cells(Func&& func, saw::data>& dat){ for(std::size_t i = 0; i < dat.get_dim_size(0); ++i){ for(std::size_t j = 0; j < dat.get_dim_size(1); ++j){ func(dat.at(i,j), i, j); @@ -128,7 +130,7 @@ void apply_for_cells(Func&& func, saw::data>& da } } -void set_geometry(saw::data>& latt){ +void set_geometry(saw::data>& latt){ using namespace kel::lbm; apply_for_cells([](auto& cell, std::size_t i, std::size_t j){ uint8_t val = 0; @@ -145,7 +147,7 @@ void set_geometry(saw::data> }, latt); } -void set_initial_conditions(saw::data>& latt){ +void set_initial_conditions(saw::data>& latt){ using namespace kel::lbm; apply_for_cells([](auto& cell, std::size_t i, std::size_t j){ (void) i; @@ -155,8 +157,8 @@ void set_initial_conditions(saw::data>& old_latt, - saw::data>& new_latt + saw::data>& old_latt, + saw::data>& new_latt ){ } @@ -165,8 +167,8 @@ int main(){ using namespace kel::lbm; saw::data< - schema::FixedArray< - schema::Lattice, 2 + sch::FixedArray< + sch::Lattice, 2 > ,saw::encode::Native > lattices; //{dim_x, dim_y}; -- cgit v1.2.3