foamVtuCells.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) 2014-2020 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::vtuCells
28 
29 Description
30  A deep-copy description of an OpenFOAM volume mesh in data structures
31  suitable for VTK UnstructuredGrid, including the possibility of
32  decomposing polyhedral cells into primitive cell types.
33 
34  Knowledge of the vtkUnstructuredGrid and the corresponding \c .vtu
35  xml file-format aids in understanding this class.
36  The class can be used for the VTK xml format, legacy format, as well as a
37  VTK internal representation. The internal representation is somewhat
38  related to the xml format, but not entirely.
39 
40 SeeAlso
41  Foam::vtk::vtuSizing
42 
43 SourceFiles
44  foamVtuCells.C
45  foamVtuCellsI.H
46 
47 \*---------------------------------------------------------------------------*/
48 
49 #ifndef foamVtuCells_H
50 #define foamVtuCells_H
51 
52 #include "foamVtkCore.H"
53 #include "foamVtkMeshMaps.H"
54 #include "foamVtuSizing.H"
55 #include "labelList.H"
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 
59 namespace Foam
60 {
61 
62 // Forward Declarations
63 class polyMesh;
64 
65 namespace vtk
66 {
67 // Forward Declarations
68 class outputOptions;
69 
70 /*---------------------------------------------------------------------------*\
71  Class Foam::vtk::vtuCells Declaration
72 \*---------------------------------------------------------------------------*/
73 
74 class vtuCells
75 :
76  public vtuSizing
77 {
78  // Private Data
79 
80  // Requested output types
81 
82  //- Output content type
83  contentType output_;
84 
85  //- Bookkeeping for polyhedral cell decomposition
86  bool decomposeRequest_;
87 
88 
89  // Storage of output
90 
91  //- Cell types (including added cells) in vtk numbering
92  // Range is 1-255
93  List<uint8_t> cellTypes_;
94 
95  //- Vertices per cell (including added cells) in vtk ordering
96  List<label> vertLabels_;
97 
98  //- Connectivity (vertices) offset for the end of each cell
99  List<label> vertOffset_;
100 
101  //- Face lists per polyhedral cell
102  List<label> faceLabels_;
103 
104  //- Face label offsets
105  List<label> faceOffset_;
106 
107  //- Bookkeeping for polyhedral cell decomposition
108  foamVtkMeshMaps maps_;
109 
110 
111  // Private Member Functions
112 
113  //- Create the geometry using the previously requested output and
114  //- decomposition types.
115  void repopulate(const polyMesh& mesh);
116 
117  //- No copy construct
118  vtuCells(const vtuCells&) = delete;
119 
120  //- No copy assignment
121  void operator=(const vtuCells&) = delete;
122 
123 
124 public:
125 
126  // Constructors
127 
128  //- Default construct (XML format, no polyhedral decomposition)
129  explicit vtuCells
130  (
131  const enum contentType output = contentType::XML,
132  const bool decompose = false
133  );
134 
135  //- Construct from components, create output information immediately
136  explicit vtuCells
137  (
138  const polyMesh& mesh,
139  const enum contentType output = contentType::XML,
140  const bool decompose = false
141  );
142 
143  //- Construct from components.
144  // Optionally with polyhedral decomposition.
145  explicit vtuCells
146  (
147  const vtk::outputOptions opts,
148  const bool decompose = false
149  );
150 
151  //- Construct from components, create output information immediately
152  vtuCells
153  (
154  const polyMesh& mesh,
155  const vtk::outputOptions opts,
156  const bool decompose = false
157  );
158 
159 
160  // Member Functions
161 
162  // Access
163 
164  //- The output content type
165  inline enum contentType content() const;
166 
167  //- Query the polyhedral decompose requested flag.
168  inline bool decomposeRequested() const;
169 
170  //- True if no cellTypes are populated.
171  inline bool empty() const noexcept;
172 
173  //- The size of populated cellTypes.
174  inline label size() const noexcept;
175 
176 
177  // Edit
178 
179  //- Reset all sizes to zero.
180  void clear();
181 
182  //- Create the geometry using the previously requested output and
183  //- decomposition types.
184  void reset(const polyMesh& mesh);
185 
186  //- Respecify requested output and decomposition type prior to
187  //- creating the geometry
188  void reset
189  (
190  const polyMesh& mesh,
191  const enum contentType output,
192  const bool decompose
193  );
194 
195  //- Renumber cell ids to account for subset meshes
196  void renumberCells(const labelUList& mapping);
197 
198  //- Renumber point ids to account for subset meshes
199  void renumberPoints(const labelUList& mapping);
200 
201 
202  // Storage Access
203 
204  //- Values for "types" (XML) and "CELL_TYPES" (legacy)
205  inline const List<uint8_t>& cellTypes() const;
206 
207  //- Values for "connectivity" (XML) or "CELLS" (legacy)
208  inline const labelList& vertLabels() const;
209 
210  //- Values for "offsets" (XML only)
211  inline const labelList& vertOffsets() const;
212 
213  //- Values for "faces" (XML only)
214  inline const labelList& faceLabels() const;
215 
216  //- Values for "faceoffset" (XML only)
217  inline const labelList& faceOffsets() const;
218 
219  //- Additional point addressing (from added point to original cell)
220  inline const labelList& addPointCellLabels() const;
221 
222  //- Original cell ids for all cells (regular and decomposed).
223  inline const labelList& cellMap() const;
224 };
225 
226 
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 
229 } // End namespace vtk
230 } // End namespace Foam
231 
232 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 
234 #include "foamVtuCellsI.H"
235 
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 
238 #endif
239 
240 // ************************************************************************* //
Foam::vtk::outputOptions
Encapsulated combinations of output format options. This is primarily useful when defining the output...
Definition: foamVtkOutputOptions.H:59
Foam::output
static Ostream & output(Ostream &os, const IntRange< T > &range)
Definition: IntRanges.C:66
Foam::vtk::vtuSizing::decompose
bool decompose() const
Query the decompose flag (normally off)
Definition: foamVtuSizingI.H:32
Foam::vtk::vtuCells::content
enum contentType content() const
The output content type.
Definition: foamVtuCellsI.H:33
Foam::vtk::vtuCells::reset
void reset(const polyMesh &mesh)
Definition: foamVtuCells.C:166
Foam::vtk::vtuCells::cellTypes
const List< uint8_t > & cellTypes() const
Values for "types" (XML) and "CELL_TYPES" (legacy)
Definition: foamVtuCellsI.H:58
Foam::vtk::vtuCells::cellMap
const labelList & cellMap() const
Original cell ids for all cells (regular and decomposed).
Definition: foamVtuCellsI.H:100
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
foamVtuSizing.H
foamVtuCellsI.H
labelList.H
Foam::vtk::vtuCells::vertOffsets
const labelList & vertOffsets() const
Values for "offsets" (XML only)
Definition: foamVtuCellsI.H:72
Foam::vtk::vtuCells::addPointCellLabels
const labelList & addPointCellLabels() const
Additional point addressing (from added point to original cell)
Definition: foamVtuCellsI.H:93
Foam::vtk::vtuCells::vertLabels
const labelList & vertLabels() const
Values for "connectivity" (XML) or "CELLS" (legacy)
Definition: foamVtuCellsI.H:65
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::vtk::vtuSizing::contentType
contentType
Types of content that the storage may represent.
Definition: foamVtuSizing.H:207
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::vtk::vtuSizing
Sizing descriptions and routines for transcribing an OpenFOAM volume mesh into a VTK unstructured gri...
Definition: foamVtuSizing.H:200
Foam::vtk::vtuCells::renumberCells
void renumberCells(const labelUList &mapping)
Renumber cell ids to account for subset meshes.
Definition: foamVtuCells.C:187
Foam::vtk::vtuCells::faceLabels
const labelList & faceLabels() const
Values for "faces" (XML only)
Definition: foamVtuCellsI.H:79
Foam::vtk::vtuCells::size
label size() const noexcept
The size of populated cellTypes.
Definition: foamVtuCellsI.H:51
Foam::vtk::vtuCells::faceOffsets
const labelList & faceOffsets() const
Values for "faceoffset" (XML only)
Definition: foamVtuCellsI.H:86
Foam::vtk::vtuCells::clear
void clear()
Reset all sizes to zero.
Definition: foamVtuCells.C:94
Foam::List< uint8_t >
Foam::vtk::vtuCells::renumberPoints
void renumberPoints(const labelUList &mapping)
Renumber point ids to account for subset meshes.
Definition: foamVtuCells.C:193
Foam::UList< label >
foamVtkCore.H
Foam::vtk::vtuCells
A deep-copy description of an OpenFOAM volume mesh in data structures suitable for VTK UnstructuredGr...
Definition: foamVtuCells.H:73
Foam::vtk::vtuCells::decomposeRequested
bool decomposeRequested() const
Query the polyhedral decompose requested flag.
Definition: foamVtuCellsI.H:39
Foam::vtk::vtuCells::empty
bool empty() const noexcept
True if no cellTypes are populated.
Definition: foamVtuCellsI.H:45
foamVtkMeshMaps.H
Foam::foamVtkMeshMaps
Bookkeeping for mesh subsetting and/or polyhedral cell decomposition. Although the main use case is f...
Definition: foamVtkMeshMaps.H:58