Peano
Loading...
Searching...
No Matches
VTUTextFileWriter.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 "tarch/logging/Log.h"
8#include <vector>
9#include <string>
10#include "../../../PVDTimeSeriesWriter.h"
11
12
13namespace tarch {
14 namespace plotter {
15 namespace griddata {
16 namespace unstructured {
17 namespace vtk {
18 class VTUTextFileWriter;
19 }
20 }
21 }
22 }
23}
24
25
54 private:
59
60 static const std::string HEADER;
61
62 const std::string _dataType;
63
65
70
75
76 std::string _vertexDescription;
77 std::string _cellDescription;
82
83 std::string _fileName;
84
85 void validateDataWriterIdentifier( const std::string& identifier ) const;
86
87 public:
88 VTUTextFileWriter(const std::string& fileName, const std::string& indexFileName, tarch::plotter::PVDTimeSeriesWriter::IndexFileMode modeFile, double timeStamp, const int precision=6);
90
91 virtual bool isOpen() override;
92
97 virtual bool writeToFile() override;
98
99 virtual void clear() override;
100
101 virtual VertexWriter* createVertexWriter() override;
102 virtual CellWriter* createCellWriter() override;
103 virtual CellDataWriter* createCellDataWriter( const std::string& identifier, int recordsPerCell ) override;
104 virtual VertexDataWriter* createVertexDataWriter( const std::string& identifier, int recordsPerVertex ) override;
105
112 const std::string& metaDataFilename,
113 const std::vector< std::string >& files
114 );
115
126 private:
130 friend class VTUTextFileWriter;
131
132
134 const std::string _dataType;
135
140
145
149 std::ostringstream _out;
150
151 VertexWriter(VTUTextFileWriter& writer, std::string datatype);
152
157 _dataType(writer._dataType),
159 _myWriter(writer._myWriter),
160 _out() {
161 assertion(false);
162 }
163 public:
164 virtual ~VertexWriter();
165
166 virtual int plotVertex(const tarch::la::Vector<2,double>& position) override;
167 virtual int plotVertex(const tarch::la::Vector<3,double>& position) override;
168
169 virtual void close() override;
170 };
171
177 private:
181 friend class VTUTextFileWriter;
182
183 const std::string _dataType;
184
190
195
199 std::ostringstream _connectivityOut;
200
204 std::ostringstream _offsetsOut;
205
209 std::ostringstream _typesOut;
210
211 CellWriter(VTUTextFileWriter& writer, std::string datatype);
212
213 CellWriter(const CellWriter& writer):
214 _dataType(writer._dataType),
217 _myWriter(writer._myWriter),
219 _offsetsOut(),
220 _typesOut() {
221 assertion(false);
222 }
223 public:
224 virtual ~CellWriter();
225
226 virtual int plotHexahedron(int vertexIndex[8]) override;
227
228 virtual int plotQuadrangle(int vertexIndex[4]) override;
229
230 virtual int plotLine(int vertexIndex[2]) override;
231
232 virtual int plotTriangle(int vertexIndex[3]) override;
233
234 virtual int plotPoint(int vertexIndex) override;
235
236 virtual void close() override;
237 };
238
241 private:
245 friend class VTUTextFileWriter;
246
247 const std::string _dataType;
248
252 const std::string _identifier;
253
259
264
268 std::ostringstream _out;
269
271
272 double _minValue;
273 double _maxValue;
274 CellDataWriter(const std::string& dataIdentifier, VTUTextFileWriter& writer, int recordsPerCell, std::string dataType);
275
277 _dataType(copy._dataType),
278 _myWriter(copy._myWriter) {
279 assertion(false);
280 }
281 public:
283
284 virtual void close() override;
285
286 virtual void plotCell( int index, double value ) override;
287 virtual void plotCell( int index, const tarch::la::Vector<2,double>& value ) override;
288 virtual void plotCell( int index, const tarch::la::Vector<3,double>& value ) override;
289 virtual void plotCell( int index, double* values, int numberOfValues ) override;
290
291 double getMinValue() const;
292 double getMaxValue() const;
293
294 virtual void assignRemainingCellsDefaultValues() override;
295 };
296
299 private:
303 friend class VTUTextFileWriter;
304
305 const std::string _dataType;
306
311
316
320 std::ostringstream _out;
321
323
324 double _minValue;
325 double _maxValue;
326
327 std::string _identifier;
328
329 VertexDataWriter(const std::string& dataIdentifier, VTUTextFileWriter& writer, int recordsPerVertex, std::string dataType);
330
332 _dataType(copy._dataType),
333 _myWriter(copy._myWriter) {
334 assertion(false);
335 }
336 public:
338
339 virtual void close() override;
340
341 virtual void plotVertex( int index, double value ) override;
342 virtual void plotVertex( int index, const tarch::la::Vector<2,double>& value ) override;
343 virtual void plotVertex( int index, const tarch::la::Vector<3,double>& value ) override;
344 virtual void plotVertex( int index, double* values, int numberOfValues ) override;
345
346 double getMinValue() const;
347 double getMaxValue() const;
348
350 };
351};
352
#define assertion(expr)
Log Device.
Definition Log.h:517
This is the vertex writer you have to create to plot the vertices.
CellDataWriter(const std::string &dataIdentifier, VTUTextFileWriter &writer, int recordsPerCell, std::string dataType)
virtual void plotCell(int index, double value) override
Write data for one cell.
virtual void plotCell(int index, const tarch::la::Vector< 3, double > &value) override
virtual void plotCell(int index, double *values, int numberOfValues) override
int _lastWriteCommandCellNumber
Is set to -1 in the beginning and then incremented by each data plot call.
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< 2, double > &value) override
CellWriter(VTUTextFileWriter &writer, std::string datatype)
virtual void plotVertex(int index, double value) override
Write data for one cell.
VertexDataWriter(const std::string &dataIdentifier, VTUTextFileWriter &writer, int recordsPerVertex, std::string dataType)
virtual void plotVertex(int index, const tarch::la::Vector< 2, double > &value) override
virtual void plotVertex(int index, double *values, int numberOfValues) override
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(VTUTextFileWriter &writer, std::string datatype)
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
const std::string _dataType
either "float" or "double" depending on _precision
void validateDataWriterIdentifier(const std::string &identifier) const
virtual CellDataWriter * createCellDataWriter(const std::string &identifier, int recordsPerCell) override
Caller has to destroy this instance manually.
virtual VertexDataWriter * createVertexDataWriter(const std::string &identifier, int recordsPerVertex) override
Caller has to destroy this instance manually.
void writeMetaDataFileForParallelSnapshot(const std::string &metaDataFilename, const std::vector< std::string > &files)
This can be called on any writer (if there are multiple ones in a parallel run), but it cannot be sta...
virtual void clear() override
Clear the writer, i.e.
VTUTextFileWriter(const std::string &fileName, const std::string &indexFileName, tarch::plotter::PVDTimeSeriesWriter::IndexFileMode modeFile, double timeStamp, const int precision=6)
virtual VertexWriter * createVertexWriter() override
Caller has to destroy this instance manually.
virtual CellWriter * createCellWriter() 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