# NAG FL Interfaced03eef (dim2_​ellip_​discret)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

d03eef discretizes a second-order elliptic partial differential equation (PDE) on a rectangular region.

## 2Specification

Fortran Interface
 Subroutine d03eef ( xmin, xmax, ymin, ymax, pdef, bndy, ngx, ngy, lda, a, rhs,
 Integer, Intent (In) :: ngx, ngy, lda Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: xmin, xmax, ymin, ymax Real (Kind=nag_wp), Intent (Inout) :: a(lda,7) Real (Kind=nag_wp), Intent (Out) :: rhs(lda) Character (1), Intent (In) :: scheme External :: pdef, bndy
#include <nag.h>
 void d03eef_ (const double *xmin, const double *xmax, const double *ymin, const double *ymax, void (NAG_CALL *pdef)(const double *x, const double *y, double *alpha, double *beta, double *gamma, double *delta, double *epslon, double *phi, double *psi),void (NAG_CALL *bndy)(const double *x, const double *y, double *a, double *b, double *c, const Integer *ibnd),const Integer *ngx, const Integer *ngy, const Integer *lda, double a[], double rhs[], const char *scheme, Integer *ifail, const Charlen length_scheme)
The routine may be called by the names d03eef or nagf_pde_dim2_ellip_discret.

## 3Description

d03eef discretizes a second-order linear elliptic partial differential equation of the form
 $α(x,y) ∂2U ∂x2 + β(x,y) ∂2U ∂x ∂y + γ(x,y) ∂2U ∂y2 + δ(x,y) ∂U ∂x +ε(x,y) ∂U ∂y + ϕ(x,y) U = ψ(x,y)$ (1)
on a rectangular region
 $xA≤x≤xB yA≤y≤yB$
subject to boundary conditions of the form
 $a(x,y) U+ b(x,y) ∂U ∂n = c(x,y)$
where $\frac{\partial U}{\partial n}$ denotes the outward pointing normal derivative on the boundary. Equation (1) is said to be elliptic if
 $4 α(x,y) γ(x,y) ≥ (β(x,y)) 2$
for all points in the rectangular region. The linear equations produced are in a form suitable for passing directly to the multigrid routine d03edf.
The equation is discretized on a rectangular grid, with ${n}_{x}$ grid points in the $x$-direction and ${n}_{y}$ grid points in the $y$-direction. The grid spacing used is, therefore,
 $hx=(xB-xA)/(nx-1) hy=(yB-yA)/(ny-1)$
and the coordinates of the grid points $\left({x}_{i},{y}_{j}\right)$ are
 $xi=xA+(i-1)hx, i=1,2,…,nx, yj=yA+(j-1)hy, j=1,2,…,ny.$
At each grid point $\left({x}_{i},{y}_{j}\right)$ six neighbouring grid points are used to approximate the partial differential equation, so that the equation is discretized on the seven-point stencil shown in Figure 1.
For convenience the approximation ${u}_{ij}$ to the exact solution $U\left({x}_{i},{y}_{j}\right)$ is denoted by ${u}_{\mathrm{O}}$, and the neighbouring approximations are labelled according to points of the compass as shown. Where numerical labels for the seven points are required, these are also shown.
The following approximations are used for the second derivatives:
 $∂2U ∂x2 ≃ 1hx2 (uE-2uO+uW) ∂2U ∂y2 ≃ 1hy2 (uN-2uO+uS) ∂2U ∂x∂y ≃ 12hxhy (uN-uNW+uE-2uO+uW-uSE+uS).$
Two possible schemes may be used to approximate the first derivatives:
Central Differences
 $∂U ∂x ≃ 12hx (uE-uW) ∂U ∂y ≃ 12hy (uN-uS)$
Upwind Differences
 $∂U ∂x ≃ 1hx(uO-uW) if δ(x,y)>0 ∂U ∂x ≃ 1hx(uE-uO) if δ(x,y)<0 ∂U ∂y ≃ 1hy(uN-uO) if ε(x,y)>0 ∂U ∂y ≃ 1hy(uO-uS) if ε(x,y)<0.$
Central differences are more accurate than upwind differences, but upwind differences may lead to a more diagonally dominant matrix for those problems where the coefficients of the first derivatives are significantly larger than the coefficients of the second derivatives.
The approximations used for the first derivatives may be written in a more compact form as follows:
 $∂U ∂x ≃ 12hx ((kx-1)uW-2kxuO+(kx+1)uE) ∂U ∂y ≃ 12hy ((ky-1)uS-2kyuO+(ky+1)uN)$
where ${k}_{x}=\mathrm{sign}\delta$ and ${k}_{y}=\mathrm{sign}\epsilon$ for upwind differences, and ${k}_{x}={k}_{y}=0$ for central differences.
At all points in the rectangular domain, including the boundary, the coefficients in the partial differential equation are evaluated by calling pdef, and applying the approximations. This leads to a seven-diagonal system of linear equations of the form:
 $Aij6ui-1,j+1 + Aij7ui,j+1 + Aij3ui-1,j + Aij4uij + Aij5ui+1,j + Aij1ui,j-1 + Aij2ui+1,j-1=fij, i=1,2,…,nx​ and ​j=1,2,…,ny,$
where the coefficients are given by
 $Aij1 = β (xi,yj)12hxhy +γ (xi,yj)1hy2 +ε (xi,yj)12hy (ky-1) Aij2 = -β (xi,yj)12hxhy Aij3 = α (xi,yj)1hx2 +β (xi,yj)12hxhy +δ (xi,yj)12hx (kx-1) Aij4 = -α (xi,yj)2hx2 -β (xi,yj)1hxhy -γ (xi,yj)2hy2 -δ (xi,yj)kyhx-ε (xi,yj)kyhy-ϕ (xi,yj) Aij5 = α (xi,yj)1hx2 +β (xi,yj)12hxhy +δ (xi,yj)12hx (kx+1) Aij6 = -β (xi,yj)12hxhy Aij7 = β (xi,yj)12hxhy +γ (xi,yj)1hy2 +ε (xi,yj)12hy (ky+1) fij = ψ (xi,yj)$
These equations then have to be modified to take account of the boundary conditions. These may be Dirichlet (where the solution is given), Neumann (where the derivative of the solution is given), or mixed (where a linear combination of solution and derivative is given).
If the boundary conditions are Dirichlet, there are an infinity of possible equations which may be applied:
 $μuij = μfij , μ≠0 .$ (2)
If d03edf is used to solve the discretized equations, it turns out that the choice of $\mu$ can have a dramatic effect on the rate of convergence, and the obvious choice $\mu =1$ is not the best. Some choices may even cause the multigrid method to fail altogether. In practice it has been found that a value of the same order as the other diagonal elements of the matrix is best, and the following value has been found to work well in practice:
 $μ=minij (-{2hx2 +2hy2 },Aij4) .$
If the boundary conditions are either mixed or Neumann (i.e., $B\ne 0$ on return from bndy), then one of the points in the seven-point stencil lies outside the domain. In this case the normal derivative in the boundary conditions is used to eliminate the ‘fictitious’ point, ${u}_{\text{outside}}$:
 $∂U ∂n ≃12h (uoutside-uinside).$ (3)
It should be noted that if the boundary conditions are Neumann and $\varphi \left(x,y\right)\equiv 0$, then there is no unique solution. The routine returns with ${\mathbf{ifail}}={\mathbf{5}}$ in this case, and the seven-diagonal matrix is singular.
The four corners are treated separately. bndy is called twice, once along each of the edges meeting at the corner. If both boundary conditions at this point are Dirichlet and the prescribed solution values agree, then this value is used in an equation of the form (2). If the prescribed solution is discontinuous at the corner, then the average of the two values is used. If one boundary condition is Dirichlet and the other is mixed, then the value prescribed by the Dirichlet condition is used in an equation of the form given above. Finally, if both conditions are mixed or Neumann, then two ‘fictitious’ points are eliminated using two equations of the form (3).
It is possible that equations for which the solution is known at all points on the boundary, have coefficients which are not defined on the boundary. Since this routine calls pdef at all points in the domain, including boundary points, arithmetic errors may occur in pdef which this routine cannot trap. If you have an equation with Dirichlet boundary conditions (i.e., $B=0$ at all points on the boundary), but with PDE coefficients which are singular on the boundary, then d03edf could be called directly only using interior grid points at your discretization.
After the equations have been set up as described above, they are checked for diagonal dominance. That is to say,
 $|Aij4| > ∑k≠4 |Aijk| , i=1,2,…,nx ​ and ​ j=1,2,…,ny .$
If this condition is not satisfied then the routine returns with ${\mathbf{ifail}}={\mathbf{6}}$. The multigrid routined03edf may still converge in this case, but if the coefficients of the first derivatives in the partial differential equation are large compared with the coefficients of the second derivative, you should consider using upwind differences (${\mathbf{scheme}}=\text{'U'}$).
Since this routine is designed primarily for use with d03edf, this document should be read in conjunction with the document for that routine.

## 4References

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

## 5Arguments

1: $\mathbf{xmin}$Real (Kind=nag_wp) Input
2: $\mathbf{xmax}$Real (Kind=nag_wp) Input
On entry: the lower and upper $x$ coordinates of the rectangular region respectively, ${x}_{A}$ and ${x}_{B}$.
Constraint: ${\mathbf{xmin}}<{\mathbf{xmax}}$.
3: $\mathbf{ymin}$Real (Kind=nag_wp) Input
4: $\mathbf{ymax}$Real (Kind=nag_wp) Input
On entry: the lower and upper $y$ coordinates of the rectangular region respectively, ${y}_{A}$ and ${y}_{B}$.
Constraint: ${\mathbf{ymin}}<{\mathbf{ymax}}$.
5: $\mathbf{pdef}$Subroutine, supplied by the user. External Procedure
pdef must evaluate the functions $\alpha \left(x,y\right)$, $\beta \left(x,y\right)$, $\gamma \left(x,y\right)$, $\delta \left(x,y\right)$, $\epsilon \left(x,y\right)$, $\varphi \left(x,y\right)$ and $\psi \left(x,y\right)$ which define the equation at a general point $\left(x,y\right)$.
The specification of pdef is:
Fortran Interface
 Subroutine pdef ( x, y, beta, phi, psi)
 Real (Kind=nag_wp), Intent (In) :: x, y Real (Kind=nag_wp), Intent (Out) :: alpha, beta, gamma, delta, epslon, phi, psi
 void pdef (const double *x, const double *y, double *alpha, double *beta, double *gamma, double *delta, double *epslon, double *phi, double *psi)
1: $\mathbf{x}$Real (Kind=nag_wp) Input
2: $\mathbf{y}$Real (Kind=nag_wp) Input
On entry: the $x$ and $y$ coordinates of the point at which the coefficients of the partial differential equation are to be evaluated.
3: $\mathbf{alpha}$Real (Kind=nag_wp) Output
4: $\mathbf{beta}$Real (Kind=nag_wp) Output
5: $\mathbf{gamma}$Real (Kind=nag_wp) Output
6: $\mathbf{delta}$Real (Kind=nag_wp) Output
7: $\mathbf{epslon}$Real (Kind=nag_wp) Output
8: $\mathbf{phi}$Real (Kind=nag_wp) Output
9: $\mathbf{psi}$Real (Kind=nag_wp) Output
On exit: alpha, beta, gamma, delta, epslon, phi and psi must be set to the values of $\alpha \left(x,y\right)$, $\beta \left(x,y\right)$, $\gamma \left(x,y\right)$, $\delta \left(x,y\right)$, $\epsilon \left(x,y\right)$, $\varphi \left(x,y\right)$ and $\psi \left(x,y\right)$ respectively at the point specified by x and y.
pdef must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which d03eef is called. Arguments denoted as Input must not be changed by this procedure.
Note: pdef should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by d03eef. If your code inadvertently does return any NaNs or infinities, d03eef is likely to produce unexpected results.
6: $\mathbf{bndy}$Subroutine, supplied by the user. External Procedure
bndy must evaluate the functions $a\left(x,y\right)$, $b\left(x,y\right)$, and $c\left(x,y\right)$ involved in the boundary conditions.
The specification of bndy is:
Fortran Interface
 Subroutine bndy ( x, y, a, b, c, ibnd)
 Integer, Intent (In) :: ibnd Real (Kind=nag_wp), Intent (In) :: x, y Real (Kind=nag_wp), Intent (Out) :: a, b, c
 void bndy (const double *x, const double *y, double *a, double *b, double *c, const Integer *ibnd)
1: $\mathbf{x}$Real (Kind=nag_wp) Input
2: $\mathbf{y}$Real (Kind=nag_wp) Input
On entry: the $x$ and $y$ coordinates of the point at which the boundary conditions are to be evaluated.
3: $\mathbf{a}$Real (Kind=nag_wp) Output
4: $\mathbf{b}$Real (Kind=nag_wp) Output
5: $\mathbf{c}$Real (Kind=nag_wp) Output
On exit: a, b and c must be set to the values of the functions appearing in the boundary conditions.
6: $\mathbf{ibnd}$Integer Input
On entry: specifies on which boundary the point $\left({\mathbf{x}},{\mathbf{y}}\right)$ lies. ${\mathbf{ibnd}}=0$, $1$, $2$ or $3$ according as the point lies on the bottom, right, top or left boundary.
bndy must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which d03eef is called. Arguments denoted as Input must not be changed by this procedure.
Note: bndy should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by d03eef. If your code inadvertently does return any NaNs or infinities, d03eef is likely to produce unexpected results.
7: $\mathbf{ngx}$Integer Input
8: $\mathbf{ngy}$Integer Input
On entry: the number of interior grid points in the $x$- and $y$-directions respectively, ${n}_{x}$ and ${n}_{y}$. If the seven-diagonal equations are to be solved by d03edf, ${\mathbf{ngx}}-1$ and ${\mathbf{ngy}}-1$ should preferably be divisible by as high a power of $2$ as possible.
Constraints:
• ${\mathbf{ngx}}\ge 3$;
• ${\mathbf{ngy}}\ge 3$.
9: $\mathbf{lda}$Integer Input
On entry: the first dimension of the array a and the dimension of the array rhs as declared in the (sub)program from which d03eef is called.
Constraint: if only the seven-diagonal equations are required, ${\mathbf{lda}}\ge {\mathbf{ngx}}×{\mathbf{ngy}}$. If a call to this routine is to be followed by a call to d03edf to solve the seven-diagonal linear equations, ${\mathbf{lda}}\ge \left(4×\left({\mathbf{ngx}}+1\right)×\left({\mathbf{ngy}}+1\right)\right)/3$.
Note: this routine only checks the former condition. d03edf, if called, will check the latter condition.
10: $\mathbf{a}\left({\mathbf{lda}},7\right)$Real (Kind=nag_wp) array Output
On exit: ${\mathbf{a}}\left(\mathit{i},\mathit{j}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{ngx}}×{\mathbf{ngy}}$ and $\mathit{j}=1,2,\dots ,7$, contains the seven-diagonal linear equations produced by the discretization described above. If ${\mathbf{lda}}>{\mathbf{ngx}}×{\mathbf{ngy}}$, the remaining elements are not referenced by the routine, but if ${\mathbf{lda}}\ge \left(4×\left({\mathbf{ngx}}+1\right)×\left({\mathbf{ngy}}+1\right)\right)/3$ then the array a can be passed directly to d03edf, where these elements are used as workspace.
11: $\mathbf{rhs}\left({\mathbf{lda}}\right)$Real (Kind=nag_wp) array Output
On exit: the first ${\mathbf{ngx}}×{\mathbf{ngy}}$ elements contain the right-hand sides of the seven-diagonal linear equations produced by the discretization described above. If ${\mathbf{lda}}>{\mathbf{ngx}}×{\mathbf{ngy}}$, the remaining elements are not referenced by the routine, but if ${\mathbf{lda}}\ge \left(4×\left({\mathbf{ngy}}+1\right)×\left({\mathbf{ngy}}+1\right)\right)/3$ then the array rhs can be passed directly to d03edf, where these elements are used as workspace.
12: $\mathbf{scheme}$Character(1) Input
On entry: the type of approximation to be used for the first derivatives which occur in the partial differential equation.
${\mathbf{scheme}}=\text{'C'}$
Central differences are used.
${\mathbf{scheme}}=\text{'U'}$
Upwind differences are used.
Constraint: ${\mathbf{scheme}}=\text{'C'}$ or $\text{'U'}$.
Note: generally speaking, if at least one of the coefficients multiplying the first derivatives (delta or epslon as returned by pdef) are large compared with the coefficients multiplying the second derivatives, then upwind differences may be more appropriate. Upwind differences are less accurate than central differences, but may result in more rapid convergence for strongly convective equations. The easiest test is to try both schemes.
13: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $-1$ is recommended since useful values can be provided in some output arguments even when ${\mathbf{ifail}}\ne {\mathbf{0}}$ on exit. When the value $-\mathbf{1}$ or $\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On exit: ${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6Error Indicators and Warnings

If on entry ${\mathbf{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:
Note: in some cases d03eef may return useful information.
${\mathbf{ifail}}=1$
On entry, ${\mathbf{ngx}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ngx}}\ge 3$.
On entry, ${\mathbf{ngx}}×{\mathbf{ngy}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{lda}}=⟨\mathit{\text{value}}⟩$.
Constraint: lda must be at least ${\mathbf{ngx}}×{\mathbf{ngy}}$.
On entry, ${\mathbf{ngy}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ngy}}\ge 3$.
On entry, ${\mathbf{scheme}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{scheme}}=\text{'C'}$ or $\text{'U'}$.
On entry, ${\mathbf{xmin}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{xmax}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{xmin}}<{\mathbf{xmax}}$.
On entry, ${\mathbf{ymin}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{ymax}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ymin}}<{\mathbf{ymax}}$.
${\mathbf{ifail}}=2$
Mixed derivative in equation and derivative in boundary condition at bottom boundary. $\left(x,y\right)=\left(⟨\mathit{\text{value}}⟩\text{, ​}⟨\mathit{\text{value}}⟩\right)$.
Mixed derivative in equation and derivative in boundary condition at bottom left boundary. $\left(x,y\right)=\left(⟨\mathit{\text{value}}⟩\text{, ​}⟨\mathit{\text{value}}⟩\right)$.
Mixed derivative in equation and derivative in boundary condition at bottom right boundary. $\left(x,y\right)=\left(⟨\mathit{\text{value}}⟩\text{, ​}⟨\mathit{\text{value}}⟩\right)$.
Mixed derivative in equation and derivative in boundary condition at left boundary. $\left(x,y\right)=\left(⟨\mathit{\text{value}}⟩\text{, ​}⟨\mathit{\text{value}}⟩\right)$.
Mixed derivative in equation and derivative in boundary condition at right boundary. $\left(x,y\right)=\left(⟨\mathit{\text{value}}⟩\text{, ​}⟨\mathit{\text{value}}⟩\right)$.
Mixed derivative in equation and derivative in boundary condition at top boundary. $\left(x,y\right)=\left(⟨\mathit{\text{value}}⟩\text{, ​}⟨\mathit{\text{value}}⟩\right)$.
Mixed derivative in equation and derivative in boundary condition at top left boundary. $\left(x,y\right)=\left(⟨\mathit{\text{value}}⟩\text{, ​}⟨\mathit{\text{value}}⟩\right)$.
Mixed derivative in equation and derivative in boundary condition at top right boundary. $\left(x,y\right)=\left(⟨\mathit{\text{value}}⟩\text{, ​}⟨\mathit{\text{value}}⟩\right)$.
${\mathbf{ifail}}=3$
Null boundary condition at bottom boundary, left end. $\left(x,y\right)=\left(⟨\mathit{\text{value}}⟩\text{, ​}⟨\mathit{\text{value}}⟩\right)$.
Null boundary condition at bottom boundary, right end. $\left(x,y\right)=\left(⟨\mathit{\text{value}}⟩\text{, ​}⟨\mathit{\text{value}}⟩\right)$.
Null boundary condition at bottom boundary. $\left(x,y\right)=\left(⟨\mathit{\text{value}}⟩\text{, ​}⟨\mathit{\text{value}}⟩\right)$.
Null boundary condition at left boundary, bottom end. $\left(x,y\right)=\left(⟨\mathit{\text{value}}⟩\text{, ​}⟨\mathit{\text{value}}⟩\right)$.
Null boundary condition at left boundary, top end. $\left(x,y\right)=\left(⟨\mathit{\text{value}}⟩\text{, ​}⟨\mathit{\text{value}}⟩\right)$.
Null boundary condition at left boundary. $\left(x,y\right)=\left(⟨\mathit{\text{value}}⟩\text{, ​}⟨\mathit{\text{value}}⟩\right)$.
Null boundary condition at right boundary, bottom end. $\left(x,y\right)=\left(⟨\mathit{\text{value}}⟩\text{, ​}⟨\mathit{\text{value}}⟩\right)$.
Null boundary condition at right boundary, top end. $\left(x,y\right)=\left(⟨\mathit{\text{value}}⟩\text{, ​}⟨\mathit{\text{value}}⟩\right)$.
Null boundary condition at right boundary. $\left(x,y\right)=\left(⟨\mathit{\text{value}}⟩\text{, ​}⟨\mathit{\text{value}}⟩\right)$.
Null boundary condition at top boundary, left end. $\left(x,y\right)=\left(⟨\mathit{\text{value}}⟩\text{, ​}⟨\mathit{\text{value}}⟩\right)$.
Null boundary condition at top boundary, right end. $\left(x,y\right)=\left(⟨\mathit{\text{value}}⟩\text{, ​}⟨\mathit{\text{value}}⟩\right)$.
Null boundary condition at top boundary. $\left(x,y\right)=\left(⟨\mathit{\text{value}}⟩\text{, ​}⟨\mathit{\text{value}}⟩\right)$.
${\mathbf{ifail}}=4$
Equation not elliptic at some point.
${\mathbf{ifail}}=5$
There is no unique solution with Neumann Boundary conditions.
${\mathbf{ifail}}=6$
The linear equations were not diagonally dominant.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

Not applicable.

## 8Parallelism and Performance

d03eef is not threaded in any implementation.

If this routine is used as a preprocessor to the multigrid routine d03edf it should be noted that the rate of convergence of that routine is strongly dependent upon the number of levels in the multigrid scheme, and thus the choice of ngx and ngy is very important.

## 10Example

The program solves the elliptic partial differential equation
 $∂2U ∂x2 + ∂2 U ∂y2 +50 ⁢ { ∂U ∂x + ∂U ∂y }=f(x,y)$
on the unit square $0\le x$, $y\le 1$, with boundary conditions
• $\frac{\partial U}{\partial n}$ given on $x=0$ and $y=0$,
• $U$ given on $x=1$ and $y=1$.
The function $f\left(x,y\right)$ and the exact form of the boundary conditions are derived from the exact solution $U\left(x,y\right)=\mathrm{sin}x\mathrm{sin}y$.
The equation is first solved using central differences. Since the coefficients of the first derivatives are large, the linear equations are not diagonally dominated, and convergence is slow. The equation is solved a second time with upwind differences, showing that convergence is more rapid, but the solution is less accurate.

### 10.1Program Text

Program Text (d03eefe.f90)

### 10.2Program Data

Program Data (d03eefe.d)

### 10.3Program Results

Program Results (d03eefe.r)