pystencils.grids.protocols.CreateNdArray

pystencils.grids.protocols.CreateNdArray#

class pystencils.grids.protocols.CreateNdArray(*args, **kwargs)#

Create an ndarray instance for a field. Mix in with IField.

create_ndarray(array_module, spatial_shape, *, dtype=None, **kwargs)#

Create an array_module.ndarray backing this field, with the given inner_shape.

If this field is defined on a PatchGrid, spatial_shape must reflect the number of nodes on that grid (i.e. number of cells, number of vertices, etc…)

Parameters:
  • array_module (ModuleType) – Reference to the array module (NumPy, CuPy, DPNP)

  • spatial_shape (tuple[int, ...]) – Shape of the field’s spatial index space

  • dtype (Union[type[generic], dtype, None]) – Data type of the field entries; if None, infer from the field type

  • kwargs – Keyword arguments forwarded to the array module’s array creation routine (ususally .zeros()).