pystencils.grids.tensor_field.MemoryLayout#

class pystencils.grids.tensor_field.MemoryLayout(value)#

Common field memory layouts available in pystencils.

LEFTMOST = 1#

Leftmost-first (Fortran-style) layout

The leftmost buffer coordinate has stride one, and strides increase monotonically left-to-right.

RIGHTMOST = 2#

Rightmost-first (C/NumPy-style) layout

The rightmost buffer coordinate has stride one, and strides increase monotonically right-to-left.

ZYXF = 3#

Naturally ordered Array-of-Structures layout.

Spatial dimensions are ordered Z-Y-X (x fastest, z the slowest coordinate). Values for each spatial index are stored in packed fashion; for multidimensional per-point data, memory order inside the pack is determined by the field type.

FZYX = 1#

Naturally ordered Structure-of-Arrays layout.

Spatial dimensions are ordered Z-Y-X (x fastest, z the slowest coordinate). Values for each spatial index are linearized separately, such that the same structure entry on adjacent nodes are also adjacent in memory (i.e. x-stride is always 1.)

FORTRAN = 1#

See MemoryLayout.LEFTMOST

SOA = 1#

See MemoryLayout.FZYX

C = 2#

See MemoryLayout.RIGHTMOST

NUMPY = 2#

See MemoryLayout.LEFTMOST

AOS = 3#

See MemoryLayout.ZYXF

linearization_order(rank, spatial_rank=None)#

Order in which buffer dimensions are linearized in memory. Ordered fastest-to-slowest.

Return type:

tuple[int, ...]

Parameters:
  • rank (int)

  • spatial_rank (int | None)