1
NUMERIC IN HYDRAULIC
ENGINEERING
Finite Volume Method (FVM)
15.01.2018
Shervin Shahriari
u www.tugraz.at
Institute of Hydraulic Engineering and Water Resources Management
2
Finite Volume Method (FVM)
Introduction
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
3
Finite Volume Method (FVM)
The governing equation of fluid flow (Continuity and Momentum
Equations) are nonlinear second order partial differential equations.
These equations can be analytically solved only for simple cases with
significant simplifications.
Therefore numerical techniques must be used to transform these
equations to solvable forms.
Several numerical techniques such as finite volume method (FVM), finite
element method (FEM) and finite difference method (FDM) are available.
Among these methods, FVM is one of the preferred method in
computational fluid dynamics due it's characteristics.
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
4
Finite Volume Method (FVM)
In FVM:
1. First step is to subdivide the geometric domain into finite number of
non-overlapping control volumes (CVs).
2. Then, the partial differential equations are discretized and
transformed into algebraic equations by integration over each cell.
3. Finally, the system of algebraic equations will be solved to compute
the values of the flow parameters (e.g. velocity and pressure) for
each elements.
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
5
Finite Volume Method (FVM)
As mentioned earlier FVM has a few specific features that makes it
suitable for CFD simulations:
1. Some of the terms in the conservation equation are transformed into
face fluxes and evaluated at the cell faces. Because the flux entering
a volume is identical to the flux which is leaving the adjacent volume,
the FVM is conservative.
2. It can be used in the three dimensional physical space on
unstructured polygonal cells.
3. In FVM, it is simple to implement various boundary conditions
because the unknown variables are evaluated at the center of the
element and not at their boundary faces.
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
6
Finite Volume Method (FVM)
OpenFOAM uses this numerical technique to solve the partial differential
equations.
The control volumes and the notations which OpenFOAM uses are shown
in Figure below:
Dependent variables are stored
at the centroids of the cells “𝑷”
and “𝑵”.
Each cell is bounded by a group
of faces “ 𝒇” and each face is
owned by one adjacent cell
(neighboring cell) except for the
boundary faces.
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
7
Finite Volume Method (FVM)
Each face has an area “ 𝑆𝑓 ” and a unit normal vector “𝑛” pointing toward
the neighboring cell, therefore a surface vector can be defines as
𝑺𝒇 = 𝑆𝑓 𝑛.
Additionally a vector “𝒅” is defined from the centroid of the owner cell
towards the centroid of the neighbor cell 𝒅 = 𝑃𝑁.
the volume of the cell is donated
as “𝑽𝑷 ”.
OpenFOAM allows using an
arbitrarily unstructured grids
with no restriction on the shape
of the cells nor on the alignment
of the faces. This provides grid
generation flexibility, particularly
for complex geometries.
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
8
Finite Volume Method (FVM)
Equation discretization
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
9
Finite Volume Method (FVM)
If we introduce a general variable 𝜙 , the governing equations for
conservation of mass, momentum and transport of scalar quantities can
be generalized by the generic transport equation for property 𝜙:
The key step in the finite volume method that distinguishes it from all
other techniques is the CV integration of the above equation. This leads to
the integral form of the transport equation:
Equation above must be discretize in space and time for a control volume.
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
10
Finite Volume Method (FVM)
Spatial discretization
In the general transport equation, the volume integrals of the convective
and the diffusive term, can be written as integrals over the bounding
surfaces of the control volume by using Gauss's theorem.
In its most general form, Gauss's theorem states:
where 𝑺 is the surface area vector, 𝜙 represents any tensor field and * is
representing any tensor product, i.e., gradient (𝛁𝜙),divergence (𝛁. 𝜙).
The Gauss's theorem can now be applied to the convective and diffusive
terms of the equation. The volume and surface integrals are then
linearized using numerical schemes.
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
11
Finite Volume Method (FVM)
Spatial discretization
The convective term on the left hand side of the equation is one of most
important term.
Using Gauss's theorem the volume integral of the convective term can be
transformed to surface integral. The surface integral then linearized as
follows:
In equation above the face value 𝜙𝒇 is needed and it can be evaluated by
various numerical schemes.
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
12
Finite Volume Method (FVM)
Spatial discretization
OpenFOAM provides several interpolation schemes for 𝜙𝒇 , among these
schemes, “upwind” is one of the simplest.
This scheme is first-order accurate and bounded.
Depends on the direction of the face flux it can be written as:
Note that “upwind” scheme is introducing
significant diffusion into the computation
and thus smooths out any sharp changes in
the value 𝜙, this scheme can be used for
preliminary simulations and creating initial
condition for more accurate computation.
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
13
Finite Volume Method (FVM)
Spatial discretization
In order to improve accuracy and overcome shortcoming of the upwind
scheme, it is possible to use another upwinding scheme “linearUpwind”.
This scheme is an extension of “upwind” scheme to second-order by
introducing a corrector.
Assuming that the sign of the face flux is positive, the general formulation
of the scheme is as follows:
where 𝜙𝑷 is the value of 𝜙 at the upstream
cell center, 𝛁𝜙𝒖𝒑𝒔𝒕𝒓𝒆𝒂𝒎 is the gradient of 𝜙 at
the upstream face and 𝒓 is a vector from the
upstream cell center to the center of the
face which 𝜙𝒇 is being evaluated.
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
14
Finite Volume Method (FVM)
Spatial discretization
Another second-order scheme which is available in OpenFOAM is central
or “linear” differencing scheme (CD).
In CD, the value of 𝜙 at the control volume face 𝒇 is interpolated by
weighting the two adjacent cell center values by the distances to the face.
The CD scheme can be written as follows:
Where ω is the weight factor and it is
computed as the ratio of the distance of the
neighboring cell center to the face 𝒇𝑵 and
the distance between the centroids of the
owner cells 𝑷𝑵.
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
15
Finite Volume Method (FVM)
Spatial discretization
Although it can be shown by Taylor series expansion that CD is second-
order accurate, i.e., the leading term of the truncation error is proportional
to the square of the grid spacing, the method is unbounded and it may
lead to oscillatory solution and unstable computations.
Comprehensive details about the upwind (UD), linear upwind (LUD) and
central (CD) differencing schemes can be found in:
In addition to above interpolation schemes,
OpenFOAM also provides various blended
schemes including various total variation
diminishing (TVD) and normalized variable
diagram (NVD) families of differencing
schemes.
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
16
Finite Volume Method (FVM)
Spatial discretization
For example, NVD Gamma scheme which is based on:
This scheme is bounded and it is a blend between the first-order upwind
(UD) scheme and central differencing (CD) scheme with smooth transition
between the two.
the NVD scheme has been modified by localizing the NVD criterion and
makes it applicable to any mesh structure and facilitating the
implementation to unstructured mesh.
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
17
Finite Volume Method (FVM)
Spatial discretization
NVD Gamma method can be written as follows:
where 𝜸 is the blending factor and it determines how much dissipation is
introduced. The value of 𝛄 is vary linearly between 0 and the pre-specified
constant of the scheme, 𝜷𝒎 .
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
18
Finite Volume Method (FVM)
Spatial discretization
The numerical schemes and their behavior are summarized in table below:
Scheme Numerical behavior
linear Unbounded second-order
upwind Bounded first-order
linearUpwind Bounded first/second order
NVD Gamma Bounded first/second order
Finally, the mass flux 𝑭 is computed from interpolated values of 𝑼. Similar
to interpolation of 𝜙𝒇 , 𝑭 can be evaluated using various schemes including
the schemes that described above.
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
19
Finite Volume Method (FVM)
Spatial discretization
Gradient computed using integrals over the faces:
Using linear scheme:
where
This is good for hexahedral mesh, however, consider using Least Squares
Gradient for tetrahedral elements.
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
20
Finite Volume Method (FVM)
Spatial discretization
Diffusion term is discretized using Gauss Theorem:
In the equation above, the discretization of the face gradient is implicit
when the length vector 𝒅 between the centroid of the cell of interest 𝑷 and
the centroid of the neighboring cell 𝑵 is orthogonal to the face plane. In
the case were 𝒅 is parallel to 𝑺𝒇 :
𝑓
𝑃 𝑆𝑓 𝑁
𝑑
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
21
Finite Volume Method (FVM)
Spatial discretization
However, when mesh is non-orthogonal:
𝑓 𝑆𝑓
𝑃 𝑘 𝑁
𝑑 ∆
A correction term may be added:
+ 𝑘𝑓 ∙ 𝛻 𝜙 𝑓
Depends on the non-orthogonality, limited non-orthogonal correction can
be used:
Limiter
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
22
Finite Volume Method (FVM)
Spatial discretization
Depends on the maximum non-orthogonality:
• Less than 60 deg: no special treatment required (Gauss linear
corrected)
• Above 70 deg: limiter can be defined (Gauss linear limited 0.5)
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
23
Finite Volume Method (FVM)
Temporal discretization
The discretization technique which have been discussed above were
Spatial discretization. In transient computation, equation
has another term on the left hand side, the temporal term.
In order to predict time dependent problems this term must be included
and discretized.
Similar to spatial discretization, the first derivative is integrated over a
control volume and then it can be linearized by various numerical
techniques including first-order Euler implicit and second-order backward
difference.
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
24
Finite Volume Method (FVM)
Temporal discretization
For example, using first-order implicit Euler method the temporal term
become:
where values at the start and end of the time step are 𝜙 𝟎 = 𝜙 𝒕 and
𝜙 𝒏 = 𝜙 𝒕 + ∆𝒕 .
This method is bounded first-order implicit.
The finite volume integration of equation over a control volume must be
further integrated over a finite time step ∆𝒕.
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
25
Finite Volume Method (FVM)
Temporal discretization
Considering the integral form of the transport equation. Using spatial
discretization techniques (which are described before) and by applying Euler
fully implicit approach:
Regardless of the schemes which are being used, the equation above can be
summarized as an algebraic system for every control volumes:
One equation of this type is assembled for each control volume.
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
26
Finite Volume Method (FVM)
Temporal discretization
the value of 𝜙𝑷𝒏 is related to the values of the neighboring cells, thus
creating a system of algebraic equations of a form:
where 𝑨 is a sparse matrix with coefficients 𝒂𝑷 and 𝒂𝑵 are the diagonal
and off-diagonal values of the matrix, 𝜙 is the vector of 𝜙 − 𝒔 for all
control volumes and finally 𝑹 is the source term vector.
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
27
Finite Volume Method (FVM)
Pressure-velocity coupling
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
28
Finite Volume Method (FVM)
Pressure-velocity coupling
One of the main challenges in computational fluid dynamics is the
coupling between the velocity and the pressure.
It can be seen from the governing equations that pressure does not have
its own equation in incompressible flow.
The pressure gradient appears on the right hand side of the momentum
equation, however there is no obvious way of obtaining it.
In order to overcome this problem a special treatment is required in order
to form the necessary inter-equation coupling.
One of the popular approach is to use the continuity equation to correct
the pressure iteratively using segregated approach.
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
29
Finite Volume Method (FVM)
Pressure-velocity coupling
In order to obtain an equation for pressure, a semi-discretized form of the
momentum equation is considered:
Source part
Transport part The source part of the transient term
The matrix coefficients for all neighbors and all other source terms
x
Corresponding velocities
To obtain 𝑼 we can divide the equation above by 𝒂𝑷 :
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
30
Finite Volume Method (FVM)
Pressure-velocity coupling
Velocities on the cell face are expressed as the face interpolation:
This equation will be used to compute the face fluxes.
The discretized form of the continuity equation is:
We can obtain the following form of the pressure equation by substituting
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
31
Finite Volume Method (FVM)
Pressure-velocity coupling
Then the final form of the discretized incompressible N-S system is:
With face flux 𝑭 is computed using:
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
32
Finite Volume Method (FVM)
Pressure-velocity coupling
The form of the equations that we obtained shows linear dependence of
velocity on pressure and vice-versa.
This inter-equation coupling requires a special treatment.
Generally there are two ways to solve these equations:
• Simultaneous algorithms: Work by computing the complete system of
equations simultaneously over the entire domain.
• Segregated approach: In this method the equations are solved in
sequence.
OpenFOAM uses segregated approach.
• For transient problems it uses PISO algorithm (pisoFoam).
• For steady-state problems it uses SIMPLE algorithm (simpleFoam).
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
33
Finite Volume Method (FVM)
Pressure-velocity coupling
Pressure Implicit with Splitting of Operator (PISO):
1. Momentum predictor stage: Using the pressure field from the
previous time-step (or initial condition), the momentum equation is
solved.
2. Pressure solution stage: Using the computed velocities, 𝑯 𝑼 can be
assembled and pressure equation can be solved.
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
34
Finite Volume Method (FVM)
Pressure-velocity coupling
Pressure Implicit with Splitting of Operator (PISO):
3. Explicit velocity correction stage: Conservative fluxes will be
computed based on the new pressure. The velocity will be corrected
based on the new pressure distribution in an explicit manner.
4. All other equations will be solved at this stage (e.g. turbulence)
5. The loop is repeated until a pre-defined tolerance is reached.
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
35
Finite Volume Method (FVM)
Pressure-velocity coupling
Semi-Implicit Method for Pressure Linked Equations (SIMPLE):
• The momentum velocity is solved using the pressure distribution
from the previous iteration (or initial condition). The equation is
under-relaxed with the velocity under-relaxation factor.
• The pressure equation is solved using the new velocities.
• With the new set of conservative fluxes, 𝑯 𝑼 , will be computed. Then
the pressure solution is under-relaxed:
Pressure field used in the
momentum predictor The solution of the pressure equation
𝑝𝑛𝑒𝑤 = 𝑝𝑜𝑙𝑑 + 𝛼𝑝 𝑝𝑝 − 𝑝𝑜𝑙𝑑
Pressure under-relaxation factor
• If the velocities are needed before the next momentum solution, the
velocities will be corrected in an explicit manner.
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
36
Finite Volume Method (FVM)
Solution of discretized equations
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
37
Finite Volume Method (FVM)
Solution of discretized equations
Previously we have discussed how to discretize the governing equations of
fluid flow.
The discretization process leads to a system of linear algebraic equations.
In general there are two families of methods to solve these systems:
• Direct methods (e.g. Gaussian elimination)
• Iterative methods (e.g. Gauss-Seidel)
In direct methods, the umber of operation for a system with 𝑵 equations
with 𝑵 unknowns is 𝑵𝟑 with 𝑵𝟐 coefficients must be stored in the memory.
In Iterative methods, the solution is obtained using repeated application of
an algorithm resulting in converged solution. The number of operations
cannot predicted in advance (typically of the order of 𝑵 per iteration cycle).
In segregated, decoupled, FV numerics, matrices are sparse (predominantly
include coefficients of 0).
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
38
Finite Volume Method (FVM)
Solution of discretized equations
In iterative methods, only non-zero coefficients of the equations need to be
stored in the memory.
Because of this, Iterative methods have advantage over direct methods.
In iterative methods, the goal is to reduce the equation residuals.
The equation residual is a measure of the error in the solution (the smaller
it is, the more accurate the solution).
It is computed by substituting the current solution into the equation and
taking the magnitude of the difference between the left and right hand
sides.
𝑨. 𝒙 = 𝒃
it is also normalized to make it independent of the scale of the problem
being analyzed.
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
39
Finite Volume Method (FVM)
Solution of discretized equations
Jacobi iteration method:
Lets consider a set of three equations:
2𝑥1 + 𝑥2 + 𝑥3 = 7
−𝑥1 + 3𝑥2 − 𝑥3 = 2
𝑥1 − 𝑥2 + 2𝑥3 = 5
In iterative methods we rearrange the equations as follows:
𝑥1 = (7 − 𝑥2 − 𝑥3 )/2
𝑥2 = (2 + 𝑥1 + 𝑥3 )/3
𝑥3 = (5 − 𝑥1 + 𝑥2 )/2
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
40
Finite Volume Method (FVM)
Solution of discretized equations
Jacobi iteration method:
In the Jacobi method, the values 𝒙𝒌𝟏 , 𝒙𝒌𝟐 and 𝒙𝒌𝟑 on the left hand side at
iteration 𝒌 are evaluated by substituting in the right hand side the last
known values 𝒙𝒌−𝟏 𝒌−𝟏
𝟏 , 𝒙𝟐 and 𝒙𝒌−𝟏
𝟑 from the previous iteration.
Let’s assume an initial values 𝒙𝟎𝟏 = 𝒙𝟎𝟐 = 𝒙𝟎𝟑 = 𝟎
Substituting these values in the right hand side of the equation
𝑥1 = (7 − 𝑥2 − 𝑥3 )/2
𝑥2 = (2 + 𝑥1 + 𝑥3 )/3
𝑥3 = (5 − 𝑥1 + 𝑥2 )/2
results in 𝑥11 = 3.5 𝑥21 = 0.667 𝑥31 = 2.5
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
41
Finite Volume Method (FVM)
Solution of discretized equations
Jacobi iteration method:
Repeating the procedure:
Iteration 2 𝑥12 = 1.9167 𝑥22 = 2.6667 𝑥32 = 1.0833
Iteration 3 𝑥13 = 1.6250 𝑥23 = 1.6667 𝑥33 = 2.8750
Iteration 4 𝑥14 = 1.2292 𝑥24 = 2.1667 𝑥34 = 2.5208
......
......
......
......
Iteration 17 𝑥117 = 1.0000 𝑥217 = 2.0000 𝑥317 = 3.0000
Check if the results in fact the solution!
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
42
Finite Volume Method (FVM)
Solution of discretized equations
Jacobi iteration method:
In a general form we can write our equations (𝒏 equations and 𝒏
unknowns): 𝑛
𝑎𝑖𝑗 𝑥𝑗 = 𝑏𝑖
𝑗=1
Rearrange to place 𝒙𝒊 on the left hand side of the 𝒊th equation:
𝑛
𝑎𝑖𝑖 𝑥𝑖 = 𝑏𝑖 − 𝑎𝑖𝑖 𝑥𝑗 (𝑖 = 1,2,3, … , 𝑛)
𝑗=1
𝑗≠𝑖
Then the Jacobi method can be written as:
𝑛
−𝑎𝑖𝑗 𝑘−1 𝑏𝑖
𝑥𝑖𝑘 = 𝑥𝑗 + (𝑖 = 1,2,3, … , 𝑛)
𝑎𝑖𝑖 𝑎𝑖𝑖
𝑗=1
𝑗≠𝑖
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
43
Finite Volume Method (FVM)
Solution of discretized equations
Gauss-Seidel iteration method:
• In Jacobi method, the right hand side is evaluated using the results
from the previous iteration or the initial guess.
• When this method is implemented as a code, the computation is carried
out sequentially.
• At the first iteration we start by setting 𝒙𝟎𝟏 = 𝒙𝟎𝟐 = 𝒙𝟎𝟑 = 𝟎 and
computing:
𝑥11 = 7 − 𝑥21 − 𝑥31 2 = 3.5
• Next we evaluate 𝒙𝟐 by the second equation 𝒙𝟐 = (𝟐 + 𝒙𝟏 + 𝒙𝟑 )/𝟑,
however, the equation contains 𝒙𝟏 which is updated in the previous
step.
• In Jacobi method, we use 𝒙𝟎𝟏 = 𝟎.
• In Gauss-Seidel method we use the updated value 𝒙𝟏𝟏 = 𝟑. 𝟓 to compute
𝒙𝟏𝟐 :
𝑥21 = 2 + 𝑥11 − 𝑥30 3 = 1.8333
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
44
Finite Volume Method (FVM)
Solution of discretized equations
Gauss-Seidel iteration method:
• In Jacobi method, the right hand side is evaluated using the results
from the previous iteration or the initial guess.
• When this method is implemented as a code, the computation is carried
out sequentially.
• At the first iteration we start by setting 𝒙𝟎𝟏 = 𝒙𝟎𝟐 = 𝒙𝟎𝟑 = 𝟎 and
computing:
𝑥11 = 7 − 𝑥20 − 𝑥30 2 = 3.5
• Next we evaluate 𝒙𝟐 by the second equation 𝒙𝟐 = (𝟐 + 𝒙𝟏 + 𝒙𝟑 )/𝟑,
however, the equation contains 𝒙𝟏 which is updated in the previous
step.
• In Jacobi method, we use 𝒙𝟎𝟏 = 𝟎.
• In Gauss-Seidel method we use the updated value 𝒙𝟏𝟏 = 𝟑. 𝟓 to compute
𝒙𝟏𝟐 :
𝑥21 = 2 + 𝑥11 − 𝑥30 3 = 1.8333
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
45
Finite Volume Method (FVM)
Solution of discretized equations
Gauss-Seidel iteration method:
• And next we compute 𝒙𝟏𝟑 using the updated values of 𝒙𝟏𝟏 and 𝒙𝟏𝟐 :
𝑥31 = 5 − 𝑥11 − 𝑥21 2 = 1.6667
• If we repeat this procedure we can obtain the solution in only 13
iterations.
• Also we can write Gauss-Seidel method in a general form:
𝑖−1 𝑛
−𝑎𝑖𝑗 𝑘 −𝑎𝑖𝑗 𝑘−1 𝑏𝑖
𝑥𝑖𝑘 = 𝑥𝑗 + 𝑥𝑗 + (𝑖 = 1,2,3, … , 𝑛)
𝑎𝑖𝑖 𝑎𝑖𝑖 𝑎𝑖𝑖
𝑗=1 𝑗=𝑗+1
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
46
Finite Volume Method (FVM)
Solution of discretized equations
Relaxation methods:
• The convergence rate of the Gauss-Seidel method can be improve by
the introduction of a relaxation parameter 𝜶.
• The Gauss-Seidel method can be rewritten in a generalized form as:
𝑖−1 𝑛
−𝑎𝑖𝑗 𝑘 −𝑎𝑖𝑗 𝑘−1 𝑏𝑖
𝑥𝑖𝑘 = 𝑥𝑖𝑘−1 +𝛼 𝑥𝑗 + 𝑥𝑗 + (𝑖 = 1,2,3, … , 𝑛)
𝑎𝑖𝑖 𝑎𝑖𝑖 𝑎𝑖𝑖
𝑗=1 𝑗=𝑖
Set 𝜶 = 𝟏. 𝟎 and 𝟏. 𝟎𝟕
Perform the calculations. Can you detects any improvements
between the two?
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
47
Finite Volume Method (FVM)
Solution of discretized equations
Geometric-algebraic multi-grid solvers:
• It uses the principle of generating a quick solution on a mesh with a
small number of cells; mapping this solution onto a finer mesh; using it
as an initial guess to obtain an accurate solution on the fine mesh.
• Or in short “iterations on computational grids with different sizes” to
improve convergence.
• The mathematical description of the technique can be found in the
relevant literatures.
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari
Institute of Hydraulic Engineering and Water Resources Management
48
Finite Volume Method (FVM)
Solution of discretized equations
Linear solver in OpenFOAM:
• There are various solvers available in OpenFOAM:
• PCG/PBiCGStab: Stabilised preconditioned (bi-)conjugate gradient, for
both symmetric and asymmetric matrices.
• PCG/PBiCG: preconditioned (bi-)conjugate gradient, with PCG for
symmetric matrices, PBiCG for asymmetric matrices.
• smoothSolver: solver that uses a smoother.
• GAMG: generalised geometric-algebraic multi-grid.
• diagonal: diagonal solver for explicit systems.
• Refer to the documentation for short explanation.
NUMERICS IN HYDRAULIC ENGINEERING
15.01.2018 Shervin Shahriari