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) 2011-2019 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 "DynamicList.H"
56 #include "labelList.H"
57 
58 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59 
60 namespace Foam
61 {
62 
63 // Forward declarations
64 class polyMesh;
65 
66 namespace vtk
67 {
68 // Forward declarations
69 class outputOptions;
70 
71 /*---------------------------------------------------------------------------*\
72  Class Foam::vtk::vtuCells Declaration
73 \*---------------------------------------------------------------------------*/
74 
75 class vtuCells
76 :
77  public vtuSizing
78 {
79  // Private Member Data
80 
81  // Requested output types
82 
83  //- Output content type
84  contentType output_;
85 
86  //- Bookkeeping for polyhedral cell decomposition
87  bool decomposeRequest_;
88 
89 
90  // Storage of output
91 
92  //- Cell types (including added cells) in vtk numbering
93  // Range is 1-255
94  List<uint8_t> cellTypes_;
95 
96  //- Vertices per cell (including added cells) in vtk ordering
97  List<label> vertLabels_;
98 
99  //- Connectivity (vertices) offset for the end of each cell
100  List<label> vertOffset_;
101 
102  //- Face lists per polyhedral cell
103  List<label> faceLabels_;
104 
105  //- Face label offsets
106  List<label> faceOffset_;
107 
108  //- Bookkeeping for polyhedral cell decomposition
109  foamVtkMeshMaps maps_;
110 
111 
112  // Private Member Functions
113 
114  //- Create the geometry using the previously requested output and
115  // decomposition types.
116  void repopulate(const polyMesh& mesh);
117 
118  //- No copy construct
119  vtuCells(const vtuCells&) = delete;
120 
121  //- No copy assignment
122  void operator=(const vtuCells&) = delete;
123 
124 
125 public:
126 
127  // Constructors
128 
129  //- Construct from components.
130  // Optionally with polyhedral decomposition.
131  vtuCells
132  (
133  const enum contentType output = contentType::XML,
134  const bool decompose = false
135  );
136 
137  //- Construct from components and create the output information
138  //- immediately
139  vtuCells
140  (
141  const polyMesh& mesh,
142  const enum contentType output = contentType::XML,
143  const bool decompose = false
144  );
145 
146  //- Construct from components.
147  // Optionally with polyhedral decomposition.
148  vtuCells
149  (
150  const vtk::outputOptions opts,
151  const bool decompose = false
152  );
153 
154  //- Construct from components, and create the output information
155  //- immediately
156  vtuCells
157  (
158  const polyMesh& mesh,
159  const vtk::outputOptions opts,
160  const bool decompose = false
161  );
162 
163 
164  //- Destructor
165  ~vtuCells() = default;
166 
167 
168  // Member Functions
169 
170  // Access
171 
172  //- The output content type
173  inline enum contentType content() const;
174 
175  //- Query the polyhedral decompose requested flag.
176  inline bool decomposeRequested() const;
177 
178  //- True if no cellTypes are populated.
179  inline bool empty() const noexcept;
180 
181  //- The size of populated cellTypes.
182  inline label size() const noexcept;
183 
184 
185  // Edit
186 
187  //- Reset all sizes to zero.
188  void clear();
189 
190  //- Create the geometry using the previously requested output and
191  //- decomposition types.
192  void reset(const polyMesh& mesh);
193 
194  //- Respecify requested output and decomposition type prior to
195  //- creating the geometry
196  void reset
197  (
198  const polyMesh& mesh,
199  const enum contentType output,
200  const bool decompose
201  );
202 
203  //- Renumber cell ids to account for subset meshes
204  void renumberCells(const labelUList& mapping);
205 
206  //- Renumber point ids to account for subset meshes
207  void renumberPoints(const labelUList& mapping);
208 
209 
210  // Storage Access
211 
212  //- Values for "types" (XML) and "CELL_TYPES" (legacy)
213  inline const List<uint8_t>& cellTypes() const;
214 
215  //- Values for "connectivity" (XML) or "CELLS" (legacy)
216  inline const labelList& vertLabels() const;
217 
218  //- Values for "offsets" (XML only)
219  inline const labelList& vertOffsets() const;
220 
221  //- Values for "faces" (XML only)
222  inline const labelList& faceLabels() const;
223 
224  //- Values for "faceoffset" (XML only)
225  inline const labelList& faceOffsets() const;
226 
227  //- Additional point addressing (from added point to original cell)
228  inline const labelList& addPointCellLabels() const;
229 
230  //- Original cell ids for all cells (regular and decomposed).
231  inline const labelList& cellMap() const;
232 
233 };
234 
235 
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 
238 } // End namespace vtk
239 } // End namespace Foam
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
243 #include "foamVtuCellsI.H"
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 #endif
248 
249 // ************************************************************************* //
Foam::vtk::outputOptions
Encapsulated combinations of output format options. This is primarily useful when defining the output...
Definition: foamVtkOutputOptions.H:59
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:34
Foam::vtk::vtuCells::reset
void reset(const polyMesh &mesh)
Definition: foamVtuCells.C:156
Foam::vtk::vtuCells::cellTypes
const List< uint8_t > & cellTypes() const
Values for "types" (XML) and "CELL_TYPES" (legacy)
Definition: foamVtuCellsI.H:59
Foam::vtk::vtuCells::cellMap
const labelList & cellMap() const
Original cell ids for all cells (regular and decomposed).
Definition: foamVtuCellsI.H:101
Foam::vtk::vtuCells::~vtuCells
~vtuCells()=default
Destructor.
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
foamVtuSizing.H
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
foamVtuCellsI.H
labelList.H
Foam::vtk::vtuCells::vertOffsets
const labelList & vertOffsets() const
Values for "offsets" (XML only)
Definition: foamVtuCellsI.H:73
Foam::vtk::vtuCells::addPointCellLabels
const labelList & addPointCellLabels() const
Additional point addressing (from added point to original cell)
Definition: foamVtuCellsI.H:94
Foam::vtk::vtuCells::vertLabels
const labelList & vertLabels() const
Values for "connectivity" (XML) or "CELLS" (legacy)
Definition: foamVtuCellsI.H:66
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::vtk::vtuSizing::contentType
contentType
Types of content that the storage may represent.
Definition: foamVtuSizing.H:173
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:166
Foam::vtk::vtuCells::renumberCells
void renumberCells(const labelUList &mapping)
Renumber cell ids to account for subset meshes.
Definition: foamVtuCells.C:177
Foam::vtk::vtuCells::faceLabels
const labelList & faceLabels() const
Values for "faces" (XML only)
Definition: foamVtuCellsI.H:80
Foam::vtk::vtuCells::size
label size() const noexcept
The size of populated cellTypes.
Definition: foamVtuCellsI.H:52
Foam::vtk::vtuCells::faceOffsets
const labelList & faceOffsets() const
Values for "faceoffset" (XML only)
Definition: foamVtuCellsI.H:87
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:183
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:74
Foam::vtk::vtuCells::decomposeRequested
bool decomposeRequested() const
Query the polyhedral decompose requested flag.
Definition: foamVtuCellsI.H:40
DynamicList.H
Foam::vtk::vtuCells::empty
bool empty() const noexcept
True if no cellTypes are populated.
Definition: foamVtuCellsI.H:46
foamVtkMeshMaps.H
Foam::foamVtkMeshMaps
Bookkeeping for mesh subsetting and/or polyhedral cell decomposition. Although the main use case is f...
Definition: foamVtkMeshMaps.H:57