foamVtkGenericPatchWriter.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) 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 Class
27  Foam::vtk::GenericPatchWriter
28 
29 Description
30  Write concrete PrimitivePatch faces/points (optionally with fields)
31  as a vtp file or a legacy vtk file.
32  The patch type is limited to representations of polygon faces
33  and 3D points and must support the following methods:
34 
35  - localPoints()
36  - localFaces()
37  .
38 
39  The file output states are managed by the Foam::vtk::fileWriter class.
40  FieldData (eg, TimeValue) must appear before any geometry pieces.
41 
42 Note
43  Parallel output is combined into a single Piece without point merging,
44  which is similar to using multi-piece data sets, but allows more
45  convenient creation as a streaming process.
46 
47 \*---------------------------------------------------------------------------*/
48 
49 #ifndef Foam_vtk_GenericPatchWriter_H
50 #define Foam_vtk_GenericPatchWriter_H
51 
52 #include "foamVtkPolyWriter.H"
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace Foam
57 {
58 namespace vtk
59 {
60 
61 /*---------------------------------------------------------------------------*\
62  Class vtk::GenericPatchWriter Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 template<class PatchType>
67 :
68  public vtk::polyWriter
69 {
70  // Private Member Data
71 
72  //- Reference to faces/points as a patch
73  const PatchType& pp_;
74 
75 
76  // Private Member Functions
77 
78  //- No copy construct
80 
81  //- No copy assignment
82  void operator=(const GenericPatchWriter<PatchType>&) = delete;
83 
84 
85 public:
86 
87  // Constructors
88 
89  //- Construct from patch (default output INLINE_BASE64)
91  (
92  const PatchType& pp,
94  )
95  :
96  vtk::polyWriter(opts),
97  pp_(pp)
98  {}
99 
100  //- Construct from components (default output INLINE_BASE64),
101  //- and open the file for writing.
102  // The file name is with/without an extension.
104  (
105  const PatchType& pp,
106  const fileName& file,
107  bool parallel = Pstream::parRun()
108  )
109  :
110  vtk::polyWriter(file, parallel),
111  pp_(pp)
112  {}
113 
114  //- Construct from components and open the file for writing.
115  // The file name is with/without an extension.
117  (
118  const PatchType& pp,
119  const vtk::outputOptions opts,
120  const fileName& file,
121  bool parallel = Pstream::parRun()
122  )
123  :
124  vtk::polyWriter(opts, file, parallel),
125  pp_(pp)
126  {}
127 
128 
129  //- Destructor
130  virtual ~GenericPatchWriter() = default;
131 
132 
133  // Member Functions
134 
135  //- Reference to the originating face/points patch
136  const PatchType& patch() const noexcept
137  {
138  return pp_;
139  }
140 
141  //- Write file header (non-collective)
142  // \note Expected calling states: (OPENED).
143  virtual bool beginFile(std::string title = "surface")
144  {
145  return vtk::polyWriter::beginFile(title);
146  }
147 
148  //- Write patch topology
149  // Also writes the file header if not previously written.
150  // \note Must be called prior to writing CellData or PointData
151  virtual bool writeGeometry()
152  {
153  return writePolyGeometry(pp_.localPoints(), pp_.localFaces());
154  }
155 
156 
157  // Write Fields
158 
159  //- Write processor ids for each poly as CellData
160  bool writeProcIDs()
161  {
163  }
164 };
165 
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 } // End namespace vtk
170 } // End namespace Foam
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 #endif
175 
176 // ************************************************************************* //
Foam::vtk::outputOptions
Encapsulated combinations of output format options. This is primarily useful when defining the output...
Definition: foamVtkOutputOptions.H:59
Foam::vtk::GenericPatchWriter::writeGeometry
virtual bool writeGeometry()
Write patch topology.
Definition: foamVtkGenericPatchWriter.H:150
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::vtk::fileWriter::opts
vtk::outputOptions opts() const
The output options in use.
Definition: foamVtkFileWriterI.H:62
Foam::vtk::GenericPatchWriter
Write concrete PrimitivePatch faces/points (optionally with fields) as a vtp file or a legacy vtk fil...
Definition: foamVtkGenericPatchWriter.H:65
Foam::vtk::polyWriter::writePolyGeometry
bool writePolyGeometry(const pointField &points, const faceList &faces)
Definition: foamVtkPolyWriter.C:649
Foam::vtk::fileWriter::beginFile
virtual bool beginFile(std::string title="")
Write file header (non-collective)
Definition: foamVtkFileWriter.C:393
Foam::vtk::GenericPatchWriter::writeProcIDs
bool writeProcIDs()
Write processor ids for each poly as CellData.
Definition: foamVtkGenericPatchWriter.H:159
Foam::vtk::fileWriter::parallel
bool parallel() const noexcept
Parallel output requested?
Definition: foamVtkFileWriterI.H:80
Foam::vtk::GenericPatchWriter::beginFile
virtual bool beginFile(std::string title="surface")
Write file header (non-collective)
Definition: foamVtkGenericPatchWriter.H:142
Foam::vtk::formatType::INLINE_BASE64
XML inline base64, base64Formatter.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::vtk::GenericPatchWriter::patch
const PatchType & patch() const noexcept
Reference to the originating face/points patch.
Definition: foamVtkGenericPatchWriter.H:135
Foam::UPstream::parRun
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:433
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::nLocalPolys_
label nLocalPolys_
Local number of polys (faces)
Definition: foamVtkPolyWriter.H:88
Foam::vtk::polyWriter
Write faces/points (optionally with fields) as a vtp file or a legacy vtk file.
Definition: foamVtkPolyWriter.H:67
Foam::vtk::GenericPatchWriter::~GenericPatchWriter
virtual ~GenericPatchWriter()=default
Destructor.
foamVtkPolyWriter.H