pymech.vtksuite

This Python module contains one routine to convert from pymech.core.HexaData to a VTK object.

Warning

The module is experimental in nature and may have some rough edges.


Contents of vtksuite.py

Module for converting pymech.core.HexaData objects to vtk

pymech.vtksuite.hexa2vtk(field, downsample=False)[source]

A function for converting pymech.core.HexaData to Traited VTK dataset. The returned dataset can be manipulated with libraries which accept a VTK object, for example Mayavi.

Example

This also requires you to have a GUI toolkit installed: either PyQt4, PySide, PySide2, PyQt5 or wxPython.

import pymech as pm
from pymech.vtksuite import hexa2vtk
from mayavi import mlab

field = pm.readnek("tests/nek/channel3D_0.f00001")
dataset = hexa2vtk(field)
mlab.pipeline.add_dataset(dataset)

Instead of MayaVi you could use also use something high-level like PyVista to wrap the underlying VTK object and later visualize them.

import pyvista as pv
dataset = pv.wrap(dataset._vtk_obj)
dataset.plot()
Parameters:
Returns:

dataset – a VTK dataset

Return type:

tvtk.tvtk_classes.unstructured_grid.UnstructuredGrid

pymech.vtksuite.writevtk(fname, data)[source]

A function for writing binary data in the XML VTK format

Parameters: