FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire...

43
FreeFem++ News F. Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile Dobrzynski, P. Ventura, F. Nataf ... http://www.freefem.org mailto:[email protected] With the support of ANR (French gov.) ANR-07-CIS7-002-01 http://www.freefem.org/ff2a3/ http://www-anr-ci.cea.fr/

Transcript of FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire...

Page 1: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

FreeFem++ NewsF. Hecht

Laboratoire Jacques-Louis LionsUniversité Pierre et Marie Curie

Paris, France

withJ. Morice, Cécile Dobrzynski,

P. Ventura, F. Nataf ...

http://www.freefem.org mailto:[email protected] the support of ANR (French gov.) ANR-07-CIS7-002-01http://www.freefem.org/ff2a3/ http://www-anr-ci.cea.fr/

Page 2: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

Outline

IntroductionHistoryThe main characteristicsThe Changes form 12/09 to 06/11

Academic Examples3d Poisson equation with mesh adaptationMove objet in meshesPrimitive equationPrimitive equation, variational formLinear elasticty equation

A industrial examplePeriodic Surface Acoustic Waves Transducer AnalysisThe γ-harmonic periodic boundary conditionsthe Element boundary formulation for semi infinite domainA trick of build the coupling of a 3 equationsa numerical case

Seminar, Seville , July 2011, Spain 2

Page 3: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

Introduction FreeFem++ is a software to solve numerically

partial differential equations (PDE) in IR2) and in IR3) with finiteelements methods. We used a user language to set and control theproblem. The FreeFem++ language allows for a quick specificationof linear PDE’s, with the variational formulation of a linear steadystate problem and the user can write they own script to solve nolinear problem and time depend problem. You can solve coupledproblem or problem with moving domain or eigenvalue problem, domesh adaptation , compute error indicator, etc ...FreeFem++ is a freeware and this run on Mac, Unix and Windowarchitecture, in parallel with MPI.

The next FreeFem workshop : Jussieu, Paris 5,6,7 December.

Seminar, Seville , July 2011, Spain 3

Page 4: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

History

1987 MacFem/PCFem les ancêtres (O. Pironneau en Pascal)payant.

1992 FreeFem réécriture de C++ (P1,P0 un maillage) O.Pironneau, D. Bernardi, F. Hecht , C. Prudhomme(adaptation Maillage, bamg).

1996 FreeFem+ réécriture de C++ (P1,P0 plusieurs maillages)O. Pironneau, D. Bernardi, F. Hecht (algèbre de fonction).

1998 FreeFem++ réécriture avec autre noyau élément fini, etun autre langage utilisateur ; F. Hecht, O. Pironneau,K.Ohtsuka.

1999 FreeFem 3d (S. Del Pino) , Une première version defreefem en 3d avec des méthodes de domaine fictif.

2008 FreeFem++ v3 réécriture du noyau élément fini pourprendre en compte les cas multidimensionnels : 1d,2d,3d...

Seminar, Seville , July 2011, Spain 4

Page 5: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

For who, for what !

For what1. R&D2. Academic Research ,3. Teaching of FEM, PDE, Weak form and variational form4. Algorithmes prototyping5. Numerical experimentation6. Scientific computing and Parallel computing

For who : the researcher, engineer, professor, student...

The mailling list mailto:[email protected] with308 members with a flux of 5-20 messages per day.

Seminar, Seville , July 2011, Spain 5

Page 6: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

The main characteristics I/II (2D)(3D)

I Wide range of finite elements : linear (2d,3d) and quadraticLagrangian (2d,3d) elements, discontinuous P1 andRaviart-Thomas elements (2d,3d), 3d Edge element , vectorialelement , mini-element( 2d, 3d), ...

I Automatic interpolation of data from a mesh to an other one (with matrix construction if need), so a finite element functionis view as a function of (x, y, z) or as an array.

I Definition of the problem (complex or real value) with thevariational form with access to the vectors and the matrix.

I Discontinuous Galerkin formulation (only in 2d to day).I LU, Cholesky, Crout, CG, GMRES, UMFPack, SuperLU,

MUMPS, HIPS, HYPRE, SUPERLU_DIST, PASTIX. ...sparse linear solver ; eigenvalue and eigenvector computationwith ARPACK.

I Online graphics with OpenGL/GLUT, C++ like syntax.Seminar, Seville , July 2011, Spain 6

Page 7: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

The main characteristics II/II (2D)(3D)

I Analytic description of boundaries, with specification by theuser of the intersection of boundaries in 2d.

