vtmWriter Class Reference

Provides a means of accumulating file entries for generating a vtkMultiBlockDataSet (.vtm) file. More...

Public Member Functions

 vtmWriter ()
 Default construct, with autoName on. More...
 
 vtmWriter (bool autoName)
 Construct with specified behaviour for autoName. More...
 
 ~vtmWriter ()=default
 Destructor. More...
 
bool empty () const
 If there are no data sets. More...
 
label size () const
 The number of data sets. More...
 
void clear ()
 Clear all entries and reset output. More...
 
void setTime (scalar timeValue)
 Define "TimeValue" for FieldData (name as per Catalyst output) More...
 
void setTime (const Time &t)
 Define "TimeValue" for FieldData (name as per Catalyst output) More...
 
label beginBlock (const word &blockName=word::null)
 Start a new block, optionally with a name. More...
 
label endBlock (const word &blockName=word::null)
 End the previous block, optionally with name checking. More...
 
bool append (const fileName &file)
 Add a file. The name is either empty or created with autoName. More...
 
bool append (const word &name, const fileName &file)
 Add a file with name. More...
 
bool append (const fileName &file, vtk::fileTag contentType)
 Add a file with given contentType extension The name is either empty or created with autoName. More...
 
bool append (const word &name, const fileName &file, vtk::fileTag contentType)
 Add a file with name, with given contentType extension. More...
 
bool append_poly (const fileName &file)
 Add a PolyData (.vtp) file. More...
 
bool append_poly (const word &name, const fileName &file)
 Add a PolyData (.vtp) file with name. More...
 
bool append_ugrid (const fileName &file)
 Add an UnstructuredGrid (.vtu) file. More...
 
bool append_ugrid (const word &name, const fileName &file)
 Add an UnstructuredGrid (.vtu) file with name. More...
 
template<vtk::fileTag DataType = vtk::fileTag::VTK_HDF>
bool append_hdf (const fileName &file)
 Add a (.vtkhdf) file. Often need to specify the content type as well (PolyData, UnstructuredGrid) More...
 
template<vtk::fileTag DataType = vtk::fileTag::VTK_HDF>
bool append_hdf (const word &name, const fileName &file)
 Add a (.vtkhdf) file with name. Often need to specify content type as well (PolyData, UnstructuredGrid) More...
 
void repair (bool collapse=false)
 Sanity fixes on the data. More...
 
void add (const word &blockName, const vtmWriter &other)
 Add in content from another vtm and place under the given block name. More...
 
void add (const word &blockName, const fileName &prefix, const vtmWriter &other)
 Add in content from another vtm and place under the given block name. Adjust the added 'file' entries to include the given prefix. More...
 
label write_xml (std::ostream &os) const
 Write the blocks and TimeValue (xml format). More...
 
label write_xml (OSstream &os) const
 Write the blocks and TimeValue (xml format). More...
 
label write_xml (const fileName &file) const
 Open file for writing (creates parent directory) and write the blocks and TimeValue. More...
 
label write (const fileName &file) const
 Forwards to write_xml(). More...
 
void dump (Ostream &os) const
 Print debug view of block and dataset contents. More...
 
bool append_vtp (const fileName &file)
 Same as append_poly - used until (2025-12) More...
 
bool append_vtu (const fileName &file)
 Same as append_ugrid - used until (2025-12) More...
 
bool append_vtp (const word &name, const fileName &file)
 Same as append_poly - used until (2025-12) More...
 
bool append_vtu (const word &name, const fileName &file)
 Same as append_ugrid - used until (2025-12) More...
 

Static Public Member Functions

static word ext ()
 File extension (always "vtm") More...
 

Detailed Description

Provides a means of accumulating file entries for generating a vtkMultiBlockDataSet (.vtm) file.

For example, to generate the following content:

<?xml version='1.0'?>
<VTKFile type='vtkMultiBlockDataSet' ...>
  <vtkMultiBlockDataSet>
    <DataSet name='internal' file='internal.vtu' />
    <Block name='boundary'>
      <DataSet name='inlet' file='boundary/inlet.vtp' />
      <DataSet name='outlet' file='boundary/outlet.vtp' />
    </Block>
  </vtkMultiBlockDataSet>
  <FieldData>
    <DataArray type='Float32' Name='TimeValue' ...>
       12.345
    </DataArray>
  </FieldData>
</VTKFile>

The following code would be used:

vtm.clear();
vtm.setTime(12.345);
vtm.append("internal", "internal.vtu");
vtm.beginBlock("boundary");
vtm.append("boundary/inlet.vtp");
vtm.append("boundary/outlet.vtp");
vtm.write("outputName");
Source files

Definition at line 90 of file foamVtmWriter.H.

Constructor & Destructor Documentation

◆ vtmWriter() [1/2]

vtmWriter ( )

Default construct, with autoName on.

◆ vtmWriter() [2/2]

vtmWriter ( bool  autoName)
explicit

Construct with specified behaviour for autoName.

◆ ~vtmWriter()

~vtmWriter ( )
default

Destructor.

Member Function Documentation

◆ ext()

Foam::word ext ( )
inlinestatic

File extension (always "vtm")

Definition at line 50 of file foamVtmWriterI.H.

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

◆ empty()

bool empty ( ) const

If there are no data sets.

◆ size()

