Skip to content

VTK Export

MicPy can export field data to the Visualization Toolkit (VTK) ImageData format (.vti). This allows you to easily visualize MICRESS results in tools like ParaView or process them further in Python using VTK-based libraries.

ParaView Plugin

MicPy also provides a dedicated ParaView plugin that enables direct loading of MICRESS binary files – no conversion required. See the ParaView plugin documentation for details.

Exporting a Field as VTK ImageData

A Field can be converted to a vtkImageData object using Field.as_vti(). You can choose how the data is represented:

  • CellData: Each Field value is mapped directly to a VTK cell.
  • PointData: Field values are interpolated to VTK grid nodes.

PointData Interpolation

Conversion of field data to PointData maps values from cell centers to mesh vertices by aggregating contributions from adjacent cells. This operation increases the data resolution from \((n_x, n_y, n_z)\) to \((n_x + 1, n_y + 1, n_z + 1)\) and will introduce a smoothing effect. Nevertheless, the transformation may be useful for applying data filters that require point-associated data, such as isosurface extraction.

from micpy.bin import read

# Read a field (e.g. the last time step of a phase fraction)
field = read("A019_01_MgAl6_D_Dendritic_3D_TQ.frac", -1)

# Convert to VTK ImageData object
vti = field.as_vti()
from micpy.bin import read

# Read a field (e.g. the last time step of a phase fraction)
field = read("A019_01_MgAl6_D_Dendritic_3D_TQ.frac", -1)

# Convert to VTK ImageData object
vti = field.as_vti(point_data=True)

Saving to a .vti File

To write the result to disk, use the built-in Field.save_vti() convenience method:

# Save as VTK ImageData file
field.save_vti("A019_01_MgAl6_D_Dendritic_3D_TQ.frac.vti")
# Save as VTK ImageData file
field.save_vti("A019_01_MgAl6_D_Dendritic_3D_TQ.frac.vti", point_data=True)

Reference

micpy.bin.Field.as_vti(name='values', point_data=False)

Convert the field to a VTK ImageData object.

Parameters:

Name Type Description Default
name str

Name of the data array. Defaults to values.

'values'
point_data bool

True if data should be stored as PointData, False if data should be stored as CellData. Defaults to False.

False

Returns: VTK ImageData object.

micpy.bin.Field.save_vti(filename, name='values', point_data=False)

Save the field as a VTK ImageData file.

Parameters:

Name Type Description Default
filename str

Filename of the VTK ImageData file.

required
name str

Name of the data array. Defaults to values.

'values'
point_data bool

True if data should be stored as PointData False if data should be stored as CellData. Defaults to False.

False

Returns: Filename of the VTK ImageData file.