Sei sulla pagina 1di 6

Student: Victor Pugliese

R#: 11492336
Course: MATH 5345 Numerical Analysis
Project 01

The problem is considered is:


−Δ𝑢 = 𝑓 𝑖𝑛 Ω = (−1,1)2
𝐸𝑞. (1) {
𝑢 = sin 𝑥 + sin 𝑦 𝑜𝑛 𝜕Ω

The equation (1) is a linear second order elliptic equation known as Poisson equation. If 𝑓 =
sin 𝑥 + sin 𝑦; thus, 𝑢 = sin 𝑥 + sin 𝑦 is the analytical solution of equation (1). It is important to
note that the model has inhomogeneous boundary condition.

I. Variational Formulation.
This problem has different trial and test space due to the boundary condition 𝑢 =
𝑔𝐷 . The trial space is given by
𝑉𝑔𝐷 = {𝑣: ‖𝑣‖𝐿2 + ‖∇𝑣‖𝐿2 < ∞, 𝑣|𝜕Ω = 𝑔𝐷 }
The test space is given by
𝑉0 = {𝑣: ‖𝑣‖𝐿2 + ‖∇𝑣‖𝐿2 < ∞, 𝑣|𝜕Ω = 0}

Then,
We multiply −Δ𝑢 = 𝑓 by a test function 𝑣, which is in 𝑉0.
− ∫ Δ𝑢𝑣𝑑𝑥 = ∫ 𝑓𝑣𝑑𝑥
Ω Ω
Using Green’s formula:
∫ ∇𝑢 ∙ ∇𝑣𝑑𝑥 − ∫ 𝑛 ∙ ∇𝑢𝑣𝑑𝑠 = ∫ 𝑓𝑣𝑑𝑥
Ω 𝜕Ω Ω
𝑣 is zero on the boundary, thus we have the following variational formulation of
(1): find 𝑢 ∈ 𝑉𝑔𝐷 such that
𝐸𝑞. (2) ∫ ∇𝑢 ∙ ∇𝑣𝑑𝑥 = ∫ 𝑓𝑣𝑑𝑥 , ∀𝑣 ∈ 𝑉0
Ω Ω

II. Finite Element Approximation


Let Κ be a triangulation of Ω.
Let 𝑉ℎ,𝑔𝐷 be a space of continuous piecewise linear functions on Κ. Also,
𝑉ℎ,𝑔𝐷 = {𝑣 ∈ 𝑉ℎ : 𝑣|𝜕Ω = 𝑔𝐷 }
Replacing 𝑉0 with 𝑉ℎ,𝑔𝐷 in equation (2), we obtain the finite element method: find
𝑢ℎ ∈ 𝑉ℎ,𝑔𝐷 such that
𝐸𝑞. (3) ∫ ∇𝑢ℎ ∙ ∇𝑣𝑑𝑥 = ∫ 𝑓𝑣𝑑𝑥 , ∀𝑣 ∈ 𝑉ℎ,0
Ω Ω

III. Derivation of a Linear System of Equation


To derive an equation for 𝑢ℎ , we write it in the form
𝑢ℎ = 𝑢ℎ,0 + 𝑢ℎ,𝑔𝐷 , 𝑢ℎ,𝑜 ∈ 𝑉ℎ,0 & 𝑢ℎ,𝑔𝐷 ∈ 𝑉ℎ,𝑔𝐷
Because 𝑢ℎ,𝑔𝐷 is known it only remains to determine 𝑢ℎ,0 .

𝑛𝑖
Let {𝜙𝑖 }𝑖=1 be the basis for 𝑉ℎ,0 .
𝜙𝑖 are the hat functions associated with the 𝑛𝑖 interior nodes within the mesh.
𝑛𝑝 𝑛𝑖 𝑛𝑔

𝑢ℎ = ∑ 𝜉𝑗 𝜙𝑗 = ∑ 𝜉𝑖 𝜙𝑖 + ∑ 𝜉𝑔 𝜙𝑔 , 𝑤𝑖𝑡ℎ 𝑛𝑖 𝑢𝑛𝑘𝑛𝑜𝑤𝑛𝑠 𝜉𝑖
𝑗=1 𝑖=1 𝑔=1

Using equation (3)


𝑛𝑖

∫ ∇ (∑ 𝜉𝑖 𝜙𝑖 + 𝑢ℎ,𝑔𝐷 ) ∙ ∇𝑣𝑑𝑥 = ∫ 𝑓𝑣𝑑𝑥 , ∀𝑣 ∈ 𝑉ℎ,0


Ω 𝑖=1 Ω
𝑛𝑖

∫ ∇ (∑ 𝜉𝑖 𝜙𝑖 ) ∙ ∇𝑣𝑑𝑥 = ∫ 𝑓𝑣𝑑𝑥 − ∫ ∇(𝑢ℎ,𝑔𝐷 ) ∙ ∇𝑣𝑑𝑥 , ∀𝑣 ∈ 𝑉ℎ,0


Ω 𝑖=1 Ω Ω

Now, we can write 𝑛𝑝 equations using the finite element method equation (3).
∫ ∇𝑢ℎ ∇𝜙𝑖 𝑑𝑥 = ∫ 𝑓𝜙𝑖 𝑑𝑥 , 𝑖 = 1,2, … , 𝑛𝑝
Ω Ω

𝑛𝑝

∫ ∇ (∑ 𝜉𝑗 𝜙𝑗 ) ∇𝜙𝑖 𝑑𝑥 = ∫ 𝑓𝜙𝑖 𝑑𝑥 , 𝑖 = 1,2, … , 𝑛𝑝


Ω 𝑗=1 Ω

𝑛𝑝

∑ 𝜉𝑗 ∫ ∇𝜙𝑗 ∇𝜙𝑖 𝑑𝑥 = ∫ 𝑓𝜙𝑖 𝑑𝑥 , 𝑖 = 1,2, … , 𝑛𝑝


𝑗=1 Ω Ω

𝑛𝑝

∑ 𝐴𝑖𝑗 𝜉𝑗 = 𝑏𝑖 , 𝑖 = 1,2, … , 𝑛𝑝
𝑗=1
Where
𝐴𝑖𝑗 = ∫ ∇𝜙𝑗 ∇𝜙𝑖 𝑑𝑥 , 𝑏𝑖 = ∫ 𝑓𝜙𝑖 𝑑𝑥 , 𝑖, 𝑗 = 1, 2, … , 𝑛𝑝
Ω Ω

Then, we have a 𝑛𝑝 × 𝑛𝑝 linear system for the unknowns 𝜉𝑖 .

𝐴𝜉 = 𝑏
𝐴 𝐴0𝑔 𝜉𝑖 𝑏0
[ 00 ][ ] = [ ]
0 𝐼 𝜉𝑔 𝑏𝑔
Where 𝐴00 is the upper left 𝑛𝑖 × 𝑛𝑖 block of A, 𝐴0𝑔 in the 𝑛𝑖 × 𝑛𝑔 upper right
block of A, 𝐼 is the 𝑛𝑔 × 𝑛𝑔 identity matrix, 𝑏0 is the first 𝑛𝑖 × 1 block of 𝑏, 𝑏𝑔 is
the 𝑛𝑔 × 1 vector with nodal values of 𝑢ℎ,𝑔𝐷 , 𝜉𝑖 is the 𝑛𝑖 × 1 vector with nodal
values of 𝑢ℎ,0 , and 𝜉𝑔 is the 𝑛𝑔 × 1 vector with nodal values of 𝑢ℎ,𝑔𝐷 . Rearranging
the first 𝑛𝑖 equations we obtain the 𝑛𝑖 × 𝑛𝑖 linear system
𝐴00 𝜉0 = 𝑏0 − 𝐴0𝑔 𝜉𝑔

IV. Basic Finite Element Algorithm


1: Create a triangulation Κ on Ω and define the corresponding space of continuous
𝑛𝑖
piecewise linear function 𝑉ℎ,0 hat function basis {𝜙𝑖 }𝑖=1 .
2: Assemble the 𝑛𝑝 × 𝑛𝑝 stiffness matrix A and the 𝑛𝑝 × 1 load vector 𝑏, with
entries
𝐴𝑖𝑗 = ∫ ∇𝜙𝑗 ∙ ∇𝜙𝑖 𝑑𝑥 , 𝑏𝑖 = ∫ 𝑓𝜙𝑖 𝑑𝑥
Ω Ω
3: Create the matrix 𝐴00 and the modified load vector 𝑏0 − 𝐴0𝑔 𝜉𝑔

4: Solve the linear system


𝐴00 𝜉0 = 𝑏0 − 𝐴0𝑔 𝜉𝑔
5: Set
𝑛𝑖

𝑢ℎ = ∑ 𝜉𝑗 𝜙𝑗
𝑗=1

V. Point matrix P and Connectivity matrix T


𝑖,𝑗,𝑘 𝑖,𝑗,𝑘
Each triangle 𝐾 have 3 nodes 𝑁𝑖,𝑗,𝑘 = (𝑥1 , 𝑥2 ). To each note 𝑁𝑖 there is a hat
function 𝜙𝑖 .
𝜙𝑖 = 𝑎𝑖 + 𝑏𝑖 𝑥1 + 𝑐𝑖 𝑥2
Where,
𝑗 𝑗 𝑗 𝑗
𝑥1 𝑥2𝑘 − 𝑥1𝑘 𝑥2 𝑥2 − 𝑥2𝑘 𝑥1𝑘 − 𝑥1
𝑎𝑖 = , 𝑏𝑖 = , 𝑐𝑖 =
2|𝐾| 2|𝐾| 2|𝐾|

|𝐾| is the area of the triangle element. The gradient of 𝜙 is the constant vector:
𝑏
∇𝜙𝑖 = [ 𝑖 ]
𝑐𝑖
The information of the triangulation is storage in Point matrix P and a Connectivity
matrix T. The number of columns in P are equal to the number of nodes in Ω. The
first and second rows are the 𝑥1 and 𝑥2 coordinates of the node.
The number of columns in T are equal to the number of elements in Ω. The first
three rows are the indexes of the corner points, clockwise order.

VI. Assembly of the Stiffness Matrix and Load Vector.


The local element stiffness matrix 𝐴𝐾 , formed by the nodes 𝑖, 𝑗, 𝑘, is calculated as
follow:
𝐴𝐾
𝑖𝑗 = ∫ ∇𝜙𝑖 ∇𝜙𝑗 𝑑𝑥 = (𝑏𝑖 𝑏𝑗 + 𝑐𝑖 𝑐𝑗 )|𝐾|
𝐾

𝑏12 + 𝑐12 𝑏2 𝑏1 + 𝑐2 𝑐1 𝑏3 𝑏1 + 𝑐3 𝑐1
𝐴𝐾 = [𝑏2 𝑏1 + 𝑐2 𝑐1 𝑏22 + 𝑐22 𝑏2 𝑏3 + 𝑐2 𝑐3 ] |𝐾|
𝑏3 𝑏1 + 𝑐3 𝑐1 𝑏2 𝑏3 + 𝑐2 𝑐3 𝑏32 + 𝑐32

Finally, 𝐴𝐾 is added to the appropriate places in 𝐴 using the information in the


connectivity matrix T.

The local element load vector 𝑏 𝐾 , formed by the nodes 𝑖, 𝑗, 𝑘, is calculated as


follow:
𝑓𝑖
𝑏𝑖𝐾 = ∫ 𝑓𝜙𝑖 𝑑𝑥 = |𝐾|
K 3
𝑓
𝐾
1 1
𝑏 = [𝑓2 ] |𝐾|
3
𝑓3
𝐾
Finally, 𝑏 is added to the appropriate places in 𝑏 using the information in the
connectivity matrix T.

VII. A Posteriori Error Estimation


The finite element solution 𝑢ℎ satisfies the estimated

‖𝑢 − 𝑢ℎ ‖2 𝐻 1 (Ω) ≤ 𝐶 ∑ 𝜂𝐾2
𝐾
Where the residual 𝜂𝐾 is defined by

1 1/2
𝜂𝐾 = ℎ𝐾 ‖𝑓 + Δ𝑢ℎ ‖𝐿2 (K) + ℎ𝐾 ‖[𝑛 ∙ ∇𝑢ℎ ]‖𝐿2 (𝜕𝐾/𝜕Ω)
2
Here, [𝑛 ∙ ∇𝑢ℎ ] denotes the jump in the normal derivative of 𝑢ℎ on the interior
edges of the element K. Also, since 𝑢ℎ is linear on K, Δ𝑢ℎ = 0.

Using a L2-norm, the discrete error is estimated as follow:


‖𝑢 − 𝑢ℎ ‖2 𝐿2(Ω) = ∑ ℎ𝐾2 (𝑒𝑖2 + 𝑒𝑗2 + 𝑒𝑘2 )
𝐾
Where 𝑖, 𝑗, 𝑘 are the vertices of triangle K.
Now, the results of the implementation of FEM in Matlab is presented:

The bounded two-dimensional domain [-1,1]2 is


shown in Figure 1. In this case, the mesh size
ℎ𝐾 = 0.25. This mesh was generated with the
function initmesh.

The triangle mesh information is storage in 3


matrices. P, called the point matrix, is of size 2 ×
𝑛𝑝 and each column contains the coordinates 𝑥1
and 𝑥2 of each node. T, called the connectivity
matrix, is of size 3 × 𝑛𝑡 and each column
contains the numbers of the three nodes in each
triangle. E, called the edge matrix, contain the Figure 1 Triangulation
nodes at the boundary of the domain.

In order to evaluate the performance of the


Finite Element Method, we will compare the
numerical solution with the analytical solution.
Figure 2 presents the L2-projection of function
𝑢 = sin 𝑥 + sin 𝑦 using the mesh descripted
previously. Figure 3 is the result obtained of FEM
using the mesh size ℎ𝐾 = 0.25. We could state
that the numerical solution is a good
approximation of the Poisson problem
Figure 2 Exact Solution, L2 projection.
presented in equation 1.

The error estimation based on 𝐿2 and 𝐻1 norms


were used to assess the FEM. FEM was
implemented using different mesh size (dx = [1,
0.5, 0.25, 0.125, 0.0625, 0.03125]) in order to
estimate the convergence order.

The theoretical order of convergence of the


error, estimated based in L2-norm, is 2. If we use
the H1-norm, the convergence order is 1. Figure
4 presents the plot of log10 of error vs log10 of
mesh size. The slope of the straight line represent
the convergence order. Figure 3 Numerical Solution FEM

The matlab files present the details about FEM implementation.


Figure 4 Error estimation. L2 norm (left) and H1 norm (right).

References
Larson, Mats G., and Fredrik Bengzon. The Finite Element Method: Theory, Implementation, and
Applications. Berlin: Springer-Verlag, 2013.
MathWorks. n.d. https://www.mathworks.com.

Potrebbero piacerti anche