label size ( ) const

The number of data sets.

◆ clear()

void clear ( )

Clear all entries and reset output.

◆ setTime() [1/2]

void setTime ( scalar  timeValue)

Define "TimeValue" for FieldData (name as per Catalyst output)

◆ setTime() [2/2]

void setTime ( const Time t)

Define "TimeValue" for FieldData (name as per Catalyst output)

◆ beginBlock()

label beginBlock ( const word blockName = word::null)

Start a new block, optionally with a name.

Returns
block depth

◆ endBlock()

label endBlock ( const word blockName = word::null)

End the previous block, optionally with name checking.

Returns
block depth

◆ append() [1/4]

bool append ( const fileName file)

Add a file. The name is either empty or created with autoName.

Returns
True if file is non-empty

◆ append() [2/4]

bool append ( const word name,
const fileName file 
)

Add a file with name.

Returns
True if file is non-empty

◆ append() [3/4]

bool append ( const fileName file,
vtk::fileTag  contentType 
)

Add a file with given contentType extension The name is either empty or created with autoName.

Returns
True if file is non-empty

◆ append() [4/4]

bool append ( const word name,
const fileName file,
vtk::fileTag  contentType 
)

Add a file with name, with given contentType extension.

Returns
True if file is non-empty

◆ append_poly() [1/2]

bool append_poly ( const fileName file)
inline

Add a PolyData (.vtp) file.

Returns
True if file is non-empty

Definition at line 56 of file foamVtmWriterI.H.

Referenced by vtmWriter::append_vtp().

Here is the caller graph for this function:

◆ append_poly() [2/2]

bool append_poly ( const word name,
const fileName file 
)
inline

Add a PolyData (.vtp) file with name.

Returns
True if file is non-empty

Definition at line 63 of file foamVtmWriterI.H.

References Foam::name().

Here is the call graph for this function:

◆ append_ugrid() [1/2]

bool append_ugrid ( const fileName file)
inline

Add an UnstructuredGrid (.vtu) file.

Returns
True if file is non-empty

Definition at line 72 of file foamVtmWriterI.H.

Referenced by vtmWriter::append_vtu().

Here is the caller graph for this function:

◆ append_ugrid() [2/2]

bool append_ugrid ( const word name,
const fileName file 
)
inline

Add an UnstructuredGrid (.vtu) file with name.

Returns
True if file is non-empty

Definition at line 79 of file foamVtmWriterI.H.

References Foam::name().

Here is the call graph for this function:

◆ append_hdf() [1/2]

bool append_hdf ( const fileName file)
inline

Add a (.vtkhdf) file. Often need to specify the content type as well (PolyData, UnstructuredGrid)

Returns
True if file is non-empty

Definition at line 89 of file foamVtmWriterI.H.

◆ append_hdf() [2/2]

bool append_hdf ( const word name,
const fileName file 
)
inline

Add a (.vtkhdf) file with name. Often need to specify content type as well (PolyData, UnstructuredGrid)

Returns
True if file is non-empty

Definition at line 97 of file foamVtmWriterI.H.

References Foam::name().

Here is the call graph for this function:

◆ repair()

void repair ( bool  collapse = false)

Sanity fixes on the data.

◆ add() [1/2]

void add ( const word blockName,
const vtmWriter other 
)

Add in content from another vtm and place under the given block name.

◆ add() [2/2]

void add ( const word blockName,
const fileName prefix,
const vtmWriter other 
)

Add in content from another vtm and place under the given block name. Adjust the added 'file' entries to include the given prefix.

◆ write_xml() [1/3]

label write_xml ( std::ostream &  os) const

Write the blocks and TimeValue (xml format).

Returns
number of data sets

◆ write_xml() [2/3]

label write_xml ( OSstream os) const

Write the blocks and TimeValue (xml format).

Returns
number of data sets

◆ write_xml() [3/3]

label write_xml ( const fileName file) const

Open file for writing (creates parent directory) and write the blocks and TimeValue.

The file name is with/without an extension.

Returns
number of data sets

◆ write()

label write ( const fileName file) const

Forwards to write_xml().

Returns
number of data sets

◆ dump()

void dump ( Ostream os) const

Print debug view of block and dataset contents.

◆ append_vtp() [1/2]

bool append_vtp ( const fileName file)
inline

Same as append_poly - used until (2025-12)

Definition at line 536 of file foamVtmWriter.H.

References vtmWriter::append_poly().

Here is the call graph for this function:

◆ append_vtu() [1/2]

bool append_vtu ( const fileName file)
inline

Same as append_ugrid - used until (2025-12)

Definition at line 541 of file foamVtmWriter.H.

References vtmWriter::append_ugrid().

Here is the call graph for this function:

◆ append_vtp() [2/2]

bool append_vtp ( const word name,
const fileName file 
)
inline

Same as append_poly - used until (2025-12)

Definition at line 546 of file foamVtmWriter.H.

References vtmWriter::append_poly(), and Foam::name().

Here is the call graph for this function:

◆ append_vtu() [2/2]

bool append_vtu ( const word name,
const fileName file 
)
inline

Same as append_ugrid - used until (2025-12)

Definition at line 554 of file foamVtmWriter.H.

References vtmWriter::append_ugrid(), and Foam::name().

Here is the call graph for this function:

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