next up previous
Next: Initializations Up: Program Structure Previous: Derivative Operators



Residuals define the system of equations, typically by using derivative operators. Consider the following residual definition:

residual phi { [0:0]       := D_LF(phi,t) ;
               [1:Nx-2]    := D_LF(phi,t,t) - D_LF(phi,x,x) ;
               [Nx-1:Nx-1] := D_LF(phi,t) }

Assuming the proper definitions of the derivative operators, this residual will encodes the linear wave equation on a string with the end points fixed. An equivalent declaration would be:

residual phi { [0:0]       := D_LF(phi,t) = 0 ;
               [1:Nx-2]    := D_LF(phi,t,t) = D_LF(phi,x,x) ;
               [Nx-1:Nx-1] := D_LF(phi,t) = 0 }

First comes the reserved word residual followed by the name of the grid function whose residual is being defined. Next comes a bracket-enclosed set of index regions and expressions. The index region shows over what range the expression is a valid description of the behavior of the system. The union of the index regions should equal the index region of the grid on which the function is defined, but this is not required. Note that each region-expression pair is separated by a semi-colon.

The residual tells how to determine the advanced value of a grid function. Thus, the residual must contain <a>f... where a is the offset to the most advanced time level defined for grid function f.

Part of a residual for a three dimensional grid function would look like:

residual A { [1:Nx][1:1][1:1] := D_LF(A,x) + D_FW(B,y) ;
          [Nx:Nx][1:Ny][1:Nz] := <1>A[0][0][0] = 5.0*C }

The reserved word residual can be preceded by the reserved word evaluate which tells the compiler to produce code which will evaluate the residual.

In addition, the word residual can be followed by a global offset for example:

residual <1>[0] A { [1:Nx] := ... }

This offset is applied globally to each expression appearing in the residual.

See section 1.12 for more information on expressions.

Robert Marsa
Thu Jun 1 09:34:30 CDT 1995