solving the laplacian equation in 3d using finite element

7
HAL Id: hal-00656481 https://hal.inria.fr/hal-00656481 Submitted on 5 Jan 2012 HAL is a multi-disciplinary open access archive for the deposit and dissemination of sci- entific research documents, whether they are pub- lished or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers. L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires publics ou privés. Solving the Laplacian Equation in 3D using Finite Element Method in C# for Structural Analysis Bedr’Eddine Ainseba, Mostafa Bendahmane, Alejandro Lopez To cite this version: Bedr’Eddine Ainseba, Mostafa Bendahmane, Alejandro Lopez. Solving the Laplacian Equation in 3D using Finite Element Method in C# for Structural Analysis. ALEJANDRO PEDROZA, CELSO GUTIÉRREZ, ELSA CHAVIRA and FRANCISCO J. MENDIETA. VEHICULOS AEROESPA- CIALES, Sociedad Mexicana de Ciencia y Tecnología Aeroespacial (Mexican Society of Aerospace Science, and Technology), 2011. hal-00656481

Upload: others

Post on 30-Oct-2021

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Solving the Laplacian Equation in 3D using Finite Element

HAL Id: hal-00656481https://hal.inria.fr/hal-00656481

Submitted on 5 Jan 2012

HAL is a multi-disciplinary open accessarchive for the deposit and dissemination of sci-entific research documents, whether they are pub-lished or not. The documents may come fromteaching and research institutions in France orabroad, or from public or private research centers.

L’archive ouverte pluridisciplinaire HAL, estdestinée au dépôt et à la diffusion de documentsscientifiques de niveau recherche, publiés ou non,émanant des établissements d’enseignement et derecherche français ou étrangers, des laboratoirespublics ou privés.

Solving the Laplacian Equation in 3D using FiniteElement Method in C# for Structural Analysis

Bedr’Eddine Ainseba, Mostafa Bendahmane, Alejandro Lopez

To cite this version:Bedr’Eddine Ainseba, Mostafa Bendahmane, Alejandro Lopez. Solving the Laplacian Equation in 3Dusing Finite Element Method in C# for Structural Analysis. ALEJANDRO PEDROZA, CELSOGUTIÉRREZ, ELSA CHAVIRA and FRANCISCO J. MENDIETA. VEHICULOS AEROESPA-CIALES, Sociedad Mexicana de Ciencia y Tecnología Aeroespacial (Mexican Society of AerospaceScience, and Technology), 2011. hal-00656481

Page 2: Solving the Laplacian Equation in 3D using Finite Element

Solving the Laplacian Equation in 3D using Finite

Element Method in C# for Structural Analysis

BedrEddine Ainseba1, Mostafa Bendahmane2 and Alejandro Lopez Rincon3

EPI, Anubis INRIA Bordeaux Sud-Ouest. Institut Mathematiques de Bordeaux, Universite Victor Segalen Bordeaux 2 Place de laVictoire 33076 Bordeaux, France.

[email protected], [email protected] and 3alejandro.lopez [email protected]

Abstract- In this paper, we present the implemen-

tation of a Finite Element Method (FEM) software

developed using C# for Three Dimensional Laplace

Equation, considering inhomogeneous Dirichlet and

Neumann Boundary Conditions. This can be used

for structural analysis.

Keywords- Finite Element Method (FEM), C#,

Boundary Conditions, Structural Design, software.

1 Implementing the Finite ElementMethod

Having the following system:−∇ ·

(c∇u

)= f, in Ω,

u = g, on Γ1,

c ∂u∂n = h, on Γ2,

(1.1)

Γ2Γ1

Ω

where Ω is a polygonal domain and ∂Ω = Γ1 ∪ Γ2.

The Finite Element Method [13] (FEM), when ap-plied to (1.1), produces a matrix-vector equationKU = F whose solution vector U contains the nodalvalues of the approximate solution function.

There are three steps to implement the FEM:

• Create the mesh for Ω,

• Calculate the Stiffness Matrix K and Load VectorF ,

• Solve the system KU = F .

1.1 Mesh

The different Meshes were created using the Meshes from*.Tri Files, *.STL Files, and *.Msh Files. The Tetrahe-dra elements are created from the given surfaces usingGMESH [1], or by programming a specified geometry,like two spheres, and transforming it into a *.Msh File.To represent the geometries we programmed a graphicenvironment using OpenGL [2] (Open Graphics Library)and a visual interface of 30 fps (frames per second). Toimplement OpenGL we used the Tao Framework [3].

q3

q1

q2

q4

- @@@I

@@

@@

@@

6

*

HHHYHH

HHH

H

1.2 Stiffness Matrix

Page 3: Solving the Laplacian Equation in 3D using Finite Element

The Stiffness Matrix is calculated using the following:

Kij =

N∑i=0

∫Tetk

c∇φi · ∇φj , (1.2)

where φ =

1, i = j,

0, i 6= j,

i, j = 1, 2, 3, 4

where the function φ is represented by

φi(x, y, z) = ai + bix+ ciy + diz, (x, y, z), (1.3)

