12
Finite Element Method Applied to Solid Analysis Design and Implementation Rui Miguel da Costa Alves Maciel May 21, 2013 Abstract This work presents the necessary and sufficient information to develop, from the three-dimensional theory of elasticity expressed as a boundary value problem (BVP), a complete software application that, through an implementation of the finite element method, is of practical use in the field of structural analysis. The finite element method, as covered in this work, is presented as the Bubnov-Galerkin method applied to the three dimensional linear elasticity BVP. The isoparametric element concept is also presented, which is used as a basis for the definition of eight finite element types used in the analysis of three-dimensional problems and the discussion of the problems associated with their integration. The method is implemented as a numerical analysis software program, with support for pre- and post-processing. The software is written in the C++ programming language, having been designed based on the use of software design patterns and following the object-oriented programming paradigm. The user interface is developed with Qt, and the three-dimensional visualisation of the models and analysis results with OpenGL 2.1. A set of examples is also shown, used to validate the implementation’s results and to demonstrate intrinsic properties of this method, as well as to compare the results obtained from the application of the three-dimensional theory of elasticity with those obtained from other theories. Keywords : Finite Element Method, Visualization, Bubnov-Galerkin method, 3D elasticity 1. Introduction The finite element method (FEM) has attained the status of one of the most popular methods used to obtain approx- imate solutions for differential equations. The method’s popularity can be attributed mainly to two properties: its ability to obtain approximate solutions even for problems with complex domains and boundary conditions, and its ease of implementation. In spite of FEM’s power and versatility, in practical ap- plications, getting a solution to a problem represents only a small part, although a fundamental one, of the entire anal- ysis process. Moreover, some estimates indicate (Cottrell et al., 2009, pg. 2) that in a simulation «only 20% of over- all time is actually devoted to the analysis per se », with the bulk of the process being concentrated in creating and preparing the model. This leads to the conclusion that, to improve the way the FEM is put to practical use, attention shouldn’t be focused on the FEM formulation alone. In- stead, a holistic approach should be taken, one which takes on the challenge of providing end-users with the means of performing analyses efficiently and in a user-friendly way. To increase the efficiency of how the FEM is employed in practical applications, it’s necessary to accompany the ever increasing ability to obtain solutions for a wide range of problems with the means to easily put together simulations and access relevant information derived from results. To be in a position to implement these much sought-out gains in efficiency, it’s necessary to look at the FEM as a piece, although one which is fundamentally important, that is integrated in a larger system, one which was designed with the express purpose of helping end-users reach their goals and remove any computational drudge frequently as- sociated with its practical application. To explore the challenges involved in developing FEM im- plementations capable of being put to practical use, a small FEM software program was developed. This FEM program, referred from this point on as FEMP, is based on a FEM im- plementation applied to the three-dimensional linear elas- ticity BVP, and has limited preprocessing and postprocess- ing capabilities. This work covers the development of the FEM based on the Bubnov-Galerkin method, followed by a brief description of the set of elements supported by FEMP. The program’s design process is also covered, accompanied 1

Finite Element Method Applied to Solid Analysis … · Finite Element Method Applied to Solid Analysis Design and Implementation Rui Miguel da Costa Alves Maciel May 21, 2013 Abstract

Embed Size (px)

Citation preview

Finite Element Method Applied to Solid Analysis

Design and Implementation

Rui Miguel da Costa Alves Maciel

May 21, 2013

Abstract

This work presents the necessary and sufficient information to develop, from the three-dimensional theory of elasticityexpressed as a boundary value problem (BVP), a complete software application that, through an implementation of thefinite element method, is of practical use in the field of structural analysis.

The finite element method, as covered in this work, is presented as the Bubnov-Galerkin method applied to the threedimensional linear elasticity BVP. The isoparametric element concept is also presented, which is used as a basis forthe definition of eight finite element types used in the analysis of three-dimensional problems and the discussion of theproblems associated with their integration.

The method is implemented as a numerical analysis software program, with support for pre- and post-processing.The software is written in the C++ programming language, having been designed based on the use of software designpatterns and following the object-oriented programming paradigm. The user interface is developed with Qt, and thethree-dimensional visualisation of the models and analysis results with OpenGL 2.1.

A set of examples is also shown, used to validate the implementation’s results and to demonstrate intrinsic properties ofthis method, as well as to compare the results obtained from the application of the three-dimensional theory of elasticitywith those obtained from other theories.

Keywords: Finite Element Method, Visualization, Bubnov-Galerkin method, 3D elasticity

1. Introduction

The finite element method (FEM) has attained the statusof one of the most popular methods used to obtain approx-imate solutions for differential equations. The method’spopularity can be attributed mainly to two properties: itsability to obtain approximate solutions even for problemswith complex domains and boundary conditions, and itsease of implementation.

