+ All Categories
Home > Documents > INSA_Generic_toolbox for FEM

INSA_Generic_toolbox for FEM

Date post: 14-Oct-2014
Category:
Upload: juancamosquera
View: 31 times
Download: 2 times
Share this document with a friend
1
135, Avenue de Rangueil 31077 Toulouse cedex 4 FRANCE Generic Toolbox for Finite Element Methods Yves Renard, Julien Pommier. UMR 5640, Universit´ e Paul Sabatier, 118 route de Narbonne, 31 062 TOULOUSE FRANCE 1 Introduction G ET F EM is a finite element library, freely distributed under the terms of the Gnu Lesser General Public License (LGPL license, http://home.gna.org/getfem/). It aims at providing some standard tools for the realisation of finite element codes, and in particular: proposing a generic management of meshes: arbitrary dimension, arbitrary geometric trans- formations; providing some generic assembling methods; implementing many advanced methods (mixed methods, mortar elements, hierarchical ele- ments, X-FEM,...), and simplify the addition of new methods; proposing a simple interface under Matlab and Python. 2 The G ET F EM ++ toolbox 2.1 The kernel At the bottom level are located the geometric transformations between the reference 0 1 2 5 3 4 0 2 1 4 5 3 element and the real element. The reference elements are build from simplices and tensorial products of simplices. The geometric transformations are defined by: a reference element ¯ T (triangle, prism, etc..) in R P . several reference nodes { ¯ x i } of this element, and the geometric nodes corresponding on the real ele- ment T R N . some polynomials of arbitrary order: τ : ¯ T R P -→ T R N τ (x)= ng -1 i=0 N i x)g i 2.2 Description of the finite elements (non-exhaustive list) Reference element + basis functions + description of the degrees of freedom. Classical P K and Q k (for arbitrary dimension N and degree K ); Discontinuous P K , tensorial product of methods, additional bubble functions; Hierarchical/composite elements; X-FEM (elements enriched by discontinuous/singular shape functions). Two-dimensional C 1 elements: Argyris, HCT, FVS; Vectorial elements: Raviart-Thomas, Nedelec; 2.3 Elementary integrals calculations Integral over an element (or a face) of the tensorial product of an arbitrary number of basis functions, or their gradients/hessians. Example: T ψ i (x) ⊗∇ψ j (x) ϕ k (x)dx, this tensor can be a basis for the calculation of elementary matrices of the Poisson’s problem, or linear elasticity. 3 Meshes and assembling 3.1 Description of meshes nodes + geometric transformations. The meshes are built element by element, or imported from Matlab’s PDE toolbox, GMSH[3], or GiD[4]. 3.2 Assembling Building the final linear system from finite element methods. Some assembling methods are pro- vided for several classical problems: linearized or large strain elasticity, Poisson, Stokes, bilaplacian, linearized plate... Generic methods: description (independant form the finite element used) of the tensorial opration to make on each element. For instance, for Poisson problem, the assembling of the term T a(x)ψ p .ψ q dx = T j a j φ j i (ψ p ) i (ψ q ) i is described by comp(Grad(#1).Grad(#1).Base(#2))(:,i,:,i,j).a(j). 4 Matlab and Python interface Some easy and widely documented interfaces for Matlab and Python are available (documentation is [2]). access to all the functionalities of the toolbox; allow to benefit from the graphical capabilities of Matlab for proposing a few functions of post- treatment (visualisation of 2D and 3D solutions), for which the quality of the visualisation has been strengthened (careful representation of the discontinuites and the degree of finite elements and geometric transformations). Below, an example of implementation with Matlab interface on a linear elasticity problem. A tripod, whose mesh was built with GiD [4], is loaded verticaly. The calculations were done in isoparametric P 2 . The colormap represents the Von Mises criteria on the surface of the deformed geometry. Von Mises on the surface of a tripod loaded verticaly (calculations done in isoparametric P 2 ) gf_workspace(’clear all’); m=gf_mesh(’import’,’gid’,’tripod.GiD.msh’); mfu=gf_mesh_fem(m,3); % mesh-fem supporting a 3D-vector field mfd=gf_mesh_fem(m,1); % scalar mesh˙fem % we choose a P2 fem for the main unknown gf_mesh_fem_set(mfu,’fem’,gf_fem(’FEM_PK(3,2)’), gf_integ(’IM_TETRA(5)’)); % the material is homogeneous, hence we use a P0 fem for the data gf_mesh_fem_set(mfd,’fem’,gf_fem(’FEM_PK(3,0)’), gf_integ(’IM_TETRA(1)’)); disp(sprintf(’nbcvs=%d, nbpts=%d, nbdof=%d’,gf_mesh_get(m,’nbcvs’),... gf_mesh_get(m,’nbpts’),gf_mesh_fem_get(mfu,’nbdof’))); P=gf_mesh_get(m,’pts’); % get list of mesh points coordinates pidtop=find(abs(P(2,:)-13)<1e-6); % find those on top of the object pidbot=find(abs(P(2,:)+10)<1e-6); % find those on the bottom % assign boundary numbers gf_mesh_fem_set(mf,’boundary’,1,gf_mesh_get(m,’faces from pid’,pidtop); gf_mesh_fem_set(mf,’boundary’,2,gf_mesh_get(m,’faces from pid’,pidbot); % setup the pde object pde.type = ’linear elasticity’; E = 1e3; Nu = 0.3; pde.mf_u=mfu; pde.mf_d=mfd; pde.F = {0,0,0}; pde.lambda={ E*Nu/((1+Nu)*(1-2*Nu)) }; % Lame coefficients pde.mu={ E/(2*(1+Nu)) }; % negative force on the Y axis, applied on boundary 1 (top of the object) pde.bound{1}.type = ’Neumann’; pde.bound{1}.G = {0,-1,0}; % the bottom of the object is fixed on the ground pde.bound{2}.type = ’Dirichlet’; pde.bound{2}.R = {0,0,0}; % solve it (the linear system is a sparse 16000x16000 matrix). tic; [U,pde]=gf_solve(pde); disp(sprintf(’solve done in %.2f sec’, toc)); % now that we have the solution, we want to compute the von mises stress % first, we need to get the gradient of the solution: mfdu=gf_mesh_fem(m,1); % the P2 fem is not derivable across elements, hence we use a discontinuous % fem for the derivative of U. gf_mesh_fem_set(mfdu,’fem’,gf_fem(’FEM_PK_DISCONTINUOUS(3,1)’), ... gf_integ(’IM_TETRAHEDRON(5)’)); % on output size(DU)=[3,3,nbdof(mfdu)] DU=gf_compute(mfu,U,’gradient’,mfdu); % from the derivative, we compute the von mises stress VM=zeros(1,gf_mesh_fem_get(mfdu,’nbdof’)); for i=1:size(DU,3), t=DU(:,:,i); E=(t+t’)/2; VM(i) = sum(E(:).ˆ2) - (1./3)*sum(diag(E))ˆ2; end; VM = 4*pde.lambda{1}ˆ2*VM; gf_plot(mfdu,VM,’mesh’,’on’, ’cvlst’,gf_mesh_get(mfdu,’outer faces’),... deformation’,U,’deformation_mf’,mfu); View in cut of the tripod. Mode of an oscillating structure (Paolo Bertolo). 5 Level-set and XFEM A set of tools are proposed for managing the geometries implic- itly defined by level-sets. The eXtended Finite Element Method (XFEM) allows to manage the dis- ontinuities of the fields accross these geometries, and the asymp- totic fields in presence of singular- ities. Example of XFEM on 3-dimensional elasticity with an angular fracture (the mesh has only one layer of element in the thickness) Displacement of a beam whose cracks are treated by XFEM (with the Von Mises criteria). 6 Other examples Stokes problem in 2D. The velocity is P 2 and the pressure is discontinuous P 1 . Left: velocity modulus on the deformed mesh. Center: velocity (arrows) and pressure (colormap). Right: zoom of center. Stokes problem in 3D, in a cylindrical tank crossed by an incompressible fluid. The figure represents the modulus of the velocity and sev- eral flux lines 1e-08 1e-07 1e-06 1e-05 0.0001 0.001 0.01 0.1 1 10 100 1 10 100 1000 10000 100000 L-infinity error number of degrees of freedom PK(2,1) PK(2,2) PK(2,3) PK(2,4) PK(2,6) PK(2,9) PK(2,12) PK(2,15) Convergence tests of the high degree finite elements on a Laplacian, with a square domain (whose solution is C ). Diffraction of a plane wave by an infinite cylinder, with Q 10 element and geometric transformations of degree 6, thus allowing to have two wavelengths per element. References [1] Y. R ENARD , J. P OMMIER, Getfem++: Short user documentation , http://download.gna.org/getfem/doc/getfemuser/getfemuser.html, 2008. [2] Y. R ENARD , J. P OMMIER, Getfem++ documentation, http://home.gna.org/getfem/doc, 2008. [3] C. G EUZAINE , J.-F. R EMACLE, Gmsh: a three-dimensional finite element mesh generator with built-in pre- and post- processing facilities, http://www.geuz.org/gmsh. [4] I NTERNATIONAL C ENTER FOR N UMERICAL M ETHODS IN E NGINEERING, GiD: the personal pre and post-processor, http://gid.cimne.upc.es/. Award Getfem++ has been awarded by the second price at the ”Trophes du Libre 2007” in the category of scientific softwares (http://www.tropheesdulibre2007.org/).
Transcript
Page 1: INSA_Generic_toolbox for FEM

135, Avenue de Rangueil31077 Toulouse cedex 4

FRANCEGeneric Toolbox for Finite Element Methods

Yves Renard, Julien Pommier.

UMR 5640, Universit́e Paul Sabatier,118 route de Narbonne, 31 062 TOULOUSE

FRANCE

1 IntroductionGETFEM is a finite element library, freely distributed under the terms of the Gnu Lesser General PublicLicense (LGPL license,http://home.gna.org/getfem/). It aims at providing some standard tools for therealisation offinite element codes, and in particular:

proposing ageneric management of meshes: arbitrary dimension, arbitrary geometric trans-formations;

providing somegeneric assembling methods;implementing manyadvanced methods(mixed methods, mortar elements, hierarchical ele-

ments, X-FEM,...), andsimplify the addition of new methods;proposing asimple interface under Matlab and Python.

2 The GETFEM ++ toolbox2.1 The kernel

At the bottom level are located the geometric transformations between the reference

0 1 2

5

3 4

0

2

1

4

5

3

� �

element and the real element. The reference elements are build from simplices andtensorial products of simplices.The geometric transformations are defined by:

• a reference element̄T (triangle, prism, etc..) inRP .

• several reference nodes{x̄i} of this element, and the geometric nodes corresponding on the real ele-mentT ⊂ RN .

• some polynomials of arbitrary order:τ : T̄ ⊂ RP −→ T ⊂ RN τ (x) =

ng−1∑i=0

N i(x̄)gi

2.2 Description of the finite elements (non-exhaustive list)Reference element + basis functions + description of the degrees of freedom.

ClassicalPK andQk(for arbitrary dimensionN and degreeK);DiscontinuousPK, tensorial product of methods, additional bubble functions;Hierarchical/composite elements;X-FEM (elements enriched by discontinuous/singular shape functions).Two-dimensionalC1 elements: Argyris, HCT, FVS;Vectorial elements: Raviart-Thomas, Nedelec;

2.3 Elementary integrals calculationsIntegral over an element (or a face) of the tensorial product of an arbitrary number of basis functions,

or their gradients/hessians.Example:

∫T ∇ψ

i(x) ⊗ ∇ψj(x) ⊗ ϕk(x)dx, this tensor can be a basis for the calculation of elementarymatrices of the Poisson’s problem, or linear elasticity.

3 Meshes and assembling3.1 Description of meshes

nodes + geometric transformations.

The meshes are built element by element, or imported from Matlab’sPDE toolbox, GMSH[3], or GiD[4].

3.2 AssemblingBuilding the final linear system from finite element methods.Some assembling methods are pro-

vided for several classical problems: linearized or large strain elasticity, Poisson, Stokes, bilaplacian,linearized plate...

Generic methods: description (independant form the finite element used) of the tensorial opration tomake on each element. For instance, for Poisson problem, the assembling of the term

∫Ta(x)∇ψp.∇ψq dx =

∫T

∑j

ajφj

∑i

(∇ψp)i(∇ψq)i

is described bycomp(Grad(#1).Grad(#1).Base(#2))(:,i,:,i,j).a(j) .

4 Matlab and Python interfaceSome easy and widely documented interfaces for Matlab and Python are available (documentation is [2]).

access to all the functionalities of the toolbox;allow to benefit from the graphical capabilities of Matlab for proposing a few functions of post-

treatment (visualisation of 2D and 3D solutions), for which the quality of the visualisation has beenstrengthened (careful representation of the discontinuites and the degree of finite elements and geometrictransformations).Below, an example of implementation with Matlab interface on a linear elasticity problem. A tripod,whose mesh was built with GiD [4], is loaded verticaly. The calculations were done in isoparametricP2.The colormap represents the Von Mises criteria on the surface of the deformed geometry.

Von Mises on the surface of a tripod loaded verticaly(calculations done in isoparametricP2)

gf_workspace (’ clear all ’);m=gf_mesh (’ import ’,’ gid ’,’ tripod.GiD.msh ’);mfu= gf_mesh_fem (m,3); % mesh-fem supporting a 3D-vector fieldmfd= gf_mesh_fem (m,1); % scalar mesh˙fem

% we choose a P2 fem for the main unknowngf_mesh_fem_set (mfu,’ fem ’, gf_fem (’ FEM_PK(3,2) ’), gf_integ (’ IM_TETRA(5) ’));% the material is homogeneous, hence we use a P0 fem for the datagf_mesh_fem_set (mfd,’ fem ’, gf_fem (’ FEM_PK(3,0) ’), gf_integ (’ IM_TETRA(1) ’));disp(sprintf(’ nbcvs=%d, nbpts=%d, nbdof=%d ’, gf_mesh_get (m,’ nbcvs ’),...

gf_mesh_get (m,’ nbpts ’), gf_mesh_fem_get (mfu,’ nbdof ’)));P=gf_mesh_get (m,’ pts ’); % get list of mesh points coordinatespidtop=find(abs(P(2,:)-13)<1e-6); % find those on top of the objectpidbot=find(abs(P(2,:)+10)<1e-6); % find those on the bottom% assign boundary numbersgf_mesh_fem_set (mf,’ boundary ’,1, gf_mesh_get (m,’ faces from pid ’,pidtop);gf_mesh_fem_set (mf,’ boundary ’,2, gf_mesh_get (m,’ faces from pid ’,pidbot);% setup the pde objectpde.type = ’ linear elasticity ’;E = 1e3; Nu = 0.3; pde.mf_u=mfu; pde.mf_d=mfd; pde.F = {0,0,0 };pde.lambda= { E*Nu/((1+Nu)*(1-2*Nu)) }; % Lame coefficientspde.mu= { E/(2*(1+Nu)) };% negative force on the Y axis, applied on boundary 1 (top of the object)pde.bound {1}.type = ’ Neumann’; pde.bound {1}.G = {0,-1,0 };% the bottom of the object is fixed on the groundpde.bound {2}.type = ’ Dirichlet ’; pde.bound {2}.R = {0,0,0 };% solve it (the linear system is a sparse 16000x16000 matrix).tic; [U,pde]= gf_solve (pde); disp(sprintf(’ solve done in %.2f sec ’, toc));

% now that we have the solution, we want to compute the von mises stress% first, we need to get the gradient of the solution:mfdu= gf_mesh_fem (m,1);% the P2 fem is not derivable across elements, hence we use a discontinuous% fem for the derivative of U.gf_mesh_fem_set (mfdu,’ fem ’, gf_fem (’ FEM_PK_DISCONTINUOUS(3,1)’), ...

gf_integ (’ IM_TETRAHEDRON(5)’));% on output size(DU)=[3,3,nbdof(mfdu)]DU=gf_compute (mfu,U,’ gradient ’,mfdu);

% from the derivative, we compute the von mises stressVM=zeros(1, gf_mesh_fem_get (mfdu,’ nbdof ’));for i=1:size(DU,3),

t=DU(:,:,i); E=(t+t’)/2; VM(i) = sum(E(:).ˆ2) - (1./3)*sum(diag(E))ˆ2;end;VM = 4*pde.lambda {1}ˆ2*VM;gf_plot (mfdu,VM,’ mesh’,’ on’, ’ cvlst ’, gf_mesh_get (mfdu,’ outer faces ’),...

’ deformation ’,U,’ deformation_mf ’,mfu);

View in cut of the tripod.Mode of an oscillating structure (Paolo

Bertolo).

5 Level-set and XFEM

A set of tools are proposed formanaging the geometries implic-itly defined by level-sets. TheeXtended Finite Element Method(XFEM) allows to manage the dis-ontinuities of the fields accrossthese geometries, and the asymp-totic fields in presence of singular-ities.

Example of XFEM on 3-dimensional elasticity with anangular fracture (the mesh has only one layer of element

in the thickness)

Displacement of a beam whose cracks are treated by XFEM (with the Von Mises criteria).

6 Other examples

Stokes problem in 2D. The velocity isP2 and the pressure is discontinuousP1. Left: velocity modulus onthe deformed mesh. Center: velocity (arrows) and pressure (colormap). Right: zoom of center.

Stokes problem in 3D, in a cylindrical tankcrossed by an incompressible fluid. The figurerepresents the modulus of the velocity and sev-eral flux lines

1e−08

1e−07

1e−06

1e−05

0.0001

0.001

0.01

0.1

1

10

100

1 10 100 1000 10000 100000

L−in

finity

err

or

number of degrees of freedom

PK(2,1)

PK(2,2)

PK(2,3)

PK(2,4)

PK(2,6)PK(2,9)

PK(2,12)

PK(2,15)

Convergence tests of the high degree finiteelements on a Laplacian, with a square domain

(whose solution isC∞).

Diffraction of a plane wave by an infinitecylinder, withQ10 element and geometric

transformations of degree 6, thus allowing tohave two wavelengths per element.

References[1] Y. RENARD, J. POMMIER, Getfem++: Short user documentation,

http://download.gna.org/getfem/doc/getfemuser/getfemuser.html, 2008.

[2] Y. RENARD, J. POMMIER, Getfem++ documentation,http://home.gna.org/getfem/doc, 2008.

[3] C. GEUZAINE, J.-F. REMACLE, Gmsh: a three-dimensional finite element mesh generator with built-in pre- and post-processing facilities, http://www.geuz.org/gmsh.

[4] INTERNATIONAL CENTER FOR NUMERICAL METHODS IN ENGINEERING, GiD: the personal pre and post-processor,http://gid.cimne.upc.es/.

AwardGetfem++ has been awarded by the second price at the ”Trophes du Libre 2007” in the category of scientificsoftwares (http://www.tropheesdulibre2007.org/).

Recommended