From c59aeef2e0c86ec3f0f34ce77c205f3ef0b034cc Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sun, 8 Nov 2026 22:04:06 +0100 Subject: Abstract move. Forstio independence --- examples/poiseulle_3d/poiseulle_3d.cpp | 71 +++++++++++++++++----------------- 1 file changed, 35 insertions(+), 36 deletions(-) (limited to 'examples/poiseulle_3d') diff --git a/examples/poiseulle_3d/poiseulle_3d.cpp b/examples/poiseulle_3d/poiseulle_3d.cpp index 83d1af1..141dc5f 100644 --- a/examples/poiseulle_3d/poiseulle_3d.cpp +++ b/examples/poiseulle_3d/poiseulle_3d.cpp @@ -146,7 +146,6 @@ public: namespace kel { namespace lbm { namespace sch { -using namespace saw::schema; using T = Float32; using Desc = Descriptor<3u,27u>; @@ -161,21 +160,21 @@ using CellStruct = Struct< Member >; } -using SyclKelAllocator = acpp::sycl::usm_allocator, acpp::sycl::usm::alloc::shared>; +using SyclKelAllocator = acpp::sycl::usm_allocator, acpp::sycl::usm::alloc::shared>; -uint64_t to_flat_index(const saw::data>& index, const saw::data>& meta){ +uint64_t to_flat_index(const kel::lbm::data>& index, const kel::lbm::data>& meta){ auto flat = index.at({2u}) + meta.at({2u})*(index.at({1u}) + index.at({0u})*meta.at({1u})); return flat.get(); } template -saw::error_or set_geometry(std::vector,SyclKelAllocator>& latt, const saw::data>& meta){ +kel::lbm::error_or set_geometry(std::vector,SyclKelAllocator>& latt, const kel::lbm::data>& meta){ using namespace kel::lbm; /** * Set ghost */ - iterator::apply([&](const saw::data>& index){ + iterator::apply([&](const kel::lbm::data>& index){ auto findex = to_flat_index(index,meta); auto& cell = latt.at(findex); auto& info = cell.template get<"info">(); @@ -183,17 +182,17 @@ saw::error_or set_geometry(std::vector,SyclKe info({0u}).set(0u); }, {{0u,0u}}, meta); - saw::data> distance; + kel::lbm::data> distance; /** * Set wall */ - iterator<1u>::apply([&](const saw::data>& index){ + iterator<1u>::apply([&](const kel::lbm::data>& index){ distance.at(index.at({0u})) = {1u}; },{{0u}},{{sch::Desc::D}}); /* */ - iterator::apply([&](const saw::data>& index){ + iterator::apply([&](const kel::lbm::data>& index){ auto findex = to_flat_index(index,meta); auto& cell = latt.at(findex); auto& info = cell.template get<"info">(); @@ -204,12 +203,12 @@ saw::error_or set_geometry(std::vector,SyclKe /** * Set fluid */ - iterator<1u>::apply([&](const saw::data>& index){ + iterator<1u>::apply([&](const kel::lbm::data>& index){ distance.at(index.at({0u})) = {2u}; },{{0u}},{{sch::Desc::D}}); /* */ - iterator::apply([&](const saw::data>& index){ + iterator::apply([&](const kel::lbm::data>& index){ auto findex = to_flat_index(index,meta); auto& cell = latt.at(findex); auto& info = cell.template get<"info">(); @@ -222,14 +221,14 @@ saw::error_or set_geometry(std::vector,SyclKe * Set inflow */ - saw::data> shifted_point; - iterator<1u>::apply([&](const saw::data>& index){ + kel::lbm::data> shifted_point; + iterator<1u>::apply([&](const kel::lbm::data>& index){ distance.at(index.at({0u})) = (index.at({0u}).get() == 0u)?1u:2u; shifted_point.at(index.at({0u})) = (index.at({0u}).get() == 0u)?3u:meta.at({index.at({0u})}); },{{0u}},{{sch::Desc::D}}); /* */ - iterator::apply([&](const saw::data>& index){ + iterator::apply([&](const kel::lbm::data>& index){ auto findex = to_flat_index(index,meta); auto& cell = latt.at(findex); auto& info = cell.template get<"info">(); @@ -241,13 +240,13 @@ saw::error_or set_geometry(std::vector,SyclKe /** * Set outflow */ - iterator<1u>::apply([&](const saw::data>& index){ + iterator<1u>::apply([&](const kel::lbm::data>& index){ distance.at(index.at({0u})) = (index.at({0u}).get() == 0u)?1u:2u; shifted_point.at(index.at({0u})) = (index.at({0u}).get() == 0u)?(meta.at({0u})-3u):0u; },{{0u}},{{sch::Desc::D}}); /* */ - iterator::apply([&](const saw::data>& index){ + iterator::apply([&](const kel::lbm::data>& index){ auto findex = to_flat_index(index,meta); auto& cell = latt.at(findex); auto& info = cell.template get<"info">(); @@ -256,51 +255,51 @@ saw::error_or set_geometry(std::vector,SyclKe }, shifted_point, meta, distance); - return saw::make_void(); + return kel::lbm::make_void(); } template -saw::error_or set_initial_conditions(std::vector,SyclKelAllocator>& latt, const saw::data>& meta){ +kel::lbm::error_or set_initial_conditions(std::vector,SyclKelAllocator>& latt, const kel::lbm::data>& meta){ - saw::data rho{1.0}; - saw::data> vel{}; + kel::lbm::data rho{1.0}; + kel::lbm::data> vel{}; vel.at({0u}) = {0.1f}; auto eq = equilibrium(rho, vel); /** * Set distribution */ - iterator::apply([&](const saw::data>& index){ + iterator::apply([&](const kel::lbm::data>& index){ auto findex = to_flat_index(index,meta); auto& cell = latt.at(findex); auto& dfs = cell.template get<"dfs">(); auto& dfs_old = cell.template get<"dfs_old">(); - for(saw::data k = 0; k < saw::data{sch::Desc::Q}; ++k){ + for(kel::lbm::data k = 0; k < kel::lbm::data{sch::Desc::Q}; ++k){ dfs(k) = eq.at(k); dfs_old(k) = eq.at(k); } }, {}, meta); - return saw::make_void(); + return kel::lbm::make_void(); } template -saw::error_or lbm_step( - std::vector,SyclKelAllocator>& latt, - const saw::data>& meta, - saw::data time_step, +kel::lbm::error_or lbm_step( + std::vector,SyclKelAllocator>& latt, + const kel::lbm::data>& meta, + kel::lbm::data time_step, acpp::sycl::queue& sycl_q ){ using dfi = df_info; bool even_step = ((time_step.get() % 2u) == 0u); - component coll{0.5384}; - component bb; + component coll{0.5384}; + component bb; /** * Collision */ - iterator::apply([&](const saw::data>& index){ + iterator::apply([&](const kel::lbm::data>& index){ auto findex = to_flat_index(index,meta); auto& cell = latt.at(findex); auto& info = cell.template get<"info">(); @@ -329,7 +328,7 @@ saw::error_or lbm_step( }, {}, meta); // Stream - iterator::apply([&](const saw::data>& index){ + iterator::apply([&](const kel::lbm::data>& index){ auto findex = to_flat_index(index,meta); auto& cell = latt.at(findex); auto& df_new = even_step ? cell.template get<"dfs">() : cell.template get<"dfs_old">(); @@ -352,10 +351,10 @@ saw::error_or lbm_step( } } }, {}, meta); - return saw::make_void(); + return kel::lbm::make_void(); } -saw::error_or real_main(int argc, char** argv){ +kel::lbm::error_or real_main(int argc, char** argv){ using dfi = df_info; converter conv { @@ -369,10 +368,10 @@ saw::error_or real_main(int argc, char** argv){ /** * Set the meta and initialize the lattice */ - saw::data> meta{{2048u,128u,128u}}; + kel::lbm::data> meta{{2048u,128u,128u}}; SyclKelAllocator sycl_shared_alloc{sycl_q}; - std::vector,SyclKelAllocator> lattice{(meta.at({0u})*meta.at({1u})*meta.at({2u})).get(), sycl_shared_alloc}; + std::vector,SyclKelAllocator> lattice{(meta.at({0u})*meta.at({1u})*meta.at({2u})).get(), sycl_shared_alloc}; /** * Set the geometry @@ -394,14 +393,14 @@ saw::error_or real_main(int argc, char** argv){ } } - for(saw::data ts{0u}; ts < saw::data{1024u*32u}; ++ts){ + for(kel::lbm::data ts{0u}; ts < kel::lbm::data{1024u*32u}; ++ts){ auto eov = lbm_step(lattice,meta,ts,sycl_q); if(eov.is_error()){ return eov; } } - return saw::make_void(); + return kel::lbm::make_void(); } } // lbm -- cgit v1.3.1