vtkSurfaceWriter.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) 2011 OpenFOAM Foundation
9 Copyright (C) 2015-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::surfaceWriters::vtkWriter
29
30Description
31 A surfaceWriter for VTK legacy (.vtk) or XML (.vtp) format.
32
33 The formatOptions for vtk:
34 \table
35 Property | Description | Required | Default
36 format | ascii or binary format | no | binary
37 legacy | Legacy VTK output | no | false
38 precision | Write precision in ascii | no | same as IOstream
39 scale | Output geometry scaling | no | 1
40 transform | Output coordinate transform | no |
41 fieldLevel | Subtract field level before scaling | no | empty dict
42 fieldScale | Output field scaling | no | empty dict
43 normal | Write face area-normal in output | no | false
44 \endtable
45
46 For example,
47 \verbatim
48 formatOptions
49 {
50 vtk
51 {
52 format binary;
53 legacy false;
54 precision 10;
55 fieldLevel
56 {
57 p 1e5; // Absolute -> gauge [Pa]
58 }
59 fieldScale
60 {
61 "p.*" 0.01; // [Pa] -> [mbar]
62 }
63 }
64 }
65 \endverbatim
66
67 \section Output file locations
68
69 The \c rootdir normally corresponds to something like
70 \c postProcessing/<name>
71
72 \subsection Geometry and Fields
73 \verbatim
74 rootdir
75 `-- timeName
76 `-- surfaceName.{vtk,vtp}
77 \endverbatim
78
79SourceFiles
80 vtkSurfaceWriter.C
81
82\*---------------------------------------------------------------------------*/
83
84#ifndef Foam_surfaceWriters_vtkWriter_H
85#define Foam_surfaceWriters_vtkWriter_H
86
87#include "surfaceWriter.H"
88
89// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
90
91namespace Foam
92{
93
94namespace vtk
95{
96// Forward Declarations
97class outputOptions;
98class surfaceWriter;
99}
100
101namespace surfaceWriters
102{
103
104/*---------------------------------------------------------------------------*\
105 Class vtkWriter Declaration
106\*---------------------------------------------------------------------------*/
107
108class vtkWriter
109:
110 public surfaceWriter
111{
112 // Private Data
113
114 //- The VTK output format type.
115 // Stored as a raw value to avoid a header dependency on fileFormats
116 unsigned fmtType_;
117
118 //- ASCII write precision
119 unsigned precision_;
120
121 //- Output face area normal
122 const bool writeNormal_;
123
124 //- Backend writer - master only
125 autoPtr<Foam::vtk::surfaceWriter> writer_;
126
127
128 // Private Member Functions
129
130 //- Templated write field operation
131 template<class Type>
132 fileName writeTemplate
133 (
134 const word& fieldName,
135 const Field<Type>& localValues
136 );
137
138
139public:
140
141 //- Declare type-name, virtual type (without debug switch)
142 TypeNameNoDebug("vtk");
143
144
145 // Constructors
146
147 //- Default construct
148 vtkWriter();
149
150 //- Construct with some output options
151 explicit vtkWriter(const vtk::outputOptions& opts);
153 //- Construct with some output options
154 explicit vtkWriter(const dictionary& options);
155
156 //- Construct from components
157 // The file name is with/without an extension.
159 (
160 const meshedSurf& surf,
161 const fileName& outputPath,
162 bool parallel = Pstream::parRun(),
163 const dictionary& options = dictionary()
164 );
165
166 //- Construct from components with specified output path.
167 // The file name is with/without an extension.
169 (
170 const pointField& points,
171 const faceList& faces,
172 const fileName& outputPath,
173 bool parallel = Pstream::parRun(),
174 const dictionary& options = dictionary()
175 );
176
177
178 //- Destructor. Calls close()
179 virtual ~vtkWriter();
180
181
182 // Member Functions
183
184 //- Finish output, clears backend.
185 virtual void close(); // override
187 //- Begin time step. Clears existing backend.
188 virtual void beginTime(const Time& t); // override
189
190 //- Begin time step. Clears existing backend.
191 virtual void beginTime(const instant& inst); // override
192
193 //- End time step. Clears existing backend.
194 virtual void endTime(); // override
195
196
197 // Write
198
199 //- Write surface geometry to file.
200 virtual fileName write(); // override
201
208};
209
210
211// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212
213} // End namespace surfaceWriters
214} // End namespace Foam
215
216// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217
218#endif
219
220// ************************************************************************* //
Generic templated field type.
Definition: Field.H:82
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:433
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A class for handling file names.
Definition: fileName.H:76
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name.
Definition: instant.H:56
Abstract definition of a meshed surface defined by faces and points.
Definition: meshedSurf.H:50
Base class for surface writers.
A surfaceWriter for VTK legacy (.vtk) or XML (.vtp) format.
virtual void endTime()
End time step. Clears existing backend.
declareSurfaceWriterWriteMethod(symmTensor)
declareSurfaceWriterWriteMethod(sphericalTensor)
virtual void beginTime(const Time &t)
Begin time step. Clears existing backend.
virtual void close()
Finish output, clears backend.
TypeNameNoDebug("vtk")
Declare type-name, virtual type (without debug switch)
virtual ~vtkWriter()
Destructor. Calls close()
virtual fileName write()
Write surface geometry to file.
Encapsulated combinations of output format options. This is primarily useful when defining the output...
A class for handling words, derived from Foam::string.
Definition: word.H:68
const pointField & points
Namespace for OpenFOAM.
#define declareSurfaceWriterWriteMethod(Type)
#define TypeNameNoDebug(TypeNameString)
Declare a ClassNameNoDebug() with extra virtual type info.
Definition: typeInfo.H:68