mpyvisualize

This tool provides visualization capabilities for result files from CFD simulations.

The visualization includes:

  • Configurable slice plane orientation and position

  • Visualizes scalar fields, vector fields not supported yet

  • Optional switch from cell data to point data

  • Optional perspective view with adjustable angles

Usage

mpyvisualize [options] command [args ...] FIELD INPUT

Slice Command

The slice command extracts a 2D slice through a 3D VTK dataset and saves it as an image file. The slice plane is defined by an origin point and a normal vector.

The FIELD argument accepts a glob pattern (same syntax as shell wildcards). When the pattern matches multiple fields, one image is created per matched field and the field name is appended to the output file stem (e.g. slice.alpha.water.png, slice.alpha.air.png).

Examples

Basic Slice

Extract a slice through the mesh center with normal vector along the z-axis:

mpyvisualize slice alpha.water result.vtk

This creates slice.alpha.water.png with the alpha.water field, using cell data and a horizontal slice plane.

Field Selection with Wildcards

Create one image for every field whose name starts with alpha:

mpyvisualize slice "alpha*" result.vtk

This creates slice.alpha.water.png and slice.alpha.air.png (one file per matched field).

With --output the field name is appended to the given stem, e.g., to produce sliceA.alpha.water.png, sliceA.alpha.air.png:

mpyvisualize slice --output sliceA.png "alpha*" result.vtk

Custom Slice Plane and Output File

Define both the origin and normal vector:

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

Perspective View

Get a perspective view with mesh boundaries shown:

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

Visualizing Point Data

Use point data instead of the default cell data:

mpyvisualize slice alpha result.vtk --pointdata

Usage with Results from OpenFOAM Foundation Software

foamToVTK -latestTime

and

mpyvisualize slice alpha.water VTK/<filename>.vtk

Output

The tool generates image files with:

  • Viridis colormap applied to the field

  • Vertical color bar showing value range

  • 3D axes for orientation

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

It supports the following output formats:

  • PNG, JPEG, TIFF, BMP