diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-01-31 17:23:03 +0100 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-01-31 17:31:57 +0100 |
| commit | be2164a504bf8f825d7a76af9504633adcf2596f (patch) | |
| tree | e46644027ca897a3b0c6a9857c3ab6410e83f2e9 | |
| parent | a7a741216ef5e4513b2dc9272ebe0facf58c4ded (diff) | |
| download | libs-lbm-be2164a504bf8f825d7a76af9504633adcf2596f.tar.gz | |
Adding vtk writing
| -rw-r--r-- | examples/poiseulle_particles_2d_gpu/sim.cpp | 15 | ||||
| -rw-r--r-- | lib/core/c++/write_vtk.hpp | 12 | ||||
| -rw-r--r-- | lib/sycl/c++/data.hpp | 2 |
3 files changed, 24 insertions, 5 deletions
diff --git a/examples/poiseulle_particles_2d_gpu/sim.cpp b/examples/poiseulle_particles_2d_gpu/sim.cpp index 255aa6d..3f3a584 100644 --- a/examples/poiseulle_particles_2d_gpu/sim.cpp +++ b/examples/poiseulle_particles_2d_gpu/sim.cpp @@ -210,6 +210,21 @@ saw::error_or<void> lbm_main(int argc, char** argv){ return eov; } } + { + auto eov = dev.copy_to_host(lbm_sycl_data,*lbm_data_ptr); + if(eov.is_error()){ + return eov; + } + } + { + std::string file_name = "t_"; + file_name += std::to_string(i.get()); + file_name += ".vtk"; + auto eov = write_vtk_file(file_name, *lbm_data_ptr); + if(eov.is_error()){ + return eov; + } + } } sycl_q.wait(); diff --git a/lib/core/c++/write_vtk.hpp b/lib/core/c++/write_vtk.hpp index 7d42bc9..204bb87 100644 --- a/lib/core/c++/write_vtk.hpp +++ b/lib/core/c++/write_vtk.hpp @@ -32,15 +32,13 @@ struct lbm_vtk_writer<sch::Primitive<T,D>> { } }; -template<typename T, uint64_t D> +template<typename T, uint64_t... D> struct lbm_vtk_writer<sch::FixedArray<T,D>> { static saw::error_or<void> apply_header(std::ostream& vtk_file, std::string_view name){ vtk_file<<"VECTORS "<<name<<" float\n"; return saw::make_void(); } - static saw::error_or<void> apply(std::ostream& vtk_file, const saw::data<sch::FixedArray<T,D>>& field){ - static_assert(D > 0, "Non-dimensionality is bad for velocity."); - static_assert(D <= 3, "4th dimension as well. Mostly due to vtk."); + static saw::error_or<void> apply(std::ostream& vtk_file, const saw::data<sch::FixedArray<T,D...>>& field){ // vtk_file<<"VECTORS "<<name<<" float\n"; for(uint64_t i = 0u; i < D; ++i){ @@ -82,6 +80,12 @@ struct lbm_vtk_writer<sch::Vector<T,D>> { } }; +template<typename... Members> +struct lbm_vtk_writer<sch::Struct<Members...>> final { + template<uint64_t i> + lbm_vtk_writer<s +}; + template<uint64_t Dim, typename... StructT, saw::string_literal... StructN> struct lbm_vtk_writer<sch::Array<sch::Struct<sch::Member<StructT,StructN>...> , Dim>> { diff --git a/lib/sycl/c++/data.hpp b/lib/sycl/c++/data.hpp index 75112fb..5155a53 100644 --- a/lib/sycl/c++/data.hpp +++ b/lib/sycl/c++/data.hpp @@ -338,7 +338,7 @@ struct sycl_copy_helper<sch::Struct<Members...>, Encode> final { } - static saw::error_or<void> copy_to_host(saw::data<Schema,Encode>& sycl_data, saw::data<Schema,encode::Sycl<Encode>>& host_data, sycl::queue& q){ + static saw::error_or<void> copy_to_host(saw::data<Schema,encode::Sycl<Encode>>& sycl_data, saw::data<Schema,Encode>& host_data, sycl::queue& q){ return copy_to_host_member<0u>(sycl_data, host_data, q); } }; |
