pystencils.grids.protocols.CreateNdArray#
- class pystencils.grids.protocols.CreateNdArray(*args, **kwargs)#
Create an
ndarrayinstance for a field. Mix in withIField.- create_ndarray(array_module, spatial_shape, *, dtype=None, **kwargs)#
Create an
array_module.ndarraybacking this field, with the giveninner_shape.If this field is defined on a
PatchGrid,spatial_shapemust 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 spacedtype (
Optional[dtype]) – Data type of the field entries; ifNone, infer from the field typekwargs – Keyword arguments forwarded to the array module’s array creation routine (ususally
.zeros()).