OpenFOAM: API Guide
v2112
The open source CFD toolbox
foamVtkLagrangianWriter.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) 2016-2018 OpenCFD Ltd.
9
-------------------------------------------------------------------------------
10
License
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
26
Class
27
Foam::vtk::lagrangianWriter
28
29
Description
30
Write lagrangian (cloud) positions and fields (as PointData) in
31
VTP format. Legacy VTK format is intentionally not supported since
32
the VTP format provides much better field selection in ParaView, and for
33
consistency with the Foam::functionObjects::vtkCloud function object.
34
35
The file output states are managed by the Foam::vtk::fileWriter class.
36
FieldData (eg, TimeValue) must appear before any geometry pieces.
37
38
Note
39
If fields should be CellData instead of PointData (default), this
40
must be decided at construction time.
41
42
SourceFiles
43
lagrangianWriter.C
44
lagrangianWriterTemplates.C
45
46
\*---------------------------------------------------------------------------*/
47
48
#ifndef Foam_vtk_lagrangianWriter_H
49
#define Foam_vtk_lagrangianWriter_H
50
51
#include "
fvMesh.H
"
52
#include "
pointField.H
"
53
#include "
foamVtkFileWriter.H
"
54
55
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56
57
namespace
Foam
58
{
59
60
// Forward Declarations
61
class
IOobjectList
;
62
template
<
class
Type>
class
IOField
;
63
64
namespace
vtk
65
{
66
67
/*---------------------------------------------------------------------------*\
68
Class vtk::lagrangianWriter Declaration
69
\*---------------------------------------------------------------------------*/
70
71
class
lagrangianWriter
72
:
73
public
vtk::fileWriter
74
{
75
// Private Member Data
76
77
//- Reference to the OpenFOAM mesh (or subset)
78
const
fvMesh
& mesh_;
79
80
//- The cloud name
81
const
word
cloudName_;
82
83
//- The number of field points for the current Piece
84
label numberOfPoints_;
85
86
//- Write as CellData (verts) instead of as PointData.
87
const
bool
useVerts_;
88
89
90
// Private Member Functions
91
92
//- The cloud directory for the current cloud name.
93
fileName
cloudDir()
const
;
94
95
//- Transcribe the cloud into pointField
96
pointField
positions()
const
;
97
98
//- Write vertex (cells)
99
void
writeVerts();
100
101
102
//- No copy construct
103
lagrangianWriter
(
const
lagrangianWriter
&) =
delete
;
104
105
//- No copy assignment
106
void
operator=(
const
lagrangianWriter
&) =
delete
;
107
108
109
protected
:
110
111
// Protected Member Functions
112
113
//- Begin CellData output section for specified number of fields.
114
// Must be called prior to writing any cell data fields.
115
// \param nFields is the number of fields, which is required for
116
// legacy format.
117
// \note Expected calling states: (PIECE | POINT_DATA).
118
//
119
// \return True if the state changed
120
virtual
bool
beginCellData
(label nFields=0);
121
122
//- Begin PointData for specified number of fields.
123
// Must be called prior to writing any point data fields.
124
// \param nFields is the number of fields, which is required for
125
// legacy format.
126
// \note Expected calling states: (PIECE | CELL_DATA).
127
//
128
// \return True if the state changed
129
virtual
bool
beginPointData
(label nFields=0);
130
131
132
public
:
133
134
// Constructors
135
136
//- Construct from components (default format INLINE_BASE64)
137
// \param useVerts Define VERTS and use CellData instead of PointData.
138
lagrangianWriter
139
(
140
const
fvMesh
&
mesh
,
141
const
word
&
cloudName
,
142
const
vtk::outputOptions
opts
=
vtk::formatType::INLINE_BASE64
,
143
bool
useVerts =
false
144
);
145
146
//- Construct from components (default format INLINE_BASE64),
147
//- and open the file for writing.
148
// The file name is with/without an extension.
149
lagrangianWriter
150
(
151
const
fvMesh
&
mesh
,
152
const
word
&
cloudName
,
153
const
fileName
& file,
154
bool
parallel
=
Pstream::parRun
()
155
);
156
157
//- Construct from components and open the file for writing.
158
// The file name is with/without an extension.
159
lagrangianWriter
160
(
161
const
fvMesh
&
mesh
,
162
const
word
&
cloudName
,
163
const
vtk::outputOptions
opts
,
164
const
fileName
& file,
165
bool
parallel
=
Pstream::parRun
()
166
);
167
168
169
//- Destructor
170
virtual
~lagrangianWriter
() =
default
;
171
172
173
// Member Functions
174
175
//- File extension for current format type.
176
using
vtk::fileWriter::ext
;
177
178
//- File extension for given output type. Always ".vtp"
179
inline
static
word
ext
(
vtk::outputOptions
)
180
{
181
// No legacy
182
return
vtk::fileExtension
[
vtk::fileTag::POLY_DATA
];
183
}
184
185
186
//- Write file header (non-collective)
187
// \note Expected calling states: (OPENED).
188
virtual
bool
beginFile
(std::string title =
""
);
189
190
//- Write cloud positions
191
// Also writes the file header if not previously written.
192
// \note Must be called prior to writing CellData or PointData
193
virtual
bool
writeGeometry
();
194
195
196
//- Begin parcel (PointData) output section
197
// Must be called prior to writing data fields.
198
// \note Expected calling states: (PIECE).
199
//
200
// \return True if the state changed
201
bool
beginParcelData
();
202
203
//- Explicitly end parcel (PointData) output and switch to PIECE state
204
// Ignored (no-op) if not currently in the parcel state.
205
bool
endParcelData
();
206
207
208
// Write
209
210
//- Write the IOField
211
template
<
class
Type>
212
void
write
(
const
IOField<Type>
&
field
);
213
214
//- Write IOFields
215
template
<
class
Type>
216
label
writeFields
(
const
wordList
&
fieldNames
,
bool
verbose=
true
);
217
218
//- Write IOFields
219
template
<
class
Type>
220
label
writeFields
(
const
IOobjectList
& objects,
bool
verbose=
true
);
221
};
222
223
224
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225
226
}
// End namespace vtk
227
}
// End namespace Foam
228
229
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230
231
#ifdef NoRepository
232
#include "
foamVtkLagrangianWriterTemplates.C
"
233
#endif
234
235
236
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237
238
#endif
239
240
// ************************************************************************* //
Foam::vtk::outputOptions
Encapsulated combinations of output format options. This is primarily useful when defining the output...
Definition:
foamVtkOutputOptions.H:59
Foam::vtk::lagrangianWriter
Write lagrangian (cloud) positions and fields (as PointData) in VTP format. Legacy VTK format is inte...
Definition:
foamVtkLagrangianWriter.H:70
Foam::vtk::fileWriter
Base class for VTK output writers that handle geometry and fields (eg, vtp, vtu data)....
Definition:
foamVtkFileWriter.H:66
cloudName
const word cloudName(propsDict.get< word >("cloud"))
Foam::word
A class for handling words, derived from Foam::string.
Definition:
word.H:65
Foam::fileName
A class for handling file names.
Definition:
fileName.H:73
Foam::IOField
A primitive field of type <T> with automated input and output.
Definition:
foamVtkLagrangianWriter.H:61
Foam::vtk::fileWriter::opts
vtk::outputOptions opts() const
The output options in use.
Definition:
foamVtkFileWriterI.H:62
foamVtkLagrangianWriterTemplates.C
Foam::vtk::lagrangianWriter::beginCellData
virtual bool beginCellData(label nFields=0)
Begin CellData output section for specified number of fields.
Definition:
foamVtkLagrangianWriter.C:103
Foam::vtk::lagrangianWriter::writeFields
label writeFields(const wordList &fieldNames, bool verbose=true)
Write IOFields.
Foam::vtk::fileExtension
const Foam::Enum< fileTag > fileExtension
File extension (without ".") for some vtk XML file content types.
Foam::vtk::fileTag::POLY_DATA
"PolyData"
foamVtkFileWriter.H
Foam::vtk::lagrangianWriter::beginParcelData
bool beginParcelData()
Begin parcel (PointData) output section.
Definition:
foamVtkLagrangianWriter.C:278
Foam::vtk::fileWriter::parallel
bool parallel() const noexcept
Parallel output requested?
Definition:
foamVtkFileWriterI.H:80
Foam::vtk::lagrangianWriter::~lagrangianWriter
virtual ~lagrangianWriter()=default
Destructor.
Foam::Field< vector >
Foam::vtk::lagrangianWriter::write
void write(const IOField< Type > &field)
Write the IOField.
Definition:
foamVtkLagrangianWriterTemplates.C:35
field
rDeltaTY field()
Foam::vtk::lagrangianWriter::ext
static word ext(vtk::outputOptions)
File extension for given output type. Always ".vtp".
Definition:
foamVtkLagrangianWriter.H:178
Foam::vtk::lagrangianWriter::endParcelData
bool endParcelData()
Explicitly end parcel (PointData) output and switch to PIECE state.
Definition:
foamVtkLagrangianWriter.C:291
fieldNames
const wordRes fieldNames(propsDict.getOrDefault< wordRes >("fields", wordRes()))
mesh
dynamicFvMesh & mesh
Definition:
createDynamicFvMesh.H:6
Foam::vtk::formatType::INLINE_BASE64
XML inline base64, base64Formatter.
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition:
fvMesh.H:85
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition:
atmBoundaryLayer.C:33
Foam::IOobjectList
List of IOobjects with searching and retrieving facilities.
Definition:
IOobjectList.H:55
pointField.H
Foam::vtk::lagrangianWriter::writeGeometry
virtual bool writeGeometry()
Write cloud positions.
Definition:
foamVtkLagrangianWriter.C:189
Foam::vtk::lagrangianWriter::beginFile
virtual bool beginFile(std::string title="")
Write file header (non-collective)
Definition:
foamVtkLagrangianWriter.C:167
Foam::UPstream::parRun
static bool & parRun() noexcept
Test if this a parallel run.
Definition:
UPstream.H:433
Foam::List< word >
Foam::vtk::lagrangianWriter::beginPointData
virtual bool beginPointData(label nFields=0)
Begin PointData for specified number of fields.
Definition:
foamVtkLagrangianWriter.C:109
Foam::vtk::fileWriter::ext
word ext() const
File extension for current format type.
Definition:
foamVtkFileWriterI.H:68
src
lagrangian
intermediate
conversion
vtk
foamVtkLagrangianWriter.H
Generated by
1.8.17
OPENFOAM® is a registered
trademark
of OpenCFD Ltd.