vtuSizing Class Reference

Sizing descriptions and routines for transcribing an OpenFOAM volume mesh into a VTK unstructured grid, with possible decomposition of polyhedral cells into primitive cell types. More...

Inheritance diagram for vtuSizing:
[legend]

Public Types

enum  contentType { LEGACY, XML, INTERNAL1, INTERNAL2 }
 Types of content that the storage may represent. More...
 
enum  slotType { CELLS, CELLS_OFFSETS, FACES, FACES_OFFSETS }
 The possible storage 'slots' that can be used. More...
 

Public Member Functions

 vtuSizing () noexcept
 Default construct. More...
 
 vtuSizing (const polyMesh &mesh)
 Construct sizing by analyzing the mesh. More...
 
 vtuSizing (const polyMesh &mesh, const bool decompose)
 Construct sizing by analyzing the mesh. More...
 
void reset (const polyMesh &mesh, const bool decompose=false)
 Reset sizing by analyzing the mesh. More...
 
void clear () noexcept
 Reset all sizes to zero. More...
 
bool decompose () const
 Query the decompose flag (normally off) More...
 
label nCells () const
 Number of cells for the mesh. More...
 
label nPoints () const
 Number of points for the mesh. More...
 
label nVertLabels () const
 Number of vertex labels for the mesh. More...
 
label nFaceLabels () const
 Number of polyhedral face labels for the mesh. More...
 
label nCellsPoly () const
 Number of polyhedral cells for the mesh. More...
 
label nVertPoly () const
 Number of vertex labels for polyhedral cells of the mesh. More...
 
label nAddCells () const
 Number of additional (decomposed) cells for the mesh. More...
 
label nAddPoints () const
 Number of additional (decomposed) points for the mesh. More...
 
label nAddVerts () const
 Number of additional (decomposed) vertices for the mesh. More...
 
label nFieldCells () const
 Number of field cells = nCells + nAddCells. More...
 
label nFieldPoints () const
 Number of field points = nPoints + nAddPoints. More...
 
label sizeOf (const enum contentType output, const enum slotType slot) const
 Return the required size for the storage slot. More...
 
label sizeLegacy () const
 The calculated size for legacy storage. More...
 
label sizeLegacy (const enum slotType slot) const
 The calculated size for legacy storage of the specified slot. More...
 
label sizeXml (const enum slotType slot) const
 The calculated size for xml storage of the specified slot. More...
 
label sizeInternal1 (const enum slotType slot) const
 The calculated size for vtk-internal storage of the specified slot. More...
 
label sizeInternal2 (const enum slotType slot) const
 The calculated size for vtk-internal storage of the specified slot. More...
 
void populateLegacy (const polyMesh &mesh, UList< uint8_t > &cellTypes, labelUList &connectivity, foamVtkMeshMaps &maps) const
 Populate lists for Legacy output. More...
 
void populateXml (const polyMesh &mesh, UList< uint8_t > &cellTypes, labelUList &connectivity, labelUList &offsets, labelUList &faces, labelUList &facesOffsets, foamVtkMeshMaps &maps) const
 Populate lists for XML output. More...
 
void populateInternal (const polyMesh &mesh, UList< uint8_t > &cellTypes, UList< int > &connectivity, UList< int > &offsets, UList< int > &faces, UList< int > &facesOffsets, foamVtkMeshMaps &maps, const enum contentType output) const
 
void populateInternal (const polyMesh &mesh, UList< uint8_t > &cellTypes, UList< int > &connectivity, UList< int > &offsets, UList< int > &faces, UList< int > &facesOffsets, labelUList &cellMap, labelUList &addPointsIds, const enum contentType output) const
 
void populateInternal (const polyMesh &mesh, UList< uint8_t > &cellTypes, UList< long > &connectivity, UList< long > &offsets, UList< long > &faces, UList< long > &facesOffsets, foamVtkMeshMaps &maps, const enum contentType output) const
 
void populateInternal (const polyMesh &mesh, UList< uint8_t > &cellTypes, UList< long > &connectivity, UList< long > &offsets, UList< long > &faces, UList< long > &facesOffsets, labelUList &cellMap, labelUList &addPointsIds, const enum contentType output) const
 
void populateInternal (const polyMesh &mesh, UList< uint8_t > &cellTypes, UList< long long > &connectivity, UList< long long > &offsets, UList< long long > &faces, UList< long long > &facesOffsets, foamVtkMeshMaps &maps, const enum contentType output) const
 
