Loading...
Searching...
No Matches
foamVtkLineWriter.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) 2021-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::lineWriter
28
29Description
30 Write edge/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
36Note
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 In the future, the duplicate points at processor connections
41 may be addressed using ghost points.
42
43SourceFiles
44 foamVtkLineWriter.cxx
45
46\*---------------------------------------------------------------------------*/
47
48#ifndef Foam_vtk_lineWriter_H
49#define Foam_vtk_lineWriter_H
50
51#include "foamVtkPolyWriter.H"
52#include "instant.H"
53
54#include <functional>
55
56// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57
58namespace Foam
59{
60namespace vtk
61{
63/*---------------------------------------------------------------------------*\
64 Class vtk::lineWriter Declaration
65\*---------------------------------------------------------------------------*/
66
67class lineWriter
68:
69 public vtk::polyWriter
70{
71 // Private Member Data
72
73 //- Reference to the points
74 std::reference_wrapper<const pointField> points_;
75
76 //- Reference to the edges
77 std::reference_wrapper<const edgeList> edges_;
78
79 //- Time name/value
80 instant instant_;
81
82
83 // Private Member Functions
84
85 //- No copy construct
86 lineWriter(const lineWriter&) = delete;
87
88 //- No copy assignment
89 void operator=(const lineWriter&) = delete;
90
91
92public:
93
94 // Constructors
95
96 //- Construct from components (default format INLINE_BASE64)
97 lineWriter
98 (
99 const pointField& pts,
100 const edgeList& edges,
102 );
103
104 //- Construct from components (default format INLINE_BASE64),
105 //- and open the file for writing.
106 // The file name is with/without an extension.
107 lineWriter
108 (
109 const pointField& pts,
110 const edgeList& edges,
111 const fileName& file,
113 );
114
115 //- Construct from components and open the file for writing.
116 // The file name is with/without an extension.
118 (
119 const pointField& pts,
120 const edgeList& edges,
122 const fileName& file,
124 );
125
126
127 //- Destructor
128 virtual ~lineWriter() = default;
129
131 // Member Functions
132
133 //- Define a time name/value for the output
134 virtual void setTime(const instant& inst);
135
136 //- Write file header (non-collective)
137 // \note Expected calling states: (OPENED).
138 virtual bool beginFile(std::string title = "");
139
140 //- Write patch topology
141 // Also writes the file header if not previously written.
142 // \note Must be called prior to writing CellData or PointData
143 virtual bool writeGeometry();
144
145 //- Write "TimeValue" FieldData (name as per Catalyst output)
146 // Must be called within the FIELD_DATA state.
147 // \note As a convenience this can also be called from
148 // (OPENED | DECLARED) states, in which case it invokes
149 // beginFieldData(1) internally.
152 //- Write the currently set time as "TimeValue" FieldData
153 void writeTimeValue();
154
155 //- Reset point/edge references to begin a new piece
156 void piece(const pointField& points, const edgeList& edges);
157
159 //- Write processor ids for each line as CellData or for each point
160 //- as PointData, depending on isPointData() state. No-op in serial.
161 bool writeProcIDs();
162
163 //- Write a uniform field of Cell (Line) or Point values
164 template<class Type>
165 void writeUniform(const word& fieldName, const Type& val)
168 }
169};
170
171
172// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173
174} // End namespace vtk
175} // End namespace Foam
176
177// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178
179#endif
180
181// ************************************************************************* //
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
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name.
Definition instant.H:56
vtk::outputOptions opts() const noexcept
The output options in use.
bool parallel() const noexcept
Parallel output requested?
void writeTimeValue(scalar timeValue)
Write "TimeValue" FieldData (name as per Catalyst output).
void writeUniform(const word &fieldName, const Type &val)
Write a uniform field of Cell (Line) or Point values.
void piece(const pointField &points, const edgeList &edges)
Reset point/edge references to begin a new piece.
virtual void setTime(const instant &inst)
Define a time name/value for the output.
bool writeProcIDs()
Write processor ids for each line as CellData or for each point as PointData, depending on isPointDat...
lineWriter(const pointField &pts, const edgeList &edges, const fileName &file, bool parallel=UPstream::parRun())
Construct from components (default format INLINE_BASE64), and open the file for writing.
lineWriter(const pointField &pts, const edgeList &edges, const vtk::outputOptions opts=vtk::formatType::INLINE_BASE64)
Construct from components (default format INLINE_BASE64).
lineWriter(const pointField &pts, const edgeList &edges, const vtk::outputOptions opts, const fileName &file, bool parallel=UPstream::parRun())
Construct from components and open the file for writing.
void writeTimeValue()
Write the currently set time as "TimeValue" FieldData.
virtual bool writeGeometry()
Write patch topology.
virtual ~lineWriter()=default
Destructor.
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 nLocalLines_
Local number of lines (edges).
void writeUniformValue(const label nCellValues, const word &fieldName, const Type &val)
Write a uniform field of Cell (Poly or Line) or Point values.
A class for handling words, derived from Foam::string.
Definition word.H:66
const pointField & 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.
List< edge > edgeList
List of edge.
Definition edgeList.H:32
vectorField pointField
pointField is a vectorField.
const pointField & pts