From 8f9f0cdc2c04ee2eaba61b8ea93a189b75a7bc9c Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Tue, 6 Oct 2026 18:39:57 +0200 Subject: Fixed throat setup --- examples/one_particle_sedimentation_2d/sim.cpp | 22 ++++++++------- examples/throat_clog_2d/init.hpp | 37 +++++++++++++++++++++++--- modules/core/c++/ghost.hpp | 13 +++++++++ 3 files changed, 59 insertions(+), 13 deletions(-) create mode 100644 modules/core/c++/ghost.hpp diff --git a/examples/one_particle_sedimentation_2d/sim.cpp b/examples/one_particle_sedimentation_2d/sim.cpp index 40bae14..2daa0b5 100644 --- a/examples/one_particle_sedimentation_2d/sim.cpp +++ b/examples/one_particle_sedimentation_2d/sim.cpp @@ -126,13 +126,16 @@ saw::error_or lbm_main(const saw::data& args){ auto lsdm_view = make_view(lbm_sycl_macro_data); auto lsdp_view = make_view(lbm_sycl_particle_data); + auto& info_f = lsd_view.template get<"info">(); - saw::data time_steps{conv.second_si_to_lbm({1.0f}).handle().template cast_to() + 1u}; - std::cout<<"Steps for 1 sec: "< record_steps; + for(uint64_t j{0u}; j < record_steps.size(); ++j){ + record_steps.at(j) = conv.second_si_to_lbm({0.1 * j}).handle().template cast_to().get(); + } + std::cout<<"Steps for 1 sec: "<(); + for(saw::data i{0u},j{0u}; j.get() < 11u and krun; ++i){ - for(saw::data i{0u}; i < time_steps and krun; ++i){ // BC + Collision { auto eov = step( @@ -150,7 +153,7 @@ saw::error_or lbm_main(const saw::data& args){ } sycl_q.wait(); - if(i.get() % 1024u == 0u){ + if(i.get() >= record_steps.at(j.get()) ){ { auto eov = dev.copy_to_host(lbm_sycl_macro_data,*lbm_macro_data_ptr); if(eov.is_error()){ @@ -158,11 +161,12 @@ saw::error_or lbm_main(const saw::data& args){ } } { - auto eov = write_vtk_file(out_dir,"ops_2d",i.get(), *lbm_macro_data_ptr); + auto eov = write_vtk_file(out_dir,"ops_2d",j.get(), *lbm_macro_data_ptr); if(eov.is_error()){ return eov; } } + ++j; } // Stream sycl_q.submit([&](acpp::sycl::handler& h){ @@ -184,10 +188,10 @@ saw::error_or lbm_main(const saw::data& args){ wait.poll(); if(print_status){ - std::cout<<"Status: "<().get() * 100 / time_steps.get())<<"%"<().get() * 100 / record_steps.at(10u))<<"%"< lbm_main(const saw::data& args){ } } { - auto eov = write_vtk_file(out_dir,std::string{"ops_2d_"}+an.template get<"coupling">().stl_string(),time_steps.get(), *lbm_macro_data_ptr); + auto eov = write_vtk_file(out_dir,std::string{"ops_2d_"}+an.template get<"coupling">().stl_string(),record_steps.at(10u), *lbm_macro_data_ptr); if(eov.is_error()){ return eov; } diff --git a/examples/throat_clog_2d/init.hpp b/examples/throat_clog_2d/init.hpp index 06ff179..335fb36 100644 --- a/examples/throat_clog_2d/init.hpp +++ b/examples/throat_clog_2d/init.hpp @@ -45,24 +45,53 @@ saw::error_or init( auto h4 = h * 0.25; saw::data e{0.1}; - saw::data c = saw::data{1.0} - e; + saw::data c = w * (saw::data{1.0} - e) * 0.5; saw::data d{0.2}; - auto b = (saw::data{1.0} - d) * 0.5; + auto b = h * (saw::data{1.0} - d) * 0.5; auto p_r = (c*c + b*b) / (b*2); + auto p_r_2 = p_r * p_r; + std::cout<<"p²_r: "<> top_pos{w2.get(),h + p_i}; + saw::data> top_pos; + { + top_pos.at({0u}) = w2.get(); + top_pos.at({1u}) = (h + p_i).get(); + } // Circle Bot - saw::data> bot_pos{w2.get(),-p_i.get()}; + saw::data> bot_pos; + { + bot_pos.at({0u}) = w2.get(); + bot_pos.at({1u}) = -p_i.get(); + } iterator::apply( [&](auto& index){ + auto& info = info_f.at(index); + auto tp_diff = top_pos; + auto bp_diff = bot_pos; + for(uint64_t i{0u}; i < Desc::D; ++i){ + tp_diff.at(i) = top_pos.at(i) - index.at(i).template cast_to(); + bp_diff.at(i) = bot_pos.at(i) - index.at(i).template cast_to(); + } + auto tpd_v = saw::math::vectorize_data(tp_diff); + auto tpd_dot = saw::math::dot(tpd_v,tpd_v); + + auto bpd_v = saw::math::vectorize_data(bp_diff); + auto bpd_dot = saw::math::dot(bpd_v,bpd_v); + + if( + (tpd_dot.at({}).template cast_to() <= p_r_2 ) or + (bpd_dot.at({}).template cast_to() <= p_r_2 ) + ){ + info.set({1u}); + } }, {}, info_f.get_dims(), diff --git a/modules/core/c++/ghost.hpp b/modules/core/c++/ghost.hpp new file mode 100644 index 0000000..12f614e --- /dev/null +++ b/modules/core/c++/ghost.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include "common.hpp" + +namespace kel { +namespace lbm { + +template +void cleanup_chunk(){ +} + +} +} -- cgit v1.3.1