diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-01-21 17:20:08 +0100 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-01-21 17:20:08 +0100 |
| commit | e60db388693b63be6d7e4c03234976b567378e94 (patch) | |
| tree | 3abb03636e8b10b575b746e3406e10fbf458903b /examples | |
| parent | b685014dd2c9cc88ed8ecef31530842309decf62 (diff) | |
| download | libs-lbm-e60db388693b63be6d7e4c03234976b567378e94.tar.gz | |
Fixing compilation errors
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/poiseulle_2d_gpu/poiseulle_2d_gpu.cpp | 2 | ||||
| -rw-r--r-- | examples/poiseulle_particles_2d_gpu/.nix/derivation.nix | 5 | ||||
| -rw-r--r-- | examples/poiseulle_particles_2d_gpu/sim.cpp | 98 |
3 files changed, 87 insertions, 18 deletions
diff --git a/examples/poiseulle_2d_gpu/poiseulle_2d_gpu.cpp b/examples/poiseulle_2d_gpu/poiseulle_2d_gpu.cpp index 0f0d219..1aaa5c0 100644 --- a/examples/poiseulle_2d_gpu/poiseulle_2d_gpu.cpp +++ b/examples/poiseulle_2d_gpu/poiseulle_2d_gpu.cpp @@ -338,9 +338,7 @@ saw::error_or<void> kel_main(int argc, char** argv){ } auto& lbm_dir = eo_lbm_dir.get_value(); auto out_dir = lbm_dir / "poiseulle_channel_2d_gpu"; - std::filesystem::create_directories(out_dir); - // lbm::converter<lbm::sch::Float64> conv { // delta_x diff --git a/examples/poiseulle_particles_2d_gpu/.nix/derivation.nix b/examples/poiseulle_particles_2d_gpu/.nix/derivation.nix index 127243d..e08f42a 100644 --- a/examples/poiseulle_particles_2d_gpu/.nix/derivation.nix +++ b/examples/poiseulle_particles_2d_gpu/.nix/derivation.nix @@ -26,11 +26,12 @@ stdenv.mkDerivation { forstio.async forstio.codec forstio.codec-unit - forstio.remote + forstio.remote + forstio.remote-filesystem forstio.codec-json adaptive-cpp kel.lbm.core -# kel-lbm.sycl + kel.lbm.sycl ]; preferLocalBuild = true; diff --git a/examples/poiseulle_particles_2d_gpu/sim.cpp b/examples/poiseulle_particles_2d_gpu/sim.cpp index 8bc60c9..be6b4f0 100644 --- a/examples/poiseulle_particles_2d_gpu/sim.cpp +++ b/examples/poiseulle_particles_2d_gpu/sim.cpp @@ -1,8 +1,15 @@ #include <kel/lbm/lbm.hpp> -#include <AdaptiveCpp/sycl/sycl.hpp> +#include <kel/lbm/sycl/lbm.hpp> + +#include <forstio/remote/filesystem/easy.hpp> +#include <forstio/codec/json/json.hpp> namespace kel { namespace lbm { + +constexpr uint64_t dim_x = 16u; +constexpr uint64_t dim_y = 4u; + namespace sch { using namespace saw::schema; @@ -14,6 +21,63 @@ using CellStruct = Struct< Member<Vector<T,Desc::D>, "velocity">, Member<Vector<T,Desc::D>, "force"> >; + + +using InfoChunk = Chunk<UInt8, 0u, dim_x, dim_y>; + +template<typename T, typename Desc> +using DfChunk = Chunk<FixedArray<T,Desc::Q>, 1u, dim_x, dim_y>; + +template<typename T, typename Desc> +using ChunkStruct = Struct< + Member<InfoChunk, "info"> +>; + +} + +template<typename T, typename Desc> +saw::error_or<void> setup_initial_conditions(saw::data<sch::ChunkStruct<T,Desc>>& fields){ + auto& info_f = fields.get<"info">(); + // Set everything as walls + iterator<Desc::D>::apply( + [&](auto& index){ + info_f.at(index).set(2u); + }, + {{0u,0u}}, + {{dim_x, dim_y}}, + {{0u,0u}} + ); + // Fluid + iterator<Desc::D>::apply( + [&](auto& index){ + info_f.at(index).set(1u); + }, + {{0u,0u}}, + {{dim_x, dim_y}}, + {{1u,1u}} + ); + + // Inflow + iterator<Desc::D>::apply( + [&](auto& index){ + info_f.at(index).set(3u); + }, + {{0u,0u}}, + {{1u, dim_y}}, + {{0u,1u}} + ); + + // Outflow + iterator<Desc::D>::apply( + [&](auto& index){ + info_f.at(index).set(4u); + }, + {{dim_x-1u,0u}}, + {{dim_x, dim_y}}, + {{0u,1u}} + ); + + return saw::make_void(); } template<typename T, typename Desc> @@ -25,48 +89,54 @@ saw::error_or<void> step(){ } template<typename T, typename Desc> -saw::error_or<void> kel_main(int argc, char** argv){ - using namespace kel; +saw::error_or<void> lbm_main(int argc, char** argv){ + using namespace kel::lbm; - using dfi = lbm::df_info<T,Desc>; + using dfi = df_info<T,Desc>; - auto eo_lbm_dir = lbm::output_directory(); + auto eo_lbm_dir = output_directory(); if(eo_lbm_dir.is_error()){ return std::move(eo_lbm_dir.get_error()); } auto& lbm_dir = eo_lbm_dir.get_value(); auto out_dir = lbm_dir / "poiseulle_particles_2d_gpu"; - lbm::converter<lbm::sch::Float64> conv { + converter<sch::Float64> conv { // delta_x {{1.0}}, // delta_t {{1.0}} }; - uint64_t x_d = 256u; - uint64_t y_d = 64u; - saw::data<sch::FixedArray<sch::UInt64,Desc::D>> meta{{x_d,y_d}}; - saw::data<sch::Array<lbm::sch::CellStruct<T,Desc>,Desc::D>> lbm_data{meta}; + // saw::data<sch::FixedArray<sch::UInt64,Desc::D>> meta{{dim_x,dim_y}}; + saw::data<sch::ChunkStruct<T,Desc>> lbm_data{}; acpp::sycl::queue sycl_q; sycl_q.wait(); { - auto eov = setup_initial_conditions(lbm_data); + auto eov = setup_initial_conditions<T,Desc>(lbm_data); if(eov.is_error()){ return eov; } } - + /* + iterator<Desc::D>::apply( + [&](auto& index){ + std::cout<<index.at({0u}).get()<<" "<<index.at({1u}).get()<<" "<<lbm_data.get<"info">().at(index).template cast_to<sch::UInt16>().get()<<"\n"; + }, + {{0u,0u}}, + {{dim_x, dim_y}} + ); + */ return saw::make_void(); } -using FloatT = kel::sch::Float32; +using FloatT = kel::lbm::sch::Float32; int main(int argc, char** argv){ - auto eov = kel_main<FloatT,kel::lbm::sch::D2Q9>(argc, argv); + auto eov = lbm_main<FloatT,kel::lbm::sch::D2Q9>(argc, argv); if(eov.is_error()){ auto& err = eov.get_error(); std::cerr<<"[Error] "<<err.get_category(); |
