foamVtkVertexWriter.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) 2026 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 Class
27  Foam::vtk::vertexWriter
28 
29 Description
30  Write vertex/points (optionally with fields)
31  as a vtp file or a legacy vtk file.
32 
33  The file output states are managed by the Foam::vtk::fileWriter class.
34  FieldData (eg, TimeValue) must appear before any geometry pieces.
35 
36 Note
37  Parallel output is combined into a single Piece without point merging,
38  which is similar to using multi-piece data sets, but allows more
39  convenient creation as a streaming process.
40 
41 SourceFiles
42  foamVtkVertexWriter.cxx
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef Foam_vtk_vertexWriter_H
47 #define Foam_vtk_vertexWriter_H
48 
49 #include "foamVtkPolyWriter.H"
50 #include "instant.H"
51 
52 #include <functional>
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace Foam
57 {
58 namespace vtk
59 {
60 
61 /*---------------------------------------------------------------------------*\
62  Class vtk::vertexWriter Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 class vertexWriter
66 :
67  public vtk::polyWriter
68 {
69  // Private Member Data
70 
71  //- Reference to the points
72  std::reference_wrapper<const pointField> points_;
73 
74  //- Time name/value
75  instant instant_;
76 
77 
78  // Private Member Functions
79 
80  //- No copy construct
81  vertexWriter(const vertexWriter&) = delete;
82 
83  //- No copy assignment
84  void operator=(const vertexWriter&) = delete;
85 
86 
87 public:
88 
89  // Constructors
90 
91  //- Construct from components (default format INLINE_BASE64)
92  explicit vertexWriter
93  (
94  const pointField& pts,
96  );
97 
98  //- Construct from components (default format INLINE_BASE64),
99  //- and open the file for writing.
100  // The file name is with/without an extension.
102  (
103  const pointField& pts,
104  const fileName& file,
105  bool parallel = UPstream::parRun()
106  );
107 
108  //- Construct from components and open the file for writing.
109  // The file name is with/without an extension.
111  (
112  const pointField& pts,
113  const vtk::outputOptions opts,
114  const fileName& file,
115  bool parallel = UPstream::parRun()
116  );
117 
118 
119  //- Destructor
120  virtual ~vertexWriter() = default;
121 
122 
123  // Member Functions
124 
125  //- Define a time name/value for the output
126  virtual void setTime(const instant& inst);
127 
128  //- Write file header (non-collective)
129  // \note Expected calling states: (OPENED).
130  virtual bool beginFile(std::string title = "");
131 
132  //- Write vertex topology
133  // Also writes the file header if not previously written.
134  // \note Must be called prior to writing CellData or PointData
135  virtual bool writeGeometry();
136 
137  //- Write "TimeValue" FieldData (name as per Catalyst output)
138  // Must be called within the FIELD_DATA state.
139  // \note As a convenience this can also be called from
140  // (OPENED | DECLARED) states, in which case it invokes
141  // beginFieldData(1) internally.
143 
144  //- Write the currently set time as "TimeValue" FieldData
145  void writeTimeValue();
146 
147  //- Reset point references to begin a new piece
148  void piece(const pointField& points);
149 };
150 
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 } // End namespace vtk
155 } // End namespace Foam
156 
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 
159 #endif
160 
161 // ************************************************************************* //
bool parallel() const noexcept
Parallel output requested?
virtual void setTime(const instant &inst)
Define a time name/value for the output.
A class for handling file names.
Definition: fileName.H:72
virtual bool writeGeometry()
Write vertex topology.
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:1774
vtk::outputOptions opts() const noexcept
The output options in use.
void writeTimeValue(scalar timeValue)
Write "TimeValue" FieldData (name as per Catalyst output)
Encapsulated combinations of output format options. This is primarily useful when defining the output...
const pointField & points
virtual ~vertexWriter()=default
Destructor.
void writeTimeValue()
Write the currently set time as "TimeValue" FieldData.
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name...
Definition: instant.H:53
void piece(const pointField &points)
Reset point references to begin a new piece.
virtual bool beginFile(std::string title="")
Write file header (non-collective)
Write vertex/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. The class is also sli...
XML inline base64, base64Formatter.
Namespace for OpenFOAM.
const pointField & pts