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-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::surfaceWriters::vtkWriter
29 
30 Description
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  \endtable
40 
41  For example,
42  \verbatim
43  formatOptions
44  {
45  vtk
46  {
47  format binary;
48  legacy false;
49  precision 10;
50  }
51  }
52  \endverbatim
53 
54  \heading Output file locations
55 
56  The \c rootdir normally corresponds to something like
57  \c postProcessing/<name>
58 
59  \subheading Geometry and Fields
60  \verbatim
61  rootdir
62  `-- timeName
63  `-- surfaceName.{vtk,vtp}
64  \endverbatim
65 
66 SourceFiles
67  vtkSurfaceWriter.C
68 
69 \*---------------------------------------------------------------------------*/
70 
71 #ifndef vtkSurfaceWriter_H
72 #define vtkSurfaceWriter_H
73 
74 #include "surfaceWriter.H"
75 
76 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
77 
78 namespace Foam
79 {
80 
81 namespace vtk
82 {
83 // Forward Declarations
84 class outputOptions;
85 class surfaceWriter;
86 }
87 
88 namespace surfaceWriters
89 {
90 
91 /*---------------------------------------------------------------------------*\
92  Class vtkWriter Declaration
93 \*---------------------------------------------------------------------------*/
94 
95 class vtkWriter
96 :
97  public surfaceWriter
98 {
99  // Private Data
100 
101  //- The VTK output format type.
102  // Stored as a raw value to avoid a header dependency on fileFormats
103  unsigned fmtType_;
104 
105  //- ASCII write precision
106  unsigned precision_;
107 
108  //- Backend writer - master only
109  autoPtr<Foam::vtk::surfaceWriter> writer_;
110 
111 
112  // Private Member Functions
113 
114  //- Templated write field operation
115  template<class Type>
116  fileName writeTemplate
117  (
118  const word& fieldName,
119  const Field<Type>& localValues
120  );
121 
122 
123 public:
124 
125  //- Declare type-name, virtual type (without debug switch)
126  TypeNameNoDebug("vtk");
127 
128 
129  // Constructors
130 
131  //- Default construct
132  vtkWriter();
133 
134  //- Construct with some output options
135  explicit vtkWriter(const vtk::outputOptions& opts);
136 
137  //- Construct with some output options
138  explicit vtkWriter(const dictionary& options);
139 
140  //- Construct from components
141  // The file name is with/without an extension.
142  vtkWriter
143  (
144  const meshedSurf& surf,
145  const fileName& outputPath,
146  bool parallel = Pstream::parRun(),
147  const dictionary& options = dictionary()
148  );
149 
150  //- Construct from components with specified output path.
151  // The file name is with/without an extension.
152  vtkWriter
153  (
154  const pointField& points,
155  const faceList& faces,
156  const fileName& outputPath,
157  bool parallel = Pstream::parRun(),
158  const dictionary& options = dictionary()
159  );
160 
161 
162  //- Destructor. Calls close()
163  virtual ~vtkWriter();
164 
165 
166  // Member Functions
167 
168  //- Finish output, clears backend.
169  virtual void close(); // override
170 
171  //- Begin time step. Clears existing backend.
172  virtual void beginTime(const Time& t); // override
173 
174  //- Begin time step. Clears existing backend.
175  virtual void beginTime(const instant& inst); // override
176 
177  //- End time step. Clears existing backend.
178  virtual void endTime(); // override
179 
180 
181  // Write
182 
183  //- Write surface geometry to file.
184  virtual fileName write(); // override
185 
192 };
193 
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 } // End namespace surfaceWriters
198 } // End namespace Foam
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 #endif
203 
204 // ************************************************************************* //
Foam::vtk::outputOptions
Encapsulated combinations of output format options. This is primarily useful when defining the output...
Definition: foamVtkOutputOptions.H:59
Foam::Tensor< scalar >
Foam::surfaceWriters::vtkWriter::declareSurfaceWriterWriteMethod
declareSurfaceWriterWriteMethod(label)
Foam::SymmTensor< scalar >
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::surfaceWriter
Base class for surface writers.
Definition: surfaceWriter.H:111
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::surfaceWriters::vtkWriter::write
virtual fileName write()
Write surface geometry to file.
Definition: vtkSurfaceWriter.C:183
Foam::UPstream::parRun
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:415
Foam::surfaceWriters::vtkWriter::close
virtual void close()
Finish output, clears backend.
Definition: vtkSurfaceWriter.C:155
Foam::meshedSurf
Abstract definition of a meshed surface defined by faces and points.
Definition: meshedSurf.H:49
Foam::surfaceWriters::vtkWriter::beginTime
virtual void beginTime(const Time &t)
Begin time step. Clears existing backend.
Definition: vtkSurfaceWriter.C:162
surfaceWriter.H
Foam::surfaceWriters::vtkWriter
A surfaceWriter for VTK legacy (.vtk) or XML (.vtp) format.
Definition: vtkSurfaceWriter.H:114
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::surfaceWriters::vtkWriter::endTime
virtual void endTime()
End time step. Clears existing backend.
Definition: vtkSurfaceWriter.C:176
Foam::surfaceWriters::vtkWriter::TypeNameNoDebug
TypeNameNoDebug("vtk")
Declare type-name, virtual type (without debug switch)
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::surfaceWriters::vtkWriter::~vtkWriter
virtual ~vtkWriter()
Destructor. Calls close()
Definition: vtkSurfaceWriter.C:147
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::SphericalTensor< scalar >
Foam::autoPtr< Foam::vtk::surfaceWriter >
Foam::Vector< scalar >
Foam::List< face >
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::instant
An instant of time. Contains the time value and name.
Definition: instant.H:52
Foam::surfaceWriters::vtkWriter::vtkWriter
vtkWriter()
Default construct.
Definition: vtkSurfaceWriter.C:64