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-2025 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  Foam::vtk::formatType fmtType
40 ) noexcept
41 :
42  fmtType_(fmtType),
43  precision_(IOstream::defaultPrecision())
44 {}
45 
46 
48 (
49  Foam::vtk::formatType fmtType,
50  unsigned prec
51 ) noexcept
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 
75 inline const Foam::word&
77 {
78  return
79  (
80  legacy()
82  : vtk::fileExtension[contentType]
83  );
84 }
85 
86 
88 {
89  return (fmtType_ == formatType::HDF_FORMAT);
90 }
91 
92 
94 {
95  return
96  (
97  fmtType_ == formatType::LEGACY_ASCII
98  || fmtType_ == formatType::LEGACY_BINARY
99  );
100 }
101 
103 inline bool Foam::vtk::outputOptions::xml() const noexcept
104 {
105  return (!legacy() && !is_hdf());
106 }
107 
108 
109 inline bool Foam::vtk::outputOptions::append() const noexcept
110 {
111  return
112  (
113  fmtType_ == formatType::APPEND_BASE64
114  || fmtType_ == formatType::APPEND_BINARY
115  );
116 }
117 
119 inline bool Foam::vtk::outputOptions::insitu() const noexcept
120 {
121  return !append();
122 }
123 
125 inline bool Foam::vtk::outputOptions::ascii() const noexcept
126 {
127  return !(unsigned(fmtType_) & 0x0F);
128 }
129 
130 
131 inline unsigned Foam::vtk::outputOptions::precision() const noexcept
132 {
133  return precision_;
134 }
135 
136 
137 // ************************************************************************* //
XML append raw binary, appendRawFormatter.
autoPtr< formatter > newFormatter(std::ostream &os) const
Return new formatter based on the selected output options.
const word fileExtension
Legacy file extension ("vtk")
const Foam::Enum< fileTag > fileExtension
File extension (without ".") for some vtk XML file content types.
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)
autoPtr< vtk::formatter > newFormatter(std::ostream &os, unsigned prec=IOstream::defaultPrecision())
Return a default 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.
bool is_hdf() const noexcept
True if HDF file format was requested [ADVANCED USAGE].
formatType
The output format type for file contents.
Definition: foamVtkCore.H:88
bool ascii() const noexcept
True if output format is ASCII.
bool insitu() const noexcept
True if output format does not use an append mode.
outputOptions() noexcept
Default construct - XML insitu ASCII format with default precision.
const direction noexcept
Definition: scalarImpl.H:265
vtk::formatType fmt() const noexcept
The output format type.
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
fileTag
Some common XML tags for vtk files.
Definition: foamVtkCore.H:153
bool legacy() const noexcept
True if writer uses legacy file format.
XML append base64, appendBase64Formatter.
Legacy ASCII, legacyAsciiFormatter.
const word & ext(vtk::fileTag contentType) const
The file extension (legacy or xml) for the given content-type.