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.

Parameters
  • 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.

Parameters
  • 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.

Notes

More info about simple moving average available at:

https://en.wikipedia.org/wiki/Moving_average#Simple_moving_average
devito.builtins.norm(f, order=2)[source]

Compute the norm of a Function.

Parameters
  • f (Function) – Input Function.

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

devito.builtins.sumall(f)[source]

Compute the sum of all Function data.

Parameters

f (Function) – Input Function.

devito.builtins.inner(f, g)[source]

Inner product of two Functions.

Parameters
Raises

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.

Notes

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

devito.builtins.mmin(f)[source]

Retrieve the minimum.

Parameters

f (array_like or Function) – Input operand.

devito.builtins.mmax(f)[source]

Retrieve the maximum.

Parameters

f (array_like or Function) – Input operand.