In spite of FEM’s power and versatility, in practical ap-plications, getting a solution to a problem represents only asmall part, although a fundamental one, of the entire anal-ysis process. Moreover, some estimates indicate (Cottrellet al., 2009, pg. 2) that in a simulation «only 20% of over-all time is actually devoted to the analysis per se», withthe bulk of the process being concentrated in creating andpreparing the model. This leads to the conclusion that, toimprove the way the FEM is put to practical use, attentionshouldn’t be focused on the FEM formulation alone. In-stead, a holistic approach should be taken, one which takeson the challenge of providing end-users with the means ofperforming analyses efficiently and in a user-friendly way.

To increase the efficiency of how the FEM is employed inpractical applications, it’s necessary to accompany the everincreasing ability to obtain solutions for a wide range ofproblems with the means to easily put together simulationsand access relevant information derived from results.

To be in a position to implement these much sought-outgains in efficiency, it’s necessary to look at the FEM as apiece, although one which is fundamentally important, thatis integrated in a larger system, one which was designedwith the express purpose of helping end-users reach theirgoals and remove any computational drudge frequently as-sociated with its practical application.

To explore the challenges involved in developing FEM im-plementations capable of being put to practical use, a smallFEM software program was developed. This FEM program,referred from this point on as FEMP, is based on a FEM im-plementation applied to the three-dimensional linear elas-ticity BVP, and has limited preprocessing and postprocess-ing capabilities. This work covers the development of theFEM based on the Bubnov-Galerkin method, followed by abrief description of the set of elements supported by FEMP.The program’s design process is also covered, accompanied

1

2.3 Compatibility 2 THE THREE-DIMENSIONAL LINEAR ELASTICITY BVP

by a description of the program’s main components and therequirements that guided their development. Finally, a setof numerical examples are presented to showcase FEMP’scapabilities.

2. The three-dimensional linear

elasticity BVP

The three-dimensional linear elasticity boundary-valueproblem, as used to implement the FEM, is defined in thissection.

2.1. Problem domain

The three-dimensional linear elasticity boundary-valueproblem is defined on a closed domain Ω ∈ R

3, with aboundary Γ = Ω \ Ω, being Ω the interior set of Ω. Letx = (x1, x2, x3) ∈ Ω. The boundary Γ is also set so thatΓN ∩ ΓD = ∅, and Γ = ΓN ∪ΓD, being ΓD and ΓN , respec-tively, the set of points in the boundary where Dirichlet andNewmann boundary conditions are set.

ΓD

ΓN

Ω

x1 x2

x3

Figure 1: Abstract representation of three-dimensional lin-ear elasticity’s problem domain.

2.2. Equilibrium

It was assumed that the solid under analysis is in thestate of static equilibrium in the undeformed configuration.This requirement, when applied to the forces acting on theCauchy tetrahedron, is expressed as:

σij,i + bj = 0 (1)

where bj represents the prescribed force per unit volume. Bybalancing the moments on the Cauchy tetrahedron, it canbe shown that σij is symmetric.

On the boundary, this requirement is expressed as:

σijni = tj , x ∈ ΓN (2)

where ni represents an outer normal vector and tj the pre-

scribed force per unit area.

2.3. Compatibility

In three-dimensional linear elasticity problems, the dis-placement field is represented by a map u : Ω 7→ R

3. Fromthis point onward, each component of the u(x) map is rep-resented by ui(x). It is assumed that ui(x) is continuousthroughout Ω.

By adopting the small displacements hypothesis, thestrain tensor is expressed as:

ǫij(x) =1

2(ui,j(x) + uj,i(x)) (3)

It is also required that ui(x) complies with the problem’skinematic boundary conditions.

ui(x) = ui(x) , x ∈ ΓD (4)

where ui(x) represents the set of points where ui(x)’s valueshave been prescribed.

2.4. Constitutive equation

Hooke’s law was adopted as the constitutive relations,which are represented as:

σij = Dijkl (ǫkl − ǫkl) + σij (5)

with D representing the stiffness tensor and ǫ and σ repre-senting, respectively, the residual strain and stress tensors.From this point onward, ǫ and ǫ will be omitted, resultingin the following expression:

σij = Dijkl ǫkl (6)

For isotropic materials, this relation is representedthrough the following expression:

σij =E

1 + ν

(

ǫij +ν

1− 2 νǫkk δij

)

(7)

where ν and E represent, respectively, Poisson’s coefficient

and Young’s modulus, and δij represents Kronecker’s delta.

2.5. The boundary-value problem

The three-dimensional linear elasticity boundary-valueproblem is defined as follows:

ǫij = 12 (ui,j + uj,i) , x ∈ Ω

σij,i + bj = 0 , x ∈ Ωσij = Dijklǫkl , x ∈ Ωui = ui , x ∈ ΓD

σijni = tj , x ∈ ΓN

(8)

2

3 THE FINITE ELEMENT METHOD 3.1 Formulation

3. The finite element method

In this section, the formulation of the finite elementmethod is presented as the Bubnov-Galerkin method ap-plied to the weak form of the three dimensional linear elas-tic BVP. Subsequently, the elements supported by FEMPwill be introduced, followed by a concise description of theadopted cubature rules.

3.1. Formulation

The three-dimensional linear elasticity BVP may also beexpressed as:

L [u(x)] = pi(x) , x ∈ Ω

ui(x) = ui(x) , x ∈ ΓD

