foamVtkLegacyRawFormatter.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) 2017-2022 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
26Class
27 Foam::vtk::legacyRawFormatter
28
29Description
30 Binary output for the VTK legacy format, always written as big-endian
31 and with 32-bit integers.
32
33 This format should never be used for OpenFOAM with 64-bit label sizes.
34
35SourceFiles
36 foamVtkLegacyRawFormatter.C
37
38\*---------------------------------------------------------------------------*/
39
40#ifndef Foam_vtk_legacyRawFormatter_H
41#define Foam_vtk_legacyRawFormatter_H
42
43#include "foamVtkFormatter.H"
44
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46
47namespace Foam
48{
49namespace vtk
50{
51
52/*---------------------------------------------------------------------------*\
53 Class vtk::legacyRawFormatter Declaration
54\*---------------------------------------------------------------------------*/
57:
58 public vtk::formatter
59{
60 // Private Data Members
61
62 static const char* legacyName_;
63 static const vtk::outputOptions opts_;
64
65
66protected:
67
68 // Protected Member Functions
69
70 //- Write
71 void write(const char* s, std::streamsize n);
72
73 //- No copy construct
75
76 //- No copy assignment
77 void operator=(const legacyRawFormatter&) = delete;
78
79
80public:
81
82 // Constructors
83
84 //- Construct and attach to an output stream
85 explicit legacyRawFormatter(std::ostream& os);
86
87
88 //- Destructor
89 virtual ~legacyRawFormatter() = default;
90
91
92 // Member Functions
93
94 //- The output is LEGACY_BINARY.
95 virtual const vtk::outputOptions& opts() const;
96
97 //- Name for the legacy binary output type ("BINARY")
98 virtual const char* name() const;
99
100 //- Name for the XML append encoding (unused)
101 // Currently identical to name(), but do not rely on this.
102 virtual const char* encoding() const;
103
104
105 //- Write leading size - a no-op for legacy binary output
106 // \return False - never used by this format
107 virtual bool writeSize(const uint64_t ignored);
108
109 virtual void write(const uint8_t val);
110 virtual void write(const label val);
111 virtual void write(const float val);
112 virtual void write(const double val);
113
114 //- Write a newline to the output
115 virtual void flush();
116
117
118 // Disable some XML-only methods
120 inline virtual formatter& endTag(vtk::fileTag) { return *this; }
121 inline virtual formatter& endDataArray() { return *this; }
122 inline virtual formatter& endFieldData() { return *this; }
123 inline virtual formatter& endCellData() { return *this; }
124 inline virtual formatter& endPointData() { return *this; }
125 inline virtual formatter& endPiece() { return *this; }
126 inline virtual formatter& endVTKFile() { return *this; }
127};
128
129
130// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131
132} // End namespace vtk
133} // End namespace Foam
134
135// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136
137#endif
138
139// ************************************************************************* //
label n
Abstract class for a VTK output stream formatter.
std::ostream & os() noexcept
Access to the underlying output stream.
Binary output for the VTK legacy format, always written as big-endian and with 32-bit integers.
virtual formatter & endPointData()
End "PointData" XML section.
void operator=(const legacyRawFormatter &)=delete
No copy assignment.
virtual formatter & endVTKFile()
End "VTKFile" XML section.
virtual formatter & endTag(vtk::fileTag)
An end XML tag with sanity check.
legacyRawFormatter(const legacyRawFormatter &)=delete
No copy construct.
virtual formatter & endCellData()
End "CellData" XML section.
virtual const vtk::outputOptions & opts() const
The output is LEGACY_BINARY.
virtual const char * name() const
Name for the legacy binary output type ("BINARY")
virtual formatter & endDataArray()
End "DataArray" XML section.
virtual bool writeSize(const uint64_t ignored)
Write leading size - a no-op for legacy binary output.
virtual formatter & endPiece()
End "Piece" XML section.
virtual ~legacyRawFormatter()=default
Destructor.
virtual formatter & endFieldData()
End "FieldData" XML section.
virtual void flush()
Write a newline to the output.
virtual const char * encoding() const
Name for the XML append encoding (unused)
Encapsulated combinations of output format options. This is primarily useful when defining the output...
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
fileTag
Some common XML tags for vtk files.
Definition: foamVtkCore.H:114
Namespace for OpenFOAM.
runTime write()