Loading...
Searching...
No Matches
foamVtkOutput.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2016-2025 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Namespace
27 Foam::vtk
28
29Description
30 Namespace for handling VTK output.
31 Contains classes and functions for writing VTK file content.
32
33Namespace
34 Foam::vtk::legacy
35
36Description
37 Namespace for legacy VTK output constants and functions.
38
39SourceFiles
40 foamVtkOutput.cxx
41 foamVtkOutput.txx
42 foamVtkOutputI.H
43
44\*---------------------------------------------------------------------------*/
45
46#ifndef Foam_vtk_output_H
47#define Foam_vtk_output_H
48
49#include "autoPtr.H"
50#include "bitSet.H"
51#include "Enum.H"
52#include "foamVtkCore.H"
53#include "foamVtkFormatter.H"
54#include "floatScalar.H"
55#include "symmTensor.H"
56#include "IOstream.H"
57
58// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59
60namespace Foam
61{
62
63// Forward Declarations
64class instant;
65class globalIndex;
66
67namespace vtk
68{
69
70// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71
72// General Functions
73
74 //- Return a default asciiFormatter
76 (
77 std::ostream& os,
78 unsigned prec = IOstream::defaultPrecision()
79 );
80
81 //- Return a new formatter based on the specified format type
83 (
84 std::ostream& os,
85 const enum formatType fmtType,
86 unsigned prec = IOstream::defaultPrecision()
87 );
88
89
90 //- Write an identity list of labels.
91 // The output does not include the payload size.
92 void writeIdentity(vtk::formatter& fmt, const label len, label start=0);
93
94 //- Write a list of uint8_t values.
95 // The output does not include the payload size.
96 void writeList(vtk::formatter& fmt, const UList<uint8_t>& values);
97
98 //- Component-wise write of a value (N times)
99 template<class Type>
100 inline void write(vtk::formatter& fmt, const Type& val, const label n=1);
101
102 //- Component-wise write of a value (N times) in parallel
103 // The value and count may differ on each processor
104 template<class Type>
105 inline void writeValueParallel
106 (
107 vtk::formatter& fmt,
108 const Type& val,
109 const label count=1
110 );
111
112
113 //- Write a list of values.
114 // The output does not include the payload size.
115 template<class Type>
116 void writeList(vtk::formatter& fmt, const UList<Type>& values);
118 //- Write a list of values.
119 // The output does not include the payload size.
120 template<class Type, unsigned N>
121 void writeList(vtk::formatter& fmt, const FixedList<Type, N>& values);
122
123
124 //- Write a list of values via indirect addressing.
125 // The output does not include the payload size.
126 template<class Type>
127 void writeList
128 (
129 vtk::formatter& fmt,
130 const UList<Type>& values,
131 const labelUList& addressing
132 );
133
134 //- Write a list of values via indirect addressing.
135 // The output does not include the payload size.
136 template<class Type>
137 void writeList
138 (
140 const UList<Type>& values,
141 const bitSet& selected
142 );
143
144 //- Write a list of values and a list of values via indirect addressing.
145 // The output does not include the payload size.
146 template<class Type>
147 void writeLists
149 vtk::formatter& fmt,
150 const UList<Type>& values1,
151 const UList<Type>& values2,
152 const labelUList& addressing
153 );
154
155
156 //- Write a list of values.
157 // The output does not include the payload size.
158 template<class Type>
160 (
162 const UList<Type>& values
163 );
164
165 //- Write a list of values, with constant per-processor offset
166 // The output does not include the payload size.
168 (
169 vtk::formatter& fmt,
170 const UList<label>& values,
172 const globalIndex& procOffset
173 );
175 //- Write a list of values via indirect addressing.
176 // The output does not include the payload size.
177 template<class Type>
179 (
180 vtk::formatter& fmt,
181 const UList<Type>& values,
182 const labelUList& addressing
183 );
184
185 //- Write a list of values via indirect addressing.
186 // The output does not include the payload size.
187 template<class Type>
190 vtk::formatter& fmt,
191 const UList<Type>& values,
192 const bitSet& selected
193 );
194
195 //- Write a list of values and another list of values.
196 // The output does not include the payload size.
197 template<class Type>
199 (
201 const UList<Type>& values1,
202 const UList<Type>& values2
203 );
204
205 //- Write a list of values and a list of values via indirect addressing.
206 // The output does not include the payload size.
207 template<class Type>
209 (
210 vtk::formatter& fmt,
211 const UList<Type>& values1,
212 const UList<Type>& values2,
213 const labelUList& addressing
214 );
215
216
217/*---------------------------------------------------------------------------*\
218 Namespace legacy
219\*---------------------------------------------------------------------------*/
220
221namespace legacy
222{
223
224// Functions
225
226 //- Emit header for legacy file (vtk DataFile Version 2.0)
227 // Writes "ASCII" or "BINARY" depending on specified type.
228 void fileHeader(std::ostream& os, const std::string& title, bool binary);
229
230 //- Emit header for legacy file, with "ASCII" or "BINARY" depending on
231 //- the formatter type.
232 // If the contentType is non-empty, it is used for "DATASET" line.
233 void fileHeader
234 (
235 vtk::formatter& fmt,
236 const std::string& title,
237 const std::string& contentType
238 );
239
240 //- Emit header for legacy file, with "ASCII" or "BINARY" depending on
241 //- the formatter type.
242 // Includes "DATASET" with the specified dataset type.
243 inline void fileHeader
244 (
245 vtk::formatter& fmt,
246 const std::string& title,
247 vtk::fileTag contentType
248 );
249
250 //- Emit header for legacy file, with "ASCII" or "BINARY" depending on
251 //- the formatter type.
252 // Includes "DATASET" of the templated dataset type.
253 template<vtk::fileTag ContentType>
254 inline void fileHeader(vtk::formatter& fmt, const std::string& title);
255
256 //- Emit header for POINTS (with trailing newline).
257 inline void beginPoints(std::ostream& os, label nPoints);
258
259 //- Emit header for VERTICES (with trailing newline).
260 // The nConnectivity is the sum of all connectivity points used,
261 // but \b without additional space for the size prefixes.
262 // The additional prefix sizes are added internally.
263 // \note With nConnectivity == 0, assume one point per element
264 inline void beginVerts
265 (
266 std::ostream& os,
267 label nVerts,
268 label nConnectivity = 0
269 );
270
271 //- Emit header for LINES (with trailing newline).
272 // The nConnectivity is the sum of all connectivity points used,
273 // but \b without additional space for the size prefixes.
274 // The additional prefix sizes are added internally.
275 // \note With nConnectivity == 0, assume two points per element
276 inline void beginLines
277 (
278 std::ostream& os,
279 label nLines,
280 label nConnectivity = 0
281 );
282
283 //- Emit header for POLYGONS (with trailing newline).
284 // The nConnectivity is the sum of all connectivity points used,
285 // but \b without additional space for the size prefixes.
286 // The additional prefix sizes are added internally.
287 inline void beginPolys(std::ostream& os, label nPolys, label nConnectivity);
288
289
290 //- Emit "FIELD FieldData <n>"
291 inline void fieldData(vtk::formatter& fmt, label nFields);
292
293 //- Emit legacy FIELD FieldData nFields.
294 inline void beginFieldData(vtk::formatter& fmt, label nFields);
295
296 //- Emit legacy CELL_DATA nCells, FIELD FieldData nFields.
297 inline void beginCellData
298 (
299 vtk::formatter& fmt,
300 label nCells,
301 label nFields
302 );
303
304 //- Emit legacy POINT_DATA nPoints, FIELD FieldData nFields.
305 inline void beginPointData
306 (
307 vtk::formatter& fmt,
308 label nPoints,
309 label nFields
310 );
311
312
313 //- Emit "TimeValue" for a FIELD entry (name as per Catalyst output)
314 inline void writeTimeValue(vtk::formatter& fmt, scalar timeValue);
315
316 //- Start output of float field with the specified name.
317 template<direction nComp>
318 inline void floatField
319 (
320 vtk::formatter& fmt,
321 const word& name,
322 const label nEntries
323 );
324
325 //- Start output of double field with the specified name.
326 template<direction nComp>
327 inline void doubleField
328 (
329 vtk::formatter& fmt,
330 const word& name,
331 const label nEntries
332 );
333
334 //- Start output of int field with the specified name.
335 template<direction nComp>
336 inline void intField
337 (
338 vtk::formatter& fmt,
339 const word& name,
340 const label nEntries
341 );
342
343} // End namespace legacy
344
345
346// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
347
348} // End namespace vtk
349} // End namespace Foam
350
351
352// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
353
354#include "foamVtkOutputI.H"
355
356#ifdef NoRepository
357 #include "foamVtkOutput.txx"
358#endif
359
360// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
361
362#endif
363
364// ************************************************************************* //
label n
A 1D vector of objects of type <T> with a fixed length <N>.
Definition FixedList.H:73
static unsigned int defaultPrecision() noexcept
Return the default precision.
Definition IOstream.H:437
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition bitSet.H:61
Calculates a non-overlapping list of offsets based on an input size (eg, number of cells) from differ...
Definition globalIndex.H:77
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name.
Definition instant.H:56
Abstract class for a VTK output stream formatter.
A class for handling words, derived from Foam::string.
Definition word.H:66
OBJstream os(runTime.globalPath()/outputName)
label nPoints
Namespace for legacy VTK output constants and functions.
void intField(vtk::formatter &fmt, const word &name, const label nEntries)
Start output of int field with the specified name.
void beginPolys(std::ostream &os, label nPolys, label nConnectivity)
Emit header for POLYGONS (with trailing newline).
void beginLines(std::ostream &os, label nLines, label nConnectivity=0)
Emit header for LINES (with trailing newline).
void doubleField(vtk::formatter &fmt, const word &name, const label nEntries)
Start output of double field with the specified name.
void fieldData(vtk::formatter &fmt, label nFields)
Emit "FIELD FieldData <n>".
void beginPoints(std::ostream &os, label nPoints)
Emit header for POINTS (with trailing newline).
void beginCellData(vtk::formatter &fmt, label nCells, label nFields)
Emit legacy CELL_DATA nCells, FIELD FieldData nFields.
void fileHeader(std::ostream &os, const std::string &title, bool binary)
Emit header for legacy file (vtk DataFile Version 2.0).
void beginPointData(vtk::formatter &fmt, label nPoints, label nFields)
Emit legacy POINT_DATA nPoints, FIELD FieldData nFields.
void writeTimeValue(vtk::formatter &fmt, scalar timeValue)
Emit "TimeValue" for a FIELD entry (name as per Catalyst output).
void floatField(vtk::formatter &fmt, const word &name, const label nEntries)
Start output of float field with the specified name.
void beginVerts(std::ostream &os, label nVerts, label nConnectivity=0)
Emit header for VERTICES (with trailing newline).
void beginFieldData(vtk::formatter &fmt, label nFields)
Emit legacy FIELD FieldData nFields.
Namespace for handling VTK output. Contains classes and functions for writing VTK file content.
autoPtr< vtk::formatter > newFormatter(std::ostream &os, unsigned prec=IOstream::defaultPrecision())
Return a default asciiFormatter.
void writeIdentity(vtk::formatter &fmt, const label len, label start=0)
Write an identity list of labels.
fileTag
Some common XML tags for vtk files.
formatType
The output format type for file contents.
Definition foamVtkCore.H:89
void writeListsParallel(vtk::formatter &fmt, const UList< Type > &values1, const UList< Type > &values2)
Write a list of values and another list of values.
void writeLists(vtk::formatter &fmt, const UList< Type > &values1, const UList< Type > &values2, const labelUList &addressing)
Write a list of values and a list of values via indirect addressing.
void writeList(vtk::formatter &fmt, const UList< uint8_t > &values)
Write a list of uint8_t values.
void writeListParallel(vtk::formatter &fmt, const UList< Type > &values)
Write a list of values.
void writeValueParallel(vtk::formatter &fmt, const Type &val, const label count=1)
Component-wise write of a value (N times) in parallel.
Namespace for OpenFOAM.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
UList< label > labelUList
A UList of labels.
Definition UList.H:75
runTime write()