void populateInternal (const polyMesh &mesh, UList< uint8_t > &cellTypes, UList< long long > &connectivity, UList< long long > &offsets, UList< long long > &faces, UList< long long > &facesOffsets, labelUList &cellMap, labelUList &addPointsIds, const enum contentType output) const
 
void info (Ostream &os) const
 Report some information. More...
 
bool operator== (const vtuSizing &rhs) const
 Test equality. More...
 
bool operator!= (const vtuSizing &rhs) const
 Test inequality. More...
 

Static Public Member Functions

static labelList copyVertLabelsLegacy (const labelUList &connectivity, const label globalPointOffset)
 Copy vertex labels with a global point offset - legacy format. More...
 
static labelList copyVertLabelsXml (const labelUList &connectivity, const label globalPointOffset)
 Copy vertex labels with a global point offset - XML format. More...
 
static labelList copyFaceLabelsXml (const labelUList &faceLabels, const label globalPointOffset)
 Copy faces stream labels with a global point offset - XML format. More...
 
static labelList copyFaceOffsetsXml (const labelUList &faceOffsets, const label prevOffset)
 Copy face offsets with an offset from previous - XML format. More...
 
static void renumberVertLabelsLegacy (labelUList &connectivity, const label globalPointOffset)
 Renumber vertex labels by global point offset - legacy format. More...
 
static void renumberVertLabelsXml (labelUList &connectivity, const label globalPointOffset)
 Renumber vertex labels by global point offset - XML format. More...
 
static void renumberFaceLabelsXml (labelUList &faceLabels, const label globalPointOffset)
 Renumber faces stream labels by global point offset - XML format. More...
 
static void renumberFaceOffsetsXml (labelUList &faceOffsets, const label prevOffset)
 Renumber face offsets with an offset from previous - XML format. More...
 

Detailed Description

Sizing descriptions and routines for transcribing an OpenFOAM volume mesh into a VTK unstructured grid, with possible decomposition of polyhedral cells into primitive cell types.

This class is intended to populate externally allocated arrays with content that is compatible with what VTK expects. This approach allows an improved separation of the OpenFOAM mesh description and the storage, and allows support of alternative storage containers (eg, std::vector, vtkDataArray). The ideal goal would be a zero-copy mechanism, but this does not work for several reasons:

  • OpenFOAM and VTK have different point ordering for prism
  • polyhedral decomposition
  • face-stream are required for VTK
  • VTK internal storage includes list size as part of the data
  • VTK includes storage may be a different base size (eg, long long) compared to the OpenFOAM label.
Data Entries (slots)

These are the storage entries normally associate with each output-type:

legacy output
types vtk cell type (1-255)
cells nLabels and unique vertex labels used by the cell, or
[nLabels nFaces, nFace0Pts, id1, id2, ..., nFace1Pts, id1, id2, ...]
xml output
types vtk cell type (1-255)
connectivity unique vertex labels used by the cell
offsets end offset for each of connectivity
faces face stream for polyhedral cells
[nFaces, nFace0Pts, id1, id2, ..., nFace1Pts, id1, id2, ...]
faceoffsets end offset for each of faces, with -1 for primitive cells
internal1 storage (VTK-8 and earlier)
types vtk cell type (1-255)
connectivity nLabels and unique vertex labels used by the cell
location begin location for each of connectivity
faces face stream for polyhedral cells
[nFaces, nFace0Pts, id1, id2, ..., nFace1Pts, id1, id2, ...]
facelocation begin location for each of faces, with -1 for primitive cells
internal2 storage (with VTK_CELL_ARRAY_V2)
types vtk cell type (1-255)
connectivity unique vertex labels used by the cell
offsets begin/end offsets for connectivity
faces face stream for polyhedral cells
[nFaces, nFace0Pts, id1, id2, ..., nFace1Pts, id1, id2, ...]
facelocation begin location for each of faces, with -1 for primitive cells

The VTK storage concept for "connectivity" and "faces" somewhat resemble a CompactListList.

Note
It is possible to specify a global point offset (via the globalIndex) so that the cell point labels will use global numbering. There is no support for point renumbering with merged mesh points, since it likely more efficient to use VTK point-blanking to mark duplicate points instead of merging points ourselves.
The VTK_CELL_ARRAY_V2 define (from vtkCellArray.h) indicates if the new (internal2) new format is being used.
Source files

Definition at line 200 of file foamVtuSizing.H.

Member Enumeration Documentation

◆ contentType

Types of content that the storage may represent.

