FreeFEM Documentation on GitHub

stars - forks

Loops

See Loop example.

for

For loop.

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

if

If condition.

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

else

See if.

while

While loop.

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

continue

Continue a loop.

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

break

Break a loop.

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

try

Try a part of code.

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

See Basic error handling example and Error handling example.

catch

Catch an error, see try

Implicit loop

Array with one index:

1for [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:

1for [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