NAG Library Routine Document

d03ubf  (dim3_ellip_fd_iter)

 Contents

    1  Purpose
    7  Accuracy

1
Purpose

d03ubf 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 seven-point molecule form on a three-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

Fortran Interface
Subroutine d03ubf ( n1, n2, n3, lda, sda, a, b, c, d, e, f, g, aparam, it, r, wrksp1, wrksp2, wrksp3, ifail)
Integer, Intent (In):: n1, n2, n3, lda, sda, it
Integer, Intent (Inout):: ifail
Real (Kind=nag_wp), Intent (In):: a(lda,sda,n3), b(lda,sda,n3), c(lda,sda,n3), d(lda,sda,n3), e(lda,sda,n3), f(lda,sda,n3), g(lda,sda,n3), aparam
Real (Kind=nag_wp), Intent (Inout):: r(lda,sda,n3), wrksp1(lda,sda,n3), wrksp2(lda,sda,n3), wrksp3(lda,sda,n3)
C Header Interface
#include nagmk26.h
void  d03ubf_ ( const Integer *n1, const Integer *n2, const Integer *n3, const Integer *lda, const Integer *sda, const double a[], const double b[], const double c[], const double d[], const double e[], const double f[], const double g[], const double *aparam, const Integer *it, double r[], double wrksp1[], double wrksp2[], double wrksp3[], Integer *ifail)

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 three-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
r n = 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.
d03ubf 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×n3 by n1×n2×n3 matrix and r is a known vector of length n1×n2×n3. The set of equations (2) must be of seven-diagonal form
aijksij,k-1+bijksi,j-1,k+cijksi-1,jk+dijksijk+eijksi+1,jk+fijksi,j+1,k+gijksij,k+1=rijk  
for i=1,2,,n1, j=1,2,,n2 and k=1,2,,n3, provided that dijk0.0. Indeed, if dijk=0.0, then the equation is assumed to be
sijk=rijk.  
The calling program supplies the current residual r at each iteration and the coefficients of the seven-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 argument 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 seven-diagonal element arrays a, b, c, d, e, f and g 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 seven-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 seven-diagonal system (2) of the form given above. For example, the solution of a system of eleven-diagonal equations each involving the combination of terms with ti±1,j±1,k,ti±1,j,k,ti,j±1,k,ti,j,k±1 and tijk could use the seven-diagonal coefficients on which to base the update, provided these incorporate the major features of the equations.
Problems in topologically non-rectangular box-shaped regions can be solved using the routine by surrounding the region with a circumscribing topologically rectangular box. The equations for the nodal values external to the region of interest are set to zero (i.e., dijk=rijk=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, f and g 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 three 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, e, f and g 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 Poisson'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 for those cases when convergence is slow. For such problems there is generally an associated compatibility condition. For the example mentioned this compatibility condition equates the total net source within the region (i.e., the source integrated over the region) with the total net outflow across the boundaries defined by the Neumann conditions (i.e., the normal derivative integrated along the whole boundary). It is very important that the algebraic equations derived to model such a problem accurately implement the compatibility condition. If they do not, a net source or sink is very likely to be represented by the set of algebraic equations and no steady-state solution of the equations exists.

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
Weinstein H G, Stone H L and Kwan T V (1969) Iterative procedure for solution of systems of parabolic and elliptic equations in three dimensions Industrial and Engineering Chemistry Fundamentals 8 281–287

5
Arguments

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:     n3 – IntegerInput
On entry: the number of nodes in the third coordinate direction, n3.
Constraint: n3>1.
4:     lda – IntegerInput
On entry: the first dimension of the arrays a, b, c, d, e, f, g, r, wrksp1, wrksp2 and wrksp3 as declared in the (sub)program from which d03ubf is called.
Constraint: ldan1.
5:     sda – IntegerInput
On entry: the second dimension of the arrays a, b, c, d, e, f, g, r, wrksp1, wrksp2 and wrksp3 as declared in the (sub)program from which d03ubf is called.
Constraint: sdan2.
6:     aldasdan3 – Real (Kind=nag_wp) arrayInput
On entry: aijk must contain the coefficient of sij,k-1 in the i,j,kth equation of the system (2), for i=1,2,,n1, j=1,2,,n2 and k=1,2,,n3. The elements of a, for k=1, must be zero after incorporating the boundary conditions, since they involve nodal values from outside the box.
7:     bldasdan3 – Real (Kind=nag_wp) arrayInput
On entry: bijk must contain the coefficient of si,j-1,k in the i,j,kth equation of the system (2), for i=1,2,,n1, j=1,2,,n2 and k=1,2,,n3. The elements of b, for j=1, must be zero after incorporating the boundary conditions, since they involve nodal values from outside the box.
8:     cldasdan3 – Real (Kind=nag_wp) arrayInput
On entry: cijk must contain the coefficient of si-1,j,k in the i,j,kth equation of the system (2), for i=1,2,,n1, j=1,2,,n2 and k=1,2,,n3. The elements of c, for i=1, must be zero after incorporating the boundary conditions, since they involve nodal values from outside the box.
9:     dldasdan3 – Real (Kind=nag_wp) arrayInput
On entry: dijk must contain the coefficient of sijk, the ‘central’ term, in the i,j,kth equation of the system (2), for i=1,2,,n1, j=1,2,,n2 and k=1,2,,n3. The elements of d are checked to ensure that they are nonzero. If any element is found to be zero, the corresponding algebraic equation is assumed to be sijk=rijk. 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 dijk=0.0 at appropriate points. The corresponding value of rijk is set equal to the appropriate value, namely the difference between the prescribed value of tijk and the current value in the Dirichlet case, or zero at an external point.
10:   eldasdan3 – Real (Kind=nag_wp) arrayInput
On entry: eijk must contain the coefficient of si+1,j,k in the i,j,kth equation of the system (2), for i=1,2,,n1, j=1,2,,n2 and k=1,2,,n3. The elements of e, for i=n1, must be zero after incorporating the boundary conditions, since they involve nodal values from outside the box.
11:   fldasdan3 – Real (Kind=nag_wp) arrayInput
On entry: fijk must contain the coefficient of si,j+1,k in the i,j,kth equation of the system (2), for i=1,2,,n1, j=1,2,,n2 and k=1,2,,n3. The elements of f, for j=n2, must be zero after incorporating the boundary conditions, since they involve nodal values from outside the box.
12:   gldasdan3 – Real (Kind=nag_wp) arrayInput
On entry: gijk must contain the coefficient of si,j,k+1 in the i,j,kth equation of the system (2), for i=1,2,,n1, j=1,2,,n2 and k=1,2,,n3. The elements of g, for k=n3, must be zero after incorporating the boundary conditions, since they involve nodal values from outside the box.
13:   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<aparamn1-12+n2-12+n3-12/3.0.
14:   it – IntegerInput
On entry: the iteration number. It must be initialized, but not necessarily to 1, before the first call, and should be incremented by one in the calling program for each subsequent call. The routine uses this counter to select the appropriate acceleration argument from a sequence of nine, each one being used twice in succession. (Note that the acceleration argument depends on the value of aparam.)
15:   rldasdan3 – Real (Kind=nag_wp) arrayInput/Output
On entry: the current residual rijk on the right-hand side of the i,j,kth equation of the system (2), for i=1,2,,n1, j=1,2,,n2 and k=1,2,,n3.
On exit: these residuals are overwritten by the corresponding components of the solution s of the system (2), i.e., the changes to be made to the vector t to reduce the residuals supplied.
16:   wrksp1ldasdan3 – Real (Kind=nag_wp) arrayWorkspace
17:   wrksp2ldasdan3 – Real (Kind=nag_wp) arrayWorkspace
18:   wrksp3ldasdan3 – Real (Kind=nag_wp) arrayWorkspace
19:   ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1​ or ​1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation 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 argument, 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,
orn3<2.
ifail=2
On entry,lda<n1,
orsda<n2.
ifail=3
On entry,aparam0.0.
ifail=4
On entry,aparam>n1-12+n2-12+n3-12/3.0.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

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 seven-diagonal coefficient arrays. The ultimate accuracy obtainable depends on the above factors and on the machine precision. However, since d03ubf 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 arguments. 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
Parallelism and Performance

d03ubf is not threaded in any implementation.

9
Further Comments

The time taken is approximately proportional to n1×n2×n3 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 seven-point molecule coefficients used by d03ubf 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.

10
Example

This example solves Laplace's equation in a rectangular box with a non-uniform grid spacing in the x, y and z coordinate directions and with Dirichlet boundary conditions specifying the function on the surfaces of the box equal to
e1.0+x/yn2×cos2y/yn2×e-1.0-z/yn2.  
Note that this is the same problem as that solved in the example for d03ecf. The differences in the maximum residuals obtained at each iteration between the two test runs are explained by the fact that in d03ecf the residual at each node is normalized by dividing by the central coefficient, whereas this normalization has not been used in the example program for d03ubf.

10.1
Program Text

Program Text (d03ubfe.f90)

10.2
Program Data

Program Data (d03ubfe.d)

10.3
Program Results

Program Results (d03ubfe.r)

GnuplotProduced by GNUPLOT 4.6 patchlevel 3 Example Program Solution of Three-dimensional Laplace's Equation in a Box Solutions in the xy-plane for Various Values of z U gnuplot_plot_1 gnuplot_plot_2 z = 0 gnuplot_plot_3 z = 2 gnuplot_plot_4 z = 7.4 0 1 2 3 4 5 6 x 0 2 4 6 8 10 y 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
© The Numerical Algorithms Group Ltd, Oxford, UK. 2017