diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-06-28 19:41:33 +0200 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-06-28 19:41:33 +0200 |
| commit | 78e8a621beff8ccd410f2e2c0b6df7f3931b52eb (patch) | |
| tree | 080672eb1e183fff0ef628dfc3ae6628cb8d10f5 /examples/poiseulle_particles_2d_gpu | |
| parent | 3a27bca74e7645874e52f101d467aff8ff7d78f4 (diff) | |
| parent | 283ff837896c805bddf4962caaa54c26aa8bab1f (diff) | |
| download | libs-lbm-78e8a621beff8ccd410f2e2c0b6df7f3931b52eb.tar.gz | |
Merge branch 'dev'
Diffstat (limited to 'examples/poiseulle_particles_2d_gpu')
| -rw-r--r-- | examples/poiseulle_particles_2d_gpu/common.hpp | 2 | ||||
| -rw-r--r-- | examples/poiseulle_particles_2d_gpu/init.hpp | 7 | ||||
| -rw-r--r-- | examples/poiseulle_particles_2d_gpu/sim.cpp | 45 | ||||
| -rw-r--r-- | examples/poiseulle_particles_2d_gpu/step.hpp | 13 |
4 files changed, 54 insertions, 13 deletions
diff --git a/examples/poiseulle_particles_2d_gpu/common.hpp b/examples/poiseulle_particles_2d_gpu/common.hpp index a69a2cf..6c05b64 100644 --- a/examples/poiseulle_particles_2d_gpu/common.hpp +++ b/examples/poiseulle_particles_2d_gpu/common.hpp @@ -55,7 +55,7 @@ using MacroStruct = Struct< >; template<typename T, typename Desc> -using ParticleSpheroidGroup = ParticleGroup<T,Desc::D,ParticleCollisionSpheroid<T,2.0f>>; +using ParticleSpheroidGroup = ParticleGroup<T,Desc::D,coll::Spheroid<T>>; } } diff --git a/examples/poiseulle_particles_2d_gpu/init.hpp b/examples/poiseulle_particles_2d_gpu/init.hpp index 70d59fc..617b296 100644 --- a/examples/poiseulle_particles_2d_gpu/init.hpp +++ b/examples/poiseulle_particles_2d_gpu/init.hpp @@ -7,10 +7,13 @@ namespace lbm { template<typename T, typename Desc> saw::error_or<void> setup_initial_conditions( + const converter<T>& conv, saw::data<sch::ChunkStruct<T,Desc>>& fields, saw::data<sch::MacroStruct<T,Desc>>& macros, saw::data<sch::ParticleSpheroidGroup<T,Desc>>& particles ){ + (void) conv; + auto& info_f = fields.template get<"info">(); auto& porous_f = macros.template get<"porosity">(); // Set everything as walls @@ -110,9 +113,11 @@ saw::error_or<void> setup_initial_conditions( ); { + saw::data<sch::Scalar<T>> radius_p; + radius_p.at({}).set(2); saw::data<sch::Scalar<T>> dense_p; dense_p.at({}).set(1); - particles = create_spheroid_particle_group<T,Desc::D,2.0f>(dense_p, {{16u}}); + particles = create_spheroid_particle_group<T,Desc::D>(radius_p, dense_p, {{16u}}); } return saw::make_void(); diff --git a/examples/poiseulle_particles_2d_gpu/sim.cpp b/examples/poiseulle_particles_2d_gpu/sim.cpp index 3de3cfb..47c5daa 100644 --- a/examples/poiseulle_particles_2d_gpu/sim.cpp +++ b/examples/poiseulle_particles_2d_gpu/sim.cpp @@ -2,12 +2,38 @@ #include "init.hpp" #include "step.hpp" +#include <forstio/codec/args.hpp> + +/** + * For deciding what parameters to use maybe? + */ +namespace args { +using namespace saw::schema; + +using LbmArgsStruct = Struct< + Member<UInt8,"use_slip">, + Member<String, "coupling"> +>; + +using LbmArgs = Args< + LbmArgsStruct, + Tuple<> +>; +} + template<typename T, typename Desc> saw::error_or<void> lbm_main(int argc, char** argv){ using namespace kel::lbm; using dfi = df_info<T,Desc>; + auto eo_args = saw::parse_args<args::LbmArgs>(argc,argv); + if(eo_args.is_error()){ + return std::move(eo_args.get_error()); + } + auto& args = eo_args.get_value(); + (void)args; + auto eo_lbm_dir = output_directory(); if(eo_lbm_dir.is_error()){ return std::move(eo_lbm_dir.get_error()); @@ -37,7 +63,7 @@ saw::error_or<void> lbm_main(int argc, char** argv){ auto lbm_data_ptr = saw::heap<saw::data<sch::ChunkStruct<T,Desc>>>(); auto lbm_macro_data_ptr = saw::heap<saw::data<sch::MacroStruct<T,Desc>>>(); auto lbm_particle_data_ptr = saw::heap<saw::data<sch::ParticleSpheroidGroup<T,Desc>>>(); - + std::cout<<"Estimated Bytes: "<<memory_estimate<sch::ChunkStruct<T,Desc>,sch::MacroStruct<T,Desc>>().get()<<std::endl; auto eo_aio = saw::setup_async_io(); @@ -62,7 +88,7 @@ saw::error_or<void> lbm_main(int argc, char** argv){ sycl_q.wait(); { - auto eov = setup_initial_conditions<T,Desc>(*lbm_data_ptr,*lbm_macro_data_ptr,*lbm_particle_data_ptr); + auto eov = setup_initial_conditions<T,Desc>(conv,*lbm_data_ptr,*lbm_macro_data_ptr,*lbm_particle_data_ptr); if(eov.is_error()){ return eov; } @@ -92,21 +118,24 @@ saw::error_or<void> lbm_main(int argc, char** argv){ } } sycl_q.wait(); + auto lsd_view = make_view(lbm_sycl_data); auto lsdm_view = make_view(lbm_sycl_macro_data); auto lsdp_view = make_view(lbm_sycl_particle_data); saw::data<sch::UInt64> time_steps{16u*4096ul}; + auto& info_f = lsd_view.template get<"info">(); for(saw::data<sch::UInt64> i{0u}; i < time_steps and krun; ++i){ // BC + Collision { - auto eov = step<T,Desc>(lsd_view,lsdm_view,lsdp_view,i,dev); + auto eov = step<T,Desc>(conv,lsd_view,lsdm_view,lsdp_view,i,dev); if(eov.is_error()){ return eov; } } + sycl_q.wait(); if(i.get() % 32u == 0u){ { @@ -131,22 +160,22 @@ saw::error_or<void> lbm_main(int argc, char** argv){ 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){ + + auto info = info_f.at(index).get(); + + if(info > 0u){ stream.apply(lsd_view,index,i); } }); }).wait(); wait.poll(); + if(print_status){ std::cout<<"Status: "<<i.get()<<" of "<<time_steps.get()<<" - "<<(i.template cast_to<sch::Float64>().get() * 100 / time_steps.get())<<"%"<<std::endl; print_status = false; } print_progress_bar(i.get(), time_steps.get()-1u); } - // After Loop sycl_q.wait(); { diff --git a/examples/poiseulle_particles_2d_gpu/step.hpp b/examples/poiseulle_particles_2d_gpu/step.hpp index a4e44b4..aa0e382 100644 --- a/examples/poiseulle_particles_2d_gpu/step.hpp +++ b/examples/poiseulle_particles_2d_gpu/step.hpp @@ -7,6 +7,7 @@ namespace lbm { template<typename T, typename Desc> saw::error_or<void> step( + const converter<T>& conv, saw::data<sch::Ptr<sch::ChunkStruct<T,Desc>>,encode::Sycl<saw::encode::Native>>& fields, saw::data<sch::Ptr<sch::MacroStruct<T,Desc>>,encode::Sycl<saw::encode::Native>>& macros, saw::data<sch::Ptr<sch::ParticleSpheroidGroup<T,Desc>>,encode::Sycl<saw::encode::Native>>& particles, @@ -17,9 +18,11 @@ saw::error_or<void> step( auto& info_f = fields.template get<"info">(); auto& porous_f = macros.template get<"porosity">(); + component<T,Desc,cmpt::HlbmParticle,encode::Sycl<saw::encode::Native>> particle; + // auto coll_ev = q.submit([&](acpp::sycl::handler& h){ - component<T,Desc,cmpt::Hlbm,encode::Sycl<saw::encode::Native>> collision{0.65}; + component<T,Desc,cmpt::Hlbm,encode::Sycl<saw::encode::Native>> collision{0.8}; component<T,Desc,cmpt::BounceBack,encode::Sycl<saw::encode::Native>> bb; component<T,Desc,cmpt::AntiBounceBack<0u>,encode::Sycl<saw::encode::Native>> abb; @@ -32,7 +35,7 @@ saw::error_or<void> step( component<T,Desc,cmpt::ZouHeHorizontal<true>,encode::Sycl<saw::encode::Native>> flow_in{ [&](){ - uint64_t target_t_i = 64u; + uint64_t target_t_i = 16u; if(t_i.get() < target_t_i){ return 1.0 + (0.0002 / target_t_i) * t_i.get(); } @@ -41,7 +44,6 @@ saw::error_or<void> step( }; component<T,Desc,cmpt::ZouHeHorizontal<false>,encode::Sycl<saw::encode::Native>> flow_out{1.0}; - h.parallel_for(acpp::sycl::range<Desc::D>{dim_x,dim_y}, [=](acpp::sycl::id<Desc::D> idx){ saw::data<sch::FixedArray<sch::UInt64,Desc::D>> index; for(uint64_t i = 0u; i < Desc::D; ++i){ @@ -75,6 +77,11 @@ saw::error_or<void> step( }); }).wait(); + q.submit([&](acpp::sycl::handler& h){ + h.parallel_for(acpp::sycl::range<1u>{1u}, [=](acpp::sycl::id<1u> idx){ + particle.apply(fields,macros,particles,{{0u}},t_i); + }); + }).wait(); // Step /* |
