internalWriter Class Reference

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

Inheritance diagram for internalWriter:
[legend]
Collaboration diagram for internalWriter:
[legend]

Public Member Functions

 internalWriter (const fvMesh &mesh, const vtk::vtuCells &cells, const vtk::outputOptions opts=vtk::formatType::INLINE_BASE64)
 File extension for given output type. More...
 
 internalWriter (const fvMesh &mesh, const vtk::vtuCells &cells, const fileName &file, bool parallel=Pstream::parRun())
 Construct from components (default format INLINE_BASE64),. More...
 
 internalWriter (const fvMesh &mesh, const vtk::vtuCells &cells, const vtk::outputOptions opts, const fileName &file, bool parallel=Pstream::parRun())
 Construct from components (default format INLINE_BASE64),. More...
 
virtual ~internalWriter ()=default
 Destructor. More...
 
virtual bool beginFile (std::string title="")
 Write file header (non-collective) More...
 
virtual bool writeGeometry ()
 Write mesh topology. More...
 
virtual bool beginCellData (label nFields=0)
 Begin CellData output section for specified number of fields. More...
 
virtual bool beginPointData (label nFields=0)
 Begin PointData for specified number of fields. More...
 
void writeCellIDs ()
 Write cell ids as CellData. More...
 
bool writeProcIDs ()
 Write processor ids as CellData. This is no-op in serial. More...
 
void writePointIDs ()
 Write point ids as PointData. More...
 
template<class Type >
void writeUniform (const word &fieldName, const Type &val)
 Write a uniform field of Cell or Point values. More...
 
template<class Type , template< class > class PatchField>
void write (const GeometricField< Type, PatchField, pointMesh > &field)
 Write point field. More...
 
template<class Type >
void write (const DimensionedField< Type, volMesh > &field)
 Write the internal field. More...
 
template<class Type , template< class > class PatchField>
void write (const GeometricField< Type, PatchField, volMesh > &field)
 Write the volume field (internal part) More...
 
template<class Type >
void write (const DimensionedField< Type, volMesh > &vfield, const volPointInterpolation &pInterp)
 Write internal field with point interpolation. More...
 
template<class Type >
void write (const GeometricField< Type, fvPatchField, volMesh > &vfield, const volPointInterpolation &pInterp)
 Write volume field with point interpolation. More...
 
- Public Member Functions inherited from fileWriter
 fileWriter (const vtk::fileTag contentType, const vtk::outputOptions opts)
 Construct from components. More...
 
virtual ~fileWriter ()
 Destructor. More...
 
vtk::fileTag contentType () const
 The content type. More...
 
vtk::outputOptions opts () const
 The output options in use. More...
 
word ext () const
 File extension for current format type. More...
 
bool legacy () const
 Commonly used query. More...
 
bool parallel () const
 Parallel output requested? More...
 
const wordstate () const
 The output state in printable format. More...
 
const fileNameoutput () const
 The current output file name. More...
 
bool open (const fileName &file, bool parallel=Pstream::parRun())
 Open file for writing (creates parent directory). More...
 
void close ()
 End the file contents and close the file after writing. More...
 
bool beginFieldData (label nFields=0)
 Begin FieldData output section for specified number of fields. More...
 
label nCellData () const
 Return the number of CellData written for the Piece thus far. More...
 
label nPointData () const
 Return the number of PointData written for the Piece thus far. More...
 
bool endFieldData ()
 Explicitly end FieldData output and switch to DECLARED state. More...
 
bool endCellData ()
 Explicitly end CellData output and switch to PIECE state. More...
 
bool endPointData ()
 Explicitly end PointData output and switch to PIECE state. More...
 
void writeTimeValue (scalar timeValue)
 Write "TimeValue" FieldData (name as per Catalyst output) More...
 

Static Public Member Functions

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

Static Public Attributes

static int debug = 0
 Debug information. More...
 

Additional Inherited Members

