Peano
Loading...
Searching...
No Matches
VTKTextFileWriter.h
Go to the documentation of this file.
1// This file is part of the Peano project. For conditions of distribution and
2// use, please see the copyright notice at www.peano-framework.org
3#pragma once
4
5
6#include "../../../PVDTimeSeriesWriter.h"
7#include "tarch/logging/Log.h"
9
10
11namespace tarch {
12 namespace plotter {
13 namespace griddata {
14 namespace unstructured {
15 namespace vtk {
16 class VTKTextFileWriter;
17 }
18 }
19 }
20 }
21}
22
23
52 private:
57
58 static const std::string HEADER;
59
61
63 const int _precision;
64
66 const std::string _doubleOrFloat;
67
72
77
82
83 std::string _vertexDescription;
84 std::string _cellDescription;
88
89 std::string _fileName;
90
91 void validateDataWriterIdentifier( const std::string& identifier ) const;
92
93
94 std::string setDoubleOrFloatString(const int precision){
95 if (precision < 7){
96 return "float";
97 } else {
98 return "double";
99 }
100 }
101
102 public:
103 VTKTextFileWriter(const std::string& fileName, const std::string& indexFileName, tarch::plotter::PVDTimeSeriesWriter::IndexFileMode modeFile, double timeStamp, const int precision=6);
105
106 virtual bool isOpen() override;
107
108 virtual bool writeToFile() override;
109
110 virtual void clear() override;
111
112 virtual VertexWriter* createVertexWriter() override;
113 virtual CellWriter* createCellWriter() override;
114 virtual CellDataWriter* createCellDataWriter( const std::string& identifier, int recordsPerCell ) override;
115 virtual VertexDataWriter* createVertexDataWriter( const std::string& identifier, int recordsPerVertex ) override;
116
127 private:
131 friend class VTKTextFileWriter;
132
137
142
146 std::ostringstream _out;
147
149
155 _myWriter(writer._myWriter),
156 _out() {
157 assertion(false);
158 }
159 public:
160 virtual ~VertexWriter();
161
162 virtual int plotVertex(const tarch::la::Vector<2,double>& position) override;
163 virtual int plotVertex(const tarch::la::Vector<3,double>& position) override;
164
165 virtual void close() override;
166 };
167
173 private:
177 friend class VTKTextFileWriter;
178
183
188
199
203 std::ostringstream _cellOut;
204
208 std::ostringstream _cellTypeOut;
209
211
212 CellWriter(const CellWriter& writer):
214 _myWriter(writer._myWriter),
216 _cellOut(),
217 _cellTypeOut() {
218 assertion(false);
219 }
220 public:
221 virtual ~CellWriter();
222
223 virtual int plotHexahedron(int vertexIndex[8]) override;
224
225 virtual int plotQuadrangle(int vertexIndex[4]) override;
226
227 virtual int plotLine(int vertexIndex[2]) override;
228
229 virtual int plotTriangle(int vertexIndex[3]) override;
230
231 virtual int plotPoint(int vertexIndex) override;
232
233 virtual void close() override;
234 };
235
238 private:
242 friend class VTKTextFileWriter;
243
247 const std::string _identifier;
248
254
259
263 std::ostringstream _out;
264
266
267 double _minValue;
268 double _maxValue;
269 CellDataWriter(const std::string& dataIdentifier, VTKTextFileWriter& writer, int recordsPerCell);
270
272 _myWriter(copy._myWriter) {
273 assertion(false);
274 }
275 public:
277
278 virtual void close() override;
279
280 virtual void plotCell( int index, double value ) override;
281 virtual void plotCell( int index, const tarch::la::Vector<2,double>& value ) override;
282 virtual void plotCell( int index, const tarch::la::Vector<3,double>& value ) override;
283 virtual void plotCell( int index, double* values, int numberOfValues ) override;
284
285 double getMinValue() const;
286 double getMaxValue() const;
287
288 virtual void assignRemainingCellsDefaultValues() override;
289 };
290
293 private:
297 friend class VTKTextFileWriter;
298
303
308
312 std::ostringstream _out;
313
315
316 double _minValue;
317 double _maxValue;
318
319 std::string _identifier;
320
321 VertexDataWriter(const std::string& dataIdentifier, VTKTextFileWriter& writer, int recordsPerVertex);
322
324 _myWriter(copy._myWriter) {
325 assertion(false);
326 }
327 public:
329
330 virtual void close() override;
331
332 virtual void plotVertex( int index, double value ) override;
333 virtual void plotVertex( int index, const tarch::la::Vector<2,double>& value ) override;
334 virtual void plotVertex( int index, const tarch::la::Vector<3,double>& value ) override;
335 virtual void plotVertex( int index, double* values, int numberOfValues ) override;
336
337 double getMinValue() const;
338 double getMaxValue() const;
339
341 };
342};
343
#define assertion(expr)
Log Device.
Definition Log.h:517
This is the vertex writer you have to create to plot the vertices.
virtual void plotCell(int index, double value) override
Write data for one cell.
virtual void plotCell(int index, double *values, int numberOfValues) override
virtual void plotCell(int index, const tarch::la::Vector< 2, double > &value) override
CellDataWriter(const std::string &dataIdentifier, VTKTextFileWriter &writer, int recordsPerCell)
virtual void close() override
If you close your writer, each cell/vertex has to be assigned a value, i.e.
virtual void plotCell(int index, const tarch::la::Vector< 3, double > &value) override
int _lastWriteCommandCellNumber
Is set to -1 in the beginning and then incremented by each data plot call.
int _cellListEntries
The tag CELLS in a vtk file requires the number of total entries in the following list of cell-interc...
virtual void plotVertex(int index, const tarch::la::Vector< 2, double > &value) override
virtual void plotVertex(int index, double value) override
Write data for one cell.
virtual void plotVertex(int index, double *values, int numberOfValues) override
VertexDataWriter(const std::string &dataIdentifier, VTKTextFileWriter &writer, int recordsPerVertex)
virtual void plotVertex(int index, const tarch::la::Vector< 3, double > &value) override
This is the vertex writer you have to create to plot the vertices.
VertexWriter(const VertexWriter &writer)
Do not copy a vertex writer.
virtual int plotVertex(const tarch::la::Vector< 3, double > &position) override
virtual int plotVertex(const tarch::la::Vector< 2, double > &position) override
virtual CellDataWriter * createCellDataWriter(const std::string &identifier, int recordsPerCell) override
Caller has to destroy this instance manually.
virtual void clear() override
Clear the writer, i.e.
void validateDataWriterIdentifier(const std::string &identifier) const
virtual CellWriter * createCellWriter() override
Caller has to destroy this instance manually.
const std::string _doubleOrFloat
either "float" or "double" depending on _precision
VTKTextFileWriter(const std::string &fileName, const std::string &indexFileName, tarch::plotter::PVDTimeSeriesWriter::IndexFileMode modeFile, double timeStamp, const int precision=6)
virtual VertexDataWriter * createVertexDataWriter(const std::string &identifier, int recordsPerVertex) override
Caller has to destroy this instance manually.
virtual VertexWriter * createVertexWriter() override
Caller has to destroy this instance manually.
Have to include this header, as I need access to the SYCL_EXTERNAL keyword.
Definition accelerator.h:19
Simple vector class.
Definition Vector.h:159