B [u(x)] = ti(x) , x ∈ ΓN

(9a)

(9b)

(9c)

where L[.] and B[.] represent differential operators. In thiscontext, ui(x) represents a function which satisfies all theconditions expressed in (9), and from this point onward isreferred to as the exact solution.

In general, it’s practically impossible to find u(x) forBVPs with an arbitrary domain and boundary conditions.As an alternative, u(x) is replaced with u(x), a functionthat satisfies (9b) but generally does not satisfy (9a) or(9c). Consequently, the results of L[u(x)] and B[u(x)] arenot, in general, respectively p(x) or t(x). In general, a resid-ual error, or simply residual, will exist. For this problem,the residuals are expressed as:

RΩi(x) = Li [u(x)]− pi(x)

RΓN i(x) = Bi [u(x)] − ti(x)

(10a)

(10b)

where RΩ(x) and RΓN(x) represent, respectively, the do-

main and static boundary equilibrium residuals.The u(x) function is chosen with the express purpose of

approximating u(x) in the problem domain. For this pur-pose, this function represents the mapping:

ui :

Ω, DoF

7→ R

where DoF = di1, · · · , din ∈ Rn represents the degrees of

freedom of ui(x), a set of parameters used to adjust u(x) tou(x). This function is referred to as trial function.

By employing a error minimisation criteria, it is possibleto find a set of values di1, · · · , din which represent theoptimal approximation of ui(x) by ui(x). A trial functionassociated with a set of DoFs obtained by an error min-imisation criteria represents an approximate solution to aBVP, which is referred to as approximate solution.

Let a trial function be represented as a linear combinationof a finite set of orthogonal basis functions, expressed as:

ui(x) =

n∑

k=1

dikNk(x) (11)

with Nk(x) being a basis function. The set of basis func-tions used to specify a trial function spans a complete innerproduct space, referred to as Vn.

One such error minimisation schemes, known as theBubnov-Galerkin method, defines approximate solutions bydetermining the set of DoF values which minimise the resid-ual obtained from a trial function. This is done by solvingthe following system of equations:

Ω

Wi(x)RΩi(x) dΩ = 0 , i ∈ 1, 2, 3

ΓN

Wi(x)RΓN i(x) dΓN = 0 , i ∈ 1, 2, 3(12)

where Wi(x), a weight function, also belongs to Vn, and isdefined as follows:

Wi(x) =

n∑

k=1

cikNk(x) (13)

By replacing (13) into (12):

Ω

Wi(x)(

σji,j(x) + bi(x))

dΩ = 0

ΓN

Wi(x) (σij(x)nj(x) − ti(x)) dΓN = 0

(14a)

(14b)

By applying the integration by parts formula and the di-vergence theorem to (14a), followed by adding the resultingexpression to (14b):

Ω

Wi,j(x)σij(x) dΩ =

ΓN

Wi(x)ti(x) dΓN+

+

Ω

Wi(x)bi(x) dΩ (15)

Replacing (13) into (15):

Ω

n∑

k=1

cikNk,j(x)σij(x) dΩ =

=

ΓN

n∑

k=1

cikNk(x)ti(x) dΓN+

+

Ω

n∑

k=1

cikNk(x)bi(x) dΩ (16)

This expression shows that (12) will only hold if both(10a) and (10b) are orthogonal to each basis function of Vn,or if the expression represents a trivial linear combinationof cik. By refactoring (16) to isolate cik, and ignoring thetrivial solution:

3

3.1 Formulation 3 THE FINITE ELEMENT METHOD

Ω

Nk,j(x)σij(x) dΩ =

ΓN

Nk(x)ti(x) dΓN+

+

Ω

Nk(x)bi(x) dΩ (17)

Equation (17) represents the Bubnov-Galerkin methodapplied to the weak form of the three-dimensional linearelasticity BVP. In matrix notation, it can be expressed as:

a(11)(11) · · · a(11)(3n)...

. . ....

a(3n)(11) · · · a(3n)(3n)

d11...

d3n

=

f11...

f3n

(18)

where, if i = j:

a(ik)(jl) =

Ω

Nk,i

E(1− ν)

(1 + ν)(1 − 2ν)Nl,j+

+

3∑

m 6=i,j

Nk,m

E

1 + νNl,m dΩ (19)

and, if i 6= j:

a(ik)(jl) =

Ω

Nk,i

(1 + ν)(1 − 2ν)Nl,j+

+Nk,j

E

1 + νNl,i dΩ (20)

Also:

fik =

ΓN

Nk(x)ti(x) dΓN +

Ω

Nk(x)bi(x) dΩ (21)

The system of algebraic linear equations represented in18, in matrix notation, can be expressed as:

[K] d = f (22)

where [K] is referred to as stiffness matrix, d as the degree

of freedom vector and f the equivalent nodal load vector.The latter can be represented as:

f =

fΓN

+ fΩ (23)

Where

fΓN

and fΩ represent, respectively, contribu-tions from body and surface forces, and are expressed as:

fΓN

=

ΓN

[Nk(x)]T ti(x) dΓN

=

Ω

[N(x)]T

bi(x)