for i, j = 1, 2, 3, 4.

The coefficients ai + bi + ci + di can be found by solvinga 4 x 4 system of equations. For example, for i = 1 weget the following system:

a1 + b1x1 + c1y1 + d1z1 = 1

a1 + b1x2 + c1y2 + d1z2 = 0

a1 + b1x3 + c1y3 + d1z3 = 0

a1 + b1x4 + c1y4 + d1z4 = 0.

(1.4)

If we combine the 4 systems and put them in matrixform we have the next system:

1 x1 y1 z1

1 x2 y2 z2

1 x3 y3 z3

1 x4 y4 z4

a1 a2 a3 a4

b1 b2 b3 b4c1 c2 c3 c4d1 d2 d3 d4

= (1.5)

1 0 0 00 1 0 00 0 1 00 0 0 1

,where

a1 a2 a3 a4

b1 b2 b3 b4c1 c2 c3 c4d1 d2 d3 d4

, (1.6)

is the inverse of 1 x1 y1 z1

1 x2 y2 z2

1 x3 y3 z3

1 x4 y4 z4

. (1.7)

To assemble the Stiffness Matrix is necessary to calculatethe following integral:∫

Tetk

c∇φi · ∇φj . (1.8)

since φi is linear over Tetk (the k Tetrahedra), the gra-dients are constant:

∇φi =

bicidi

. (1.9)

Therefore∫Tetk

c∇φi · ∇φj = (∇φi · ∇φj)∫Tetk

c, (1.10)

and the integral of c can be estimated with the 1-pointrule. ∫

Tetk

c = V ∗ c(x, y, z), (1.11)

where

x =x1 + x2 + x3 + x4

4,

y =y1 + y2 + y3 + y4

4,

z =z1 + z2 + z3 + z4

4,

(1.12)

and

V =1

6det

∣∣∣∣∣∣∣∣1 x1 y1 z1

1 x2 y2 z2

1 x3 y3 z3

1 x4 y4 z4

∣∣∣∣∣∣∣∣ . (1.13)

1.3 Load Vector

To compute the load vector F the process is similar:∫Tetk

fφi =1

4V f(x, y, z). (1.14)

1.4 Dirichlet conditions

To deal with the Inhomogeneous Dirichlet conditions theLoad Vector F becomes:

Fi =

∫Ω

fφi −∫

Ω

c∇G · ∇φi, i = 1, 2, .., N, (1.15)

where G is defined by

G(n) =

g(n), n ∈ Γ1,

0, n 6= Γ1.

The function G will be 0 in all the tetrahedra that doesnot have constrained nodes. In the tetrahedra that have

Page 4: Solving the Laplacian Equation in 3D using Finite Element

at least one constrained node, the calculation will havethe next form:

−∫Tet

c∇G∇φi = −∇G∇φi∫Tet

c, (1.16)

where

∇G =

4∑i=0

wi∇φi,

and wi are the values in each Node. The contributionsto Fi will have the form of

Fi− = c(x, y, z) ∗G ∗ V, (1.17)

where G has the form of

G =

b1 c1 d1

b2 c2 d2

b3 c3 d3

b4 c4 d4

∗ b1 b2 b3 b4c1 c2 c3 c4d1 d2 d3 d4

∗w1

w2

w3

w4

.(1.18)

and will contribute to each Node i in the tetrahedra.

1.5 Inhomogeneous Neumann condi-tions

To add the Inhomogeneous Neumann conditions the loadvector F becomes:

Fi =

∫Ω

fφi −∫

Ω

c∇G · ∇φi +

∫Γ2

hφi, i = 1, 2, .., N

(1.19)where ∫

Γ2

hφi =

∫e1

hφi +

∫e2

hφi +

∫e3

hφi. (1.20)

being e1 and e2 and e3 the Nodes of the outside trianglebelonging to the the tetrahedra in the Γ2.

To apply the Neuman Data vector in each node,we do the following steps:First we add the values of the NeumanDatai,fori =1, 2, 3 and we will call this value h and divide it by 3.Then we calculate the Normal vector,then we generatetwo temporal vectors in the next form x2 − x1

y2 − y1

z2 − z1

, (1.21)

x3 − x1

y3 − y1

z3 − z1

. (1.22)

then we do the cross product of the vectors (1.21) and(1.22), and calculate the Euclidian norm( n = ‖x‖ =√x2 + y2 + z2) of the vector. The area of the triangle

will be

A =n

2, (1.23)

The contributions to Fi will have the form of

Fi+ =h ∗A

3. (1.24)

1.6 Solving the System

We have a system KU = F , where the Stiffness Matrixis a positive definitive matrix, we can solve the systemby implementing the Conjugate Gradient algorithm.To improve the performance of the algorithm we usesparse matrix multiplication for each step in the CG cal-culation. This reduces the calculation up to 90% in time.

The Stiffness Matrix , for the moment has a limit.In Visual Studio and Visual C# Express the limit in64 bits systems is an object (in this case an array)of 2 GB. In practice, the object ,to be manageable,should not be greater of 1 GB. To solve this problem forlarge calculations the information is written in disk andloaded where necessary to have enough free memorythrough SQL implementation.

