• 沒有找到結果。

The Elliptic Equation

在文檔中 Partial Differential Equation Toolbox (頁 155-162)

4

The Finite Element Method

4-4

3 Discretize the PDE and the boundary conditions to obtain a linear system Ku = F. The unknown vector u contains the values of the approximate solution at the mesh points, the matrix K is assembled from the coefficients c, a, h, and q and the right-hand side F contains, essentially, averages of f around each mesh point and contributions from g. Once the matrices K and F are assembled, you have the entire MATLAB environment at your disposal to solve the linear system and further process the solution.

More elaborate applications make use of the FEM-specific information returned by the different functions of the toolbox. Therefore we quickly summarize the theory and technique of FEM solvers to enable advanced applications to make full use of the computed quantities.

FEM can be summarized in the following sentence: Project the weak form of the differential equation onto a finite-dimensional function space. The rest of this section deals with explaining the above statement.

We start with the weak form of the differential equation. Without restricting the generality, we assume generalized Neumann conditions on the whole boundary, since Dirichlet conditions can be approximated by generalized Neumann conditions. In the simple case of a unit matrix h, setting g = qr and then letting yields the Dirichlet condition because division with a very large q cancels the normal derivative terms. The actual implementation is different, since the above procedure may create conditioning problems. The mixed boundary condition of the system case requires a more complicated treatment, detailed in the section “The Elliptic System.”

Assume that u is a solution of the differential equation. Multiply the equation with an arbitrary test function v and integrate on Ω:

Integrate by parts (i.e., use Green’s formula) to obtain:

The boundary integral can be replaced by the boundary condition:

q→∞

∇ (

– ⋅(c u∇ ) )v+auv dx fv dx

=

c u

( )

v+auv dx

∂Ω(qu+g)vds =

fv dx

The Elliptic Equation

4-5 Replace the original problem with: Find u such that

This equation is called the variational, or weak, form of the differential equation. Obviously, any solution of the differential equation is also a solution of the variational problem. The reverse is true under some restrictions on the domain and on the coefficient functions. The solution of the variational problem is also called the weak solution of the differential equation.

The solution u and the test functions v belong to some function space V. The next step is to choose an Np-dimensional subspace . Project the weak form of the differential equation onto a finite-dimensional function space simply means requesting u and v to lie in rather than V. The solution of the finite dimensional problem turns out to be the element of that lies closest to the weak solution when measured in the energy norm (see below). Convergence is guaranteed if the space tends to V as . Since the differential operator is linear, we demand that the variational equation is satisfied for Np test-functions φi that form a basis, i.e.,

Expand u in the same basis of

and obtain the system of equations c u

( )

v+auvfv dx

∂Ω(qu+g)vds = 0, v

VN

pV VN

p

VN

p

VN

p NP→∞

VN

p

c u

( )

φi+auφiidx