- Protected Types inherited from fileWriter
enum  outputState {
  CLOSED = 0, OPENED, DECLARED, FIELD_DATA,
  PIECE, CELL_DATA, POINT_DATA
}
 Internal tracking of the output state. More...
 
- Protected Member Functions inherited from fileWriter
std::ofstream & os ()
 The backend ostream in use. More...
 
vtk::formatterformat ()
 The VTK formatter in use. More...
 
bool isState (outputState test) const
 True if the output state corresponds to the test state. More...
 
bool notState (outputState test) const
 True if the output state does not correspond to the test state. More...
 
template<class Type >
void writeUniform (const word &fieldName, const Type &val, const label nValues)
 Write uniform field content. More...
 
bool enter_Piece ()
 Trigger change state to Piece. Resets nCellData_, nPointData_. More...
 
bool endPiece ()
 Explicitly end Piece output and switch to DECLARED state. More...
 
bool enter_CellData (label nEntries, label nFields)
 Trigger change state to CellData. More...
 
bool enter_PointData (label nEntries, label nFields)
 Trigger change state to PointData. More...
 
bool exit_File ()
 Emit file footer (end data, end piece, end file) More...
 
 fileWriter (const fileWriter &)=delete
 No copy construct. More...
 
void operator= (const fileWriter &)=delete
 No copy assignment. More...
 
- Protected Attributes inherited from fileWriter
vtk::fileTag contentType_
 The content type. More...
 
outputOptions opts_
 The requested output options. More...
 
bool parallel_
 Writing in parallel (via master) More...
 
outputState state_
 The output state. More...
 
label nCellData_
 The number of CellData written for the Piece thus far. More...
 
label nPointData_
 The number of PointData written for the Piece thus far. More...
 
fileName outputFile_
 The output file name. More...
 
autoPtr< vtk::formatterformat_
 The VTK formatter in use (master process) More...
 
std::ofstream os_
 The backend ostream in use (master process) More...
 
- Static Protected Attributes inherited from fileWriter
static const Enum< outputStatestateNames
 Names for the output state (for messages, not for file output). More...
 

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.
Source files

Definition at line 71 of file foamVtkInternalWriter.H.

Constructor & Destructor Documentation

◆ internalWriter() [1/3]

internalWriter ( const fvMesh mesh,
const vtk::vtuCells cells,
const vtk::outputOptions  opts = vtk::formatType::INLINE_BASE64 
)

File extension for given output type.

constexpr static vtk::fileTag content = vtk::fileTag::UNSTRUCTURED_GRID; Construct from components (default format INLINE_BASE64),

Definition at line 480 of file foamVtkInternalWriter.C.

◆ internalWriter() [2/3]

internalWriter ( const fvMesh mesh,
const vtk::vtuCells cells,
const fileName file,
bool  parallel = Pstream::parRun() 
)

Construct from components (default format INLINE_BASE64),.

The file name is with/without an extension.

Definition at line 498 of file foamVtkInternalWriter.C.

◆ internalWriter() [3/3]

internalWriter ( const fvMesh mesh,
const vtk::vtuCells cells,
const vtk::outputOptions  opts,
const fileName file,
bool  parallel = Pstream::parRun() 
)

Construct from components (default format INLINE_BASE64),.

The file name is with/without an extension.

Definition at line 512 of file foamVtkInternalWriter.C.

◆ ~internalWriter()

virtual ~internalWriter ( )
virtualdefault

Destructor.

Member Function Documentation

◆ ext()

static word ext ( vtk::outputOptions  opts)
inlinestatic

File extension for given output type.

Definition at line 169 of file foamVtkInternalWriter.H.

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

Here is the call graph for this function:

◆ beginFile()

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

Write file header (non-collective)

Note
Expected calling states: (OPENED)

Reimplemented from fileWriter.

Definition at line 528 of file foamVtkInternalWriter.C.

References fileWriter::beginFile(), DebugInFunction, Foam::endl(), and Foam::name().

Here is the call graph for this function:

◆ writeGeometry()

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.

Definition at line 566 of file foamVtkInternalWriter.C.

References Foam::vtk::CELLS, and format().

