From a7420c5f5f56bb21de0241ed152ad9b55965d42d Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Fri, 30 Jan 2026 19:08:54 +0100 Subject: Simulation works partially. Reconfirm with writing data out --- examples/poiseulle_particles_2d_gpu/sim.cpp | 52 ++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 4 deletions(-) (limited to 'examples') diff --git a/examples/poiseulle_particles_2d_gpu/sim.cpp b/examples/poiseulle_particles_2d_gpu/sim.cpp index fc9fc61..e655315 100644 --- a/examples/poiseulle_particles_2d_gpu/sim.cpp +++ b/examples/poiseulle_particles_2d_gpu/sim.cpp @@ -32,7 +32,7 @@ saw::error_or setup_initial_conditions(saw::data> // Set everything as walls iterator::apply( [&](auto& index){ - info_f.at(index).set(2u); + info_f.at(index).set(1u); }, {}, info_f.get_dims(), @@ -41,7 +41,7 @@ saw::error_or setup_initial_conditions(saw::data> // Fluid iterator::apply( [&](auto& index){ - info_f.at(index).set(1u); + info_f.at(index).set(2u); }, {}, info_f.get_dims(), @@ -91,15 +91,59 @@ saw::error_or step(saw::data>,encode::Sy auto& q = dev.get_handle(); auto& info_f = fields.template get<"info">(); + // auto coll_ev = q.submit([&](acpp::sycl::handler& h){ + // Need nicer things to handle the flow. I see improvement here component> collision{0.6}; + component> bb; + component,encode::Sycl> flow_in{1.01}; + component,encode::Sycl> flow_out{1.0}; + h.parallel_for(acpp::sycl::range{dim_x,dim_y}, [=](acpp::sycl::id idx){ saw::data> index; for(uint64_t i = 0u; i < Desc::D; ++i){ index.at({{i}}).set(idx[i]); } - collision.apply(fields,index,t_i); + auto info = info_f.at(index); + + switch(info.get()){ + case 0u: + break; + case 1u: + bb.apply(fields,index,t_i); + break; + case 2u: + collision.apply(fields,index,t_i); + break; + case 3u: + flow_in.apply(fields,index,t_i); + collision.apply(fields,index,t_i); + break; + case 4u: + flow_out.apply(fields,index,t_i); + collision.apply(fields,index,t_i); + break; + default: + break; + } + }); + }).wait(); + + q.submit([&](acpp::sycl::handler& h){ + component> stream; + + h.parallel_for(acpp::sycl::range{dim_x,dim_y}, [=](acpp::sycl::id idx){ + saw::data> index; + for(uint64_t i = 0u; i < Desc::D; ++i){ + index.at({{i}}).set(idx[i]); + } + + auto info = info_f.at(index); + + if(info.get() > 0u){ + stream.apply(fields,index,t_i); + } }); }).wait(); @@ -155,7 +199,7 @@ saw::error_or lbm_main(int argc, char** argv){ } sycl_q.wait(); - for(saw::data i{0u}; i < saw::data{32ul}; ++i){ + for(saw::data i{0u}; i < saw::data{1024ul}; ++i){ auto eov = step(lsd_view,i,dev); if(eov.is_error()){ return eov; -- cgit v1.2.3