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