From c59aeef2e0c86ec3f0f34ce77c205f3ef0b034cc Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sun, 8 Nov 2026 22:04:06 +0100 Subject: Abstract move. Forstio independence --- examples/settling_cubes_2d_ibm_gpu/sim.cpp | 82 +++++++++++++++--------------- 1 file changed, 41 insertions(+), 41 deletions(-) (limited to 'examples/settling_cubes_2d_ibm_gpu') diff --git a/examples/settling_cubes_2d_ibm_gpu/sim.cpp b/examples/settling_cubes_2d_ibm_gpu/sim.cpp index d7c51bc..50e6ce5 100644 --- a/examples/settling_cubes_2d_ibm_gpu/sim.cpp +++ b/examples/settling_cubes_2d_ibm_gpu/sim.cpp @@ -17,7 +17,6 @@ constexpr uint64_t dim_y = dim_x * 2ul; constexpr uint64_t particle_amount = 16ul; namespace sch { -using namespace saw::schema; using InfoChunk = Chunk; @@ -66,10 +65,10 @@ using ParticleGroups = Tuple< } template -saw::error_or setup_initial_conditions( - saw::data>& fields, - saw::data>& macros, - saw::data>& particles +kel::lbm::error_or setup_initial_conditions( + kel::lbm::data>& fields, + kel::lbm::data>& macros, + kel::lbm::data>& particles ){ auto& info_f = fields.template get<"info">(); // Set everything as walls @@ -111,7 +110,7 @@ saw::error_or setup_initial_conditions( // Particles { - saw::data> dense_p; + kel::lbm::data> dense_p; dense_p.at({}).set(1); // auto& spheroid_group = particles.template get<0u>(); auto& spheroid_group = particles; @@ -147,15 +146,15 @@ saw::error_or setup_initial_conditions( // Particle in hacky flavour {} - return saw::make_void(); + return kel::lbm::make_void(); } template -saw::error_or step( - saw::data>,encode::Sycl>& fields, - saw::data>,encode::Sycl>& macros, - saw::data>,encode::Sycl>& p_group, - saw::data t_i, +kel::lbm::error_or step( + kel::lbm::data>,encode::Sycl>& fields, + kel::lbm::data>,encode::Sycl>& macros, + kel::lbm::data>,encode::Sycl>& p_group, + kel::lbm::data t_i, device& dev ){ auto& q = dev.get_handle(); @@ -170,7 +169,7 @@ saw::error_or step( q.submit([&](acpp::sycl::handler& h){ h.parallel_for(acpp::sycl::range{dim_x,dim_y}, [=](acpp::sycl::id idx){ - saw::data> index; + kel::lbm::data> index; for(uint64_t i = 0u; i < Desc::D; ++i){ index.at({{i}}).set(idx[i]); } @@ -183,14 +182,14 @@ saw::error_or step( q.submit([&](acpp::sycl::handler& h){ h.parallel_for(acpp::sycl::range<1u>{p_meta.at({0u}).get()}, [=](acpp::sycl::id<1u> idx){ - saw::data> index; + kel::lbm::data> index; for(uint64_t i = 0u; i < 1u; ++i){ index.at({{i}}).set(idx[i]); } auto& p = parts.at(index); auto& p_rb = p.template get<"rigid_body">(); - saw::data> delta_t; + kel::lbm::data> delta_t; delta_t.at({}).set(1.0f); auto& p_pos = p_rb.template get<"position">(); @@ -200,12 +199,12 @@ saw::error_or step( iterator::apply( [&](auto& m_ind){ - saw::data> index_shift; + kel::lbm::data> index_shift; for(uint64_t i{0u}; i < Desc::D; ++i){ index_shift.at({{i}}) = m_ind.at({i}).template cast_to() - (vels.meta().at({i})+1u).template cast_to() * 0.5; } - saw::data> transformed_pos; + kel::lbm::data> transformed_pos; for(uint64_t i{0u}; i < Desc::D; ++i){ // TODO add rotation, scaling here. transformed_pos.at({{i}}) = index_shift.at({{i}}); @@ -215,8 +214,8 @@ saw::error_or step( auto p_pos_lag = p_pos + transformed_pos; // Pick the closest momentum and clamp it - saw::data> p_cell_pos; - saw::data> p_cell_pos_vec; + kel::lbm::data> p_cell_pos; + kel::lbm::data> p_cell_pos_vec; for(uint64_t i{0u}; i < Desc::D; ++i){ p_cell_pos.at({{i}}) = (p_pos_lag.at({{i}}) + 0.5).template cast_to(); p_cell_pos.at({{i}}).set(std::max(0ul,std::min(p_cell_pos.at({{i}}).get(), vels.meta().at({{i}}).get() - 2ul))); @@ -230,7 +229,7 @@ saw::error_or step( auto p_vel = (p_pos - p_rb.template get<"position_old">()) * delta_t; - auto u_solid = p_vel + saw::math::cross(p_rot,rel_cell_to_part_pos); + auto u_solid = p_vel + kel::lbm::math::cross(p_rot,rel_cell_to_part_pos); // Force auto force = (u_solid - u_fluid) / delta_t; @@ -252,11 +251,11 @@ saw::error_or step( // auto coll_ev = q.submit([&](acpp::sycl::handler& h){ // Need nicer things to handle the flow. I see improvement here - component> collision{0.8}; - component> bb; + component> collision{0.8}; + component> bb; h.parallel_for(acpp::sycl::range{dim_x,dim_y}, [=](acpp::sycl::id idx){ - saw::data> index; + kel::lbm::data> index; for(uint64_t i = 0u; i < Desc::D; ++i){ index.at({{i}}).set(idx[i]); } @@ -285,13 +284,13 @@ saw::error_or step( }).wait(); */ - return saw::make_void(); + return kel::lbm::make_void(); } } } template -saw::error_or lbm_main(int argc, char** argv){ +kel::lbm::error_or lbm_main(int argc, char** argv){ using namespace kel::lbm; using dfi = df_info; @@ -308,7 +307,7 @@ saw::error_or lbm_main(int argc, char** argv){ std::error_code ec; std::filesystem::create_directories(out_dir,ec); if(ec != std::errc{}){ - return saw::make_error("Could not create output directory"); + return kel::lbm::make_error("Could not create output directory"); } } @@ -321,18 +320,19 @@ saw::error_or lbm_main(int argc, char** argv){ print_lbm_meta(conv,{0.05},{0.01},{0.4 * dim_y}); - // saw::data> meta{{dim_x,dim_y}}; - auto lbm_data_ptr = saw::heap>>(); - auto lbm_macro_data_ptr = saw::heap>>(); - auto lbm_particle_data_ptr = saw::heap>>(); - // auto lbm_particles_ptr = saw::heap,part_count>>>(); - // saw::data> p_mask; + // kel::lbm::data> meta{{dim_x,dim_y}}; + auto lbm_data_ptr = kel::lbm::heap>>(); + auto lbm_macro_data_ptr = kel::lbm::heap>>(); + auto lbm_particle_data_ptr = kel::lbm::heap>>(); + // auto lbm_particles_ptr = kel::lbm::heap,part_count>>>(); + // kel::lbm::data> p_mask; std::cout<<"Estimated Bytes of LBM Fields: "<,sch::MacroStruct>().get()<( + std::string{eo_aio.get_error().get_message()}); } auto& aio = eo_aio.get_value(); saw::wait_scope wait{aio.event_loop}; @@ -364,9 +364,9 @@ saw::error_or lbm_main(int argc, char** argv){ } } - saw::data, encode::Sycl> lbm_sycl_data{sycl_q}; - saw::data, encode::Sycl> lbm_sycl_macro_data{sycl_q}; - saw::data, encode::Sycl> lbm_sycl_particle_data{sycl_q}; + kel::lbm::data, encode::Sycl> lbm_sycl_data{sycl_q}; + kel::lbm::data, encode::Sycl> lbm_sycl_macro_data{sycl_q}; + kel::lbm::data, encode::Sycl> lbm_sycl_particle_data{sycl_q}; { auto eov = dev.copy_to_device(*lbm_data_ptr,lbm_sycl_data); @@ -398,11 +398,11 @@ saw::error_or lbm_main(int argc, char** argv){ return eov; } } - saw::data time_steps{16u*4096ul}; + kel::lbm::data time_steps{16u*4096ul}; auto& info_f = lsd_view.template get<"info">(); - for(saw::data i{0u}; i < time_steps and krun; ++i){ + for(kel::lbm::data i{0u}; i < time_steps and krun; ++i){ // BC + Collision { auto eov = step(lsd_view,lsdm_view,lsdp_view,i,dev); @@ -443,10 +443,10 @@ saw::error_or lbm_main(int argc, char** argv){ */ // Stream sycl_q.submit([&](acpp::sycl::handler& h){ - component> stream; + component> stream; h.parallel_for(acpp::sycl::range{dim_x,dim_y}, [=](acpp::sycl::id idx){ - saw::data> index; + kel::lbm::data> index; for(uint64_t i = 0u; i < Desc::D; ++i){ index.at({{i}}).set(idx[i]); } @@ -482,7 +482,7 @@ saw::error_or lbm_main(int argc, char** argv){ } sycl_q.wait(); - return saw::make_void(); + return kel::lbm::make_void(); } using FloatT = kel::lbm::sch::Float32; -- cgit v1.3.1