# Gradient computation

### From CFD-Wiki

Line 1: | Line 1: | ||

- | == | + | == Introduction == |

- | + | For structured orthogonal grids, the gradient of a scalar at a given control volume centroid can be easily computed using the definition of the derivatives. The case becomes more complicated when general unstructured grids are involved. The usual approach is to make use of Green-Gauss theorem which states that the surface integral of a scalar function is equal to the volume integral (over the volume bound by the surface) of the gradient of the scalar function. <br> | |

- | + | <math>\int_{\Omega}\nabla \phi d\Omega = \int_{S} \phi dS </math><br> | |

- | + | Assuming that <math> \nabla \phi </math> is constant over the control volume, the Green-Gauss equation can be rewritten as <br> | |

- | </math> | + | <math>\int_{\Omega}\nabla \phi d\Omega =\nabla \phi_P \Omega = \int_{S} \phi dS </math><br> |

- | + | We next approximate the integral over the surface as a summation of the average scalar value times the surface vector <br> | |

- | + | <math>\nabla \phi_P =\frac {1}{\Omega}\sum_{faces} \phi_f \vec S_f </math><br> | |

- | \ | + | The face value <math>\phi_f</math> still needs to be defined. Following are some practical methods to compute the average face value. |

- | </math> | + | |

- | == | + | == Face value computation == |

- | + | As mentioned above, the average value of the scalar at a given face has to be correctly approximated in order to yield a correct computation of the cell gradient. As the FVM uses a cell centered formulation, values at the faces are not readily avaialble, they have to be interpolated. There are two main approaches to compute the face value of a scalar | |

- | + | *'''Cell based''' in which the face value is computed using the values at its straddling cells | |

- | + | *'''Node based''' in which the face value is computed using the values at its straddling nodes | |

- | + | ''Note that these methods are not specific for the computation of the gradient. They can be used in any occasion when the face value is needed.'' | |

- | + | ||

- | + | ||

- | + | ||

+ | === Cell based methods === | ||

+ | We define <math>\alpha</math> as the weighing geometric factor between cells P and N <br> | ||

+ | <math> \alpha = \frac {\left | \vec r_N - \vec r_f \right |} {\left | \vec r_N - \vec r_P \right |}</math> <br> | ||

+ | then a simple approximation for the face value can be defined as <br> | ||

+ | <math> \phi _f = \alpha \phi_P + \left( {1 - \alpha} \right)\phi_N</math> <br> | ||

+ | This approximation is also known as a weighted interpolation. It is defined by a compact stencil in that only the cells straddling the face are only involved in the interpolation.<br> | ||

+ | A special case arises when the face is situated midway between the two control volumes and the approximation reduces to an arithmetic average <br> | ||

+ | <math> \phi_f = 0.5 \left( \phi_P + \phi _N \right) </math> <br> | ||

+ | <br> | ||

+ | The advantage of this approach is that it is simple to implement. All of the operations involved are face-based and do not require any additional grid connectivity. Furthermore, the procedure can be readily implemented in three dimensions. <br> | ||

+ | From an accuracy point of view, the above relation leads to a second order approximation of <math> \phi_f </math> only when the segment [PN] and surface Sf are aligned. Thus a second order accurate representation of the gradient is generally not achieved except for this case.<br> | ||

+ | For highly skewed unstructured grids, the accuracy decreases with increasing skewness. In such a case, a correction is added to the above approximation and an iterative procedure is usually needed to find the face value. | ||

+ | ===Node based methods === | ||

+ | The value of <math> \phi_f </math> can be computed as the mean of the nodes defining the face. This necessitates the estimation of the properties at the nodes. The properties at the nodes are calculated using the weighted average of the properties within the cells defining that node. The weight is taken as the inverse of the distance of the node from the cell center <br> | ||

+ | <math> \phi_{vertex} = \phi_v = | ||

+ | \frac{{\sum\limits_{n = 1}^{cells} {\frac{{\phi _{Pn} }}{{\left| {\vec r_v - \vec r_{Pn} } \right|}}} }}{{\sum\limits_{n = 1}^{cells} {\frac{1}{{\left| {\vec r_v - \vec r_{Pn} } \right|}}} }} | ||

+ | </math> <br> | ||

+ | where v denotes the concerned vertex and the loop is performed over the the cells that define the vertex. Pn is the index of the cell, and <math>\left| {\vec r_v - \vec r_{Pn} } \right|</math> is the distance from the vertex to the cell centroid. <br> | ||

+ | Finally, the face value is taken as the arithmetic average of the values at the vertices.<br> | ||

+ | <math> \phi _f = {\begin{matrix} {1 \over {N_{fv}}} \end{matrix}} \sum\limits_{i = 1}^{N_{fv}} {\phi _i }</math> <br> | ||

+ | where Nfv represents the number of '''Vertices''' defining a given face. | ||

== Note == | == Note == | ||

The above mentioned gradients are sometimes called '''unlimited gradients''' since the face value obtained from them can exceed the bounding cell values. For this reason, for implementing higher order schemes, it becomes important to restrict them, so as not to introduce over and undershoot of variables. | The above mentioned gradients are sometimes called '''unlimited gradients''' since the face value obtained from them can exceed the bounding cell values. For this reason, for implementing higher order schemes, it becomes important to restrict them, so as not to introduce over and undershoot of variables. |

## Revision as of 01:17, 6 December 2005

## Contents |

## Introduction

For structured orthogonal grids, the gradient of a scalar at a given control volume centroid can be easily computed using the definition of the derivatives. The case becomes more complicated when general unstructured grids are involved. The usual approach is to make use of Green-Gauss theorem which states that the surface integral of a scalar function is equal to the volume integral (over the volume bound by the surface) of the gradient of the scalar function.

Assuming that is constant over the control volume, the Green-Gauss equation can be rewritten as

We next approximate the integral over the surface as a summation of the average scalar value times the surface vector

The face value still needs to be defined. Following are some practical methods to compute the average face value.

## Face value computation

As mentioned above, the average value of the scalar at a given face has to be correctly approximated in order to yield a correct computation of the cell gradient. As the FVM uses a cell centered formulation, values at the faces are not readily avaialble, they have to be interpolated. There are two main approaches to compute the face value of a scalar

**Cell based**in which the face value is computed using the values at its straddling cells**Node based**in which the face value is computed using the values at its straddling nodes

*Note that these methods are not specific for the computation of the gradient. They can be used in any occasion when the face value is needed.*

### Cell based methods

We define as the weighing geometric factor between cells P and N

then a simple approximation for the face value can be defined as

This approximation is also known as a weighted interpolation. It is defined by a compact stencil in that only the cells straddling the face are only involved in the interpolation.

A special case arises when the face is situated midway between the two control volumes and the approximation reduces to an arithmetic average

The advantage of this approach is that it is simple to implement. All of the operations involved are face-based and do not require any additional grid connectivity. Furthermore, the procedure can be readily implemented in three dimensions.

From an accuracy point of view, the above relation leads to a second order approximation of only when the segment [PN] and surface Sf are aligned. Thus a second order accurate representation of the gradient is generally not achieved except for this case.

For highly skewed unstructured grids, the accuracy decreases with increasing skewness. In such a case, a correction is added to the above approximation and an iterative procedure is usually needed to find the face value.

### Node based methods

The value of can be computed as the mean of the nodes defining the face. This necessitates the estimation of the properties at the nodes. The properties at the nodes are calculated using the weighted average of the properties within the cells defining that node. The weight is taken as the inverse of the distance of the node from the cell center

where v denotes the concerned vertex and the loop is performed over the the cells that define the vertex. Pn is the index of the cell, and is the distance from the vertex to the cell centroid.

Finally, the face value is taken as the arithmetic average of the values at the vertices.

where Nfv represents the number of **Vertices** defining a given face.

## Note

The above mentioned gradients are sometimes called **unlimited gradients** since the face value obtained from them can exceed the bounding cell values. For this reason, for implementing higher order schemes, it becomes important to restrict them, so as not to introduce over and undershoot of variables.

* Return to Numerical Methods *