๐ท๏ธ Typing (foamlib.typing)๏
Standard types๏
The following are aliases of the primary types used throughout foamlib to represent the equivalent OpenFOAM data structures.
ๆณจ้
For concrete classes in foamlib that represent files and some stored data types (like foamlib.Dimensioned), see the foamlib.FoamFile section.
- foamlib.typing.SubDict: TypeAlias = dict[str, 'Data | SubDict | None'] | multicollections.MultiDict[str, 'Data | SubDict | None']๏
An OpenFOAM dictionary nested in a file.
- foamlib.typing.Data: TypeAlias = str | int | float | bool | foamlib._files.types.Dimensioned | foamlib._files.types.DimensionSet | list['DataEntry | KeywordEntry | Dict'] | numpy.ndarray[tuple[int] | tuple[int, typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating]] | tuple[str | int | float | bool | foamlib._files.types.Dimensioned | foamlib._files.types.DimensionSet | list['DataEntry | KeywordEntry | Dict'] | numpy.ndarray[tuple[int] | tuple[int, typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating]], str | int | float | bool | foamlib._files.types.Dimensioned | foamlib._files.types.DimensionSet | list['DataEntry | KeywordEntry | Dict'] | numpy.ndarray[tuple[int] | tuple[int, typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating]], typing.Unpack[tuple[str | int | float | bool | foamlib._files.types.Dimensioned | foamlib._files.types.DimensionSet | list['DataEntry | KeywordEntry | Dict'] | numpy.ndarray[tuple[int] | tuple[int, typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating]], ...]]]๏
A single OpenFOAM value, or multiple values as a tuple.
- foamlib.typing.StandaloneData: TypeAlias = str | int | float | bool | foamlib._files.types.Dimensioned | foamlib._files.types.DimensionSet | list['DataEntry | KeywordEntry | Dict'] | numpy.ndarray[tuple[int] | tuple[int, typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating]] | numpy.ndarray[tuple[int], numpy.dtype[numpy.int64 | numpy.int32 | numpy.float64]] | numpy.ndarray[tuple[int, typing.Literal[3]], numpy.dtype[numpy.float64 | numpy.float32]] | list[numpy.ndarray[tuple[typing.Literal[3, 4]], numpy.dtype[numpy.int64]]] | tuple[str | int | float | bool | foamlib._files.types.Dimensioned | foamlib._files.types.DimensionSet | list['DataEntry | KeywordEntry | Dict'] | numpy.ndarray[tuple[int] | tuple[int, typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating]] | numpy.ndarray[tuple[int], numpy.dtype[numpy.int64 | numpy.int32 | numpy.float64]] | numpy.ndarray[tuple[int, typing.Literal[3]], numpy.dtype[numpy.float64 | numpy.float32]] | list[numpy.ndarray[tuple[typing.Literal[3, 4]], numpy.dtype[numpy.int64]]], str | int | float | bool | foamlib._files.types.Dimensioned | foamlib._files.types.DimensionSet | list['DataEntry | KeywordEntry | Dict'] | numpy.ndarray[tuple[int] | tuple[int, typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating]] | numpy.ndarray[tuple[int], numpy.dtype[numpy.int64 | numpy.int32 | numpy.float64]] | numpy.ndarray[tuple[int, typing.Literal[3]], numpy.dtype[numpy.float64 | numpy.float32]] | list[numpy.ndarray[tuple[typing.Literal[3, 4]], numpy.dtype[numpy.int64]]], typing.Unpack[tuple[str | int | float | bool | foamlib._files.types.Dimensioned | foamlib._files.types.DimensionSet | list['DataEntry | KeywordEntry | Dict'] | numpy.ndarray[tuple[int] | tuple[int, typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating]] | numpy.ndarray[tuple[int], numpy.dtype[numpy.int64 | numpy.int32 | numpy.float64]] | numpy.ndarray[tuple[int, typing.Literal[3]], numpy.dtype[numpy.float64 | numpy.float32]] | list[numpy.ndarray[tuple[typing.Literal[3, 4]], numpy.dtype[numpy.int64]]], ...]]]๏
One or more OpenFOAM values that can appear at the top level of a file.
- foamlib.typing.DataEntry: TypeAlias = str | int | float | bool | foamlib._files.types.Dimensioned | foamlib._files.types.DimensionSet | list['DataEntry | KeywordEntry | Dict'] | numpy.ndarray[tuple[int] | tuple[int, typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating]]๏
A single OpenFOAM value.
- foamlib.typing.StandaloneDataEntry: TypeAlias = str | int | float | bool | foamlib._files.types.Dimensioned | foamlib._files.types.DimensionSet | list['DataEntry | KeywordEntry | Dict'] | numpy.ndarray[tuple[int] | tuple[int, typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating]] | numpy.ndarray[tuple[int], numpy.dtype[numpy.int64 | numpy.int32 | numpy.float64]] | numpy.ndarray[tuple[int, typing.Literal[3]], numpy.dtype[numpy.float64 | numpy.float32]] | list[numpy.ndarray[tuple[typing.Literal[3, 4]], numpy.dtype[numpy.int64]]]๏
A single OpenFOAM value that can appear at the top level of a file.
- foamlib.typing.Dict๏
An OpenFOAM dictionary.
dict[str, Data | Dict]ใฎๅฅๅใงใใ
- foamlib.typing.KeywordEntry๏
An OpenFOAM keyword entry (i.e., a key-value pair).
tuple[DataEntry, Data | Dict]ใฎๅฅๅใงใใ
- foamlib.typing.List๏
An OpenFOAM list.
list[DataEntry | KeywordEntry | Dict]ใฎๅฅๅใงใใ
- foamlib.typing.Field: TypeAlias = float | numpy.ndarray[tuple[int] | tuple[int, typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating]]๏
An OpenFOAM field of scalars, vectors, symmetric tensors, or full tensors.
- foamlib.typing.Tensor: TypeAlias = float | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.float64]]๏
An OpenFOAM scalar, vector, symmetric tensor, or full tensor.
Other accepted types๏
These "Like" type variants accept the standard type plus other formats that could potentially be converted to the standard type.
- foamlib.typing.SubDictLike๏
Any mapping that could be interpreted as a
SubDict.Mapping[str, DataLike | SubDictLike | None]ใฎๅฅๅใงใใ
- foamlib.typing.DataLike: TypeAlias = str | int | float | bool | foamlib._files.types.Dimensioned | foamlib._files.types.DimensionSet | list['DataEntry | KeywordEntry | Dict'] | numpy.ndarray[tuple[int] | tuple[int, typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating]] | numbers.Integral | numbers.Real | collections.abc.Sequence[int | float] | collections.abc.Sequence['DataEntryLike | KeywordEntryLike | DictLike'] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.float64]] | collections.abc.Sequence[float | numbers.Real] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating | numpy.integer]] | collections.abc.Sequence[float | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.float64]] | numbers.Real | collections.abc.Sequence[float | numbers.Real] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating | numpy.integer]]] | tuple[str | int | float | bool | foamlib._files.types.Dimensioned | foamlib._files.types.DimensionSet | list['DataEntry | KeywordEntry | Dict'] | numpy.ndarray[tuple[int] | tuple[int, typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating]] | numbers.Integral | numbers.Real | collections.abc.Sequence[int | float] | collections.abc.Sequence['DataEntryLike | KeywordEntryLike | DictLike'] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.float64]] | collections.abc.Sequence[float | numbers.Real] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating | numpy.integer]] | collections.abc.Sequence[float | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.float64]] | numbers.Real | collections.abc.Sequence[float | numbers.Real] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating | numpy.integer]]], str | int | float | bool | foamlib._files.types.Dimensioned | foamlib._files.types.DimensionSet | list['DataEntry | KeywordEntry | Dict'] | numpy.ndarray[tuple[int] | tuple[int, typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating]] | numbers.Integral | numbers.Real | collections.abc.Sequence[int | float] | collections.abc.Sequence['DataEntryLike | KeywordEntryLike | DictLike'] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.float64]] | collections.abc.Sequence[float | numbers.Real] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating | numpy.integer]] | collections.abc.Sequence[float | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.float64]] | numbers.Real | collections.abc.Sequence[float | numbers.Real] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating | numpy.integer]]], typing.Unpack[tuple[str | int | float | bool | foamlib._files.types.Dimensioned | foamlib._files.types.DimensionSet | list['DataEntry | KeywordEntry | Dict'] | numpy.ndarray[tuple[int] | tuple[int, typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating]] | numbers.Integral | numbers.Real | collections.abc.Sequence[int | float] | collections.abc.Sequence['DataEntryLike | KeywordEntryLike | DictLike'] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.float64]] | collections.abc.Sequence[float | numbers.Real] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating | numpy.integer]] | collections.abc.Sequence[float | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.float64]] | numbers.Real | collections.abc.Sequence[float | numbers.Real] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating | numpy.integer]]], ...]]]๏
Any type that could be interpreted as a
Data.
- foamlib.typing.StandaloneDataLike: TypeAlias = str | int | float | bool | foamlib._files.types.Dimensioned | foamlib._files.types.DimensionSet | list['DataEntry | KeywordEntry | Dict'] | numpy.ndarray[tuple[int] | tuple[int, typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating]] | numpy.ndarray[tuple[int], numpy.dtype[numpy.int64 | numpy.int32 | numpy.float64]] | numpy.ndarray[tuple[int, typing.Literal[3]], numpy.dtype[numpy.float64 | numpy.float32]] | list[numpy.ndarray[tuple[typing.Literal[3, 4]], numpy.dtype[numpy.int64]]] | numbers.Integral | numbers.Real | collections.abc.Sequence[int | float] | collections.abc.Sequence['DataEntryLike | KeywordEntryLike | DictLike'] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.float64]] | collections.abc.Sequence[float | numbers.Real] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating | numpy.integer]] | collections.abc.Sequence[float | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.float64]] | numbers.Real | collections.abc.Sequence[float | numbers.Real] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating | numpy.integer]]] | collections.abc.Sequence[int] | collections.abc.Sequence[float] | collections.abc.Sequence[numpy.ndarray[tuple[typing.Literal[3]], numpy.dtype[numpy.floating]]] | collections.abc.Sequence[numpy.ndarray[tuple[typing.Literal[3, 4]], numpy.dtype[numpy.integer]]] | collections.abc.Sequence[collections.abc.Sequence[int]] | tuple[str | int | float | bool | foamlib._files.types.Dimensioned | foamlib._files.types.DimensionSet | list['DataEntry | KeywordEntry | Dict'] | numpy.ndarray[tuple[int] | tuple[int, typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating]] | numpy.ndarray[tuple[int], numpy.dtype[numpy.int64 | numpy.int32 | numpy.float64]] | numpy.ndarray[tuple[int, typing.Literal[3]], numpy.dtype[numpy.float64 | numpy.float32]] | list[numpy.ndarray[tuple[typing.Literal[3, 4]], numpy.dtype[numpy.int64]]] | numbers.Integral | numbers.Real | collections.abc.Sequence[int | float] | collections.abc.Sequence['DataEntryLike | KeywordEntryLike | DictLike'] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.float64]] | collections.abc.Sequence[float | numbers.Real] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating | numpy.integer]] | collections.abc.Sequence[float | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.float64]] | numbers.Real | collections.abc.Sequence[float | numbers.Real] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating | numpy.integer]]] | collections.abc.Sequence[int] | collections.abc.Sequence[float] | collections.abc.Sequence[numpy.ndarray[tuple[typing.Literal[3]], numpy.dtype[numpy.floating]]] | collections.abc.Sequence[numpy.ndarray[tuple[typing.Literal[3, 4]], numpy.dtype[numpy.integer]]] | collections.abc.Sequence[collections.abc.Sequence[int]], str | int | float | bool | foamlib._files.types.Dimensioned | foamlib._files.types.DimensionSet | list['DataEntry | KeywordEntry | Dict'] | numpy.ndarray[tuple[int] | tuple[int, typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating]] | numpy.ndarray[tuple[int], numpy.dtype[numpy.int64 | numpy.int32 | numpy.float64]] | numpy.ndarray[tuple[int, typing.Literal[3]], numpy.dtype[numpy.float64 | numpy.float32]] | list[numpy.ndarray[tuple[typing.Literal[3, 4]], numpy.dtype[numpy.int64]]] | numbers.Integral | numbers.Real | collections.abc.Sequence[int | float] | collections.abc.Sequence['DataEntryLike | KeywordEntryLike | DictLike'] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.float64]] | collections.abc.Sequence[float | numbers.Real] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating | numpy.integer]] | collections.abc.Sequence[float | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.float64]] | numbers.Real | collections.abc.Sequence[float | numbers.Real] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating | numpy.integer]]] | collections.abc.Sequence[int] | collections.abc.Sequence[float] | collections.abc.Sequence[numpy.ndarray[tuple[typing.Literal[3]], numpy.dtype[numpy.floating]]] | collections.abc.Sequence[numpy.ndarray[tuple[typing.Literal[3, 4]], numpy.dtype[numpy.integer]]] | collections.abc.Sequence[collections.abc.Sequence[int]], typing.Unpack[tuple[str | int | float | bool | foamlib._files.types.Dimensioned | foamlib._files.types.DimensionSet | list['DataEntry | KeywordEntry | Dict'] | numpy.ndarray[tuple[int] | tuple[int, typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating]] | numpy.ndarray[tuple[int], numpy.dtype[numpy.int64 | numpy.int32 | numpy.float64]] | numpy.ndarray[tuple[int, typing.Literal[3]], numpy.dtype[numpy.float64 | numpy.float32]] | list[numpy.ndarray[tuple[typing.Literal[3, 4]], numpy.dtype[numpy.int64]]] | numbers.Integral | numbers.Real | collections.abc.Sequence[int | float] | collections.abc.Sequence['DataEntryLike | KeywordEntryLike | DictLike'] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.float64]] | collections.abc.Sequence[float | numbers.Real] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating | numpy.integer]] | collections.abc.Sequence[float | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.float64]] | numbers.Real | collections.abc.Sequence[float | numbers.Real] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating | numpy.integer]]] | collections.abc.Sequence[int] | collections.abc.Sequence[float] | collections.abc.Sequence[numpy.ndarray[tuple[typing.Literal[3]], numpy.dtype[numpy.floating]]] | collections.abc.Sequence[numpy.ndarray[tuple[typing.Literal[3, 4]], numpy.dtype[numpy.integer]]] | collections.abc.Sequence[collections.abc.Sequence[int]], ...]]]๏
Any type that could be interpreted as a
StandaloneData.
- foamlib.typing.DataEntryLike: TypeAlias = str | int | float | bool | foamlib._files.types.Dimensioned | foamlib._files.types.DimensionSet | list['DataEntry | KeywordEntry | Dict'] | numpy.ndarray[tuple[int] | tuple[int, typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating]] | numbers.Integral | numbers.Real | collections.abc.Sequence[int | float] | collections.abc.Sequence['DataEntryLike | KeywordEntryLike | DictLike'] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.float64]] | collections.abc.Sequence[float | numbers.Real] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating | numpy.integer]] | collections.abc.Sequence[float | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.float64]] | numbers.Real | collections.abc.Sequence[float | numbers.Real] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating | numpy.integer]]]๏
Any type that could be interpreted as a
DataEntry.
- foamlib.typing.StandaloneDataEntryLike: TypeAlias = str | int | float | bool | foamlib._files.types.Dimensioned | foamlib._files.types.DimensionSet | list['DataEntry | KeywordEntry | Dict'] | numpy.ndarray[tuple[int] | tuple[int, typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating]] | numpy.ndarray[tuple[int], numpy.dtype[numpy.int64 | numpy.int32 | numpy.float64]] | numpy.ndarray[tuple[int, typing.Literal[3]], numpy.dtype[numpy.float64 | numpy.float32]] | list[numpy.ndarray[tuple[typing.Literal[3, 4]], numpy.dtype[numpy.int64]]] | numbers.Integral | numbers.Real | collections.abc.Sequence[int | float] | collections.abc.Sequence['DataEntryLike | KeywordEntryLike | DictLike'] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.float64]] | collections.abc.Sequence[float | numbers.Real] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating | numpy.integer]] | collections.abc.Sequence[float | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.float64]] | numbers.Real | collections.abc.Sequence[float | numbers.Real] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating | numpy.integer]]] | collections.abc.Sequence[int] | collections.abc.Sequence[float] | collections.abc.Sequence[numpy.ndarray[tuple[typing.Literal[3]], numpy.dtype[numpy.floating]]] | collections.abc.Sequence[numpy.ndarray[tuple[typing.Literal[3, 4]], numpy.dtype[numpy.integer]]] | collections.abc.Sequence[collections.abc.Sequence[int]]๏
Any type that could be interpreted as a
StandaloneDataEntry.
- foamlib.typing.DictLike๏
Any mapping that could be interpreted as a
Dict.Mapping[str, DataLike | DictLike]ใฎๅฅๅใงใใ
- foamlib.typing.KeywordEntryLike๏
Any 2-tuple that could be interpreted as a
KeywordEntry.tuple[DataEntryLike, Data | DictLike]ใฎๅฅๅใงใใ
- foamlib.typing.ListLike๏
Any sequence that could be interpreted as a
List.Sequence[DataEntryLike | KeywordEntryLike | DictLike]ใฎๅฅๅใงใใ
- foamlib.typing.FieldLike: TypeAlias = float | numpy.ndarray[tuple[int] | tuple[int, typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating]] | numbers.Real | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.float64]] | collections.abc.Sequence[float | numbers.Real] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating | numpy.integer]] | collections.abc.Sequence[float | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.float64]] | numbers.Real | collections.abc.Sequence[float | numbers.Real] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating | numpy.integer]]]๏
Any type that could be interpreted as a
Field.
- foamlib.typing.TensorLike: TypeAlias = float | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.float64]] | numbers.Real | collections.abc.Sequence[float | numbers.Real] | numpy.ndarray[tuple[typing.Literal[3, 6, 9]], numpy.dtype[numpy.floating | numpy.integer]]๏
Any type that could be interpreted as a
Tensor.
- foamlib.typing.DimensionSetLike: TypeAlias = foamlib._files.types.DimensionSet | collections.abc.Sequence[int | float]๏
Any type that could be interpreted as a
foamlib.DimensionSet.