From 761e4912e14324ccf713b9309336816cd3283b38 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 1 Jul 2026 00:15:10 +0200 Subject: stokes drag impl and run --- examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp | 58 ++++++++++++++--------- 1 file changed, 35 insertions(+), 23 deletions(-) (limited to 'examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp') diff --git a/examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp b/examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp index 81498e2..18b5258 100644 --- a/examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp +++ b/examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp @@ -47,8 +47,8 @@ using RhoChunk = Chunk, 0u, dim_x, dim_y>; template using MacroStruct = Struct< Member, "velocity">, - Member, "force">, Member, "density">, + Member, "force">, Member, "porosity"> >; @@ -100,7 +100,6 @@ saw::error_or setup_initial_conditions( {{dim_x-1u,0u}}, {{dim_x, dim_y}} ); - // Overwrite with // Inflow iterator::apply( [&](auto& index){ @@ -158,7 +157,28 @@ saw::error_or setup_initial_conditions( df_f.get_dims(), {{1u,1u}} ); - + + /* + iterator::apply( + [&](auto& index){ + saw::data> middle, ind_vec; + middle.at({{0u}}) = dim_x * 0.25; + middle.at({{1u}}) = dim_y * 0.5; + + ind_vec.at({{0u}}) = index.at({{0u}}).template cast_to(); + ind_vec.at({{1u}}) = index.at({{1u}}).template cast_to(); + + auto dist = middle - ind_vec; + auto dist_2 = saw::math::dot(dist,dist); + if(dist_2.at({}).get() < dim_y*dim_y*0.01){ + porous_f.at(index).at({}) = 0.0; + } + }, + {},// 0-index + df_f.get_dims() + ); + */ + return saw::make_void(); } @@ -173,7 +193,9 @@ saw::error_or step( auto& info_f = fields.template get<"info">(); auto& porous_f = macros.template get<"porosity">(); + // auto coll_ev = q.submit([&](acpp::sycl::handler& h){ + component> bgk{0.8}; component> collision{0.8}; component> bb; component,encode::Sycl> abb; @@ -181,13 +203,15 @@ saw::error_or step( saw::data> eps; eps.at({}).set(1.5f); saw::data> rad; - rad.at({}).set(dim_y*0.1*0.25); + rad.at({}).set(dim_y*0.1/4.0); saw::data> p_pos; { p_pos.at({{0u}}) = dim_x * 0.5; p_pos.at({{1u}}) = dim_y * 0.5; } component> opa{p_pos,rad,eps}; + + component> fg; component,encode::Sycl> flow_in{ [&](){ @@ -218,21 +242,20 @@ saw::error_or step( case 2u: opa.apply(macros,index,t_i); collision.apply(fields,macros,index,t_i); + fg.apply(fields,macros,index,t_i); break; case 3u: flow_in.apply(fields,index,t_i); - //equi.apply(fields,index,t_i); - collision.apply(fields,macros,index,t_i); + // equi.apply(fields,index,t_i); + bgk.apply(fields,macros,index,t_i); break; case 4u: flow_out.apply(fields,index,t_i); // equi.apply(fields,index,t_i); - collision.apply(fields,macros,index,t_i); - break; + bgk.apply(fields,macros,index,t_i); + break; case 5u: - // Corners bb.apply(fields,index,t_i); - break; default: break; } @@ -342,9 +365,7 @@ saw::error_or lbm_main(int argc, char** argv){ sycl_q.wait(); auto lsd_view = make_view(lbm_sycl_data); auto lsdm_view = make_view(lbm_sycl_macro_data); - saw::data time_steps{16u*4096ul}; - auto& info_f = lsd_view.template get<"info">(); for(saw::data i{0u}; i < time_steps and krun; ++i){ @@ -356,8 +377,7 @@ saw::error_or lbm_main(int argc, char** argv){ } } sycl_q.wait(); - /* - if(i.get() % 32u == 0u){ + if(i.get() % 32u == 0u){ { auto eov = dev.copy_to_host(lbm_sycl_macro_data,*lbm_macro_data_ptr); if(eov.is_error()){ @@ -365,14 +385,12 @@ saw::error_or lbm_main(int argc, char** argv){ } } { - auto eov = write_vtk_file(out_dir,"m",i.get(), *lbm_macro_data_ptr); + auto eov = write_csv_file(out_dir,"m",i.get(), *lbm_macro_data_ptr); if(eov.is_error()){ return eov; } } } - */ - // Stream sycl_q.submit([&](acpp::sycl::handler& h){ component> stream; @@ -412,12 +430,6 @@ saw::error_or lbm_main(int argc, char** argv){ return eov; } } - { - auto eov = write_csv_file(out_dir,"m",time_steps.get(), *lbm_macro_data_ptr); - if(eov.is_error()){ - return eov; - } - } sycl_q.wait(); return saw::make_void(); -- cgit v1.2.3