Loading...
Searching...
No Matches
internalMeshWriter Class Reference

Write an OpenFOAM volume (internal) geometry and internal fields as a vtu file or a legacy vtk file. More...

#include <foamVtkInternalMeshWriter.H>

Inheritance diagram for internalMeshWriter:
Collaboration diagram for internalMeshWriter:

Public Member Functions

 internalMeshWriter (const internalMeshWriter &)=delete
 File extension for given output type.
void operator= (const internalMeshWriter &)=delete
 No copy assignment.
 internalMeshWriter (const polyMesh &mesh, const vtk::vtuCells &cells, const vtk::outputOptions opts=vtk::formatType::INLINE_BASE64)
 Construct from components (default format INLINE_BASE64),.
 internalMeshWriter (const polyMesh &mesh, const vtk::vtuCells &cells, const fileName &file, bool parallel=UPstream::parRun())
 Construct from components (default format INLINE_BASE64),.
 internalMeshWriter (const polyMesh &mesh, const vtk::vtuCells &cells, const vtk::outputOptions opts, const fileName &file, bool parallel=UPstream::parRun())
 Construct from components (default format INLINE_BASE64),.
virtual ~internalMeshWriter ()=default
 Destructor.
virtual bool beginFile (std::string title="")
 Write file header (non-collective).
virtual bool writeGeometry ()
 Write mesh topology.
virtual bool beginCellData (label nFields=0)
 Begin CellData output section for specified number of fields.
virtual bool beginPointData (label nFields=0)
 Begin PointData for specified number of fields.
void writeCellIDs ()
 Write cell ids as CellData.
bool writeProcIDs ()
 Write processor ids as CellData. This is no-op in serial.
void writePointIDs ()
 Write point ids as PointData.
template<class Type>
void writeUniform (const word &fieldName, const Type &val)
 Write a uniform field of Cell or Point values.
template<class Type>
void writeCellData (const word &fieldName, const UList< Type > &field)
 Write primitive field of CellData.
template<class Type>
void writePointData (const word &fieldName, const UList< Type > &field)
 Write primitive field of PointData.
word ext () const
 File extension for current format type.
Public Member Functions inherited from fileWriter
 fileWriter (const vtk::fileTag contentType, const vtk::outputOptions opts)
 Construct from components.
virtual ~fileWriter ()
 Destructor.
vtk::fileTag contentType () const noexcept
 The content type.
vtk::outputOptions opts () const noexcept
 The output options in use.
word ext () const
 File extension for current format type.
bool legacy () const noexcept
 Commonly used query.
bool parallel () const noexcept
 Parallel output requested?
const wordstate () const
 The output state in printable format.
const fileNameoutput () const noexcept
 The current output file name.
virtual bool open (const fileName &file, bool parallel=UPstream::parRun())
 Open file for writing (creates parent directory).
void close ()
 End the file contents and close the file after writing.
bool beginFieldData (label nFields=0)
 Begin FieldData output section for specified number of fields.
bool isCellData () const noexcept
 True if output state corresponds to CELL_DATA.
bool isPointData () const noexcept
 True if output state corresponds to POINT_DATA.
label nCellData () const noexcept
 The number of CellData written for the Piece thus far.
label nPointData () const noexcept
 The number of PointData written for the Piece thus far.
bool endFieldData ()
 Explicitly end FieldData output and switch to DECLARED state.
bool endCellData ()
 Explicitly end CellData output and switch to PIECE state.
bool endPointData ()
 Explicitly end PointData output and switch to PIECE state.
void writeTimeValue (scalar timeValue)
 Write "TimeValue" FieldData (name as per Catalyst output).

Static Public Member Functions

static word ext (vtk::outputOptions opts)
 File extension for given output type.

Static Public Attributes

static int debug
 Debug information.

Protected Member Functions

label nTotalPoints () const noexcept
 Total number of field points for the current Piece.
label nTotalCells () const noexcept
 Total number of field cells for the current Piece.
Protected Member Functions inherited from fileWriter
void checkFormatterValidity () const
 Verify that formatter in either allocated or not required.
OstreamreportBadState (Ostream &, outputState expected) const
 Generate message reporting bad writer state.
OstreamreportBadState (Ostream &, outputState, outputState) const
 Generate message reporting bad writer state.
std::ofstream & os () noexcept
 The backend ostream in use.
vtk::formatterformat ()
 The VTK formatter in use. FatalError for off-processor.
bool isState (outputState test) const noexcept
 True if output state corresponds to the test state.
bool notState (outputState test) const noexcept
 True if output state does not correspond to the test state.