∂Ω(qu+gids = 0, i = 1, , Np

VN

p

u x( ) Ujφj( )x

j=1 Np

=

c∇φj

( )

φi+aφjφidx+

∂Ωqφjφids

 

 

j=1 Np

Uj

fφidx

= gφids,

∂Ω i

+ = 1, ,… Np

4

The Finite Element Method

4-6

Use the following notations:

(Stiffness matrix) (Mass matrix)

and rewrite the system in the form (K + M + Q)U = F + G.

K, M, and Q are Np-by-Np matrices, and F and G are Np-vectors. K, M, and F are produced by assema, while Q, G are produced by assemb. When it is not necessary to distinguish K, M, and Q or F and G, we collapse the notations to KU = F, which form the output of assempde.

When the problem is self-adjoint and elliptic in the usual mathematical sense, the matrix K + M + Q becomes symmetric and positive definite. Many common problems have these characteristics, most notably those that can also be formulated as minimization problems. For the case of a scalar equation, K, M, and Q are obviously symmetric. If c(x) ≥ δ > 0, a(x) ≥ 0 and q(x) ≥ 0 with q(x) >

0 on some part of , then, if U

0.

UT(K + M + Q)U is the energy norm. There are many choices of the test-function spaces. The toolbox uses continuous functions that are linear on each triangle of the mesh. Piecewise linearity guarantees that the integrals defining the stiffness matrix K exist. Projection onto is nothing more than linear interpolation, and the evaluation of the solution inside a triangle is done just in terms of the nodal values. If the mesh is uniformly refined,

approximates the set of smooth functions on Ω.

A suitable basis for is the set of “tent” or “hat” functions φi. These are linear on each triangle and take the value 0 at all nodes xj except for xi. Requesting φi(xi) = 1 yields the very pleasant property

Ki j, (c∇φj)

φidx

=

Mi j, jφidx

=

Qi j, qφjφids

∂Ω

=

Fi idx

=

Gi gφids

∂Ω

=

UT(K+M+Q)U c∇u2

+au2 dx+

∂Ωqu2ds>0, if U0.

=

VN

p

VN

p

VN

p

The Elliptic Equation

4-7 i.e., by solving the FEM system we obtain the nodal values of the approximate solution. Finally note that the basis function φi vanishes on all the triangles that do not contain the node xi. The immediate consequence is that the integrals appearing in Ki,j, Mi,j, Qi,j, Fi and Gi only need to be computed on the triangles that contain the node xi. Secondly, it means that Ki,j and Mi,j are zero unless xi and xj are vertices of the same triangle and thus K and M are very sparse matrices. Their sparse structure depends on the ordering of the indices of the mesh points.

The integrals in the FEM matrices are computed by adding the contributions from each triangle to the corresponding entries (i.e., only if the corresponding mesh point is a vertex of the triangle). This process is commonly called assembling, hence the name of the function assempde.

The assembling routines scan the triangles of the mesh. For each triangle they compute the so-called local matrices1 and add their components to the correct positions in the sparse matrices or vectors. The integrals are computed using the mid-point rule. This approximation is optimal since it has the same order of accuracy as the piecewise linear interpolation.

Consider a triangle given by the nodes P1, P2, and P3 as in the following figure.

1. The local 3-by-3 matrices contain the integrals evaluated only on the current triangle.

The coefficients are assumed constant on the triangle and they are evaluated only in the triangle barycenter.

u x( )i Ujφj( )xi

j=1 Np

Ui,

= =

The local triangle P1P2P3

P

P

P 1

2

3

Pc Pb

x

y1

1

4

The Finite Element Method

4-8

The simplest computations are for the local mass matrix m:

where Pc is the center of mass of ∆ P1P2P3, i.e.,

The contribution to the right-hand side F is just

For the local stiffness matrix we have to evaluate the gradients of the basis functions that do not vanish on P1P2P3. Since the basis functions are linear on the triangle P1P2P3, the gradients are constants. Denote the basis functions φ1, φ2, and φ3 such that φi(Pi) = 1. If P2 – P3 = [x1,y1]T then we have that

and after integration (taking c as a constant matrix on the triangle)

If two vertices of the triangle lie on the boundary , they contribute to the line integrals associated to the boundary conditions. If the two boundary points are P1 and P2, then we have

and

where Pb is the mid-point of P1P2. mi j, a P( )φc i( )φx j( )x dx

P1P2P3

a P( )c area--- 1(∆P121P2P3)( +δi j, ),

= =

Pc P1+P2+P3 ---3

=

fi f P( )c area(∆P1P2P3) ---3

=

φ1

∇ 1

2area(∆P1P2P3) --- y1

x1

=

ki j, 1

4area(∆P1P2P3)

--- y[ j,–xj]c P( )c y1x1

=

Qi j, q P( )b P1P2

--- 16 ( +δi j, ), i j, 1 2,

= =

Gi g P( )b P1P2

---2 , i 1 2,

= =

The Elliptic Equation

4-9 For each triangle the vertices Pm of the local triangle correspond to the indices im of the mesh points. The contributions of the individual triangle are added to the matrices such that, e.g.,

This is done by the function assempde. The gradients and the areas of the triangles are computed by the function pdetrg.

The Dirichlet boundary conditions are treated in a slightly different manner.

They are eliminated from the linear system by a procedure that yields a symmetric, reduced system. The function assempde can return matrices K, F, B, and ud such that the solution is u = Bv + ud where Kv = F. u is an Np-vector, and if the rank of the Dirichlet conditions is rD, then v has Np – rD components.

Ki

m,int Ki

m,in

← +km n, , m n, = 1 2 3, ,

4

The Finite Element Method

4-10

在文檔中 Partial Differential Equation Toolbox (頁 155-162)

相關文件