foamVtkSurfaceWriter.C
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
26\*---------------------------------------------------------------------------*/
27
29
30// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31
33(
34 const pointField& points,
35 const faceList& faces,
36 const vtk::outputOptions opts
37)
38:
39 vtk::polyWriter(opts),
40
41 points_(std::cref<pointField>(points)),
42 faces_(std::cref<faceList>(faces)),
43 instant_()
44{}
45
46
48(
49 const pointField& points,
50 const faceList& faces,
51 const fileName& file,
52 bool parallel
53)
54:
55 surfaceWriter(points, faces)
56{
57 open(file, parallel);
58}
59
60
62(
63 const pointField& points,
64 const faceList& faces,
65 const vtk::outputOptions opts,
66 const fileName& file,
67 bool parallel
68)
69:
70 surfaceWriter(points, faces, opts)
71{
72 open(file, parallel);
73}
74
75
76// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
77
79{
80 instant_ = inst;
81}
82
83
85{
86 if (title.size())
87 {
88 return vtk::fileWriter::beginFile(title);
89 }
90
91 if (!instant_.name().empty())
92 {
94 (
95 "time='" + instant_.name() + "'"
96 );
97 }
98
99 // Provide default title
100 return vtk::fileWriter::beginFile("surface");
101}
102
103
105{
106 return writePolyGeometry(points_.get(), faces_.get());
107}
108
109
111{
112 if (!instant_.name().empty())
113 {
114 vtk::fileWriter::writeTimeValue(instant_.value());
115 }
116}
117
118
120(
121 const pointField& points,
122 const faceList& faces
123)
124{
125 endPiece();
126
127 points_ = std::cref<pointField>(points);
128 faces_ = std::cref<faceList>(faces);
129}
130
131
133{
134 return vtk::fileWriter::writeProcIDs(nLocalPolys_);
135}
136
137
138// ************************************************************************* //
A class for handling file names.
Definition: fileName.H:76
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name.
Definition: instant.H:56
bool parallel() const noexcept
Parallel output requested?
virtual bool open(const fileName &file, bool parallel=Pstream::parRun())
Open file for writing (creates parent directory).
virtual bool beginFile(std::string title="")
Write file header (non-collective)
void writeTimeValue()
Write the currently set time as "TimeValue" FieldData.
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.
Write faces/points (optionally with fields) as a vtp file or a legacy vtk file.
virtual void setTime(const instant &inst)
Define a time name/value for the output.
void piece(const pointField &points, const faceList &faces)
Reset point/face references to begin a new piece.
void writeTimeValue()
Write the currently set time as "TimeValue" FieldData.
virtual bool writeGeometry()
Write patch topology.
virtual bool beginFile(std::string title="")
Write file header (non-collective)
const pointField & points