From c0549d71b2109f10c1238db8b22362e7826ba61b Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sun, 5 Jul 2026 15:59:23 +0200 Subject: Just rename from lib to modules --- lib/core/c++/write_vtk.hpp | 256 --------------------------------------------- 1 file changed, 256 deletions(-) delete mode 100644 lib/core/c++/write_vtk.hpp (limited to 'lib/core/c++/write_vtk.hpp') diff --git a/lib/core/c++/write_vtk.hpp b/lib/core/c++/write_vtk.hpp deleted file mode 100644 index e852172..0000000 --- a/lib/core/c++/write_vtk.hpp +++ /dev/null @@ -1,256 +0,0 @@ -#pragma once - -#include - -#include -#include - -#include "descriptor.hpp" -#include "flatten.hpp" -#include "chunk.hpp" - -#include -#include - -namespace kel { -namespace lbm { -namespace impl { - -template -struct lbm_vtk_writer { -}; - -template -struct lbm_vtk_writer> { - static saw::error_or apply_header(std::ostream& vtk_file, std::string_view name){ - vtk_file<<"SCALARS "< apply(std::ostream& vtk_file, const saw::data>& field){ - if constexpr (std::is_same_v and D == 1u) { - vtk_file<().get()<<"\n"; - }else{ - vtk_file< -struct lbm_vtk_writer> { - static saw::error_or apply_header(std::ostream& vtk_file, std::string_view name){ - vtk_file<<"VECTORS "< apply(std::ostream& vtk_file, const saw::data>& field){ - saw::data> index; - for(saw::data it{0}; it.get() < D; ++it){ - index.at({0u}).set(0u); - } - - // vtk_file<<"VECTORS "< 0){ - vtk_file<<" "; - } - vtk_file< -struct lbm_vtk_writer> { - - template - static saw::error_or apply_d(std::ostream& vtk_file, const saw::data>& field, saw::data>& index){ - // VTK wants to iterate over z,y,x instead of x,y,z - // We could reorder the dimensions, but eh - if constexpr ( d > 0u){ - for(index.at({d-1u}) = 0u; index.at({d-1u}) < field.get_dims().at({d-1u}); ++index.at({d-1u})){ - auto eov = apply_d(vtk_file, field, index); - } - }else{ - auto eov = lbm_vtk_writer::apply(vtk_file, field.at(index)); - if(eov.is_error()) return eov; - } - return saw::make_void(); - } - - static saw::error_or apply(std::ostream& vtk_file, const saw::data>& field, std::string_view name){ - { - auto eov = lbm_vtk_writer::apply_header(vtk_file,name); - if(eov.is_error()){ - return eov; - } - } - saw::data> index; - for(saw::data it{0}; it.get() < sizeof...(D); ++it){ - index.at({0u}).set(0u); - } - - { - auto eov = apply_d(vtk_file, field, index); - if(eov.is_error()){ - return eov; - } - } - - vtk_file<<"\n"; - - return saw::make_void(); - } -}; - -template -struct lbm_vtk_writer> { - static saw::error_or apply_header(std::ostream& vtk_file, std::string_view name){ - vtk_file<<"VECTORS "< apply(std::ostream& vtk_file, const saw::data>& field){ - static_assert(D > 0, "Non-dimensionality is bad for velocity."); - static_assert(D <= 3, "4th dimension as well. Mostly due to vtk."); - - // vtk_file<<"VECTORS "< 0){ - vtk_file<<" "; - } - vtk_file< -struct lbm_vtk_writer> { - static saw::error_or apply_header(std::ostream& vtk_file, std::string_view name){ - vtk_file<<"SCALARS "< apply(std::ostream& vtk_file, const saw::data>& field){ - // vtk_file<<"VECTORS "< -struct lbm_vtk_writer,Keys>...>> final { - template - static saw::error_or iterate_i(std::ostream& vtk_file, - const saw::data,Keys>...>>& field){ - - if constexpr ( i < sizeof...(MemberT) ) { - using MT = typename saw::parameter_pack_type,Keys>...>::type; - { - auto eov = lbm_vtk_writer::apply(vtk_file,field.template get(), MT::KeyLiteral.view()); - if(eov.is_error()){ - return eov; - } - } - - return iterate_i(vtk_file, field); - } - - return saw::make_void(); - } - - - static saw::error_or apply(std::ostream& vtk_file, - const saw::data,Keys>...>>& field){ - - vtk_file - <<"# vtk DataFile Version 3.0\n" - <<"LBM File\n" - <<"ASCII\n" - <<"DATASET STRUCTURED_POINTS\n" - <<"SPACING 1.0 1.0 1.0\n" - <<"ORIGIN 0.0 0.0 0.0\n" - ; - - auto& field_0 = field.template get::literal>(); - auto meta = field_0.get_dims(); - - saw::data pd_size{1u}; - // DIMENSIONS - - { - vtk_file << "DIMENSIONS"; - pd_size.set(saw::ct_multiply::value); - - static_assert(saw::ct_multiply::value > 0u, "Invalid Dim size resulting in length 0u"); - - for(saw::data i{0u}; i.get() < sizeof...(Dims); ++i){ - vtk_file << " " << meta.at(i).get(); - } - for(saw::data i{sizeof...(Dims)}; i.get() < 3u; ++i){ - vtk_file << " 1"; - } - - vtk_file << "\n"; - } - if constexpr (sizeof...(MemberT) > 0u){ - // POINT DATA - { - vtk_file << "\nPOINT_DATA " << pd_size.get() <<"\n"; - } - - // HEADER TO BODY - { - vtk_file << "\n"; - } - } - - return iterate_i<0u>(vtk_file, field); - } -}; - -} - -template -saw::error_or write_vtk_file(const std::filesystem::path& out_dir, const std::string_view& file_name, uint64_t d_t, const saw::data& field){ - - auto vtk_dir = out_dir / "vtk"; - { - std::error_code ec; - std::filesystem::create_directories(vtk_dir,ec); - if(ec != std::errc{}){ - return saw::make_error("Could not create directory for write_vtk_file function"); - } - } - std::string ft_name{file_name}; - - std::stringstream sstr; - sstr - <("Could not open file."); - } - - auto eov = impl::lbm_vtk_writer::apply(vtk_file, field); - return eov; -} - -} -} -- cgit v1.2.3