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_vtp (const fileName &file)
 Add a (.vtp) file. More...
 
bool append_vtp (const word &name, const fileName &file)
 Add a (.vtp) file with name. More...
 
bool append_vtu (const fileName &file)
 Add a (.vtu) file. More...
 
bool append_vtu (const word &name, const fileName &file)
 Add a (.vtu) file with name. 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 (const fileName &file)
 Open file for writing (creates parent directory) and write the blocks and TimeValue. More...
 
void dump (Ostream &os) const
 Print debug view of block and dataset contents. 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 87 of file foamVtmWriter.H.

Constructor & Destructor Documentation

◆ vtmWriter() [1/2]

vtmWriter ( )

Default construct, with autoName on.

Definition at line 310 of file foamVtmWriter.C.

◆ vtmWriter() [2/2]

vtmWriter ( bool  autoName)
explicit

Construct with specified behaviour for autoName.

Definition at line 316 of file foamVtmWriter.C.

◆ ~vtmWriter()

~vtmWriter ( )
default

Destructor.

Member Function Documentation

◆ ext()

Foam::word ext ( )
inlinestatic

File extension (always "vtm")

Definition at line 23 of file foamVtmWriterI.H.

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

◆ empty()

bool empty ( ) const

If there are no data sets.

Definition at line 338 of file foamVtmWriter.C.

References Foam::constant::electromagnetic::e.

◆ size()

Foam::label size ( ) const

The number of data sets.

Definition at line 352 of file foamVtmWriter.C.

References Foam::constant::electromagnetic::e.

◆ clear()

void clear ( )

Clear all entries and reset output.

Definition at line 328 of file foamVtmWriter.C.

References Foam::Zero.

◆ setTime() [1/2]

void setTime ( scalar  timeValue)

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

Definition at line 368 of file foamVtmWriter.C.

Referenced by vtkWrite::write().

Here is the caller graph for this function:

◆ setTime() [2/2]

void setTime ( const Time t)

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

Definition at line 375 of file foamVtmWriter.C.

References dimensioned< Type >::value().

Here is the call graph for this function:

◆ beginBlock()

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

Start a new block, optionally with a name.

Returns
block depth

Definition at line 382 of file foamVtmWriter.C.

◆ endBlock()

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

End the previous block, optionally with name checking.

Returns
block depth

Definition at line 391 of file foamVtmWriter.C.

References Foam::endl(), and WarningInFunction.

Here is the call graph for this function:

◆ 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

Definition at line 412 of file foamVtmWriter.C.

References append(), word::null, and fileName::stem().

Here is the call graph for this function:

◆ append() [2/4]

bool append ( const word name,
const fileName file 
)

Add a file with name.

Returns
True if file is non-empty

Definition at line 439 of file foamVtmWriter.C.

References Foam::name().

Here is the call graph for this function:

◆ 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

Definition at line 424 of file foamVtmWriter.C.

References append(), word::null, and fileName::stem().

Here is the call graph for this function:

◆ 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

Definition at line 455 of file foamVtmWriter.C.

References Foam::vtk::fileExtension, fileName::has_ext(), and Foam::name().

Here is the call graph for this function:

◆ append_vtp() [1/2]

bool append_vtp ( const fileName file)
inline

Add a (.vtp) file.

Returns
True if file is non-empty

Definition at line 29 of file foamVtmWriterI.H.

References append(), and Foam::vtk::POLY_DATA.

Here is the call graph for this function:

◆ append_vtp() [2/2]

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

Add a (.vtp) file with name.

Returns
True if file is non-empty

Definition at line 36 of file foamVtmWriterI.H.

References append(), Foam::name(), and Foam::vtk::POLY_DATA.

Here is the call graph for this function:

◆ append_vtu() [1/2]

bool append_vtu ( const fileName file)
inline

Add a (.vtu) file.

Returns
True if file is non-empty

Definition at line 45 of file foamVtmWriterI.H.

References append(), and Foam::vtk::UNSTRUCTURED_GRID.

Here is the call graph for this function:

◆ append_vtu() [2/2]

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

Add a (.vtu) file with name.

Returns
True if file is non-empty

Definition at line 52 of file foamVtmWriterI.H.

References append(), Foam::name(), and Foam::vtk::UNSTRUCTURED_GRID.

Here is the call graph for this function:

◆ repair()

void repair ( bool  collapse = false)

Sanity fixes on the data.

Definition at line 199 of file foamVtmWriter.C.

References Foam::constant::electromagnetic::e.

◆ add() [1/2]

void add ( const word blockName,
const vtmWriter other 
)

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

Definition at line 562 of file foamVtmWriter.C.

References Foam::add(), and fileName::null.

Referenced by vtkWrite::write().

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

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

Definition at line 487 of file foamVtmWriter.C.

References Foam::beginBlock(), Foam::constant::electromagnetic::e, and f().

Here is the call graph for this function:

◆ write()

Foam::label write ( const fileName file)

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

Definition at line 571 of file foamVtmWriter.C.

References Foam::constant::electromagnetic::e, format(), fileName::has_ext(), Foam::vtk::INLINE_ASCII, Foam::mkDir(), Foam::vtk::MULTI_BLOCK, Foam::name(), Foam::vtk::newFormatter(), and fileName::path().

Referenced by vtkWrite::write().

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

◆ dump()

void dump ( Ostream os) const

Print debug view of block and dataset contents.

Definition at line 252 of file foamVtmWriter.C.

References Foam::constant::electromagnetic::e, Foam::nl, and os().

Here is the call graph for this function:

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