From 434607c33deab6ad91cfeb203050138c108958ed Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 10 Dec 2025 17:08:14 +0100 Subject: Geometry for poiseulle setup --- examples/poiseulle_2d_gpu/poiseulle_2d_gpu.cpp | 84 ++++++++++++++++++++------ 1 file changed, 64 insertions(+), 20 deletions(-) (limited to 'examples/poiseulle_2d_gpu/poiseulle_2d_gpu.cpp') diff --git a/examples/poiseulle_2d_gpu/poiseulle_2d_gpu.cpp b/examples/poiseulle_2d_gpu/poiseulle_2d_gpu.cpp index d52af6a..56bcdaf 100644 --- a/examples/poiseulle_2d_gpu/poiseulle_2d_gpu.cpp +++ b/examples/poiseulle_2d_gpu/poiseulle_2d_gpu.cpp @@ -64,21 +64,45 @@ struct PressureBoundaryRestrictedVelocityTo {}; * */ -void set_geometry( - std::vector, SyclDeviceAlloc>& dfs, - std::vector, SyclDeviceAlloc>& dfs_old, - std::vector, SyclDeviceAlloc>& info, +saw::error_or set_geometry( + saw::data* cells, const saw::data>& meta, acpp::sycl::queue& sycl_q ){ using namespace kel::lbm; + sycl_q.submit([&](acpp::sycl::handler& h){ + h.parallel_for(acpp::sycl::range<2>{meta.at({0}).get(), meta.at({1}).get()},[=](acpp::sycl::id<2> idx){ + size_t i = idx[0]; + size_t j = idx[1]; + + size_t acc_id = j * meta.at({0u}).get() + i; + auto& c = cells[acc_id]; + auto& info = c.template get<"info">()({0}); + + if(i >= 2u and j >= 2u and (i+2u) < meta.at({0u}).get() and (j+2u) < meta.at({1u}).get()){ + // Fluid + info.set({2u}); + }else if(((j+2u) == meta.at({1u}).get() or j == 1u) and (i>=1u and (i+1u)= 1 and (j+1 < meta.at({1u}).get()) ) ){ + // Left input + info.set({3u}); + }else if((i+2u) == meta.at({0u}).get() and (j >= 1 and (j+1) < meta.at({1u}).get() )){ + // Left output + info.set({4u}); + }else { + info.set({0u}); + } + }); + }); + + return saw::make_void(); } void set_initial_conditions( - std::vector, SyclDeviceAlloc>& dfs, - std::vector, SyclDeviceAlloc>& dfs_old, - std::vector, SyclDeviceAlloc>& info, + saw::data* cells, const saw::data>& meta, acpp::sycl::queue& sycl_q ){ @@ -91,9 +115,7 @@ void set_initial_conditions( } void lbm_step( - std::vector, SyclDeviceAlloc>& dfs, - std::vector, SyclDeviceAlloc>& dfs_old, - std::vector, SyclDeviceAlloc>& info, + saw::data* cells, const saw::data>& meta, uint64_t time_step, acpp::sycl::queue& sycl_q @@ -105,11 +127,12 @@ void lbm_step( /** * 1. Relaxation parameter \tau */ + /* component coll{0.5384}; component bb; component> inlet{1.01 * dfi::cs2}; component> outlet{1.0 * dfi::cs2}; - + */ } } } @@ -130,36 +153,57 @@ saw::error_or kel_main(int argc, char** argv){ // Create Dir TODO // - lbm::converter conv { + lbm::converter conv { // delta_x {{1.0}}, // delta_t {{1.0}} }; - uint64_t x_d = 1024u; - uint64_t y_d = 128u; + uint64_t x_d = 256u; + uint64_t y_d = 64u; acpp::sycl::queue sycl_q; - SyclHostAlloc sycl_host_alloc{sycl_q}; - SyclDeviceAlloc sycl_dev_alloc{sycl_q}; + SyclHostAlloc sycl_host_alloc{sycl_q}; + // SyclDeviceAlloc sycl_dev_alloc{sycl_q}; + + std::vector, SyclHostAlloc> host_cells{x_d * y_d,sycl_host_alloc}; - std::vector, SyclHostAlloc> cells{x_d * y_d,sycl_alloc}; - std::vector, SyclDeviceAlloc> cells{x_d * y_d,sycl_alloc}; + saw::data* cells = acpp::sycl::malloc_device>(x_d * y_d,sycl_q); { - auto eov = set_geometry(cells); + auto eov = lbm::set_geometry(cells,{{x_d,y_d}},sycl_q); if(eov.is_error()){ return eov; } } + sycl_q.wait(); + sycl_q.memcpy(&host_cells[0u], cells, x_d * y_d * sizeof(saw::data) ); + sycl_q.wait(); + acpp::sycl::free(cells, sycl_q); + sycl_q.wait(); + + std::string vtk_f_name{"tmp/poiseulle_2d_gpu_"}; + vtk_f_name += std::to_string(0u) + ".vtk"; + // write_vtk_file(vtk_f_name,host_cells); + + for(uint64_t i = 0u; i < x_d; ++i){ + for(uint64_t j = 0u; j < y_d; ++j){ + + size_t acc_id = j * x_d + i; + + std::cout<(host_cells.at(acc_id).template get<"info">()({0u}).get())<<" "; + } + std::cout<<"\n"; + } + std::cout<(argc, argv); if(eov.is_error()){ auto& err = eov.get_error(); std::cerr<<"[Error] "<