(24a)

(24b)

(a) Original definition (b) Partitioned

Figure 2: Representation of Ω.

The stiffness matrix can be expressed as:

[K] =

Ω

[B]T [D][B] dΩ (25)

where [D] is the the matrix representation of the stiffnesstensor. The [B] matrix is defined as:

[B(x)] = [B1(x), · · · , Bn(x)] (26)

where:

[Bi(x)] =

∂Ni(x)∂x1

0 0

0 ∂Ni(x)∂x2

0

0 0 ∂Ni(x)∂x3

∂Ni(x)∂x2

∂Ni(x)∂x1

0

0 ∂Ni(x)∂x3

∂Ni(x)∂x2

∂Ni(x)∂x3

0 ∂Ni(x)∂x1

(27)

The FEM represents the Bubnov-Galerkin method ap-plied to the weak form of the three-dimensional linear elas-ticity BVP, where ui(x) is a piecewise defined linear ap-proximation of ui(x). To define ui(x), Ω is partitioned intosub-domains with a geometrically simple configuration, re-ferred to as Ωe

k, as represented in figure 2. Each Ωek defines

the support of a local trial function, represented by ueik(x),

whose basis functions span a linear subspace of Vn, referredto as V e

nk. The association between ueik(x) and its support,

Ωek, constitutes a finite element (Reddy, 1993, pág. 4).By partitioning Ω into a collection of geometrically sim-

ple sub-domains, each ueik(x) can be defined based on a

reference finite element, by mapping it to each Ωek. This

reference finite element is referred to as parent element, andits support is referred to as parent element domain.

Considering (13), local trial functions can be defined asfollows:

ueik(x) =

n∑

l=1

deiklNekl(x) , x ∈ Ωe

k

0 , x /∈ Ωek

(28)

which leads to the definition of the finite element trial func-

tion:

ui(x) =

m∑

k=1

ueik(x) (29)

4

3 THE FINITE ELEMENT METHOD 3.2 Supported elements

Ne

11 Ne

12 Ne

21 Ne

22

N1 = Ne

11 N2 = Ne

12 +Ne

21 N3 = Ne

22

Figure 3: Element base functions, and how they map toglobal base functions.

As shown in figure 3, when finite elements share n com-mon degrees of freedom, the element base functions associ-ated with them are combined to form a global base function,expressed as:

Nk(x) =n∑

l=1

Nekl(x) (30)

3.2. Supported elements

Elements were mapped from the parent domain to theglobal space employing the isoparametric transformation.Each Ωe

k is parametrised through the following expression:

x = x(ξ) =

n∑

j=1

Nj(ξ)pj (31)

being pj the j-th point in Ω that is interpolated by theparametrisation and ξ the interpolation parameter. By us-ing this parametrisation, the integrals expressed in (19),(20) and (21) assume the following form:

Ωek

f(x) dΩek =

Ωe,local

k

f ( x(ξ) ) V (ξ) dΩe,localk (32)

with V (ξ) being the n-volume point conversion factor,which is expressed as:

V (ξ) =

det(

[Dx(ξ)][Dx(ξ)]t)

(33)

where [Dx(ξ)] represents the Jacobian matrix of (31). Forvolume integrals, (33) evaluates to:

V (ξ) = det(

[Dx(ξ)])

. (34)

For surface integrals, it is expressed as:

V (ξ) = ‖D1x(ξ) ×D2x(ξ)‖ (35)

The integrand functions from (19) and (20) include par-tial derivatives of Nk with respect to global coordinates,

1

3

4

2

ξ1 ξ2

ξ3

(a) 4-node tetrahedral.

1

6

3

10

4

8

2

5 7

9

ξ1 ξ2

ξ3

(b) 10-node tetrahedral.

Figure 4: Tetrahedral finite element family, mapped in localcoordinates.

while (31) expresses these functions with regards to the lo-cal coordinate system. To obtain these derivative functions,the following coordinate transformation is used:

∂Nj

∂ξ1∂Nj

∂ξ2∂Nj

∂ξ3

=

∂x1

∂ξ1

∂x2

∂ξ1

∂x3

∂ξ1∂x1

∂ξ2

∂x2

∂ξ2

∂x3

∂ξ2∂x1

∂ξ3

∂x2

∂ξ3

∂x3

∂ξ3

∂Nj

∂x1

∂Nj

∂x2

∂Nj

∂x3

(36)

From this expression, the partial derivatives of Nk withrespect to global coordinates are provided by:

∂Nj

∂x1

∂Nj

∂x2

∂Nj

∂x3

= [Dx]−1

∂Nj

∂ξ1∂Nj

∂ξ2∂Nj

∂ξ3

(37)

The stiffness matrix coefficients can be calculated by re-placing (34) and (37) in the integrals (19) and (20). Thesurface force contribution to the equivalent nodal force vec-tor is expressed as:

fΓN

ik =

ΓN

Nk(ξ)ti(ξ) ‖D1x(ξ) ×D2x(ξ)‖ dΓN (38)

while the body force contribution is expressed as:

fΩik =

Ω