I Automatic mesh generator, based on the Delaunay-Voronoïalgorithm. (2d,3d)

I load and save Mesh, solutionI Mesh adaptation based on metric, possibly anisotropic (only in

2d), with optional automatic computation of the metric fromthe Hessian of a solution. (2d,3d).

I Link with other soft : parview, gmsh , vtk, medit, gnuplotI Dynamic linking to add plugin.I Full MPI interfaceI Wide range of of examples : Navier-Stokes 3d, elasticity 3d,

fluid structure, eigenvalue problem, Schwarz’ domaindecomposition algorithm, residual error indicator ...

Seminar, Seville , July 2011, Spain 7

Page 8: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

How to use

on Unix build a "yours.edp" file with your favorite editor :emacs, vi, nedit, etc. EnterFreeFem++ yours.edp orFreeFem++ must be in a directory of your PATH shellvariable.

on Window, MacOs X build a "yours.edp" file with your favoritetext editor (raw text, not word text) : emacs, winedit,wordpad, bbedit, ... and click on the icon of theapplication FreeFem++ and load you file via de openfile dialog box or drag and drop the icon of your builtfile on the application FreeFem++ icon.

Seminar, Seville , July 2011, Spain 8

Page 9: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

The Changes form 12/09 to 12/10

I add some interface with lapack (inverse of fullmatrix, eigenvalue of full matrix)

I change the version of tetgen to 1.4.3 download (4time faster)

I add 3d beam examples e*3d/beam.edpI add dynamic load interface with newuoa fortran

optimizer without derivative see ffnewuoa.edpexample ins examples++-load

I correct problem of free of mesh in case of gluingmeshes Th = Tha + Thb;

I add 3d example and interpolation matrix (e ∗ 3d/mat_interpole.edp)

I writing schwarz-nm-3d.edp examplesI add array of 3d meshI add seekp, tellp method on ostream type seekg,

teeg method on istream typeI correct ’ operator do alway in complex case the

conj and trans (Hermissian stuff)

I plot of complex field and 3d vector .. ( ? ? ?)

I uniformize named parameter in change,movemesh, in load "msh" , glumesh, ...

I change mesh2 tool to make a renumbering ofvertex for periodic 3d mesh.Th = change(Th, renumv = old2new) ;

I correct SubStringI add automatic compilation of download software,

(lots of parallel solver)

I Simplify the compilation of dynamics plugin withff-c++ -auto

I correct mistake in mpiI do asynchronous Isend/Irecv of matrix , meshes.

I 3d mesh adaptation exempleI correct interface of mshmet (compute 3d metric),

freeyams surface adaptation, mmg3d (3d meshmovement)

I add quoting in macro argument

I add script to simple the launch of mpi caseI add MPI version on Windows (not tested)

I Compile a version for Windows 64 arch ?

Seminar, Seville , July 2011, Spain 9

Page 10: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

The Changes form 01/11 to 06/11

I correct probleme of comm world on SuperLuDist(complex version)

I correct medit Makefile.am in case of nocompilation of medit ..

I Add thresholdings.cpp thresholdings.edp inexamples++-load to remove to small coef in amatrix .

I Add lots of DDM Schwarz GMRES precondionnedwith a coarse grid solver overlapping :

I Add a true exemple to buld mesh form a image(lg.pgm) , Leman-mesh.edp

I Add New syntaxe in macro generationNewMacro a(i) .... EndMacro with // commentand macro definition.

I Add interface with special function to GSLhttp://www.gnu.org/software/gsl/ the full list isin the example examples++-loal/gsl.edp

I correct the precond of gmres algo in A−1 : (29mars 2011) to build a correct Navier-Stokes

I add cast TypeOfSolver on int to parametrize thechoise of linear solver.

I put comment in the documentation aboutnegative tgv

I correct mpiReduce for complex and real data.I add mpiAllReduce(umax,dmaxg,comm,mpiMAX);

where for real umax,dmaxg ;

I update the finite element list in documentionI add (load "Element-Mixte") NEW FINITE

ELEMENT 2D TDNSS1 sym matrix 2x2 conformein H(divdiv)/div(divs)) ∈ H−1, RT1 andBDM1 conforme in H(div) Raviart Thomas ofDegree 1 and Bezzi, Douglas, Marini RT1 andBDM1ortho conforme in H(curl) Nedelec FiniteElem.

I add matrix multiplication with lapack interfaceI add tool to change the region and label number

change(Th,fregion= integer function to set theregion number )

