PrecomputedSparseFunction

class devito.types.PrecomputedSparseFunction(*args)[source]

Bases: AbstractSparseFunction

Tensor symbol representing a sparse array in symbolic equations; unlike SparseFunction, PrecomputedSparseFunction uses externally-defined data for interpolation.

Parameters:
  • name (str) – Name of the symbol.

  • npoint (int) – Number of sparse points.

  • grid (Grid) – The computational domain from which the sparse points are sampled.

  • r (int) – Number of gridpoints in each Dimension to interpolate a single sparse point to. E.g. r=2 for linear interpolation.

  • coordinates (np.ndarray, optional) – The coordinates of each sparse point.

  • gridpoints (np.ndarray, optional) – An array carrying the reference grid point corresponding to each sparse point. Of all the gridpoints that one sparse point would be interpolated to, this is the grid point closest to the origin, i.e. the one with the lowest value of each coordinate Dimension. Must be a two-dimensional array of shape (npoint, grid.ndim).

  • interpolation_coeffs (np.ndarray, optional) – An array containing the coefficient for each of the r^2 (2D) or r^3 (3D) gridpoints that each sparse point will be interpolated to. The coefficient is split across the n Dimensions such that the contribution of the point (i, j, k) will be multiplied by interp_coeffs[…, i]*interp_coeffs[…,j]*interp_coeffs[…,k]. So for r=6, we will store 18 coefficients per sparse point (instead of potentially 216). Must be a three-dimensional array of shape (npoint, grid.ndim, r).

  • space_order (int, optional) – Discretisation order for space derivatives. Defaults to 0.

  • shape (tuple of ints, optional) – Shape of the object. Defaults to (npoint,).

  • dimensions (tuple of Dimension, optional) – Dimensions associated with the object. Only necessary if the SparseFunction defines a multi-dimensional tensor.

  • dtype (data-type, optional) – Any object that can be interpreted as a numpy data type. Defaults to np.float32.

  • initializer (callable or any object exposing the buffer interface, optional) – Data initializer. If a callable is provided, data is allocated lazily.

  • allocator (MemoryAllocator, optional) – Controller for memory allocation. To be used, for example, when one wants to take advantage of the memory hierarchy in a NUMA architecture. Refer to default_allocator.__doc__ for more information.

Notes

The parameters must always be given as keyword arguments, since SymPy uses *args to (re-)create the Dimension arguments of the symbolic object.

property data

The domain data values, as a numpy.ndarray.

Elements are stored in row-major format.

Notes

With this accessor you are claiming that you will modify the values you get back. If you only need to look at the values, use data_ro() instead.

property data_domain

The domain data values.

Elements are stored in row-major format.

Notes

Alias to self.data.

With this accessor you are claiming that you will modify the values you get back. If you only need to look at the values, use data_ro_domain() instead.

property data_ro_domain

Read-only view of the domain data values.

property data_ro_with_halo

Read-only view of the domain+outhalo data values.

property data_with_halo

The domain+outhalo data values.

Elements are stored in row-major format.

Notes

With this accessor you are claiming that you will modify the values you get back. If you only need to look at the values, use data_ro_with_halo() instead.

property dimensions

Tuple of Dimensions representing the object indices.

property dtype

The data type of the object in the generated code, represented as a Python class:

  • numpy.dtype: basic data types. For example, np.float64 -> double.

  • ctypes: composite objects (e.g., structs), foreign types.

property grid

The Grid on which the discretization occurred.

inject(*args, **kwargs)

Implement an injection operation from a sparse point onto the grid

interpolate(*args, **kwargs)

Implement an interpolation operation from the grid onto the given sparse points

property name

The name of the object.

shape

Shape of the domain region. The domain constitutes the area of the data written to by an Operator.

Notes

In an MPI context, this is the local domain region shape.

property space_order

The space order.