Base class for VTK output writers that handle geometry and fields (eg, vtp, vtu data). These output formats are structured as DECLARED, FIELD_DATA, PIECE followed by any CELL_DATA or POINT_DATA. More...
#include <foamVtkFileWriter.H>


Public Member Functions | |
| 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 word & | state () const |
| The output state in printable format. | |
| const fileName & | output () 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. | |
| virtual bool | beginFile (std::string title="") |
| Write file header (non-collective). | |
| bool | beginFieldData (label nFields=0) |
| Begin FieldData output section for specified number of fields. | |
| virtual bool | writeGeometry ()=0 |
| Write mesh topology. | |
| virtual bool | beginCellData (label nFields=0)=0 |
| Begin CellData output section for specified number of fields. | |
| virtual bool | beginPointData (label nFields=0)=0 |
| Begin PointData 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). | |
Protected Types | |
| enum class | outputState : uint8_t { CLOSED = 0 , OPENED , DECLARED , FIELD_DATA , PIECE , CELL_DATA , POINT_DATA } |
| Internal tracking of the output state. More... | |
Protected Member Functions | |
| void | checkFormatterValidity () const |
| Verify that formatter in either allocated or not required. | |
| Ostream & | reportBadState (Ostream &, outputState expected) const |
| Generate message reporting bad writer state. | |
| Ostream & | reportBadState (Ostream &, outputState, outputState) const |
| Generate message reporting bad writer state. | |
| std::ofstream & | os () noexcept |
| The backend ostream in use. | |
| vtk::formatter & | format () |
| 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 | |
| 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::formatter > | format_ |
| The VTK formatter in use (only valid on master process). | |
| std::ofstream | os_ |
| The backend ostream in use (only opened on master process). | |
Static Protected Attributes | |
| static const Enum< outputState > | stateNames |
| Names for the output state (for messages, not for file output). | |
Base class for VTK output writers that handle geometry and fields (eg, vtp, vtu data). These output formats are structured as DECLARED, FIELD_DATA, PIECE followed by any CELL_DATA or POINT_DATA.
This writer base tracks these expected output states internally to help avoid logic errors in the callers.
The FieldData element must be placed prior to writing any geometry Piece. This moves the information to the front of the output file for visibility and simplifies the logic when creating multi-piece geometries.
Definition at line 65 of file foamVtkFileWriter.H.
|
strongprotected |
Internal tracking of the output state.
| Enumerator | |
|---|---|
| CLOSED | File is closed. |
| OPENED | File is opened. |
| DECLARED | File contents declared (VTKFile header written). |
| FIELD_DATA | Inside FieldData. |
| PIECE | Inside Piece (after geometry write). |
| CELL_DATA | Inside CellData. |
| POINT_DATA | Inside PointData. |
Definition at line 74 of file foamVtkFileWriter.H.
|
protecteddelete |
No copy construct.
References fileWriter().
Referenced by fileWriter(), fileWriter(), operator=(), and ~fileWriter().


| fileWriter | ( | const vtk::fileTag | contentType, |
| const vtk::outputOptions | opts ) |
Construct from components.
References contentType(), fileWriter(), and opts().

|
virtual |
Destructor.
References contentType(), ext(), fileWriter(), legacy(), Foam::noexcept, opts(), output(), parallel(), and state().

|
protected |
Verify that formatter in either allocated or not required.
|
protected |
Generate message reporting bad writer state.
|
protected |
Generate message reporting bad writer state.
References format(), isState(), Foam::noexcept, and notState().

|
inlineprotectednoexcept |
The backend ostream in use.
Definition at line 23 of file foamVtkFileWriterI.H.
References Foam::noexcept, and os_.
|
inlineprotected |
The VTK formatter in use. FatalError for off-processor.
Definition at line 29 of file foamVtkFileWriterI.H.
References format_.
Referenced by reportBadState().