I nuTriangle now given the tet number in 3D.I add mpireduce of matrix to build parallel matrixI correct the Hips interface (not to bad , in test)

I add interface with MUMPS_4.10.0 version (withautomatic download )

I add P1dc3d finite element in pluging"Element_P1dc1"

I correct bug in gibbs renumbering in 1 case verusample mesh)

I correct bug in interpolation operator with periodicB.C.

Seminar, Seville , July 2011, Spain 10

Page 11: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

Laplace equation, weak form

Let a domain Ω with a partition of ∂Ω in Γ2,Γe.Find u a solution in such that :

−∆u = 1 in Ω, u = 2 on Γ2,∂u

∂~n= 0 on Γe (1)

Denote Vg = v ∈ H1(Ω)/v|Γ2= g .

The Basic variationnal formulation with is : find u ∈ V2(Ω) , suchthat ∫

Ω∇u.∇v =

∫Ω

1v+

∫Γ

∂u

∂nv, ∀v ∈ V0(Ω) (2)

The finite element method is just : replace Vg with a finite elementspace, and the FreeFem++ code :

Seminar, Seville , July 2011, Spain 11

Page 12: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

Laplace equation in FreeFem++

The finite element method is just : replace Vg with a finite elementspace, and the FreeFem++ code :

mesh3 Th("Th-hex-sph.msh"); // read a mesh 3dfespace Vh(Th,P1); // define the P1 EF space

Vh u,v; // set test and unknow FE function in Vh.macro Grad(u) [dx(u),dy(u),dz(u)] // EOM Grad defsolve laplace(u,v,solver=CG) =

int3d(Th)( Grad(u)’*Grad(v) )- int3d(Th) ( 1*v)+ on(2,u=2); // int on γ2

plot(u,fill=1,wait=1,value=0,wait=1);

Run:fish.edp Run:Laplace3d.edp Run:EqPoisson.edp

Seminar, Seville , July 2011, Spain 12

Page 13: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

Poisson equation with 3d mesh adaptation

load "msh3" load "tetgen" load "mshmet" load "medit"int nn = 6;int[int] l1111=[1,1,1,1],l01=[0,1],l11=[1,1]; // label numberingmesh3 Th3=buildlayers(square(nn,nn,region=0,label=l1111),

nn, zbound=[0,1], labelmid=l11,labelup = l01,labeldown = l01);Th3=trunc(Th3,(x<0.5)|(y < 0.5)|(z < 0.5) ,label=1); // remove ]0.5, 1[3

fespace Vh(Th3,P1); Vh u,v; // FE. space definitionmacro Grad(u) [dx(u),dy(u),dz(u)] // EOMproblem Poisson(u,v,solver=CG) =

int3d(Th3)( Grad(u)’*Grad(v) ) -int3d(Th3)( 1*v ) + on(1,u=0);

real errm=1e-2; // level of errorfor(int ii=0; ii<5; ii++)

Poisson; Vh h;h[]=mshmet(Th3,u,normalization=1,aniso=0,nbregul=1,hmin=1e-3,

hmax=0.3,err=errm);errm*= 0.8; // change the level of errorTh3=tetgreconstruction(Th3,switch="raAQ",sizeofvolume=h*h*h/6.);medit("U-adap-iso-"+ii,Th3,u,wait=1);

Run:Laplace-Adapt-3d.edp

Seminar, Seville , July 2011, Spain 13

Page 14: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

Move structure in meshes

load "msh3" load "tetgen" load "medit" load "mmg3d"include "MeshSurface.idp" real hs = 0.8;int[int] N=[4/hs,8/hs,11.5/hs]; real [int,int] B=[[-2,2],[-2,6],[-10,1.5]];int [int,int] L=[[311,311],[311,311],[311,311]];mesh3 ThH = SurfaceHex(N,B,L,1); mesh3 ThSg =Sphere(1,hs,300,-1); // "gluing" surface meshesmesh3 ThSd =Sphere(1,hs,310,-1);ThSd=movemesh3(ThSd,transfo=[x,4+y,z]); mesh3 ThHS=ThH+ThSg+ThSd;real voltet=(hs^3)/6.; real[int] domaine = [0,0,-4,1,voltet];real [int] holes=[0,0,0,0,4,0];mesh3 Th = tetg(ThHS,switch="pqaAAYYQ",regionlist=domaine,holelist=holes);medit("Box-With-two-Ball",Th);

// End build mesh

int[int] opt=[9,0,64,0,0,3]; // options of mmg3d see freeem++ docreal[int] vit=[0,0,-0.3]; //

