Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_pde_2d_gen_order2_checkgrid (d03ry)

## Purpose

nag_pde_2d_gen_order2_checkgrid (d03ry) is designed to be used in conjunction with nag_pde_2d_gen_order2_rectilinear (d03rb). It can be called from the inidom to check the user-specified initial grid data and to obtain a simple graphical representation of the initial grid.

## Syntax

[pgrid, ifail] = d03ry(nx, ny, lrow, irow, icol, llbnd, ilbnd, lbnd, 'npts', npts, 'nrows', nrows, 'nbnds', nbnds, 'nbpts', nbpts)
[pgrid, ifail] = nag_pde_2d_gen_order2_checkgrid(nx, ny, lrow, irow, icol, llbnd, ilbnd, lbnd, 'npts', npts, 'nrows', nrows, 'nbnds', nbnds, 'nbpts', nbpts)

## Description

nag_pde_2d_gen_order2_checkgrid (d03ry) outputs a character array which can be printed to provide a simple graphical representation of the virtual and base grids supplied to nag_pde_2d_gen_order2_rectilinear (d03rb). It must be called only from within the inidom after all output parameters of inidom (other than ierr) have been set. nag_pde_2d_gen_order2_checkgrid (d03ry) also checks the validity of the grid data specified in inidom.
You are strongly advised to call nag_pde_2d_gen_order2_checkgrid (d03ry) during the initial call of nag_pde_2d_gen_order2_rectilinear (d03rb) (at least) and to print the resulting character array in order to check that the base grid is exactly as required.
nag_pde_2d_gen_order2_checkgrid (d03ry) writes a representation of each point in the virtual and base grids to the character array pgrid as follows:
 – internal base grid points are written as two dots (..); – boundary base grid points are written as the ilbnd value (i.e., the type) of the boundary; – points external to the base grid are written as XX.
As an example, consider a rectangular domain with a rectangular hole in which the virtual domain extends by one base grid point beyond the actual domain in all directions. The output when each row of pgrid is printed consecutively is as follows:
``` XX XX XX XX XX XX XX XX XX XX XX XX XX XX
XX 23  3  3  3  3  3  3  3  3  3  3 34 XX
XX  2 .. .. .. .. .. .. .. .. .. ..  4 XX
XX  2 .. .. .. .. .. .. .. .. .. ..  4 XX
XX  2 .. .. 14  1  1  1  1 21 .. ..  4 XX
XX  2 .. ..  4 XX XX XX XX  2 .. ..  4 XX
XX  2 .. ..  4 XX XX XX XX  2 .. ..  4 XX
XX  2 .. ..  4 XX XX XX XX  2 .. ..  4 XX
XX  2 .. ..  4 XX XX XX XX  2 .. ..  4 XX
XX  2 .. ..  4 XX XX XX XX  2 .. ..  4 XX
XX  2 .. .. 43  3  3  3  3 32 .. ..  4 XX
XX  2 .. .. .. .. .. .. .. .. .. ..  4 XX
XX  2 .. .. .. .. .. .. .. .. .. ..  4 XX
XX 12  1  1  1  1  1  1  1  1  1  1 41 XX
XX XX XX XX XX XX XX XX XX XX XX XX XX XX
```

None.

## Parameters

### Compulsory Input Parameters

