Professional Documents
Culture Documents
Method of FEM
Method of FEM
Method of FEM
Outline
1 Quadrature
Integration in 1D
Integration in 2D and 3D
2 Boundary conditions
Penalty method
Lagrange multiplier method
Outline
1 Quadrature
Integration in 1D
Integration in 2D and 3D
2 Boundary conditions
Penalty method
Lagrange multiplier method
Integration
Riemann sum
Comments:
Both simple but inefficient!
Numerical Integration in 1D
Instead of the Hermite basis functions, and discretize only displacements! Strong form:
d2 d2 w
EI(x) = f (x)
dx2 dx2
a
multiply with test function u(x) and integrate by parts twice
1 d2 w(x) d2 u(x) 1
Z Z
EI(x) dx = f (x)u(x)dx
0 dx2 dx2 0
a
boundary terms [·]1
0 zero by basis selection
code
The full commented code of the following demo will be made available to you in case you would like
to play around. This code is a comparisson between analytical and numerical evaluation of integrals
needed in the implementation of the Galerkin procedure. In the following slides the most important
parts of the code are highlighted. Namely:
1 syms x % C o o r d i n a t e a x i s
2 syms q ( x )
3 % The l o a d i n g o f t h e beam :
4 q( x ) = x .ˆ2 − 0.3∗ x .ˆ4
5 NBASIS = 4 ;
6 f o r i = 1 : NBASIS
7 P h i ( i ) = x . ˆ ( i +1) ;
8 end
9 % Compute t h e i n t e g r a l s n e e d e d f o r t h e s t i f f n e s s m a t r i x :
10 f o r i =1:NBASIS
11 f o r j = 1 : NBASIS
12 K( i , j )= . . .
13 i n t ( EI∗ d i f f ( Phi ( i ) ,2) ∗ d i f f ( Phi ( j ) ,2) ,0 , L ) ;
14 end
15 % A n a l y t i c a l computation of the load v e c t o r :
16 f ( i ) = i n t ( q ( x ) ∗ Phi ( i ) ,0 , L ) ;
17 end
1 q u a d r o r d e r = QUAD ORD ;
2
3 %L o a d i n g t h e Gauss−L e g e n d r e q u a d r a t u r e n o d e s
4 % and w e i g h t s f o r a f i l e :
5 n o d e s w e i g h t s = W{ q u a d r o r d e r −1};
6 n o d e s = ( n o d e s w e i g h t s . n o d e s +1)∗L / 2 ;
7 w e i g h t s = W{ q u a d r o r d e r −1}. w e i g h t s ;
8
9 for i =1: N b a s i s
10 f o r j =1: N b a s i s
11 V = e v a l ( subs ( EI ∗ d i f f ( Phi ( i ) ,2) ∗ d i f f ( Phi ( j ) ,2) , nodes ) ) ;
12 K approx ( i , j ) = V’ ∗ w e i g h t s ;
13 % Note t h a t we don ’ t i n t e g r a t e a n a l y t i c a l l y !
14 % we can g e t EXACT r e s u l t s w i t h o u t d o i n g s o
15 end
16
17 f a p p r o x ( i ) = e v a l ( s u b s ( P h i ( i ) ∗q ( x ) , n o d e s ) ) ’∗ w e i g h t s ;
18 end
Numerical Results
Conclussions
Notice the errors in the approximation (1.7e−13 for quadrature of order 4!). This is close to
machine precission (the ”eps” command in matlab).
1D Quadrature order ”N” means we evaluate the function inside the integral ”N” times, and
we sum the results according to some weight (see next slide).
Instead of integrating analytically a function, we can get EXACT results by carefully selecting
points of evaluation (instead of regular intervals as in trapezoidal and Riemann sums).
We equate all the terms, for every ai term. we arrive at the following linear system:
R1
dx
1 1 1 1 w1
−1
x1
R 1 xdx
x2 x3 x4 w2
−1
2 = R1 2
x1 x22 x23 x42
w3
−1
x dx
x31 x32 x33 x34 w4 R1 3
x dx
| {z } −1
Vandermonde matrix
Non-Gaussian Quadrature
Weights can be negative, in practice they have values of very different scales and solution of
the system for high order quadrature is numerically unstable!
The technique will approximate well integrals of functions that are approximated well with the
corresponding polynomials.
Lower order quadrature works, but as we will see it is far from the best we can do! (half as
good).
Legendre polynomials
In the following, we will see how the Legendre polynomials are important for quadrature in 1D. We
are to use xi such that this integral is exact for every polynomial f (x) with degree n < 2N − 1. For
a given N , solution xi are roots of the Legendre orthogonal polynomial of degree N
Orthogonal polynomials
Legendre orthogonal polynomials Ln satisfy (by construction)a :
Z 1 2
hLk , Lm i = Lk (x)Lm (x)dx = δmk
−1 2m + 1
From now on this integral is going to be refered to as L2 inner product. Formulas for the first few
polynomials areb ,
L0 (x) = 1
L1 (x) = x
1 2
L2 (x) = (3x − 1)
2
1 3
L3 (x) = (5x − 3x)
8
1 4 2
L4 (x) = (35x − 30x + 3)
8
a
There are
R more general definitions of orthogonality and Gaussian quadrature where
hf, giw = Ω f (x)g(x)w(x)dx. The resulting polynomials are useful in other important contexts (stochastic
finite elements!)
b
They are computed with a process known as Gram-Schmidt orthogonalization
Outline of proof:
(N ) (N )
3 {x1 , · · · , xN } are the N roots of the Legendre polynomial of degree N . For brevity, we
(N )
ommit the superscript xi = xi . Chose the quadrature nodes to be these exact points:
Z 1 0Z 1 N :0 N
g(x)L
:
n (x)dx + r(x)dx =
X
w
i g(x
X wi r(xi )
i )Ln (xi ) +
−1 −1
i=1 i=1
4 Since Ln (xi ) = 0, the first term of the RHS vanishes. Moreover, since the degree of g(x) is
lower than N , the first integral term on the left is also zero! That is, through orthogonality
and the abillity to express polynomials of order N − 1 with a polynomial basis that contains
all the monomials (such as the Legendre basis order N )!
Considering again that we are evaluating the quadrature rule on the roots of Legendre polynomial of
degree N , the term LN becomes zero
And we are left with the task of determining the weights as in the non-gaussian case. Therefore,
surprizingly, a N -point gauss quadrature rule is exact for polynomials up to degree 2N − 1.
In practice, the computational determination of weights wi and nodes xi of 1D Gaussian quadrature
rules happens through the so-called Golub-Welsch algorithm.
Quadrilaterals
Tensor-product Quadrature
Take tensor product of the 1D rules. Example: Quadrature in x:
(ξ) (ξ) (ξ) (ξ) (ξ)
wi = {w1 , w2 , w3 , w4 }
ξi = {ξ1 , ξ2 , ξ3 , ξ4 }
Quadrature in y
(η) (η) (η) (η) (η)
wi = {w1 , w2 , w3 , x4 }
ηi = {η1 , η2 , η3 , η4 }
Outline
1 Quadrature
Integration in 1D
Integration in 2D and 3D
2 Boundary conditions
Penalty method
Lagrange multiplier method
Homogeneous constraints
[K]{u} = {f }
K11 ... K1N u1 f
1
. .. . .
.
. . . ..
= .
. .
.
KN 1 ... KN N
u f
N N
Homogeneous constraints
the constraint un = 0, in a matrix form consistent with our FE linear system reads,
N
X
vi u i = 0
i=0
u1
.
.
.
0 ... 1 ... 0 un =0
.
.
.
uN
[V] = Vij = vi vj
T
[V] = {v} {v}
0 ... 0
..
.
. .
[V] = . .
. 1 .
..
.
0 ... 0
This forces the degrees of freedom in the system to satisfy the constraint numerically (not explicitly).
[K] ← [K]pen
with
The rest are the same! (multiply by a large number and add to [K] before solution).
Non-zero RHS
Say, we want to constrain u3 − 2u5 = 3 and at the same time u2 − u3 = 0. In matrix form, the
constraints read:
u1
u2
u3
0 0 1 0 −2 ... u4 = 3
|{z}
} u5
| {z
a1
{v1 }
..
.
u1
u2
u3
0 1 −1 0 0 ... u4 = 0
|{z}
} u5
| {z
a2
{v2 }
..
.
Application of BC on system
In order to impose the constraint on the system, we proceed as such: Multiplying both equations with
the corresponding {vi }T and summing up the constraints for the left-hand side we get,
2
X T
[V ] = {vi } {vi }
i=1
[Kpen ] = [K] + [V ] · p
{fpen } = {f } + {A} · p
What changes, is that we also have a right-hand-side due to the non-homogeneous constraints!
Solution
Simply compute
−1
{u} = [Kpen ] {fpen }
Lagrange multipliers
[v]T
[K]
[KLagr ] =
[v] 0
K11 ... K1N v11 v21
. .. . . .
. . . .
. . . . .
[KLagr ] =
KN 1 ... KN N v1N v2N
v ... v1N 0 0
11
v21 ... v2N 0 0
Constraints at RHS
Instead of adding, we are again appending.
{f }
{fLagr } =
{P }
Comparisson
Penalty has the advantage that does not introduce degrees of freedom to the linear system.
However, this rarely becomes a real problem with modern hardware.
Some linear system solvers rely on the matrix being positive definite for fast convergence -
Lagrange multipliers may not work with some linear system solvers
Lagrange multiplier method provides directly the constraint forces (as the values corresponding
to the rows and columns of the constraints).
When constraints are linearly dependent (a constraint vector can be expressed as linear
combination of other constraints in the same system) iterative solvers (i.e. GMRES) have to
be used. Linear independence of constraints is hard to judge in some cases (however, there are
linear algebra techniques one can perform to remedy that).
The multi-freedom homogeneous case for the Master-slave elimination method, is described
partially in the project description. This method is also exact (as Lagr. Multipliers).