vtkCoordSetWriter.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-2016 OpenFOAM Foundation
9  Copyright (C) 2021-2022 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::coordSetWriters::vtkWriter
29 
30 Description
31 
32 SourceFiles
33  vtkCoordSetWriter.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef Foam_coordSetWriters_vtkWriter_H
38 #define Foam_coordSetWriters_vtkWriter_H
39 
40 #include "coordSetWriter.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 // Forward Declarations
48 class OFstream;
49 
50 namespace vtk
51 {
52 // Forward Declarations
53 class outputOptions;
54 class coordSetWriter;
55 }
56 
57 namespace coordSetWriters
58 {
59 
60 /*---------------------------------------------------------------------------*\
61  Class vtkCoordSetWriter Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 class vtkWriter
65 :
66  public coordSetWriter
67 {
68  // Private Data
69 
70  //- The VTK output format type.
71  // Stored as a raw value to avoid a header dependency on fileFormats
72  unsigned fmtType_;
73 
74  //- ASCII write precision
75  unsigned precision_;
76 
77  //- Backend writer - master only
79 
80 
81  // Private Member Functions
82 
83  //- Templated write operation
84  template<class Type>
85  fileName writeTemplate
86  (
87  const word& fieldName,
88  const UPtrList<const Field<Type>>& fieldPtrs
89  );
90 
91  //- Templated write operation
92  template<class Type>
93  fileName writeTemplate
94  (
95  const word& fieldName,
96  const Field<Type>& vals
97  );
98 
99  //- Templated write operation
100  template<class Type>
101  fileName writeTemplate
102  (
103  const word& fieldName,
104  const List<Field<Type>>& fieldValues
105  );
106 
107 public:
108 
109  //- Runtime type information (no debug)
110  TypeNameNoDebug("vtk");
111 
112  // Constructors
113 
114  //- Default construct
115  vtkWriter();
116 
117  //- Construct with some output options
118  explicit vtkWriter(const vtk::outputOptions& opts);
119 
120  //- Default construct with specified options
121  explicit vtkWriter(const dictionary& options);
122 
123  //- Construct from components
124  vtkWriter
125  (
126  const coordSet& coords,
127  const fileName& outputPath,
128  const dictionary& options = dictionary()
129  );
130 
131  //- Construct from components
132  vtkWriter
133  (
134  const UPtrList<coordSet>& tracks,
135  const fileName& outputPath,
136  const dictionary& options = dictionary()
137  );
138 
139 
140  //- Destructor. Calls close()
141  virtual ~vtkWriter();
142 
143 
144  // Member Functions
145 
146  //- Expected (characteristic) output file name - information only
147  virtual fileName path() const; // override
148 
149  //- Close and reset, clears backend.
150  virtual void close(bool force = false); // override
151 
152  //- Begin time step. Clears existing backend.
153  virtual void beginTime(const Time& t); // override
154 
155  //- Begin time step. Clears existing backend.
156  virtual void beginTime(const instant& inst); // override
157 
158  //- End time step. Clears existing backend.
159  virtual void endTime(); // override
160 
161 
162  // Write
163 
164  //- Write geometry to file.
165  virtual fileName write(); // override
166 
173 };
174 
175 
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 
178 } // End namespace coordSetWriters
179 } // End namespace Foam
180 
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 
183 #endif
184 
185 // ************************************************************************* //
A class for handling file names.
Definition: fileName.H:72
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
virtual void close(bool force=false)
Close and reset, clears backend.
virtual ~vtkWriter()
Destructor. Calls close()
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
virtual fileName path() const
Expected (characteristic) output file name - information only.
Encapsulated combinations of output format options. This is primarily useful when defining the output...
virtual fileName write()
Write geometry to file.
Holds list of sampling positions.
Definition: coordSet.H:49
Generic templated field type.
Definition: Field.H:62
A class for handling words, derived from Foam::string.
Definition: word.H:63
Base class for writing coordSet(s) and tracks with fields.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: HashTable.H:106
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
virtual void beginTime(const Time &t)
Begin time step. Clears existing backend.
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name...
Definition: instant.H:53
virtual void endTime()
End time step. Clears existing backend.
TypeNameNoDebug("vtk")
Runtime type information (no debug)
Tensor of scalars, i.e. Tensor<scalar>.
Namespace for OpenFOAM.