naginterfaces.library.pde.dim2_​ellip_​mgrid

naginterfaces.library.pde.dim2_ellip_mgrid(ngx, ngy, a, rhs, ub, maxit, acc, iout, io_manager=None)[source]

dim2_ellip_mgrid solves seven-diagonal systems of linear equations which arise from the discretization of an elliptic partial differential equation on a rectangular region. This function uses a multigrid technique.

For full information please refer to the NAG Library document for d03ed

https://www.nag.com/numeric/nl/nagdoc_27.3/flhtml/d03/d03edf.html

Parameters
ngxint

The number of interior grid points in the -direction, . should preferably be divisible by as high a power of as possible.

ngyint

The number of interior grid points in the -direction, . should preferably be divisible by as high a power of as possible.

afloat, array-like, shape

must be set to , for , for , for .

rhsfloat, array-like, shape

must be set to , for , for .

ubfloat, array-like, shape

must be set to the initial estimate for the solution .

maxitint

The maximum permitted number of multigrid iterations. If , no multigrid iterations are performed, but the coarse-grid approximations and incomplete Crout decompositions are computed, and may be output if is set accordingly.

accfloat

The required tolerance for convergence of the residual -norm:

where and is the computed solution. Note that the norm is not scaled by the number of equations. The function will stop after fewer than iterations if the residual -norm is less than the specified tolerance. (If , at least one iteration is always performed.)

If on entry , the machine precision is used as a default value for the tolerance; if , but is less than the machine precision, the function will stop when the residual -norm is less than the machine precision and will be set to .

ioutint

Controls the output of printed information to the file object associated with the advisory I/O unit (see FileObjManager):

No output.

The solution , for , for .

The residual -norm after each iteration, with the reduction factor over the previous iteration.

As for and .

As for , plus the final residual (as returned in ).

As for , plus the initial elements of and .

As for , plus the Galerkin coarse grid approximations.

As for , plus the incomplete Crout decompositions.

As for , plus the residual after each iteration.

The elements , the Galerkin coarse grid approximations and the incomplete Crout decompositions are output in the format:

Y-index

X-index

where , for , for .

The vectors , , are output in matrix form with rows and columns.

Where , the values for a given value are produced in rows of .

Values of may yield considerable amounts of output.

io_managerFileObjManager, optional

Manager for I/O in this routine.

Returns
afloat, ndarray, shape

Is overwritten.

rhsfloat, ndarray, shape

The first elements are unchanged and the rest of the array is used as workspace.

ubfloat, ndarray, shape

The corresponding component of the residual .

usfloat, ndarray, shape

The residual -norm, stored in element .

ufloat, ndarray, shape

The computed solution is returned in , for , for .

numitint

The number of iterations performed.

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

After iterations the residual norm is not less than the tolerance , residual norm , tolerance . The residual norm increased at one or more iterations after the first.

Warns
NagAlgorithmicWarning
(errno )

After iterations the residual norm is not less than the tolerance , residual norm , tolerance . The residual norm has decreased at each iteration after the first.

(errno )

On entry, is less than machine precision. The function terminated because the residual norm is less than machine precision. residual norm , machine precision and .

Notes

No equivalent traditional C interface for this routine exists in the NAG Library.

dim2_ellip_mgrid solves, by multigrid iteration, the seven-point scheme

which arises from the discretization of an elliptic partial differential equation of the form

and its boundary conditions, defined on a rectangular region. This we write in matrix form as

The algorithm is described in separate reports by Wesseling (1982a), Wesseling (1982b) and McCarthy (1983).

Systems of linear equations, matching the seven-point stencil defined above, are solved by a multigrid iteration. An initial estimate of the solution must be provided by you. A zero guess may be supplied if no better approximation is available.

A ‘smoother’ based on incomplete Crout decomposition is used to eliminate the high frequency components of the error. A restriction operator is then used to map the system on to a sequence of coarser grids. The errors are then smoothed and prolongated (mapped onto successively finer grids). When the finest cycle is reached, the approximation to the solution is corrected. The cycle is repeated for iterations or until the required accuracy, , is reached.

dim2_ellip_mgrid will automatically determine the number of possible coarse grids, ‘levels’ of the multigrid scheme, for a particular problem. In other words, dim2_ellip_mgrid determines the maximum integer so that and can be expressed in the form

It should be noted that the rate of convergence improves significantly with the number of levels used (see McCarthy (1983)), so that and should be carefully chosen so that and have factors of the form , with as large as possible. For good convergence the integer should be at least .

dim2_ellip_mgrid has been found to be robust in application, but being an iterative method the problem of divergence can arise. For a strictly diagonally dominant matrix

no such problem is foreseen. The diagonal dominance of is not a necessary condition, but should this condition be strongly violated then divergence may occur. The quickest test is to try the function.

References

McCarthy, G J, 1983, Investigation into the multigrid code MGD1, Report AERE-R 10889, Harwell

Wesseling, P, 1982, MGD1 – a robust and efficient multigrid method, Multigrid Methods. Lecture Notes in Mathematics (960), 614–630, Springer–Verlag

Wesseling, P, 1982, Theoretical aspects of a multigrid method, SIAM J. Sci. Statist. Comput. (3), 387–407