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/one_particle_sedimentation_2d/common.hpp | 1 - examples/one_particle_sedimentation_2d/init.hpp | 14 ++-- examples/one_particle_sedimentation_2d/sim.cpp | 38 +++++----- examples/one_particle_sedimentation_2d/step.hpp | 84 +++++++++++------------ 4 files changed, 68 insertions(+), 69 deletions(-) (limited to 'examples/one_particle_sedimentation_2d') diff --git a/examples/one_particle_sedimentation_2d/common.hpp b/examples/one_particle_sedimentation_2d/common.hpp index ffb7f40..e28622f 100644 --- a/examples/one_particle_sedimentation_2d/common.hpp +++ b/examples/one_particle_sedimentation_2d/common.hpp @@ -29,7 +29,6 @@ constexpr uint64_t dim_y = 800ul; constexpr uint64_t particle_amount = 1ul; namespace sch { -using namespace saw::schema; using InfoChunk = Chunk; diff --git a/examples/one_particle_sedimentation_2d/init.hpp b/examples/one_particle_sedimentation_2d/init.hpp index 8bcc236..989ec4f 100644 --- a/examples/one_particle_sedimentation_2d/init.hpp +++ b/examples/one_particle_sedimentation_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 ){ auto& info_f = fields.template get<"info">(); auto& porous_f = macros.template get<"porosity">(); @@ -74,10 +74,10 @@ saw::error_or init( ); { - saw::data> radius_p; + kel::lbm::data> radius_p; radius_p.at({}).set(conv.meter_si_to_lbm({{0.00125}}).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">(); @@ -94,7 +94,7 @@ saw::error_or init( } } - return saw::make_void(); + return kel::lbm::make_void(); } } diff --git a/examples/one_particle_sedimentation_2d/sim.cpp b/examples/one_particle_sedimentation_2d/sim.cpp index 2daa0b5..7c8456f 100644 --- a/examples/one_particle_sedimentation_2d/sim.cpp +++ b/examples/one_particle_sedimentation_2d/sim.cpp @@ -8,7 +8,6 @@ * For deciding what parameters to use maybe? */ namespace args { -using namespace saw::schema; using LbmArgsStruct = Struct< Member @@ -21,7 +20,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">(); @@ -40,7 +39,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"); } } @@ -50,23 +49,24 @@ saw::error_or lbm_main(const saw::data& args){ // delta_t {{3e-7}} }; - saw::data> kin_vis_si{1e-3}; + kel::lbm::data> kin_vis_si{1e-3}; auto kin_vis_lbm = conv.kinematic_viscosity_si_to_lbm(kin_vis_si); auto tau = conv.template kinematic_viscosity_lbm_to_tau(kin_vis_lbm); print_lbm_meta(conv,kin_vis_si,{1e-4},{2}); std::cout<<"Position: "<> 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}; @@ -98,9 +98,9 @@ saw::error_or lbm_main(const saw::data& args){ } } - 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(); { @@ -134,7 +134,7 @@ saw::error_or lbm_main(const saw::data& args){ } std::cout<<"Steps for 1 sec: "< i{0u},j{0u}; j.get() < 11u and krun; ++i){ + for(kel::lbm::data i{0u},j{0u}; j.get() < 11u and krun; ++i){ // BC + Collision { @@ -170,10 +170,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]); } @@ -209,16 +209,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()){ @@ -237,7 +237,7 @@ saw::error_or k_main(int argc, char** argv){ return lbm_main(args); } - return saw::make_error("Invalid coupling"); + return kel::lbm::make_error("Invalid coupling"); } diff --git a/examples/one_particle_sedimentation_2d/step.hpp b/examples/one_particle_sedimentation_2d/step.hpp index 4bc9dde..de42dec 100644 --- a/examples/one_particle_sedimentation_2d/step.hpp +++ b/examples/one_particle_sedimentation_2d/step.hpp @@ -6,16 +6,16 @@ namespace kel { namespace lbm { template -saw::error_or step( +kel::lbm::error_or step( const converter& conv, - const saw::data>& tau, - saw::data>,encode::Sycl>& fields, - saw::data>,encode::Sycl>& macros, - saw::data>,encode::Sycl>& particles, - saw::data t_i, + const kel::lbm::data>& tau, + 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">(); @@ -24,9 +24,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]); } @@ -35,10 +35,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]); } @@ -48,11 +48,11 @@ saw::error_or step( }).wait(); q.submit([&](acpp::sycl::handler& h){ - component> collision{tau}; - component> bb; + component> collision{tau}; + 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]); } @@ -75,9 +75,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]); } @@ -90,12 +90,12 @@ saw::error_or step( }).wait(); q.submit([&](acpp::sycl::handler& h){ - saw::data> gf; + kel::lbm::data> gf; gf.at({{1u}}) = conv.acceleration_si_to_lbm({-9.81}).handle(); - component> fplbm_one_part{gf}; + component> fplbm_one_part{gf}; 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]); } @@ -106,13 +106,13 @@ saw::error_or step( // auto coll_ev = q.submit([&](acpp::sycl::handler& h){ - component> bgk{tau}; - component> collision{tau}; - component> bb; - component,encode::Sycl> flow_out{1.0}; + component> bgk{tau}; + component> collision{tau}; + 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]); } @@ -130,12 +130,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.41) * y_si.get() - (1.2 / (0.41*0.41)) * y_si.get() * y_si.get())}}).handle(); + vel.at({{0u}}) = conv.velocity_si_to_lbm({{static_cast::type>((1.2 / 0.41) * y_si.get() - (1.2 / (0.41*0.41)) * y_si.get() * y_si.get())}}).handle(); vel.at({{1u}}) = 0.0f; } return vel; @@ -156,9 +156,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]); } @@ -168,10 +168,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]); } @@ -182,13 +182,13 @@ saw::error_or step( // auto coll_ev = q.submit([&](acpp::sycl::handler& h){ - component> bgk{1.0}; - component> collision{tau}; - component> bb; - component,encode::Sycl> flow_out{1.0}; + component> bgk{1.0}; + component> collision{tau}; + 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]); } @@ -206,12 +206,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.41) * y_si.get() - (1.2 / (0.41*0.41)) * y_si.get() * y_si.get())}}).handle(); + vel.at({{0u}}) = conv.velocity_si_to_lbm({{static_cast::type>((1.2 / 0.41) * y_si.get() - (1.2 / (0.41*0.41)) * y_si.get() * y_si.get())}}).handle(); vel.at({{1u}}) = 0.0f; } return vel; @@ -233,7 +233,7 @@ saw::error_or step( } - return saw::make_void(); + return kel::lbm::make_void(); } } -- cgit v1.3.1