Nk(ξ)bi(ξ) det(

[Dx(ξ)])

dΩ (39)

FEMP supports eight types of of three-dimensionalisoparametric finite elements, grouped in three categories:tetrahedral, hexahedral, and triangular prismatic. Thetetrahedral category includes the 4-node and the 10-nodetetrahedral elements, shown in figure 4. The hexahedralcategory includes the 8-node and 27-node Lagrangean finiteelement, as well as the 20-node Serendipian finite elements.These elements are represented in figure 5. The triangu-lar prismatic category, represented in figure 6, includes the6-node, 15-node and the 18-node triangular prismatic ele-ments.

The complete list of the elements’ basis functions andnode ordering is included in Maciel (2013, Annex A).

5

4 SOFTWARE DESIGN AND DEVELOPMENT

ξ1

ξ2

ξ3 2

34

1

5 6

78

(a) 8-node La-grangean.

ξ1

ξ2

ξ3 2

34

1

5 6

78

9

10

11

12

13

14

1516

17

18 19

20

(b) 20-node Serendip-ian.

ξ1

ξ2

ξ3 2

34

1

5 6

78

9

10

11

12

13

14

1516

17

18 19

20

21

22

2324

25

26

27

(c) 27-node La-grangean.

Figure 5: Hexahedral finite element family, mapped in localcoordinates.

ξ1 ξ2

ξ3

1

6

3

4

2

5

9

11 12

(a) 6-node triangularprism.

ξ1 ξ2

ξ3

1

6

310

4

8

2

5

7

9

11 12

13 14

15

(b) 15-node Serendip-ian triangular prism.

ξ1 ξ2

ξ3

1

6

310

4

8

2

5

7

9

11 12

13 14

15

16 17

18

(c) 18-node triangularprism.

Figure 6: Triangular prismatic finite element family,mapped in local coordinates.

3.3. Numerical integration

In general, the integrals expressed in subsection 3.2 can’tbe evaluated in closed form, which leads to the use of nu-merical integration schemes.An efficient technique for func-tions that are polynomials, or near polynomials is Gauss

quadrature (Zienkiewicz et al., 2005, pg. 160). This tech-nique expresses integrals of a polynomial function as:

∫ 1

−1

f(ξ) dξ =

n∑

i=1

f(ξi)wi (40)

where A represents the integration domain, and qi andwi represent, respectively, the i-th quadrature point andweight. Each quadrature rule consist of a set of quadraturepoints, and corresponding weights. A Gauss-Legendre-typeintegration scheme composed of n integration points canintegrate exactly polynomials of degree up to (2n− 1).

While Gauss quadrature rules were determined to inte-grate functions with scalar variables, by Fubini’s theoremit’s possible to integrate functions with vectorial variablesby using:

Ωe

F (β1, β2, β3)dΩe =

l∑

i

m∑

j

n∑

k

f(β1i, β2j , β3k)wiwjwk

Although Gauss quadrature rules only integrate exactlypolynomial functions up to a degree, when using isopara-metric elements, the integrand functions expressed in (19)and (20) are - in general - rational functions, while (38)

includes a square root of a polynomial function. When an-point Gauss quadrature rules is used to integrate thesefunctions, they instead return the integral of a polynomialof degree (2n−1) which interpolates the integrand functionin the points where it is evaluated.

By the Stone-Weierstrass theorem, it can be shown that,by increasing the number of integration points, the inte-gral of a continuous non-polynomial function defined on aclosed interval will converge to its exact value, and that theinterpolation is estimated by the expression (Pina, 1995,pág. 55):

‖en‖ ≤1

4(n+ 1)‖f (n+1)‖∞hn+1 (41)

where h is the maximum spacing between quadraturepoints.

A list of the cubature rules implemented in FEMP isavailable in Maciel (2013, Annex B).

4. Software design and development

The main requirement for FEMP’s design were that it im-plemented the FEM applied do the linear three-dimensionalelasticity BVP. In addition, it should have some visualisa-tion capabilities, to represent models and post-processingresults. Geometry design and mesh generation were con-sidered to be outside of the scope of this work. Therefore,FEMP would need to import mesh data generated by third-party programs.

The following sections cover que main requirements thatserved as a basis for FEMP’s design.

4.1. Data type

FEMP’s design was centred on the data type employedto describe FEM problems. By defining this data type,a FEM implementation can be developed as an operatorwhich takes a specific FEM problem as an operand andreturns the respective approximate solution.

This data type is required to store all the necessary infor-mation to describe FEM models and associated boundaryconditions. This includes the set of elements obtained fromthe mesh discretization of the problem domain, along withthe relevant material properties, as well as static and kine-matic boundary conditions.

For kinematic boundary conditions, it was determinedthat it was only necessary to prescribe zero displacements ofindividual degrees of freedom with regards to the problem’scoordinate system.

For the static boundary conditions, FEMP was requiredto support body, boundary and nodal forces. As each typeof static boundary condition is computed differently, it wasdetermined that each one should be implemented througha dedicated base class, which would be stored in a dedi-cated list. In turn, each base class would be specialised

6

