From 43d795c0afa3c613fb3aee10de7ddf579cf78645 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Tue, 7 Jul 2026 20:33:25 +0200 Subject: Fixed Stokes example (yikes) --- examples/stokes_drag_particle_2d_fplbm_gpu/sim.cpp | 33 ++++++++++++++++------ examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp | 33 ++++++++++++++++------ examples/stokes_drag_particle_2d_psm_gpu/sim.cpp | 31 ++++++++++++++------ 3 files changed, 71 insertions(+), 26 deletions(-) (limited to 'examples') diff --git a/examples/stokes_drag_particle_2d_fplbm_gpu/sim.cpp b/examples/stokes_drag_particle_2d_fplbm_gpu/sim.cpp index fb31f47..5de963d 100644 --- a/examples/stokes_drag_particle_2d_fplbm_gpu/sim.cpp +++ b/examples/stokes_drag_particle_2d_fplbm_gpu/sim.cpp @@ -150,7 +150,7 @@ saw::error_or setup_initial_conditions( rho.at({}) = {1}; auto& vel = vel_f.at(index); if(info_f.at(index).get() == 2u){ - vel.at({{0u}}) = 0.0; + vel.at({{0u}}) = 0.0002f; } auto eq = equilibrium(rho,vel); @@ -214,17 +214,30 @@ saw::error_or step( } component> opa{p_pos,rad,eps}; - component,encode::Sycl> flow_in{ - [&](){ - uint64_t target_t_i = 16u; + component,encode::Sycl> flow_in{ + [&]() -> saw::data>{ + saw::data> vel; + uint64_t target_t_i = 8u; if(t_i.get() < target_t_i){ - return 1.0 + (0.00002 / target_t_i) * t_i.get(); + vel.at({{0u}}) = (0.0002 / target_t_i) * t_i.get(); + }else{ + vel.at({{0u}}) = 0.0002; } - return 1.00002; + return vel; + }() + }; + component,encode::Sycl> flow_out{ + [&]() -> saw::data>{ + saw::data> vel; + uint64_t target_t_i = 8u; + if(t_i.get() < target_t_i){ + vel.at({{0u}}) = (0.0002 / target_t_i) * t_i.get(); + }else{ + vel.at({{0u}}) = 0.0002; + } + return vel; }() }; - component,encode::Sycl> flow_out{1.0}; - h.parallel_for(acpp::sycl::range{dim_x,dim_y}, [=](acpp::sycl::id idx){ saw::data> index; @@ -365,7 +378,9 @@ saw::error_or 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); - saw::data time_steps{16u*4096ul}; + + saw::data time_steps{32u*4096ul}; + auto& info_f = lsd_view.template get<"info">(); for(saw::data i{0u}; i < time_steps and krun; ++i){ diff --git a/examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp b/examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp index 9a04211..68c0b35 100644 --- a/examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp +++ b/examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp @@ -147,7 +147,7 @@ saw::error_or setup_initial_conditions( rho.at({}) = {1}; auto& vel = vel_f.at(index); if(info_f.at(index).get() == 2u){ - vel.at({{0u}}) = 0.0; + vel.at({{0u}}) = 0.0002f; } auto eq = equilibrium(rho,vel); @@ -214,17 +214,30 @@ saw::error_or step( component> fg; - component,encode::Sycl> flow_in{ - [&](){ - uint64_t target_t_i = 16u; + component,encode::Sycl> flow_in{ + [&]() -> saw::data>{ + saw::data> vel; + uint64_t target_t_i = 8u; if(t_i.get() < target_t_i){ - return 1.0 + (0.00002 / target_t_i) * t_i.get(); + vel.at({{0u}}) = (0.0002 / target_t_i) * t_i.get(); + }else{ + vel.at({{0u}}) = 0.0002; } - return 1.00002; + return vel; + }() + }; + component,encode::Sycl> flow_out{ + [&]() -> saw::data>{ + saw::data> vel; + uint64_t target_t_i = 8u; + if(t_i.get() < target_t_i){ + vel.at({{0u}}) = (0.0002 / target_t_i) * t_i.get(); + }else{ + vel.at({{0u}}) = 0.0002; + } + return vel; }() }; - component,encode::Sycl> flow_out{1.0}; - h.parallel_for(acpp::sycl::range{dim_x,dim_y}, [=](acpp::sycl::id idx){ saw::data> index; @@ -367,7 +380,9 @@ saw::error_or 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); - saw::data time_steps{16u*4096ul}; + + saw::data time_steps{32u*4096ul}; + auto& info_f = lsd_view.template get<"info">(); for(saw::data i{0u}; i < time_steps and krun; ++i){ diff --git a/examples/stokes_drag_particle_2d_psm_gpu/sim.cpp b/examples/stokes_drag_particle_2d_psm_gpu/sim.cpp index 9781691..3ab3dda 100644 --- a/examples/stokes_drag_particle_2d_psm_gpu/sim.cpp +++ b/examples/stokes_drag_particle_2d_psm_gpu/sim.cpp @@ -134,6 +134,7 @@ saw::error_or setup_initial_conditions( por_f.at(index).at({}) = {1}; rho.at({}) = {1}; auto& vel = vel_f.at(index); + auto eq = equilibrium(rho,vel); df = eq; @@ -149,7 +150,7 @@ saw::error_or setup_initial_conditions( rho.at({}) = {1}; auto& vel = vel_f.at(index); if(info_f.at(index).get() == 2u){ - vel.at({{0u}}) = 0.0; + vel.at({{0u}}) = 0.0002f; } auto eq = equilibrium(rho,vel); @@ -233,16 +234,30 @@ saw::error_or step( } component> opa{p_pos,rad,eps}; - component,encode::Sycl> flow_in{ - [&](){ - uint64_t target_t_i = 16u; + component,encode::Sycl> flow_in{ + [&]() -> saw::data>{ + saw::data> vel; + uint64_t target_t_i = 8u; + if(t_i.get() < target_t_i){ + vel.at({{0u}}) = (0.0002 / target_t_i) * t_i.get(); + }else{ + vel.at({{0u}}) = 0.0002; + } + return vel; + }() + }; + component,encode::Sycl> flow_out{ + [&]() -> saw::data>{ + saw::data> vel; + uint64_t target_t_i = 8u; if(t_i.get() < target_t_i){ - return 1.0 + (0.00002 / target_t_i) * t_i.get(); + vel.at({{0u}}) = (0.0002 / target_t_i) * t_i.get(); + }else{ + vel.at({{0u}}) = 0.0002; } - return 1.00002; + return vel; }() }; - component,encode::Sycl> flow_out{1.0}; component> fg; @@ -389,7 +404,7 @@ saw::error_or lbm_main(int argc, char** argv){ auto lsd_view = make_view(lbm_sycl_data); auto lsdm_view = make_view(lbm_sycl_macro_data); - saw::data time_steps{16u*4096ul}; + saw::data time_steps{32u*4096ul}; auto& info_f = lsd_view.template get<"info">(); -- cgit v1.2.3 From 544c842c63cd048160f4277a6d0ca3a1f89bd9d1 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Tue, 7 Jul 2026 20:41:45 +0200 Subject: Changing the initial velocity --- examples/stokes_drag_particle_2d_fplbm_gpu/sim.cpp | 4 +- examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp | 4 +- examples/stokes_drag_particle_2d_psm_gpu/sim.cpp | 46 +--------------------- 3 files changed, 3 insertions(+), 51 deletions(-) (limited to 'examples') diff --git a/examples/stokes_drag_particle_2d_fplbm_gpu/sim.cpp b/examples/stokes_drag_particle_2d_fplbm_gpu/sim.cpp index 5de963d..98c72a2 100644 --- a/examples/stokes_drag_particle_2d_fplbm_gpu/sim.cpp +++ b/examples/stokes_drag_particle_2d_fplbm_gpu/sim.cpp @@ -135,6 +135,7 @@ saw::error_or setup_initial_conditions( por_f.at(index).at({}) = {0}; rho.at({}) = {1}; auto& vel = vel_f.at(index); + vel.at({{0u}}) = 0.0002f; auto eq = equilibrium(rho,vel); df = eq; @@ -149,9 +150,6 @@ saw::error_or setup_initial_conditions( auto& rho = rho_f.at(index); rho.at({}) = {1}; auto& vel = vel_f.at(index); - if(info_f.at(index).get() == 2u){ - vel.at({{0u}}) = 0.0002f; - } auto eq = equilibrium(rho,vel); df = eq; diff --git a/examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp b/examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp index 68c0b35..e0cbda2 100644 --- a/examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp +++ b/examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp @@ -132,6 +132,7 @@ saw::error_or setup_initial_conditions( por_f.at(index).at({}) = {1}; rho.at({}) = {1}; auto& vel = vel_f.at(index); + vel.at({{0u}}) = 0.0002f; auto eq = equilibrium(rho,vel); df = eq; @@ -146,9 +147,6 @@ saw::error_or setup_initial_conditions( auto& rho = rho_f.at(index); rho.at({}) = {1}; auto& vel = vel_f.at(index); - if(info_f.at(index).get() == 2u){ - vel.at({{0u}}) = 0.0002f; - } auto eq = equilibrium(rho,vel); df = eq; diff --git a/examples/stokes_drag_particle_2d_psm_gpu/sim.cpp b/examples/stokes_drag_particle_2d_psm_gpu/sim.cpp index 3ab3dda..9d678a8 100644 --- a/examples/stokes_drag_particle_2d_psm_gpu/sim.cpp +++ b/examples/stokes_drag_particle_2d_psm_gpu/sim.cpp @@ -134,6 +134,7 @@ saw::error_or setup_initial_conditions( por_f.at(index).at({}) = {1}; rho.at({}) = {1}; auto& vel = vel_f.at(index); + vel.at({{0u}}) = 0.0002f; auto eq = equilibrium(rho,vel); @@ -149,9 +150,6 @@ saw::error_or setup_initial_conditions( auto& rho = rho_f.at(index); rho.at({}) = {1}; auto& vel = vel_f.at(index); - if(info_f.at(index).get() == 2u){ - vel.at({{0u}}) = 0.0002f; - } auto eq = equilibrium(rho,vel); df = eq; @@ -161,48 +159,6 @@ saw::error_or setup_initial_conditions( {{1u,1u}} ); - saw::data> eps; - eps.at({}).set(1.5f); - saw::data> rad; - rad.at({}).set(dim_y*0.1); - saw::data> p_pos; - { - p_pos.at({{0u}}) = dim_x * 0.5; - p_pos.at({{1u}}) = dim_y * 0.5; - } - - /* - component opa{p_pos,rad,eps}; - iterator::apply( - [&](auto& index){ - opa.apply(macros,index,{}); - }, - {},// 0-index - df_f.get_dims() - ); - */ - - /* - iterator::apply( - [&](auto& index){ - saw::data> middle, ind_vec; - middle.at({{0u}}) = dim_x * 0.25; - middle.at({{1u}}) = dim_y * 0.5; - - ind_vec.at({{0u}}) = index.at({{0u}}).template cast_to(); - ind_vec.at({{1u}}) = index.at({{1u}}).template cast_to(); - - auto dist = middle - ind_vec; - auto dist_2 = saw::math::dot(dist,dist); - if(dist_2.at({}).get() < dim_y*dim_y*0.01){ - porous_f.at(index).at({}) = 0.0; - } - }, - {},// 0-index - df_f.get_dims() - ); - */ - return saw::make_void(); } -- cgit v1.2.3