1:     nx – int64int32nag_int scalar
2:     ny – int64int32nag_int scalar
The number of virtual grid points in the x$x$- and y$y$-direction respectively (including the boundary points).
Constraint: nx and ny4${\mathbf{ny}}\ge 4$.
3:     lrow(nrows) – int64int32nag_int array
nrows, the dimension of the array, must satisfy the constraint 4nrowsny$4\le {\mathbf{nrows}}\le {\mathbf{ny}}$.
lrow(i)${\mathbf{lrow}}\left(\mathit{i}\right)$, for i = 1,2,,nrows$\mathit{i}=1,2,\dots ,{\mathbf{nrows}}$, contains the base grid index of the first grid point in base grid row i$\mathit{i}$.
Constraints:
• 1lrow(i)npts$1\le {\mathbf{lrow}}\left(\mathit{i}\right)\le {\mathbf{npts}}$, for i = 1,2,,nrows$\mathit{i}=1,2,\dots ,{\mathbf{nrows}}$;
• lrow(i1) < lrow(i)${\mathbf{lrow}}\left(\mathit{i}-1\right)<{\mathbf{lrow}}\left(\mathit{i}\right)$, for i = 2,3,,nrows$\mathit{i}=2,3,\dots ,{\mathbf{nrows}}$.
4:     irow(nrows) – int64int32nag_int array
nrows, the dimension of the array, must satisfy the constraint 4nrowsny$4\le {\mathbf{nrows}}\le {\mathbf{ny}}$.
irow(i)${\mathbf{irow}}\left(\mathit{i}\right)$, for i = 1,2,,nrows$\mathit{i}=1,2,\dots ,{\mathbf{nrows}}$, contains the virtual grid row number that corresponds to base grid row i$\mathit{i}$.
Constraints:
• 0irow(i)ny$0\le {\mathbf{irow}}\left(\mathit{i}\right)\le {\mathbf{ny}}$, for i = 1,2,,nrows$\mathit{i}=1,2,\dots ,{\mathbf{nrows}}$;
• irow(i1) < irow(i)${\mathbf{irow}}\left(\mathit{i}-1\right)<{\mathbf{irow}}\left(\mathit{i}\right)$, for i = 2,3,,nrows$\mathit{i}=2,3,\dots ,{\mathbf{nrows}}$.
5:     icol(npts) – int64int32nag_int array
npts, the dimension of the array, must satisfy the constraint nptsnx × ny${\mathbf{npts}}\le {\mathbf{nx}}×{\mathbf{ny}}$.
icol(i)${\mathbf{icol}}\left(\mathit{i}\right)$, for i = 1,2,,npts$\mathit{i}=1,2,\dots ,{\mathbf{npts}}$, contains the virtual grid column number that contains base grid point i$\mathit{i}$.
Constraint: 0icol(i)nx$0\le {\mathbf{icol}}\left(\mathit{i}\right)\le {\mathbf{nx}}$, for i = 1,2,,npts$\mathit{i}=1,2,\dots ,{\mathbf{npts}}$.
6:     llbnd(nbnds) – int64int32nag_int array
nbnds, the dimension of the array, must satisfy the constraint nbnds8${\mathbf{nbnds}}\ge 8$.
llbnd(i)${\mathbf{llbnd}}\left(\mathit{i}\right)$, for i = 1,2,,nbnds$\mathit{i}=1,2,\dots ,{\mathbf{nbnds}}$, contains the element of lbnd corresponding to the start of the i$\mathit{i}$th boundary (or corner).
Constraints:
• 1llbnd(i)nbpts$1\le {\mathbf{llbnd}}\left(\mathit{i}\right)\le {\mathbf{nbpts}}$, for i = 1,2,,nbnds$\mathit{i}=1,2,\dots ,{\mathbf{nbnds}}$;
• llbnd(i1) < llbnd(i)${\mathbf{llbnd}}\left(\mathit{i}-1\right)<{\mathbf{llbnd}}\left(\mathit{i}\right)$, for i = 2,3,,nbnds$\mathit{i}=2,3,\dots ,{\mathbf{nbnds}}$.
7:     ilbnd(nbnds) – int64int32nag_int array
nbnds, the dimension of the array, must satisfy the constraint nbnds8${\mathbf{nbnds}}\ge 8$.
ilbnd(i)${\mathbf{ilbnd}}\left(\mathit{i}\right)$, for i = 1,2,,nbnds$\mathit{i}=1,2,\dots ,{\mathbf{nbnds}}$, contains the type of the i$\mathit{i}$th boundary (or corner), as defined in nag_pde_2d_gen_order2_rectilinear (d03rb).
Constraint: ilbnd(i)${\mathbf{ilbnd}}\left(\mathit{i}\right)$ must be equal to one of the following: 1$1$, 2$2$, 3$3$, 4$4$, 12$12$, 23$23$, 34$34$, 41$41$, 21$21$, 32$32$, 43$43$ or 14$14$, for i = 1,2,,nbnds$\mathit{i}=1,2,\dots ,{\mathbf{nbnds}}$.
8:     lbnd(nbpts) – int64int32nag_int array
nbpts, the dimension of the array, must satisfy the constraint 12nbpts < npts$12\le {\mathbf{nbpts}}<{\mathbf{npts}}$.
lbnd(i)${\mathbf{lbnd}}\left(\mathit{i}\right)$, for i = 1,2,,nbpts$\mathit{i}=1,2,\dots ,{\mathbf{nbpts}}$, contains the grid index of the i$\mathit{i}$th boundary point.
Constraint: 1lbnd(i)npts$1\le {\mathbf{lbnd}}\left(\mathit{i}\right)\le {\mathbf{npts}}$, for i = 1,2,,nbpts$\mathit{i}=1,2,\dots ,{\mathbf{nbpts}}$.

