Read a result file#

pyvista_frd.read() returns a pyvista.UnstructuredGrid. Nodal results are stored as point data and work with standard PyVista filters.

The file here is a cantilever: 600 linear hexahedra fixed at one end and loaded at the other, solved by CalculiX 2.22.

from pathlib import Path

import pyvista as pv

import pyvista_frd

# Sphinx-Gallery runs this file from ``doc/examples``.
DATA = Path('../_data').resolve()

Read the first result step.

mesh = pyvista_frd.read(DATA / 'cantilever.frd')
mesh
UnstructuredGrid (0x7f9965d48100)
  N Cells:    600
  N Points:   900
  X Bounds:   0.000e+00, 1.500e+02
  Y Bounds:   0.000e+00, 2.000e+01
  Z Bounds:   0.000e+00, 2.000e+01
  N Arrays:   15


DISP and STRESS come from the file. The reader derives the _Mises and _PS* arrays from the stress tensor.

original_node_ids (900,)
DISP             (900, 3)
STRESS           (900, 6)
STRESS_Mises     (900,)
STRESS_sgMises   (900,)
STRESS_PS3       (900,)
STRESS_PS2       (900,)
STRESS_PS1       (900,)
TOSTRAIN         (900, 6)
TOSTRAIN_Mises   (900,)
TOSTRAIN_sgMises (900,)
TOSTRAIN_PS3     (900,)
TOSTRAIN_PS2     (900,)
TOSTRAIN_PS1     (900,)
ERROR            (900,)

Plot displacement on the deformed mesh. A factor of 200 makes the small displacement visible.

warped = mesh.warp_by_vector('DISP', factor=200)

pl = pv.Plotter(window_size=(1000, 380))
pl.add_mesh(warped, scalars='DISP', component=2, cmap='coolwarm', show_edges=True)
pl.add_mesh(mesh, style='wireframe', color='grey', opacity=0.3)
pl.camera.tight(padding=0.05, adjust_render_window=False, view='xz')
pl.show()
plot a quickstart

Apply a standard PyVista clip to the same mesh.

pl = pv.Plotter(window_size=(1000, 380))
pl.add_mesh(warped.clip('y'), scalars='STRESS_Mises', cmap='inferno', show_edges=True)
pl.camera.tight(padding=0.05, adjust_render_window=False, view='xz')
pl.show()
plot a quickstart

Total running time of the script: (0 minutes 2.370 seconds)

Gallery generated by Sphinx-Gallery