Introduction a` FreeFem++J.MoriceLaboratoire Jacques-Louis LionsUniversite Pierre et Marie CurieParis, Franceavec O. Pironneau, F. Hechthttp://www.freefem.org mailto:hecht@ann.jussieu.frFinance par l’Agence National de La Recherche(ANR) ANR-07-CIS7-002-01http://www.freefem.org/ff2a3/ http://www-anr-ci.cea.fr/FreeFem++ Cours M2, dec. 2009 1PLAN{ Introduction Freefem++{ Element Syntaxe{ Formulation Variationnelle et EF{ Generation de maillage 2D{ Examples :{ Equation de Poisson avec condition de Neumann et condition de Dirichlet{ de P avec systeme matricielle{ Adaptation de Maillage avec indication d’erreur{ Probleme de Stokes 3D{ Generation de maillage 3DFreeFem++ Cours M2, dec. 2009 2IntroductionFreeFem++ est un solveur permettant de resoudre les equations aux deriveespartielles (PDE) en 2d et 3d.Methode employe : Methode d’elements nis. EF : P0, P1, P2,Raviart-Thomas, P1 diconstinue,FreeFem++ est un logiciel sous licence LGPL. Il fonctionne sous Mac, Unixet Window. Algorithme // avec MPI.FreeFem++ Cours M2, dec. 2009 3The main characteristics of FreeFem++ I/II (2D){ Wide range of nite elements : linear (2d,3d) (P1) and quadratic Lagran-gian (2d,3d) elements (P2), discontinuous P1 and Raviart-Thomas elements(2d,3d), 3d Edge element , vectorial element, mini-element( 2d, 3d), ...{ Automatic interpolation of data from a mesh to an other one, so a niteelement function is view as a function of (x;y;z) or as an array.{ De ...
J.Morice Laboratoire Jacques-Louis Lions Universit´ePierreetMarieCurie Paris, France
http://www.freefem.org
O. Pironneau, F. Hecht
FreeFem++ Cours M2, dec. 2009
Introduction`aFreeFem++
PLAN
– IntroductionFreefem++ – Element Syntaxe – Formulation Variationnelle et EF –G´en´erationdemaillage2D – Examples : – Equation de Poisson avec condition de Neumann et condition de Dirichlet – Equation de Poisson avec systeme matricielle ` – Adaptation de Maillage avec indication d’erreur –Probl`emedeStokes3D –Ge´n´erationdemaillage3D
FreeFem++ Cours M2, dec. 2009
2
Introduction
FreeFem++auit´sqexu´dnoaser´eantdrelesouduevlosnuttemreprsteiveres´e partielles (PDE) en 2d et 3d.
The main characteristics ofFreeFem++ II/II(2D) – Analyticdescription of boundaries, with specification by the user of the intersection of boundaries in 2d. –Automatic mesh generator, based on the Delaunay-Voronoi algorithm. (2d,3d) – load and save Mesh, solution –Mesh adaptation based on metric, possibly anisotropic, with optional auto-matic computation of the metric from the Hessian of a solution. –LU, Cholesky, Crout, CG, GMRES, UMFPack,SuperLU, MUMPS,...sparse linear solver ;eigenvalueand eigenvector computation with ARPACK. – Online graphics, C++ like syntax. – Link with other soft : modulef, emc2, medit, gnuplot, tetgen, superlu, mumps ... – Dynamic linking to add functonality. – Wide range of of examples : Navier-Stokes3d, elasticity3d, fluid structure, eigenvalue problem, Schwarz’ domain decomposition algorithm, residual er-ror indicator, ... FreeFem++ Cours M2, dec. 2009 5
Element of syntax : Like in C++ 1/ The basic numerical type are :int,real,complex,bool, string inti = 0 ; integer// an reala=2.5 ; reel// a complexcc=2.5+1.i*2 ;// a complex boolb=(a<3.) ; boolean// a BOOLEAN Initialisation: 0 <=>false,6= 0<=>true The operator like in C : Arithmetic :: + - * / = Arithmetic in C:: += -= /= *= ++ --Comparison :: == != < > <= >= && || redefintion : ^// (power) :: a^b=ab |// a|b=aorb &// a&b=aandb FreeFem++ Cours M2, dec. 2009 6
Element of syntax : Like in C++ 2 // Automatic cast for numerical value : bool, int, reel, complex funcf=x+y ; formal line function// a func ;}real g(int i, real a) { ..... return i+a ; // Loops for(int i=0 ;i<n ;i++) { ... ;} if( <bool exp> ) { ... ;}else ;} ;{ ... while( <bool exp> ) { ... ;} break continuekey words // Thescoop of a variable the current block : { inta=1 ; } block// a cout << a << endl ; the variable a not existe here.// error lots of math function :exp, log, tan, ... FreeFem++ Cours M2, dec. 2009 7
Element of syntax : 4/4
LesEntre´es/sortiescommeenc++
Ecran : : cout, cin, ...
Pour ouvrir un fichier en lecture : ifstreamname(nom_fichier) ;