Enumerator
LEGACY 

Legacy VTK content.

XML 

XML (VTU) content.

INTERNAL1 

Internal vtkUnstructuredGrid content.

INTERNAL2 

Internal vtkUnstructuredGrid content, VTK_CELL_ARRAY_V2.

Definition at line 207 of file foamVtuSizing.H.

◆ slotType

enum slotType

The possible storage 'slots' that can be used.

Enumerator
CELLS 

Cell connectivity (ALL)

CELLS_OFFSETS 

Cell end-offsets (XML), locations (INTERNAL1) or begin/end offsets (INTERNAL2)

FACES 

Face-stream (XML, INTERNAL)

FACES_OFFSETS 

Faces end-offsets (XML) or locations (INTERNAL1)

Definition at line 216 of file foamVtuSizing.H.

Constructor & Destructor Documentation

◆ vtuSizing() [1/3]

vtuSizing ( )
noexcept

Default construct.

Definition at line 47 of file foamVtuSizing.C.

References clear().

Here is the call graph for this function:

◆ vtuSizing() [2/3]

vtuSizing ( const polyMesh mesh)
explicit

Construct sizing by analyzing the mesh.

No polyhedral decomposition.

◆ vtuSizing() [3/3]

vtuSizing ( const polyMesh mesh,
const bool  decompose 
)

Construct sizing by analyzing the mesh.

Optionally with polyhedral decomposition.

Definition at line 54 of file foamVtuSizing.C.

References clear(), and mesh.

Here is the call graph for this function:

Member Function Documentation

◆ reset()

void reset ( const polyMesh mesh,
const bool  decompose = false 
)

Reset sizing by analyzing the mesh.

Optionally with polyhedral decomposition.

Definition at line 84 of file foamVtuSizing.C.

References HashTable< T, Key, Hash >::clear(), f(), cellModel::HEX, Foam::hex(), HashSet< Key, Hash >::insert(), mesh, cellShape::model(), cellModel::PRISM, cellModel::PYR, cellModel::ref(), HashTable< T, Key, Hash >::size(), cellModel::TET, cellModel::TETWEDGE, and cellModel::WEDGE.

Here is the call graph for this function:

◆ clear()

void clear ( )
noexcept

Reset all sizes to zero.

Definition at line 66 of file foamVtuSizing.C.

◆ decompose()

bool decompose ( ) const
inline

Query the decompose flag (normally off)

Definition at line 32 of file foamVtuSizingI.H.

Referenced by vtuSizing::operator==().

Here is the caller graph for this function:

◆ nCells()

Foam::label nCells ( ) const
inline

Number of cells for the mesh.

Definition at line 38 of file foamVtuSizingI.H.

Referenced by vtuSizing::operator==().

Here is the caller graph for this function:

◆ nPoints()

Foam::label nPoints ( ) const
inline

Number of points for the mesh.

Definition at line 44 of file foamVtuSizingI.H.

Referenced by vtuSizing::operator==().

Here is the caller graph for this function:

◆ nVertLabels()

Foam::label nVertLabels ( ) const
inline

Number of vertex labels for the mesh.

Definition at line 50 of file foamVtuSizingI.H.

Referenced by vtuSizing::operator==().

Here is the caller graph for this function:

◆ nFaceLabels()

Foam::label nFaceLabels ( ) const
inline

Number of polyhedral face labels for the mesh.

Definition at line 56 of file foamVtuSizingI.H.

Referenced by vtuSizing::operator==().

Here is the caller graph for this function:

◆ nCellsPoly()

Foam::label nCellsPoly ( ) const
inline

Number of polyhedral cells for the mesh.

Definition at line 62 of file foamVtuSizingI.H.

Referenced by vtuSizing::operator==().

Here is the caller graph for this function:

◆ nVertPoly()

Foam::label nVertPoly ( ) const
inline

Number of vertex labels for polyhedral cells of the mesh.

Definition at line 68 of file foamVtuSizingI.H.

Referenced by vtuSizing::operator==().

Here is the caller graph for this function:

◆ nAddCells()

Foam::label nAddCells ( ) const
inline

Number of additional (decomposed) cells for the mesh.

Definition at line 74 of file foamVtuSizingI.H.

Referenced by vtuSizing::operator==().

Here is the caller graph for this function:

◆ nAddPoints()

Foam::label nAddPoints ( ) const
inline

Number of additional (decomposed) points for the mesh.

Definition at line 80 of file foamVtuSizingI.H.

Referenced by vtuSizing::operator==().

