internalMeshWriter Class Reference

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

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

Public Member Functions

 internalMeshWriter (const polyMesh &mesh, const vtk::vtuCells &cells, const vtk::outputOptions opts=vtk::formatType::INLINE_BASE64)
 File extension for given output type. More...
 
 internalMeshWriter (const polyMesh &mesh, const vtk::vtuCells &cells, const fileName &file, bool parallel=Pstream::parRun())
 Construct from components (default format INLINE_BASE64),. More...
 
 internalMeshWriter (const polyMesh &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 ~internalMeshWriter ()=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 >
void writeCellData (const word &fieldName, const UList< Type > &field)
 Write primitive field of CellData. More...
 
template<class Type >
void writePointData (const word &fieldName, const UList< Type > &field)
 Write primitive field of PointData. 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 noexcept
 The content type. More...
 
vtk::outputOptions opts () const noexcept
 The output options in use. More...
 
word ext () const
 File extension for current format type. More...
 
bool legacy () const noexcept
 Commonly used query. More...
 
bool parallel () const noexcept
 Parallel output requested? More...
 
const wordstate () const
 The output state in printable format. More...
 
const fileNameoutput () const noexcept
 The current output file name. More...
 
virtual 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...
 
virtual bool beginFile (std::string title="")
 Write file header (non-collective) More...
 
bool beginFieldData (label nFields=0)
 Begin FieldData output section for specified number of fields. More...
 
virtual bool writeGeometry ()=0
 Write mesh topology. More...
 
virtual bool beginCellData (label nFields=0)=0
 Begin CellData output section for specified number of fields. More...
 
virtual bool beginPointData (label nFields=0)=0
 Begin PointData for specified number of fields. More...
 
label nCellData () const noexcept
 Return the number of CellData written for the Piece thus far. More...
 
label nPointData () const noexcept
 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...
 

Protected Attributes

label numberOfPoints_
 The number of field points for the current Piece. More...
 
label numberOfCells_
 The number of field cells for the current Piece. More...
 
const polyMeshmesh_
 Reference to the OpenFOAM mesh (or subset) More...
 
const vtuCellsvtuCells_
 The volume cells (internalMesh) More...
 
- Protected Attributes inherited from fileWriter
outputState state_
 The output state. More...
 
vtk::fileTag contentType_
 The content type (PolyData, UnstructuredGrid ...) More...
 
bool parallel_
 Parallel writing (via master) More...
 
vtk::outputOptions opts_
 Requested output options. 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 (only valid on master process) More...
 
std::ofstream os_
 The backend ostream in use (only opened on master process) More...
 

Additional Inherited Members

- Protected Types inherited from fileWriter
enum  outputState : uint8_t {
  CLOSED = 0 , OPENED , DECLARED , FIELD_DATA ,
  PIECE , CELL_DATA , POINT_DATA
}
 Internal tracking of the output state. More...
 
- Protected Member Functions inherited from fileWriter
void checkFormatterValidity () const
 Verify that formatter in either allocated or not required. More...
 
OstreamreportBadState (Ostream &, outputState expected) const
 Generate message reporting bad writer state. More...
 
OstreamreportBadState (Ostream &, outputState, outputState) const
 Generate message reporting bad writer state. More...
 
std::ofstream & os () noexcept
 The backend ostream in use. More...
 
vtk::formatterformat ()
 The VTK formatter in use. FatalError for off-processor. More...
 
bool isState (outputState test) const noexcept
 True if output state corresponds to the test state. More...
 
bool notState (outputState test) const noexcept
 True if output state does not correspond to the test state. More...
 
template<class Type >
void beginDataArray (const word &fieldName, const label nValues)
 Start of a field or DataArray output (legacy or non-legacy). More...
 
void endDataArray ()
 Flush formatter and end of DataArray output (non-legacy) More...
 
void beginPoints (const label nPoints)
 Start of a POINTS DataArray. More...
 
void endPoints ()
 End of a POINTS DataArray. 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...
 
template<class Type >
void writeUniform (const word &fieldName, const Type &val, const label nValues)
 Write uniform field content. More...
 
template<class Type >
void writeBasicField (const word &fieldName, const UList< Type > &field)
 Write basic (primitive) field content. More...
 
bool writeProcIDs (const label nValues)
 Write nValues of processor ids as CellData (no-op in serial) More...
 
 fileWriter (const fileWriter &)=delete
 No copy construct. More...
 
void operator= (const fileWriter &)=delete
 No copy assignment. 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.
See also
Foam::vtk::internalWriter
Source files

Definition at line 69 of file foamVtkInternalMeshWriter.H.

Constructor & Destructor Documentation

◆ internalMeshWriter() [1/3]

internalMeshWriter ( const polyMesh 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 471 of file foamVtkInternalMeshWriter.C.

References outputOptions::append(), and fileWriter::opts_.

Here is the call graph for this function:

◆ internalMeshWriter() [2/3]

internalMeshWriter ( const polyMesh 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 490 of file foamVtkInternalMeshWriter.C.

References fileWriter::open(), and fileWriter::parallel().

Here is the call graph for this function:

◆ internalMeshWriter() [3/3]

internalMeshWriter ( const polyMesh 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 504 of file foamVtkInternalMeshWriter.C.

References fileWriter::open(), and fileWriter::parallel().

Here is the call graph for this function:

◆ ~internalMeshWriter()

virtual ~internalMeshWriter ( )
virtualdefault

Destructor.

Member Function Documentation

◆ ext()

static word ext ( vtk::outputOptions  opts)
inlinestatic

File extension for given output type.

Definition at line 171 of file foamVtkInternalMeshWriter.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 521 of file foamVtkInternalMeshWriter.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 559 of file foamVtkInternalMeshWriter.C.

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

Referenced by interfaceTrackingFvMesh::writeVTK(), lumpedPointMovement::writeVTP(), and lumpedPointMovement::writeZonesVTP().

Here is the call graph for this function:
Here is the caller 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 596 of file foamVtkInternalMeshWriter.C.

Referenced by lumpedPointMovement::writeVTP(), and lumpedPointMovement::writeZonesVTP().

Here is the caller graph for this function:

◆ 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 602 of file foamVtkInternalMeshWriter.C.

Referenced by isoSurfaceTopo::isoSurfaceTopo(), and lumpedPointMovement::writeVTP().

Here is the caller graph for this function:

◆ writeCellIDs()

void writeCellIDs ( )

Write cell ids as CellData.

Must be called within the CELL_DATA state.

Definition at line 608 of file foamVtkInternalMeshWriter.C.

References 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 642 of file foamVtkInternalMeshWriter.C.

References lineWriter::writeProcIDs().

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 654 of file foamVtkInternalMeshWriter.C.

References Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, format(), Foam::identity(), globalIndex::localStart(), Foam::nl, 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 34 of file foamVtkInternalMeshWriterTemplates.C.

References fileWriter::CELL_DATA, Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, fileWriter::isState(), fileWriter::nCellData_, vtuSizing::nFieldCells(), vtuSizing::nFieldPoints(), Foam::nl, fileWriter::nPointData_, fileWriter::POINT_DATA, fileWriter::reportBadState(), and internalMeshWriter::vtuCells_.

Referenced by lumpedPointMovement::writeVTP(), and lumpedPointMovement::writeZonesVTP().

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

◆ writeCellData()

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

Write primitive field of CellData.

Definition at line 71 of file foamVtkInternalMeshWriterTemplates.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:

◆ writePointData()

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

Write primitive field of PointData.

Definition at line 106 of file foamVtkInternalMeshWriterTemplates.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:

Member Data Documentation

◆ numberOfPoints_

label numberOfPoints_
protected

The number of field points for the current Piece.

Definition at line 78 of file foamVtkInternalMeshWriter.H.

Referenced by internalWriter::write().

◆ numberOfCells_

label numberOfCells_
protected

The number of field cells for the current Piece.

Definition at line 81 of file foamVtkInternalMeshWriter.H.

◆ mesh_

const polyMesh& mesh_
protected

Reference to the OpenFOAM mesh (or subset)

Definition at line 84 of file foamVtkInternalMeshWriter.H.

◆ vtuCells_

const vtuCells& vtuCells_
protected

The volume cells (internalMesh)

Definition at line 87 of file foamVtkInternalMeshWriter.H.

Referenced by internalWriter::write(), and internalMeshWriter::writeUniform().

◆ debug

int debug = 0
static

Debug information.

Definition at line 123 of file foamVtkInternalMeshWriter.H.


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