GFem language documentation -- 3.4.2 Building functions

Previous: 3.4.1 Functions and scalars
Up: 3.4 Functions
Next: 3.4.3 Value of a function at one point

### 3.4.2 Building functions

There are 6 predefined functions: `x,y,ib,region, nx, ny` .

- The coordinate `x` is horizontal and `y` is vertical.

- On pdOmega it is equal to the boundary identification number.

The usual `if... then ... else` statement can be used with an important restriction on the logical expression which must return a scalar value:

    if( logical  expression) then
     {
       statement;
       ....;
       statement;
     }
    else
     {
       .....
     };

The `logical expression` controls the `if` by its return being 0 or >0, it is evaluated only once (i.e. with `x`, `y` being the coordinates of the first vertex, if there are functions inside the logical expression). Auxiliary variables can be used.

In order to minimize the memory the symbol `:=` tells the compiler not to allocate a data array to this variable. Thus `v=sin(a*pi*x);` generates an array for `v` but no array is assigned to `a` in the statement `a:=2` .