Here is the caller graph for this function:

◆ nAddVerts()

Foam::label nAddVerts ( ) const
inline

Number of additional (decomposed) vertices for the mesh.

Definition at line 86 of file foamVtuSizingI.H.

Referenced by vtuSizing::operator==().

Here is the caller graph for this function:

◆ nFieldCells()

Foam::label nFieldCells ( ) const
inline

Number of field cells = nCells + nAddCells.

Definition at line 92 of file foamVtuSizingI.H.

Referenced by vtuAdaptor::internal().

Here is the caller graph for this function:

◆ nFieldPoints()

Foam::label nFieldPoints ( ) const
inline

Number of field points = nPoints + nAddPoints.

Definition at line 98 of file foamVtuSizingI.H.

◆ sizeOf()

Foam::label sizeOf ( const enum contentType  output,
const enum slotType  slot 
) const

Return the required size for the storage slot.

Definition at line 207 of file foamVtuSizing.C.

References Foam::vtk::CELLS, and Foam::vtk::FACES.

Referenced by vtuAdaptor::internal().

Here is the caller graph for this function:

◆ sizeLegacy() [1/2]

Foam::label sizeLegacy ( ) const
inline

The calculated size for legacy storage.

Definition at line 104 of file foamVtuSizingI.H.

References Foam::vtk::CELLS.

◆ sizeLegacy() [2/2]

Foam::label sizeLegacy ( const enum slotType  slot) const
inline

The calculated size for legacy storage of the specified slot.

Definition at line 111 of file foamVtuSizingI.H.

◆ sizeXml()

Foam::label sizeXml ( const enum slotType  slot) const
inline

The calculated size for xml storage of the specified slot.

Definition at line 120 of file foamVtuSizingI.H.

◆ sizeInternal1()

Foam::label sizeInternal1 ( const enum slotType  slot) const
inline

The calculated size for vtk-internal storage of the specified slot.

Definition at line 129 of file foamVtuSizingI.H.

◆ sizeInternal2()

Foam::label sizeInternal2 ( const enum slotType  slot) const
inline

The calculated size for vtk-internal storage of the specified slot.

Definition at line 138 of file foamVtuSizingI.H.

◆ populateLegacy()

void populateLegacy ( const polyMesh mesh,
UList< uint8_t > &  cellTypes,
labelUList connectivity,
foamVtkMeshMaps maps 
) const

Populate lists for Legacy output.

Definition at line 314 of file foamVtuSizing.C.

References foamVtkMeshMaps::additionalIds(), foamVtkMeshMaps::cellMap(), cellTypes, and mesh.

Here is the call graph for this function:

◆ populateXml()

void populateXml ( const polyMesh mesh,
UList< uint8_t > &  cellTypes,
labelUList connectivity,
labelUList offsets,
labelUList faces,
labelUList facesOffsets,
foamVtkMeshMaps maps 
) const

Populate lists for XML output.

Definition at line 343 of file foamVtuSizing.C.

References foamVtkMeshMaps::additionalIds(), foamVtkMeshMaps::cellMap(), cellTypes, and mesh.

Here is the call graph for this function:

◆ populateInternal() [1/6]

void populateInternal ( const polyMesh mesh,
UList< uint8_t > &  cellTypes,
UList< int > &  connectivity,
UList< int > &  offsets,
UList< int > &  faces,
UList< int > &  facesOffsets,
foamVtkMeshMaps maps,
const enum contentType  output 
) const

Populate lists for Internal VTK format

Definition at line 432 of file foamVtuSizing.C.

Referenced by vtuAdaptor::internal().

Here is the caller graph for this function:

◆ populateInternal() [2/6]

void populateInternal ( const polyMesh mesh,
UList< uint8_t > &  cellTypes,
UList< int > &  connectivity,
UList< int > &  offsets,
UList< int > &  faces,
UList< int > &  facesOffsets,
labelUList cellMap,
labelUList addPointsIds,
const enum contentType  output 
) const

Populate lists for Internal VTK format

Definition at line 432 of file foamVtuSizing.C.

◆ populateInternal() [3/6]

void populateInternal ( const polyMesh mesh,
UList< uint8_t > &  cellTypes,
UList< long > &  connectivity,
UList< long > &  offsets,
UList< long > &  faces,
UList< long > &  facesOffsets,
foamVtkMeshMaps maps,
const enum contentType  output 
) const

Populate lists for Internal VTK format

Definition at line 433 of file foamVtuSizing.C.

