© Ihor Mirzov, 2019-2024
Distributed under GNU General Public License v3.0
Downloads | How to use | Screenshots | Your help | For developers | TODO
Converts CalculiX ASCII .frd-file to view and postprocess analysis results in Paraview. Generates von Mises and principal components for stress and strain tensors.
Creates separate file for each output interval - it makes possible to animate time history. Caution! If you have 300 time steps in the FRD, there will be 300 Paraview files. If you need one file - write output only for one step in your CalculiX model.
Converter is tested on CalculiX examples. Here is how some test log looks like.
FRD reader is tested to reduce processing time as much as possible. Now it's quite optimized and fast, but Python itself is slower than C/C++. Here we can do nothing, so, for example, Calmed converter must be faster - another question is if it's able to read and convert any CalculiX results.
To install and run the latest release (version 3.1.0) of of this converter you'll need Python 3 and optionally pipx or conda:
pip install ccx2paraview
# or, with pipx:
pipx install ccx2paraview
# or, within a new conda environment:
conda create -n ccx2paraview_rel numpy paraview ccx2paraview
Hint! Installing paraview and ccx2paraview from the conda-forge channel can be achieved by adding conda-forge to your channels with:
conda config --add channels conda-forge
conda config --set channel_priority strict
Having installed ccx2paraview via pip or pipx, you'll need to either cd into the ccx2paraview-directory, or add it to your PATH. Then, run converter with command (both in Linux and in Windows):
python ccx2paraview.py yourjobname.frd vtk
python ccx2paraview.py yourjobname.frd vtu
Also you can pass both formats to convert .frd to .vtk and .vtu at once.
Using the conda environment as described above, an additional binary is provided (thanks to conda-forge's package). Activate the conda-environment first:
conda activate ccx2paraview_rel
Then, run converter from the python source as described above or use the provided binary:
ccx2paraview yourjobname.frd vtk
ccx2paraview yourjobname.frd vtu
To use the current release of ccx2paraview in your python code:
import logging
import ccx2paraview.ccx2paraview
logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s')
c = ccx2paraview.ccx2paraview.Converter(frd_file_name, ['vtu'])
c.run()
Please, pay attention that .frd-file type should be ASCII, not binary! Use keywords *NODE FILE, *EL FILE and *CONTACT FILE in your INP model to get results in ASCII format.
It is recommended to convert .frd to modern XML .vtu format - its contents are compressed. If you have more than one time step there will be additional XML file created - the PVD file. Open it in Paraview to read data from all time steps (all VTU files) at ones.
Starting from ccx2paraview v3.0.0 legacy .vtk format is also fully supported - previously there were problems with component names.
Attention! While developing this converter I'm using latest Python3, latest VTK and latest ParaView. If you have problems with opening conversion results in ParaView - update it.
Hint! When using the conda environment, a working version of ParaView should be available in the environment already.
Installation of the latest release via pip was tested with a fresh install of:
- Python 3.8: will install ccx2paraview v3.0.0
- Python 3.9: will install ccx2paraview v3.0.0
- Python 3.10: works!
- Python 3.11: works!
- Python 3.11: works!
- Python 3.12: works - but will provoke SyntaxWarning: invalid escape sequence
- Python 3.13: won't work - numpy-vtk incompatibility
Using a conda-environment:
- Python 3.12: works!
conda create -n ccx2paraview_rel python=3.12 numpy paraview ccx2paraview
- Python 3.13: works - but will provoke SyntaxWarning: invalid escape sequence
conda create -n ccx2paraview_rel numpy paraview ccx2paraview
A snippet for Paraview programmable filter to convert 6 components data array to full tensor:
import numpy as np
res = np.array([])
pd = inputs[0].PointData['S']
for xx,yy,zz,xy,yz,xz in pd:
t = np.array([[xx,xy,xz],[xy,yy,yz],[xz,yz,zz]])
res = np.append(res, t)
tensor = dsa.VTKArray(res)
tensor.shape = (len(pd), 3, 3)
output.PointData.append(tensor, 'S_tensor')
A snippet for Paraview programmable filter to calculate eigenvalues and eigenvectors:
import numpy as np
eigenvalues = np.array([])
eigenvectors = np.array([])
pd = inputs[0].PointData['S']
for xx,yy,zz,xy,yz,xz in pd:
t = np.array([[xx,xy,xz],[xy,yy,yz],[xz,yz,zz]])
w, v = np.linalg.eig(t)
w_ = np.absolute(w).tolist()
i = w_.index(max(w_))
eigenvalues = np.append(eigenvalues, w[i]) # max abs eigenvalue
eigenvectors = np.append(eigenvectors, v[i]) # max principal vector
eigenvectors = dsa.VTKArray(eigenvectors)
eigenvalues = dsa.VTKArray(eigenvalues)
eigenvectors.shape = (len(pd), 3)
eigenvalues.shape = (len(pd), 1)
output.PointData.append(eigenvectors, 'S_max_principal_vectors')
output.PointData.append(eigenvalues, 'S_max_eigenvalues')
To install this converter from github you'll need Python 3 and optionally conda:
# install vtk first
pip install vtk
pip install git+https://github.com/calculix/ccx2paraview.git
# or, with conda (paraview has vtk, so no need to install it seprately):
conda create -n ccx2paraview_devel python=3.12 numpy paraview
conda activate ccx2paraview_devel
pip install git+https://github.com/calculix/ccx2paraview.git
Attention! Currently, installing vtk via pip seems to break ParaView's pvpython. When using the conda environment, ParaView's included vtk will be used (alongside having a working ParaView in the environment).
Run converter with command:
ccx2paraview yourjobname.frd vtk
ccx2paraview yourjobname.frd vtu
Also you can pass both formats to convert .frd to .vtk and .vtu at once.
There are also the following aliases for converting files to a fixed format
ccxToVTK yourjobname.frd
ccxToVTU yourjobname.frd
To use the development version of ccx2paraview in your python code:
import logging
from ccx2paraview.common import Converter
logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s')
c = Converter(frd_file_name, ['vtu'])
c.run()
Converted von Mises stress field with Turbo colormap:
Converted translations field with Viridis colormap:
Please, you may:
- Star this project.
- Simply use this software and ask questions.
- Share your models and screenshots.
- Report problems by posting issues.
- Do something from the TODO-list as a developer.
- Or even become a sponsor to me.
To install and use ccx2paraview-package: see above.
The binaries are created automatically when installing with pip from github via the project scripts in pyproject.toml:
[project.scripts]
ccx2paraview = "ccx2paraview.cli:main"
ccxToVTK = "ccx2paraview.cli:ccx_to_vtk"
ccxToVTU = "ccx2paraview.cli:ccx_to_vtu"
If you have Python version >= 3.8 create binary with nuitka:
pip3 install nuitka
In Windows:
set CC=C:\\MinGW64\\mingw64\\bin\\gcc.exe
python3 -m nuitka --follow-imports --python-flags=-m ccx2paraview
In Linux:
python3 -m nuitka --follow-imports --python-flags=-m ccx2paraview
If you have Python version < 3.8 create binary with pyinstaller:
pip3 install pyinstaller
pyinstaller __init__.py --onefile
Read how to create packages for pypi.org:
python3 -m pip install --upgrade build twine
python3 -m build
python3 -m twine upload dist/*
Read about VTK file formats and VTK unstructured grid. Remember that FRD file is node based, so element results are also stored at nodes after extrapolation from the integration points.
Test CALMED binary.
Log memory consumption.
Read binary .frd files: https://github.com/wr1/frd2vtu
Read DAT files: it would be a killer feature if Paraview could visualize results in Gauss points. Use CCXStressReader.
Contribute to meshio. FRD writer. Use meshio XDMF writer: #6
Add element’s material tangent stiffness tensor. Easiest for the paraview user would be to provide it in the (deflected) global cartesian frame. This dataset is useful for checking input data for anisotropic materials, as well as for the stuff with inverse design of fields of this tensor. But it’s a lot more work to produce, especially with nonlinear materials. It’s almost as useful to see the highest principal value of the stiffness, as a scalar or a vector. (but for the vector you need to do the transformation)