#pragma once #include "common.hpp" namespace kel { namespace lbm { template kel::lbm::error_or step( const converter& conv, kel::lbm::data>,encode::Sycl>& fields, kel::lbm::data>,encode::Sycl>& macros, kel::lbm::data>,encode::Sycl>& particles, kel::lbm::data t_i, device& dev ){ static constexpr kel::lbm::data sub_steps{0u}; auto& q = dev.get_handle(); auto& info_f = fields.template get<"info">(); auto& porous_f = macros.template get<"porosity">(); if constexpr ( std::is_same_v ){ q.submit([&](acpp::sycl::handler& h){ component> hlbm_reset; h.parallel_for(acpp::sycl::range{dim_x,dim_y}, [=](acpp::sycl::id idx){ kel::lbm::data> index; for(uint64_t i = 0u; i < Desc::D; ++i){ index.at({{i}}).set(idx[i]); } hlbm_reset.apply(fields,macros,index,t_i); }); }).wait(); q.submit([&](acpp::sycl::handler& h){ component> hlbm_one_part; h.parallel_for(acpp::sycl::range<1u>{particle_amount}, [=](acpp::sycl::id<1u> idx){ kel::lbm::data> index; for(uint64_t i = 0u; i < 1u; ++i){ index.at({{i}}).set(idx[i]); } hlbm_one_part.apply(fields,macros,particles,index,t_i,{0u}); }); }).wait(); q.submit([&](acpp::sycl::handler& h){ component> collision{0.8201}; component> bb; component,encode::Sycl> flow_out{1.0}; h.parallel_for(acpp::sycl::range{dim_x,dim_y}, [=](acpp::sycl::id idx){ kel::lbm::data> index; for(uint64_t i = 0u; i < Desc::D; ++i){ index.at({{i}}).set(idx[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,macros,index,t_i); break; case 3u: { component,encode::Sycl> flow_in{ [&]() -> kel::lbm::data> { kel::lbm::data> vel; kel::lbm::data scale; { scale.set([&](){ if(t_i.get() > 1024u){ return 1.0f; } return t_i.get() / 1024.0f; }()); } { auto y_si = conv.meter_lbm_to_si(as_unit>(index.at({{1u}}).template cast_to())).handle(); vel.at({{0u}}) = conv.velocity_si_to_lbm({static_cast::type>((0.1 / 0.64) * y_si.get() - (0.1 / (0.64*0.64)) * y_si.get() * y_si.get())}).handle() * scale; vel.at({{1u}}) = 0.0f; } return vel; }() }; flow_in.apply(fields,index,t_i); } collision.apply(fields,macros,index,t_i); break; case 4u: flow_out.apply(fields,index,t_i); collision.apply(fields,macros,index,t_i); break; default: break; } }); }).wait(); }else if constexpr ( std::is_same_v ){ q.submit([&](acpp::sycl::handler& h){ component> fplbm_reset; h.parallel_for(acpp::sycl::range{dim_x,dim_y}, [=](acpp::sycl::id idx){ kel::lbm::data> index; for(uint64_t i = 0u; i < Desc::D; ++i){ index.at({{i}}).set(idx[i]); } fplbm_reset.apply(fields,macros,index,t_i); }); }).wait(); /** * Particle step, split so contact lands between the fluid gather and * the integration. With 20 particles in a converging throat they jam * against one another, so without a contact pass they would simply * pass through each other and through the walls. */ q.submit([&](acpp::sycl::handler& h){ component> p_reset; component> p_gather; component> p_integrate; /** * Stiffness is sized so an impact at the inflow speed stays well * under a tenth of a radius of overlap; see dem_stiffness_for. */ dem_params p_dem{2.0e-2, 0.4, 0.0, 0.0}; kel::lbm::data> p_extent{{dim_x,dim_y}}; component> p_contact{p_dem,p_extent}; h.parallel_for(acpp::sycl::range<1u>{particle_amount}, [=](acpp::sycl::id<1u> idx){ kel::lbm::data> index; for(uint64_t i = 0u; i < 1u; ++i){ index.at({{i}}).set(idx[i]); } p_reset.apply(particles,index,t_i); p_gather.apply(fields,macros,particles,index,t_i,{4u}); p_contact.apply(particles,index,t_i,{4u}); p_integrate.apply(particles,index,t_i,{4u}); }); }).wait(); // auto coll_ev = q.submit([&](acpp::sycl::handler& h){ component> bgk{0.8201}; component> collision{0.8201}; component> bb; component,encode::Sycl> flow_out{1.0}; h.parallel_for(acpp::sycl::range{dim_x,dim_y}, [=](acpp::sycl::id idx){ kel::lbm::data> index; for(uint64_t i = 0u; i < Desc::D; ++i){ index.at({{i}}).set(idx[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,macros,index,t_i); break; case 3u: { component,encode::Sycl> flow_in{ [&]() -> kel::lbm::data> { kel::lbm::data> vel; { auto y_si = conv.meter_lbm_to_si(as_unit>(index.at({{1u}}).template cast_to())).handle(); vel.at({{0u}}) = conv.velocity_si_to_lbm({static_cast::type>((0.01 / 0.64) * y_si.get() - (0.01 / (0.64*0.64)) * y_si.get() * y_si.get())}).handle(); vel.at({{1u}}) = 0.0f; } return vel; }() }; flow_in.apply(fields,index,t_i); } bgk.apply(fields,macros,index,t_i); break; case 4u: flow_out.apply(fields,index,t_i); bgk.apply(fields,macros,index,t_i); break; default: break; } }); }).wait(); }else if constexpr ( std::is_same_v ){ q.submit([&](acpp::sycl::handler& h){ component> fplbm_reset; h.parallel_for(acpp::sycl::range{dim_x,dim_y}, [=](acpp::sycl::id idx){ kel::lbm::data> index; for(uint64_t i = 0u; i < Desc::D; ++i){ index.at({{i}}).set(idx[i]); } fplbm_reset.apply(fields,macros,index,t_i); }); }).wait(); q.submit([&](acpp::sycl::handler& h){ component> fplbm_one_part; h.parallel_for(acpp::sycl::range<1u>{particle_amount}, [=](acpp::sycl::id<1u> idx){ kel::lbm::data> index; for(uint64_t i = 0u; i < 1u; ++i){ index.at({{i}}).set(idx[i]); } fplbm_one_part.apply(fields,macros,particles,index,t_i,{0u}); }); }).wait(); // auto coll_ev = q.submit([&](acpp::sycl::handler& h){ component> bgk{0.8201}; component> collision{0.8201}; component> bb; component,encode::Sycl> flow_out{1.0}; h.parallel_for(acpp::sycl::range{dim_x,dim_y}, [=](acpp::sycl::id idx){ kel::lbm::data> index; for(uint64_t i = 0u; i < Desc::D; ++i){ index.at({{i}}).set(idx[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,macros,index,t_i); break; case 3u: { component,encode::Sycl> flow_in{ [&]() -> kel::lbm::data> { kel::lbm::data> vel; { auto y_si = conv.meter_lbm_to_si(as_unit>(index.at({{1u}}).template cast_to())).handle(); vel.at({{0u}}) = conv.velocity_si_to_lbm({static_cast::type>((1.2 / 0.64) * y_si.get() - (1.2 / (0.64*0.64)) * y_si.get() * y_si.get())}).handle(); vel.at({{1u}}) = 0.0f; } return vel; }() }; flow_in.apply(fields,index,t_i); } bgk.apply(fields,macros,index,t_i); break; case 4u: flow_out.apply(fields,index,t_i); bgk.apply(fields,macros,index,t_i); break; default: break; } }); }).wait(); } return kel::lbm::make_void(); } } }