OpenLB 1.7
Loading...
Searching...
No Matches
vtkWriter.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2013-2016 Thomas Henn, Mathias J. Krause
4 * 2016-2017 Albert Mink, Maximilian Gaedtke, Markus Morhard, Mathias J. Krause
5 * 2021 Nicolas Hafen, Mathias J. Krause
6 * E-mail contact: info@openlb.net
7 * The most recent release of OpenLB can be downloaded at
8 * <http://www.openlb.net/>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public
21 * License along with this program; if not, write to the Free
22 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 * Boston, MA 02110-1301, USA.
24 */
25
26#ifndef VTK_WRITER_H
27#define VTK_WRITER_H
28
49namespace olb {
50
51//Define vtkType enumarator
52enum vtkType { VTI, VTU, VTP };
53
54//VTKwriter class
55template<typename T, typename FUNCTOR, vtkType VTKTYPE>
56class VTKwriter {
57public:
58 static constexpr bool parallel = FUNCTOR::isSuper;
59 static constexpr unsigned D = FUNCTOR::d;
61 VTKwriter( const std::string & name, bool binary=true, bool compress=true );
64 void addFunctor(FUNCTOR& f);
67 void addFunctor(FUNCTOR& f, const std::string& functorName);
69 //
70
71
72
73
74 template<bool vtmAsMaster,typename F>
75 void write(int iT, std::string nameCollection, F applyFunctors);
76 void write(int iT = 0);
77 void write(FUNCTOR& f, int iT = 0);
78 void write(std::shared_ptr<FUNCTOR> ptr_f, int iT = 0);
80 // the master pvd file, where all data files are linked!
81 void createMasterFile();
82
83protected:
85 void preamblePVD(const std::string& fullNamePVD);
87 void dataPVD(int iT, const std::string& fullNamePVD,
88 const std::string& namePiece);
90 void closePVD(const std::string& fullNamePVD);
91
93 void preambleVTM(const std::string& fullNameVTM);
95 void closeVTM(const std::string& fullNameVTM);
98 void dataVTM(int iC, const std::string& fullNameVTM, const std::string& namePiece);
100 template<bool vtmAsMaster=false>
101 void writeVTM(int iT, int rankSize, std::string fileExtension, std::string nameCollection);
103 void preambleVTU(const std::string& fullName, Vector<int,1> extent1);
105 void closeVTU(const std::string& fullNamePiece);
107 void cellDataVTU(const std::string& fullName, Vector<int,1> extent1);
108
110 void preambleVTI(const std::string& fullName,
111 const LatticeR<D> extent0, const LatticeR<D> extent1,
112 PhysR<T,D> origin, T delta);
114 void closeVTI(const std::string& fullNamePiece);
116 void closePiece(const std::string& fullNamePiece);
117
118
120 template<unsigned sourceDim>
121 void dataArrayPoints(const std::string& fullName,
122 Vector<int,sourceDim> extent1, int iC=0 );
124 template<unsigned sourceDim>
125 void dataArraySingleFunctor(const std::string& fullName,
126 FUNCTOR& f,
127 Vector<int,sourceDim> extent1, int iC=0 );
128private:
129 mutable OstreamManager clout;
131 bool _createFile;
133 std::string const _name;
135 std::vector<FUNCTOR*> _pointerVec;
137 bool _binary;
139 bool _compress;
140};
141
142
143//VTU: vtk writer for unstructured data
144template<typename T, typename DESCRIPTOR, bool parallel=true>
146 T,
147 typename std::conditional_t<
148 parallel,
151 >,
152 VTU
153>;
154
155//VTI (image) version, corresponding to original SuperVTMwriterXD
156template<typename T, typename DESCRIPTOR>
158 T,
160 VTI
161>;
162
163} // namespace OLB
164
165#endif
ContainerF is a NON-PARALLELIZED (no block/super differentiation) functor intended to extract data fr...
class for marking output with some text
represents all functors that operate on a SuperStructure<T,3> in general
void closeVTI(const std::string &fullNamePiece)
performes </ImageData> and </VTKFile>
Definition vtkWriter.hh:381
void dataArraySingleFunctor(const std::string &fullName, FUNCTOR &f, Vector< int, sourceDim > extent1, int iC=0)
writes functors stored at pointerVec
Definition vtkWriter.hh:548
void closeVTU(const std::string &fullNamePiece)
performes </ImageData> and </VTKFile>
Definition vtkWriter.hh:323
void preambleVTM(const std::string &fullNameVTM)
performes <VTKFile ...> and <Collection>
Definition vtkWriter.hh:438
VTKwriter(const std::string &name, bool binary=true, bool compress=true)
constructor
Definition vtkWriter.hh:35
void preamblePVD(const std::string &fullNamePVD)
performes <VTKFile ...> and <Collection>
Definition vtkWriter.hh:407
void createMasterFile()
have to be called before calling write(int iT=0), since it creates
Definition vtkWriter.hh:283
void closeVTM(const std::string &fullNameVTM)
performes </Collection> and </VTKFile>
Definition vtkWriter.hh:452
static constexpr unsigned D
Definition vtkWriter.h:59
void dataVTM(int iC, const std::string &fullNameVTM, const std::string &namePiece)
performes <DataSet timestep= ... file=namePiece > used for linking vti into pvd files
Definition vtkWriter.hh:465
void dataArrayPoints(const std::string &fullName, Vector< int, sourceDim > extent1, int iC=0)
writes points necessary for VTU
Definition vtkWriter.hh:501
void write(int iT, std::string nameCollection, F applyFunctors)
to clear stored functors, not yet used due to lack of necessity
Definition vtkWriter.hh:92
void closePiece(const std::string &fullNamePiece)
performes </PointData> and </Piece>
Definition vtkWriter.hh:394
void preambleVTU(const std::string &fullName, Vector< int, 1 > extent1)
performes <VTKFile ...>, <ImageData ...> and <PieceExtent ...>
Definition vtkWriter.hh:299
void preambleVTI(const std::string &fullName, const LatticeR< D > extent0, const LatticeR< D > extent1, PhysR< T, D > origin, T delta)
performes <VTKFile ...>, <ImageData ...>, <PieceExtent ...> and <PointData ...>
Definition vtkWriter.hh:341
void closePVD(const std::string &fullNamePVD)
performes </Collection> and </VTKFile>
Definition vtkWriter.hh:422
static constexpr bool parallel
Definition vtkWriter.h:58
void cellDataVTU(const std::string &fullName, Vector< int, 1 > extent1)
TODO: add description: connectivity, offsete, type of unscructured nodes.
Definition vtkWriter.hh:519
void addFunctor(FUNCTOR &f)
put functor to _pointerVec to simplify writing process of several functors
Definition vtkWriter.hh:41
void writeVTM(int iT, int rankSize, std::string fileExtension, std::string nameCollection)
wrapper for VTM file creation
Definition vtkWriter.hh:56
void dataPVD(int iT, const std::string &fullNamePVD, const std::string &namePiece)
performes <DataSet timestep= ... file=namePiece >
Definition vtkWriter.hh:480
Plain old scalar vector.
Definition vector.h:47
Top level namespace for all of OpenLB.
vtkType
Definition vtkWriter.h:52
@ VTU
Definition vtkWriter.h:52
@ VTP
Definition vtkWriter.h:52
@ VTI
Definition vtkWriter.h:52