Built-in Operators

Devito provides a number of convenience Operators that can be imported and run in user code to facilitate development. These are exposed as free functions.

All built-in Operators support MPI.

Built-in Operators provided by Devito.

devito.builtins.assign(f, v=0)[source]

Assign a value to a Function.

  • f (Function) – The left-hand side of the assignment.
  • v (scalar, optional) – The right-hand side of the assignment.
devito.builtins.smooth(f, g, axis=None)[source]

Smooth a Function through simple moving average.

  • f (Function) – The left-hand side of the smoothing kernel, that is the smoothed Function.
  • g (Function) – The right-hand side of the smoothing kernel, that is the Function being smoothed.
  • axis (Dimension or list of Dimensions, optional) – The Dimension along which the smoothing operation is performed. Defaults to f’s innermost Dimension.


More info about simple moving average available at:

devito.builtins.norm(f, order=2)[source]

Compute the norm of a Function.

  • f (Function) – Input Function.
  • order (int, optional) – The order of the norm. Defaults to 2.

Compute the sum of all Function data.

Parameters:f (Function) – Input Function.
devito.builtins.inner(f, g)[source]

Inner product of two Functions.


ValueError – If the two input Functions are defined over different grids, or have different dimensionality, or their dimension-wise sizes don’t match. If in input are two SparseFunctions and their coordinates don’t match, the exception is raised.


The inner product is the sum of all dimension-wise products. For 1D Functions, the inner product corresponds to the dot product.