Skip to main content

Read CalculiX FRD result files. The parser is C++ behind a plain C ABI, so the same implementation serves Python, C++, and anything else with a foreign-function interface — and the Python side turns what it produced into a pyvista.UnstructuredGrid.

import pyvista_frd

mesh = pyvista_frd.read("mesh.frd")
mesh.plot(scalars="STRESS_Mises")

Time steps work the way PyVista’s reader does:

reader = pyvista_frd.FRDReader("mesh.frd")
reader.time_values          # [0.5, 1.0]
reader.set_active_time_value(1.0)
mesh = reader.read()

Installation

pip install pyvista-frd-reader

Wheels are published for Linux (x86_64 and aarch64), macOS (Intel and Apple silicon) and Windows. They contain a compiled library and no CPython extension module, so one wheel per platform serves every supported interpreter.

The Linux wheels are manylinux_2_28, meaning glibc 2.28 or newer – RHEL 8, Debian 10, Ubuntu 20.04 and later. That floor comes from NumPy and VTK, not from this package: the core needs only C++17, but a wheel tagged for an older glibc than its own dependencies can be installed on would promise something that does not work.

Installing from source needs CMake and a C++17 compiler: there is no pure-Python fallback, because a reader that silently falls back is indistinguishable from one that works until someone measures it.

What it reads

Element types HE8, PE6, PE15, TE4, HE20, TE10, TR3, TR6, QU4, QU8, BE2, BE3, PY5 and PY13 — the last two being CalculiX’s experimental pyramids, C3D5 and C3D13. Both the short and long element-record formats are handled, including the case CalculiX produces past 9999 nodes, where the node ids in a record run together with no separator at all.

All four encodings, which is a block header’s last field: the two ASCII widths and the two binary ones, float32 and float64. Binary FRD is what CalculiX writes from *REFINE MESH and from a DOUBLE output card, and PyVista’s reader cannot open it — it parses FRD as text, so a binary file returns an empty mesh or an error. See doc/binary.md.

For any 6-component tensor whose name contains STRESS or STRAIN, the reader appends the derived arrays PyVista’s reader appends:

  • <NAME>_Mises — equivalent von Mises magnitude

  • <NAME>_sgMises — signed by the trace

  • <NAME>_PS1, _PS2, _PS3 — principal values, largest first

Elements with the wrong number of nodes, or a type nothing recognises, raise pyvista.InvalidMeshWarning naming the line they were found on.

The grid’s cell arrays are handed to VTK in 32-bit storage whenever the mesh fits in it, which is any file short of two billion connectivity entries. vtkCellArray keeps the width it is given, so that halves what the mesh costs to hold for as long as it is held. Points stay float64.

What it writes

The same four encodings.

import pyvista_frd

mesh = pyvista_frd.read("result.frd")
pyvista_frd.write("copy.frd", mesh)                # ASCII, six digits
pyvista_frd.write("small.frd", mesh, binary=True)  # a third of the size, exact

# Or convert without going through a mesh. A binary file that no ASCII-only
# reader can open becomes one any of them can.
pyvista_frd.convert("binary.frd", "ascii.frd", binary=False)

The writer is graded on reproducing CalculiX’s bytes, not on agreeing with this library’s own reader: a document read and emitted again is the input byte for byte, over 1,111 external FRD files. That gate turned up a second dialect of the format shipped with CalculiX GraphiX, and the fact that CalculiX renders its ASCII values through single precision – which this library deliberately does not, so a converted file carries the full double and differs from CalculiX’s own text at a rounding tie. Separately, CalculiX itself reads files this library writes and produces byte-identical results from them. The method and its limits are in doc/writing.md.

Speed

Not why this exists – multi-language reuse is – but the question follows the language, so it is measured rather than asserted. Against PyVista’s reader, reading the same file to the same grid:

file

pyvista_frd

pyvista

ratio

mesh.frd (0.14 MB)

3.12 ms

8.13 ms

2.6x

synthetic (12.8 MB)

82.4 ms

534 ms

6.5x

