# The LinearUpwind Scheme

The following article is related to the LinearUpwind scheme, implemented in OpenFOAM®. The article will describe the implementation to understand the usage and how the code works in that particular area. The LinearUpwind Scheme is related to the limited surface interpolation schemes which is related to the surface Interpolation schemes. Thus, in OpenFOAM®, the LinearUpwind scheme is a limited scheme. In the code section below, it is shown that the limiter in use is zero but an explicit correction is applied.

## General Remarks

The LinearUpwind Scheme (First/Second Order Scheme)

Using the LinearUpwind scheme increases the accuracy while being more stable -- compared to the Upwind scheme concerning accuracy and regarding stability to the Linear scheme. This scheme is based on the Upwind scheme, and that's why the LinearUpwind inherits the Upwind scheme. The limiter is set to zero as it is based on the Upwind scheme. Additionally, the weights() functions are the same as for the Upwind scheme. The difference is related to the explicit correction that is implemented in the LinearUpwind class. The gradient-based explicit correction is used to increase the accuracy of the standard Upwind scheme. If one compares the Linear scheme with the LinearUpwind scheme, it is evident that the LinearUpwind scheme is much more stable than the Linear scheme. Additionally, the increase in accuracy compared to the Upwind scheme can be seen. Nevertheless, the LinearUpwind scheme can calculate non-physical values.

## The Results

Of The Numerical Analysis

### Structured Grid (0°)

20 x 20 numerical cells

### Structured Grid (0°)

40 x 40 numerical cells

### Structured Grid (0°)

80 x 80 numerical cells

Comparison

### Structured Grid (45°)

20 x 20 numerical cells

### Structured Grid (45°)

40 x 40 numerical cells

### Structured Grid (45°)

80 x 80 numerical cells

Comparison

### Unstructured Grid

20 x 20 numerical cells

### Unstructured Grid

40 x 40 numerical cells

### Unstructured Grid

80 x 80 numerical cells

Comparison

### Polygon Grid

20 x 20 numerical cells

### Polygon Grid

40 x 40 numerical cells

### Polygon Grid

80 x 80 numerical cells

Comparison

### Grid Comparison

20 x 20 numerical cells

### Grid Comparison

40 x 40 numerical cells

### Grid Comparison

80 x 80 numerical cells

## The Code

LinearUpwind scheme

The LinearUpwind scheme is implemented in the LinearUpwind class. The class inherits the Upwind class in which the weights() and limiter() functions are defined. The limiter is set to zero and the weights return either zero or one depending on the flux sign. The difference of the LinearUpwind class is related to the implementation of the correction() function. There are two correction() functions implemented. One is for a GenericField while the other one is explicitly defined for vector fields and the fluxes. However, the explicit correction is calculated in both functions similarly:

• Calculate the gradient of the field of interest (vf)
• Calculate the explicit correction using the face center and cell center vector (Cf - C) and the already calculated gradient (inner product)
     tmp tgradVf = gradScheme_().grad(vf, gradSchemeName_);