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-2022 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 vtk::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 protected:
68 
69  // Protected Member Functions
70 
71  //- Write
72  void write(const char* s, std::streamsize n);
73 
74  //- No copy construct
75  appendRawFormatter(const appendRawFormatter&) = delete;
76 
77  //- No copy assignment
78  void operator=(const appendRawFormatter&) = delete;
79 
80 
81 public:
82 
83  // Constructors
84 
85  //- Construct and attach to an output stream
86  explicit appendRawFormatter(std::ostream& os);
87 
88 
89  //- Destructor
90  virtual ~appendRawFormatter() = default;
91 
92 
93  // Member Functions
94 
95  //- The output is APPEND_BINARY.
96  virtual const vtk::outputOptions& opts() const;
97 
98  //- Output name for XML type ("append")
99  virtual const char* name() const;
100 
101  //- Output name for append encoding type ("raw")
102  virtual const char* encoding() const;
103 
104  //- Increase the append data offset by numbytes and sizeof(uint64_t).
105  // The additional (uint64_t) size information is consistent with
106  // writeSize()
107  //
108  // \return The previous data offset
109  virtual uint64_t offset(const uint64_t numbytes);
110 
111  //- Write leading size for binary output
112  // \return True - format uses this information
113  virtual bool writeSize(const uint64_t numbytes);
114 
115  virtual void write(const uint8_t val);
116  virtual void write(const label val);
117  virtual void write(const float val);
118  virtual void write(const double val);
119 
120  //- A no-op for this format
121  virtual void flush();
122 };
123 
124 
125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 
127 } // End namespace vtk
128 } // End namespace Foam
129 
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131 
132 #endif
133 
134 // ************************************************************************* //
Abstract class for a VTK output stream formatter.
virtual const char * name() const
Output name for XML type ("append")
appendRawFormatter(const appendRawFormatter &)=delete
No copy construct.
virtual void flush()
A no-op for this format.
Encapsulated combinations of output format options. This is primarily useful when defining the output...
std::ostream & os() noexcept
Access to the underlying output stream.
virtual uint64_t offset(const uint64_t numbytes)
Increase the append data offset by numbytes and sizeof(uint64_t).
virtual ~appendRawFormatter()=default
Destructor.
virtual const vtk::outputOptions & opts() const
The output is APPEND_BINARY.
virtual bool writeSize(const uint64_t numbytes)
Write leading size for binary output.
void operator=(const appendRawFormatter &)=delete
No copy assignment.
label n
Appended raw binary output.
virtual const char * encoding() const
Output name for append encoding type ("raw")
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))
void write(const char *s, std::streamsize n)
Write.
Namespace for OpenFOAM.