# Gradient

## DESCRIPTION

This module calculates the gradient of a two or three dimensional field. A centered difference algorithm is used to calculate the gradient. For a three dimensional lattice f, the three component vector field is:
```grad(f(i,j,k)) = (
```
```(f(i+1,j  ,k  )-f(i-1,j  ,k  ))/delx,
(f(i  ,j+1,k  )-f(i  ,j-1,k  ))/dely,
(f(i  ,j  ,k+1)-f(i  ,j  ,k-1))/delz)
```

Where:

```delx = x(i+1)-x(i-1)
dely = y(j+1)-y(j-1)
delz = z(k+1)-z(k-1)
```

For a two dimensional lattice f, the two component vector field is:

```grad(f(i,j)) = (
```
```(f(i+1,j  )-f(i-1,j  ))/delx,
(f(i  ,j+1)-f(i  ,j-1))/dely)
```

At the lower (i=imin or j=jmin or k=kmin) boundaries of the lattice, a forward difference is used in the component on the boundary:

```grad(imin,j,k) = (
```
```(f(imin+1,j  ,k  )-f(imin,j  ,k  ))/delx,
(f(imin  ,j+1,k  )-f(imin,j  ,k  ))/dely,
(f(imin  ,j  ,k+1)=f(imin,j  ,k  ))/delz)
```

Similarly, at the upper boundaries (i=imax or j=jmax or k=kmax) a backward difference is used for the component on the boundary. The results can be converted into geometry by VectorGen for display in the Render module. The Scale parameter is used to scale the vector values at each node of the lattice. The Channel slider is used to select the desired component if the input lattice is a vector field.

This module has been replaced by GradientLat, which offers more functionality, but is retained for backwards compatibility. The module may be removed from future releases.

## INPUTS

Port: Input Field
Type: Lattice
Constraints: 2..3-D
Constraints: uniform
The input lattice.

## WIDGETS

Port: Scale
Type: Dial
A scale factor.

Port: Channel
Type: Slider
The vector component if the Input Field is a vector lattice. This is zero- based.

## OUTPUTS

Port: Gradient
Type: Lattice
Constraints: 2..3-D
Constraints: 2..3-vector
Constraints: float
Constraints: uniform
The output gradient.

## SEE ALSO

GradientLat, Gradient3D, VectorGen, LatFunction.
[Documentation Home]
© The Numerical Algorithms Group Ltd, Oxford UK. 2000