Loading...
Searching...
No Matches
foamVtkSurfaceFieldWriter.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) 2016-2025 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::vtk::surfaceFieldWriter
29
30Description
31 Write surfaces fields (as PointData) in VTP format.
32 Legacy VTK format is intentionally not supported.
33
34 The file output is structured as HEAD, FIELD_DATA, PIECE followed by any
35 CELL_DATA or POINT_DATA. These states are tracked internally to help
36 detect logic errors.
37
38 The FieldData element is to be placed prior to writing any geometry
39 Piece. This moves the information to the front of the output file
40 for visibility and simplifies the logic.
41
42Note
43 Parallel output is combined into a single Piece without point merging,
44 which is similar to using multi-piece data sets, but allows more
45 convenient creation as a streaming process.
46 In the future, the duplicate points at processor connections
47 may be addressed using ghost points.
48
49SourceFiles
50 foamVtkSurfaceFieldWriter.cxx
51
52\*---------------------------------------------------------------------------*/
53
54#ifndef Foam_vtk_surfaceFieldWriter_H
55#define Foam_vtk_surfaceFieldWriter_H
56
57#include "foamVtkFileWriter.H"
58#include "fvMesh.H"
59#include "pointField.H"
60
61// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
62
63namespace Foam
64{
65namespace vtk
66{
68/*---------------------------------------------------------------------------*\
69 Class vtk::surfaceFieldWriter Declaration
70\*---------------------------------------------------------------------------*/
71
73:
74 public vtk::fileWriter
75{
76 // Private Member Data
77
78 //- Reference to the OpenFOAM mesh (or subset)
79 const fvMesh& mesh_;
80
81 //- Slab addressing for field points of the current Piece
82 OffsetRange<label> pointSlab_;
83
84 //- Total number of field points for the current Piece
85 label nTotalPoints() const noexcept { return pointSlab_.total(); }
86
87public:
88
89 // Generated Methods
90
91 //- No copy construct
93
94 //- No copy assignment
95 void operator=(const surfaceFieldWriter&) = delete;
96
97
98 // Constructors
99
100 //- Construct from mesh (default format INLINE_BASE64)
102 (
103 const fvMesh& mesh,
105 );
106
107 //- Construct from mesh (default format INLINE_BASE64),
108 //- and open the file for writing.
109 // The file name is with/without an extension.
111 (
112 const fvMesh& mesh,
113 const fileName& file,
115 );
116
117 //- Construct from mesh and open the file for writing.
118 // The file name is with/without an extension.
121 const fvMesh& mesh,
123 const fileName& file,
125 );
126
127
128 //- Destructor
129 virtual ~surfaceFieldWriter() = default;
130
131
132 // Member Functions
133
134 //- File extension for current format type.
136
137 //- File extension for given output type
138 inline static word ext(vtk::outputOptions)
139 {
140 // No legacy
142 }
143
145 //- Write file header (non-collective)
146 // \note Expected calling states: (OPENED).
147 virtual bool beginFile(std::string title = "");
148
149 //- Write cloud positions
150 // Also writes the file header if not previously written.
151 // \note Must be called prior to writing CellData or PointData
152 virtual bool writeGeometry();
153
154 //- Begin CellData output section for specified number of fields.
155 // Must be called prior to writing any cell data fields.
156 // \param nFields is the number of fields, which is required for
157 // legacy format.
158 // \note Expected calling states: (PIECE | POINT_DATA).
159 //
160 // \return True if the state changed
161 virtual bool beginCellData(label nFields=0);
162
163 //- Begin PointData output section
164 // Must be called prior to writing data fields.
165 // \note Expected calling states: (PIECE).
166 //
167 // \return True if the state changed
168 virtual bool beginPointData(label nFields=0);
170
171 // Write
172
173 //- Write field
174 void write(const surfaceVectorField& field);
175};
176
178// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179
180} // End namespace vtk
181} // End namespace Foam
182
183// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184
185#endif
186
187// ************************************************************************* //
A tuple of integers comprising start, size, total.
Definition OffsetRange.H:82
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
Definition UPstream.H:1669
A class for handling file names.
Definition fileName.H:75
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
Base class for VTK output writers that handle geometry and fields (eg, vtp, vtu data)....
vtk::outputOptions opts() const noexcept
The output options in use.
bool parallel() const noexcept
Parallel output requested?
word ext() const
File extension for current format type.
Encapsulated combinations of output format options. This is primarily useful when defining the output...
surfaceFieldWriter(const fvMesh &mesh, const vtk::outputOptions opts=vtk::formatType::INLINE_BASE64)
Construct from mesh (default format INLINE_BASE64).
void operator=(const surfaceFieldWriter &)=delete
No copy assignment.
surfaceFieldWriter(const surfaceFieldWriter &)=delete
No copy construct.
virtual bool beginCellData(label nFields=0)
Begin CellData output section for specified number of fields.
virtual bool beginPointData(label nFields=0)
Begin PointData output section.
void write(const surfaceVectorField &field)
Write field.
static word ext(vtk::outputOptions)
File extension for given output type.
word ext() const
File extension for current format type.
virtual ~surfaceFieldWriter()=default
Destructor.
surfaceFieldWriter(const fvMesh &mesh, const fileName &file, bool parallel=UPstream::parRun())
Construct from mesh (default format INLINE_BASE64), and open the file for writing.
surfaceFieldWriter(const fvMesh &mesh, const vtk::outputOptions opts, const fileName &file, bool parallel=UPstream::parRun())
Construct from mesh and open the file for writing.
virtual bool writeGeometry()
Write cloud positions.
virtual bool beginFile(std::string title="")
Write file header (non-collective).
A class for handling words, derived from Foam::string.
Definition word.H:66
rDeltaTY field()
dynamicFvMesh & mesh
Namespace for handling VTK output. Contains classes and functions for writing VTK file content.
@ POLY_DATA
"PolyData"
@ INLINE_BASE64
XML inline base64, base64Formatter.
Definition foamVtkCore.H:91
const Foam::Enum< fileTag > fileExtension
File extension (without ".") for some vtk XML file content types.
Namespace for OpenFOAM.
GeometricField< vector, fvsPatchField, surfaceMesh > surfaceVectorField
runTime write()