### Optional Input Parameters

1:     npts – int64int32nag_int scalar
Default: The dimension of the array icol.
The total number of points in the base grid.
Constraint: nptsnx × ny${\mathbf{npts}}\le {\mathbf{nx}}×{\mathbf{ny}}$.
2:     nrows – int64int32nag_int scalar
Default: The dimension of the arrays lrow, irow. (An error is raised if these dimensions are not equal.)
The total number of rows of the virtual grid that contain base grid points.
Constraint: 4nrowsny$4\le {\mathbf{nrows}}\le {\mathbf{ny}}$.
3:     nbnds – int64int32nag_int scalar
Default: The dimension of the arrays llbnd, ilbnd. (An error is raised if these dimensions are not equal.)
The total number of physical boundaries and corners in the base grid.
Constraint: nbnds8${\mathbf{nbnds}}\ge 8$.
4:     nbpts – int64int32nag_int scalar
Default: The dimension of the array lbnd.
The total number of boundary points in the base grid.
Constraint: 12nbpts < npts$12\le {\mathbf{nbpts}}<{\mathbf{npts}}$.

iwk leniwk

### Output Parameters

1:     pgrid(ny) – cell array of strings
pgrid(i)${\mathbf{pgrid}}\left(\mathit{i}\right)$, for i = 1,2,,ny$\mathit{i}=1,2,\dots ,{\mathbf{ny}}$, contains a graphical representation of row nyi + 1${\mathbf{ny}}-\mathit{i}+1$ of the virtual grid (see Section [Description]).
2:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

## Error Indicators and Warnings