fespace Vh(Th,P1); macro Grad(u) [dx(u),dy(u),dz(u)] //Vh uh,vh; // to compute the displacemnt fieldproblem Lap(uh,vh,solver=CG) = int3d(Th)(Grad(uh)’*Grad(vh))

+ on(310,300,uh=vit[2] ) + on(311,uh=0.);

for(int it=0; it<29; it++)Lap; plot(Th,uh);Th=mmg3d(Th,options=opt,displacement=[0.,0.,uh],memory=1000);

Run:fallingspheres.edp

Seminar, Seville , July 2011, Spain 14

Page 15: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

The formulation Primitive equation, toyProblem.

Let ω a domain of R2 and Ω of R2 such thatΩ = (x, y, z)/(x, y) ∈ ω, z0(x, y) < z < zd(x, y) where z0,zd arethe z of top, and the z of the deep of the domain Ω, correspondingto Γ0 (the top) and Γd (the deep), and Γv is the vertical boundary.

Denote, uH is the horizontal velocity, ∇H horizontal gradient ; themean value in z : pz =

∫z p/

∫z 1, ....

The Stokes Primitive equation in Ω ⊂ R3 find u, velocity, p thepressure, such that p is independent of z and :

νH∆HuH + νz∆zuH −∇Hpz

= f

∇.u = 0

Seminar, Seville , July 2011, Spain 15

Page 16: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

The formulation Primitive equation, BC

B.C :

I u3 = 0 on Γ0 and Γd

I uH are given on Γv and Γd .

I we use a wall law at the Γ0 .

remark, due to B.C. on u3, we have ∂zu3z

= 0 so the equation iswell pose , because ∂z(u3) = −∇HuH and u3 know on zd, gives∇H .uH

z= 0,

Seminar, Seville , July 2011, Spain 16

Page 17: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

The formulation Primitive equation,variational form

find uH ∈ Vg and pz ∈W such that ∀vH ∈ V0, qz ∈W :∫

ΩνH∇HuH .∇HvH + νz∇zuH .∇zvH

−∫ω∇H .uH

zqz

−∫ω∇H .vH

zpz = −

∫ΩfvH + ...

where Ω is the horizontal trace of Ω. and u3 is reconstruct fromuH with :

∀v3 ∈ V0,

∫Ω∂zu3∂zv3 = −

∫Ω∇H .uH∂zv3

with V0 = v ∈ H1Ω, v|Γd= 0, v|Γ0

= 0.

Seminar, Seville , July 2011, Spain 17

Page 18: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

The formulation Primitive equation,FreeFem++

V is fespace(Th,[P2,P2]),W is fespace(Thp,[P1],periodic[[G0,x,y],[[Gd,x,y])),where Thp is a mesh with one layer to build a 2d FE element spacebecause No interpolation between 2d and 3d fespace.

mesh Th2D=square(nn,nn);int[int] refm=[1,1,2,1,3,10,4,1], refu=[0,3], refd=[0,2];fespace Vh2(Th2D,P2);mesh3Th=buildlayers(Th2D,nn,zbound=[-1.,0.],labelmid=refm,labelup=refu,labeldown=refd);mesh3Thp=buildlayers(Th2D,1,zbound=[-1.,0.],labelmid=refm,labelup=refu,labeldown=refd);

fespace Vh(Th,[P2,P2,P1]) ; // for u1,u2, pfespace Uh(Th,[P2]) ;fespace Wh(Th,[P2,P2]) ; // for u1,u2fespace Ph2(Thp,[P1],periodic=[[2,x,y],[3,x,y]]) ; // 2dspace ... for p Seminar, Seville , July 2011, Spain 18

Page 19: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

Injection , FreeFem++

The Injection Ih : (u1, u2, pz) 7→ (u1, u2, p)

matrix Ih; // matrix du go from 3d,3d,2d -> 3d,3d,3d

// numbering first u1,u2 second p.int[int] V2Pc=[-1,-1,0], V2Wc=[0,1,-1]; // u1, u2

matrix IPh =interpolate(Vh,Ph2,U2Vc=V2Pc);// ΠV h(v ∈ Ph2)

matrix IWh =interpolate(Vh,Wh,U2Vc=V2Wc);int n = IPh.n;int m = IWh.m+IPh.m;int[int] nuV=0:n-1; // idint[int] nuW=0:IWh.m-1; // u1,u2int[int] nuP=IWh.m:m-1; // p (2d)matrix JJh = IPh(nuV^-1,nuP^-1);matrix IIh = IWh(nuV^-1,nuW^-1);Ih = JJh + IIh;

Seminar, Seville , July 2011, Spain 19

Page 20: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

Matrix , FreeFem++

varf vPrimitive([u1,u2,p3],[v1,v2,q3]) =int3d(Th)(

nuH * ( GradH(u1)’*GradH(v1)+ GradH(u2)’*GradH(v2) )

+ nuz * (dz(u1)*dz(v1) + dz(u2)*dz(v2) )- div2(u1,u2)* q3 // - du3*q3- div2(v1,v2)* p3 // - dv3*p3- 1e-6*p3*q3 // mean value for p3 is zero ..

) // bil. form+ int2d(Th,3) ( (u1*v1 + u2*v2)*0.00001)+ int2d(Th,3) ( v1*0.0001 ) //+ on(10,u1=x*(1-x),u2=0)+ on(1,u1=0,u2=0)+ on(2,u1=0,u2=0);

matrix AA = vPrimitive(Vh,Vh,tgv=ttgv) ;matrix A = AA*Ih; A = Ih’*A; // A = Ih’*A*Ih .

Seminar, Seville , July 2011, Spain 20

Page 21: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

Solve , FreeFem++

real[int] bb= vPrimitive(0,Vh,tgv=ttgv) ;real[int] b=Ih’*bb;real[int] uu= A^-1*b;Vh [u1,u2,p3] ;u1[] = Ih*uu;

varf vU3(u3,v3)=int3d(Th)( dz(u3)*dz(v3) )+ on(3,2,u3=0);

varf vU3U([u1,u2],[v3])=int3d(Th)(-1.*div2(u1,u2)*dz(v3));

matrix A3= vU3(Uh,Uh), B3= vU3U(Vh,Uh);

real[int] b3 = B3*u1[];Uh u3; u3[] = A3^-1*b3;Run:primitive-eq.edp

Seminar, Seville , July 2011, Spain 21

Page 22: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

Linear Lame equation, weak form

Let a domain Ω ⊂ Rd with a partition of ∂Ω in Γd,Γn.Find the displacement u field such that :

−∇.σ(u) = f in Ω, u = 0 on Γd, σ(u).n = 0 on Γn (3)

Where ε(u) = 12(∇u + t∇u) and σ(u) = Aε(u) with A the

linear positif operator on symmetric d× d matrix corresponding tothe material propriety. Denote Vg = v ∈ H1(Ω)d/v|Γd

= g .The Basic displacement variational formulation is : find u ∈ V0(Ω), such that∫

Ωε(v) : Aε(u) =

∫Ωv.f+

∫Γ((Aε(u)).n).v, ∀v ∈ V0(Ω) (4)

Seminar, Seville , July 2011, Spain 22

Page 23: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

Linear elasticty equation, in FreeFem++ The

finite element method is just : replace Vg with a finite elementspace, and the FreeFem++ code :load "medit" include "cube.idp"int[int] Nxyz=[20,5,5];real [int,int] Bxyz=[[0.,5.],[0.,1.],[0.,1.]];int [int,int] Lxyz=[[1,2],[2,2],[2,2]];mesh3 Th=Cube(Nxyz,Bxyz,Lxyz);

// Alu ...real rhoAlu = 2600, alu11= 1.11e11 , alu12 = 0.61e11 ;real alu44= (alu11-alu12)*0.5;func Aalu = [ [alu11, alu12,alu12, 0. ,0. ,0. ],

[alu12, alu11,alu12, 0. ,0. ,0. ],[alu12, alu12,alu11, 0. ,0. ,0. ],[0. , 0. , 0. , alu44,0. ,0. ],[0. , 0. , 0. , 0. ,alu44,0. ],[0. , 0. , 0. , 0. ,0. ,alu44]

];real gravity = -9.81;

Seminar, Seville , July 2011, Spain 23

Page 24: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

Linear elasticty equation, in FreeFem++

The problem code :

fespace Vh(Th,[P1,P1,P1]);Vh [u1,u2,u3], [v1,v2,v3];macro Strain(u1,u2,u3) [ dx(u1), dy(u2),dz(u3), (dz(u2)

+dy(u3)), (dz(u1)+dx(u3)), (dy(u1)+dx(u2)) ] // EOMsolve Lame([u1,u2,u3],[v1,v2,v3])=

int3d(Th)( Strain(v1,v2,v3)’*(Aalu*Strain(u1,u2,u3)) )- int3d(Th) ( rhoAlu*gravity*v3)+ on(1,u1=0,u2=0,u3=0) ;

