From 5be771eb356263bf43c57056eba77df7235c78f4 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Fri, 27 Jun 2025 21:27:20 +0200 Subject: Fixing things --- examples/cavity_2d.cpp | 26 ---------------------- examples/poiseulle_2d.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 52 insertions(+), 30 deletions(-) diff --git a/examples/cavity_2d.cpp b/examples/cavity_2d.cpp index 6ecdb23..6332bcf 100644 --- a/examples/cavity_2d.cpp +++ b/examples/cavity_2d.cpp @@ -52,33 +52,7 @@ using MacroStruct = Struct< >; using CavityFieldD2Q9 = CellField>; -} - -/** - * Calculates the equilibrium for each direction - */ -template -std::array::type,Desc::Q> equilibrium( - typename saw::native_data_type::type rho, - const std::array::type, Desc::D>& vel -){ - using dfi = df_info; - - typename std::array::type,Desc::Q> eq; - - for(std::size_t i = 0u; i < eq.size(); ++i){ - auto vel_c = (vel[0u]*dfi::directions[i][0u] + vel[1u]*dfi::directions[i][1u]); - auto vel_c_cs2 = vel_c * dfi::inv_cs2; - eq[i] = dfi::weights[i] * rho * ( - 1.0 - + vel_c_cs2 - - dfi::inv_cs2 * 0.5 * ( vel[0u] * vel[0u] + vel[1u] * vel[1u] ) - + vel_c_cs2 * vel_c_cs2 * 0.5 - ); - } - return eq; -} /* template diff --git a/examples/poiseulle_2d.cpp b/examples/poiseulle_2d.cpp index 0ec4fc0..2f60ffd 100644 --- a/examples/poiseulle_2d.cpp +++ b/examples/poiseulle_2d.cpp @@ -44,6 +44,55 @@ using CavityFieldD2Q9 = CellField>; } } +void set_geometry(saw::data& latt){ + using namespace kel::lbm; + + auto meta = latt.meta(); + for(saw::data i{0u}; i < meta.at(0u); ++i){ + for(saw::data j{0u}; j < meta.at(1u); ++j ){ + auto& cell = latt({{i,j}}); + auto& info = cell.template get<"info">(); + + + } + } + +} + +void set_initial_conditions(saw::data& latt){ + using namespace kel::lbm; + + typename saw::native_data_type::type rho = 1.0; + auto meta = latt.meta(); + + // Collide + for(saw::data i{0u}; i < meta.at(0u); ++i){ + for(saw::data j{0u}; j < meta.at(1u); ++j ){ + auto& cell = latt({{i,j}}); + auto& info = cell.template get<"info">(); + + } + } + /* + { + std::array::type, sch::D2Q9::D> vel = {0.0, 0.0}; + auto eq = equilibrium(rho, vel); + + apply_for_cells([&eq](auto& cell, std::size_t i, std::size_t j){ + (void) i; + (void) j; + auto& dfs = cell.template get<"dfs">(); + auto& dfs_old = cell.template get<"dfs_old">(); + auto info = cell.template get<"info">()(0u).get(); + for(uint64_t k = 0; k < sch::D2Q9::Q; ++k){ + dfs(k).set(eq[k]); + dfs_old(k).set(eq[k]); + } + }, latt); + } + */ +} + int main(int argc, char** argv){ using namespace kel::lbm; @@ -52,7 +101,7 @@ int main(int argc, char** argv){ cfg_file_name = argv[1]; } - auto eo_conf = load_lbm_config>(cfg_file_name); + auto eo_conf = load_lbm_config>(cfg_file_name); if(eo_conf.is_error()){ auto& err = eo_conf.get_error(); std::cerr<<"[Error]: "<()} }; - print_lbm_meta>(conv, {conf.template get<"kinematic_viscosity">()}); - - saw::data> dim{{128, 128}}; + print_lbm_meta>(conv, {conf.template get<"kinematic_viscosity">()}); + saw::data> dim{{1024, 128}}; saw::data lattice{dim}; return 0; -- cgit v1.2.3