Errors or warnings detected by the function:
ifail = 1${\mathbf{ifail}}=1$
 On entry, nx or ny < 4${\mathbf{ny}}<4$, or npts > nx × ny${\mathbf{npts}}>{\mathbf{nx}}×{\mathbf{ny}}$, or nrows < 4${\mathbf{nrows}}<4$, or ${\mathbf{nrows}}>{\mathbf{ny}}$, or nbnds < 8${\mathbf{nbnds}}<8$, or nbpts < 12${\mathbf{nbpts}}<12$, or ${\mathbf{nbpts}}\ge {\mathbf{npts}}$, or lrow(i) < 1${\mathbf{lrow}}\left(i\right)<1$, for some i = 1,2, … ,nrows$i=1,2,\dots ,{\mathbf{nrows}}$, or lrow(i) > npts${\mathbf{lrow}}\left(i\right)>{\mathbf{npts}}$, for some i = 1,2, … ,nrows$i=1,2,\dots ,{\mathbf{nrows}}$, or lrow(i) ≤ lrow(i − 1)${\mathbf{lrow}}\left(i\right)\le {\mathbf{lrow}}\left(i-1\right)$, for some i = 2,3, … ,nrows$i=2,3,\dots ,{\mathbf{nrows}}$, or irow(i) < 0${\mathbf{irow}}\left(i\right)<0$, for some i = 1,2, … ,nrows$i=1,2,\dots ,{\mathbf{nrows}}$, or irow(i) > ny${\mathbf{irow}}\left(i\right)>{\mathbf{ny}}$, for some i = 1,2, … ,nrows$i=1,2,\dots ,{\mathbf{nrows}}$, or irow(i) ≤ irow(i − 1)${\mathbf{irow}}\left(i\right)\le {\mathbf{irow}}\left(i-1\right)$, for some i = 2,3, … ,nrows$i=2,3,\dots ,{\mathbf{nrows}}$, or icol(i) < 0${\mathbf{icol}}\left(i\right)<0$, for some i = 1,2, … ,npts$i=1,2,\dots ,{\mathbf{npts}}$, or icol(i) > nx${\mathbf{icol}}\left(i\right)>{\mathbf{nx}}$, for some i = 1,2, … ,npts$i=1,2,\dots ,{\mathbf{npts}}$, or llbnd(i) < 1${\mathbf{llbnd}}\left(i\right)<1$, for some i = 1,2, … ,nbnds$i=1,2,\dots ,{\mathbf{nbnds}}$, or llbnd(i) > nbpts${\mathbf{llbnd}}\left(i\right)>{\mathbf{nbpts}}$, for some i = 1,2, … ,nbnds$i=1,2,\dots ,{\mathbf{nbnds}}$, or llbnd(i) ≤ llbnd(i − 1)${\mathbf{llbnd}}\left(i\right)\le {\mathbf{llbnd}}\left(i-1\right)$, for some i = 2,3, … ,nbpts$i=2,3,\dots ,{\mathbf{nbpts}}$, or ilbnd(i) ≠ 1${\mathbf{ilbnd}}\left(i\right)\ne 1$, 2$2$, 3$3$, 4$4$, 12$12$, 23$23$, 34$34$, 41$41$, 21$21$, 32$32$, 43$43$ or 14$14$, for some i = 1,2, … ,nbnds$i=1,2,\dots ,{\mathbf{nbnds}}$, or lbnd(i) < 1${\mathbf{lbnd}}\left(i\right)<1$, for some i = 1,2, … ,nbpts$i=1,2,\dots ,{\mathbf{nbpts}}$, or lbnd(i) > npts${\mathbf{lbnd}}\left(i\right)>{\mathbf{npts}}$, for some i = 1,2, … ,nbpts$i=1,2,\dots ,{\mathbf{nbpts}}$, or leniwk < nx × ny + 1$\mathit{leniwk}<{\mathbf{nx}}×{\mathbf{ny}}+1$, or LEN(pgrid(1)) < 3 × nx$\mathrm{LEN}\left({\mathbf{pgrid}}\left(1\right)\right)<3×{\mathbf{nx}}$.

Not applicable.

None.

## Example