|
inlineprotectednoexcept |
True if output state corresponds to the test state.
Definition at line 35 of file foamVtkFileWriterI.H.
References state_.
Referenced by reportBadState().

|
inlineprotectednoexcept |
True if output state does not correspond to the test state.
Definition at line 41 of file foamVtkFileWriterI.H.
References state_.
Referenced by reportBadState().

|
protected |
Start of a field or DataArray output (legacy or non-legacy).
References beginDataArray().
Referenced by beginDataArray().


|
protected |
Flush formatter and end of DataArray output (non-legacy).
References endDataArray().
Referenced by endDataArray().


|
protected |
Start of a POINTS DataArray.
References beginPoints(), and nPoints.
Referenced by beginPoints().


|
protected |
End of a POINTS DataArray.
References endPoints().
Referenced by endPoints().


|
protected |
Trigger change state to Piece. Resets nCellData_, nPointData_.
References enter_Piece().
Referenced by enter_Piece().


|
protected |
Explicitly end Piece output and switch to DECLARED state.
Ignored (no-op) if not currently in the PIECE state.
References endPiece().
Referenced by endPiece().


|
protected |
Trigger change state to CellData.
Legacy requires both parameters. XML doesn't require either.
References enter_CellData().
Referenced by enter_CellData().


|
protected |
Trigger change state to PointData.
Legacy requires both parameters. XML doesn't require either.
References enter_PointData().
Referenced by enter_PointData().


|
protected |
Emit file footer (end data, end piece, end file).
References exit_File().
Referenced by exit_File().


|
protected |
Write uniform field content.
No context checking (eg, file-open, CellData, PointData, etc) The value and count can be different on each processor
References writeUniform().
Referenced by writeUniform().


|
protected |
Write basic (primitive) field content.
No context checking (eg, file-open, CellData, PointData, etc)
References field(), and writeBasicField().
Referenced by writeBasicField().


|
protected |
Write nValues of processor ids as CellData or PointData (no-op in serial).
References writeProcIDs().
Referenced by writeProcIDs(), and GenericPatchWriter< indirectPrimitivePatch >::writeProcIDs().


|
protecteddelete |
|
inlinenoexcept |
The content type.
Definition at line 49 of file foamVtkFileWriterI.H.
References contentType_, and Foam::noexcept.
Referenced by fileWriter(), and ~fileWriter().

|
inlinenoexcept |
The output options in use.
Definition at line 55 of file foamVtkFileWriterI.H.
References Foam::noexcept, and opts_.
Referenced by coordSetWriter::coordSetWriter(), coordSetWriter::coordSetWriter(), internalMeshWriter::ext(), patchMeshWriter::ext(), polyWriter::ext(), fileWriter(), GenericPatchWriter< indirectPrimitivePatch >::GenericPatchWriter(), GenericPatchWriter< indirectPrimitivePatch >::GenericPatchWriter(), internalMeshWriter::internalMeshWriter(), internalMeshWriter::internalMeshWriter(), internalWriter::internalWriter(), internalWriter::internalWriter(), lagrangianWriter::lagrangianWriter(), lagrangianWriter::lagrangianWriter(), lineWriter::lineWriter(), lineWriter::lineWriter(), patchMeshWriter::patchMeshWriter(), patchMeshWriter::patchMeshWriter(), patchWriter::patchWriter(), patchWriter::patchWriter(), patchWriter::patchWriter(), polyWriter::polyWriter(), polyWriter::polyWriter(), surfaceFieldWriter::surfaceFieldWriter(), surfaceFieldWriter::surfaceFieldWriter(), surfaceWriter::surfaceWriter(), surfaceWriter::surfaceWriter(), and ~fileWriter().