template<class Type>
void beginDataArray (const word &fieldName, const label nValues)
 Start of a field or DataArray output (legacy or non-legacy).
void endDataArray ()
 Flush formatter and end of DataArray output (non-legacy).
void beginPoints (const label nPoints)
 Start of a POINTS DataArray.
void endPoints ()
 End of a POINTS DataArray.
bool enter_Piece ()
 Trigger change state to Piece. Resets nCellData_, nPointData_.
bool endPiece ()
 Explicitly end Piece output and switch to DECLARED state.
bool enter_CellData (label nEntries, label nFields)
 Trigger change state to CellData.
bool enter_PointData (label nEntries, label nFields)
 Trigger change state to PointData.
bool exit_File ()
 Emit file footer (end data, end piece, end file).
template<class Type>
void writeUniform (const word &fieldName, const Type &val, const label nValues)
 Write uniform field content.
template<class Type>
void writeBasicField (const word &fieldName, const UList< Type > &field)
 Write basic (primitive) field content.
bool writeProcIDs (const label nValues)
 Write nValues of processor ids as CellData or PointData (no-op in serial).
 fileWriter (const fileWriter &)=delete
 No copy construct.
void operator= (const fileWriter &)=delete
 No copy assignment.

Protected Attributes

const polyMeshmesh_
 Reference to the OpenFOAM mesh (or subset).
const vtk::vtuCellsvtuCells_
 The volume cells (internalMesh).
OffsetRange< label > pointSlab_
 Slab addressing for field points of the current Piece.
OffsetRange< label > cellSlab_
 Slab addressing for field cells of the current Piece.
Protected Attributes inherited from fileWriter
outputState state_
 The output state.
vtk::fileTag contentType_
 The content type (PolyData, UnstructuredGrid ...).
bool parallel_
 Parallel writing (via master).
vtk::outputOptions opts_
 Requested output options.
label nCellData_
 The number of CellData written for the Piece thus far.
label nPointData_
 The number of PointData written for the Piece thus far.
fileName outputFile_
 The output file name.
autoPtr< vtk::formatterformat_
 The VTK formatter in use (only valid on master process).
std::ofstream os_
 The backend ostream in use (only opened on master process).

Additional Inherited Members

Protected Types inherited from fileWriter
enum class  outputState : uint8_t {
  CLOSED = 0 , OPENED , DECLARED , FIELD_DATA ,
  PIECE , CELL_DATA , POINT_DATA
}
 Internal tracking of the output state. More...
Static Protected Attributes inherited from fileWriter
static const Enum< outputStatestateNames
 Names for the output state (for messages, not for file output).

Detailed Description

Write an OpenFOAM volume (internal) geometry and internal fields as a vtu file or a legacy vtk file.

The file output states are managed by the Foam::vtk::fileWriter class. FieldData (eg, TimeValue) must appear before any geometry pieces.

Note
Parallel output is combined into a single Piece without point merging, which is similar to using multi-piece data sets, but allows more convenient creation as a streaming process. In the future, the duplicate points at processor connections may be addressed using ghost points.
See also
Foam::vtk::internalWriter
Source files

Definition at line 65 of file foamVtkInternalMeshWriter.H.

Constructor & Destructor Documentation

◆ internalMeshWriter() [1/4]

internalMeshWriter ( const internalMeshWriter & )
delete

File extension for given output type.

constexpr static vtk::fileTag content = vtk::fileTag::UNSTRUCTURED_GRID;

No copy construct

References internalMeshWriter().

Referenced by internalMeshWriter(), internalWriter::internalWriter(), internalWriter::internalWriter(), internalWriter::internalWriter(), and operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ internalMeshWriter() [2/4]

internalMeshWriter ( const polyMesh & mesh,
const vtk::vtuCells & cells,
const vtk::outputOptions opts = vtk::formatType::INLINE_BASE64 )

Construct from components (default format INLINE_BASE64),.

References cells, Foam::vtk::INLINE_BASE64, mesh, and fileWriter::opts().

Here is the call graph for this function:

◆ internalMeshWriter() [3/4]

internalMeshWriter ( const polyMesh & mesh,
const vtk::vtuCells & cells,
const fileName & file,
bool parallel = UPstream::parRun() )

Construct from components (default format INLINE_BASE64),.

The file name is with/without an extension.

References cells, mesh, fileWriter::parallel(), and UPstream::parRun().

Here is the call graph for this function:

◆ internalMeshWriter() [4/4]

internalMeshWriter ( const polyMesh & mesh,
const vtk::vtuCells & cells,
const vtk::outputOptions opts,
const fileName & file,
bool parallel = UPstream::parRun() )

