Divergence Split

Class: kwave.toolbox.FourierCollocation Package: kwave.toolbox

Calculate components of divergence of vector field.

Syntax

df = divergenceSplit(obj, f)
df = divergenceSplit(obj, f, Staggering='forward')

Description

Calculates the split components (e.g., dfx/dx, dfy/dy) of the divergence of a vector field in 1D, 2D, or 3D using a Fourier collocation spectral method. This is equivalent to the diagonal of the vector gradient.

The vector components of the input field, and the split components of the divergence, are stacked in the 4th dimension. For example, if calling divergence on a vector field in 2D, the input should have dimensions (Nx, Ny, 1, 2), and the output will be the same size. This is to allow codes to implement multi-dimensional support by always looping over the fourth dimension.

If obj.kappa is defined, a k-space correction is applied as part of the divergence calculation. If kappa is a scalar (single frequency correction) or empty, the contributions to the divergence for each of the Cartesian coordinates are calculated using 1D FFTs. If kappa is a matrix, they are calculated using ND FFTs, and kappa is applied in the Fourier domain.

The divergence operations (and kappa if defined) are defined on the padded grid. Thus, the inputs to this function must also be defined on the padded grid. The output can be returned on a spatially staggered grid by setting the optional Staggering argument.

Input Arguments

  • f - (numeric) Vector field to compute divergence of.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

  • Staggering - ('none', 'forward', 'backward') Option to return the output staggered by half a grid point in the specified direction. Default = 'none'.

Output Arguments

  • df - (numeric) Components of divergence of f.