4 SOFTWARE DESIGN AND DEVELOPMENT 4.3 FEM equation assembly

SurfaceLoadDomainLoad

1

1

11

1

1

1

Element

Material

LoadPattern

Node

NodeRestrictions

NodalLoad

Model

*

*

*

*

*

1

*

*

*

Figure 7: Class diagram for the Model data type, withmethods and attributes omitted.

with regards to the parametrisation of the force prescrip-tion domain.

It was assumed that it was only necessary to supportconstant body forces, while boundary forces should be ableto vary along the parametrisation domain.

It was also noted that a user would need to subjectthe same model to different sets of static boundary con-ditions. To avoid the proliferation of files used to representFEM problems, static boundary conditions were organisedin groups, referred to as load patterns.

Finally, it was noted that node restrictions and nodalforces were associated with individual nodes, while domainand surface loads were defined based on an ordered set ofnodes.

Taking these requirements under consideration, theModel data structure was defined as described in figure 7.

4.2. Data importation

In FEMP’s design stage, it was determined that it wasnecessary to import two types of data: previously savedmodels and mesh descriptions generated by third-party pro-grams.

Following the separation of concerns design principle, alldata import components were developed as operators thattook as operands an object of the data type described insection 4.1, and an input file stream. Each data import op-erator implemented a pushdown automaton (Crespo, 2001,pg. 66) developed for its data format, providing support forhandling and reporting syntax and grammar errors.

To store the model information, a new document formatwas defined. The requirements for this document formatwere that it should be able to store all the informationstored in the model data type described in section4.1, itshould include information on the document format ver-sion, and it should be human-readable. The document ver-sion requirement was to safeguard the possibility to updatethe document format definition while retaining the abil-ity to parse older files, without introducing any compati-bility problems between versions. The human-readabilityrequirement was set to safeguard the end-users’ ability to

build global stiffness matrix

Add domain loads contribution

Add surface loads contribution

Solve system of linear equations

Add nodal loads contribution

Figure 8: Activity diagram of the FEM equation assemblyprocess.

use the multitude of third-party tools designed to manipu-late human-readable formats. With these requirements inmind, a new format was created as a subset of the JSONdata interchange language, as defined in Crockford (2006).

4.3. FEM equation assembly

The ability to assemble the FEM equation and obtain theFEM solution to a problem is the backbone of any FEMsoftware application. The process is organised as describedin the activity diagram showed in figure 8.

The separation of concerns design principle was againapplied to the design of the component responsible for thistask. The component was designed as an operator thattook as operands the description of the simulation (i.e., themodel and a load pattern) and returned the FEM equation.

The stiffness matrix assembly process, represented by theactivity diagram shown in figure 9, implemented the calcu-lations and numerical integration scheme described in sec-tion 3.3. The equivalent nodal load vector assembly pro-cess, which included the contributions from body, surface,and nodal loads, was assembled in a similar manner.

4.4. Matrix algebra and linear equations

solver

The FEM equation assembly procedure implemented inFEMP obtained the stiffness matrix by calculating [D] and[B] for each element and subsequently executing the matrixproduct expressed in (25). For this purpose, FEMP reliedon matrix algebra operators for dense matrices provided byEigen (Guennebaud et al., 2010).

To solve the FEM equation, FEMP included customsolvers based on the Cholesky and the conjugate gradientmethod, and also provided support for UMFPack (Davis,2004). As each solver required the stiffness matrix to be de-scribed through a different data type, each solver’s matrixdata type was implemented following the template policy

generic programming design pattern (Alexandrescu, 2001,pg. 6).

7

4.6 Graphical user interface 4 SOFTWARE DESIGN AND DEVELOPMENT

Initialize quadrature rule

set V matrix

set dNdcsi, dNdeta, dNdzeta for integration point

calculate V

set B matrix

K += k_elem

Initialize variables

move to next quadrature point

move to next element

Are there elements left?

Are there quadrature points left?

YesNo

YesNo

k_elem += Bt*D*B*det(V)*Weight

Figure 9: Activity diagram of the stiffness matrix assemblyprocess.

FEMP’s solvers were implemented as a strategy pattern

(Gamma et al., 1995), whose class diagrams is shown infigure 10. By following the separation of concerns de-sign principle, the solvers were implemented as an operatorwhich took the matrix and equivalent nodal force vector asoperands, and returned the degrees of freedom vector.

4.5. Numerial integration

In the analysis requirements stage, it was found thatthe numerical integration part of FEM equation assemblystage, described in 4.3, represented an invariant part of thealgorithm, where the cubature rules depended on whichelement was processed. Considering these characteristics,the numerical integration component was implemented asa template method design pattern (Gamma et al., 1995).The class that represents each finite element and kinematicboundary condition type provided a member function thatreturned the quadrature rule to be used by the FEM equa-tion assembly algorithm.

UMFPACKSolver

Analysis

+ run()

ConjugateGradientSolver

Solver

+ initialize()+ solve()+ cleanup()

CholeskySolver

+solver

Figure 10: Class diagram for FEMP’s solver.

Figure 11: FEMP’s graphical user interface.

4.6. Graphical user interface

