Language references
In essence FreeFEM is a compiler: its language is typed, polymorphic, with exception and reentrant.
Every variable must be declared of a certain type, in a declarative statement; each statement are separated from the next by a semicolon ;
.
The language allows the manipulation of basic types integers (int
), reals (real
), strings (string
), arrays (example: real[int]
), bi-dimensional (2D) finite element meshes (mesh
), 2D finite element spaces (fespace
), analytical functions (func
), arrays of finite element functions (func[basic_type]
), linear and bilinear operators, sparse matrices, vectors , etc.
For example:
1int i, n = 20; //i, n are integer
2real[int] xx(n), yy(n); //two array of size n
3for (i = 0; i < 20; i++){ //which can be used in statements such as
4 xx[i] = cos(i*pi/10);
5 yy[i] = sin(i*pi/10);
6}
The life of a variable is the current block {...}
, except the fespace
variable, and the variables local to a block are destroyed at the end of the block as follows.
Tip
Example
1real r = 0.01;
2mesh Th = square(10, 10); //unit square mesh
3fespace Vh(Th, P1); //P1 Lagrange finite element space
4Vh u = x + exp(y);
5func f = z*x + r*log(y);
6plot(u, wait=true);
7{ // new block
8 real r = 2; //not the same r
9 fespace Vh(Th, P1); //error because Vh is a global name
10}// end of block
11//here r back to 0.01
The type declarations are mandatory in FreeFEM; in the end this feature is an asset because it is easy to make bugs in a language with many implicit types.
The variable name is just an alphanumeric string, the underscore character _
is not allowed, because it will be used as an operator in the future.
- Types
- Global variables
- Quadrature formulae
- Operators
- Addition operator +
- Increment operator ++
- Substraction operator -
- Decrement operator –
- Multiplication operator *
- Equal operator =
- Comparison operator ==
- Comparison operator !=
- Comparison operator <, <=
- Comparison operator >, >=
- Compound operator +=, -=, *=, /=
- Term by term multiplication .*
- Division operator /
- Term by term division ./
- Remainder from the division %
- Power operator ^
- Inverse of a matrix ^-1
- Transpose operator ‘
- Tensor scalar product :
- C++ arithmetical if expression ? :
- Loops
- I/O
- Functions
- abs
- acos
- acosh
- adaptmesh
- adj
- AffineCG
- AffineGMRES
- arg
- asin
- asinh
- assert
- atan
- atan2
- atanh
- atoi
- atof
- BFGS
- buildmesh
- ceil
- change
- checkmovemesh
- chi
- clock
- complexEigenValue
- conj
- convect
- copysign
- cos
- cosh
- diffnp
- diffpos
- dist
- dumptable
- dx
- dxx
- dxy
- dxz
- dy
- dyx
- dyy
- dyz
- dz
- dzx
- dzy
- dzz
- EigenValue
- emptymesh
- erf
- erfc
- exec
- exit
- exp
- fdim
- floor
- fmax
- fmin
- fmod
- imag
- int1d
- int2d
- int3d
- intalledges
- intallfaces
- interpolate
- invdiff
- invdiffnp
- invdiffpos
- isInf
- isNaN
- isNormal
- j0
- j1
- jn
- jump
- LinearCG
- LinearGMRES
- lgamma
- log
- log10
- lrint
- lround
- ltime
- max
- min
- movemesh
- NaN
- NLCG
- on
- plot
- polar
- pow
- projection
- randinit
- randint31
- randint32
- randreal1
- randreal2
- randreal3
- randres53
- readmesh
- readmesh3
- real
- rint
- round
- savemesh
- set
- sign
- signbit
- sin
- sinh
- sort
- splitmesh
- sqrt
- square
- storagetotal
- storageused
- strtod
- strtol
- swap
- system
- tan
- tanh
- tgamma
- time
- trace
- trunc
- y0
- y1
- yn
- External libraries
- aniso
- BEC
- Binary I/O
- buildlayer
- ClosePoints
- Curvature
- dfft
- distance
- DxWriter
- Element_P1bl
- exactpartition
- ff-AiryBiry
- ff-cmaes
- ff_gsl_awk
- gslcdfugaussianP
- gslcdfugaussianQ
- gslcdfugaussianPinv
- gslcdfugaussianQinv
- gslcdfgaussianP
- gslcdfgaussianQ
- gslcdfgaussianPinv
- gslcdfgaussianQinv
- gslcdfgammaP
- gslcdfgammaQ
- gslcdfgammaPinv
- gslcdfgammaQinv
- gslcdfcauchyP
- gslcdfcauchyQ
- gslcdfcauchyPinv
- gslcdfcauchyQinv
- gslcdflaplaceP
- gslcdflaplaceQ
- gslcdflaplacePinv
- gslcdflaplaceQinv
- gslcdfrayleighP
- gslcdfrayleighQ
- gslcdfrayleighPinv
- gslcdfrayleighQinv
- gslcdfchisqP
- gslcdfchisqQ
- gslcdfchisqPinv
- gslcdfchisqQinv
- gslcdfexponentialP
- gslcdfexponentialQ
- gslcdfexponentialPinv
- gslcdfexponentialQinv
- gslcdfexppowP
- gslcdfexppowQ
- gslcdftdistP
- gslcdftdistQ
- gslcdftdistPinv
- gslcdftdistQinv
- gslcdffdistP
- gslcdffdistQ
- gslcdffdistPinv
- gslcdffdistQinv
- gslcdfbetaP
- gslcdfbetaQ
- gslcdfbetaPinv
- gslcdfbetaQinv
- gslcdfflatP
- gslcdfflatQ
- gslcdfflatPinv
- gslcdfflatQinv
- gslcdflognormalP
- gslcdflognormalQ
- gslcdflognormalPinv
- gslcdflognormalQinv
- gslcdfgumbel1P
- gslcdfgumbel1Q
- gslcdfgumbel1Pinv
- gslcdfgumbel1Qinv
- gslcdfgumbel2P
- gslcdfgumbel2Q
- gslcdfgumbel2Pinv
- gslcdfgumbel2Qinv
- gslcdfweibullP
- gslcdfweibullQ
- gslcdfweibullPinv
- gslcdfweibullQinv
- gslcdfparetoP
- gslcdfparetoQ
- gslcdfparetoPinv
- gslcdfparetoQinv
- gslcdflogisticP
- gslcdflogisticQ
- gslcdflogisticPinv
- gslcdflogisticQinv
- gslcdfbinomialP
- gslcdfbinomialQ
- gslcdfpoissonP
- gslcdfpoissonQ
- gslcdfgeometricP
- gslcdfgeometricQ
- gslcdfnegativebinomialP
- gslcdfnegativebinomialQ
- gslcdfpascalP
- gslcdfpascalQ
- gslranbernoullipdf
- gslranbeta
- gslranbetapdf
- gslranbinomialpdf
- gslranexponential
- gslranexponentialpdf
- gslranexppow
- gslranexppowpdf
- gslrancauchy
- gslrancauchypdf
- gslranchisq
- gslranchisqpdf
- gslranerlang
- gslranerlangpdf
- gslranfdist
- gslranfdistpdf
- gslranflat
- gslranflatpdf
- gslrangamma
- gslrangammaint
- gslrangammapdf
- gslrangammamt
- gslrangammaknuth
- gslrangaussian
- gslrangaussianratiomethod
- gslrangaussianziggurat
- gslrangaussianpdf
- gslranugaussian
- gslranugaussianratiomethod
- gslranugaussianpdf
- gslrangaussiantail
- gslrangaussiantailpdf
- gslranugaussiantail
- gslranugaussiantailpdf
- gslranlandau
- gslranlandaupdf
- gslrangeometricpdf
- gslrangumbel1
- gslrangumbel1pdf
- gslrangumbel2
- gslrangumbel2pdf
- gslranlogistic
- gslranlogisticpdf
- gslranlognormal
- gslranlognormalpdf
- gslranlogarithmicpdf
- gslrannegativebinomialpdf
- gslranpascalpdf
- gslranpareto
- gslranparetopdf
- gslranpoissonpdf
- gslranrayleigh
- gslranrayleighpdf
- gslranrayleightail
- gslranrayleightailpdf
- gslrantdist
- gslrantdistpdf
- gslranlaplace
- gslranlaplacepdf
- gslranlevy
- gslranweibull
- gslranweibullpdf
- gslsfairyAi
- gslsfairyBi
- gslsfairyAiscaled
- gslsfairyBiscaled
- gslsfairyAideriv
- gslsfairyBideriv
- gslsfairyAiderivscaled
- gslsfairyBiderivscaled
- gslsfairyzeroAi
- gslsfairyzeroBi
- gslsfairyzeroAideriv
- gslsfairyzeroBideriv
- gslsfbesselJ0
- gslsfbesselJ1
- gslsfbesselJn
- gslsfbesselY0
- gslsfbesselY1
- gslsfbesselYn
- gslsfbesselI0
- gslsfbesselI1
- gslsfbesselIn
- gslsfbesselI0scaled
- gslsfbesselI1scaled
- gslsfbesselInscaled
- gslsfbesselK0
- gslsfbesselK1
- gslsfbesselKn
- gslsfbesselK0scaled
- gslsfbesselK1scaled
- gslsfbesselKnscaled
- gslsfbesselj0
- gslsfbesselj1
- gslsfbesselj2
- gslsfbesseljl
- gslsfbessely0
- gslsfbessely1
- gslsfbessely2
- gslsfbesselyl
- gslsfbesseli0scaled
- gslsfbesseli1scaled
- gslsfbesseli2scaled
- gslsfbesselilscaled
- gslsfbesselk0scaled
- gslsfbesselk1scaled
- gslsfbesselk2scaled
- gslsfbesselklscaled
- gslsfbesselJnu
- gslsfbesselYnu
- gslsfbesselInuscaled
- gslsfbesselInu
- gslsfbesselKnuscaled
- gslsfbesselKnu
- gslsfbessellnKnu
- gslsfbesselzeroJ0
- gslsfbesselzeroJ1
- gslsfbesselzeroJnu
- gslsfclausen
- gslsfhydrogenicR1
- gslsfdawson
- gslsfdebye1
- gslsfdebye2
- gslsfdebye3
- gslsfdebye4
- gslsfdebye5
- gslsfdebye6
- gslsfdilog
- gslsfmultiply
- gslsfellintKcomp
- gslsfellintEcomp
- gslsfellintPcomp
- gslsfellintDcomp
- gslsfellintF
- gslsfellintE
- gslsfellintRC
- gslsferfc
- gslsflogerfc
- gslsferf
- gslsferfZ
- gslsferfQ
- gslsfhazard
- gslsfexp
- gslsfexpmult
- gslsfexpm1
- gslsfexprel
- gslsfexprel2
- gslsfexpreln
- gslsfexpintE1
- gslsfexpintE2
- gslsfexpintEn
- gslsfexpintE1scaled
- gslsfexpintE2scaled
- gslsfexpintEnscaled
- gslsfexpintEi
- gslsfexpintEiscaled
- gslsfShi
- gslsfChi
- gslsfexpint3
- gslsfSi
- gslsfCi
- gslsfatanint
- gslsffermidiracm1
- gslsffermidirac0
- gslsffermidirac1
- gslsffermidirac2
- gslsffermidiracint
- gslsffermidiracmhalf
- gslsffermidirachalf
- gslsffermidirac3half
- gslsffermidiracinc0
- gslsflngamma
- gslsfgamma
- gslsfgammastar
- gslsfgammainv
- gslsftaylorcoeff
- gslsffact
- gslsfdoublefact
- gslsflnfact
- gslsflndoublefact
- gslsflnchoose
- gslsfchoose
- gslsflnpoch
- gslsfpoch
- gslsfpochrel
- gslsfgammaincQ
- gslsfgammaincP
- gslsfgammainc
- gslsflnbeta
- gslsfbeta
- gslsfbetainc
- gslsfgegenpoly1
- gslsfgegenpoly2
- gslsfgegenpoly3
- gslsfgegenpolyn
- gslsfhyperg0F1
- gslsfhyperg1F1int
- gslsfhyperg1F1
- gslsfhypergUint
- gslsfhypergU
- gslsfhyperg2F0
- gslsflaguerre1
- gslsflaguerre2
- gslsflaguerre3
- gslsflaguerren
- gslsflambertW0
- gslsflambertWm1
- gslsflegendrePl
- gslsflegendreP1
- gslsflegendreP2
- gslsflegendreP3
- gslsflegendreQ0
- gslsflegendreQ1
- gslsflegendreQl
- gslsflegendrePlm
- gslsflegendresphPlm
- gslsflegendrearraysize
- gslsfconicalPhalf
- gslsfconicalPmhalf
- gslsfconicalP0
- gslsfconicalP1
- gslsfconicalPsphreg
- gslsfconicalPcylreg
- gslsflegendreH3d0
- gslsflegendreH3d1
- gslsflegendreH3d
- gslsflog
- gslsflogabs
- gslsflog1plusx
- gslsflog1plusxmx
- gslsfpowint
- gslsfpsiint
- gslsfpsi
- gslsfpsi1piy
- gslsfpsi1int
- gslsfpsi1
- gslsfpsin
- gslsfsynchrotron1
- gslsfsynchrotron2
- gslsftransport2
- gslsftransport3
- gslsftransport4
- gslsftransport5
- gslsfsin
- gslsfcos
- gslsfhypot
- gslsfsinc
- gslsflnsinh
- gslsflncosh
- gslsfanglerestrictsymm
- gslsfanglerestrictpos
- gslsfzetaint
- gslsfzeta
- gslsfzetam1
- gslsfzetam1int
- gslsfhzeta
- gslsfetaint
- gslsfeta
- ff-Ipopt
- fflapack
- ff-mmap-semaphore
- ffnewuoa
- ff-NLopt
- nloptDIRECT
- nloptDIRECTL
- nloptDIRECTLRand
- nloptDIRECTScal
- nloptDIRECTNoScal
- nloptDIRECTLNoScal
- nloptDIRECTLRandNoScal
- nloptOrigDIRECT
- nloptOrigDIRECTL
- nloptStoGO
- nloptStoGORand
- nloptLBFGS
- nloptPRAXIS
- nloptVar1
- nloptVar2
- nloptTNewton
- nloptTNewtonRestart
- nloptTNewtonPrecond
- nloptTNewtonPrecondRestart
- nloptCRS2
- nloptMMA
- nloptCOBYLA
- nloptNEWUOA
- nloptNEWUOABound
- nloptNelderMead
- nloptSbplx
- nloptBOBYQA
- nloptISRES
- nloptSLSQP
- nloptMLSL
- nloptMLSLLDS
- nloptAUGLAG
- nloptAUGLAGEQ
- ffrandom
- FreeFemQA
- freeyams
- gmsh
- gsl
- ilut
- iohdf5
- iovtk
- isoline
- lapack
- lgbmo
- mat_dervieux
- mat_psi
- medit
- metis
- MetricKuate
- MetricPk
- mmg3d
- mmg3d-v4.0
- msh3
- mshmet
- MUMPS
- MUMPS_seq
- netgen
- NewSolver
- PARDISO
- pcm2rnm
- pipe
- qf11to25
- scotch
- shell
- splitedges
- splitmesh12
- splitmesh3
- splitmesh4
- splitmesh6
- SuperLu
- symmetrizeCSR
- tetgen
- UMFPACK64
- VTK_writer_3d
- VTK_writer