diff options
| -rw-r--r-- | examples/one_particle_sedimentation_2d/sim.cpp | 22 | ||||
| -rw-r--r-- | examples/throat_clog_2d/init.hpp | 37 | ||||
| -rw-r--r-- | modules/core/c++/ghost.hpp | 13 |
3 files changed, 59 insertions, 13 deletions
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<void> lbm_main(const saw::data<args::LbmArgs>& 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<sch::UInt64> time_steps{conv.second_si_to_lbm({1.0f}).handle().template cast_to<sch::UInt64>() + 1u}; - std::cout<<"Steps for 1 sec: "<<time_steps.get()<<std::endl; + std::array<uint64_t,11u> 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<sch::UInt64>().get(); + } + std::cout<<"Steps for 1 sec: "<<record_steps.at(10u)<<std::endl; - auto& info_f = lsd_view.template get<"info">(); + for(saw::data<sch::UInt64> i{0u},j{0u}; j.get() < 11u and krun; ++i){ - for(saw::data<sch::UInt64> i{0u}; i < time_steps and krun; ++i){ // BC + Collision { auto eov = step<T,Desc,Coll>( @@ -150,7 +153,7 @@ saw::error_or<void> lbm_main(const saw::data<args::LbmArgs>& 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<void> lbm_main(const saw::data<args::LbmArgs>& 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<void> lbm_main(const saw::data<args::LbmArgs>& args){ wait.poll(); if(print_status){ - std::cout<<"Status: "<<i.get()<<" of "<<time_steps.get()<<" - "<<(i.template cast_to<sch::Float64>().get() * 100 / time_steps.get())<<"%"<<std::endl; + std::cout<<"Status: "<<i.get()<<" of "<<record_steps.at(10u)<<" - "<<(i.template cast_to<sch::Float64>().get() * 100 / record_steps.at(10u))<<"%"<<std::endl; print_status = false; } - print_progress_bar(i.get()+1u, time_steps.get()); + print_progress_bar(i.get()+1u, record_steps.at(10u)); } // After Loop sycl_q.wait(); @@ -198,7 +202,7 @@ saw::error_or<void> lbm_main(const saw::data<args::LbmArgs>& 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<void> init( auto h4 = h * 0.25; saw::data<T> e{0.1}; - saw::data<T> c = saw::data<T>{1.0} - e; + saw::data<T> c = w * (saw::data<T>{1.0} - e) * 0.5; saw::data<T> d{0.2}; - auto b = (saw::data<T>{1.0} - d) * 0.5; + auto b = h * (saw::data<T>{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: "<<p_r_2.get()<<std::endl; auto p_i = p_r - b; // Circle Top - saw::data<sch::FixedArray<sch::Int64,2u>> top_pos{w2.get(),h + p_i}; + saw::data<sch::FixedArray<sch::Int64,Desc::D>> top_pos; + { + top_pos.at({0u}) = w2.get(); + top_pos.at({1u}) = (h + p_i).get(); + } // Circle Bot - saw::data<sch::FixedArray<sch::Int64,2u>> bot_pos{w2.get(),-p_i.get()}; + saw::data<sch::FixedArray<sch::Int64,Desc::D>> bot_pos; + { + bot_pos.at({0u}) = w2.get(); + bot_pos.at({1u}) = -p_i.get(); + } iterator<Desc::D>::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<sch::Int64>(); + bp_diff.at(i) = bot_pos.at(i) - index.at(i).template cast_to<sch::Int64>(); + } + + 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<T>() <= p_r_2 ) or + (bpd_dot.at({}).template cast_to<T>() <= 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<typename D, uint64_t Border = 1u, uint64_t Ghost = 0u> +void cleanup_chunk(){ +} + +} +} |
