Python API#
Everything below is importable from the top-level pyvista_frd package.
Reading#
- pyvista_frd.read(path, *, time_point=None, inp_path=None)[source]#
Read an FRD file into a
pyvista.UnstructuredGrid.- Parameters:
path (str | os.PathLike) – File to read.
time_point (int, optional) – Time step to read. Defaults to the first step.
inp_path (str | os.PathLike, optional) – Companion input deck; see
FRDReaderfor set array naming.
- Returns:
The mesh, with the chosen step’s arrays as point data.
- Return type:
Examples
>>> import pyvista_frd >>> mesh = pyvista_frd.read('mesh.frd')
- class pyvista_frd.FRDReader(path, *, inp_path=None)[source]#
Reader for CalculiX FRD result files (
.frd).Reads both ASCII encodings and both binary encodings. Supported element types are HE8, PE6, PE15, TE4, HE20, TE10, TR3, TR6, QU4, QU8, BE2, BE3, PY5 and PY13.
For each six-component STRESS or STRAIN tensor, the reader adds:
<NAME>_Mises: equivalent von Mises magnitude.<NAME>_sgMises: signed von Mises magnitude.<NAME>_PS1,_PS2,_PS3: principal components, largest first.
- Parameters:
path (str | os.PathLike) – File to read.
inp_path (str | os.PathLike, optional) – Companion input deck. When supplied, add boolean
NSET:<NAME>point arrays andELSET:<NAME>cell arrays. No deck is loaded automatically. IDs absent from the FRD mesh are omitted from masks. Named surfaces are available throughread_surface()andread_surfaces(); their missing-ID policy is explicit.
- sets#
Original set/surface memberships and element types from the input deck. Empty when no input deck was supplied.
- Type:
- Warns:
pyvista.InvalidMeshWarning – Emitted during construction for an invalid node count or unsupported element type.
- Parameters:
path (str | os.PathLike[str])
inp_path (str | os.PathLike[str] | None)
Examples
>>> import pyvista_frd >>> reader = pyvista_frd.FRDReader('mesh.frd') >>> reader.time_values [0.5, 1.0] >>> mesh = reader.read()
- set_active_time_point(time_point)[source]#
Set the active time point.
- Parameters:
time_point (int)
- Return type:
None
- set_active_time_value(time_value)[source]#
Set the active time value. An exact match is required.
- Parameters:
time_value (float)
- Return type:
None
- property active_time_value: float#
Return the currently active time value, or 0.0 if there are none.
- read()[source]#
Build the mesh for the active time step.
- Returns:
Mesh with
original_node_idsand every array of the active step attached as point data. Node IDs useint32when all values fit, otherwiseint64.- Return type:
- property surface_names: list[str]#
Return uppercase surface names, qualified by kind when names overlap.
- read_surface(name, *, missing='raise')[source]#
Read a named surface with results from the active time step.
- Parameters:
name (str) – Case-insensitive key from
surface_names. Shared names useNODE:NAMEorELEMENT:NAME.missing (str, default: 'raise') – Raise for IDs absent from the FRD mesh. With
'warn', report and omit those IDs, recording them in output field data. Invalid or unsupported face mappings always raise.
- Returns:
Face/edge elements, or vertices for a nodal surface. Point arrays are copied from the current result step. Element faces retain
original_element_idsandsurface_face_labelsas cell data. Quadratic faces retain their midside nodes and VTK cell types.- Return type:
Notes
The companion deck must explicitly define the surface. Extraction includes internal faces and uses original FRD IDs, not array indices. Nodal surfaces are vertices, with no inferred polygon connectivity. No result interpolation, averaging, or deformation is performed. Returned coordinates and result arrays have independent storage.
- read_surfaces(*, missing='raise')[source]#
Read every named surface into a MultiBlock at the active time step.
missinghas the same meaning as inread_surface().- Parameters:
missing (str)
- Return type:
Input-deck sets and surfaces#
- pyvista_frd.read_sets(path)[source]#
Read sets and named surfaces from a CalculiX
.inpfile.- Parameters:
path (str | os.PathLike) – Input deck. Relative
*INCLUDE, INPUT=...paths are resolved from this file’s directory, the CalculiX job directory.- Returns:
Sets, surfaces, and element types expressed using original IDs.
- Return type:
- Raises:
ValueError – Invalid set or surface syntax, an undefined reference, an include cycle, or unsupported assembly or set-generation syntax.
OSError – The deck or an included file cannot be opened.
Notes
Supports
*NSET,*ELSET,GENERATE, references to earlier sets, repeated definitions,*NODE, NSET=...,*ELEMENT, ELSET=..., and nested*INCLUDE. References copy membership at the point of use. Also reads NODE and ELEMENT*SURFACEdefinitions. Other analysis keywords are ignored. Abaqus part/instance namespaces, and sets created by mesh-generation keywords are unsupported.Examples
>>> import pyvista_frd >>> sets = pyvista_frd.read_sets('model.inp') >>> fixed_ids = sets.node_sets['FIXED']
- class pyvista_frd.INPSets(node_sets=<factory>, element_sets=<factory>, surfaces=<factory>, element_types=<factory>)[source]#
Original set and surface membership from an input deck.
Names are normalized to uppercase. Arrays contain sorted, unique int64 IDs, including IDs absent from an FRD output mesh. Node and element sets have separate namespaces. Ordering such as
UNSORTEDis not preserved: these sets describe membership, not constraint or equation ordering.surfacesmaps uppercase names toINPSurfacedefinitions. When NODE and ELEMENT surfaces share a name, their keys are qualified asNODE:NAMEandELEMENT:NAME.element_typesmaps original element IDs to uppercase*ELEMENT, TYPE=...declarations, including elements without an ELSET; these distinguish shell, plane, beam, and solid faces.
- class pyvista_frd.INPSurface(kind, node_ids=(), element_faces=())[source]#
A named surface’s original IDs, independent of an FRD output mesh.
kindis'NODE'or'ELEMENT'. Nodal surfaces holdnode_ids; element surfaces hold(element_id, face_label)pairs inelement_faces. Membership is deduplicated and sorted. Face labels use CalculiX input numbering, not VTK face indices.
Writing#
- pyvista_frd.write(path, mesh, *, binary=False, double=True, time=1.0, step=1)[source]#
Write a mesh and its point data to a CalculiX FRD file.
- Parameters:
path (str | os.PathLike) – File to write.
mesh (pyvista.UnstructuredGrid) – Mesh to write. Every cell type must have a CalculiX element code.
binary (bool, default: False) – Write binary records. ASCII records are used by default.
double (bool, default: True) – Use 64-bit binary values. Set to
Falsefor 32-bit binary values.time (float and int) – The time value and step number recorded in the result block header.
step (float and int) – The time value and step number recorded in the result block header.
- Return type:
None
Notes
Point data is written; cell data is not. An array that is neither a scalar, three-component vector, nor six-component tensor is written with a scalar kind code and its own component names.
The output identifies this package as its writer rather than CalculiX.
Examples
>>> import pyvista_frd >>> pyvista_frd.write('out.frd', mesh)
- pyvista_frd.convert(source, target, *, binary=None, double=True)[source]#
Rewrite an FRD file, optionally changing its encoding.
If
binaryis omitted, each block keeps its input encoding. Set it toFalseto make binary records available to ASCII-only readers. ASCII output stores six significant digits.- Raises:
FRDFormatError – If a block has no format code and cannot be converted safely.
- Parameters:
- Return type:
None
Examples
>>> import pyvista_frd >>> pyvista_frd.convert('binary.frd', 'ascii.frd', binary=False)
Diagnostics#
Errors#
Native-library exceptions inherit from FRDError and the corresponding
built-in exception. For example, FRDFormatError is also a
ValueError.
- exception pyvista_frd.FRDError(status, detail='')[source]#
Base class for errors reported by the native library.
Subclasses also inherit the corresponding built-in Python exception.
- exception pyvista_frd.FRDFormatError(status, detail='')[source]#
The bytes were not a readable FRD document.
- exception pyvista_frd.FRDRaggedArrayError(status, detail='')[source]#
One result block contains inconsistent component counts.
- exception pyvista_frd.FRDRangeError(status, detail='')[source]#
A step, array or element index was out of range.
- exception pyvista_frd.FRDInvalidArgumentError(status, detail='')[source]#
An argument the native core rejected.
- exception pyvista_frd.FRDMemoryError(status, detail='')[source]#
The native core could not allocate.
- exception pyvista_frd.FRDInternalError(status, detail='')[source]#
The native library failed independently of the input file.
The native library could not be loaded on this machine.
Constants#
These constants are importable from the top-level package.
- pyvista_frd.reader.ELEMENT_TYPE_NAMES#
CalculiX element codes and their names, keyed by the code an FRD file uses.
The code is the second field of an element’s
-1record. The names are what the reference reader prints in its warnings, so they are message text rather than an internal table –PY5andPY13are CalculiX’s experimental pyramids, C3D5 and C3D13.
- pyvista_frd._capi.ABI_VERSION = 3#
ABI this binding speaks. A library reporting anything else is refused.
Below the Python layer#
NativeFile provides NumPy arrays directly from the C API without
building a pyvista.UnstructuredGrid.
- class pyvista_frd.NativeFile(path, *, wedge_order=0)[source]#
An open FRD document.
Owns the native handle and copies returned buffers into NumPy arrays. This class does not construct PyVista objects.
- Parameters:
path (str | os.PathLike[str])
wedge_order (int)
- classmethod from_bytes(data, *, wedge_order=0)[source]#
Open a document already in memory, without a temporary file.
- Parameters:
- Return type:
- property cell_ids: NDArray[np.int64]#
Return original element IDs in mesh cell order; skipped cells are absent.
- array_infos(step)[source]#
Return
(name, n_components, kind)for every array in a step.Metadata for a step is fetched in one C API call.