Function Definitions

<< Click to Display Table of Contents >>

Navigation:  Problem Descriptor Reference > The Sections of a Descriptor > Definitions >

Function Definitions

Previous pageReturn to chapter overviewNext page

Definitions can be made to depend on one to three explicit arguments, much as with a Function definition in a procedural language.  The syntax of the parameterized definition is

name ( argname )  =  expression

name ( argname1 , argname2 )  =  expression

name ( argname1 , argname2 , argname3 , ...)  =  expression
 

The maximum number of arguments is 10, and the construct is only meaningful if expression contains references to the argnames.  Names defined in this way can later be used by supplying actual values for the arguments.  As with other definitions in FlexPDE, these actual parameters may be any valid expression with coordinate or variable dependences.  The argnames used in the definition are local to the definition and are undefined outside the scope of the defining expression.

Note that it is never necessary to pass known definitions, such as coordinate names, variable names, or other parameters as arguments to a parameterized definition, because they are always globally known and are evaluated in the proper context.  Use the parameterized definition facility when you want to pass values that are not globally known.

Note: This construct is implemented by textual expansion of the definitions in place of the function reference.  It is not a run-time call, as in a procedural language.

 

Example:  

DEFINITIONS

sq(arg) = arg*arg

...

EQUATIONS

div(a*grad(u)) + sq(u+1)*dx(u) +4 = 0;

   

In this case, the equation will expand to

div(a*grad(u)) + (u+1)*(u+1)*dx(u) + 4 = 0.

 

See also "Samples | Usage | Function_Definition.pde"