◆ populateInternal() [4/6]

void populateInternal ( const polyMesh mesh,
UList< uint8_t > &  cellTypes,
UList< long > &  connectivity,
UList< long > &  offsets,
UList< long > &  faces,
UList< long > &  facesOffsets,
labelUList cellMap,
labelUList addPointsIds,
const enum contentType  output 
) const

Populate lists for Internal VTK format

Definition at line 433 of file foamVtuSizing.C.

◆ populateInternal() [5/6]

void populateInternal ( const polyMesh mesh,
UList< uint8_t > &  cellTypes,
UList< long long > &  connectivity,
UList< long long > &  offsets,
UList< long long > &  faces,
UList< long long > &  facesOffsets,
foamVtkMeshMaps maps,
const enum contentType  output 
) const

Populate lists for Internal VTK format

Definition at line 434 of file foamVtuSizing.C.

◆ populateInternal() [6/6]

void populateInternal ( const polyMesh mesh,
UList< uint8_t > &  cellTypes,
UList< long long > &  connectivity,
UList< long long > &  offsets,
UList< long long > &  faces,
UList< long long > &  facesOffsets,
labelUList cellMap,
labelUList addPointsIds,
const enum contentType  output 
) const

Populate lists for Internal VTK format

Definition at line 434 of file foamVtuSizing.C.

◆ copyVertLabelsLegacy()

Foam::labelList copyVertLabelsLegacy ( const labelUList connectivity,
const label  globalPointOffset 
)
static

Copy vertex labels with a global point offset - legacy format.

Definition at line 443 of file foamVtuSizing.C.

◆ copyVertLabelsXml()

Foam::labelList copyVertLabelsXml ( const labelUList connectivity,
const label  globalPointOffset 
)
static

Copy vertex labels with a global point offset - XML format.

Definition at line 526 of file foamVtuSizing.C.

◆ copyFaceLabelsXml()

Foam::labelList copyFaceLabelsXml ( const labelUList faceLabels,
const label  globalPointOffset 
)
static

Copy faces stream labels with a global point offset - XML format.

Definition at line 565 of file foamVtuSizing.C.

◆ copyFaceOffsetsXml()

Foam::labelList copyFaceOffsetsXml ( const labelUList faceOffsets,
const label  prevOffset 
)
static

Copy face offsets with an offset from previous - XML format.

Definition at line 620 of file foamVtuSizing.C.

◆ renumberVertLabelsLegacy()

void renumberVertLabelsLegacy ( labelUList connectivity,
const label  globalPointOffset 
)
static

Renumber vertex labels by global point offset - legacy format.

Definition at line 461 of file foamVtuSizing.C.

References UList< T >::begin(), and UList< T >::end().

Here is the call graph for this function:

◆ renumberVertLabelsXml()

void renumberVertLabelsXml ( labelUList connectivity,
const label  globalPointOffset 
)
static

Renumber vertex labels by global point offset - XML format.

Definition at line 544 of file foamVtuSizing.C.

◆ renumberFaceLabelsXml()

void renumberFaceLabelsXml ( labelUList faceLabels,
const label  globalPointOffset 
)
static

Renumber faces stream labels by global point offset - XML format.

Definition at line 583 of file foamVtuSizing.C.

References UList< T >::begin(), and UList< T >::end().

Here is the call graph for this function:

◆ renumberFaceOffsetsXml()

void renumberFaceOffsetsXml ( labelUList faceOffsets,
const label  prevOffset 
)
static

Renumber face offsets with an offset from previous - XML format.

Definition at line 638 of file foamVtuSizing.C.

◆ info()

void info ( Ostream os) const

Report some information.

Definition at line 663 of file foamVtuSizing.C.

◆ operator==()

bool operator== ( const vtuSizing rhs) const

Test equality.

Definition at line 698 of file foamVtuSizing.C.

References vtuSizing::decompose(), vtuSizing::nAddCells(), vtuSizing::nAddPoints(), vtuSizing::nAddVerts(), vtuSizing::nCells(), vtuSizing::nCellsPoly(), vtuSizing::nFaceLabels(), nPoints, vtuSizing::nPoints(), vtuSizing::nVertLabels(), and vtuSizing::nVertPoly().

Here is the call graph for this function:

◆ operator!=()

bool operator!= ( const vtuSizing rhs) const

Test inequality.

Definition at line 717 of file foamVtuSizing.C.

References Foam::operator==().

Here is the call graph for this function:

The documentation for this class was generated from the following files: