# vector (1d, 2d, 3d)¶

The vector updater computes a range of first derivatives of quanties defined on the USim computational mesh using a least squares gradient method. This updater differs from the firstOrderMusclUpdater (1d, 2d, 3d), classicMusclUpdater (1d, 2d, 3d), unstructMusclUpdater (1d, 2d, 3d) and thirdOrderMusclUpdater (1d, 2d, 3d) updaters in that no upwinding is performed here. As such, the vector updater is only suitable for problems that do not require upwind stabilization.

The vector updater accepts the parameters below, in addition to those required by Updater.

## Data¶

in (string vector, required)
Defined by the choice of the derivative attribute, as detailed below.
out (string vector, required)
Defined by the choice of the derivative attribute, as detailed below.

## Parameters¶

orderAccuracy (integer, required)
Order of the polynomial that is used to form the operator. Choice of 1, 2 or 3 corresponding, respectively to first, second and third order accuracy. The appropriate choice of order varies on the problem type and the mesh used.
numberOfInterpolationPoints (integer, required)

Number of points to be considerd for the least squares fit. This parameter varies from mesh to mesh and should be determined by computing a known function on the mesh.

The numberOfInterpolationPoints must be greater than (or equal to) the number of coefficients in the polynomial approximation. This means that in 1d the value is 4, in 2D the value is at least 6 and in 3D the value is at least 10.

These choices do not guarantee that a matrix inverse will be found. The following values though appear to be adequate in general: in 1D 4; in 2D 8 and in 3D 20.

coefficient (float, required)
Constant floating point value, c that multiplies the output of the diffusion updater.
derivative (string, required)
The type of derivative that will be performed. Available derivatives are:

Computes $$c\nabla \phi$$ where $$\phi$$ is a scalar quantity defined on the grid and c is a constant coefficient. When derivative = gradient is specified, the following input and output variables should be specified:

in
$$\phi$$ (nodalArray, 1-component, required): scalar quantity to compute the gradient of.
out
$$c\nabla \phi$$ (nodalArray, 3-components, required): gradient of $$\phi$$
curl (derivative = curl)

Computes $$c\nabla \times \mathbf{v}$$ where $$\mathbf{v}$$ is a vector quantity defined on the grid and c is a constant coefficient. When derivative = curl is specified, the following input and output variables should be specified:

in
$$\mathbf{v}$$ (nodalArray, 3-components, required): vector quantity to compute the curl of.
out
$$c\nabla \times \mathbf{v}$$ (nodalArray, 3-components, required): curl of $$\mathbf{v}$$
divergence (derivative = divergence)

Computes $$c\nabla \cdot \mathbf{v}$$ where $$\mathbf{v}$$ is a vector quantity defined on the grid and c is a constant coefficient. When derivative = divergence is specified, the following input and output variables should be specified:

in
$$\mathbf{v}$$ (nodalArray, 3-components, required); vector quantity to compute the divergence of.
out
$$c\nabla \cdot \mathbf{v}$$ (nodalArray, 3-components, required); divergence of $$\mathbf{v}$$

## Example¶

The following code block demonstrates the least squares gradient operator for computing the gradient of a scalar quantity:

<Updater derivative>
kind = vector2d
coefficient = 1.0
numberOfInterpolationPoints = 8
orderAccuracy = 2
onGrid = domain
in = [phi]
</Updater>

The following code block demonstrates the least squares curl operator for computing the curl of a vector quantity:

<Updater copier>
kind = vector2d
onGrid = domain
derivative = curl
coefficient = 1.0
orderAccuracy = 1
numberOfInterpolationPoints = 5
in = [q]
out = [qnew]
</Updater>

The following code block demonstrates the least squares divergence operator for computing the divergence of a vector quantity:

<Updater copier>
kind = vector2d
onGrid = domain
derivative = divergence
orderAccuracy = 2
coefficient = 1.0
numberOfInterpolationPoints = 8  # 7 for 1st degree polynomial
in = [q]
out = [qnew]
</Updater>