Medians of interleaved runs on one workstation. Treat the ratio as indicative and the absolute figures as a property of that machine – benchmarks/read_speed.py reproduces both, and interleaves the two arms rather than running one after the other, because a machine that drifts mid-run otherwise charges the drift to whichever arm was unlucky.

The ratio grows with file size because both readers pay the same fixed cost to build the VTK grid at the end; only the parse differs. On a small file that fixed cost is most of the work.

Two files is a spot check, not a measurement. Over CalculiX’s own regression suite – 839 files, 125 MB, both readers driven to the same end state – the aggregate is 7.42x, the median file is 5.49x, and the spread runs from 0.83x on a tiny file to 37.67x on a small one with many time steps. Those numbers, and the reason the naive comparison flatters this library, are in doc/parity.md.

Parity

This reader is graded against PyVista’s, file by file and array by array. As well as the fixture corpus in tests/, it has been swept over 1,766 FRD files this project did not write – CalculiX’s regression suite, solved, plus every .frd GitHub’s code search will return – with no divergences. One of those files is binary and only this library can read it, which is counted as its own verdict rather than as an agreement. The method, the findings, and an explicit account of what the sweep does not establish are in doc/parity.md. Deliberate differences from PyVista are listed in doc/divergences.md.

Credit

The FRD reader this library reimplements was written by Rafal (@3rav) in pyvista#8255, and every behavioural decision reproduced here is one he made first. His reader is vendored unchanged as the oracle this project is tested against. The format itself is CalculiX’s, by Guido Dhondt and Klaus Wittig. See doc/history.md for the full lineage and licensing.

Relationship to PyVista’s reader

PyVista ships its own .frd reader, written in Python. This package is a reimplementation of it, and agreement with it is the claim being made: the conformance suite compares every array of every file in the corpus against PyVista’s own parser, bit for bit, and the exceptions are listed in doc/divergences.md with the test that pins each one.

This package deliberately does not register itself as PyVista’s .frd handler. Doing so today would make pv.read use this reader while pv.get_reader kept the built-in — two readers for one extension, differing by which call the user made. Overriding it properly is a follow-up.

Using it from C++

The core builds standalone and installs a header and a library:

cmake -S cpp -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build

cpp/include/pvfrd/pvfrd.h is the whole public surface. It is plain C with no C++ types crossing the boundary:

#include <pvfrd/pvfrd.h>

pvfrd_file *file = NULL;
if (pvfrd_open("mesh.frd", &file) != PVFRD_OK) { /* handle it */ }

const double *points = pvfrd_points(file);
uint64_t n_points = pvfrd_n_points(file);

int64_t index = pvfrd_find_array(file, /* step */ 0, "STRESS_Mises");
const double *mises = NULL;
pvfrd_array_data(file, 0, index, &mises);

pvfrd_close(file);

Linking against the shared library needs nothing else. Linking against the static one needs the C++ runtime and libm named explicitly – -lstdc++ -lm on GCC and Clang – because a static archive carries no link dependencies of its own. CI compiles and links the example above on every push, so if it is wrong here it is wrong in a way that reddens a build.

Opening a file parses the mesh and indexes the result blocks; a step’s values are parsed when that step is first asked for, so reading one time step of a many-step file does not pay for the rest. pvfrd_open_memory takes bytes you already have, for callers holding the file in an archive or an HTTP response.

Development

cmake -S cpp -B cpp/build -DPVFRD_BUILD_TESTS=ON
cmake --build cpp/build
./cpp/build/pvfrd_tests                      # the C++ tier

pip install -e .[tests]
pytest                                       # conformance against PyVista

Both tiers read the same fixture corpus under tests/fixtures/.

tools/mutate.py breaks the C++ on purpose — twenty-one plausible mistakes, one at a time — and checks that the suite reddens for each. A green suite has two explanations, and that script is what tells them apart. It is also how the corpus grew: two mutants survived the first sweep, and the files that now catch them were written in response.

Releasing

Tag it. doc/releasing.md covers the one-time PyPI setup and what the pipeline checks before it will publish.

License

