lagrangianWriter Class Reference

Write lagrangian (cloud) positions and fields (as PointData) in VTP format. Legacy VTK format is intentionally not supported since the VTP format provides much better field selection in ParaView, and for consistency with the Foam::functionObjects::vtkCloud function object. More...

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

Public Member Functions

 lagrangianWriter (const fvMesh &mesh, const word &cloudName, const vtk::outputOptions opts=vtk::formatType::INLINE_BASE64, bool useVerts=false)
 Construct from components (default format INLINE_BASE64) More...
 
 lagrangianWriter (const fvMesh &mesh, const word &cloudName, const fileName &file, bool parallel=Pstream::parRun())
 
 lagrangianWriter (const fvMesh &mesh, const word &cloudName, const vtk::outputOptions opts, const fileName &file, bool parallel=Pstream::parRun())
 Construct from components and open the file for writing. More...
 
virtual ~lagrangianWriter ()=default
 Destructor. More...
 
virtual bool beginFile (std::string title="")
 Write file header (non-collective) More...
 
virtual bool writeGeometry ()
 Write cloud positions. More...
 
bool beginParcelData ()
 Begin parcel (PointData) output section. More...
 
bool endParcelData ()
 Explicitly end parcel (PointData) output and switch to PIECE state. More...
 
template<class Type >
void write (const IOField< Type > &field)
 Write the IOField. More...
 
template<class Type >
label writeFields (const wordList &fieldNames, bool verbose=true)
 Write IOFields. More...
 
template<class Type >
label writeFields (const IOobjectList &objects, bool verbose=true)
 Write IOFields. More...
 
template<class Type >
Foam::label writeFields (const wordList &fieldNames, bool verbose)
 
template<class Type >
Foam::label writeFields (const IOobjectList &objects, const bool verbose)
 
- 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)
 File extension for given output type. Always ".vtp". More...
 

Protected Member Functions

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

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 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...
 
- 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 lagrangian (cloud) positions and fields (as PointData) in VTP format. Legacy VTK format is intentionally not supported since the VTP format provides much better field selection in ParaView, and for consistency with the Foam::functionObjects::vtkCloud function object.

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

Note
If fields should be CellData instead of PointData (default), this must be decided at construction time.
Source files

Definition at line 70 of file foamVtkLagrangianWriter.H.

Constructor & Destructor Documentation

◆ lagrangianWriter() [1/3]

lagrangianWriter ( const fvMesh mesh,
const word cloudName,
const vtk::outputOptions  opts = vtk::formatType::INLINE_BASE64,
bool  useVerts = false 
)

Construct from components (default format INLINE_BASE64)

Parameters
useVertsDefine VERTS and use CellData instead of PointData.

Definition at line 117 of file foamVtkLagrangianWriter.C.

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

Here is the call graph for this function:

◆ lagrangianWriter() [2/3]

lagrangianWriter ( const fvMesh mesh,
const word cloudName,
const fileName file,
bool  parallel = Pstream::parRun() 
)

Construct from components (default format INLINE_BASE64), and open the file for writing.

The file name is with/without an extension.

Definition at line 136 of file foamVtkLagrangianWriter.C.

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

Here is the call graph for this function:

◆ lagrangianWriter() [3/3]

lagrangianWriter ( const fvMesh mesh,
const word cloudName,
const vtk::outputOptions  opts,
const fileName file,
bool  parallel = Pstream::parRun() 
)

Construct from components and open the file for writing.

The file name is with/without an extension.

Definition at line 150 of file foamVtkLagrangianWriter.C.

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

Here is the call graph for this function:

◆ ~lagrangianWriter()

virtual ~lagrangianWriter ( )
virtualdefault

Destructor.

Member Function Documentation

◆ beginCellData()

bool beginCellData ( label  nFields = 0)
protectedvirtual

Begin CellData output section for specified number of fields.

Must be called prior to writing any cell data fields.

Parameters
nFieldsis the number of fields, which is required for legacy format.
Note
Expected calling states: (PIECE | POINT_DATA).
Returns
True if the state changed

Implements fileWriter.

Definition at line 103 of file foamVtkLagrangianWriter.C.

◆ beginPointData()

bool beginPointData ( label  nFields = 0)
protectedvirtual

Begin PointData for specified number of fields.

Must be called prior to writing any point data fields.

Parameters
nFieldsis the number of fields, which is required for legacy format.
Note
Expected calling states: (PIECE | CELL_DATA).
Returns
True if the state changed

Implements fileWriter.

Definition at line 109 of file foamVtkLagrangianWriter.C.

◆ ext()

static word ext ( vtk::outputOptions  )
inlinestatic

File extension for given output type. Always ".vtp".

Definition at line 178 of file foamVtkLagrangianWriter.H.

References Foam::vtk::fileExtension, and Foam::vtk::POLY_DATA.

◆ beginFile()

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

Write file header (non-collective)

Note
Expected calling states: (OPENED).

Reimplemented from fileWriter.

Definition at line 167 of file foamVtkLagrangianWriter.C.

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

Here is the call graph for this function:

◆ writeGeometry()

bool writeGeometry ( )
virtual

Write cloud positions.

Also writes the file header if not previously written.

Note
Must be called prior to writing CellData or PointData

Implements fileWriter.

Definition at line 189 of file foamVtkLagrangianWriter.C.

References format(), Foam::vtk::NUMBER_OF_POINTS, Foam::vtk::NUMBER_OF_VERTS, Foam::vtk::PIECE, Foam::vtk::POINTS, Foam::reduce(), UList< T >::size(), Foam::vtk::writeList(), and Foam::vtk::writeListParallel().

Here is the call graph for this function:

◆ beginParcelData()

bool beginParcelData ( )

Begin parcel (PointData) output section.

Must be called prior to writing data fields.

Note
Expected calling states: (PIECE).
Returns
True if the state changed

Definition at line 278 of file foamVtkLagrangianWriter.C.

References beginCellData(), and beginPointData().

Here is the call graph for this function:

◆ endParcelData()

bool endParcelData ( )

Explicitly end parcel (PointData) output and switch to PIECE state.

Ignored (no-op) if not currently in the parcel state.

Definition at line 291 of file foamVtkLagrangianWriter.C.

◆ write()

void write ( const IOField< Type > &  field)

Write the IOField.

Definition at line 35 of file foamVtkLagrangianWriterTemplates.C.

References fileWriter::CELL_DATA, Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, field(), fileWriter::isState(), fileWriter::nCellData_, Foam::nl, fileWriter::nPointData_, fileWriter::POINT_DATA, and fileWriter::reportBadState().

Here is the call graph for this function:

◆ writeFields() [1/4]

label writeFields ( const wordList fieldNames,
bool  verbose = true 
)

Write IOFields.

◆ writeFields() [2/4]

label writeFields ( const IOobjectList objects,
bool  verbose = true 
)

Write IOFields.

◆ writeFields() [3/4]

Foam::label writeFields ( const wordList fieldNames,
bool  verbose 
)

Definition at line 74 of file foamVtkLagrangianWriterTemplates.C.

References Foam::endl(), field(), Foam::Info, io(), IOobject::READ_IF_PRESENT, and Foam::returnReduce().

Here is the call graph for this function:

◆ writeFields() [4/4]

Foam::label writeFields ( const IOobjectList objects,
const bool  verbose 
)

Definition at line 140 of file foamVtkLagrangianWriterTemplates.C.

References IOobjectList::allNames().

Here is the call graph for this function:

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