Here is the call graph for this function:

◆ beginCellData()

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.

Definition at line 603 of file foamVtkInternalWriter.C.

◆ beginPointData()

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.

Definition at line 609 of file foamVtkInternalWriter.C.

◆ writeCellIDs()

void writeCellIDs ( )

Write cell ids as CellData.

Must be called within the CELL_DATA state.

Definition at line 615 of file foamVtkInternalWriter.C.

References Foam::vtk::CELL_DATA, Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, format(), Foam::nl, Foam::vtk::writeList(), and Foam::vtk::writeListParallel().

Here is the call graph for this function:

◆ writeProcIDs()

bool writeProcIDs ( )

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

Must be called within the CELL_DATA state.

Definition at line 668 of file foamVtkInternalWriter.C.

References Foam::vtk::CELL_DATA, Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, format(), UPstream::master(), Foam::nl, UPstream::nProcs(), Foam::returnReduce(), globalIndex::size(), and Foam::vtk::write().

Here is the call graph for this function:

◆ writePointIDs()

void writePointIDs ( )

Write point ids as PointData.

Must be called within the POINT_DATA state.

Definition at line 730 of file foamVtkInternalWriter.C.

References Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, format(), Foam::identity(), Foam::nl, Foam::vtk::POINT_DATA, Foam::vtk::writeList(), and Foam::vtk::writeListParallel().

Here is the call graph for this function:

◆ writeUniform()

void writeUniform ( const word fieldName,
const Type &  val 
)

Write a uniform field of Cell or Point values.

Definition at line 37 of file foamVtkInternalWriterTemplates.C.

References Foam::endl(), Foam::exit(), Foam::FatalError, Foam::nl, Foam::expressions::patchExpr::POINT_DATA, Foam::val, and WarningInFunction.

Here is the call graph for this function:

◆ write() [1/5]

void write ( const GeometricField< Type, PatchField, pointMesh > &  field)

Write point field.

Interpolate to originating cell centre for decomposed cells.

Definition at line 64 of file foamVtkInternalWriterTemplates.C.

References cellId, Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, field(), format(), Foam::interpolatePointToCell(), Foam::nl, Foam::expressions::patchExpr::POINT_DATA, Foam::val, Foam::vtk::write(), Foam::vtk::writeList(), and Foam::vtk::writeListsParallel().

Here is the call graph for this function:

◆ write() [2/5]

void write ( const DimensionedField< Type, volMesh > &  field)

Write the internal field.

Definition at line 134 of file foamVtkInternalWriterTemplates.C.

References Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, field(), format(), Foam::nl, Foam::vtk::writeList(), and Foam::vtk::writeListParallel().

Here is the call graph for this function:

◆ write() [3/5]

void write ( const GeometricField< Type, PatchField, volMesh > &  field)

Write the volume field (internal part)

Definition at line 190 of file foamVtkInternalWriterTemplates.C.

References field(), and Foam::vtk::write().

Here is the call graph for this function:

◆ write() [4/5]

void write ( const DimensionedField< Type, volMesh > &  vfield,
const volPointInterpolation pInterp 
)

Write internal field with point interpolation.

Definition at line 200 of file foamVtkInternalWriterTemplates.C.

References Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, format(), Foam::nl, pInterp, Foam::expressions::patchExpr::POINT_DATA, Foam::vtk::writeLists(), and Foam::vtk::writeListsParallel().

Here is the call graph for this function:

◆ write() [5/5]

void write ( const GeometricField< Type, fvPatchField, volMesh > &  vfield,
const volPointInterpolation pInterp 
)

Write volume field with point interpolation.

Definition at line 269 of file foamVtkInternalWriterTemplates.C.

References Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, format(), Foam::nl, pInterp, Foam::expressions::patchExpr::POINT_DATA, Foam::vtk::writeLists(), and Foam::vtk::writeListsParallel().

Here is the call graph for this function:

Member Data Documentation

◆ debug

int debug = 0
static

Debug information.

Definition at line 121 of file foamVtkInternalWriter.H.


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