Utilities

matengine.utils.plotting

matengine.utils.plotting.array_to_vtk(arr, fname='array_out')[source]

Save a 2D or 3D array as a VTK file for visualisation using PyVista.

Parameters:
arr: numpy.ndarray

The array to be saved as a VTK file. Can be 2D or 3D.

fname: str, optional

The name of the output VTK file (without extension). Default is ‘array_out’.

Notes:
  • For 2D arrays, the function creates a structured grid with zero height (z-dimension).

  • For 3D arrays, the function directly wraps the array as a PyVista grid.

matengine.utils.plotting.plot_array(arr, show=False)[source]

Plot a 2D array using matplotlib’s imshow function.

Parameters:
arr: numpy.ndarray

The 2D array to be plotted.

show: bool, optional

If True, displays the plot immediately. Default is False.