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 -------------------------------------------------------------------------------
10 License
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 
28 #include "foamVtkSurfaceWriter.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
32 Foam::vtk::surfaceWriter::surfaceWriter
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 
47 Foam::vtk::surfaceWriter::surfaceWriter
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 
61 Foam::vtk::surfaceWriter::surfaceWriter
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 
84 bool Foam::vtk::surfaceWriter::beginFile(std::string title)
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 // ************************************************************************* //
Foam::vtk::outputOptions
Encapsulated combinations of output format options. This is primarily useful when defining the output...
Definition: foamVtkOutputOptions.H:59
Foam::vtk::surfaceWriter::beginFile
virtual bool beginFile(std::string title="")
Write file header (non-collective)
Definition: foamVtkSurfaceWriter.C:84
Foam::vtk::surfaceWriter::piece
void piece(const pointField &points, const faceList &faces)
Reset point/face references to begin a new piece.
Definition: foamVtkSurfaceWriter.C:120
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::vtk::surfaceWriter::writeTimeValue
void writeTimeValue()
Write the currently set time as "TimeValue" FieldData.
Definition: foamVtkSurfaceWriter.C:110
Foam::vtk::fileWriter::writeTimeValue
void writeTimeValue(scalar timeValue)
Write "TimeValue" FieldData (name as per Catalyst output)
Definition: foamVtkFileWriter.C:518
Foam::vtk::surfaceWriter::writeGeometry
virtual bool writeGeometry()
Write patch topology.
Definition: foamVtkSurfaceWriter.C:104
Foam::vtk::fileWriter::beginFile
virtual bool beginFile(std::string title="")
Write file header (non-collective)
Definition: foamVtkFileWriter.C:393
foamVtkSurfaceWriter.H
Foam::vtk::surfaceWriter::setTime
virtual void setTime(const instant &inst)
Define a time name/value for the output.
Definition: foamVtkSurfaceWriter.C:78
Foam::Field< vector >
Foam::vtk::surfaceWriter::writeProcIDs
bool writeProcIDs()
Definition: foamVtkSurfaceWriter.C:132
Foam::vtk::surfaceWriter
Write faces/points (optionally with fields) as a vtp file or a legacy vtk file.
Definition: foamVtkSurfaceWriter.H:65
Foam::List< face >
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::vtk::fileWriter::writeProcIDs
bool writeProcIDs(const label nValues)
Write nValues of processor ids as CellData (no-op in serial)
Definition: foamVtkFileWriter.C:545
Foam::vtk::polyWriter
Write faces/points (optionally with fields) as a vtp file or a legacy vtk file.
Definition: foamVtkPolyWriter.H:67
Foam::instant
An instant of time. Contains the time value and name.
Definition: instant.H:52