pystencils.grids.tensor_field.TensorField#
- class pystencils.grids.tensor_field.TensorField(name, spatial_rank, tensor_shape=(), *, dtype=DynamicType.NUMERIC_TYPE, layout=MemoryLayout.RIGHTMOST)#
Tensor field mapping each point of a \(d\)-dimensional index space to a rank \(n\) tensor.
A tensor field is a function
\[f: I \to T^{k_1 \times \cdots \times k_n}\]from an index space \(I \subset \mathbb{Z}^{d}\) to a tensor space over \(T\). \(T\) may be \(\mathbb{R}\) or a specific numeric
data type.Note
Degenerate tensor shapes (i.e. \(n_i = 1\) for any \(i\)) are not supported.
Accessing Values Field entries can be accessed using the
[]and()operators. Spatial offsets must be given in[]; they are interpreted relative to the current node. Tensor indices are passed to().Examples:
Access vector entry 1 at the current node:
f(1)
Access scalar entry at the eastern neighbor node:
f[1, 0]()
Access tensor entry
(0, 0)at the north-west neighbor node:
f[-1, 1](0, 0)
- Parameters:
name (
str) – Name of the tensor fieldspatial_rank (
int) – Dimensionality of the index space \(I\)tensor_shape (
tuple[int,...]) – Shape of the field’s tensorsdtype (
str|type|dtype|PsType|DynamicType) – Data type of the field’s tensor entrieslayout (
str|MemoryLayout) – Memory layout of the field’s memory buffers at runtime
- property dtype: PsNumericType | DynamicType#
Data type of tensor entries
- property layout: MemoryLayout#
Memory layout of runtime buffers
- get_buffer_spec()#
Return the buffer specification defining the field’s memory properties
- Return type:
- get_iteration_limits()#
Return the iteration limits for kernels operating on this field
- Return type: