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.C
41
42\*---------------------------------------------------------------------------*/
43
44#ifndef Foam_vtk_coordSetWriter_H
45#define Foam_vtk_coordSetWriter_H
46
47#include "foamVtkPolyWriter.H"
48#include "UPtrList.H"
49#include "Field.H"
50#include "instant.H"
51
52// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53
54namespace Foam
55{
56namespace vtk
57{
58
59/*---------------------------------------------------------------------------*\
60 Class vtk::coordSetWriter Declaration
61\*---------------------------------------------------------------------------*/
64:
65 public vtk::polyWriter
66{
67public:
68
69 // Data Types
70
71 //- Types of element output.
73 {
78 };
79
80private:
81
82 // Private Member Data
83
84 //- Reference to the points
86
87 //- Time name/value
88 instant instant_;
89
90 //- Preferred output element type
91 elemOutputType elemOutput_;
92
93
94 // Private Member Functions
95
96
97 // Private Member Functions
98
99 //- Determine sizes (nLocalPoints_, nLocalLines_),
100 //- and begin piece
101 void beginPiece();
102
103 //- Write points
104 void writePoints();
105
106 //- Write vertices, legacy format
107 // \param pointOffset processor-local point offset
108 void writeVertsLegacy();
109
110 //- Write vertices
111 // \param pointOffset processor-local point offset
112 void writeVerts();
113
114 //- Write lines, legacy format
115 // \param pointOffset processor-local point offset
116 void writeLinesLegacy();
117
118 //- Write lines
119 // \param pointOffset processor-local point offset
120 void writeLines();
121
122
123 //- No copy construct
124 coordSetWriter(const coordSetWriter&) = delete;
125
126 //- No copy assignment
127 void operator=(const coordSetWriter&) = delete;
128
129
130public:
131
132 // Constructors
133
134 //- Construct from components (default format INLINE_BASE64)
136 (
139 );
140
141 //- Construct from components (default format INLINE_BASE64),
142 //- and open the file for writing.
143 // The file name is with/without an extension.
145 (
147 const fileName& file,
148 bool paralel = false /* ignored: always false */
149 );
150
151 //- Construct from components and open the file for writing.
152 // The file name is with/without an extension.
154 (
157 const fileName& file,
158 bool paralel = false /* ignored: always false */
159 );
160
161
162 //- Destructor
163 virtual ~coordSetWriter() = default;
164
165
166 // Member Functions
167
168 //- Define preferred element type
169 void setElementType(const elemOutputType elemOutput);
170
171 //- Open file for writing. Non-parallel only
172 virtual bool open
173 (
174 const fileName& file,
175 bool parallel = false /* ignored: always false */
176 );
177
178 //- Define a time name/value for the output
179 virtual void setTime(const instant& inst);
180
181 //- Write file header (non-collective)
182 // \note Expected calling states: (OPENED).
183 virtual bool beginFile(std::string title = "");
184
185 //- Write patch topology
186 // Also writes the file header if not previously written.
187 // \note Must be called prior to writing CellData or PointData
188 virtual bool writeGeometry();
189
190 //- Write "TimeValue" FieldData (name as per Catalyst output)
191 // Must be called within the FIELD_DATA state.
192 // \note As a convenience this can also be called from
193 // (OPENED | DECLARED) states, in which case it invokes
194 // beginFieldData(1) internally.
196
197 //- Write the currently set time as "TimeValue" FieldData
198 void writeTimeValue();
199
200 //- Reset point references to begin a new piece
202
203
204 //- Write processor ids for each line as CellData
205 //- (no-op in serial)
206 bool writeProcIDs();
207
208
209 // Write
210
211 //- Write primitive field of PointData
212 template<class Type>
213 void writePointData
214 (
215 const word& fieldName,
216 const UPtrList<const Field<Type>>& fieldPtrs
217 );
218};
219
220
221// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
222
223} // End namespace vtk
224} // End namespace Foam
225
226// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227
228#ifdef NoRepository
230#endif
231
232// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233
234#endif
235
236// ************************************************************************* //
Generic templated field type.
Definition: Field.H:82
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: UPtrList.H:71
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
Write as points/lines, optionally with fields, as a vtp file or a legacy vtk file.
void piece(const UPtrList< const pointField > &points)
Reset point references to begin a new piece.
void setElementType(const elemOutputType elemOutput)
Define preferred element type.
elemOutputType
Types of element output.
virtual void setTime(const instant &inst)
Define a time name/value for the output.
virtual ~coordSetWriter()=default
Destructor.
virtual bool open(const fileName &file, bool parallel=false)
Open file for writing. Non-parallel only.
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()
Write the currently set time as "TimeValue" FieldData.
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:68
const pointField & points
@ INLINE_BASE64
XML inline base64, base64Formatter.
Namespace for OpenFOAM.