From 1e2e1755beb592f86f61337524121b98063a0d89 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Tue, 26 May 2026 19:19:47 +0200 Subject: Dangling --- examples/poiseulle_particles_2d_ibm_gpu/sim.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'examples/poiseulle_particles_2d_ibm_gpu') diff --git a/examples/poiseulle_particles_2d_ibm_gpu/sim.cpp b/examples/poiseulle_particles_2d_ibm_gpu/sim.cpp index e68d7da..2e0aee6 100644 --- a/examples/poiseulle_particles_2d_ibm_gpu/sim.cpp +++ b/examples/poiseulle_particles_2d_ibm_gpu/sim.cpp @@ -292,12 +292,11 @@ saw::error_or step( index_shift.at({{i}}) = index.at({i}).template cast_to() - com.at({{i}}); } - /// TODO 1. Calculate force pickup from neigbouring u_vel cells - auto inter_vel = n_linear_interpolate(vel,index_shift); + // auto inter_vel = n_linear_interpolate(vel,index_shift); /// TODO 3. Distribute force to fluid - + }, {}, mask.meta()); }); -- cgit v1.2.3 From 960a3ef31095af11c7c764a1bcdcb4b424c529b8 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Tue, 26 May 2026 22:24:09 +0200 Subject: Dangling changes. Fixed compilation issues which hurt my brain --- examples/poiseulle_particles_2d_ibm_gpu/sim.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples/poiseulle_particles_2d_ibm_gpu') diff --git a/examples/poiseulle_particles_2d_ibm_gpu/sim.cpp b/examples/poiseulle_particles_2d_ibm_gpu/sim.cpp index 2e0aee6..77ecda2 100644 --- a/examples/poiseulle_particles_2d_ibm_gpu/sim.cpp +++ b/examples/poiseulle_particles_2d_ibm_gpu/sim.cpp @@ -289,7 +289,7 @@ saw::error_or step( /// Calculate the shift from the mask saw::data> index_shift; for(uint64_t i = 0u; i < Desc::D; ++i){ - index_shift.at({{i}}) = index.at({i}).template cast_to() - com.at({{i}}); + index_shift.at({{i}}) = index.at({i}).template cast_to() - com.at({}).at({{i}}); } /// TODO 1. Calculate force pickup from neigbouring u_vel cells -- cgit v1.2.3 From 346d979dcdea3e3f37d3ad55680b4f0469d7220c Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 27 May 2026 15:58:45 +0200 Subject: Dangliung --- examples/poiseulle_particles_2d_ibm_gpu/sim.cpp | 29 ++++++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'examples/poiseulle_particles_2d_ibm_gpu') diff --git a/examples/poiseulle_particles_2d_ibm_gpu/sim.cpp b/examples/poiseulle_particles_2d_ibm_gpu/sim.cpp index 77ecda2..7726663 100644 --- a/examples/poiseulle_particles_2d_ibm_gpu/sim.cpp +++ b/examples/poiseulle_particles_2d_ibm_gpu/sim.cpp @@ -265,9 +265,13 @@ saw::error_or step( // h.depends_on(collision_ev); }).wait(); */ + + auto& force_f = macros.template get<"force">(); + q.submit([&](acpp::sycl::handler& h){ h.parallel_for(acpp::sycl::range<1u>{1u}, [=](acpp::sycl::id<1u> idx){ - auto& vel = macros.template get<"velocity">(); + auto& vel_f = macros.template get<"velocity">(); + auto& dense_f = macros.template get<"density">(); auto& ps = particles; auto& mask = ps.template get<"mask">(); @@ -276,7 +280,7 @@ saw::error_or step( auto& parts = ps.template get<"particles">(); - auto& p_i = parts.at({{0u}}); + auto& p_i = parts.at({{idx[0u]}}); auto& p_i_rb = p_i.template get<"rigid_body">(); /// 0. Iterate over mask and calculate position in LBM grid @@ -290,13 +294,26 @@ saw::error_or step( saw::data> index_shift; for(uint64_t i = 0u; i < Desc::D; ++i){ index_shift.at({{i}}) = index.at({i}).template cast_to() - com.at({}).at({{i}}); + // Scale to LBM Grid + index_shift.at({{i}}) = index_shift.at({{i}}) * ; } - /// TODO 1. Calculate force pickup from neigbouring u_vel cells - // auto inter_vel = n_linear_interpolate(vel,index_shift); + // Shift our pos into the index + auto p_i_rb_pos_ind = p_i_rb_pos + index_shift; + + /// Calculate force pickup from neigbouring u_vel cells + // auto inter_vel_fluid = n_linear_interpolate(vel_f,p_i_rb_pos_ind); + auto inter_vel_fluid = n_closest_read(vel_f,p_i_rb_pos_ind); - /// TODO 3. Distribute force to fluid - + // Technically TODO to use moment + auto inter_moment_fluid = inter_vel_fluid; + + // Technically Particles can have more timesteps than the fluid + auto force_response = -inter_moment_fluid; + + /// Distribute force to fluid + // n_linear_spread(force_f,p_i_rb_pos_ind, force_response); + n_closest_add(force_f,p_i_rb_pos_ind, force_response); }, {}, mask.meta()); }); -- cgit v1.2.3 From 2dd7c95a111a930e8e23140ab3fec074e7de4c8c Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Fri, 29 May 2026 21:56:48 +0200 Subject: Dangling --- examples/poiseulle_particles_2d_ibm_gpu/sim.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'examples/poiseulle_particles_2d_ibm_gpu') diff --git a/examples/poiseulle_particles_2d_ibm_gpu/sim.cpp b/examples/poiseulle_particles_2d_ibm_gpu/sim.cpp index 7726663..d4bf053 100644 --- a/examples/poiseulle_particles_2d_ibm_gpu/sim.cpp +++ b/examples/poiseulle_particles_2d_ibm_gpu/sim.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include @@ -275,6 +275,7 @@ saw::error_or step( auto& ps = particles; auto& mask = ps.template get<"mask">(); + auto& mask_step = ps.template get<"mask_step">().at({}); auto& dense = ps.template get<"density">().at({}); auto& com = ps.template get<"center_of_mass">(); @@ -295,7 +296,7 @@ saw::error_or step( for(uint64_t i = 0u; i < Desc::D; ++i){ index_shift.at({{i}}) = index.at({i}).template cast_to() - com.at({}).at({{i}}); // Scale to LBM Grid - index_shift.at({{i}}) = index_shift.at({{i}}) * ; + index_shift.at({{i}}) = index_shift.at({{i}}) * mask_step.at({}); } // Shift our pos into the index -- cgit v1.2.3 From 7fd9bfd5946472230a3b74c52f88e19c15741faf Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Mon, 1 Jun 2026 17:21:44 +0200 Subject: I seem to have no clue what I'm doing --- examples/poiseulle_particles_2d_ibm_gpu/sim.cpp | 152 ++++++++++++++---------- 1 file changed, 90 insertions(+), 62 deletions(-) (limited to 'examples/poiseulle_particles_2d_ibm_gpu') diff --git a/examples/poiseulle_particles_2d_ibm_gpu/sim.cpp b/examples/poiseulle_particles_2d_ibm_gpu/sim.cpp index d4bf053..e1bd3ba 100644 --- a/examples/poiseulle_particles_2d_ibm_gpu/sim.cpp +++ b/examples/poiseulle_particles_2d_ibm_gpu/sim.cpp @@ -114,6 +114,7 @@ saw::error_or setup_initial_conditions( auto& df_f = fields.template get<"dfs_old">(); auto& rho_f = macros.template get<"density">(); auto& vel_f = macros.template get<"velocity">(); + auto& force_f = macros.template get<"force">(); iterator::apply( [&](auto& index){ @@ -135,6 +136,9 @@ saw::error_or setup_initial_conditions( auto& rho = rho_f.at(index); rho.at({}) = {1}; auto& vel = vel_f.at(index); + auto& force = force_f.at(index); + force = {}; + if(info_f.at(index).get() == 2u){ vel.at({{0u}}) = 0.0; } @@ -195,15 +199,79 @@ saw::error_or step( ){ auto& q = dev.get_handle(); auto& info_f = fields.template get<"info">(); + auto& force_f = macros.template get<"force">(); + + q.submit([&](acpp::sycl::handler& h){ + h.parallel_for(acpp::sycl::range{dim_x,dim_y}, [=](acpp::sycl::id idx){ + saw::data> index; + for(uint64_t i = 0u; i < Desc::D; ++i){ + index.at({{i}}).set(idx[i]); + } + + auto& force = force_f.at(index); + + for(uint64_t i{0u}; i < Desc::D; ++i){ + force.at({{i}}) = 0.0; + } + }); + }).wait(); + + q.submit([&](acpp::sycl::handler& h){ + h.parallel_for(acpp::sycl::range<1u>{1u}, [=](acpp::sycl::id<1u> idx){ + auto& vel_f = macros.template get<"velocity">(); + auto& dense_f = macros.template get<"density">(); + + auto& ps = particles; + auto& mask = ps.template get<"mask">(); + auto& mask_step = ps.template get<"mask_step">().at({}); + auto& p_dense = ps.template get<"density">().at({}); + auto& com = ps.template get<"center_of_mass">(); + + auto& parts = ps.template get<"particles">(); + + auto& p_i = parts.at({{idx[0u]}}); + + auto& p_i_rb = p_i.template get<"rigid_body">(); + /// 0. Iterate over mask and calculate position in LBM grid + /// In this case it's simple since I'm too lazy to do scaling and rotation + /// Technically scale => rotate => translate + /// Here it's only translate + auto& p_i_rb_pos = p_i_rb.template get<"position">(); + + iterator::apply([&](const auto& index){ + /// Calculate the shift from the mask + saw::data> index_shift; + for(uint64_t i = 0u; i < Desc::D; ++i){ + index_shift.at({{i}}) = index.at({i}).template cast_to() - com.at({}).at({{i}}); + // Scale to LBM Grid + index_shift.at({{i}}) = index_shift.at({{i}}) * mask_step.at({}); + } + + // Shift our pos into the index + auto p_i_rb_pos_ind = p_i_rb_pos + index_shift; + + /// Calculate force pickup from neigbouring u_vel cells + // auto inter_vel_fluid = n_linear_interpolate(vel_f,p_i_rb_pos_ind); + auto inter_vel_fluid = n_closest_read(vel_f,p_i_rb_pos_ind); + + // Technically TODO to use moment + auto inter_moment_fluid = inter_vel_fluid; + + // Technically Particles can have more timesteps than the fluid + auto force_response = -inter_moment_fluid; + + /// Distribute force to fluid + // n_linear_spread(force_f,p_i_rb_pos_ind, force_response); + n_closest_add(force_f,p_i_rb_pos_ind, force_response); + + }, {}, mask.meta()); + }); + }).wait(); // auto coll_ev = q.submit([&](acpp::sycl::handler& h){ // Need nicer things to handle the flow. I see improvement here - saw::data> f; - f.at({{0u}}) = 0.0; - f.at({{1u}}) = -1.0; - - component> collision{0.65,f}; + component> collision{0.65}; component> bb; component,encode::Sycl> abb; @@ -233,7 +301,7 @@ saw::error_or step( } auto info = info_f.at(index); - + switch(info.get()){ case 0u: break; @@ -256,6 +324,8 @@ saw::error_or step( break; } }); + + }).wait(); @@ -265,61 +335,6 @@ saw::error_or step( // h.depends_on(collision_ev); }).wait(); */ - - auto& force_f = macros.template get<"force">(); - - q.submit([&](acpp::sycl::handler& h){ - h.parallel_for(acpp::sycl::range<1u>{1u}, [=](acpp::sycl::id<1u> idx){ - auto& vel_f = macros.template get<"velocity">(); - auto& dense_f = macros.template get<"density">(); - - auto& ps = particles; - auto& mask = ps.template get<"mask">(); - auto& mask_step = ps.template get<"mask_step">().at({}); - auto& dense = ps.template get<"density">().at({}); - auto& com = ps.template get<"center_of_mass">(); - - auto& parts = ps.template get<"particles">(); - - auto& p_i = parts.at({{idx[0u]}}); - - auto& p_i_rb = p_i.template get<"rigid_body">(); - /// 0. Iterate over mask and calculate position in LBM grid - /// In this case it's simple since I'm too lazy to do scaling and rotation - /// Technically scale => rotate => translate - /// Here it's only translate - auto& p_i_rb_pos = p_i_rb.template get<"position">(); - - iterator::apply([&](const auto& index){ - /// Calculate the shift from the mask - saw::data> index_shift; - for(uint64_t i = 0u; i < Desc::D; ++i){ - index_shift.at({{i}}) = index.at({i}).template cast_to() - com.at({}).at({{i}}); - // Scale to LBM Grid - index_shift.at({{i}}) = index_shift.at({{i}}) * mask_step.at({}); - } - - // Shift our pos into the index - auto p_i_rb_pos_ind = p_i_rb_pos + index_shift; - - /// Calculate force pickup from neigbouring u_vel cells - // auto inter_vel_fluid = n_linear_interpolate(vel_f,p_i_rb_pos_ind); - auto inter_vel_fluid = n_closest_read(vel_f,p_i_rb_pos_ind); - - // Technically TODO to use moment - auto inter_moment_fluid = inter_vel_fluid; - - // Technically Particles can have more timesteps than the fluid - auto force_response = -inter_moment_fluid; - - /// Distribute force to fluid - // n_linear_spread(force_f,p_i_rb_pos_ind, force_response); - n_closest_add(force_f,p_i_rb_pos_ind, force_response); - - }, {}, mask.meta()); - }); - }).wait(); - return saw::make_void(); } } @@ -493,8 +508,21 @@ saw::error_or lbm_main(int argc, char** argv){ }); }).wait(); wait.poll(); + + // PRINT STATUS ON SIGUSR1 if(print_status){ - std::cout<<"Status: "<().get() * 100 / time_steps.get())<<"%"<