Loading...
Searching...
No Matches
foamVtkOutputOptions.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-------------------------------------------------------------------------------
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::outputOptions
28
29Description
30 Encapsulated combinations of output format options.
31 This is primarily useful when defining the output type based on some
32 command-line arguments or dictionary contents.
33 However, it can also be a useful alternative to using the underlying
34 enumeration directly, since this class provides additional methods
35 not possible with an enum.
36
37SourceFiles
38 foamVtkOutputOptions.cxx
39 foamVtkOutputOptionsI.H
40
41\*---------------------------------------------------------------------------*/
42
43#ifndef Foam_vtk_outputOptions_H
44#define Foam_vtk_outputOptions_H
45
46#include "foamVtkOutput.H"
47
48// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49
50namespace Foam
51{
52namespace vtk
53{
55/*---------------------------------------------------------------------------*\
56 Class vtk::outputOptions Declaration
57\*---------------------------------------------------------------------------*/
58
59class outputOptions
60{
61 // Private Member Data
62
69
70 //- The output format type
71 vtk::formatType fmtType_;
72
73 //- ASCII write precision
74 mutable unsigned precision_;
75
76
77public:
78
79 // Constructors
80
81 //- Default construct - XML insitu ASCII format with default precision
82 inline outputOptions() noexcept;
83
84 //- Construct with specified format and default (ASCII) precision
85 //
86 // \note This constructor should remain non-explicit.
87 inline outputOptions(vtk::formatType fmtType) noexcept;
88
89 //- Construct with specified format and (ASCII) write precision
90 inline outputOptions(vtk::formatType fmtType, unsigned prec) noexcept;
91
92
93 // Selectors
94
95 //- Return new formatter based on the selected output options
96 inline autoPtr<formatter> newFormatter(std::ostream& os) const;
97
98
99 // Member Functions
100
101 // Access
102
103 //- The output format type
104 inline vtk::formatType fmt() const noexcept;
105
106 //- The file extension (legacy or xml) for the given content-type
107 inline const word& ext(vtk::fileTag contentType) const;
108
109 //- True if writer uses legacy file format
110 inline bool legacy() const noexcept;
111
112 //- True if writer uses XML file format (non-legacy)
113 inline bool xml() const noexcept;
114
115 //- True if HDF file format was requested [ADVANCED USAGE]
116 inline bool is_hdf() const noexcept;
117
118 //- True if output format uses an append mode
119 inline bool append() const noexcept;
120
121 //- True if output format does not use an append mode
122 inline bool insitu() const noexcept;
123
124 //- True if output format is ASCII
125 inline bool ascii() const noexcept;
126
127 //- Return the ASCII write precision
128 inline unsigned precision() const noexcept;
129
130
131 // Edit
132
133 //- Toggle ASCII mode on/off.
134 // In XML append mode, this switches between base64 and raw binary.
135 // In XML inline mode, this switches between ASCII and base64.
136 // In legacy mode, this switches between ASCII and binary.
137 // \return outputOptions for chaining
138 outputOptions& ascii(bool on) noexcept;
139
140 //- Toggle append mode on/off.
141 // \return outputOptions for chaining
142 outputOptions& append(bool on) noexcept;
143
144 //- Toggle legacy mode on/off.
145 // \return outputOptions for chaining
146 outputOptions& legacy(bool on) noexcept;
147
148 //- Set the write precision to be used for new ASCII formatters
149 // \return outputOptions for chaining
150 outputOptions& precision(unsigned prec) noexcept;
151
152
153 // Other
154
155 //- A text description about the output option selected
156 std::string description() const;
157};
158
159
160// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161
162} // End namespace vtk
163} // End namespace Foam
164
165// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166
168
169// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170
171#endif
172
173// ************************************************************************* //
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
bool insitu() const noexcept
True if output format does not use an append mode.
autoPtr< formatter > newFormatter(std::ostream &os) const
Return new formatter based on the selected output options.
std::string description() const
A text description about the output option selected.
bool is_hdf() const noexcept
True if HDF file format was requested [ADVANCED USAGE].
bool legacy() const noexcept
True if writer uses legacy file format.
outputOptions & append(bool on) noexcept
Toggle append mode on/off.
outputOptions & legacy(bool on) noexcept
Toggle legacy mode on/off.
outputOptions() noexcept
Default construct - XML insitu ASCII format with default precision.
outputOptions & precision(unsigned prec) noexcept
Set the write precision to be used for new ASCII formatters.
outputOptions & ascii(bool on) noexcept
Toggle ASCII mode on/off.
bool append() const noexcept
True if output format uses an append mode.
bool xml() const noexcept
True if writer uses XML file format (non-legacy).
vtk::formatType fmt() const noexcept
The output format type.
const word & ext(vtk::fileTag contentType) const
The file extension (legacy or xml) for the given content-type.
bool ascii() const noexcept
True if output format is ASCII.
unsigned precision() const noexcept
Return the ASCII write precision.
A class for handling words, derived from Foam::string.
Definition word.H:66
OBJstream os(runTime.globalPath()/outputName)
Namespace for handling VTK output. Contains classes and functions for writing VTK file content.
fileTag
Some common XML tags for vtk files.
formatType
The output format type for file contents.
Definition foamVtkCore.H:89
Namespace for OpenFOAM.