foamVtkOutputOptionsI.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 \*---------------------------------------------------------------------------*/
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
31 :
32  fmtType_(formatType::INLINE_ASCII),
33  precision_(IOstream::defaultPrecision())
34 {}
35 
36 
38 (
39  enum vtk::formatType fmtType
40 )
41 :
42  fmtType_(fmtType),
43  precision_(IOstream::defaultPrecision())
44 {}
45 
46 
48 (
49  enum vtk::formatType fmtType,
50  unsigned prec
51 )
52 :
53  fmtType_(fmtType),
54  precision_(prec)
55 {}
56 
57 
58 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
59 
61 Foam::vtk::outputOptions::newFormatter(std::ostream& os) const
62 {
63  return vtk::newFormatter(os, fmtType_, precision_);
64 }
65 
66 
67 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
68 
70 {
71  return fmtType_;
72 }
73 
74 
76 {
77  return
78  (
79  legacy()
81  : vtk::fileExtension[contentType]
82  );
83 }
84 
85 
87 {
88  return
89  (
90  fmtType_ == formatType::LEGACY_ASCII
91  || fmtType_ == formatType::LEGACY_BINARY
92  );
93 }
94 
95 
96 inline bool Foam::vtk::outputOptions::xml() const noexcept
97 {
98  return !legacy();
99 }
100 
101 
102 inline bool Foam::vtk::outputOptions::append() const noexcept
103 {
104  return
105  (
106  fmtType_ == formatType::APPEND_BASE64
107  || fmtType_ == formatType::APPEND_BINARY
108  );
109 }
110 
112 inline bool Foam::vtk::outputOptions::insitu() const noexcept
113 {
114  return !append();
115 }
116 
118 inline bool Foam::vtk::outputOptions::ascii() const noexcept
119 {
120  return !(unsigned(fmtType_) & 0x0F);
121 }
122 
123 
124 inline unsigned Foam::vtk::outputOptions::precision() const noexcept
125 {
126  return precision_;
127 }
128 
129 
130 // ************************************************************************* //
XML append raw binary, appendRawFormatter.
autoPtr< formatter > newFormatter(std::ostream &os) const
Return new formatter based on the selected output options.
bool append() const noexcept
True if output format uses an append mode.
const word fileExtension
Legacy file extension ("vtk")
autoPtr< vtk::formatter > newFormatter(std::ostream &os, unsigned prec=IOstream::defaultPrecision())
Return a default asciiFormatter.
Definition: foamVtkOutput.C:41
outputOptions()
Default construct - XML insitu ASCII format with default precision.
bool xml() const noexcept
True if writer uses XML file format (non-legacy)
XML inline ASCII, asciiFormatter.
unsigned precision() const noexcept
Return the ASCII write precision.
A class for handling words, derived from Foam::string.
Definition: word.H:63
Legacy raw binary, legacyRawFormatter.
formatType
The output format type for file contents.
Definition: foamVtkCore.H:66
bool ascii() const noexcept
True if output format is ASCII.
bool insitu() const noexcept
True if output format does not use an append mode.
const direction noexcept
Definition: Scalar.H:258
vtk::formatType fmt() const noexcept
The output format type.
OBJstream os(runTime.globalPath()/outputName)
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
An IOstream is an abstract base class for all input/output systems; be they streams, files, token lists etc.
Definition: IOstream.H:82
const Foam::Enum< fileTag > fileExtension
File extension (without ".") for some vtk XML file content types.
fileTag
Some common XML tags for vtk files.
Definition: foamVtkCore.H:122
bool legacy() const noexcept
True if writer uses legacy file format.
XML append base64, appendBase64Formatter.
Legacy ASCII, legacyAsciiFormatter.
word ext(vtk::fileTag contentType) const
The file extension (legacy or xml) for the given content-type.