diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-03-02 21:11:15 +0100 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-03-02 21:11:21 +0100 |
| commit | 8be0ee7f948c52c1e71e2437bf6e15800daca47d (patch) | |
| tree | c9208f2e566e91294b349ec5808f0f826cfb08ec | |
| parent | 971250070e7b27590d215de54116f3990ab8ff5a (diff) | |
| download | libs-lbm-8be0ee7f948c52c1e71e2437bf6e15800daca47d.tar.gz | |
Dangling
| -rw-r--r-- | examples/poiseulle_particles_2d_gpu/sim.cpp | 43 | ||||
| -rw-r--r-- | lib/core/c++/particle/geometry/circle.hpp | 33 |
2 files changed, 41 insertions, 35 deletions
diff --git a/examples/poiseulle_particles_2d_gpu/sim.cpp b/examples/poiseulle_particles_2d_gpu/sim.cpp index 0f7c97b..4bc9dfb 100644 --- a/examples/poiseulle_particles_2d_gpu/sim.cpp +++ b/examples/poiseulle_particles_2d_gpu/sim.cpp @@ -220,9 +220,9 @@ saw::error_or<void> step( [&](){ uint64_t target_t_i = 64u; if(t_i.get() < target_t_i){ - return 1.0 + (0.015 / target_t_i) * t_i.get(); + return 1.0 + (0.0015 / target_t_i) * t_i.get(); } - return 1.015; + return 1.0015; }() }; component<T,Desc,cmpt::ZouHeHorizontal<false>,encode::Sycl<saw::encode::Native>> flow_out{1.0}; @@ -240,10 +240,16 @@ saw::error_or<void> step( case 0u: break; case 1u: - // bb.apply(fields,index,t_i); + bb.apply(fields,index,t_i); break; case 2u: + flow_in.apply(fields,index,t_i); + collision.apply(fields,macros,index,t_i); + break; case 3u: + flow_out.apply(fields,index,t_i); + collision.apply(fields,macros,index,t_i); + break; case 4u: collision.apply(fields,macros,index,t_i); break; @@ -270,24 +276,6 @@ saw::error_or<void> step( }); }).wait(); - q.submit([&](acpp::sycl::handler& h){ - h.parallel_for(acpp::sycl::range<Desc::D>{dim_x,dim_y}, [=](acpp::sycl::id<Desc::D> idx){ - switch(info.get()){ - case 1u: - bb.apply(fields,index,t_i); - break; - case 3u: - // equi.apply(fields,index,t_i); - flow_in.apply(fields,index,t_i); - break; - case 4u: - // equi.apply(fields,index,t_i); - flow_out.apply(fields,index,t_i); - break; - } - }); - }).wait(); - // Step /* q.submit([&](acpp::sycl::handler& h){ @@ -396,6 +384,12 @@ saw::error_or<void> lbm_main(int argc, char** argv){ for(saw::data<sch::UInt64> i{0u}; i < time_steps and krun; ++i){ { + auto eov = dev.copy_to_host(lbm_sycl_macro_data,*lbm_macro_data_ptr); + if(eov.is_error()){ + return eov; + } + } + { { auto eov = write_vtk_file(out_dir,"t",i.get(), *lbm_macro_data_ptr); if(eov.is_error()){ @@ -409,13 +403,6 @@ saw::error_or<void> lbm_main(int argc, char** argv){ return eov; } } - { - auto eov = dev.copy_to_host(lbm_sycl_macro_data,*lbm_macro_data_ptr); - if(eov.is_error()){ - return eov; - } - } - 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; diff --git a/lib/core/c++/particle/geometry/circle.hpp b/lib/core/c++/particle/geometry/circle.hpp index 331f06d..cf9b87e 100644 --- a/lib/core/c++/particle/geometry/circle.hpp +++ b/lib/core/c++/particle/geometry/circle.hpp @@ -5,7 +5,7 @@ namespace kel { namespace lbm { -template<typename T> +template<typename T, uint64_t D> class particle_circle_geometry { private: public: @@ -13,8 +13,8 @@ public: {} template<typename MT = T> - saw::data<sch::ParticleMask<MT,2>> generate_mask(uint64_t resolution, uint64_t boundary_nodes = 0) const { - saw::data<sch::ParticleMask<MT,2>> mask; + saw::data<sch::ParticleMask<MT,D>> generate_mask(uint64_t resolution, uint64_t boundary_nodes = 0) const { + saw::data<sch::ParticleMask<MT,D>> mask; auto& grid = mask.template get<"grid">(); auto& com = mask.template get<"center_of_mass">(); @@ -28,6 +28,24 @@ public: saw::data<T> delta_x{static_cast<typename saw::native_data_type<T>::type>(2.0 / static_cast<double>(diameter_i))}; saw::data<T> center = (saw::data<T>{1.0} + saw::data<T>{2.0} * saw::data<T>{static_cast<saw::native_data_type<T>::type>(boundary_nodes)/diameter_i}); + saw::data<sch::FixedArray<sch::UInt64,D>> boundary_arr; + for(uint64_t i = 0u; i < D; ++i){ + boundary_arr.set(boundary_nodes); + } + + iterator<D>::apply([&](const auto& index){ + grid.at(index).set(0); + }, {}, grid.dims()); + + iterator<D>::apply([&](const auto& index){ + saw::data<sch::Vector<T,D>> f_ind; + for(uint64_t i = 0u; i < D; ++i){ + f_ind.at({{i}}) = (index.at({{i}}) + 0.5) * delta_x - center; + } + + auto norm_f_ind = saw::math::norm(f_ind); + }, {}, grid.dims(),boundary_arr); + for(uint64_t i = 0; i < size; ++i){ for(uint64_t j = 0; j < size; ++j){ grid.at({{i,j}}).set(0); @@ -43,18 +61,19 @@ public: } } + // I don't fully remember what this did saw::data<T> total_mass{}; - iterate_over([&](const saw::data<sch::FixedArray<sch::UInt64,2u>>& index){ + iterator::apply<D>::apply([&](const saw::data<sch::FixedArray<sch::UInt64,D>>& index){ auto ind_vec = saw::math::vectorize_data(index).template cast_to<T>(); - for(uint64_t i{0u}; i < 2u; ++i){ + for(uint64_t i{0u}; i < D; ++i){ ind_vec.at({{i}}) = ind_vec.at({{i}}) * grid.at(index); } com = com + ind_vec; total_mass = total_mass + grid.at(index); - },{{0u,0u}}, grid.dims()); + },{}, grid.dims()); - for(uint64_t i{0u}; i < 2u; ++i){ + for(uint64_t i{0u}; i < D; ++i){ com.at({{i}}) = com.at({{i}}) / total_mass; } |
