FreeFEM Documentation on GitHub

stars - forks

Loops

See Loop example.

for

For loop.

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

if

If condition.

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

else

See if.

while

While loop.

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

continue

Continue a loop.

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

break

Break a loop.

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

try

Try a part of code.

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

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