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 FRDReader for set array naming.

Returns:

The mesh, with the chosen step’s arrays as point data.

Return type:

pyvista.UnstructuredGrid

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 and ELSET:<NAME> cell arrays. No deck is loaded automatically. IDs absent from the FRD mesh are omitted from masks. Named surfaces are available through read_surface() and read_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:

INPSets

Warns:

pyvista.InvalidMeshWarning – Emitted during construction for an invalid node count or unsupported element type.

Parameters:

Examples

>>> import pyvista_frd
>>> reader = pyvista_frd.FRDReader('mesh.frd')
>>> reader.time_values
[0.5, 1.0]
>>> mesh = reader.read()
property number_time_points: int#

Return the total number of time points.

time_point_value(time_point)[source]#

Return the time value associated with the given time point.

Parameters:

time_point (int)

Return type:

float

property time_values: list[float]#

Return the list of available time values.

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_ids and every array of the active step attached as point data. Node IDs use int32 when all values fit, otherwise int64.

Return type:

pyvista.UnstructuredGrid

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 use NODE:NAME or ELEMENT: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_ids and surface_face_labels as cell data. Quadratic faces retain their midside nodes and VTK cell types.

Return type:

pyvista.UnstructuredGrid

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.

missing has the same meaning as in read_surface().

Parameters:

missing (str)

Return type:

MultiBlock

Input-deck sets and surfaces#

pyvista_frd.read_sets(path)[source]#

Read sets and named surfaces from a CalculiX .inp file.

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:

INPSets

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 *SURFACE definitions. 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 UNSORTED is not preserved: these sets describe membership, not constraint or equation ordering.

surfaces maps uppercase names to INPSurface definitions. When NODE and ELEMENT surfaces share a name, their keys are qualified as NODE:NAME and ELEMENT:NAME. element_types maps original element IDs to uppercase *ELEMENT, TYPE=... declarations, including elements without an ELSET; these distinguish shell, plane, beam, and solid faces.

Parameters:
class pyvista_frd.INPSurface(kind, node_ids=(), element_faces=())[source]#

A named surface’s original IDs, independent of an FRD output mesh.

kind is 'NODE' or 'ELEMENT'. Nodal surfaces hold node_ids; element surfaces hold (element_id, face_label) pairs in element_faces. Membership is deduplicated and sorted. Face labels use CalculiX input numbering, not VTK face indices.

Parameters:

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 False for 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 binary is omitted, each block keeps its input encoding. Set it to False to 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#

class pyvista_frd.Diagnostic(kind, element_type, line, n_expected, n_actual)[source]#

One questionable element, as the parser saw it.

Parameters:
  • kind (int)

  • element_type (int)

  • line (int)

  • n_expected (int | None)

  • n_actual (int | None)

class pyvista_frd.DiagnosticKind[source]#

Why an element was reported as questionable.

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.

Parameters:
Return type:

None

exception pyvista_frd.FRDFormatError(status, detail='')[source]#

The bytes were not a readable FRD document.

Parameters:
Return type:

None

exception pyvista_frd.FRDRaggedArrayError(status, detail='')[source]#

One result block contains inconsistent component counts.

Parameters:
Return type:

None

exception pyvista_frd.FRDRangeError(status, detail='')[source]#

A step, array or element index was out of range.

Parameters:
Return type:

None

exception pyvista_frd.FRDInvalidArgumentError(status, detail='')[source]#

An argument the native core rejected.

Parameters:
Return type:

None

exception pyvista_frd.FRDMemoryError(status, detail='')[source]#

The native core could not allocate.

Parameters:
Return type:

None

exception pyvista_frd.FRDInternalError(status, detail='')[source]#

The native library failed independently of the input file.

Parameters:
Return type:

None

exception pyvista_frd.NativeUnavailableError[source]#

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 -1 record. The names are what the reference reader prints in its warnings, so they are message text rather than an internal table – PY5 and PY13 are CalculiX’s experimental pyramids, C3D5 and C3D13.

pyvista_frd._capi.ABI_VERSION = 3#

ABI this binding speaks. A library reporting anything else is refused.

pyvista_frd.library_path()[source]#

Return the file the native core was loaded from.

Return type:

str

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:
classmethod from_bytes(data, *, wedge_order=0)[source]#

Open a document already in memory, without a temporary file.

Parameters:
Return type:

NativeFile

close()[source]#

Release the document. Idempotent.

Return type:

None

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.

Parameters:

step (int)

Return type:

list[tuple[str, int, int]]

array(step, index)[source]#

Return array index of step, shaped (n_points,) or 2-D.

Parameters:
Return type:

NDArray[np.float64]

property steps_parsed: int#

Number of times a step’s values have been parsed.

The count is zero before any result is requested and increments once for each distinct parsed step.

find_array(step, name)[source]#

Index of name within step, or -1.

Parameters:
Return type:

int