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