diff options
Diffstat (limited to 'c++/write_vtk.hpp')
-rw-r--r-- | c++/write_vtk.hpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/c++/write_vtk.hpp b/c++/write_vtk.hpp index c9ecc99..0647db5 100644 --- a/c++/write_vtk.hpp +++ b/c++/write_vtk.hpp @@ -3,6 +3,7 @@ #include <forstio/error.hpp> #include <forstio/codec/data.hpp> +#include <forstio/codec/data_math.hpp> #include "descriptor.hpp" @@ -55,6 +56,31 @@ struct lbm_vtk_writer<sch::FixedArray<T,D>> { } }; +template<typename T, uint64_t D> +struct lbm_vtk_writer<sch::Vector<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::Vector<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."); + + // vtk_file<<"VECTORS "<<name<<" float\n"; + for(uint64_t i = 0u; i < D; ++i){ + if(i > 0){ + vtk_file<<" "; + } + vtk_file<<field.at({{i}}).get(); + } + for(uint64_t i = D; i < 3; ++i){ + vtk_file<<" 0"; + } + vtk_file<<"\n"; + return saw::make_void(); + } +}; + template<uint64_t Dim, typename... StructT, saw::string_literal... StructN> struct lbm_vtk_writer<sch::Array<sch::Struct<sch::Member<StructT,StructN>...> , Dim>> { |