Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::vtk::GenericPatchWriter
Description
Write concrete PrimitivePatch faces/points (optionally with fields)
as a vtp file or a legacy vtk file.
The patch type is limited to representations of polygon faces
and 3D points and must support the following methods:
- localPoints()
- localFaces()
.
The file output states are managed by the Foam::vtk::fileWriter class.
FieldData (eg, TimeValue) must appear before any geometry pieces.
Note
Parallel output is combined into a single Piece without point merging,
which is similar to using multi-piece data sets, but allows more
convenient creation as a streaming process.
\*---------------------------------------------------------------------------*/
#ifndef Foam_vtk_GenericPatchWriter_H
#define Foam_vtk_GenericPatchWriter_H
#include "foamVtkPolyWriter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace vtk
{
/*---------------------------------------------------------------------------*\
Class vtk::GenericPatchWriter Declaration
\*---------------------------------------------------------------------------*/
template<class PatchType>
class GenericPatchWriter
:
public vtk::polyWriter
{
// Private Member Data
//- Reference to faces/points as a patch
const PatchType& pp_;
// Private Member Functions
//- No copy construct
GenericPatchWriter(const GenericPatchWriter<PatchType>&) = delete;
//- No copy assignment
void operator=(const GenericPatchWriter<PatchType>&) = delete;
public:
// Constructors
//- Construct from patch (default output INLINE_BASE64)
explicit GenericPatchWriter
(
const PatchType& pp,
const vtk::outputOptions opts = vtk::formatType::INLINE_BASE64
)
:
vtk::polyWriter(opts),
pp_(pp)
{}
//- Construct from components (default output INLINE_BASE64),
//- and open the file for writing.
// The file name is with/without an extension.
GenericPatchWriter
(
const PatchType& pp,
const fileName& file,
bool parallel = Pstream::parRun()
)
:
vtk::polyWriter(file, parallel),
pp_(pp)
{}
//- Construct from components and open the file for writing.
// The file name is with/without an extension.
GenericPatchWriter
(
const PatchType& pp,
const vtk::outputOptions opts,
const fileName& file,
bool parallel = Pstream::parRun()
)
:
vtk::polyWriter(opts, file, parallel),
pp_(pp)
{}
//- Destructor
virtual ~GenericPatchWriter() = default;
// Member Functions
//- Reference to the originating face/points patch
const PatchType& patch() const noexcept
{
return pp_;
}
//- Write file header (non-collective)
// \note Expected calling states: (OPENED).
virtual bool beginFile(std::string title = "surface")
{
return vtk::polyWriter::beginFile(title);
}
//- Write patch topology
// Also writes the file header if not previously written.
// \note Must be called prior to writing CellData or PointData
virtual bool writeGeometry()
{
return writePolyGeometry(pp_.localPoints(), pp_.localFaces());
}
// Write Fields
//- Write processor ids for each poly as CellData
bool writeProcIDs()
{
return vtk::polyWriter::writeProcIDs(nLocalPolys_);
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace vtk
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //