Python scripts documentation

VTK conversion

Converts all .vtk files to .vtp.

This script converts all VTK files in the postProcessing directory.

Example:

Run python script in case root directory:

$ python convert_vtk.py

Todo:
  • None

phase.convert_vtk.convert_surfaces(vtkFile)

Converts a vtk file to vtp format if it does not exist. Deletes the vtk file upon successful conversion or if vtp file exists.

Parameters:

vtkFile (str) – VTK file path and name.

Returns:

0 if successful.

Return type:

int

phase.convert_vtk.vtk2vtp(invtkfile, outvtpfile)

Converts a vtk file to vtp format.

Parameters:
  • invtkfile (str) – VTK file path and name.

  • outvtpfile (str) – VTP file path and name.

Returns:

0 if successful.

Return type:

int

PVD generation

Generates a .pvd XML file to post-process surfaces function objects.

This script assembles the VTK files in separate time directories.

Example:

Run python script in case root directory:

$ python generate_pvd.py

Todo:
  • None

phase.generate_pvd.create_xml(surface='zNormal', file_format='vtp')

Create <surface>.pvd file with existing VTK files.

Parameters:
  • surface (str) – Surface of vtk/vtp files.

  • file_format (str) – vtp or vtk.

Returns:

0 if successful.

Return type:

int

phase.generate_pvd.write_pvd(surfaces=('zNormal',))

Write PVD files for requested slices.

Phase contour

Plots the crystal and under-cooling.

This script plots the phase field contour using the output in the postProcessing directory.

Example:

Run python script in case root directory:

$ python3 plot.py

Todo:
  • None

phase.plot.load_slice(filename)

Read field from .vtp file.

Parameters:

filename (str) – Filename of .vtp file, including path.

Returns:

A tuple containing points, triangulation and scalar field.

Return type:

tuple[numpy.array]

phase.plot.plot_crystal(image_name='Crystal.png', cmap='jet')

Plots crystal contour.

Parameters:
  • image_name (str) – Filename of image, including path.

  • cmap (str or matplotlib.colormaps) – Color map for plotting contour.

Returns:

0 if successful.

Return type:

int