D03UAF (PDF version)
D03 Chapter Contents
D03 Chapter Introduction
NAG Library Manual

NAG Library Routine Document

D03UAF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

D03UAF performs at each call one iteration of the Strongly Implicit Procedure. It is used to calculate on successive calls a sequence of approximate corrections to the current estimate of the solution when solving a system of simultaneous algebraic equations for which the iterative update matrix is of five-point molecule form on a two-dimensional topologically-rectangular mesh. (‘Topological’ means that a polar grid r,θ, for example, can be used as it is equivalent to a rectangular box.)

2  Specification

SUBROUTINE D03UAF ( N1, N2, LDA, A, B, C, D, E, APARAM, IT, R, WRKSP1, WRKSP2, IFAIL)
INTEGER  N1, N2, LDA, IT, IFAIL
REAL (KIND=nag_wp)  A(LDA,N2), B(LDA,N2), C(LDA,N2), D(LDA,N2), E(LDA,N2), APARAM, R(LDA,N2), WRKSP1(LDA,N2), WRKSP2(LDA,N2)

3  Description

Given a set of simultaneous equations
Mt=q (1)
(which could be nonlinear) derived, for example, from a finite difference representation of a two-dimensional elliptic partial differential equation and its boundary conditions, the solution t may be obtained iteratively from a starting approximation t 1  by the formulae
rn = q-Mtn Msn = r n t n+1 = t n +s n .
Thus r n  is the residual of the nth approximate solution t n , and s n  is the update change vector.
D03UAF determines the approximate change vector s corresponding to a given residual r, i.e., it determines an approximate solution to a set of equations
Ms=r (2)
where M is a square n1×n2 by n1×n2 matrix and r is a known vector of length n1×n2. The set of equations (2) must be of five-diagonal form
aij si,j-1 + bij si-1,j + cij sij + dij si+1,j + eij si,j+1 = rij ,
for i=1,2,,n1 and j=1,2,,n2, provided that cij0.0. Indeed, if cij=0.0, then the equation is assumed to be
sij=rij.
For example, if n1=3 and n2=2, the equations take the form
c11 d11 e11 b21 c21 d21 e21 b31 c31 e31 a12 c12 d12 a22 b22 c22 d22 a32 b32 c32 s11 s21 s31 s12 s22 s32 = r11 r21 r31 r12 r22 r32 .
The calling program supplies the current residual r at each iteration and the coefficients of the five-point molecule system of equations on which the update procedure is based. The routine performs one iteration, using the approximate LU factorization of the Strongly Implicit Procedure with the necessary acceleration parameter adjustment, to calculate the approximate solution s of the set of equations (2). The change s overwrites the residual array for return to the calling program. The calling program must combine this change stored in r with the old approximation to obtain the new approximate solution for t. It must then recalculate the residuals and, if the accuracy requirements have not been satisfied, commence the next iterative cycle.
Clearly there is no requirement that the iterative update matrix passed in the form of the five-diagonal element arrays A, B, C, D and E is the same as that used to calculate the residuals, and therefore the one governing the problem. However, the convergence may be impaired if they are not equal. Indeed, if the system of equations (1) is not precisely of the five-diagonal form illustrated above but has a few additional terms, then the methods of deferred or defect correction can be employed. The residual is calculated by the calling program using the full system of equations, but the update formula is based on a five-diagonal system (2) of the form given above. For example, the solution of a system of nine-diagonal equations each involving the combination of terms with ti±1,j±1,ti±1,j,ti,j±1 and tij could use the five-diagonal coefficients on which to base the update, provided these incorporate the major features of the equations.
Problems in topologically non-rectangular regions can be solved using the routine by surrounding the region with a circumscribing topological rectangle. The equations for the nodal values external to the region of interest are set to zero (i.e., cij=rij=0) and the boundary conditions are incorporated into the equations for the appropriate nodes.
If there is no better initial approximation when starting the iterative cycle, one can use an array of all zeros as the initial approximation from which the first set of residuals are determined.
The routine can be used to solve linear elliptic equations in which case the arrays A, B, C, D, E and the quantities q will be unchanged during the iterative cycles, or for solving nonlinear elliptic equations in which case some or all of these arrays may require updating as each new approximate solution is derived. Depending on the nonlinearity, some under-relaxation of the coefficients and/or source terms may be needed during their recalculation using the new estimates of the solution (see Jacobs (1972)).
The routine can also be used to solve each step of a time-dependent parabolic equation in two space dimensions. The solution at each time step can be expressed in terms of an elliptic equation if the Crank–Nicolson or other form of implicit time integration is used.
Neither diagonal dominance, nor positive-definiteness, of the matrix M or of the update matrix formed from the arrays A, B, C, D and E is necessary to ensure convergence.
For problems in which the solution is not unique, in the sense that an arbitrary constant can be added to the solution (for example Laplace's equation with all Neumann boundary conditions), the calling program should subtract a typical nodal value from the whole solution t at every iteration to keep rounding errors to a minimum.

4  References

Ames W F (1977) Nonlinear Partial Differential Equations in Engineering (2nd Edition) Academic Press
Jacobs D A H (1972) The strongly implicit procedure for the numerical solution of parabolic and elliptic partial differential equations Note RD/L/N66/72 Central Electricity Research Laboratory
Stone H L (1968) Iterative solution of implicit approximations of multi-dimensional partial differential equations SIAM J. Numer. Anal. 5 530–558

5  Parameters

1:     N1 – INTEGERInput
On entry: the number of nodes in the first coordinate direction, n1.
Constraint: N1>1.
2:     N2 – INTEGERInput
On entry: the number of nodes in the second coordinate direction, n2.
Constraint: N2>1.
3:     LDA – INTEGERInput
On entry: the first dimension of the arrays A, B, C, D, E, R, WRKSP1 and WRKSP2 as declared in the (sub)program from which D03UAF is called.
Constraint: LDAN1.
4:     A(LDA,N2) – REAL (KIND=nag_wp) arrayInput
On entry: Aij must contain the coefficient of the ‘southerly’ term involving si,j-1 in the i,jth equation of the system (2), for i=1,2,,N1 and j=1,2,,N2. The elements of A, for j=1, must be zero after incorporating the boundary conditions, since they involve nodal values from outside the rectangle.
5:     B(LDA,N2) – REAL (KIND=nag_wp) arrayInput
On entry: Bij must contain the coefficient of the ‘westerly’ term involving si-1,j in the i,jth equation of the system (2), for i=1,2,,N1 and j=1,2,,N2. The elements of B, for i=1, must be zero after incorporating the boundary conditions, since they involve nodal values from outside the rectangle.
6:     C(LDA,N2) – REAL (KIND=nag_wp) arrayInput
On entry: Cij must contain the coefficient of the ‘central’ term involving sij in the i,jth equation of the system (2), for i=1,2,,N1 and j=1,2,,N2. The elements of C are checked to ensure that they are nonzero. If any element is found to be zero, the corresponding algebraic equation is assumed to be sij=rij. This feature can be used to define the equations for nodes at which, for example, Dirichlet boundary conditions are applied, or for nodes external to the problem of interest, by setting Cij=0.0 at appropriate points. The corresponding value of Rij is set equal to the appropriate value, namely the difference between the prescribed value of tij and the current value of tij in the Dirichlet case, or zero at an external point.
7:     D(LDA,N2) – REAL (KIND=nag_wp) arrayInput
On entry: Dij must contain the coefficient of the ‘easterly’ term involving si+1,j in the i,jth equation of the system (2), for i=1,2,,N1 and j=1,2,,N2. The elements of D, for i=N1, must be zero after incorporating the boundary conditions, since they involve nodal values from outside the rectangle.
8:     E(LDA,N2) – REAL (KIND=nag_wp) arrayInput
On entry: Eij must contain the coefficient of the ‘northerly’ term involving si,j+1 in the i,jth equation of the system (2), for i=1,2,,N1 and j=1,2,,N2. The elements of E, for j=N2, must be zero after incorporating the boundary conditions, since they involve nodal values from outside the rectangle.
9:     APARAM – REAL (KIND=nag_wp)Input
On entry: the iteration acceleration factor. A value of 1.0 is adequate for most typical problems. However, if convergence is slow, the value can be reduced, typically to 0.2 or 0.1. If divergence is obtained, the value can be increased, typically to 2.0, 5.0 or 10.0.
Constraint: 0.0<APARAM N1-1 2+ N2-1 2/2.0.
10:   IT – INTEGERInput
On entry: the iteration number. It must be initialized, but not necessarily to 1, before the first call, and must be incremented by one in the calling program for each subsequent call. D03UAF uses the counter to select the appropriate acceleration parameter from a sequence of nine, each one being used twice in succession. (Note that the acceleration parameter depends on the value of APARAM.)
11:   R(LDA,N2) – REAL (KIND=nag_wp) arrayInput/Output
On entry: Rij must contain the current residual rij on the right-hand side of the i,jth equation of the system (2), for i=1,2,,N1 and j=1,2,,N2.
On exit: these residuals are overwritten by the corresponding components of solution s to the system (2), i.e., the changes to be made to the vector t to reduce the residuals supplied.
12:   WRKSP1(LDA,N2) – REAL (KIND=nag_wp) arrayWorkspace
13:   WRKSP2(LDA,N2) – REAL (KIND=nag_wp) arrayWorkspace
14:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry IFAIL=0 or -1, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
IFAIL=1
On entry,N1<2,
orN2<2.
IFAIL=2
On entry,LDA<N1.
IFAIL=3
On entry,APARAM0.0.
IFAIL=4
On entry,APARAM> N1-1 2+ N2-1 2/2.0.

7  Accuracy

The improvement in accuracy for each iteration, i.e., on each call, depends on the size of the system and on the condition of the update matrix characterised by the five-diagonal coefficient arrays. The ultimate accuracy obtainable depends on the above factors and on the machine precision. However, since D03UAF works with residuals and the update vector, the calling program can, in most cases where at each iteration all the residuals are usually of about the same size, calculate the residuals from extended precision values of the function, source term and equation coefficients if greater accuracy is required. The rate of convergence obtained with the Strongly Implicit Procedure is not always smooth because of the cyclic use of nine acceleration parameters. The convergence may become slow with very large problems. The final accuracy obtained can be judged approximately from the rate of convergence determined from the changes to the dependent variable t and in particular the change on the last iteration.

8  Further Comments

The time taken is approximately proportional to N1×N2 for each call.
When used with deferred or defect correction, the residual is calculated in the calling program from a different system of equations to those represented by the five-point molecule coefficients used by D03UAF as the basis of the iterative update procedure. When using deferred correction the overall rate of convergence depends not only on the items detailed in Section 7 but also on the difference between the two coefficient matrices used.
Convergence may not always be obtained when the problem is very large and/or the coefficients of the equations have widely disparate values. The latter case may be associated with an ill-conditioned matrix.

9  Example

This example solves Laplace's equation in a rectangle with a non-uniform grid spacing in the x and y coordinate directions and with Dirichlet boundary conditions specifying the function on the perimeter of the rectangle equal to e1.0+x/yn2×cosy/yn2.

9.1  Program Text

Program Text (d03uafe.f90)

9.2  Program Data

Program Data (d03uafe.d)

9.3  Program Results

Program Results (d03uafe.r)

Produced by GNUPLOT 4.4 patchlevel 0 Example Program Laplace's Equation on a Non-uniform Grid 0 2 4 6 8 10 12 14 16 x 0 5 10 15 20 25 30 35 40 45 y 0.5 0.6 0.7 0.8 0.9 1 1.1 1.2 1.3 1.4 1.5 U

D03UAF (PDF version)
D03 Chapter Contents
D03 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2012