From 9195e0017ef8ac6cceec11ca082d4b688d9a55c9 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 30 Apr 2025 13:29:32 +0200 Subject: Compiling vtk generic write --- c++/particle/particle.hpp | 2 +- c++/write_vtk.hpp | 70 +++++++++++++++++++++++++++++++++++------------ 2 files changed, 54 insertions(+), 18 deletions(-) (limited to 'c++') diff --git a/c++/particle/particle.hpp b/c++/particle/particle.hpp index d253e64..1c7b241 100644 --- a/c++/particle/particle.hpp +++ b/c++/particle/particle.hpp @@ -35,7 +35,7 @@ class particle_system { private: saw::data> particles_; - void verlet_step(saw::data& particle, saw::data time_step_delta){ + void verlet_step(saw::data>& particle, saw::data time_step_delta){ auto& body = particle.template get<"rigid_body">(); auto& pos = body.template get<"position">(); diff --git a/c++/write_vtk.hpp b/c++/write_vtk.hpp index 7bde854..3a2bd68 100644 --- a/c++/write_vtk.hpp +++ b/c++/write_vtk.hpp @@ -2,34 +2,64 @@ #include +#include + +#include "descriptor.hpp" + +#include + namespace kel { namespace lbm { namespace impl { +template +struct lbm_vtk_writer { +}; + template -struct lbm_vtk_writer...> { +struct lbm_vtk_writer...>> { saw::error_or apply(){ return saw::make_void(); } }; -template -struct lbm_vtk_writer { +template +struct lbm_vtk_writer> { + static saw::error_or apply(std::ofstream& vtk_file, std::string_view name){ + vtk_file<<"VECTORS "< -struct lbm_vtk_writer...>>> { +struct lbm_vtk_writer...>>> { + template + saw::error_or write_i_iterate_d(std::ofstream& vtk_file, const saw::data...>>>& field, saw::data>& index){ + if constexpr (Dep == Desc::D){ + + } + } + template - saw::error_or write_i(std::ofstream& vtk_file, const saw::data...>>>& field){ + saw::error_or write_i(std::ofstream& vtk_file, const saw::data...>>>& field){ - // vtk_file<< + auto meta = field.meta(); + saw::data> index; + for(saw::data it{0}; it.get() < Desc::D; ++it){ + index.at({0u}).set(0u); + } + // vtk_file write? + // Data header + { + auto eov = lbm_vtk_writer::type>::apply(vtk_file, saw::parameter_key_pack_type::literal.view()); + } + return write_i_iterate_d(vtk_file, field, index); return saw::make_void(); } template - saw::error_or iterate_i(std::ofstream& vtk_file, const saw::data...>>>& field){ + saw::error_or iterate_i(std::ofstream& vtk_file, const saw::data...>>>& field){ { auto eov = write_i(vtk_file, field); if(eov.is_error()){ @@ -43,28 +73,35 @@ struct lbm_vtk_writer...>>> { } saw::error_or apply(std::ofstream& vtk_file, - const saw::data...>>>& field){ + const saw::data...>>>& field){ auto meta = field.meta(); + saw::data pd_size{1u}; // DIMENSIONS { vtk_file << "DIMENSIONS "; - for(saw::data i{0u}; i < Desc::D; ++i){ + for(saw::data i{0u}; i.get() < Desc::D; ++i){ + pd_size = pd_size * meta.at(i); vtk_file << " " << meta.at(i).get(); } - for(saw::data i{Desc::D}; i < 3u; ++i){ + for(saw::data i{Desc::D}; i.get() < 3u; ++i){ vtk_file << " 1"; } vtk_file << "\n"; } - // HEADER TO BODY - { - vtk_file << "\n"; - } - if constexpr (sizeof...(StructT) > 0u){ + // POINT DATA + { + vtk_file << "POINT_DATA " << pd_size.get() <<"\n"; + } + + // HEADER TO BODY + { + vtk_file << "\n"; + } + return iterate_i<0u>(vtk_file, field); } @@ -93,7 +130,7 @@ saw::error_or write_vtk(const std::string_view file_name, const saw::data< ; - auto eov = lbm_vtk_writer::apply(vtk_file, field); + auto eov = impl::lbm_vtk_writer::apply(vtk_file, field); return eov; /* vtk_file <<"# vtk DataFile Version 3.0\n"; @@ -106,7 +143,6 @@ saw::error_or write_vtk(const std::string_view file_name, const saw::data< vtk_file <<"POINT_DATA "<<(dim_x*dim_y)<<"\n"; vtk_file <<"VECTORS Velocity float\n"; */ -:w } } } -- cgit v1.2.3