FEMP’s graphical user interface (GUI) was developedusing the Qt framework (Qt 4.7), relying heavily on the useof the Observer design pattern (Gamma et al., 1995), bothas Qt’s signals and slots construct and libsigc++ callbackframework (libsigc++ v2.2.10).

FEMP was designed as a multiple document interface(MDI) application. All MDI windows share a common baseclass, MdiWindow, which is used to declare the basic inter-faces that all MDI window classes must implement. Basedon this class, two types of MDI windows were defined: a3D modelling window, which includes an OpenGL view-port widget to render 3D representations of both the modeland analysis results, and an analysis results window, whichserves as a container for a widget designed to display results.

The 3D modelling windows include GUI components de-fined through mixin classes, so that, when required, theycan be reused in different types of subclasses. The OpenGLviewport widget included in the 3D modelling window isimplemented through a strategy design pattern, to providea way to render models according to different representationstrategies, as represented in figure 12. The model represen-tation strategy define the interface used by the scenegraphcomponent, described in section 4.7, to render each sceneobject according to the policy which is set.

An object selection system was also implemented inFEMP. This system consists of two classes: SelectionMan-

ager and Selection. The SelectionManager class manages alist of scene objects which were selected by the user, rep-resented as an object of type Selection, and provides a setof interfaces designed to notify any GUI component of anychange to the selection list, as shown in figure 13. For thispurpose, the Observer design pattern (Gamma et al., 1995)was used to automatically notify any GUI component onany event originated from any change made to the selectionlist.

4.7. Scenegraph

FEMP’s visualisation was implemented through a scene-graph component. This component consists essentially ofa list of all scene objects rendered in the 3D viewport, a

8

4 SOFTWARE DESIGN AND DEVELOPMENT 4.7 Scenegraph

ModelViewport PostProcessingViewport

ModelViewport

(a) Model representation strategy.

ModelViewport PostProcessingViewport

ModelViewport

(b) Postprocessing strategy

Figure 12: Strategy design pattern used to configure theuser interface.

: SelectionManager : ModelWindow

: setSelection(selection Selection)

: selectElement(eref : fem::element_ref_t)

: ModelWindow

: setSelection(selection: Selection)

Figure 13: Sequence diagram of the object selection system.

Figure 14: Representation of the Observer design pattern.

Figure 15: Representation of how the scene graph is organ-ised.

graph used to organise how these objects are rendered, anda set of routines required to manage the data structuresand render the scene. It also includes a camera component,which is used to manage how the scene is presented to theuser.

The 3D viewport is used to render the model and analy-sis results by employing a model-view-controller design pat-tern (Gamma et al., 1995), where the model data type de-scribed in section 4.1 participates as the Model, and thescenegraph component participates as both the View andthe Controller. Both the model and the scenegraph wereupdated to reflect any relevant change by employing theObserver design pattern, represented in figure 14.

The scenegraph component was implemented through afaçade design pattern (Gamma et al., 1995), to providea single interface to handle how scene objects were ren-dered, and thus limit the component’s complexity. Thescene graph structure represents an undirected graph with-out cycles (i.e., a tree structure), and it is automatically as-sembled from the list of all scene objects. The scene graphis formed by two types of vertices: leafs, which representindividual scene objects, and the internal vertices, whosefunction is to group child vertices.

All vertices contain a description of a boundary. In leafs,the boundary defines a region in space which contains theleaf’s scene object, while in internal vertices it represents aregion in space which contains the boundaries of all childvertices, as represented in 15.

The scene graph structure is assembled according to agraph assembly policy which, taking under consideration

9

5.2 Cubic cantilever 5 NUMERICAL EXAMPLES

Figure 16: View frustum culling representation.

Figure 17: Picking representation.

the current state of the camera component, organises theobjects to implement a form of view frustum culling. Forthis purpose, the scene graph structure was implementedas a combination of a composite and visitor design pattern(Gamma et al., 1995). By defining a concrete visitor classwhich would render scene objects only if they were includedin the view frustrum, as represented in figure 16, this pro-vided a convenient way to render only the scene objectswith added efficiency.

The scenegraph component was also used to implementmouse picking. This was achieved by defining a concretevisitor class that traversed the scene graph to find whichscene objects were intersected by a pick ray, as shown infigure 17.

5. Numerical examples

In this section, two examples based on analysis conductedby FEMP are shown. The examples included in this sectionwere defined based on a coherent system of units.

5.1. Patch test

The patch test refers to a family of practical tests whichwere created to provide a sufficient condition for conver-gence (Zienkiewicz et al., 2005, pg. 40) but also have beenadopted as a test to validate the results produced by a FEMimplementation.

FEMP’s implementation was tested by performing apatch test based on a test referred to as test C in

Figure 18: Graphical representation of the e33 field obtainedfrom a patch of eight 8-node hexahedral finite elements.

Zienkiewicz et al. (2005, pg. 334). The test consisted ofsubjecting a model of a prismatic bar with square cross sec-tion, defined by a small patch of elements, to constant stateof strain. This was achieved by prescribing constant nega-tive surface forces of t = 1.00 at the ends of the bar. Themodel measured l = 4.00 in length, with the axis alignedwith the coordinate system’s ZZ axis, and the edges of thesquare cross section measured b = 1.00. For the materialproperties, E = 10 and ν = 0.3.

