foamVtkAppendRawFormatter.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-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::appendRawFormatter
28 
29 Description
30  Appended raw binary output.
31 
32 SourceFiles
33  foamVtkAppendRawFormatter.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef Foam_vtk_appendRawFormatter_H
38 #define Foam_vtk_appendRawFormatter_H
39 
40 #include "foamVtkFormatter.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 namespace vtk
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class vtk::appendRawFormatter Declaration
51 \*---------------------------------------------------------------------------*/
52 
54 :
55  public formatter
56 {
57  // Private Data Members
58 
59  static const char* name_;
60  static const char* encoding_;
61  static const outputOptions opts_;
62 
63  //- The current offset for append data.
64  uint64_t offset_;
65 
66 
67  // Private Member Functions
68 
69  //- No copy construct
70  appendRawFormatter(const appendRawFormatter&) = delete;
71 
72  //- No copy assignment
73  void operator=(const appendRawFormatter&) = delete;
74 
75 
76 protected:
77 
78  // Protected Member Functions
79 
80  //- Write
81  void write(const char* s, std::streamsize n);
82 
83 
84 public:
85 
86  // Constructors
87 
88  //- Construct and attach to an output stream
89  appendRawFormatter(std::ostream& os);
90 
91 
92  //- Destructor
93  virtual ~appendRawFormatter() = default;
94 
95 
96  // Member Functions
97 
98  //- The output is APPEND_BINARY.
99  virtual const outputOptions& opts() const;
100 
101  //- Output name for XML type ("append")
102  virtual const char* name() const;
103 
104  //- Output name for append encoding type ("raw")
105  virtual const char* encoding() const;
106 
107  //- Increase the append data offset by numbytes and sizeof(uint64_t).
108  // The additional (uint64_t) size information is consistent with
109  // writeSize()
110  //
111  // \return The previous data offset
112  virtual uint64_t offset(const uint64_t numbytes);
113 
114  //- Write leading size for binary output
115  // \return True - format uses this information
116  virtual bool writeSize(const uint64_t numbytes);
117 
118  virtual void write(const uint8_t val);
119  virtual void write(const label val);
120  virtual void write(const float val);
121  virtual void write(const double val);
122 
123  //- A no-op for this format
124  virtual void flush();
125 
126 };
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 } // End namespace vtk
131 } // End namespace Foam
132 
133 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134 
135 #endif
136 
137 // ************************************************************************* //
Foam::vtk::outputOptions
Encapsulated combinations of output format options. This is primarily useful when defining the output...
Definition: foamVtkOutputOptions.H:59
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
foamVtkFormatter.H
Foam::vtk::appendRawFormatter::writeSize
virtual bool writeSize(const uint64_t numbytes)
Write leading size for binary output.
Definition: foamVtkAppendRawFormatter.C:95
Foam::vtk::appendRawFormatter::encoding
virtual const char * encoding() const
Output name for append encoding type ("raw")
Definition: foamVtkAppendRawFormatter.C:77
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::vtk::formatter::os
std::ostream & os()
Access to the underlying output stream.
Definition: foamVtkFormatterI.H:70
Foam::vtk::appendRawFormatter::offset
virtual uint64_t offset(const uint64_t numbytes)
Increase the append data offset by numbytes and sizeof(uint64_t).
Definition: foamVtkAppendRawFormatter.C:83
Foam::vtk::appendRawFormatter::name
virtual const char * name() const
Output name for XML type ("append")
Definition: foamVtkAppendRawFormatter.C:71
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::vtk::appendRawFormatter::opts
virtual const outputOptions & opts() const
The output is APPEND_BINARY.
Definition: foamVtkAppendRawFormatter.C:65
Foam::vtk::appendRawFormatter::~appendRawFormatter
virtual ~appendRawFormatter()=default
Destructor.
Foam::vtk::appendRawFormatter::flush
virtual void flush()
A no-op for this format.
Definition: foamVtkAppendRawFormatter.C:143
Foam::vtk::appendRawFormatter
Appended raw binary output.
Definition: foamVtkAppendRawFormatter.H:52
Foam::vtk::appendRawFormatter::write
void write(const char *s, std::streamsize n)
Write.
Definition: foamVtkAppendRawFormatter.C:44
Foam::vtk::formatter
Abstract class for a VTK output stream formatter.
Definition: foamVtkFormatter.H:68