Read a result file#

pyvista_frd.read() turns a CalculiX .frd file into a pyvista.UnstructuredGrid. Every nodal result in the file arrives as point data, and the mesh is ready to plot, clip, warp, or save in any format PyVista writes.

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 each example from its own directory; the decks and
# their solved output live one level up, in ``doc/_data``.
DATA = Path('../_data').resolve()

Reading is one call.

mesh = pyvista_frd.read(DATA / 'cantilever.frd')
mesh
UnstructuredGrid (0x7fd9443f0160)
  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


The arrays are named as CalculiX named them. DISP and STRESS came off the file; the _Mises and _PS* arrays are computed from the stress tensor on the way through, matching what PyVista’s own reader appends.

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,)

Deflection under load, drawn on the deformed shape. The displacements are small, so pyvista.DataSetFilters.warp_by_vector() exaggerates them.

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

Nothing about the result is special to this package once it is read. It is an ordinary PyVista mesh, so the usual filters apply.

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 6.395 seconds)

Gallery generated by Sphinx-Gallery