Loading...
Searching...
No Matches
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-2025 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::vtuCells
28
29Description
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
40SeeAlso
41 Foam::vtk::vtuSizing
42
43SourceFiles
44 foamVtuCells.cxx
45 foamVtuCells.txx
46 foamVtuCellsI.H
47
48\*---------------------------------------------------------------------------*/
49
50#ifndef Foam_vtk_vtuCells_H
51#define Foam_vtk_vtuCells_H
52
53#include "foamVtkCore.H"
54#include "foamVtkMeshMaps.H"
55#include "foamVtuSizing.H"
56#include "labelList.H"
57#include "pointField.H"
58#include "refPtr.H"
59
60// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61
62namespace Foam
63{
64
65// Forward Declarations
66class polyMesh;
67
68namespace vtk
69{
70
71// Forward Declarations
72class outputOptions;
74/*---------------------------------------------------------------------------*\
75 Class Foam::vtk::vtuCells Declaration
76\*---------------------------------------------------------------------------*/
77
78class vtuCells
79:
80 public vtk::vtuSizing
81{
82 // Private Data
83
84 // Requested output types
85
86 //- Output content type (enum)
88
89 //- Bookkeeping for polyhedral cell decomposition
90 bool decomposeRequest_;
91
92
93 // Storage of output
94
95 //- Cell types (including added cells) in vtk numbering
96 // Range is 1-255
97 List<uint8_t> cellTypes_;
98
99 //- Vertices per cell (including added cells) in vtk ordering
100 List<label> vertLabels_;
101
102 //- Connectivity (vertices) offsets for each cell.
103 //- Can be begin, or end or begin/end (depending on the format)
104 List<label> vertOffset_;
105
106 //- Face lists per polyhedral cell
107 List<label> faceLabels_;
108
109 //- Face label offsets.
110 //- Can be begin, or end or begin/end (depending on the format)
111 List<label> faceOffset_;
112
113 //- Face ids per polyhedral cell (HDF only).
114 // Possibly demand-driven content
115 mutable List<label> polyFaceIds_;
116
117 //- Offsets into the face ids (HDF only)
118 List<label> polyFaceOffset_;
119
120 //- Bookkeeping for polyhedral cell decomposition,
121 //- also used by the manual SUBSET_MESH selection mode.
122 foamVtkMeshMaps maps_;
123
124
125 // Private Member Functions
126
127 //- Resize storage
128 void resize_all();
129
130 //- Create the geometry entries
131 void populateOutput(const polyMesh& mesh);
132
133 //- Create the geometry entries from shapes
134 void populateOutput(const UList<cellShape>& shapes);
135
136public:
137
138 // Generated Methods
139
140 //- No copy construct
141 vtuCells(const vtuCells&) = delete;
142
143 //- No copy assignment
144 void operator=(const vtuCells&) = delete;
145
146
147 // Constructors
148
149 //- Default construct (XML format, no polyhedral decomposition)
150 explicit vtuCells
151 (
152 const enum contentType output = contentType::XML,
153 const bool decompose = false
154 );
155
156 //- Construct from components, create output information immediately
157 explicit vtuCells
158 (
159 const polyMesh& mesh,
160 const enum contentType output = contentType::XML,
161 const bool decompose = false
162 );
163
164 //- Construct from components.
165 // Optionally with polyhedral decomposition.
166 explicit vtuCells
167 (
168 const vtk::outputOptions opts,
169 const bool decompose = false
170 );
172 //- Construct from components, create output information immediately
174 (
175 const polyMesh& mesh,
176 const vtk::outputOptions opts,
177 const bool decompose = false
178 );
180
181 // Member Functions
182
183 // Access
184
185 //- The output content type
186 inline enum contentType content() const noexcept;
187
188 //- Query the polyhedral decompose requested flag.
189 inline bool decomposeRequested() const noexcept;
190
191 //- True if no cellTypes are populated.
192 inline bool empty() const noexcept;
193
194 //- The size of populated cellTypes (the number of cells)
195 inline label size() const noexcept;
196
197 //- The cellMap is non-identity for a SUBSET_MESH or
198 //- when there are decomposed cells.
199 inline bool useCellMap() const noexcept;
201 //- The pointMap is available and non-identity [FUTURE USE]
202 inline bool usePointMap() const noexcept;
203
204 //- Test for hdf content type
205 inline bool is_hdf() const noexcept;
206
207
208 // Edit
210 //- Reset all sizes to zero.
211 void clear();
212
213 //- Create the geometry using the previously requested output and
214 //- decomposition types.
215 void reset(const polyMesh& mesh);
216
217 //- Create the geometry for a mesh subset,
218 //- using previously requested output and decomposition types.
219 void reset
220 (
221 const polyMesh& mesh,
222 const labelUList& subsetCellsIds
223 );
224
225 //- Respecify requested output and decomposition type prior to
226 //- creating the geometry
227 void reset
228 (
229 const polyMesh& mesh,
230 const enum contentType output,
231 const bool decompose
232 );
233
234 //- Reset sizing using primitive shapes only (ADVANCED USAGE)
235 // Effectively removes any polyhedrals!
236 void resetShapes(const UList<cellShape>& shapes);
237
238 //- Renumber cell ids to account for subset meshes
239 void renumberCells(const labelUList& mapping);
240
241 //- Renumber point ids to account for subset meshes
242 void renumberPoints(const labelUList& mapping);
243
244 //- Define which additional cell-centres are to be used (ADVANCED!)
245 void addPointCellLabels(const labelUList& cellIds);
246
247
248 // Storage Access (legacy and non-legacy)
249
250 //- The cell \c "types" (legacy: \c "CELL_TYPES")
251 inline const List<uint8_t>& cellTypes() const noexcept;
252
253 //- The cell \c "connectivity" (legacy: \c "CELLS")
254 inline const labelList& vertLabels() const noexcept;
255
256
257 // Storage Access (non-legacy only)
258
259 //- The \c "offsets" into the connectivity list vertLabels()
260 // The content depends on the format:
261 // - XML : end offset
262 // - INTERNAL1 : begin location
263 // - INTERNAL2 : begin/end offsets
264 // - HDF : begin/end offsets
265 inline const labelList& vertOffsets() const noexcept;
266
267 //- The polyhedral \c "faces" or \c "FaceConnectivity".
268 // The content depends on the format:
269 // - XML / INTERNAL : a face stream with embedded sizing
270 // - HDF : the vertex list of polyhedral faces
271 inline const labelList& faceLabels() const noexcept;
272
273 //- The \c "facesoffset" or the \c "FaceOffsets".
274 // The content depends on the format:
275 // - XML : the per-cell \c end offset into faceLabels(),
276 // - INTERNAL : the per-cell \c begin offset into faceLabels(),
277 // with -1 for primitive types
278 // - HDF : the per-cell begin/end offset into faceLabels(),
279 // with an empty range for primitive types
280 inline const labelList& faceOffsets() const noexcept;
281
282 //- Face ids per polyhedral cell (HDF only)
283 // Possibly demand-driven content
284 const labelList& polyFaceIds() const;
286 //- Offsets into the polyhedral face ids (HDF only)
287 inline const labelList& polyFaceOffsets() const noexcept;
288
289 //- Additional point addressing (from added point to original cell)
290 inline const labelList& addPointCellLabels() const noexcept;
291
292 //- The mesh cell ids for all cells (regular and decomposed).
293 // For a volume field these would be the cell ids to extract
294 // from the field.
295 inline const labelList& cellMap() const noexcept;
296
297 //- The mesh point ids [FUTURE USE]
298 inline const labelUList& pointMap() const noexcept;
299
300
301 // Adjusted versions
303 //- The "connectivity" (legacy: "CELLS")
304 //- adjusted by the specified (global) point offset
305 refPtr<labelList> vertLabels(label pointOffset) const;
306
307 //- Connectivity (vertices) offsets for each cell
308 //- adjusted by the specified (global) cell offset
310 (
313 label beginOffset,
315 bool syncPar = false
316 ) const;
317
318 //- The "faces" stream/connectivity (non-legacy only)
319 //- adjusted by the specified (global) point offset
320 refPtr<labelList> faceLabels(label pointOffset) const;
321
322 //- The offsets into "faces" (non-legacy only)
323 //- adjusted by the specified (global) face offset.
324 // Returns a dummy set of offsets if there are no "faces"
326 (
329 label beginOffset,
331 bool syncPar = false
332 ) const;
333
334 //- The "PolyhedronToFaces" ids (HDF only)
335 //- adjusted by the specified (global) face offset.
336 refPtr<labelList> polyFaceIds(label beginOffset) const;
337
338 //- The "PolyhedronOffsets" (HDF only), which are the
339 //- offsets into the polyhedral face ids,
340 //- adjusted by the specified (global) cell offset.
342 (
345 label beginOffset,
347 bool syncPar = false
348 ) const;
349
350
351 // Mapping/Generation Methods
352
353 //- Return the mesh points,
354 //- possibly with cell centres for addPointCellLabels()
355 // \note not valid for a SHAPE_MESH
356 template<class PointType = Foam::point>
357 tmp<Field<PointType>> points(const polyMesh& mesh) const;
358};
359
360
361// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
362
363} // End namespace vtk
364} // End namespace Foam
365
366// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
368#include "foamVtuCellsI.H"
369
370// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
371
372#ifdef NoRepository
373 #include "foamVtuCells.txx"
374#endif
375
376// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
377
378#endif
379
380// ************************************************************************* //
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
An analytical geometric cellShape.
Definition cellShape.H:71
Bookkeeping for mesh subsetting and/or polyhedral cell decomposition. Although the main use case is f...
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
A class for managing references or pointers (no reference counting).
Definition refPtr.H:54
A class for managing temporary objects.
Definition tmp.H:75
Encapsulated combinations of output format options. This is primarily useful when defining the output...
void resetShapes(const UList< cellShape > &shapes)
Reset sizing using primitive shapes only (ADVANCED USAGE).
const List< uint8_t > & cellTypes() const noexcept
The cell "types" (legacy: "CELL_TYPES").
bool is_hdf() const noexcept
Test for hdf content type.
const labelList & vertOffsets() const noexcept
The "offsets" into the connectivity list vertLabels().
bool empty() const noexcept
True if no cellTypes are populated.
vtuCells(const polyMesh &mesh, const vtk::outputOptions opts, const bool decompose=false)
Construct from components, create output information immediately.
const labelList & faceOffsets() const noexcept
The "facesoffset" or the "FaceOffsets".
const labelList & polyFaceOffsets() const noexcept
Offsets into the polyhedral face ids (HDF only).
void addPointCellLabels(const labelUList &cellIds)
Define which additional cell-centres are to be used (ADVANCED!).
void renumberPoints(const labelUList &mapping)
Renumber point ids to account for subset meshes.
void operator=(const vtuCells &)=delete
No copy assignment.
vtuCells(const polyMesh &mesh, const enum contentType output=contentType::XML, const bool decompose=false)
Construct from components, create output information immediately.
void reset(const polyMesh &mesh)
Create the geometry using the previously requested output and decomposition types.
const labelUList & pointMap() const noexcept
The mesh point ids [FUTURE USE].
label size() const noexcept
The size of populated cellTypes (the number of cells).
void renumberCells(const labelUList &mapping)
Renumber cell ids to account for subset meshes.
bool useCellMap() const noexcept
The cellMap is non-identity for a SUBSET_MESH or when there are decomposed cells.
bool decomposeRequested() const noexcept
Query the polyhedral decompose requested flag.
const labelList & cellMap() const noexcept
The mesh cell ids for all cells (regular and decomposed).
enum contentType content() const noexcept
The output content type.
tmp< Field< PointType > > points(const polyMesh &mesh) const
Return the mesh points, possibly with cell centres for addPointCellLabels().
const labelList & vertLabels() const noexcept
The cell "connectivity" (legacy: "CELLS").
const labelList & polyFaceIds() const
Face ids per polyhedral cell (HDF only).
vtuCells(const vtk::outputOptions opts, const bool decompose=false)
Construct from components.
void clear()
Reset all sizes to zero.
const labelList & faceLabels() const noexcept
The polyhedral "faces" or "FaceConnectivity".
vtuCells(const vtuCells &)=delete
No copy construct.
bool usePointMap() const noexcept
The pointMap is available and non-identity [FUTURE USE].
vtuCells(const enum contentType output=contentType::XML, const bool decompose=false)
Default construct (XML format, no polyhedral decomposition).
Sizing descriptions and routines for transcribing an OpenFOAM volume mesh into a VTK unstructured gri...
bool decompose() const noexcept
Query the decompose flag (normally off).
contentType
Types of content that the storage may represent.
dynamicFvMesh & mesh
Namespace for handling VTK output. Contains classes and functions for writing VTK file content.
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
vector point
Point is a vector.
Definition point.H:37
const direction noexcept
Definition scalarImpl.H:265
UList< label > labelUList
A UList of labels.
Definition UList.H:75