summaryrefslogtreecommitdiff
path: root/examples/stdkr_2d_bgk
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2026-08-20 18:59:00 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2026-08-20 18:59:00 +0200
commit5cd236287542b47016fe3c49aa56bb66d74c4ad7 (patch)
treea3eaf3b0419a1c5897c344a949cf5775b1637afc /examples/stdkr_2d_bgk
parent5dade743e7c1e6b0b6001b4265bf792f0b05f93a (diff)
downloadlibs-lbm-5cd236287542b47016fe3c49aa56bb66d74c4ad7.tar.gz
Feierabend
Diffstat (limited to 'examples/stdkr_2d_bgk')
-rw-r--r--examples/stdkr_2d_bgk/init.hpp46
-rw-r--r--examples/stdkr_2d_bgk/sim.cpp13
-rw-r--r--examples/stdkr_2d_bgk/step.hpp3
3 files changed, 25 insertions, 37 deletions
diff --git a/examples/stdkr_2d_bgk/init.hpp b/examples/stdkr_2d_bgk/init.hpp
index abc2a26..3127c88 100644
--- a/examples/stdkr_2d_bgk/init.hpp
+++ b/examples/stdkr_2d_bgk/init.hpp
@@ -14,7 +14,6 @@ saw::error_or<void> init(
(void) conv;
auto& info_f = fields.template get<"info">();
- auto& porous_f = macros.template get<"porosity">();
// Set everything as walls
iterator<Desc::D>::apply(
[&](auto& index){
@@ -57,13 +56,11 @@ saw::error_or<void> init(
auto& df_f = fields.template get<"dfs_old">();
auto& rho_f = macros.template get<"density">();
auto& vel_f = macros.template get<"momentum">();
- auto& por_f = macros.template get<"porosity">();
iterator<Desc::D>::apply(
[&](auto& index){
auto& df = df_f.at(index);
auto& rho = rho_f.at(index);
- por_f.at(index).at({}) = {1};
rho.at({}) = {1};
auto& vel = vel_f.at(index);
auto eq = equilibrium<T,Desc>(rho,vel);
@@ -92,31 +89,32 @@ saw::error_or<void> init(
{{1u,1u}}
);
- {
+ iterator<Desc::D>::apply(
+ [&](const auto& index){
+ auto& info = info_f.at(index);
+ saw::data<sch::Scalar<T>> radius_p;
+ radius_p.at({}).set(conv.meter_si_to_lbm({{0.05}}).handle().get());
+ saw::data<sch::Scalar<T>> dense_p;
+ dense_p.at({}).set(1);
- }
- {
- saw::data<sch::Scalar<T>> radius_p;
- radius_p.at({}).set(conv.meter_si_to_lbm({{0.05}}).handle().get());
- std::cout<<"RADIUS: "<<radius_p.at({}).get()<<std::endl;
- saw::data<sch::Scalar<T>> dense_p;
- dense_p.at({}).set(1);
- /*
- auto& parts = particles.template get<"particles">();
+ saw::data<sch::Vector<T,Desc::D>> middle,ind_vec;
+ middle.at({{0u}}) = conv.meter_si_to_lbm({{0.16}}).handle();
+ middle.at({{1u}}) = conv.meter_si_to_lbm({{0.2}}).handle();
- {
- auto& p = parts.at({0u});
- auto& prb = p.template get<"rigid_body">();
- auto& p_pos = prb.template get<"position">();
- auto& p_posold = prb.template get<"position_old">();
- p_pos.at({{0u}}) = conv.meter_si_to_lbm({{0.16}}).handle();
- p_pos.at({{1u}}) = conv.meter_si_to_lbm({{0.2}}).handle();
+ for(uint64_t i{0u}; i < Desc::D; ++i){
+ ind_vec.at({{i}}) = index.at({i}).template cast_to<T>();
+ }
- p_posold = p_pos;
- }
- */
- }
+ auto dist = ind_vec - middle;
+ auto dist_2 = saw::math::dot(dist,dist);
+ if(dist_2.at({}) < radius_p.at({}) * radius_p.at({})){
+ info_f.at(index) = 1u;
+ }
+ },
+ {},// 0-index
+ df_f.get_dims()
+ );
return saw::make_void();
}
diff --git a/examples/stdkr_2d_bgk/sim.cpp b/examples/stdkr_2d_bgk/sim.cpp
index 558a219..36147d5 100644
--- a/examples/stdkr_2d_bgk/sim.cpp
+++ b/examples/stdkr_2d_bgk/sim.cpp
@@ -56,7 +56,6 @@ saw::error_or<void> lbm_main(const saw::data<args::LbmArgs>& args){
// saw::data<sch::FixedArray<sch::UInt64,Desc::D>> meta{{dim_x,dim_y}};
auto lbm_data_ptr = saw::heap<saw::data<sch::ChunkStruct<T,Desc>>>();
auto lbm_macro_data_ptr = saw::heap<saw::data<sch::MacroStruct<T,Desc>>>();
- auto lbm_particle_data_ptr = saw::heap<saw::data<sch::ParticleSpheroidGroup<T,Desc>>>();
std::cout<<"Estimated Bytes: "<<memory_estimate<sch::ChunkStruct<T,Desc>,sch::MacroStruct<T,Desc>>().get()<<std::endl;
@@ -82,7 +81,7 @@ saw::error_or<void> lbm_main(const saw::data<args::LbmArgs>& args){
sycl_q.wait();
{
- auto eov = init<T,Desc,Coll>(conv,*lbm_data_ptr,*lbm_macro_data_ptr,*lbm_particle_data_ptr);
+ auto eov = init<T,Desc,Coll>(conv,*lbm_data_ptr,*lbm_macro_data_ptr);
if(eov.is_error()){
return eov;
}
@@ -96,7 +95,6 @@ saw::error_or<void> lbm_main(const saw::data<args::LbmArgs>& args){
saw::data<sch::ChunkStruct<T,Desc>, encode::Sycl<saw::encode::Native>> lbm_sycl_data{sycl_q};
saw::data<sch::MacroStruct<T,Desc>, encode::Sycl<saw::encode::Native>> lbm_sycl_macro_data{sycl_q};
- saw::data<sch::ParticleSpheroidGroup<T,Desc>, encode::Sycl<saw::encode::Native>> lbm_sycl_particle_data{sycl_q};
sycl_q.wait();
{
@@ -111,16 +109,9 @@ saw::error_or<void> lbm_main(const saw::data<args::LbmArgs>& args){
return eov;
}
}
- {
- auto eov = dev.copy_to_device(*lbm_particle_data_ptr,lbm_sycl_particle_data);
- if(eov.is_error()){
- return eov;
- }
- }
sycl_q.wait();
auto lsd_view = make_view(lbm_sycl_data);
auto lsdm_view = make_view(lbm_sycl_macro_data);
- auto lsdp_view = make_view(lbm_sycl_particle_data);
saw::data<sch::UInt64> time_steps{64u*1024ul};
@@ -129,7 +120,7 @@ saw::error_or<void> lbm_main(const saw::data<args::LbmArgs>& args){
for(saw::data<sch::UInt64> i{0u}; i < time_steps and krun; ++i){
// BC + Collision
{
- auto eov = step<T,Desc,Coll>(conv,lsd_view,lsdm_view,lsdp_view,i,dev);
+ auto eov = step<T,Desc,Coll>(conv,lsd_view,lsdm_view,i,dev);
if(eov.is_error()){
return eov;
}
diff --git a/examples/stdkr_2d_bgk/step.hpp b/examples/stdkr_2d_bgk/step.hpp
index 667f5a3..cbf9f43 100644
--- a/examples/stdkr_2d_bgk/step.hpp
+++ b/examples/stdkr_2d_bgk/step.hpp
@@ -17,13 +17,12 @@ saw::error_or<void> step(
auto& q = dev.get_handle();
auto& info_f = fields.template get<"info">();
- auto& porous_f = macros.template get<"porosity">();
{
q.submit([&](acpp::sycl::handler& h){
component<T,Desc,cmpt::BGK,encode::Sycl<saw::encode::Native>> collision{1.0};
component<T,Desc,cmpt::BounceBack,encode::Sycl<saw::encode::Native>> bb;
- component<T,Desc,cmpt::ZouHeHorizontal<false>,encode::Sycl<saw::encode::Native>> flow_out{1.0};
+ component<T,Desc,cmpt::ZouHePressureX<false>,encode::Sycl<saw::encode::Native>> flow_out{1.0};
h.parallel_for(acpp::sycl::range<Desc::D>{dim_x,dim_y}, [=](acpp::sycl::id<Desc::D> idx){
saw::data<sch::FixedArray<sch::UInt64,Desc::D>> index;