|
inline |
File extension for current format type.
Definition at line 61 of file foamVtkFileWriterI.H.
References contentType_, and opts_.
Referenced by vtkWriter::write(), ~fileWriter(), internalMeshWriter::~internalMeshWriter(), lagrangianWriter::~lagrangianWriter(), patchMeshWriter::~patchMeshWriter(), polyWriter::~polyWriter(), and surfaceFieldWriter::~surfaceFieldWriter().

|
inlinenoexcept |
Commonly used query.
Definition at line 67 of file foamVtkFileWriterI.H.
References Foam::noexcept, and opts_.
Referenced by ~fileWriter().

|
inlinenoexcept |
Parallel output requested?
Definition at line 73 of file foamVtkFileWriterI.H.
References Foam::noexcept, and parallel_.
Referenced by GenericPatchWriter< indirectPrimitivePatch >::GenericPatchWriter(), GenericPatchWriter< indirectPrimitivePatch >::GenericPatchWriter(), internalMeshWriter::internalMeshWriter(), internalMeshWriter::internalMeshWriter(), internalWriter::internalWriter(), internalWriter::internalWriter(), lagrangianWriter::lagrangianWriter(), lagrangianWriter::lagrangianWriter(), lineWriter::lineWriter(), lineWriter::lineWriter(), coordSetWriter::open(), open(), patchMeshWriter::patchMeshWriter(), patchMeshWriter::patchMeshWriter(), patchWriter::patchWriter(), patchWriter::patchWriter(), patchWriter::patchWriter(), polyWriter::polyWriter(), polyWriter::polyWriter(), surfaceFieldWriter::surfaceFieldWriter(), surfaceFieldWriter::surfaceFieldWriter(), surfaceWriter::surfaceWriter(), surfaceWriter::surfaceWriter(), and ~fileWriter().

|
inline |
The output state in printable format.
Definition at line 79 of file foamVtkFileWriterI.H.
References state_, and stateNames.
Referenced by ~fileWriter().

|
inlinenoexcept |
The current output file name.
Definition at line 85 of file foamVtkFileWriterI.H.
References Foam::noexcept, and outputFile_.
Referenced by ~fileWriter().

|
virtual |
Open file for writing (creates parent directory).
The file name is normally without an extension, this will be added according to the content-type and the output format (legacy/xml). If the file name has an extension, it will be used where if appropriate or changed to suit the format (legacy/xml) type.
Reimplemented in coordSetWriter.
References open(), and parallel().
Referenced by open().


| void close | ( | ) |
End the file contents and close the file after writing.
References close().
Referenced by close(), and topOVariablesBase::writeSurfaceFiles().


|
virtual |
Write file header (non-collective).
Reimplemented in coordSetWriter, GenericPatchWriter< PatchType >, GenericPatchWriter< indirectPrimitivePatch >, GenericPatchWriter< primitivePatch >, GenericPatchWriter< uindirectPrimitivePatch >, internalMeshWriter, lagrangianWriter, lineWriter, patchMeshWriter, surfaceFieldWriter, and surfaceWriter.
References beginFile().
Referenced by beginFile(), and GenericPatchWriter< indirectPrimitivePatch >::beginFile().


| bool beginFieldData | ( | label | nFields = 0 | ) |
Begin FieldData output section for specified number of fields.
| nFields | is for legacy format only. When nFields=0, this a no-op for legacy format. |
References beginFieldData().
Referenced by beginFieldData().


|
pure virtual |
Write mesh topology.
Also writes the file header if not previously written.
Implemented in coordSetWriter, GenericPatchWriter< PatchType >, GenericPatchWriter< indirectPrimitivePatch >, GenericPatchWriter< primitivePatch >, GenericPatchWriter< uindirectPrimitivePatch >, internalMeshWriter, lagrangianWriter, lineWriter, patchMeshWriter, polyWriter, surfaceFieldWriter, and surfaceWriter.
References writeGeometry().
Referenced by writeGeometry().