A patch model was created for each finite element typeimplemented in FEMP. After running the analyses, all ele-ments were able to produce a constant state of strain, withǫ33 = −0, 1, ǫ11 = ǫ22 = 0, 03, and ǫij ≈ 0, i 6= j. The com-plete results are available in Maciel (2013). The result forthe analysis conducted on the 8-node hexahedral elementpatch, as represented by FEMP, is presented in figure 18,with blue representing the highest negative value for ǫ33.

5.2. Cubic cantilever

To evaluate the order of convergence of each element typesupported by FEMP, analyses were performed on a seriesof FEM models of a cubic cantilever.

The cantilever was defined as measuring 1.00 × 1.00 ×1.00 whose faces are perpendicular to the global coordinatesystem’s axis. The material properties were prescribed asE = 10 and ν = 0.3. All models were subjected to a unitbody force of b = 1.00 prescribed to all elements parallel tothe x3 axis.

For each finite element type, a set of progressively re-fined models were created based on an element subdivisionscheme. After performing the analysis on each model, theirstrain energy was evaluated. The results are available inMaciel (2013), and are represented in figure 19.

The results show that, as expected, the convergence rateof each element implemented in FEMP are identical to thetheoretical convergence rate for elements with a completepolynomial expansion of the same degree. The results alsoshow that an asymptotically convergence was not achieved,which can be attributed to the influence of singularities, as(Zienkiewicz et al., 2005, pg. 38)

The results were also factored with regards to estimates

10

5 NUMERICAL EXAMPLES 5.2 Cubic cantilever

(a) Linear elements.

(b) Quadratic elements.

Figure 19: Graph of the energy error convergence rate interms of the h-refinement of the models.

of the computational cost associated with each finite ele-ment type. The strain energy results presented in figure 19represented in terms of the time taken to conduct the anal-ysis are presented in figure 20.

It was also possible to calculate stress fields from theFEM analysis results. In figure 21 it is displayed a cubemodel in the deformed configuration. The stress resultstaken from the FEM analysis were compared with thoseproduced by the Euler-Bernoulli beam theory and are pre-sented in figure 22.

Figure 20: Graph of the energy error convergence rate interms of analysis duration.

Figure 21: Model formed by 512 8-node hexahedral finiteelements, subjected to a constant body force, displacementsamplified 100×.

(a) σ23 stress.

(b) σ33 stress.

Figure 22: Comparison between stresses calculated fromEuler-Bernoulli theory and FEM analysis, taken from themid vertical fiber included in the fixed plane.

11

REFERENCES REFERENCES

6. Conclusions

Based on the experience gained from designing and de-veloping FEMP, it was possible to conclude that the FEMapplied to the three-dimensional linear elasticity BVP, inspite of it’s non-trivial theoretical background, is simple toimplement. However, developing a competitive FEM ap-plication which is appropriate for practical applications isa challenging task, that requires knowledge on a multitudeof fields, including computer graphics and mesh generation.Without this, it’s practically impossible to develop an ap-plication which can be adequately used to analyse practicalproblems.

References

Alexandrescu, Andrei (2001). Modern C++ Design:

Generic Programming and Design Patterns Applied.Addison-Wesley.

Cottrell, J. Austin, Thomas J.R. Hughes and Yuri Bazilevs(2009). Isogeometric Analysis: Toward Integration of

CAD and FEA. Wiley.

Crespo, Rui Gustavo (2001). Processadores de linguagens:

da concepção à implementação. IST Press, second edi-tion.

Crockford, D. (2006). The application/json Media Type forJavaScript Object Notation (JSON). RFC 4627 (Infor-mational).

Davis, Timothy A. (2004). Algorithm 832: Umfpack v4.3—an unsymmetric-pattern multifrontal method. ACM

Trans. Math. Softw., 30, 196–199.

Gamma, Erich, Richard Helm, Ralph Johnson and JohnVlissides (1995). Design Patterns: Elements of Reusable

Object-Oriented Software. Addison-Wesley.

Guennebaud, Gaël, Benoît Jacob et al. (2010). Eigen v2.http://eigen.tuxfamily.org.

libsigc++ v2.2.10 (2012). libsigc++ v2.2.10.http://libsigc.sourceforge.net/.

Maciel, Rui (2013). Método dos elementos finitos aplicado à

análise de sólidos: concepção e implementação. Master’sthesis, Instituto Superior Técnico.

Pina, Heitor (1995). Métodos Numéricos. McGraw Hill.

Qt 4.7 (2011). Qt 4.7.http://doc.qt.nokia.com/4.7/index.html.

Reddy, J. N. (1993). An introduction to the finite element

method. McGraw-Hill, second edition.

Zienkiewicz, O. C., R. L. Taylor and J. Z. Zhu (2005). Finite

Element Method: Its Basis and Fundamentals, volume 1.Elsevier Butterworth–Heinemann, sixth edition.

12