VTK Export¶
MicPy can export field data to the Visualization Toolkit (VTK) ImageData format (.vti). This makes it easy to use MICRESS results in external 3D visualization tools such as ParaView, or in Python workflows with VTK-based libraries.
ParaView Plugin
For seamless integration with ParaView, MicPy provides a dedicated ParaView plugin that allows MICRESS binary files to be opened directly in ParaView without prior conversion.
Exporting a Field as VTK ImageData¶
A Field can be converted directly to VTK ImageData using Field.as_vti(). By default, values are written as CellData.
from micpy.bin import read
# Read a field (for example: the last time step)
field = read("A005_Grain_Growth_Misorientation_3D.korn", -1)
# Convert to VTK ImageData (CellData by default)
vti = field.as_vti()
Saving to a .vti File¶
To write the result to disk, use the built-in Field.save_vti() convenience method:
Rendering in Python with PyVista¶
If you're working in an interactive environment (for example, a Jupyter notebook), you can render the exported VTK ImageData directly using a VTK-based library such as PyVista:
import pyvista as pv
# Convert the VTK ImageData object into a PyVista dataset
grid = pv.wrap(vti)
# Simple rendering
pv.plot(grid)

CellData vs PointData¶
VTK ImageData can store values either per cell (CellData) or per grid point (PointData). MicPy supports both representations:
- Default:
field.as_vti()maps values to CellData. - Optional:
field.as_vti(point_data=True)returns PointData. In this mode, MicPy derives point values from neighboring cells so that the exported dataset preserves the original domain size.
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' |
point_data | bool |
| 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' |
point_data | bool |
| False |
Returns: Filename of the VTK ImageData file.