real coef= 0.1/u1[].linfty; int[int] ref2=[1,0,2,0];mesh3 Thm=movemesh3(Th,

transfo=[x+u1*coef,y+u2*coef,z+u3*coef],label=ref2);

plot(Th,Thm, wait=1,cmm="coef amplification = "+coef );medit("Th-Thm",Th,Thm);

Seminar, Seville , July 2011, Spain 24

Page 25: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

Lame equation / figure

Run:beam-3d.edp Run:beam-EV-3d.edp Run:beam-3d-Adapt.edp

Seminar, Seville , July 2011, Spain 25

Page 26: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

Periodic Surface Acoustic Waves TransducerAnalysis

A true industrial numerical problem (2d) :1. 3 EDP : Dielectric, Elasticity, Piezoelectric , Linear, harmonic

approximation2. α-periodic B.C. (New simple idea)3. semi-infinite Dielectric domain (classical Fourier/Floquet

transforme)4. semi-infinite Piezoelectric domain (Hard)

In 9 month, we build with P. Ventura (100%, me 10%) a numericalsimulator form scratch (8 months for the validation), The only thing toadd to freefem++ is a interface with lapack to compute eigenvector offull 8× 8 matrix.

Le dernier message (hier) : Les calculs des paramètres physiquesdes transducteurs dans la bande d’arrêt et les évaluations decapacité statiques sont très satisfaisants par rapport aux résultatsexpérimentaux ! Seminar, Seville , July 2011, Spain 26

Page 27: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

The physic

Dielectric medium (semi space)

x

maxh

minh

e

p

d

Period p

y

z

uB

dB

d

p

rB lB

Dielectric medium

Buried electrode

Piezoelectric medium

Piezoelectric medium (semi space)

u

e

d

e r

p l

p

r

d l

d

In the dielectric medium Ωd,

D = εdE (5)

In the elastic medium Ωe

T = Ce : S (6)

With Ce is the elastic tensor for theelastic metallic domain. In the piezoe-lectric domain

T = CEp : S − eE

D = eTS + εSE(7)

Seminar, Seville , July 2011, Spain 27

Page 28: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

The physic

The material domain Ωm obeys Newton’s second law :

∇ · T = ρ∂2u

∂t2(8)

The quasi static Maxwell’s equation is assumed for the wholedomain Ω :

∇ ·D = 0 (9)

By using the divergence relationship and the Green’s integralformula, it results the general weak formulation of the periodicγ-harmonic problem :

Seminar, Seville , July 2011, Spain 28

Page 29: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

The variational form

Find (u, φ) in V 3γ (Ωm)× Vγ (Ω)(verifying the equipotential

boundary condition in the electrode), such that for all (v, ψ) inV 3γ (Ωm)× V 3

γ (Ω), satisfying the zero equi potential boundarycondition), we have :∫

Ωm

S (v) : T (u) dΩ− ω2

∫Ωm

ρ v · u dΩ

−∫

ΩE (ψ) · (eS (u) + εE (φ)) dΩ

−∫

Γd

v · (T (u) · n) dΓ−∫

Γu∪Γd

ψ (D (φ) · n) dΓ = 0 (10)

With, Vγ (Ω)is the mathematical space of L2 (Ω) with the derivativein L2 (Ω) satisfying γ-harmonic periodic boundary conditions.

Seminar, Seville , July 2011, Spain 29

Page 30: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

The γ-harmonic periodic boundary trick

Let us first define ϕγ (x) = e−j2πγ x

p , ϕγ (x) is a γ-harmonicperiodic function satisfying :

ϕγ (x+ p) = e−j2πγϕγ (x) (11)

We just do the change of variable :u (x, y) = ϕγ (x)u (x, y)φ (x, y) = ϕγ (x)φ (x, y)

(12)

Where u (x) and φ (x) are p-periodic functions.The main idea is to define a new differential operator ∇γ by :

∇γu = ∇ (ϕγu) = ϕγ∇u + ϕγ

′u (13)

Because the physical fields E,D,T , and S are expressed usingpartial derivative of u, and, φ, it is possible to define the operatorsEγ (φ) = E (ϕγφ

), Dγ (φ) = D (ϕγφ), Tγ (u) = T (ϕγu

),and, Sγ (u) = S (ϕγu

). Seminar, Seville , July 2011, Spain 30

Page 31: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

The new variational form with period BC.

Find (u, φ)in V 31 (Ωm)× V1 (Ω) (verifying the equipotential

boundary condition), such that for all (v, ψ)in V 31 (Ωm)×V 3

