ibfoamrig.core.FieldData#

class ibfoamrig.core.FieldData(frame)[source]#

Bases: object

Cell values of one or more fields together with the cell centres.

Variables:

frame (polars.DataFrame) – One row per cell with columns cellI, x, y, z, and one column per field component.

classmethod from_file(path, *, fields=None)[source]#

Loads a table written by a function object.

Parameters:
  • path (StrPath) – Path to the table.

  • fields (Sequence[str] | None) – Field columns to keep. The cell index and centres are always kept. If None, all columns are loaded.

Returns:

The loaded field data.

Raises:
Return type:

Self

classmethod from_fields(centres, fields, volumes=None)[source]#

Builds field data from OpenFOAM field files.

Vector and tensor fields are split into one column per component, e.g. U into Ux, Uy, Uz. Uniform fields are expanded to all cells.

Parameters:
  • centres (FoamField) – Cell centres, written by postProcess -func writeCellCentres.

  • fields (Iterable[FoamField]) – The fields to include.

  • volumes (FoamField | None) – Cell volumes, written by postProcess -func writeCellVolumes. Optional.

Returns:

The field data, with cells in mesh order.

Raises:

ValueError – If centres is not a nonuniform vector field, a field does not match the number of cells, or two columns get the same name.

Return type:

Self

property fields: list[str]#

Names of the field columns, without geometric columns.

project_line(start, end, tol)[source]#

Selects cells whose centres lie within tol of a line segment.

Each cell is projected onto the segment. Two columns are added: s , the distance of the projection from start, and distance, the distance of the centre from the line. The values are the raw cell values.

Parameters:
  • start (Point) – First end point (x, y, z) of the segment.

  • end (Point) – Second end point (x, y, z) of the segment.

  • tol (float) – Largest distance from the line for a cell to be kept.

Returns:

The selected cells, sorted by s.

Raises:

ValueError – If start and end coincide or tol is not positive.

Return type:

Self

column(name)[source]#

Returns the values of one column.

Parameters:

name (str) – Name of the column.

Returns:

The column as a polars Series.

Raises:

KeyError – If the column does not exist.

Return type:

Series