summaryrefslogtreecommitdiff
path: root/examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2026-07-01 00:15:10 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2026-07-01 00:15:10 +0200
commit761e4912e14324ccf713b9309336816cd3283b38 (patch)
treeb4d4519bb6df9b1f91778484cd5bc361c9356a47 /examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp
parent2bae8b93faf614b1acb5df7269087b4f3786da5a (diff)
downloadlibs-lbm-761e4912e14324ccf713b9309336816cd3283b38.tar.gz
stokes drag impl and run
Diffstat (limited to 'examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp')
-rw-r--r--examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp58
1 files changed, 35 insertions, 23 deletions
diff --git a/examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp b/examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp
index 81498e2..18b5258 100644
--- a/examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp
+++ b/examples/stokes_drag_particle_2d_hlbm_gpu/sim.cpp
@@ -47,8 +47,8 @@ using RhoChunk = Chunk<Scalar<T>, 0u, dim_x, dim_y>;
template<typename T, typename Desc>
using MacroStruct = Struct<
Member<VelChunk<T,Desc>, "velocity">,
- Member<VelChunk<T,Desc>, "force">,
Member<RhoChunk<T>, "density">,
+ Member<VelChunk<T,Desc>, "force">,
Member<ScalarChunk<T,Desc>, "porosity">
>;
@@ -100,7 +100,6 @@ saw::error_or<void> setup_initial_conditions(
{{dim_x-1u,0u}},
{{dim_x, dim_y}}
);
- // Overwrite with
// Inflow
iterator<Desc::D>::apply(
[&](auto& index){
@@ -158,7 +157,28 @@ saw::error_or<void> setup_initial_conditions(
df_f.get_dims(),
{{1u,1u}}
);
-
+
+ /*
+ iterator<Desc::D>::apply(
+ [&](auto& index){
+ saw::data<sch::Vector<T,Desc::D>> 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<T>();
+ ind_vec.at({{1u}}) = index.at({{1u}}).template cast_to<T>();
+
+ 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();
}
@@ -173,7 +193,9 @@ saw::error_or<void> step(
auto& info_f = fields.template get<"info">();
auto& porous_f = macros.template get<"porosity">();
+ // auto coll_ev =
q.submit([&](acpp::sycl::handler& h){
+ component<T,Desc,cmpt::BGK, encode::Sycl<saw::encode::Native>> bgk{0.8};
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;
@@ -181,13 +203,15 @@ saw::error_or<void> step(
saw::data<sch::Scalar<T>> eps;
eps.at({}).set(1.5f);
saw::data<sch::Scalar<T>> rad;
- rad.at({}).set(dim_y*0.1*0.25);
+ rad.at({}).set(dim_y*0.1/4.0);
saw::data<sch::Vector<T,Desc::D>> p_pos;
{
p_pos.at({{0u}}) = dim_x * 0.5;
p_pos.at({{1u}}) = dim_y * 0.5;
}
component<T,Desc,cmpt::OneParticleAt,encode::Sycl<saw::encode::Native>> opa{p_pos,rad,eps};
+
+ component<T,Desc,cmpt::ForceGather, encode::Sycl<saw::encode::Native>> fg;
component<T,Desc,cmpt::ZouHeHorizontal<true>,encode::Sycl<saw::encode::Native>> flow_in{
[&](){
@@ -218,21 +242,20 @@ saw::error_or<void> step(
case 2u:
opa.apply(macros,index,t_i);
collision.apply(fields,macros,index,t_i);
+ fg.apply(fields,macros,index,t_i);
break;
case 3u:
flow_in.apply(fields,index,t_i);
- //equi.apply(fields,index,t_i);
- collision.apply(fields,macros,index,t_i);
+ // equi.apply(fields,index,t_i);
+ bgk.apply(fields,macros,index,t_i);
break;
case 4u:
flow_out.apply(fields,index,t_i);
// equi.apply(fields,index,t_i);
- collision.apply(fields,macros,index,t_i);
- break;
+ bgk.apply(fields,macros,index,t_i);
+ break;
case 5u:
- // Corners
bb.apply(fields,index,t_i);
- break;
default:
break;
}
@@ -342,9 +365,7 @@ 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);
-
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){
@@ -356,8 +377,7 @@ saw::error_or<void> lbm_main(int argc, char** argv){
}
}
sycl_q.wait();
- /*
- if(i.get() % 32u == 0u){
+ if(i.get() % 32u == 0u){
{
auto eov = dev.copy_to_host(lbm_sycl_macro_data,*lbm_macro_data_ptr);
if(eov.is_error()){
@@ -365,14 +385,12 @@ saw::error_or<void> lbm_main(int argc, char** argv){
}
}
{
- auto eov = write_vtk_file(out_dir,"m",i.get(), *lbm_macro_data_ptr);
+ auto eov = write_csv_file(out_dir,"m",i.get(), *lbm_macro_data_ptr);
if(eov.is_error()){
return eov;
}
}
}
- */
-
// Stream
sycl_q.submit([&](acpp::sycl::handler& h){
component<T,Desc,cmpt::Stream,encode::Sycl<saw::encode::Native>> stream;
@@ -412,12 +430,6 @@ saw::error_or<void> lbm_main(int argc, char** argv){
return eov;
}
}
- {
- auto eov = write_csv_file(out_dir,"m",time_steps.get(), *lbm_macro_data_ptr);
- if(eov.is_error()){
- return eov;
- }
- }
sycl_q.wait();
return saw::make_void();