Construct from components (default format INLINE_BASE64),.

The file name is with/without an extension.

References cells, mesh, fileWriter::opts(), fileWriter::parallel(), and UPstream::parRun().

Here is the call graph for this function:

◆ ~internalMeshWriter()

virtual ~internalMeshWriter ( )
virtualdefault

Destructor.

References fileWriter::ext().

Here is the call graph for this function:

Member Function Documentation

◆ nTotalPoints()

label nTotalPoints ( ) const
inlineprotectednoexcept

Total number of field points for the current Piece.

Definition at line 99 of file foamVtkInternalMeshWriter.H.

References Foam::noexcept, and pointSlab_.

◆ nTotalCells()

label nTotalCells ( ) const
inlineprotectednoexcept

Total number of field cells for the current Piece.

Definition at line 104 of file foamVtkInternalMeshWriter.H.

References cellSlab_, and Foam::noexcept.

◆ operator=()

void operator= ( const internalMeshWriter & )
delete

No copy assignment.

References internalMeshWriter().

Here is the call graph for this function:

◆ ext() [1/2]

word ext ( vtk::outputOptions opts)
inlinestatic

File extension for given output type.

Definition at line 218 of file foamVtkInternalMeshWriter.H.

References fileWriter::opts(), and Foam::vtk::UNSTRUCTURED_GRID.

Here is the call graph for this function:

◆ beginFile()

virtual bool beginFile ( std::string title = "")
virtual

Write file header (non-collective).

Note
Expected calling states: (OPENED)

Reimplemented from fileWriter.

◆ writeGeometry()

virtual bool writeGeometry ( )
virtual

Write mesh topology.

Also writes the file header if not previously written.

Note
Must be called prior to writing CellData or PointData

Implements fileWriter.

◆ beginCellData()

virtual bool beginCellData ( label nFields = 0)
virtual

Begin CellData output section for specified number of fields.

Must be called prior to writing any cell data fields.

Parameters
nFieldsis for legacy format only. When nFields=0, this a no-op for legacy format.
Note
Expected calling states: (PIECE | POINT_DATA).
Returns
True if the state changed

Implements fileWriter.

◆ beginPointData()

virtual bool beginPointData ( label nFields = 0)
virtual

Begin PointData for specified number of fields.

Must be called prior to writing any point data fields.

Parameters
nFieldsis for legacy format only. When nFields=0, this a no-op for legacy format.
Note
Expected calling states: (PIECE | CELL_DATA).
Returns
True if the state changed

Implements fileWriter.

Referenced by isoSurfaceTopo::isoSurfaceTopo().

Here is the caller graph for this function:

◆ writeCellIDs()

void writeCellIDs ( )

Write cell ids as CellData.

Must be called within the CELL_DATA state.

◆ writeProcIDs()

bool writeProcIDs ( )

Write processor ids as CellData. This is no-op in serial.

Must be called within the CELL_DATA state.

◆ writePointIDs()

void writePointIDs ( )

Write point ids as PointData.

Must be called within the POINT_DATA state.

◆ writeUniform()

template<class Type>
void writeUniform ( const word & fieldName,
const Type & val )

Write a uniform field of Cell or Point values.

◆ writeCellData()

template<class Type>
void writeCellData ( const word & fieldName,
const UList< Type > & field )

Write primitive field of CellData.

References field().

Here is the call graph for this function:

◆ writePointData()

template<class Type>
void writePointData ( const word & fieldName,
const UList< Type > & field )

Write primitive field of PointData.

References field().

Here is the call graph for this function:

◆ ext() [2/2]

Foam::word ext ( ) const
inline

File extension for current format type.

Definition at line 318 of file foamVtkFileWriterI.H.

Member Data Documentation

◆ mesh_

const polyMesh& mesh_
protected

Reference to the OpenFOAM mesh (or subset).

Definition at line 76 of file foamVtkInternalMeshWriter.H.

◆ vtuCells_

const vtk::vtuCells& vtuCells_
protected

The volume cells (internalMesh).

Definition at line 81 of file foamVtkInternalMeshWriter.H.

◆ pointSlab_

OffsetRange<label> pointSlab_
protected

Slab addressing for field points of the current Piece.

Definition at line 86 of file foamVtkInternalMeshWriter.H.

Referenced by nTotalPoints().

◆ cellSlab_

OffsetRange<label> cellSlab_
protected

Slab addressing for field cells of the current Piece.

Definition at line 91 of file foamVtkInternalMeshWriter.H.

Referenced by nTotalCells().

◆ debug

int debug
static

Debug information.

Definition at line 141 of file foamVtkInternalMeshWriter.H.


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