|
pure virtual |
Begin CellData output section for specified number of fields.
Must be called prior to writing any cell data fields.
| nFields | is for legacy format only. When nFields=0, this a no-op for legacy format. |
Implemented in internalMeshWriter, lagrangianWriter, patchMeshWriter, polyWriter, and surfaceFieldWriter.
References beginCellData().
Referenced by beginCellData().


|
pure virtual |
Begin PointData for specified number of fields.
Must be called prior to writing any point data fields.
| nFields | is for legacy format only. When nFields=0, this a no-op for legacy format. |
Implemented in internalMeshWriter, lagrangianWriter, patchMeshWriter, polyWriter, and surfaceFieldWriter.
References beginPointData(), isCellData(), isPointData(), nCellData(), Foam::noexcept, and nPointData().
Referenced by beginPointData().


|
inlinenoexcept |
True if output state corresponds to CELL_DATA.
Definition at line 103 of file foamVtkFileWriterI.H.
References CELL_DATA, Foam::noexcept, and state_.
Referenced by beginPointData().

|
inlinenoexcept |
True if output state corresponds to POINT_DATA.
Definition at line 109 of file foamVtkFileWriterI.H.
References Foam::noexcept, POINT_DATA, and state_.
Referenced by beginPointData(), and GenericPatchWriter< indirectPrimitivePatch >::writeProcIDs().

|
inlinenoexcept |
The number of CellData written for the Piece thus far.
Definition at line 91 of file foamVtkFileWriterI.H.
References nCellData_, and Foam::noexcept.
Referenced by beginPointData().

|
inlinenoexcept |
The number of PointData written for the Piece thus far.
Definition at line 97 of file foamVtkFileWriterI.H.
References Foam::noexcept, and nPointData_.
Referenced by beginPointData().

| bool endFieldData | ( | ) |
Explicitly end FieldData output and switch to DECLARED state.
Ignored (no-op) if not currently in the FIELD_DATA state.
References endFieldData().
Referenced by endFieldData().


| bool endCellData | ( | ) |
Explicitly end CellData output and switch to PIECE state.
Ignored (no-op) if not currently in the CELL_DATA state.
References endCellData().
Referenced by endCellData().


| bool endPointData | ( | ) |
Explicitly end PointData output and switch to PIECE state.
Ignored (no-op) if not currently in the POINT_DATA state.
References endPointData().
Referenced by endPointData().


| void writeTimeValue | ( | scalar | timeValue | ) |
Write "TimeValue" FieldData (name as per Catalyst output).
Must be called within the FIELD_DATA state.
References writeTimeValue().
Referenced by coordSetWriter::writeGeometry(), lineWriter::writeGeometry(), surfaceWriter::writeGeometry(), and writeTimeValue().


|
staticprotected |
Names for the output state (for messages, not for file output).
Definition at line 88 of file foamVtkFileWriter.H.
Referenced by state().
|
protected |
The output state.
Definition at line 94 of file foamVtkFileWriter.H.
Referenced by isCellData(), isPointData(), isState(), notState(), and state().
|
protected |
The content type (PolyData, UnstructuredGrid ...).
Definition at line 99 of file foamVtkFileWriter.H.
Referenced by contentType(), and ext().
|
protected |
Parallel writing (via master).
Definition at line 104 of file foamVtkFileWriter.H.
Referenced by parallel().
|
protected |
Requested output options.
Definition at line 109 of file foamVtkFileWriter.H.
|
protected |
The number of CellData written for the Piece thus far.
Definition at line 114 of file foamVtkFileWriter.H.
Referenced by nCellData().
|
protected |
The number of PointData written for the Piece thus far.
Definition at line 119 of file foamVtkFileWriter.H.
Referenced by nPointData().
|
protected |
|
protected |
The VTK formatter in use (only valid on master process).
Definition at line 129 of file foamVtkFileWriter.H.
Referenced by format().
|
protected |
The backend ostream in use (only opened on master process).
Definition at line 134 of file foamVtkFileWriter.H.
Referenced by os().