1 (Ω),satisfying the zero equipotential boundary condition), we have :

∫Ωm

Sγ (v) : Tγ (u) dΩ− ω2

∫Ωm

ρ v · u dΩ

−∫

ΩEγ (ψ) · (eSγ (u) + εEγ (φ)) dΩ

−∫

Γd

ϕγv · (Tγ (u)n) dΓ−

∫Γu∪Γd

ϕγψ(Dγ (φ) · n) dΓ = 0

(14)

Where, V1 (Ω) is the mathematical space of L2 (Ω) with derivativein L2 (Ω) satisfying p-periodic boundary conditions.

Seminar, Seville , July 2011, Spain 31

Page 32: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

BEM computation

We have to modelized the following term :

−∫

Γd

ϕγv ·(Tγ (u)n) dΓ−

∫Γu∪Γd

ϕγψ(Dγ (φ) · n) dΓ, (15)

also called border terms.First from (15), let us look at the boundary integral AΓu , at theinterface Γu of the semi-infinite dielectric semi-space.

AΓu =

∫Γu

ϕγψDγ (φ) · n dΓ (16)

Seminar, Seville , July 2011, Spain 32

Page 33: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

BEM computation The elementary coefficients to compute

are for all finite element basic functions wi introduce in (??), onlyfor node i ∈ Nu the set of node on Γu.

∀(i, j) ∈ N 2u , (AΓu)ij = −εd

∫Γu

ϕγwi ∂n (ϕγwj) dΓ (17)

According [2], it is possible to expand, at the interface Γu theγ-harmonic periodic ϕγwj into the Floquet’s basis function

