Module stencils

class findiff.stencils.StencilSet(diff_op, shape, old_stl=None)

Represent the finite difference stencil for a given differential operator.

Constructor for Stencil objects.

Parameters:
  • shape – tuple of ints Shape of the grid on which the stencil should be applied.

  • axis – int >= 0 The coordinate axis along which to take the partial derivative.

  • order – int > 0 The order of the derivative.

  • h – float The spacing of the (equidistant) grid

apply(u, idx0)

Applies the stencil to a point in an equidistant grid.

Parameters:
  • u – ndarray An array with the function to differentiate.

  • idx0 – int or tuple of ints The index of the grid point where to differentiate the function.

Returns:

The derivative at the given point.

apply_all(u)

Applies the stencil to all grid points.

Parameters:

u – ndarray An array with the function to differentiate.

Returns:

An array with the derivative.