Loading...
Searching...
No Matches
foamVtkCore.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
39Namespace
40 Foam::vtk::Tools
41
42Description
43 A collection of static methods to help with conversion to/from VTK data.
44
45SourceFiles
46 foamVtkCore.cxx
47 foamVtkCore.txx
48
49\*---------------------------------------------------------------------------*/
50
51#ifndef Foam_vtk_core_H
52#define Foam_vtk_core_H
53
54#include <cstdint>
55
56#include "Enum.H"
57#include "pTraits.H"
58
59// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60
61namespace Foam
62{
63
64// Forward Declarations
65template<class Cmpt> class SymmTensor;
66
67namespace vtk
68{
69
70// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71
72 // Enumerations
73
74 //- The context when outputting a VTK file (XML or legacy).
75 enum OutputContext : uint8_t
76 {
80 };
81
82
83 //- The output format type for file contents.
84 // Upper bits for output type, lower bits for the format itself.
85 enum class formatType : uint8_t
86 {
87 INLINE_ASCII = 0,
89 APPEND_BASE64 = 0x11,
91 LEGACY_ASCII = 0x20,
93 HDF_FORMAT = 0x40,
94 };
96 //- Test for vtk append format (xml)
97 inline bool isAppend(enum formatType fmt) noexcept
98 {
99 return (uint8_t(fmt) & 0x10);
100 }
101
102 //- Test for vtk legacy format
103 inline bool isLegacy(enum formatType fmt) noexcept
104 {
105 return (uint8_t(fmt) & 0x20);
106 }
107
108 //- Test for HDF format
109 inline bool isHDF(enum formatType fmt) noexcept
111 return (formatType::HDF_FORMAT == fmt);
112 }
113
114
115 //- Equivalent to enumeration in "vtkCellType.h" (should be uint8_t)
116 enum cellType : uint8_t
117 {
119 VTK_VERTEX = 1,
120 VTK_POLY_VERTEX = 2,
121 VTK_LINE = 3,
122 VTK_POLY_LINE = 4,
123 VTK_TRIANGLE = 5,
125 VTK_POLYGON = 7,
126 VTK_PIXEL = 8,
148 POINTS,
149 CELLS,
150 POLYS,
151 VERTS,
152 LINES,
154 POINT_DATA,
160 };
162 //- File extension (without ".") for some vtk XML file content types
165 //- Version string for some vtk XML file content types
168 //- Strings corresponding to the vtk XML tags
171 //- Some common XML attributes for vtk files
172 enum class fileAttr : uint8_t
173 {
174 OFFSET,
182 };
183
184 //- Strings corresponding to the vtk XML attributes
186
187 //- Some common names for XML DataArray entries
188 enum class dataArrayAttr : uint8_t
189 {
190 POINTS,
191 OFFSETS,
194 FACES,
196 };
198 //- Strings corresponding to the vtk XML DataArray attributes
202/*---------------------------------------------------------------------------*\
203 Namespace legacy
204\*---------------------------------------------------------------------------*/
205
206namespace legacy
207{
208
209 //- Legacy file extension ("vtk")
210 extern const word fileExtension;
211
212 //- Legacy content names (POLYDATA, UNSTRUCTURED_GRID)
214
215 //- Legacy file tags (eg, LINES, CELL_DATA, POINT_DATA, ...)
218 //- Legacy attributes (eg, OFFSETS)
221} // End namespace Foam::vtk::legacy
222
223
224/*---------------------------------------------------------------------------*\
225 Namespace Tools
226\*---------------------------------------------------------------------------*/
227
228namespace Tools
229{
230
231//- Return a copy of the \p value, with components changed
232//- from OpenFOAM order to VTK order (for symmTensor)
233template<class Type>
234Type copyTuple(const Type& value);
235
236//- Implementation detail - not for general use!
237template<class FloatType, class Type>
238const FloatType* copyTuple_impl(FloatType output[], const Type& value);
239
240
241//- Copy/transcribe components of OpenFOAM \p value to the \p output buffer
242//- (which must be large enough to contain all components)
243//
244// \note When copying, the components of Foam::symmTensor are reordering
245// to match the VTK order:
246// - OpenFOAM : (XX, XY, XZ, YY, YZ, ZZ)
247// - VTK order: (XX, YY, ZZ, XY, YZ, XZ)
248//
249// \returns the pointer to \p output buffer, which allows this routine
250// to act as pass-through filter.
251template<class Type>
252const double* copyTuple
253(
254 double output[],
255 const Type& value
256);
257
258//- Copy/transcribe components of OpenFOAM \p value to the \p output buffer
259//- (which must be large enough to contain all components)
260template<class Type>
261const float* copyTuple
262(
263 float output[],
264 const Type& value
265);
266
267//- Inplace component reordering of \p value from OpenFOAM order to VTK order
268// Reordering is currently only applied for Foam::symmTensor,
269// all other types are a no-op.
270//
271// \sa copyTuple
272template<class Type>
273void reorderTuple(Type& value);
274
275} // End namespace Foam::vtk::Tools
276
277// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
278
279} // End namespace vtk
280} // End namespace Foam
281
282// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
283
284#ifdef NoRepository
285 #include "foamVtkCore.txx"
286#endif
287
288// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
289
290#endif
291
292// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition Enum.H:57
A templated (3 x 3) symmetric tensor of objects of <T>, effectively containing 6 elements,...
Definition SymmTensor.H:53
A class for handling words, derived from Foam::string.
Definition word.H:66
void reorderTuple(Type &value)
Inplace component reordering of value from OpenFOAM order to VTK order.
const FloatType * copyTuple_impl(FloatType output[], const Type &value)
Implementation detail - not for general use!
Type copyTuple(const Type &value)
Return a copy of the value, with components changed from OpenFOAM order to VTK order (for symmTensor)...
Namespace for legacy VTK output constants and functions.
const Foam::Enum< dataArrayAttr > dataArrayAttrNames
Legacy attributes (eg, OFFSETS).
const word fileExtension
Legacy file extension ("vtk").
const Foam::Enum< vtk::fileTag > contentNames
Legacy content names (POLYDATA, UNSTRUCTURED_GRID).
const Foam::Enum< vtk::fileTag > fileTagNames
Legacy file tags (eg, LINES, CELL_DATA, POINT_DATA, ...).
Namespace for handling VTK output. Contains classes and functions for writing VTK file content.
fileAttr
Some common XML attributes for vtk files.
@ NUMBER_OF_POLYS
"NumberOfPolys"
@ NUMBER_OF_COMPONENTS
"NumberOfComponents"
@ NUMBER_OF_TUPLES
"NumberOfTuples"
@ NUMBER_OF_LINES
"NumberOfLines"
@ NUMBER_OF_CELLS
"NumberOfCells"
@ NUMBER_OF_VERTS
"NumberOfVerts"
@ NUMBER_OF_POINTS
"NumberOfPoints"
const Foam::Enum< dataArrayAttr > dataArrayAttrNames
Strings corresponding to the vtk XML DataArray attributes.
dataArrayAttr
Some common names for XML DataArray entries.
@ FACEOFFSETS
"faceoffsets"
@ CONNECTIVITY
"connectivity"
fileTag
Some common XML tags for vtk files.
@ FIELD_DATA
"FieldData"
@ CELL_DATA
"CellData"
@ UNKNOWN
placeholder
@ POINT_DATA
"PointData"
@ DATA_ARRAY
"DataArray"
@ UNSTRUCTURED_GRID
"UnstructuredGrid"
@ VTK_FILE
"VTKFile"
@ MULTI_BLOCK
"vtkMultiBlockDataSet"
@ VTK_HDF
"VTKHDF" - used for the extension
@ POLY_DATA
"PolyData"
@ DATA_SET
"DataSet"
formatType
The output format type for file contents.
Definition foamVtkCore.H:89
@ APPEND_BASE64
XML append base64, appendBase64Formatter.
Definition foamVtkCore.H:92
@ APPEND_BINARY
XML append raw binary, appendRawFormatter.
Definition foamVtkCore.H:93
@ INLINE_ASCII
XML inline ASCII, asciiFormatter.
Definition foamVtkCore.H:90
@ LEGACY_ASCII
Legacy ASCII, legacyAsciiFormatter.
Definition foamVtkCore.H:94
@ LEGACY_BINARY
Legacy raw binary, legacyRawFormatter.
Definition foamVtkCore.H:95
@ HDF_FORMAT
VTKHDF format.
Definition foamVtkCore.H:96
@ INLINE_BASE64
XML inline base64, base64Formatter.
Definition foamVtkCore.H:91
bool isAppend(enum formatType fmt) noexcept
Test for vtk append format (xml).
const Foam::Enum< fileTag > fileContentVersions
Version string for some vtk XML file content types.
const Foam::Enum< fileAttr > fileAttrNames
Strings corresponding to the vtk XML attributes.
OutputContext
The context when outputting a VTK file (XML or legacy).
Definition foamVtkCore.H:76
@ INLINE
Generate header and inline data.
Definition foamVtkCore.H:77
@ HEADER
Generate header only.
Definition foamVtkCore.H:78
@ APPEND
Generate append-data.
Definition foamVtkCore.H:79
bool isLegacy(enum formatType fmt) noexcept
Test for vtk legacy format.
const Foam::Enum< fileTag > fileTagNames
Strings corresponding to the vtk XML tags.
bool isHDF(enum formatType fmt) noexcept
Test for HDF format.
cellType
Equivalent to enumeration in "vtkCellType.h" (should be uint8_t).
@ VTK_TRIANGLE_STRIP
@ VTK_PENTAGONAL_PRISM
@ VTK_HEXAGONAL_PRISM
const Foam::Enum< fileTag > fileExtension
File extension (without ".") for some vtk XML file content types.
Namespace for OpenFOAM.