Loading...
Searching...
No Matches
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-2023 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
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
75public:
76
77 // Generated Methods
78
79 //- No copy construct
81
82 //- No copy assignment
83 void operator=(const GenericPatchWriter<PatchType>&) = delete;
84
85
86 // Constructors
87
88 //- Construct from patch (default output INLINE_BASE64)
89 explicit GenericPatchWriter
90 (
91 const PatchType& pp,
93 )
94 :
96 pp_(pp)
97 {}
98
99 //- Construct from components (default output INLINE_BASE64),
100 //- and open the file for writing.
101 // The file name is with/without an extension.
103 (
104 const PatchType& pp,
105 const fileName& file,
107 )
108 :
109 vtk::polyWriter(file, parallel),
110 pp_(pp)
111 {}
112
113 //- Construct from components and open the file for writing.
114 // The file name is with/without an extension.
116 (
117 const PatchType& pp,
119 const fileName& file,
121 )
123 vtk::polyWriter(opts, file, parallel),
124 pp_(pp)
125 {}
126
127
128 //- Destructor
129 virtual ~GenericPatchWriter() = default;
130
131
132 // Member Functions
133
134 //- Reference to the originating face/points patch
135 const PatchType& patch() const noexcept
136 {
137 return pp_;
139
140 //- Write file header (non-collective)
141 // \note Expected calling states: (OPENED).
142 virtual bool beginFile(std::string title = "surface")
143 {
144 return vtk::polyWriter::beginFile(title);
145 }
147 //- Write patch topology
148 // Also writes the file header if not previously written.
149 // \note Must be called prior to writing CellData or PointData
150 virtual bool writeGeometry()
151 {
152 return writePolyGeometry(pp_.localPoints(), pp_.localFaces());
153 }
154
155
156 // Write Fields
157
158 //- Write processor ids for each poly as CellData
159 bool writeProcIDs()
160 {
161 if (this->isPointData())
162 {
164 }
166 }
168
169
170// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171
172} // End namespace vtk
173} // End namespace Foam
174
175// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176
177#endif
179// ************************************************************************* //
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
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
virtual bool beginFile(std::string title="surface")
Write file header (non-collective).
GenericPatchWriter(const GenericPatchWriter< PatchType > &)=delete
No copy construct.
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).
void operator=(const GenericPatchWriter< PatchType > &)=delete
No copy assignment.
virtual bool writeGeometry()
Write patch topology.
GenericPatchWriter(const PatchType &pp, const vtk::outputOptions opts, const fileName &file, bool parallel=UPstream::parRun())
Construct from components and open the file for writing.
GenericPatchWriter(const PatchType &pp, const fileName &file, bool parallel=UPstream::parRun())
Construct from components (default output INLINE_BASE64), and open the file for writing.
bool writeProcIDs(const label nValues)
Write nValues of processor ids as CellData or PointData (no-op in serial).
vtk::outputOptions opts() const noexcept
The output options in use.
bool isPointData() const noexcept
True if output state corresponds to POINT_DATA.
bool parallel() const noexcept
Parallel output requested?
virtual bool beginFile(std::string title="")
Write file header (non-collective).
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)
Low-level write face/point topology. Normally used by writeGeometry() in a derived class.
label nLocalPoints_
Local number of 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 direction noexcept
Definition scalarImpl.H:265