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
- USDC.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
- USDC.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
- USDC.generate_pvd.create_xml(variable='U', surface='yNormal', file_format='vtp')¶
Create <variable>.pvd file with existing VTK files.
- Parameters
variable (str) – Name of field.
surface (str) – Surface of vtk/vtp files.
file_format (str) – vtp or vtk.
- Returns
0 if successful.
- Return type
int
Contour plots¶
Plots the pressure and jet profiles.
This script plots the acoustic pressure and jet profiles using the output in the postProcessing directory.
- Example:
Run python script in case root directory:
$ python3 plot_jet.py
- Todo:
None
- USDC.plot_jet.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]
- USDC.plot_jet.plot_jet(image_name='jet.png', pcmap='viridis', Ucmap='jet')¶
Plots acoustic pressure and velocity contours.
- Parameters
image_name (str) – Filename of image, including path.
pcmap (str or matplotlib.colormaps) – Color map for plotting P contour.
Ucmap (str or matplotlib.colormaps) – Color map for plotting U contour.
- Returns
0 if successful.
- Return type
int