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/throat_clog_2d/common.hpp | 1 - examples/throat_clog_2d/init.hpp | 34 +++++++------- examples/throat_clog_2d/sim.cpp | 42 ++++++++--------- examples/throat_clog_2d/step.hpp | 94 +++++++++++++++++++------------------- 4 files changed, 85 insertions(+), 86 deletions(-) (limited to 'examples/throat_clog_2d') diff --git a/examples/throat_clog_2d/common.hpp b/examples/throat_clog_2d/common.hpp index 15fe08a..d74b2f9 100644 --- a/examples/throat_clog_2d/common.hpp +++ b/examples/throat_clog_2d/common.hpp @@ -28,7 +28,6 @@ constexpr uint64_t dim_x = dim_y * 4ul; constexpr uint64_t particle_amount = 1ul; namespace sch { -using namespace saw::schema; using InfoChunk = Chunk; diff --git a/examples/throat_clog_2d/init.hpp b/examples/throat_clog_2d/init.hpp index 68b2aaa..f76cd67 100644 --- a/examples/throat_clog_2d/init.hpp +++ b/examples/throat_clog_2d/init.hpp @@ -6,11 +6,11 @@ namespace kel { namespace lbm { template -saw::error_or init( +kel::lbm::error_or init( const converter& conv, - saw::data>& fields, - saw::data>& macros, - saw::data>& particles + kel::lbm::data>& fields, + kel::lbm::data>& macros, + kel::lbm::data>& particles ){ (void) conv; @@ -44,11 +44,11 @@ saw::error_or init( auto w2 = w * 0.5; auto h4 = h * 0.25; - saw::data e{0.1}; - saw::data c = w * (saw::data{1.0} - e) * 0.5; + kel::lbm::data e{0.1}; + kel::lbm::data c = w * (kel::lbm::data{1.0} - e) * 0.5; - saw::data d{0.2}; - auto b = h * (saw::data{1.0} - d) * 0.5; + kel::lbm::data d{0.2}; + auto b = h * (kel::lbm::data{1.0} - d) * 0.5; auto p_r = (c*c + b*b) / (b*2); auto p_r_2 = p_r * p_r; @@ -56,14 +56,14 @@ saw::error_or init( auto p_i = p_r - b; // Circle Top - saw::data> top_pos; + kel::lbm::data> top_pos; { top_pos.at({0u}) = w2.get(); top_pos.at({1u}) = (h + p_i).get(); } // Circle Bot - saw::data> bot_pos; + kel::lbm::data> bot_pos; { bot_pos.at({0u}) = w2.get(); bot_pos.at({1u}) = -p_i.get(); @@ -80,11 +80,11 @@ saw::error_or init( bp_diff.at(i) = bot_pos.at(i) - index.at(i).template cast_to(); } - auto tpd_v = saw::math::vectorize_data(tp_diff); - auto tpd_dot = saw::math::dot(tpd_v,tpd_v); + auto tpd_v = kel::lbm::math::vectorize_data(tp_diff); + auto tpd_dot = kel::lbm::math::dot(tpd_v,tpd_v); - auto bpd_v = saw::math::vectorize_data(bp_diff); - auto bpd_dot = saw::math::dot(bpd_v,bpd_v); + auto bpd_v = kel::lbm::math::vectorize_data(bp_diff); + auto bpd_dot = kel::lbm::math::dot(bpd_v,bpd_v); if( (tpd_dot.at({}).template cast_to() <= p_r_2 ) or @@ -157,10 +157,10 @@ saw::error_or init( ); { - saw::data> radius_p; + kel::lbm::data> radius_p; radius_p.at({}).set(conv.meter_si_to_lbm({{0.05}}).handle().get()); std::cout<<"RADIUS: "<> dense_p; + kel::lbm::data> dense_p; dense_p.at({}).set(1); particles = create_spheroid_particle_group(radius_p, dense_p, {{64u}}); auto& parts = particles.template get<"particles">(); @@ -177,7 +177,7 @@ saw::error_or init( } } - return saw::make_void(); + return kel::lbm::make_void(); } } diff --git a/examples/throat_clog_2d/sim.cpp b/examples/throat_clog_2d/sim.cpp index 4084353..118e1b1 100644 --- a/examples/throat_clog_2d/sim.cpp +++ b/examples/throat_clog_2d/sim.cpp @@ -8,7 +8,6 @@ * For deciding what parameters to use maybe? */ namespace args { -using namespace saw::schema; using LbmArgsStruct = Struct< Member @@ -22,7 +21,7 @@ using LbmArgs = Args< } template -saw::error_or lbm_main(const saw::data& args){ +kel::lbm::error_or lbm_main(const kel::lbm::data& args){ using namespace kel::lbm; auto& an = args.template get<"args">(); @@ -41,7 +40,7 @@ saw::error_or lbm_main(const saw::data& args){ 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"); } } @@ -54,16 +53,17 @@ saw::error_or lbm_main(const saw::data& args){ print_lbm_meta(conv,{1e-3},{1e-4},{0.2 * 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>>(); + // 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>>(); std::cout<<"Estimated Bytes: "<,sch::MacroStruct>().get()<( + std::string{eo_aio.get_error().get_message()}); } auto& aio = eo_aio.get_value(); saw::wait_scope wait{aio.event_loop}; @@ -101,9 +101,9 @@ saw::error_or lbm_main(const saw::data& args){ } sycl_q.wait(); - 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}; sycl_q.wait(); { @@ -129,11 +129,11 @@ saw::error_or lbm_main(const saw::data& args){ auto lsdm_view = make_view(lbm_sycl_macro_data); auto lsdp_view = make_view(lbm_sycl_particle_data); - saw::data time_steps{256u*512ul}; + kel::lbm::data time_steps{256u*512ul}; 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(conv,lsd_view,lsdm_view,lsdp_view,i,dev); @@ -159,10 +159,10 @@ saw::error_or lbm_main(const saw::data& args){ } // 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]); } @@ -203,16 +203,16 @@ saw::error_or lbm_main(const saw::data& args){ } } sycl_q.wait(); - return saw::make_void(); + return kel::lbm::make_void(); } using FloatT = kel::lbm::sch::Float32; using DescT = kel::lbm::sch::D2Q9; -saw::error_or k_main(int argc, char** argv){ +kel::lbm::error_or k_main(int argc, char** argv){ using namespace kel::lbm; - saw::data args; + kel::lbm::data args; { auto eov = saw::parse_args(args,argc,argv); if(eov.is_error()){ @@ -222,11 +222,11 @@ saw::error_or k_main(int argc, char** argv){ auto& an = args.template get<"args">(); auto& coupling = an.template get<"coupling">(); - auto resolution_resolve = [&]() -> saw::error_or{ + auto resolution_resolve = [&]() -> kel::lbm::error_or{ return lbm_main(args); }; - auto coupling_resolve = [&]() -> saw::error_or { + auto coupling_resolve = [&]() -> kel::lbm::error_or { if(coupling.stl_view() == "hlbm"){ return resolution_resolve.template operator()(); } else if(coupling.stl_view() == "fplbm"){ @@ -238,7 +238,7 @@ saw::error_or k_main(int argc, char** argv){ return coupling_resolve(); - return saw::make_error("Invalid coupling"); + return kel::lbm::make_error("Invalid coupling"); } diff --git a/examples/throat_clog_2d/step.hpp b/examples/throat_clog_2d/step.hpp index dab9178..840f8ba 100644 --- a/examples/throat_clog_2d/step.hpp +++ b/examples/throat_clog_2d/step.hpp @@ -6,15 +6,15 @@ namespace kel { namespace lbm { template -saw::error_or step( +kel::lbm::error_or step( const converter& conv, - saw::data>,encode::Sycl>& fields, - saw::data>,encode::Sycl>& macros, - saw::data>,encode::Sycl>& particles, - saw::data t_i, + 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 saw::data sub_steps{0u}; + static constexpr kel::lbm::data sub_steps{0u}; auto& q = dev.get_handle(); auto& info_f = fields.template get<"info">(); @@ -22,9 +22,9 @@ saw::error_or step( if constexpr ( std::is_same_v ){ q.submit([&](acpp::sycl::handler& h){ - component> hlbm_reset; + component> hlbm_reset; 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]); } @@ -33,10 +33,10 @@ saw::error_or step( }); }).wait(); q.submit([&](acpp::sycl::handler& h){ - component> hlbm_one_part; + component> hlbm_one_part; h.parallel_for(acpp::sycl::range<1u>{particle_amount}, [=](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]); } @@ -46,12 +46,12 @@ saw::error_or step( }).wait(); q.submit([&](acpp::sycl::handler& h){ - component> collision{0.8201}; - component> bb; - component,encode::Sycl> flow_out{1.0}; + 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){ - saw::data> index; + kel::lbm::data> index; for(uint64_t i = 0u; i < Desc::D; ++i){ index.at({{i}}).set(idx[i]); } @@ -69,10 +69,10 @@ saw::error_or step( break; case 3u: { - component,encode::Sycl> flow_in{ - [&]() -> saw::data> { - saw::data> vel; - saw::data scale; + component,encode::Sycl> flow_in{ + [&]() -> kel::lbm::data> { + kel::lbm::data> vel; + kel::lbm::data scale; { scale.set([&](){ if(t_i.get() > 1024u){ @@ -84,7 +84,7 @@ saw::error_or step( } { auto y_si = conv.meter_lbm_to_si(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({{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; @@ -105,9 +105,9 @@ saw::error_or step( }).wait(); }else if constexpr ( std::is_same_v ){ q.submit([&](acpp::sycl::handler& h){ - component> fplbm_reset; + component> fplbm_reset; 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]); } @@ -117,11 +117,11 @@ saw::error_or step( }).wait(); q.submit([&](acpp::sycl::handler& h){ - saw::data> grav; - component> fplbm_one_part{grav}; + kel::lbm::data> grav; + component> fplbm_one_part{grav}; h.parallel_for(acpp::sycl::range<1u>{particle_amount}, [=](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]); } @@ -132,13 +132,13 @@ saw::error_or step( // 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}; + 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){ - saw::data> index; + kel::lbm::data> index; for(uint64_t i = 0u; i < Desc::D; ++i){ index.at({{i}}).set(idx[i]); } @@ -156,12 +156,12 @@ saw::error_or step( break; case 3u: { - component,encode::Sycl> flow_in{ - [&]() -> saw::data> { - saw::data> vel; + component,encode::Sycl> flow_in{ + [&]() -> kel::lbm::data> { + kel::lbm::data> vel; { auto y_si = conv.meter_lbm_to_si(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({{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; @@ -182,9 +182,9 @@ saw::error_or step( }).wait(); }else if constexpr ( std::is_same_v ){ q.submit([&](acpp::sycl::handler& h){ - component> fplbm_reset; + component> fplbm_reset; 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]); } @@ -194,10 +194,10 @@ saw::error_or step( }).wait(); q.submit([&](acpp::sycl::handler& h){ - component> fplbm_one_part; + component> fplbm_one_part; h.parallel_for(acpp::sycl::range<1u>{particle_amount}, [=](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]); } @@ -208,13 +208,13 @@ saw::error_or step( // 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}; + 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){ - saw::data> index; + kel::lbm::data> index; for(uint64_t i = 0u; i < Desc::D; ++i){ index.at({{i}}).set(idx[i]); } @@ -232,12 +232,12 @@ saw::error_or step( break; case 3u: { - component,encode::Sycl> flow_in{ - [&]() -> saw::data> { - saw::data> vel; + component,encode::Sycl> flow_in{ + [&]() -> kel::lbm::data> { + kel::lbm::data> vel; { auto y_si = conv.meter_lbm_to_si(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({{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; @@ -259,7 +259,7 @@ saw::error_or step( } - return saw::make_void(); + return kel::lbm::make_void(); } } -- cgit v1.3.1