2 Numerical Results for FEM

To test the program we used the following equations:

u = (x−1)∗(x−1)∗(y−1)∗(y−1)∗(z−1)∗(z−1), (2.1)

c = 1.

As Mesh we have two spheres as is Figure 1. Knowingthe analytical solution in each of the nodes is (2.1), wehave the next result (Figure 2) in the Nodes in Γ2 wherethe difference between the calculated and the analyticalsolution is shaded. The generated figures of the test areFigure 3 and 4 for the calculated and analytical solutionrespectively.

With a calculated error of 3.78x10−4 using the following

Page 5: Solving the Laplacian Equation in 3D using Finite Element

Figure 1: Mesh use for the FEM Test 1

Figure 2: Results of FEM Test 1

formula:

e =

Nt∑i=0

(|uta[i]−utc[i]|)

Nt∑j=1

(|uta[i]|)

nt. (2.2)

Figure 3: Calculated solution of FEM Test

Figure 4: Analytical solution of FEM Test

The software can be applied to any geometry and withdifferent mathematical functions as in Figure 5. Withthe Boundary Conditions described in Figure 6 wherethe color red Represents the Neuman Boundary Con-ditions and the black the Dirichlet Boundary Condi-tions.We applied the FEM and we have a calculated errorof 5.42x10−3. We can see the result in the Figure 7.

Figure 5: A simplified Mesh for a Wing with 223 Nodesand 1498 Tetrahedra

Figure 6: Boundary Conditions for the Wing Mesh

Page 6: Solving the Laplacian Equation in 3D using Finite Element

We refine the mesh as in Figure 5. and make the anal-

Figure 7: FEM Results for the Wing Mesh

ysis again, we can see the results in Figure 9, havingan error of 1.79x10−3, we can conclude that error getssmaller as we have more elements.

Figure 8: Second Mesh for a Wing with 1803 Nodes and10864 Tetrahedra

Figure 9: FEM Results for the Wing Mesh 2

3 Conclusions and Future Work

The software was created using the Visual C# Express

2010, a free open compiler from Microsoft. It was testedover a Window 7 computer with a 64 bit processor. Thetime needed to make the analysis is about of 2 minutes,and it has been tested with up to 50,000 elements, whichtakes about 15 minutes.

The software was successful in solving the Laplace equa-tion in 3 dimensions which is very useful in calculatingthe propagation of heat and electrostatic energy which isused in mechanical and mechatronical design and can beapplied to the design of aero spatial equipment. It wastested with several geometries and different test func-tions.

As future work the second version of the software willimplement Vibration analysis and Steady State analysisand the implementation of the Delaunay triangulationfor local Mesh Refinement.

References

[1] Geuzaine C. and Remacle J. Gmsh: a three- di-mensional finite element mesh generator with built-in pre- and post- processing facilities. Web.1997-2008.< http : //www.geuz.org/gmsh >.

[2] OpenGL - The Industry Standard for High Per-formance Graphics. Web. 21 May 2011. < http ://www.opengl.org/ >.

[3] R. Ridge, ” Tao framework.”. Web. 21 May 2011.< http : //www.taoframework.com/Home >.

[4] Gockenbach, Mark S. Understanding and Imple-menting the Finite Element Method. Philadelphia,PA: Society for Industrial and Applied Mathemat-ics, 2006. Print.

[5] Blum, Howard. ”Solid Mechanics and Its Applica-tions # 157: MATLAB Codes for Finite ElementAnalysis: Solids and Structures by A. J. M. Fer-reira - Powell’s Books.” Web. 09 May 2011.

[6] Reddy, J. N. An Introduction to the Finite ElementMethod. McGraw-Hill, 1993. Print.

[7] Petyt, M. Introduction to Finite Element VibrationAnalysis. New York: Cambridge UP, 2010.

[8] Dhondt, Guido D. C. The Finite Element Methodfor Three-dimensional Thermomechanical Applica-tions. Hoboken, NJ: Wiley, 2004. Print.

Page 7: Solving the Laplacian Equation in 3D using Finite Element

[9] Liu, Gui-Rong, and S. S. Quek. The Finite Ele-ment Method: a Practical Course. Oxford [u.a.:Butterworth-Heinemann, 2006. Print.

[10] Polycarpou, Anastasis C. Introduction to the FiniteElement Method in Electromagnetics. [San Rafael,Calif.]: Morgan & Claypool, 2006. Print.

[11] Press, William H. Numerical Recipes: the Art ofScientific Computing. Cambridge, UK: CambridgeUP, 2007. Print.

[12] Lucquin, Brigitte, and Olivier Pironneau. Introduc-tion Au Calcul Scientifique. Paris: Masson, 19 9.Print.

[13] ”Finite Element Method.” Wikipedia, the FreeEncyclopedia. Web. 09 May 2011. < http ://en.wikipedia.org/wiki/F initeelementmethod >.