fm (x, y) = e−2π(j(m+γ)x−|m+γ|((y−yu))/p = ϕγ (x) fm (x, y) .(18)

where yu is the y coordinate of Γu.

ϕγ (x)wj (x, y) =

+∞∑m=−∞

cjmfm (x, y) (19)

With the L2(Γu) orthogonality of Fourier’s basis fm , we have :

cjm =1

p

∫Γu

wjfmdΓ, (20)

Seminar, Seville , July 2011, Spain 33

Page 34: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

BEM computation,

and on Γu the normal derivative ∂nfm(x, y) = ∂yfm(x, y)satisfies :

∂nfm = −gmfm, with gm =2π

p|γ +m| (21)

Leading to the relationship :

∂n (ϕγwj) = −

+∞∑m=−∞

cjmgmfm (22)

Finally the term (AΓu)ij is

(AΓu)ij =εdp

+∞∑m=∞

gm

∫Γu

wifmdΓ

∫Γu

wjfmdΓ (23)

Seminar, Seville , July 2011, Spain 34

Page 35: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

BEM computation Piezo

Secondly, the boundary integral We introduce the generalize stresstensor,

Tγ(u, φ) =

(Tγ(u)Dγ(ψ)T

)Using [11], it is possible to generalize previous method, but nowthe set of degree of freedom on Γb are set Nb of node on Γbmultiply 4 due to the fourth component (u1, u2, u2, φ) ∈ C4 weintroduce N b = Nb × 1, 2, 3, 4 the set of degree of Freedom, thevectorial finite element basis are w

I = ekwi with ek is canonical

basis vector of C4. The coefficients (AΓd)IJ with (I, J) ∈N b

2

with I = (i, k), J = (j, `) are

(AΓd)IJ = −

∫Γd

ϕγwI · T (wJ

)n dΓ (24)

Seminar, Seville , July 2011, Spain 35

Page 36: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

BEM piezo

With Fahmy Adler technique we get the 4× 4 matrix Gm such thaton Γb we have

∀k = 1, 2, 3, 4, T (fmk)n = −Gmfmk

on Γb (25)

where fmk = e−2πj((m+γ)x)/pek , with ek are the canonical basis

of C4.So with the same computation, we get

(AΓd)IJ =

1

p

+∞∑m=∞

Gmk`∫

Γu

wifmdΓ

∫Γu

wjfmdΓ (26)

because I = (i, k) and J = (j, `).

Seminar, Seville , July 2011, Spain 36

Page 37: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

BEM matrices

For the true computation of the matrices (AΓu)ij ,(AΓd)IJ , we

limit the number of harmonics to Nh by introduction of vectorCm = (Cmi )i∈Nb

, with Cmi =∫

Γuwif

mdΓ, we have

AΓu 'εdp

Nh∑m=−Nh

(Cm) gm (Cm)T

(27)

and (Cmk )I =

∫Γd

ek.wIfm dΓ

AΓu '1

p

Nh∑m=−Nh

(Cmk ) Gmk` (Cm

` )T

(28)

Seminar, Seville , July 2011, Spain 37

Page 38: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

FreeFem++ Trick, computation of the I set

int n = Vh.ndof;real p = int1d(Th,lbord)(1.);

real xx0 = 2.*p , xx1 = xx0-p*1.e-6;real xx2 = xx0-p*2.e-6 , xx3 = xx0-p*3.e-6;

varf vBord([u1,u2,u3,phi],[v1,v2,v3,v]) =on(lbord,u1=x-xx0,u2=x-xx1,u3=x-xx2,phi=x-xx3);

real[int] onbord = vBord(0,Vh);int[int] ii(0:onbord.n-1); // 0,1,2, ... n-1sort(onbord,ii);onbord = onbord ? 1 : 0; // 1 if onbord is non zeroint kdfBEM = onbord.sum +0.5 ;// number of DoF onbordint[int] IdfB2Vh(kdfBEM);

IdfB2Vh = ii(0:kdfBEM-1); // the set I.

Seminar, Seville , July 2011, Spain 38

Page 39: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

FreeFem Coding of Boundary Term

for ( n=-nharm;n<=nharm;++n) complex[int,int] wwn(kdfBEM,4);real ek(4);complex cWn = -2*pi*1i*n/perio;for( k=0;k<4;++k) ek=0.;ek[k]=1.;varf vWn([u],[v1,v2,v3,v4])=int1d(Th,lbord,qforder=25)(exp(cWn*x) *( d[0]* v1+ d[1]* v2+d[2]* v3+d[3]* v4);complex[int] wn =vWn(0, Vh);wwn(:,k) = wn(IdfB2Vh);

real s = 2.*pi*(n+gam)/perio/omega;complex coef = -1i*omega/perio;GreenPiezo4x4(GG,s,rho,CC,EE,EEps,-1);for(int k=0;k<4;++k)

for(int l=0;l<4;++l)ABemFull += (coef*GG(k,l))*wwn(:,k)*wwn(:,l)’;

Seminar, Seville , July 2011, Spain 39

Page 40: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

FreeFem Coding of Boundary Term Remak the

stabilization term in Green (espi=10−10)macro dxa(up) (phia*dx(up)+dphiadx*up) // EOMmacro dya(up) (phia*dy(up)) // EOM

...real rhoomega2 = rho*omega*omega;

// VF Part K (non frequency dependent)varf vfullK ([u1,u2,u3,uphi],[v1,v2,v3,vphi]) =

int2d(Th,regPiezo)(Strain(v1,v2,v3)’*(C5x5*Strain(u1,u2,u3) )

- Strain(v1,v2,v3)’*(E5x2*E(uphi))- E(vphi)’*(E5x2’*Strain(u1,u2,u3))- E(vphi)’*(Eps*E(uphi)))

+ int2d(Th,regElas) (Strain(v1,v2,v3)’*(CAlu5x5*Strain(u1,u2,u3) )

+ E(vphi)’*E(uphi)*epsi )- int2d(Th,regDielec)( ( E(vphi)’*E(uphi) )*Deps

+ epsi*(u1*v1+u2*v2+u3*v3) )+ on(labelec,uphi=phia’);

Seminar, Seville , July 2011, Spain 40

Page 41: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

a numerical case

!Plot of S21 for a 309.70 MHz filter, with three different electrodegeometries. All data has frequency shifted to 309.7 MHz for clarity.

Seminar, Seville , July 2011, Spain 41

Page 42: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

a numerical case

!

comparison of calculated velocities with measurement.Run:PerIDT-V2.3.edp

Seminar, Seville , July 2011, Spain 42

Page 43: FreeFem++ News - UM+/uploads/Main/ff-seville-2011-2.pdf · FreeFem++ News F.Hecht Laboratoire Jacques-Louis Lions Université Pierre et Marie Curie Paris, France with J. Morice, Cécile

Conclusion/Future

Freefem++ v3 isI very good tool to solve non standard PDE in 2D/3DI to try new domain decomposition domain algorithm

The the future we try to do :I Build more graphic with VTK, paraview , ... (in progress)I Add Finite volume facility for hyperbolic PDE (just begin C.F.

FreeVol Projet)I 3d anisotrope mesh adaptationI automate the parallel tool

Thank for you attention.

Seminar, Seville , July 2011, Spain 43