```function nag_pde_2d_gen_order2_checkgrid_example
nx = int64(11);
ny = int64(11);
lrow = [int64(1);4;15;26;37;46;57;68;79;88;97];
irow = [int64(0);1;2;3;4;5;6;7;8;9;10];
icol = [int64(0);1;2;0;1;2;3;4;5;6;7;8;9;10;0;1;2;3;4;5;6;7;8;9;10; ...
0;1;2;3;4;5;6;7;8;9;10;0;1;2;3;4;5;8;9;10;0;1;2;3;4;5;6;7;8;9; ...
10;0;1;2;3;4;5;6;7;8;9;10;0;1;2;3;4;5;6;7;8;9;10;0;1;2;3;4;5;6; ...
7;8;0;1;2;3;4;5;6;7;8;0;1;2;3;4;5;6;7;8];
llbnd = [int64(1);2;11;18;19;24;31;37;42;48;53;55;56;58;59;60;61;62; ...
63;64;65;66;67;68;69;70;71;72];
ilbnd = [int64(1);2;3;4;1;4;1;2;3;4;3;4;1;2;12;23;34;41;14;41;12;23; ...
34;41;43;14;21;32];
lbnd = [int64(2);4;15;26;37;46;57;68;79;88;98;99;100;101;102;103;104; ...
96;86;85;84;83;82;70;59;48;39;28;17;6;8;9;10;11;12;13;18;29;40; ...
49;60;72;73;74;75;76;77;67;56;45;36;25;33;32;42;52;53;43;1;97; ...
105;87;81;3;7;71;78;14;31;51;54;34];
[pgrid, ifail] = nag_pde_2d_gen_order2_checkgrid(nx, ny, lrow, irow, icol, llbnd, ilbnd, lbnd)
```
```

pgrid =

' 23  3  3  3  3  3  3  3 34 XX XX'
'  2 .. .. .. .. .. .. ..  4 XX XX'
'  2 .. 14  1  1  1  1  1 41 XX XX'
'  2 ..  4 23  3  3  3  3  3  3 34'
'  2 ..  4  2 .. .. .. .. .. ..  4'
'  2 ..  4  2 .. 14  1  1 21 ..  4'
'  2 ..  4  2 ..  4 XX XX  2 ..  4'
'  2 ..  4  2 .. 43  3  3 32 ..  4'
'  2 ..  4  2 .. .. .. .. .. ..  4'
'  2 ..  4 12  1  1  1  1  1  1 41'
' 12  1 41 XX XX XX XX XX XX XX XX'

ifail =

0

```
```function d03ry_example
nx = int64(11);
ny = int64(11);
lrow = [int64(1);4;15;26;37;46;57;68;79;88;97];
irow = [int64(0);1;2;3;4;5;6;7;8;9;10];
icol = [int64(0);1;2;0;1;2;3;4;5;6;7;8;9;10;0;1;2;3;4;5;6;7;8;9;10; ...
0;1;2;3;4;5;6;7;8;9;10;0;1;2;3;4;5;8;9;10;0;1;2;3;4;5;6;7;8;9; ...
10;0;1;2;3;4;5;6;7;8;9;10;0;1;2;3;4;5;6;7;8;9;10;0;1;2;3;4;5;6; ...
7;8;0;1;2;3;4;5;6;7;8;0;1;2;3;4;5;6;7;8];
llbnd = [int64(1);2;11;18;19;24;31;37;42;48;53;55;56;58;59;60;61;62; ...
63;64;65;66;67;68;69;70;71;72];
ilbnd = [int64(1);2;3;4;1;4;1;2;3;4;3;4;1;2;12;23;34;41;14;41;12;23; ...
34;41;43;14;21;32];
lbnd = [int64(2);4;15;26;37;46;57;68;79;88;98;99;100;101;102;103;104; ...
96;86;85;84;83;82;70;59;48;39;28;17;6;8;9;10;11;12;13;18;29;40; ...
49;60;72;73;74;75;76;77;67;56;45;36;25;33;32;42;52;53;43;1;97; ...
105;87;81;3;7;71;78;14;31;51;54;34];
[pgrid, ifail] = d03ry(nx, ny, lrow, irow, icol, llbnd, ilbnd, lbnd)
```
```

pgrid =

' 23  3  3  3  3  3  3  3 34 XX XX'
'  2 .. .. .. .. .. .. ..  4 XX XX'
'  2 .. 14  1  1  1  1  1 41 XX XX'
'  2 ..  4 23  3  3  3  3  3  3 34'
'  2 ..  4  2 .. .. .. .. .. ..  4'
'  2 ..  4  2 .. 14  1  1 21 ..  4'
'  2 ..  4  2 ..  4 XX XX  2 ..  4'
'  2 ..  4  2 .. 43  3  3 32 ..  4'
'  2 ..  4  2 .. .. .. .. .. ..  4'
'  2 ..  4 12  1  1  1  1  1  1 41'
' 12  1 41 XX XX XX XX XX XX XX XX'

ifail =

0

```