Loading...
Searching...
No Matches
foamVtkCoordSetWriter.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) 2022 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::vtk::coordSetWriter
28
29Description
30 Write as points/lines, optionally with fields,
31 as a vtp file or a legacy vtk file.
32
33 The file output states are managed by the Foam::vtk::fileWriter class.
34 FieldData (eg, TimeValue) must appear before any geometry pieces.
35
36Note
37 Non-parallel only
38
39SourceFiles
40 foamVtkCoordSetWriter.cxx
41 foamVtkCoordSetWriter.txx
42
43\*---------------------------------------------------------------------------*/
44
45#ifndef Foam_vtk_coordSetWriter_H
46#define Foam_vtk_coordSetWriter_H
47
48#include "foamVtkPolyWriter.H"
49#include "UPtrList.H"
50#include "Field.H"
51#include "instant.H"
52
53// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54
55namespace Foam
56{
57namespace vtk
58{
60/*---------------------------------------------------------------------------*\
61 Class vtk::coordSetWriter Declaration
62\*---------------------------------------------------------------------------*/
63
65:
66 public vtk::polyWriter
67{
68public:
69
70 // Data Types
71
72 //- Types of element output.
74 {
79 };
80
81private:
82
83 // Private Member Data
84
85 //- Reference to the points
87
88 //- Time name/value
89 instant instant_;
90
91 //- Preferred output element type
92 elemOutputType elemOutput_;
93
94
95 // Private Member Functions
96
97
98 // Private Member Functions
99
100 //- Determine sizes (nLocalPoints_, nLocalLines_),
101 //- and begin piece
102 void beginPiece();
103
104 //- Write points
105 void writePoints();
106
107 //- Write vertices, legacy format
108 // \param pointOffset processor-local point offset
109 void writeVertsLegacy();
110
111 //- Write vertices
112 // \param pointOffset processor-local point offset
113 void writeVerts();
114
115 //- Write lines, legacy format
116 // \param pointOffset processor-local point offset
117 void writeLinesLegacy();
118
119 //- Write lines
120 // \param pointOffset processor-local point offset
121 void writeLines();
122
123public:
124
125 // Generated Methods
126
127 //- No copy construct
128 coordSetWriter(const coordSetWriter&) = delete;
129
130 //- No copy assignment
131 void operator=(const coordSetWriter&) = delete;
132
133
134 // Constructors
135
136 //- Construct from components (default format INLINE_BASE64)
137 explicit coordSetWriter
138 (
141 );
142
143 //- Construct from components (default format INLINE_BASE64),
144 //- and open the file for writing.
145 // The file name is with/without an extension.
147 (
149 const fileName& file,
150 bool paralel = false /* ignored: always false */
151 );
152
153 //- Construct from components and open the file for writing.
154 // The file name is with/without an extension.
156 (
159 const fileName& file,
160 bool paralel = false /* ignored: always false */
161 );
163
164 //- Destructor
165 virtual ~coordSetWriter() = default;
166
167
168 // Member Functions
169
170 //- Define preferred element type
171 void setElementType(const elemOutputType elemOutput);
172
173 //- Open file for writing. Non-parallel only
174 virtual bool open
175 (
176 const fileName& file,
177 bool parallel = false /* ignored: always false */
178 );
179
180 //- Define a time name/value for the output
181 virtual void setTime(const instant& inst);
182
183 //- Write file header (non-collective)
184 // \note Expected calling states: (OPENED).
185 virtual bool beginFile(std::string title = "");
187 //- Write patch topology
188 // Also writes the file header if not previously written.
189 // \note Must be called prior to writing CellData or PointData
190 virtual bool writeGeometry();
191
192 //- Write "TimeValue" FieldData (name as per Catalyst output)
193 // Must be called within the FIELD_DATA state.
194 // \note As a convenience this can also be called from
195 // (OPENED | DECLARED) states, in which case it invokes
196 // beginFieldData(1) internally.
199 //- Write the currently set time as "TimeValue" FieldData
200 void writeTimeValue();
201
202 //- Reset point references to begin a new piece
204
205
206 //- Write processor ids for each line as CellData or for each point
207 //- as PointData, depending on isPointData() state. No-op in serial.
208 // Not implemented.
209 bool writeProcIDs();
210
212 // Write
213
214 //- Write primitive field of PointData
215 template<class Type>
216 void writePointData
217 (
218 const word& fieldName,
219 const UPtrList<const Field<Type>>& fieldPtrs
220 );
221};
222
223
224// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225
226} // End namespace vtk
227} // End namespace Foam
228
229// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230
231#ifdef NoRepository
232 #include "foamVtkCoordSetWriter.txx"
233#endif
234
235// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236
237#endif
238
239// ************************************************************************* //
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition UPtrList.H:101
A class for handling file names.
Definition fileName.H:75
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name.
Definition instant.H:56
Write as points/lines, optionally with fields, as a vtp file or a legacy vtk file.
virtual bool open(const fileName &file, bool parallel=false)
Open file for writing. Non-parallel only.
void piece(const UPtrList< const pointField > &points)
Reset point references to begin a new piece.
void setElementType(const elemOutputType elemOutput)
Define preferred element type.
virtual void setTime(const instant &inst)
Define a time name/value for the output.
coordSetWriter(const UPtrList< const pointField > &pts, const fileName &file, bool paralel=false)
Construct from components (default format INLINE_BASE64), and open the file for writing.
coordSetWriter(const coordSetWriter &)=delete
No copy construct.
coordSetWriter(const UPtrList< const pointField > &pts, const vtk::outputOptions opts, const fileName &file, bool paralel=false)
Construct from components and open the file for writing.
void operator=(const coordSetWriter &)=delete
No copy assignment.
elemOutputType
Types of element output.
bool writeProcIDs()
Write processor ids for each line as CellData or for each point as PointData, depending on isPointDat...
virtual ~coordSetWriter()=default
Destructor.
coordSetWriter(const UPtrList< const pointField > &pts, const vtk::outputOptions opts=vtk::formatType::INLINE_BASE64)
Construct from components (default format INLINE_BASE64).
void writePointData(const word &fieldName, const UPtrList< const Field< Type > > &fieldPtrs)
Write primitive field of PointData.
void writeTimeValue()
Write the currently set time as "TimeValue" FieldData.
virtual bool writeGeometry()
Write patch topology.
virtual bool beginFile(std::string title="")
Write file header (non-collective).
vtk::outputOptions opts() const noexcept
The output options in use.
bool parallel() const noexcept
Parallel output requested?
void writeTimeValue(scalar timeValue)
Write "TimeValue" FieldData (name as per Catalyst output).
Encapsulated combinations of output format options. This is primarily useful when defining the output...
Write faces/points (optionally with fields) as a vtp file or a legacy vtk file.
A class for handling words, derived from Foam::string.
Definition word.H:66
const pointField & points
Namespace for handling VTK output. Contains classes and functions for writing VTK file content.
@ INLINE_BASE64
XML inline base64, base64Formatter.
Definition foamVtkCore.H:91
Namespace for OpenFOAM.
const pointField & pts