mpyvisualize

This tool creates visualizations from CFD simulation result files and saves them as image files.

Usage

mpyvisualize [options] <subcommand> [subcommand-options]

Subcommands

slice - Slice Plot

This command reads a VTK file. In case it contains a 3D mesh, it extracts a 2D slice through the 3D domain and saves the visualization as an image file. In case the VTK file contains already a 2D mesh, it saves the visualization as an image file directly.

The field data can be extracted from either cell data or point data, or automatically determined (cell is preferred). FIELD accepts glob patterns; when the pattern matches multiple fields, one image is produced per matched field with the field name appended to the output stem (e.g. slice.alpha.water.png).

The slice plane is defined by an origin point and a normal vector. Normal view is used by default but can be switched to a perspective view, which makes the mesh outline visible and allows to set the camera angles. The colormap can be changed. Colormap range can be controlled.

mpyvisualize slice [options] FIELD INPUT

Options:

  • --output FILE - Output image file path (default: slice.<field>.png)

  • --normal VECTOR - Normal vector of the slice plane (default: (0,0,1))

  • --origin POINT - Origin point of the slice plane (default: mesh center)

  • --perspective / --no-perspective - Use perspective view instead of parallel projection (default: off)

  • --perspective-azimuth FLOAT - Camera azimuth angle in degrees (default: 15)

  • --perspective-elevation FLOAT - Camera elevation angle in degrees (default: 15)

  • --feature-edges / --no-feature-edges - Overlay mesh feature edges in black (default: on in perspective mode, off otherwise)

  • --color-map, --cmap NAME - Colormap name (default: Fast). Fast is a perceptually uniform colormap and the default in ParaView. Any matplotlib colormap is also accepted.

  • --color-limits, --clim MIN,MAX - Fix colormap range, e.g. [0,1] (default: auto-detected)

  • --size WIDTHxHEIGHT - Output image dimensions in pixels (default: 1024x768)

  • --font-size INT - Font size for axis labels and scalar bar (default: 12)

  • --scalarmapping - Set how scalars are mapped to the mesh. ‘auto’ checks cell data first, then point data.

Example:

mpyvisualize slice alpha.water result.vtk

Examples

Field Selection with Wildcards

mpyvisualize slice "alpha*" result.vtk

Custom Slice Plane

mpyvisualize slice alpha.water result.vtk \
    --origin "(0.5,0.5,0.5)" \
    --normal "(0,1,0)"

Perspective View with Feature Edges

mpyvisualize slice alpha.water result.vtk \
    --perspective \
    --perspective-azimuth 45 \
    --perspective-elevation 30 \
    --feature-edges

Fixed Color Limits

mpyvisualize slice alpha.water result.vtk --color-limits "[0,1]"

High-Resolution Output

mpyvisualize slice alpha.water result.vtk --size "1920x1080" --font-size 18

Usage with Results from OpenFOAM Foundation Software

foamToVTK -latestTime
mpyvisualize slice alpha.water VTK/<filename>.vtk

Supported File Formats

The tool supports all result file formats readable by PyVista:

  • Legacy VTK format (.vtk)

  • VTK XML formats (.vtu, .vtp, .vti, .vts, .vtr)

  • EnSight format (.case, .encas)

  • Plot3D format (.xyz, .q)

  • And many others supported by PyVista

Supported output image formats: PNG, JPEG, TIFF, BMP.