FreeFEM Documentation on GitHub

stars - forks

Loops

See Loop example.

for

For loop.

1 for (int i = 0; i < N; ++i){
2     ...
3 }

if

If condition.

1 if (condition){
2     ...
3 }
4 else{
5     ...
6 }

else

See if.

while

While loop.

1 while (condition){
2     ...
3 }

continue

Continue a loop.

1 for (int i = 0; i < N; ++i){
2     ...
3     if (condition) continue;
4     ...
5 }

break

Break a loop.

1 while (condition1){
2     ...
3     if (condition) break;
4     ...
5 }

try

Try a part of code.

1 try{
2     ...
3 }
4 catch(...){
5     ...
6 }

See Basic error handling example and Error handling example.

catch

Catch an error, see try

Implicit loop

Array with one index:

1 for [i, ai : a]

If real[int] a(10), then i=0:9 and ai is a reference to a[i].

Array with two indices or matrix:

1 for [i, j, aij : a]

If real[int] a(10, 11), then i=0:9, j=1:10 and aij is a reference to a(i, j).

See Implicit loop example.

Table of content