summaryrefslogtreecommitdiff
path: root/examples/poiseulle_particles_2d_ibm_gpu
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2026-11-08 22:04:06 +0100
committerClaudius "keldu" Holeksa <mail@keldu.de>2026-11-08 22:04:06 +0100
commitc59aeef2e0c86ec3f0f34ce77c205f3ef0b034cc (patch)
tree7e29aea25537b31040c5bb3649749706e54e5706 /examples/poiseulle_particles_2d_ibm_gpu
parentfa6bc96b28f6654040992b282525b88d5d46aca9 (diff)
downloadlibs-lbm-c59aeef2e0c86ec3f0f34ce77c205f3ef0b034cc.tar.gz
Abstract move. Forstio independence
Diffstat (limited to 'examples/poiseulle_particles_2d_ibm_gpu')
-rw-r--r--examples/poiseulle_particles_2d_ibm_gpu/sim.cpp78
1 files changed, 39 insertions, 39 deletions
diff --git a/examples/poiseulle_particles_2d_ibm_gpu/sim.cpp b/examples/poiseulle_particles_2d_ibm_gpu/sim.cpp
index d63515d..b051c4e 100644
--- a/examples/poiseulle_particles_2d_ibm_gpu/sim.cpp
+++ b/examples/poiseulle_particles_2d_ibm_gpu/sim.cpp
@@ -18,7 +18,6 @@ constexpr uint64_t dim_x = dim_y * 20ul;
// constexpr uint64_t particle_amount = 1ul;
namespace sch {
-using namespace saw::schema;
using InfoChunk = Chunk<UInt8, 0u, dim_x, dim_y>;
@@ -66,10 +65,10 @@ using ParticleSpheroidGroup = ParticleGroup<
}
template<typename T, typename Desc>
-saw::error_or<void> setup_initial_conditions(
- saw::data<sch::ChunkStruct<T,Desc>>& fields,
- saw::data<sch::MacroStruct<T,Desc>>& macros,
- saw::data<sch::ParticleSpheroidGroup<T,Desc>>& particles
+kel::lbm::error_or<void> setup_initial_conditions(
+ kel::lbm::data<sch::ChunkStruct<T,Desc>>& fields,
+ kel::lbm::data<sch::MacroStruct<T,Desc>>& macros,
+ kel::lbm::data<sch::ParticleSpheroidGroup<T,Desc>>& particles
){
auto& info_f = fields.template get<"info">();
// Set everything as walls
@@ -153,7 +152,7 @@ saw::error_or<void> setup_initial_conditions(
// Particles
{
- saw::data<sch::Scalar<T>> dense_p;
+ kel::lbm::data<sch::Scalar<T>> dense_p;
dense_p.at({}).set(1);
auto& spheroid_grp = particles;
@@ -186,15 +185,15 @@ saw::error_or<void> setup_initial_conditions(
}
}
- return saw::make_void();
+ return kel::lbm::make_void();
}
template<typename T, typename Desc>
-saw::error_or<void> step(
- saw::data<sch::Ptr<sch::ChunkStruct<T,Desc>>,encode::Sycl<saw::encode::Native>>& fields,
- saw::data<sch::Ptr<sch::MacroStruct<T,Desc>>,encode::Sycl<saw::encode::Native>>& macros,
- saw::data<sch::Ptr<sch::ParticleSpheroidGroup<T,Desc>>,encode::Sycl<saw::encode::Native>>& particles,
- saw::data<sch::UInt64> t_i,
+kel::lbm::error_or<void> step(
+ kel::lbm::data<sch::Ptr<sch::ChunkStruct<T,Desc>>,encode::Sycl<kel::lbm::enc::Native>>& fields,
+ kel::lbm::data<sch::Ptr<sch::MacroStruct<T,Desc>>,encode::Sycl<kel::lbm::enc::Native>>& macros,
+ kel::lbm::data<sch::Ptr<sch::ParticleSpheroidGroup<T,Desc>>,encode::Sycl<kel::lbm::enc::Native>>& particles,
+ kel::lbm::data<sch::UInt64> t_i,
device& dev
){
auto& q = dev.get_handle();
@@ -203,7 +202,7 @@ saw::error_or<void> step(
q.submit([&](acpp::sycl::handler& h){
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;
+ kel::lbm::data<sch::FixedArray<sch::UInt64,Desc::D>> index;
for(uint64_t i = 0u; i < Desc::D; ++i){
index.at({{i}}).set(idx[i]);
}
@@ -240,7 +239,7 @@ saw::error_or<void> step(
iterator<Desc::D>::apply([&](const auto& index){
/// Calculate the shift from the mask
- saw::data<sch::Vector<T,Desc::D>> index_shift;
+ kel::lbm::data<sch::Vector<T,Desc::D>> index_shift;
for(uint64_t i = 0u; i < Desc::D; ++i){
index_shift.at({{i}}) = index.at({i}).template cast_to<T>() - com.at({}).at({{i}});
// Scale to LBM Grid
@@ -271,18 +270,18 @@ saw::error_or<void> step(
// auto coll_ev =
q.submit([&](acpp::sycl::handler& h){
// Need nicer things to handle the flow. I see improvement here
- component<T,Desc,cmpt::BGKGuo, encode::Sycl<saw::encode::Native>> collision{0.65};
- component<T,Desc,cmpt::BounceBack,encode::Sycl<saw::encode::Native>> bb;
- component<T,Desc,cmpt::AntiBounceBack<0u>,encode::Sycl<saw::encode::Native>> abb;
+ component<T,Desc,cmpt::BGKGuo, encode::Sycl<kel::lbm::enc::Native>> collision{0.65};
+ component<T,Desc,cmpt::BounceBack,encode::Sycl<kel::lbm::enc::Native>> bb;
+ component<T,Desc,cmpt::AntiBounceBack<0u>,encode::Sycl<kel::lbm::enc::Native>> abb;
- saw::data<sch::Scalar<T>> rho_b;
+ kel::lbm::data<sch::Scalar<T>> rho_b;
rho_b.at({}) = 1.0;
- saw::data<sch::Vector<T,Desc::D>> vel_b;
+ kel::lbm::data<sch::Vector<T,Desc::D>> vel_b;
vel_b.at({{0u}}) = 0.015;
- component<T,Desc,cmpt::Equilibrium,encode::Sycl<saw::encode::Native>> equi{rho_b,vel_b};
+ component<T,Desc,cmpt::Equilibrium,encode::Sycl<kel::lbm::enc::Native>> equi{rho_b,vel_b};
- component<T,Desc,cmpt::ZouHeHorizontal<true>,encode::Sycl<saw::encode::Native>> flow_in{
+ component<T,Desc,cmpt::ZouHeHorizontal<true>,encode::Sycl<kel::lbm::enc::Native>> flow_in{
[&](){
uint64_t target_t_i = 32u;
if(t_i.get() < target_t_i){
@@ -291,11 +290,11 @@ saw::error_or<void> step(
return 1.0002;
}()
};
- component<T,Desc,cmpt::ZouHeHorizontal<false>,encode::Sycl<saw::encode::Native>> flow_out{1.0};
+ component<T,Desc,cmpt::ZouHeHorizontal<false>,encode::Sycl<kel::lbm::enc::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;
+ kel::lbm::data<sch::FixedArray<sch::UInt64,Desc::D>> index;
for(uint64_t i = 0u; i < Desc::D; ++i){
index.at({{i}}).set(idx[i]);
}
@@ -335,13 +334,13 @@ saw::error_or<void> step(
// h.depends_on(collision_ev);
}).wait();
*/
- return saw::make_void();
+ return kel::lbm::make_void();
}
}
}
template<typename T, typename Desc>
-saw::error_or<void> lbm_main(int argc, char** argv){
+kel::lbm::error_or<void> lbm_main(int argc, char** argv){
using namespace kel::lbm;
/*
@@ -366,7 +365,7 @@ saw::error_or<void> lbm_main(int argc, char** argv){
std::error_code ec;
std::filesystem::create_directories(out_dir,ec);
if(ec != std::errc{}){
- return saw::make_error<saw::err::critical>("Could not create output directory");
+ return kel::lbm::make_error<kel::lbm::err::critical>("Could not create output directory");
}
}
@@ -379,16 +378,17 @@ saw::error_or<void> lbm_main(int argc, char** argv){
print_lbm_meta<T,Desc>(conv,{0.1},{1e-4},{0.4 * dim_y});
- // 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_ptr = saw::heap<saw::data<sch::ParticleSpheroidGroup<T,Desc>>>();
+ // kel::lbm::data<sch::FixedArray<sch::UInt64,Desc::D>> meta{{dim_x,dim_y}};
+ auto lbm_data_ptr = kel::lbm::heap<kel::lbm::data<sch::ChunkStruct<T,Desc>>>();
+ auto lbm_macro_data_ptr = kel::lbm::heap<kel::lbm::data<sch::MacroStruct<T,Desc>>>();
+ auto lbm_particle_ptr = kel::lbm::heap<kel::lbm::data<sch::ParticleSpheroidGroup<T,Desc>>>();
std::cout<<"Estimated Bytes: "<<memory_estimate<sch::ChunkStruct<T,Desc>,sch::MacroStruct<T,Desc>>().get()<<std::endl;
auto eo_aio = saw::setup_async_io();
if(eo_aio.is_error()){
- return std::move(eo_aio.get_error());
+ return kel::lbm::make_error<kel::lbm::err::critical>(
+ std::string{eo_aio.get_error().get_message()});
}
auto& aio = eo_aio.get_value();
saw::wait_scope wait{aio.event_loop};
@@ -420,9 +420,9 @@ saw::error_or<void> lbm_main(int argc, char** argv){
}
}
- 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{sycl_q};
+ kel::lbm::data<sch::ChunkStruct<T,Desc>, encode::Sycl<kel::lbm::enc::Native>> lbm_sycl_data{sycl_q};
+ kel::lbm::data<sch::MacroStruct<T,Desc>, encode::Sycl<kel::lbm::enc::Native>> lbm_sycl_macro_data{sycl_q};
+ kel::lbm::data<sch::ParticleSpheroidGroup<T,Desc>, encode::Sycl<kel::lbm::enc::Native>> lbm_sycl_particle{sycl_q};
sycl_q.wait();
{
@@ -447,11 +447,11 @@ saw::error_or<void> lbm_main(int argc, char** argv){
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);
- saw::data<sch::UInt64> time_steps{16u*4096ul};
+ kel::lbm::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){
+ for(kel::lbm::data<sch::UInt64> i{0u}; i < time_steps and krun; ++i){
// BC + Collision
{
auto eov = step<T,Desc>(lsd_view,lsdm_view,lsdp_view,i,dev);
@@ -492,10 +492,10 @@ saw::error_or<void> lbm_main(int argc, char** argv){
}
// Stream
sycl_q.submit([&](acpp::sycl::handler& h){
- component<T,Desc,cmpt::Stream,encode::Sycl<saw::encode::Native>> stream;
+ component<T,Desc,cmpt::Stream,encode::Sycl<kel::lbm::enc::Native>> stream;
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;
+ kel::lbm::data<sch::FixedArray<sch::UInt64,Desc::D>> index;
for(uint64_t i = 0u; i < Desc::D; ++i){
index.at({{i}}).set(idx[i]);
}
@@ -544,7 +544,7 @@ saw::error_or<void> lbm_main(int argc, char** argv){
}
sycl_q.wait();
- return saw::make_void();
+ return kel::lbm::make_void();
}
using FloatT = kel::lbm::sch::Float32;