MIT. The vendored fast_float header under cpp/third_party/ is Apache-2.0 / MIT / BSL at your option.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyvista_frd_reader-0.2.0.tar.gz (328.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyvista_frd_reader-0.2.0-py3-none-win_amd64.whl (128.6 kB view details)

Uploaded Python 3Windows x86-64

pyvista_frd_reader-0.2.0-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (147.1 kB view details)

Uploaded Python 3manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

pyvista_frd_reader-0.2.0-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (134.3 kB view details)

Uploaded Python 3manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

pyvista_frd_reader-0.2.0-py3-none-macosx_11_0_arm64.whl (116.2 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

pyvista_frd_reader-0.2.0-py3-none-macosx_10_15_x86_64.whl (124.9 kB view details)

Uploaded Python 3macOS 10.15+ x86-64

File details

Details for the file pyvista_frd_reader-0.2.0.tar.gz.

File metadata

  • Download URL: pyvista_frd_reader-0.2.0.tar.gz
  • Upload date:
  • Size: 328.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pyvista_frd_reader-0.2.0.tar.gz
Algorithm Hash digest
SHA256 471683450d1ac3eae6ba70bba9522970c3f3681aaea50ef5f6dcd5293b8bbeb0
MD5 605b34cdc5770cbff968bcf520b1c664
BLAKE2b-256 197a710c0b13bc8ad91ad7d35a41bca5961ee287b6a6a891ca851720626c2d12

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvista_frd_reader-0.2.0.tar.gz:

Publisher: native.yml on pyvista/pyvista-frd-reader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvista_frd_reader-0.2.0-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for pyvista_frd_reader-0.2.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 2c1dbda2d54b4835b4ac4def5d65dd59c7d12c510e7f17963fc4cdf2f1771b63
MD5 fd75a42a77e85f2bb5bfad3d684957f6
BLAKE2b-256 862e7cfa2e2b3f0d96238318b7232ce362cad38a7dcfe5c186631a8d3bd2cd5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvista_frd_reader-0.2.0-py3-none-win_amd64.whl:

Publisher: native.yml on pyvista/pyvista-frd-reader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvista_frd_reader-0.2.0-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyvista_frd_reader-0.2.0-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7e5a3bf314f71abab87411d80138b78b3448b549c8743f575ef3fce2732df2de
MD5 76131626fd57981ea95a24440a7580e8
BLAKE2b-256 3c441b5dae785c4097039b7f6dd6bb7e6decefed8b694611668d2a23a1a6fc16

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvista_frd_reader-0.2.0-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: native.yml on pyvista/pyvista-frd-reader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvista_frd_reader-0.2.0-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pyvista_frd_reader-0.2.0-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 79f48400bba492dfcaa50187d30c970ccb9e7c363ac378afcef42da79872eb28
MD5 587ba79fad3786ff2c5042c54fb0e0ce
BLAKE2b-256 c156c59c275eafa30ffc86e50bdbf5cd1856c1cacfbe39a0ec6f80de0ba0c30c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvista_frd_reader-0.2.0-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl:

Publisher: native.yml on pyvista/pyvista-frd-reader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvista_frd_reader-0.2.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyvista_frd_reader-0.2.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 31adc4fd670c3e14e9a6539ec469eaa5101d684b974d46b0ed393a823ca9df37
MD5 625d52ea68647b5f02944502912cb814
BLAKE2b-256 b6a61f1bdd06dd6fa82f11f4327a3f72d8cf624c874c0f170fd61a1f73f123e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvista_frd_reader-0.2.0-py3-none-macosx_11_0_arm64.whl:

Publisher: native.yml on pyvista/pyvista-frd-reader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvista_frd_reader-0.2.0-py3-none-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for pyvista_frd_reader-0.2.0-py3-none-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 459730fc30d40a486dd359a97ae528ae7d08d68d55cdfe42fd7c0afa049cce46
MD5 79c3adfd70193b7c0488bb4fce0397bd
BLAKE2b-256 77d16ea56144c379fd5c3f705a5620fd825fb7dbe6802e6c99678f289e54e774

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvista_frd_reader-0.2.0-py3-none-macosx_10_15_x86_64.whl:

Publisher: native.yml on pyvista/pyvista-frd-reader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.2.1

6 files

This release

0.2.0 This release

6 files

0.1.0

6 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page