VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
WbWriterVtkXmlImageBinary.h
Go to the documentation of this file.
1//=======================================================================================
2// ____ ____ __ ______ __________ __ __ __ __
3// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
4// \ \ | | | | | |_) | | | | | | | / \ | |
5// \ \ | | | | | _ / | | | | | | / /\ \ | |
6// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
7// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
8// \ \ | | ________________________________________________________________
9// \ \ | | | ______________________________________________________________|
10// \ \| | | | __ __ __ __ ______ _______
11// \ | | |_____ | | | | | | | | | _ \ / _____)
12// \ | | _____| | | | | | | | | | | \ \ \_______
13// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
14// \ _____| |__| |________| \_______/ |__| |______/ (_______/
15//
16// This file is part of VirtualFluids. VirtualFluids is free software: you can
17// redistribute it and/or modify it under the terms of the GNU General Public
18// License as published by the Free Software Foundation, either version 3 of
19// the License, or (at your option) any later version.
20//
21// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT
22// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24// for more details.
25//
26// SPDX-License-Identifier: GPL-3.0-or-later
27// SPDX-FileCopyrightText: Copyright © VirtualFluids Project contributors, see AUTHORS.md in root folder
28//
33//=======================================================================================
34#ifndef WBWRITERVTKXMLIMAGEBINARY_H
35#define WBWRITERVTKXMLIMAGEBINARY_H
36
37#include <string>
38
40
41
42
44{
45public:
47 {
48 static WbWriterVtkXmlImageBinary instance;
49 return &instance;
50 }
51
54
55private:
57 {
58 if constexpr (sizeof(unsigned char) != 1)
59 throw UbException(UB_EXARGS, "machine error char type mismatch");
60 if constexpr (sizeof(int) != 4)
61 throw UbException(UB_EXARGS, "machine error int type mismatch");
62 if constexpr (sizeof(float) != 4)
63 throw UbException(UB_EXARGS, "machine error float type mismatch");
64 }
65
66 static const std::string pvdEndTag;
67
68public:
69 std::string getFileExtension() override { return ".bin.vti"; }
70
71 // write a metafile
72 std::string writeCollection(const std::string &filename, const std::vector<std::string> &filenames,
73 const double &timestep, const bool &sepGroups);
74 std::string addFilesToCollection(const std::string &filename, const std::vector<std::string> &filenames,
75 const double &timestep, const bool &sepGroups);
76 std::string writeParallelFile(const std::string &filename, const UbTupleInt6 &wholeExtent, const UbTupleFloat3 &origin, const UbTupleFloat3 &spacing,
77 std::vector<std::string> &pieceSources, std::vector<UbTupleInt6> &pieceExtents,
78 std::vector<std::string> &pointDataNames, std::vector<std::string> &cellDataNames);
79
81 // nodes
82 std::string writeNodesWithNodeData(const std::string &filename, std::vector<UbTupleFloat3> &nodes,
83 std::vector<std::string> &datanames,
84 std::vector<std::vector<double>> &nodedata) override;
85
87 // octs
88 // 7 ---- 6
89 // /| /|
90 // 4 +--- 5 |
91 // | | | |
92 // | 3 ---+ 2
93 // |/ |/
94 // 0 ---- 1
95 std::string writeOctsWithCellData(const std::string &filename, std::vector<UbTupleFloat3> &nodes,
96 std::vector<UbTupleInt8> &cells, std::vector<std::string> &datanames,
97 std::vector<std::vector<double>> &celldata) override;
98 std::string writeOctsWithNodeData(const std::string &filename, std::vector<UbTupleFloat3> &nodes,
99 std::vector<UbTupleUInt8> &cells, std::vector<std::string> &datanames,
100 std::vector<std::vector<double>> &nodedata) override;
101 void writeData(const std::string &vtkfilename,
102 std::vector<std::string> &pointDataNames, std::vector<std::string> &cellDataNames,
103 std::vector<std::vector<double>> &nodedata, std::vector<std::vector<double>> &celldata,
105 UbTupleFloat3 &origin, UbTupleFloat3 &spacing, UbTupleInt6 &extent, unsigned int precision=6);
106
107private:
108 void getMetaDataOfImage(std::vector<UbTupleFloat3> &nodes, UbTupleFloat3& origin, UbTupleFloat3& spacing, UbTupleInt6& extent);
109};
110
111#endif // WBWRITERVTKXMLIMAGEBINARY_H
112
std::string getFileExtension() override
WbWriterVtkXmlImageBinary(const WbWriterVtkXmlImageBinary &)=delete
const WbWriterVtkXmlImageBinary & operator=(const WbWriterVtkXmlImageBinary &)=delete
static WbWriterVtkXmlImageBinary * getInstance()
std::shared_ptr< T > SPtr
#define UB_EXARGS
Definition UbException.h:73
std::string addFilesToCollection(const std::string &filename, const std::vector< std::string > &filenames, const double &timestep, const bool &sepGroups)
void writeData(const std::string &vtkfilename, std::vector< std::string > &pointDataNames, std::vector< std::string > &cellDataNames, std::vector< std::vector< double > > &nodedata, std::vector< std::vector< double > > &celldata, UbTupleInt6 &wholeExtent, UbTupleFloat3 &origin, UbTupleFloat3 &spacing, UbTupleInt6 &extent, unsigned int precision=6)
std::string writeCollection(const std::string &filename, const std::vector< std::string > &filenames, const double &timestep, const bool &sepGroups)
std::string writeOctsWithNodeData(const std::string &filename, std::vector< UbTupleFloat3 > &nodes, std::vector< UbTupleUInt8 > &cells, std::vector< std::string > &datanames, std::vector< std::vector< double > > &nodedata) override
std::string writeNodesWithNodeData(const std::string &filename, std::vector< UbTupleFloat3 > &nodes, std::vector< std::string > &datanames, std::vector< std::vector< double > > &nodedata) override
std::string writeParallelFile(const std::string &filename, const UbTupleInt6 &wholeExtent, const UbTupleFloat3 &origin, const UbTupleFloat3 &spacing, std::vector< std::string > &pieceSources, std::vector< UbTupleInt6 > &pieceExtents, std::vector< std::string > &pointDataNames, std::vector< std::string > &cellDataNames)
std::string writeOctsWithCellData(const std::string &filename, std::vector< UbTupleFloat3 > &nodes, std::vector< UbTupleInt8 > &cells, std::vector< std::string > &datanames, std::vector< std::vector< double > > &celldata) override