foamVtkGenericPatchWriter.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) 2018-2021 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::GenericPatchWriter
28
29Description
30 Write concrete PrimitivePatch faces/points (optionally with fields)
31 as a vtp file or a legacy vtk file.
32 The patch type is limited to representations of polygon faces
33 and 3D points and must support the following methods:
34
35 - localPoints()
36 - localFaces()
37 .
38
39 The file output states are managed by the Foam::vtk::fileWriter class.
40 FieldData (eg, TimeValue) must appear before any geometry pieces.
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
47\*---------------------------------------------------------------------------*/
48
49#ifndef Foam_vtk_GenericPatchWriter_H
50#define Foam_vtk_GenericPatchWriter_H
51
52#include "foamVtkPolyWriter.H"
53
54// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55
56namespace Foam
57{
58namespace vtk
59{
60
61/*---------------------------------------------------------------------------*\
62 Class vtk::GenericPatchWriter Declaration
63\*---------------------------------------------------------------------------*/
64
65template<class PatchType>
67:
68 public vtk::polyWriter
69{
70 // Private Member Data
71
72 //- Reference to faces/points as a patch
73 const PatchType& pp_;
74
75
76 // Private Member Functions
77
78 //- No copy construct
80
81 //- No copy assignment
82 void operator=(const GenericPatchWriter<PatchType>&) = delete;
83
84
85public:
86
87 // Constructors
88
89 //- Construct from patch (default output INLINE_BASE64)
90 explicit GenericPatchWriter
91 (
92 const PatchType& pp,
94 )
95 :
96 vtk::polyWriter(opts),
97 pp_(pp)
98 {}
99
100 //- Construct from components (default output INLINE_BASE64),
101 //- and open the file for writing.
102 // The file name is with/without an extension.
104 (
105 const PatchType& pp,
106 const fileName& file,
108 )
109 :
110 vtk::polyWriter(file, parallel),
111 pp_(pp)
112 {}
113
114 //- Construct from components and open the file for writing.
115 // The file name is with/without an extension.
117 (
118 const PatchType& pp,
120 const fileName& file,
122 )
123 :
124 vtk::polyWriter(opts, file, parallel),
125 pp_(pp)
126 {}
127
128
129 //- Destructor
130 virtual ~GenericPatchWriter() = default;
131
132
133 // Member Functions
134
135 //- Reference to the originating face/points patch
136 const PatchType& patch() const noexcept
137 {
138 return pp_;
139 }
140
141 //- Write file header (non-collective)
142 // \note Expected calling states: (OPENED).
143 virtual bool beginFile(std::string title = "surface")
144 {
145 return vtk::polyWriter::beginFile(title);
146 }
147
148 //- Write patch topology
149 // Also writes the file header if not previously written.
150 // \note Must be called prior to writing CellData or PointData
151 virtual bool writeGeometry()
152 {
153 return writePolyGeometry(pp_.localPoints(), pp_.localFaces());
154 }
155
156
157 // Write Fields
158
159 //- Write processor ids for each poly as CellData
160 bool writeProcIDs()
161 {
163 }
164};
165
166
167// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168
169} // End namespace vtk
170} // End namespace Foam
171
172// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173
174#endif
175
176// ************************************************************************* //
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:433
A class for handling file names.
Definition: fileName.H:76
Write concrete PrimitivePatch faces/points (optionally with fields) as a vtp file or a legacy vtk fil...
virtual bool beginFile(std::string title="surface")
Write file header (non-collective)
bool writeProcIDs()
Write processor ids for each poly as CellData.
const PatchType & patch() const noexcept
Reference to the originating face/points patch.
virtual ~GenericPatchWriter()=default
Destructor.
GenericPatchWriter(const PatchType &pp, const vtk::outputOptions opts=vtk::formatType::INLINE_BASE64)
Construct from patch (default output INLINE_BASE64)
virtual bool writeGeometry()
Write patch topology.
vtk::outputOptions opts() const noexcept
The output options in use.
bool parallel() const noexcept
Parallel output requested?
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.
label nLocalPolys_
Local number of polys (faces)
bool writePolyGeometry(const pointField &points, const faceList &faces)
virtual bool beginFile(std::string title="")
Write file header (non-collective)
@ INLINE_BASE64
XML inline base64, base64Formatter.
Namespace for OpenFOAM.
const direction noexcept
Definition: Scalar.H:223