ch 3. boundary value problems
TRANSCRIPT
Ch 3. Boundary Value Problems
Yoon Mo Jung
Computational Science and Engineering
Yonsei University
Ch 3. Boundary Value Problems 2
§3.1 Differential Equations and Finite Elements
We want to solve
−d
dx
(c(x)
du
dx
)= f(x) : 2nd order DE.
If A =d
dx, then AT = −
d
dx, so ATCAu = f.
A = − (backward difference) AT = −+(−forward difference)
− =
1
−1 1
−1 1
−1 1
+ =
−1 1
−1 1
−1 1
−1
Un+1 − Un Un − Un−1
Consider
Boundary Value Problem −d
dx
(c(x)
du
dx
)= f(x)
Fixed : u(0) = 0
Free : w(1) = 0
where w(x) = c(x)dudx.
−∫ 1
0
d
dx
(c(x)
du
dx
)v(x)dx =
∫ 1
0
f(x)v(x)dx,
for every admissible v.
Applying integration by parts,
−∫ 1
0
d
dx
(c(x)
du
dx
)vdx =
∫ 1
0
c(x)du
dx
dv
dxdx − c(x)
du
dxv∣∣∣10,
c(x)du
dx(x)v(x)
∣∣∣10= c(1)
du
dx(1)︸ ︷︷ ︸
w(1)=0
v(1) − c(0)du
dx(0) v(0)︸︷︷︸
impose 0
= 0.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 3
Figure 1: Hanging bar.
Weak form :
∫ 1
0
c(x)du
dx
dv
dxdx =
∫ 1
0
f(x)v(x)dx for every admissible v.
: Finite Element Method or Galerkin Method
• The Framework ATCA for a Hanging Bar
The bar stretches like a line of a spring. i.e. One may treat it as a continuum
limit of line of springs. See Figure 1. The point that begins at distance x
along the unstretched bar moves down to x + u(x). We want to find the
displacement u(x).
The internal force at x = 1 must be zero because no external force will
balance it. Thus w(1) = 0.
Note that the bottom end actually move down to x = 1 + u(1). Nev-
ertheless the boundary condition is written at x = 1. The reason is that
displacements u(x) are assumed small.
e(x): the elongation per unit length, called strain.
Step 1 Stretching e(x) = Au(x) = dudx
with u(0) = 0.
cf) ei = ui−ui−1 in the mass-spring system. The difference becomes
derivative.
Step 2 Hooke’s Law w(x) = c(x)e(x) = c(x)dudx.
At a point where the material of the bar suddenly changes, c(x) will
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 4
have a jump. The product w(x) = c(x)u′(x) will not jump. The
force balance at the point demands thatw(x) must be continuous. The
jump in c(x) must compensated by a jump in e(x) = dudx.
Step 3 Force balance ATw = −dwdx
= f(x) with w(1) = 0.
See the small piece of bar with thickness x in Figure 1. The internal
forces are w(x) upward and w(x + x) downwards. In equilibrium,
w(x) = w(x+x)+fx ⇒ −w(x + x) − w(x)
x= f(x).
Note that AT = − ddx
is the “transpose” of A = ddx.
displacement u(x)
u(0) = 0→ strain-displacement
e(x) = Au(x) = dudx
→ strain
elongatione(x)
→stress-strain law
(Hooke’s law)
w(x) = c(x)e(x) = c(x)dudx
→ internal stress w(x)
w(1) = 0
→ force balance
f(x) = ATw(x) = −dwdx
→ external force
per unit lengthf(x)
Again we have:
Ku := ATCAu = f .
• General Solution and Examples
Since −(cu′)′ = f and cu′ = w,
c(x)du
dx(x) − c(0)
du
dx(0) = w(x) − w(0) = −
∫ x
0
f(x)dx.
Since w(1) = 0, −w(0) = w(1) − w(0) = −∫ 1
0 f(x)dx.
Internal force (stress) w(x) =
∫ 1
0
f(x)dx −∫ x
0
f(x)dx =
∫ 1
x
f(x)dx.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 5
It means that the internal force W at the point x balances the total applied
force f below that point.
From cu′ = w and integrating,
Displacementdu
dx=
w(x)
c(x)and
∫ x
0
w(x)
c(x)dx = u(x)
by noticing u(0) = 0.
Example 1 A uniform bar is hanging under its own weight. The force per
unit length is f0 = ρg.
Sol) w(x) =∫ 1
x f0dx = (1 − x)f0
and
u(x) =∫ x
0(1−x)f0
c(x)dx =
(x − 1
2x2)
f0c.
Example 2 A bar is hanging under its own weight. In this case, c(x) = 1
if 0 ≤ x ≤ 1/2 and 2 if 1/2 < x ≤ 1. The force per unit length is
f0 = ρg.
Sol) w(x) =∫ 1
x f0dx = (1 − x)f0, which is continuous.
e(x) = dudx
= w(x)c(x)
= (1−x)f0c(x)
, which is discontinuous at x = 1/2.
u(x) =∫ x
0(1−x)f0
c(x)dx =
(x − 1
2x2)f0 if 0 ≤ x ≤ 1/2,
38f0 +
∫ x
1/2(1−x)f0
2dx if 1/2 ≤ x ≤ 1.
=(x − 1
2x2)
f02+ 3
16f0
• The Transpose of A = ddx
Why is the transpose of A = ddx
given by AT = A∗ = − ddx?
What are correct boundary conditions on A and AT ?
The underlying physics is the connection of energy eTw to work (force
·displacement) uTf . The mathematical reason is this requirement for inner
products:
AT is defined by (Au︸︷︷︸e
)Tw = uT (ATw︸ ︷︷ ︸f
) for every u and w.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 6
Inner product of functions (e, w) =
∫ 1
0
e(x)w(x)dx
Notice that∫ 1
0 e(x)w(x)dx = limn→∞∑n
i=1 e(xi)w(xi)x.
Letting A = ddx, formally,
(Au,w) =
∫ 1
0
du
dxw(x)dx =
∫ 1
0
u(x)
(d
dx
)T
w(x)dx = (u,ATw)
for every u and w.
By taking integration by parts,∫ 1
0
du
dxw(x)dx =
∫ 1
0
u(x)
(−dw
dx
)dx +
[u(x)w(x)
]x=1
x=0.
For − ddx
to be AT ,[u(x)w(x)
]x=1
x=0= 0 is needed.
Boundary condition
• If A has boundary condition u(0) = 0, AT must have w(1) = 0.
• If A has boundary condition u(0) = u(1) = 0, AT has no condition.
• If A has no condition, AT has two conditions w(0) = 0 and w(1) =
0.
cf) ATCAu = f ⇒ (ATCAu)Tv = fTv for all v
(CAu)TAv = fTv for all v
or ⟨CAu,Av⟩ = ⟨f, v⟩ for all v
• Galerkin’s Method (Finite Element Method, FEM)
Consider the fixed-free case:
Boundary Value Problem −d
dx
(c(x)
du
dx
)= f(x)
Fixed : u(0) = 0
Free : w(1) = 0
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 7
where w(x) = c(x)dudx.
−∫ 1
0
d
dx
(c(x)
du
dx
)v(x)dx =
∫ 1
0
f(x)v(x)dx,
for every admissible v.
Applying integration by parts,
−∫ 1
0
d
dx
(c(x)
du
dx
)vdx =
∫ 1
0
c(x)du
dx
dv
dxdx − c(x)
du
dxv∣∣∣10,
c(x)du
dx(x)v(x)
∣∣∣10= c(1)
du
dx(1)︸ ︷︷ ︸
w(1)=0
v(1) − c(0)du
dx(0) v(0)︸︷︷︸
=0 :required
= 0.
Weak form :
∫ 1
0
c(x)du
dx
dv
dxdx =
∫ 1
0
f(x)v(x)dx for every admissible v.
Admissibility condition: v(0) = 0.
Finite Element Method is based on the weak form with test functions v(x).
Galerkin Method: Choose n trial functions ϕ1(x), ϕ2(x), · · ·ϕn(x).
U(x) = U1ϕ1(x) + U2ϕ2(x) + · · · + Unϕn(x)
Choose n admissible test functions V1(x), V2(x), · · ·Vn(x).∫ 1
0
c(x)
n∑j=1
Uj
dϕj
dx
dVi
dxdx =
∫ 1
0
f(x)Vi(x)dx
for i = 1, · · ·n: n equations.
KU = F Kij =
∫ 1
0
c(x)dVi
dx
dϕj
dxdx and Fi =
∫ 1
0
f(x)Vi(x)dx
(1)
Construction of the Finite Element Method
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 8
Figure 2: blue lines: hat functions ϕi and a combination (piecewise linear): red line.
1. Choose the ϕi and Vi: one unknowns for each ϕ, one equation for each
V .
2. Compute exact or approximate integrals (1). If all ϕi = Vi, then
Kij = Kji.
3. The weak form becomes KU = F . The FEM approximation is∑nj=1 Uiϕi(x).
• Linear Finite Elements
There are three hat functions ϕ1(x), ϕ2(x), ϕ3(x) in Figure 2 and they
are also the test function V1, V2, V3. The functions are local-they are zero
outside intervals of length 2h, 2h, h. There is no overlap between ϕ1 and
the half-hat ϕ3, which makes the integral zero: K13 = K31 = 0. The
stiffness matrix K is tridiagonal.
Example 3 Consider the fixed-free case:
−u′′ = 1, u(0) = 0, w(1) = 0
The true solution is u(x) = x − 12x2.
Since Fi =∫ 1
0 f(x)Vi(x)dx,
F1 =
∫ 1
0
V1(x)dx︸ ︷︷ ︸area
= 2 · 12· 13· 1 = 1
3, F2 = 1
3, F3 = 1
213.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 9
Since Kij =∫ 1
0 c(x)dVidx
dϕj
dxdx,
K11 =∫ 1
0
(dV1dx
)2dx = 32 · 1
3+ (−3)2 · 1
3= 6,
K22 = 6, K33 = 32 · 13= 3.
K12 =∫ 1
0 c(x)dV1dx
dϕ2dx
dx = −3 · 3 · 13= −3,
K23 = −3, K13 = 0 (No overlap).
Finally we have KU = F : 6 −3 0
−3 6 −3
0 −3 3
U1
U2
U3
=
1/3
1/3
1/6
gives
U1
U2
U3
=
5/18
4/9
1/2
.
All three values U1, U2, U3 are agree exactly with u(x) = x− 12x2 since
it is a second order scheme: O(h2).
• Comparison with Finite Differences
KU = F in Example 3 is like 1h(−2U) = hf .
cf) Finite difference method: from 1h2(−2U) = f ,
32
2 −1 0
−1 2 −1
0 −1 1
U1
U2
U3
=
1
1
1
.
Notice that it is the first order accurate: O(h).
Example 4 Consider the following DE:
−d
dx
(c(x)
du
dx
)= f(x), f(x) = δ(x − 1/2),
c(x) =
2, 0 ≤ x ≤ 1
3
4, 13≤ x ≤ 1
, u(0) = 0, and w(1) = 0.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 10
First we find the exact solution:
ATCAu = f ⇒
ATw = f,
CAu = w.
ATw = f : −dw
dx= δ(x − 1/2), with w(1) = 0.
⇒ w(x) =
1, x < 1/2,
0, x > 1/2.
CAu = w : c(x)du
dx= w(x) with u(0) = 0.
⇒ u(x) =
∫ x
0
w(x)
c(x)dx =
∫ x
012dx = 1
2x, 0 ≤ x ≤ 1
3,
16+∫ x
1/314dx = 1
4x + 1
12, 1
3≤ x ≤ 1
2,
112
+ 18+∫ x
1/2 0dx = 524, 1
2≤ x ≤ 1.
Now we use finite elements:
F1 =∫ 1
0 δ(x − 12)V1(x)dx = V1(
12) = 1
2,
F2 =∫ 1
0 δ(x − 12)V2(x)dx = 1
2, and F3 = 0.
K11 =∫ 1
0 c(x)(V ′1 )
2dx = 13· 2 · 32 + 1
3· 4 · 32 = 18,
K12 =∫ 1
0 c(x)V ′1V
′2dx = 1
3· 4 · (−3) · 3 = −12, and K13 = 0.
K22 = 24, K23 = −12, K33 = 12.
KU = F :
18 −12 0
−12 24 −12
0 −12 12
U1
U2
U3
=
1/2
1/2
−0
.
Example 5 Allow any c(x) and f(x), using numerical integration.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 11
If we apply the midpoint rule∫ b
a f(x)dx = (b − a)f(a+b2),
F1 =
∫ 1/3
0
f(x)V1(x)dx +
∫ 2/3
1/3
f(x)V1(x)dx
≈1
3· f(1/6) ·
1
2+
1
3· f(3/6) ·
1
2.
Similarly,
K11 =
∫ 1/3
0
c(x)(V ′1 )
2dx +
∫ 2/3
1/3
c(x)(V ′1 )
2dx
≈1
3· c(1/6) · 32 +
1
3· c(3/6) · (−3)2.
Finite differences become painful when the mesh spacing changes since sec-
ond differences need a new formula.
Finite elements have geometric flexibility in 2 and 3 dims.
• More accurate Finite Elements
To increase accuracy, one may
1. refine mesh.
2. increase the degree of finite elements.
ex) quadratic elements: O(h3).
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 12
§3.2 Cubic Splines and Forth-Order Equations
Goal - want to solve the following forth order equation:d4udx4 = f(x): bending cf) d2u
dx2 = f(x): stretching
U(x) = A + Bx + Cx2 + Dx3 U(x) = A + Bx
piecewise cubic piecewise linear
:cubic finite elements :linear finite elements
U and U ′ are continuous. U is continuous.
U ′′ and U ′′′ can jump. U ′ can jump.
cf) cubic splines - approximation theory
U , U ′ and U ′′ are continuous. U ′′′ can jump.
U ′′: curvature, bending (concave, convex).
• Forth-Order Equations: Beam Bending
A beam is a horizontal structural element that is capable of withstanding load
primarily by resisting bending. The bending produces internal forces that try
to straight it. The bending force induced into the material of the beam as a
result of the external loads, own weight, span and external reactions to these
loads is called a bending moment.
The displacement u and load f , previously in the direction of the rod, are
now perpendicular to the beam. See Figure 3 (a).
(a) Simply supported beam (b) Cantilever Beam
Figure 3: Beam examples
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 13
beam cf) elastic rod
Restoring force: curvature stretching
Au = d2udx2 Au = du
dxIf it is zero, the displacement u is linear and the beam is straight.
Bending moment: M = CAu = cu′′, c: bending stiffness.
Force balance: M ′′ = f(x), equation of equilibrium (between the restoring
force and the applied force).
ATCA for a beam:
displacement u
curvature e = Au = u′′
bending moment M = ce
force balance f = ATM = M ′′
ATCAu = f ord2
dx2
(cd2u
dx2
)= f
(d2
dx2
)T= d2
dx2 : symmetric.
cf)(
ddx
)T= − d
dx: skewsymmetric or asymmetric.
(Au,M) = (u,ATM) =︸︷︷︸want to have
(u,AM).
∫ 1
0
u′′Mdx = −∫ 1
0
u′M ′dx + u′M |10
=
∫ 1
0
uM ′′dx + [u′M − uM ′]10︸ ︷︷ ︸impose 0
.
[u′M−uM ′]10 = u′(1)M(1)−u(1)M ′(1)−u′(0)M(0)+u(0)M ′(0).
1. simply supported end: u = 0, M = 0. See Figure 3(a).
2. clamped (fixed) end: u = 0, u′ = 0. See the left end in Figure 4.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 14
Figure 4: Bending a cantilever beam by perpendicular force: (cu′′)′′ = f(x).
3. free end: M = 0, M ′ = 0. See the right end in Figure 4.
4. sliding clamped end: u′ = 0, M ′ = 0. (rare)
Bendingd2
dx2
(cd2u
dx2
)= f or M = c
d2u
dx2and
d2M
dx2= f
M = cd2udx2 = Au requires two conditions on u.
d2Mdx2 = AM = ATM = f requires two conditions on M .
d2
dx2
(cd2u
dx2
)= f ⇒
∫ 1
0
d2
dx2
(cd2u
dx2
)v(x)dx =
∫ 1
0
f(x)v(x)dx
By integration by parts twice,
Weak form:
∫ 1
0
cd2u
dx2
d2v
dx2dx =
∫ 1
0
f(x)v(x)dx
Finite elements methods: U(x) =∑
Uiϕ(x) (trial functions)
Vi(x)(= ϕi(x)) (test functions)will give us discrete system KU = F .
• Cubic Finite Elements
The four coefficients of A + Bx + Cx2 + Dx3 are determined by the
endpoint displacement Udi , U
di+1 and the endpoint slope U s
i , Usi+1. Since
the neighboring intervals end with the same height and slope, the overall
piecewise cubic will have continuous height and slope.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 15
Figure 5: Displacement trial function ϕdi and slope function ϕs
i .
Displacement trial function Slope trial function
ϕd(X) = (|X| − 1)2(2|X| + 1) ϕs(X) = |X(|X| − 1)2
ϕd(0) = 1 dϕs
dX(0) = 1
ϕd(−1) = ϕdi (1) = 0 dϕs
dX(−1) = dϕs
dX(1) = 0
dϕd
dX(−1) = dϕd
dX(0) = dϕd
dX(1) = 0 ϕs(−1) = ϕs(0) = ϕs(1) = 0
See Figure 5.
The finite element approximation U(x) is a combination of these 2N trial
functions (called Hermite cubics):
U(x) = Ud1ϕ
d1(x) + U s
1ϕs1(x) + · · · + Ud
Nϕd1(x) + U s
Nϕs1(x)
We need 2N test functions. Normally these V ’s will be the same as the
ϕ’s to preserve symmetry of the matrix K.
X = x−ihh
: This connect the global coordinate x to the local coordinate
X.
We compute integrals on that standard interval of length 1, and rescale to
the actual x-interval of length h. The local-global mapping is a basic steps
in finite element code.
ϕdi (x) = ϕd
(x − ih
h
), ϕs
i(x) = ϕs
(x − ih
h
).
1. Hat functions could not be used in bending problems, because then
we are multiplying delta functions in U ′′ and V ′′. The integral of δ2
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 16
Figure 6: Assembled stiffness matrix
is infinite (∫∞−∞ δ(x)dx = 1 but
∫∞−∞ δ2(x)dx = ∞). Another
reason is that integration by parts twice doesn’t work for hat functions.
2. The error u(x)−U(x) is of order h4, because the trial space include
cubics. U(x) could match the Taylor series of u(x) in each interval,
until the x4 term produces an h4 error. The actual U(x) from finite
elements does not match the Taylor series, because it is based on in-
tegrals (the weak form). U(x) gives the smallest possible error in the
energy∫ 1
0 c(x)(d2u
dx2 − d2Udx2 )
2dx.
3. In practice, the integrals are computed separately over each interval
[ih, (i+ 1)h]. On that interval only four trial functions are non zero:
ϕdi , ϕ
si , ϕ
di+1, ϕ
si+1. Similarly only four test functions are nonzero. This
produces 16 integrals in∫cU ′′V ′′, which go into the 4 × 4 element
stiffness matrix.
How those element matrices assemble into the global stiffness matrixK,
see Figure 6. Since ϕdi and ϕs
i also contribute to the previous element
matrix Ki−1, there will be a 2 by 2 overlap in K and 6 nonzero per
low.
• Finite Differences for (cu′′)′′ = f(x)
(2u)i = ui+1 − 2ui + ui−1.
(4u)i = (22u)i = ui+2 − 4ui+1 + 6ui − 4ui−1 + ui−2.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 17
§3.3 Gradient and Divergence
So far we considered 1-d problems:
In ATCA system, A = ddx, then AT = − d
dxby integration by parts.
In 2-d or 3-d, A = ∇ = grad, then AT = −∇· = −div by Gauss-Green
formula.
∇u(x, y) = grad u =
[∂u∂x∂u∂y
], ∇ = grad =
[∂∂x∂∂y
].
∇·[w1
w2
]= div
[w1
w2
]=
∂w1
∂x+
∂w2
∂y, ∇· = div =
[∂
∂x,
∂
∂y
].
potential
u(x)
A=grad−−−−−−−−−−−−→boundary cond u=u0(x,y)
velocity
v(x, y) = (v1, v2)
C−−−→w=cv
flow rate
w(x, y) = (w1, w2)
AT=−div−−−−−−−−−−−→bd cond w·n=F0(x,y)
source
f(x, y) = −div w
Ku := ATCAu = f
Poisson equation: −div (c grad )u = −∇ · (c∇u) = f
Laplace equation: −div grad u = ∇ · ∇u = ∇2u = 0
• Gradient
Definition 6 Gradient
f : R2,R3 or Rn → R
∇f(x, y) = grad f =
[∂f∂x∂f∂y
]=
[∂∂x∂∂y
]f
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 18
The gradient of a scalar field is a vector field that points in the direction of
the greatest rate of increase of the scalar field, and whose magnitude is the
greatest rate of change.
|grad f |: maximum slope (steepest slope).grad f|grad f |: direction of maximum increase.
Definition 7 Directional derivative
Dbf(x)def= lim
h→0
f(x + hb) − f(x)
h
chain rule= ∇f · b with |b| = 1.
The directional derivative of a multivariate differentiable function along a
given vector b at a given point x intuitively represents the instantaneous
rate of change of the function, moving through x in the direction of b.
• Divergence
Definition 8 Divergence
v : R2 → R2, or R3 → R3
(x, y) 7→ (v1(x, y), v2(x, y))
∇ · v : R2 or R3 → R
∇ · v = div v =∂v1
∂x+
∂v2
∂y=
[∂
∂x,∂
∂y
]· [v1, v2]
Divergence is a vector operator that measures the magnitude of a vector
field’s source or sink at a given point, in terms of a signed scalar. More
technically, the divergence represents the volume density of the outward flux
of a vector field from an infinitesimal volume around a given point.
Physicist defines as follows:
∇ · v = limV →0
∮S v · ndAV
(= lim
volume→0
net outward flux
volume
)Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 19
Theorem 9 Divergence Theorem of Gauss:∫V
∇ · vdV =
∫∂V
v · ndA.
In words, the net divergence in the body is the net flux through the boundary
surface.
Theorem 10 Green’s Formula:
First identity :∫V (f∇
2g + ∇f · ∇g)dV =∫∂V f ∂g
∂ndA
Second identity :∫V (f∇
2g − g∇2f)dV =∫∂V
(f ∂g
∂n− g∂f
∂n
)dA
cf) Integration by part:∫ b
a fg′dx = fg∣∣ba−∫ b
a f ′gdx.
Now,∫ b
a fg′′dx = fg′∣∣ba−∫ b
a f ′g′dx.
• Curl
Definition 11 curl
v : R3 → R3
(x, y, z) 7→ (v1(x, y, z), v2(x, y, z), v3(x, y, z))
∇× : R2 or R3 → R2 or R3
curl v =∇ × v
=
(∂v3
∂y−
∂v2
∂z
)i −
(∂v3
∂x−
∂v1
∂z
)j +
(∂v2
∂x−
∂v1
∂y
)k
=
∣∣∣∣∣∣∣i j k∂∂x
∂∂y
∂∂z
v1 v2 v3
∣∣∣∣∣∣∣Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 20
Curl is a vector operator that describes the infinitesimal rotation of a vector
field. At every point in the field, the curl is represented by a vector. The
attributes of this vector (length and direction) characterize the rotation at
that point. The direction of the curl is the axis of rotation, as determined
by the right-hand rule, and the magnitude of the curl is the magnitude of
rotation. If the vector field represents the flow velocity of a moving fluid,
then the curl is the circulation density of the fluid. A vector field whose curl
is zero is called irrotational.
Physicist defines as follows:
∇×v = maxa
a limA→0
∮C F · r′(s)ds
A
(= lim
area→0
circulation along curve
enclosed area
)Theorem 12 Stokes’ Theorem:∫
S
∇ × F · ndA =
∮C
F · r′(s)ds.
In words, the net circulation through normal direction is the circulation along
the boundary.
Theorem 13 Green’s Theorem:∫∫R
∂F2
∂x−
∂F1
∂ydxdy =
∮C
F1dx + F2dy.
It is just the 2-dim version of Stokes’ Theorem.
We may derive 2d divergence theorem using Green’s theorem:∫∫R
∂v2
∂x−
∂v1
∂ydxdy =
∫B
v1dx + v2dy.
Let v2 = w1 and v1 = −w2.∫∫R
∂w1
∂x+
∂w2
∂ydxdy =
∫B
−w2dx+w1dy =
∮B
w1dy+w2dx.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 21
Figure 7: The integral of w · nds = (w1, w2) · (dy,−dx) = w1dy − w2dx is the flux. In casew2 = 0, this
∮w1dy equals
∫∫∂w1/∂xdxdy.
Figure 7 shows the flux w · n︸ ︷︷ ︸“flow rate out”
ds = w1dy−w2dx through a bound-
ary segment of length ds, which we integrate around the boundary B.
If we consider the horizontal flow (w1, 0), the divergence theorem becomes∫∫R
∂w1
∂xdxdy =
∫B
w1dy.
cf) Fundamental Theorem of Calculus:∫ b
adwdx
dx = w(b) − w(a).
It is the divergence theorem in 1D.
Remark Two important identities
1. curl (grad u) = 0: The gradient field is irrotational.
2. div (curl w) = 0.
Question:
1. If v = grad u, then curl v = 0.
If curl v = 0, v = grad u for some u?
2. If s = curl w, then div s = 0.
If div s = 0, s = curl w for some w?
Answer: Yes (Under some condition).
• Converse of the Two Identities
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 22
Kirchhoff Voltage Law (KVL): The sum of potential differences
around any loop must be zero. - No circulation.
eTw = 0 for all loops w ⇒ e = −Au.
We change concept: voltage potential and potential difference e velocity v. Then v = −Au.
Continuous form of eTw = 0 is
Zero circulation :
∫C
v1dx + v2dy = 0 for any loop C.
By Green’s theorem, ∫∫R
∂v2
∂x−
∂v1
∂ydxdy.
Since C is arbitrary, so is the enclosed region R, we have
Zero vorticity :∂v2
∂x−
∂v1
∂y= 0 for any point.
Zero vorticity is “no rotation”.
Example 14 v(x, y) = (2x, 2y) and V (x, y) = (2x,−2y) are gra-
dient fields.
curl v = ∂v2∂x
− ∂v1∂y
= 0.∂u∂x
= v1 = 2x ⇒ u(x, y) = x2 + F (y).∂u∂y
= F ′(y) = v2 = 2y ⇒ F (y) = y2 + C.
Hence u(x, y) = x2 + y2 + C.
Similarly, U(x, y) = x2 − y2 + C.
Example 15 w(x, y) = (2y,−2x) is not gradient field.
curl w = ∂w2∂x
− ∂w1∂y
= −4 = 0.
If w = grad u was true,∂u∂x
= w1 = 2y ⇒ u(x, y) = 2xy + F (y).∂u∂y
= 2x + F ′(y) = w2 = −2x ⇒ F ′(y) = −4x ????
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 23
Figure 8: The velocity fields v(x, y) = (2x, 2y) and V (x, y) = (2x,−2y) are perpendicular tothe equipotential curves u(x, y) = x2+y2+C (circles) and U(x, y) = x2−y2+C (hyperbolas).
Figure 9: w(x, y) = (2y,−2x) is tangent to the circles: rotation field, not a gradient.
Note that [x, y]T [2y,−2x] = 0.
2
[cos(−π/2) − sin(−π/2)
sin(−π/2) cos(−π/2)
] [x
y
]= 2
[0 1
−1 0
] [x
y
]=
[2y
−2x
]div w = 2 − 2 = 0. w = curl s := curl (0, 0, s).
Kirchhoff Current Law (KCL): Flow-in equals Flow-out. ATw = 0
in network - conservation of mass, source free.
Continuous form of ATw = 0 is
Solenoidal flow : div w = 0.
Example 16 Find the divergence of v(x, y) = (2x, 2y), V (x, y) =
(2x,−2y), and w(x, y) = (2y,−2x).
div v = 4 = source: Mass is not preserved.
div V = 0 and div w = 0: conservation of mass, source-free.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 24
Definition 17
Stream function s(x, y) : w1 =∂s
∂yand w2 = −
∂s
∂x.
If div w = 0, then w = curl s for some s.
Note that if w1 = ∂s∂y
and w2 = −∂s∂x
,
div w =∂w1
∂x+
∂w2
∂y=
∂2s
∂x∂y−
∂2s
∂y∂x= 0.
curl s = curl (0, 0, s(x, y)) =
(∂s
∂y,−
∂s
∂x, 0
).
Physically, the curves s(x, y) = c are the streamlines. The flow travels
along those streamlines.
Example 18 Find stream functions of V (x, y) = (2x,−2y), and
w(x, y) = (2y,−2x).∂s∂y
= 2y,
−∂s∂x
= −2y.⇒ s(x, y) = 2xy + F (x)
∂s∂x
= 2y + F ′(x) = 2y.⇒ s(x, y) = 2xy.
Similarly, s(x, y) = x2 + y2 for w.
Consider V (x, y) = (2x,−2y).
V = grad u, u(x, y) = x2 − y2. Note that curl V = 0.
V = curl s, s(x, y) = 2xy. div V = 0.
div (grad u) = ∇2u = u = 0 :Laplace equation
u is a harmonic function.
What is the relation between u(x, y) and s(x, y)?
z2 = (x + iy)2 = x2 − y2︸ ︷︷ ︸u(x,y)
+ i2xy︸ ︷︷ ︸s(x,y)
.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 25
§3.4 Laplace Equation
Laplace equation (in 2D): ∇2u = u = uxx + uyy = 0.
u(x, y) = x2 − y2 : potential function
s(x, y) = 2xy : stream function
One interpretation: When the temperature is u, heat flows along the stream-
lines s = constant.
z2 = (x + iy)2 = x2 − y2︸ ︷︷ ︸u(x,y)
+ i2xy︸ ︷︷ ︸s(x,y)
.
Furthermore, u = 0 and v = 0.
The case zn = (x + iy)n
By chain rule,
(x + iy)n =∂2
∂x2(x + iy)n +
∂2
∂y2(x + iy)n
=n(n − 1)(x + iy)n−2 − n(n − 1)(x + iy)n−2 = 0.
un = Re (x + iy)n and vn = Im (x + iy)n
General case: f(x + iy)
f(x + iy) =∂2
∂x2f(x + iy) +
∂2
∂y2f(x + iy)
=f ′′(x + iy) − f ′′(x + iy) = 0.
Let f(x + iy) = u(x, y) + iv(x, y).
∂2
∂x2f = ∂2u∂x2 + i∂
2v∂x2
∂2
∂y2f = ∂2u
∂y2+ i∂
2v∂y2
f = u + iv
f = 0 ⇔ u = 0 and v = 0.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 26
Remark This magic doesn’t work in 3 dimensions, for ∇2u = u =
uxx + uyy + uzz.
Definition 19 Analytic function:
f(x + iy) = f(z) = c0 + c1z + c2z2 + · · · =
∞∑n=0
anzn.
Example 20
∞∑n=0
zn
n!= ez = ex+iy = exeiy = ex cos y︸ ︷︷ ︸
u(x,y)
+i ex sin y︸ ︷︷ ︸v(x,y)
.
Harmonic functions : u(x, y) = Re [f(x + iy)],
v(x, y) = Im [f(x + iy)].
• The Cauchy-Riemann Equations
The potential u and stream function s are closely linked. Physically, the
flow velocity v = grad u is along the streamlines s = constant. Ge-
ometrically, the equipotentials u = constant are perpendicular to those
streamlines. Mathematically, u and s both come from the same analytic
function f(x + iy) = u(x, y) + iv(x, y) (This magic doesn’t work in
3 dimensions).
Notice that we we write f(x + iy) = u(x, y) + iv(x, y),
f : C → C but u, v : R2 → R2.
One must distinguish R2 and C:R2 is a vector space, which has no multiplication, so no division.
C is a field, which has multiplication, so division by nonzero is possible.
As a consequence, differentiation is possible on complex valued function but
only partial derivatives are allowed in R2.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 27
Definition 21
f ′(z) = limz→0
f(z + z) − f(z)
z.
Remark Note that z is of the form x + iy, including all possible
directions.
z → 0 ⇔ x → 0 and y → 0.
Thus, to consider the existence of f ′(z), one must consider all possible
combinations of x and y which x → 0 and y → 0.
First we consider z = x, the case y ≡ 0.
limx→0
f(z + x) − f(z)
x
= limx→0
u(x + x, y) + iv(x + x, y) − (u(x, y) + iv(x, y))
x
= limx→0
u(x + x, y) − u(x, y)
x+ i lim
x→0
v(x + x, y) − v(x, y)
x.
Now we invoke multivariable calculus,
limx→0
f(z + x) − f(z)
x= ux + ivx.
Now we consider the case z = iy, x ≡ 0. A similar calculation
leads:
limy→0
f(z + iy) − f(z)
iy
= limy→0
u(x, y + y) − u(x, y)
iy+ i lim
x→0
v(x, y + y) − v(x, y)
iy
= − iuy + vy.
If derivative exists, those two limits must be identical. Hence if f is analytic
(differentiable),
Cauchy-Riemann Equations: ux = vy, uy = −vx.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 28
Remark Cauchy-Riemann equations reveals the relation between complex
differentiation and multivariable calculus on R2.
Example 22 f(z) = z, f(x + iy) = x − iy.
u(x, y) = x, v(x, y) = −y.
ux = 1 = −1 = vy: z is not analytic (not differentiable).
Its analog in R2 is g(x, y) = (x,−y) := (g1, g2).
Jg =
[∂g1∂x
∂g1∂y
∂g2∂x
∂g2∂y
]=
[1 0
0 −1
].
Partial derivatives can be taken as many times as we want, since it consider
the instantaneous change along x or y direction.
From the Cauchy-Riemann equations,
u = uxx + uyy = (vy)x + (−vx)y = 0.
Similarly v = 0.
Furthermore,
grad u·grad v =
[ux
uy
]·[vx
vy
]= uxvx+uyvy = vyvx+(−vx)vy = 0.
grad u⊥grad v: The equipotentials u = constant are perpendicular to the
streamlines s = constant.
Remark
f(x + iy) = u(x, y) + iv(x, y) is analytic
⇒⇐
+ some conditions
u, v satisfy Cauchy-Riemann equations.
• Polar Coordinates: Laplace Equation in a Circle
Polar coordinates: z = x + iy = reiθ = r(cos θ + i sin θ)
Power of z: zn = (x + iy)n = rneinθ = rn cosnθ︸ ︷︷ ︸harmonic
+i rn sinnθ︸ ︷︷ ︸harmonic
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 29
Cartesian coordinates Polar coordinates
x = r cos θ r =√x2 + y2
y = r sin θ arctan yx
∂x∂r
= cos θ ∂r∂x
= x√x2+y2
∂x∂θ
= −r sin θ ∂r∂y
= y√x2+y2
... ...
u = uxx + uyy u = ∂2u∂r2
+ 1r∂u∂r
+ 1r2
∂2u∂θ2
Laplace equation in r, θ :∂2u
∂r2+
1
r
∂u
∂r+
1
r2
∂2u
∂θ2= 0
Example 23 log z = log r + iθ where z = reiθ.
Note that log r = 0 and θ = 0 except r = 0 (origin).
Radial flow u = log r and s = θ
The equipotentials log r = c are circles around the origin and the stream-
lines are the ray θ = c going out from the origin, perpendicular to the
circles. The flow is leaving from a point source δ(x, y) at the center.
The magnitude of that source is the flux through any circle of radius R.
The flux must be the same for all circles (all R) because there are no other
sources:
Flux =
∫r=R
w · nds =
∫ 2π
0
1
RRdθ = 2π.
Sol) u = log r = log√
x2 + y2.
w = grad u = 1r
(∂r∂x
, ∂r∂y
)= 1√
x2+y2
(x√
x2 + y2,
y√x2 + y2
)︸ ︷︷ ︸
x|x|=
(x,y)|(x,y)|
n = x|x| =
(x,y)|(x,y)| on the circle C : r = R.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 30
w · n = 1r
x|x| ·
x|x| =
1ron C.
C : (R cos θ,R sin θ), 0 ≤ θ ≤ 2π.dsdθ
=
√dxdθ
2+ dy
dθ
2=√
(−R sin θ)2 + (R cos θ)2 = R
Thus, ds = Rdθ.
If u = log r,∫∫D
udxdy =
∫∫D
∇ · ∇dxdy“ = ”div thm
∫C
∇ · nds = 2π.
Remark We cannot apply the divergence theorem directly. We need some
limiting procedure.
Since R is arbitrary,∫∫udxdy = 2π and u = 0 except r = 0.
Definition 24 2D Dirac delta:∫∫δ(x, y)dxdy = 1 and δ(x, y) = 0 except (x, y) = (0, 0).∫∫
F (x, y)δ(x, y)dxdy = F (0, 0).
(
1
2πlog r
)= δ(x, y)
Remark 12π
log r is called the fundamental solution for Laplace equation.
cf) 1D:
u′′ = δ, u(x) =
x if x ≥ 0,
0 if x < 0.
3D:
u = δ, u =1
4π
1
r.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 31
Example 25 Dirichlet problem on unit circle:u = 0,
u(1, θ) = u0(θ).
Let
u(r, θ) =∞∑
n=0
(anrn cosnθ + bnr
n sinnθ).
u(1, θ) =∑∞
n=0(an cosnθ + bn sinnθ) = u0(θ)
: Fourier series of u0(θ).
Remark The separation of variables u(r, θ) = R(r)Θ(θ) will give such
a representation.
• Poisson’s Equation in a Square
Let Ω be the unit square in x, y plane. Consider the following Poisson
equation: − u = f(x, y) in Ω,
u = 0 on ∂Ω.
Eigen function: − u = λu.
Let
umn = sinmπx sinnπy .
−(uxx + uyy) =(m2 + n2)π2 sinmπx sinnπy
=(m2 + n2)π2u := λmnu
and umn = 0 on ∂Ω.
Let
u(x, y) =∞∑
n=1
∞∑m=1
bmnumn =∞∑
n=1
∞∑m=1
bmn sinmπx sinnπy.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 32
−u =∑
bmnλmnumn = f(x, y)
=∞∑
n=1
∞∑m=1
bmn(m2 + n2)π2︸ ︷︷ ︸bmn
sinmπx sinnπy = f(x, y)
2D Fourier sine series of f(x, y).
Remark The separation of variables u(x, y) = X(x)Y (y) will give such
a representation.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 33
Figure 10: 5-point stencil at inside nodes (fewer −1’s next to boundary).
§3.5 Finite Differences and Fast Poisson Solvers
It is extremely unusual to use eigenvectors to solve a linear system KU =
F . Let the eigenvalue decomposition of K be SΛS−1. Especially, S must
be especially fast to work with since both S and S−1 are required.
Consider the following the following Poisson equation in a square Ω:− u = f(x, y) in Ω,
u = 0 on ∂Ω.
We replace the derivatives by second differences under uniform discretization:
uxx ≈ −Ui+1,j−2Ui,j+Ui−1,j
h2 and uyy ≈ −Ui,j+1−2Ui,j+Ui,j−1
h2 .
(K2D)U = F :
4Ui,j − Ui+1,j − Ui−1,j − Ui,j+1 − Ui,j−1 = h2f(ih, jh)(2)
The inside rows of K2D have five nonzero entries 4,−1,−1,−1,−1.
When (i, j) is next to a boundary point of the square, the know value u0 at
the neighboring boundary point moves to the right side of (2). It becomes
part of the vector F , and an entry −1 drops out of the corresponding row
of K. So K2D have five nonzeros on inside rows, and fewer nonzeros on
next-to-boundary rows. See Figure 10.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 34
Using blocks of size N , we can create the 2D matrix form the familiar N by
N second difference matrix K. We number the nodes of the square a row
at a time. Then the −1’s for the neighbors above and below are N position
away from the main diagonal of K2D. The 2D matrix is block tridiagonal
with tridiagonal blocks, and sparse:
KN×N =
2 −1
−1 2 −1
· · ·−1 2
K2DN2×N2 =
K + 2I −I
−I K + 2I −I
· · ·−I K + 2I
Its bandwidth w = N is the distance from the main diagonal to the nonze-
ros in −I.
Definition 26 Let A be an m × n matrix and B be a p × q matrix.
Then the Kronecker product A⊗
B is the mp ⊗ nq block matrix:
A ⊗ B =
a11B · · · a1nB... . . . ...
am1B amnB
i.e. aij is replaced by aijB.
Using the Kronecker product,
K2D = I⊗K+K⊗I =
K
. . .. . .
K
+
2I −I
−I 2I −I. . .
−I 2I
.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 35
Figure 11: Typical rows of K2D have 5 nonzeros. Elimination fills in the band.
• Elimination and Fill-in
It is sparse and banded, but the bandwidth is not so small. (Meshpoints
cannot be numbered so that all five neighbors in the stencil receives near by
numbers.)
Elimination fills in the zeros inside the band. We add row 1 (times 14) to
row 2 to eliminate the −1 in position (2, 1). But the last −1 in row 1
produces a new −14in row 2. A zero inside the band has disappeared. As
elimination continues, virtually the whole band of multipliers in L is filled in.
See Figure 11.
• Solver Using Eigenvalues
Note that the eigenvectors and eigenvalues of Kn are
yk = (sin kπh, · · · , sin kπh), h =1
n + 1,
λk = 2 − 2 cos kπh, k = 1, · · · , n.There will be similar pattern for K2D.
To solve KU = F , let U = α1y1 + · · · + αnyn.
We have to find α1, · · · , αn.
Expand F w.r.t. y1, · · · , yn: F = a1y1 + · · · anyn.
KU = α1λ1y1 + · · · + αnλnyn = F = a1y1 + · · · anyn.
Hence α1 = a1/λ1, · · · , αn = an/λn.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 36
We describe the method in the following 3 steps:
Step 1 Expand F as a combination F = a1y1 + · · · anyn of the
eigenvectors.
Sa = F
y1 · · · yn
a1
...
an
= a1y1 + · · · anyn = F
Step 2 Divide each ak by λk.
Step 3 Recombine eigenvectors into U = a1/λ1y1 + · · · +
an/λnyn.
U =
y1 · · · yn
a1/λ1
...
an/λn
= SΛ−1a = SΛ−1S−1F.
Step 2 is fast. The success of the method depends on the speed of step 1
and step 3: multiplying quickly by S−1 and S. Normally they both need
n2 operations since they are full matrices. But the sine eigenvectors in S
give the Discrete Sine Transform, and the Fast Fourier Transform executes
S and S−1 in n log2 n steps.
Remark In one dimension, it is slower than cn from tridiagonal elimination.
But in two dimensions n2 log2 n2 easily wins over (n2)2.
• Fast Poisson Solvers
Eigenvectors ykl (i, j) component: sinikπ
N + 1sin
jlπ
N + 1
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 37
Eigenvalues λkl K2Dykl = λklykl
λkl = 2 − coskπ
N + 1+ 2 − cos
lπ
N + 1
By 2-dim sine transform,
Fi,j =N∑k=1
N∑l=1
akl sinikπ
N + 1sin
jlπ
N + 1,
Ui,j =N∑k=1
N∑l=1
akl
λkl
sinikπ
N + 1sin
jlπ
N + 1.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 38
§3.6 The Finite Element Method
The real success of finite element method is in two and three dimensions,
where finite differences mostly hope for a square or rectangle or cube. The
boundaries can be curved and the mesh can be unstructured. See Figure 12.
(a) Triangularization of 2d domain. (b) Pyramid Function which is piecewise linear.
Figure 12: Triangularization and pyramid function examples.
Procedure
1. Write the equation in its weak form, integrated with test function v(x, y).
2. Subdivide the region into triangle or quadrilaterals.
3. Choose N simple trial functions ϕj(x, y) and look for U = U1ϕi +
· · · + UNϕN . The 1D hat function ϕ(x) can change to 2D pyramid
function ϕ(x, y).
4. Produce N equation KU = F from test functions V1, · · · , VN
(often Vj = ϕj).
5. Assemble the stiffness matrix K and the load vector F . Solve KU =
F .
Laplace equation: − ∇2u = −(uxx + uyy) = 0.
Multiply the strong form by a test function and integrate,∫∫Ω
−(uxx + uyy)vdxdy = 0.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 39
By Gauss-Green’s formula,
Weak form:
∫∫Ω
(uxvx + uyvy)dxdy =
∫∂Ω
∂u
∂nvds.
Boundary condition on u and v:
Essential condition: u = u0(x, y) on ∂Ω.
v = 0 is required at ∂Ω.
Natural condition: ∂u∂n
= F0(x, y) on ∂Ω.
No condition is imposed on v.
With the essential boundary condition,
Weak form:
∫∫Ω
(uxvx + uyvy)dxdy = 0 for all admissible v.
The beauty of this weak form is that it involves only first derivatives. It
has Au and Av instead of ATAu. We can create trial and test functions
much more easily when only the first derivatives are required.
Poisson equation −∇2u = −(uxx + uyy) = f(x, y) has the weak
form: ∫∫Ω
(uxvx + uyvy)dxdy =
∫∫Ω
fvdxdy.
Remark (ATCAu)Tv = fTv becomes the weak form: (CAu)TAv =
fTv.
• Trial and Test Functions: Galerkin’s Method
Approximation U(x, y) =N∑j=1
Ujϕj(x, y) (plus UB(x, y) if needed).
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 40
The extra functionUB(x, y) satisfies any nonzero essential conditionUB =
u0 at boundary mesh points. The trial functions ϕ1, · · · , ϕN equal zero
on the boundary.
We have N unknown coefficients U1, · · · , UN , and we need
N equations. Choose test functions Vi, · · · , VN .
Replace u in the weak form by∑N
j=1 Ujϕj and v by Vi:∫∫Ω
N∑j=1
Uj
∂ϕj
∂x
∂Vi
∂x+
N∑j=1
Uj
∂ϕj
∂y
∂Vi
∂y
dxdy
=
∫∫Ω
f(x, y)Vi(x, y)dxdy.
Stiffness matrix Kij =
∫∫Ω
[∂ϕj
∂x
∂Vi
∂x+
∂ϕj
∂y
∂Vi
∂y
]dxdy
and we have KU = F .
If Vi = ϕi, the matrix K is symmetric and positive definite.
If ϕj are localized, K is sparse (Kij = 0 when the graphs of ϕj and Vi
don’t overlap).
The right hand side F comes from f(x, y) and also from nonzero boundary
values u = u0(x, y) (in UB), or∂u∂n
= F0(x, y) .
• Pyramid Functions
We consider Laplace equation −∇2u = −(uxx + uyy) = 0 inside a
square. The boundary values are given around the whole square of side 2h.
See Figure 13.
We choose approximation U(x, y) as linear inside each of the eight trian-
gles. Thus U = a + bx + cy in each triangle. For T1, those numbers
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 41
Figure 13: Approximation U(x, y) and test pyramid V = ϕ, linear in eight triangles.
a, b, c are determined by the values U,UE, UN at the corners. UE, UN
are known from u0(x, y). The interior value U is what we want to find.
Only one test function V is required because we have one unknown U .
Test function V (x, y) = 1 − xh− y
hin T1
V (x, y) = 1 − xh
in T2
U(x, y) adjusts a+ bx+ cy to match U,UE, UN at the corners of T1:
U + xh(UE − U) + y
h(UN − U) in T1,
U + xh(UE − U) + y
h(UE − USE) in T2.
The integral of UxVx +UyVy in the weak form is easy, because all deriva-
tives are constants. Just multiply by the area 12h2.
∫∫T1
UxVx + UyVydxdy
=
∫∫T1
[(UE − U
h
)(−1
h
)+
(UN − U
h
)(−1
h
)]dxdy
=1
2(−UE + 2U − UN).∫∫
T2
[(UE − U
h
)(−1
h
)+
(UE − USE
h
)(0)
]dxdy
=1
2(U − UE).
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 42
Over T3:12(U − US).
Over T4:12(−UW + 2U − US).
Over T5:12(U − UW ).
Over T6:12(U − UN).
⇒ 4U − UE − UW − UN − US = 0
KU = F 4U = UE + UW + UN + US
U is the average of those boundary values: Discrete mean value theorem.
Remark 1. Mean value theorem for harmonic function:
u =1
|C|
∮C
uds =1
|R|
∫∫R
udxdy.
2. It is exactly the five-point Laplacian in FDM.
• Element Matrices and Element Vectors
Within a single interval in 1D, or one triangle in 2D, the approximation
solution U only involves two or three of the trial functions ϕi (the others
are zero in that element). The contribution to the global matrix K will
be a 2 by 2 or 3 by 3 element matrix Ke. When assembled into K,
this matrix will overlap other element matrices from triangles that share a
meshpoint.
(Ke)ij =
∫∫e
(∂ϕi
∂x
∂ϕj
∂x+
∂ϕi
∂y
∂ϕj
∂y
)dxdy, i, j = 1, 2, 3.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 43
With U =∑N
j=1 Ujϕj and Vi = ϕi,∫∫Ω
U2x + U2
ydxdy =N∑i=1
N∑j=1
UiUj
∫∫Ω
(∂ϕi
∂x
∂ϕj
∂x+
∂ϕi
∂y
∂ϕj
∂y
)dxdy︸ ︷︷ ︸
Kij
=N∑i=1
Ui
N∑j=1
KijUj
=UTKU : N × N matrix.∫∫e
U2x + U2
ydxdy = UTKeU : 3 × 3 matrix.
We have an N × N matrix, but its only nonzero entries are in the 3 × 3
matrix KT . At the end, K is an assembly of Ke from all triangles.
In a standard right triangle T , the three unknowns Ui, Ui+1, Ui+2 are the
corners of T . See Figure 14.
∫∫T
U2x + U2
ydxdy =
[(Ui+1 − Ui
h
)2
+
(Ui+2 − Ui
h
)2]
h2
2︸︷︷︸area
.
Element
matrix KT
UTKTU = [Ui Ui+1 Ui+2]
1 −12
−12
−12
12
0
−12
0 12
Ui
Ui+1
Ui+2
The general element matrixKe depends on the tangents of the corner angles.
See Figure 14.
Element
matrixKe =
C2 + C3 −C3 −C2
−C3 C1 + C3 −C1
−C2 −C1 C1 + C3
with ci =1
2 tan θi
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 44
Figure 14: The standard triangle T (lengths 1 or h) and an arbitrary triangle e.
One can derive the matrix above using the following observation:
With U = U1ϕ1 + U2ϕ2 + U3ϕ3,∫e ∇U · ∇ϕ1∫e ∇U · ∇ϕ2∫e ∇U · ∇ϕ3
=
∫e |∇ϕ1|2
∫e ∇ϕ1 · ∇ϕ2
∫e ∇ϕ1 · ∇ϕ3∫
e ∇ϕ2 · ∇ϕ1
∫e |∇ϕ2|2
∫e ∇ϕ2 · ∇ϕ3∫
e ∇ϕ3 · ∇ϕ1
∫e ∇ϕ3 · ∇ϕ2
∫e |∇ϕ3|2
U1
U2
U3
.
Remark Ke is only semidefinite. The constant vector [1, 1, 1] is in the null
space. U = 1 at all three corners gives U = constant and grad U = 0 in
the triangle. A fixed boundary U = u0 will make K positive definite.
How do boundary values of U enter the equation KU = F ?
If U is known at a meshpoint, it moves to the right side (into F ). This is
equivalent to the extra termUB(x, y) that matches the boundary condition.
The load vector F comes from assembling integrals of f(x, y) times U :
Element load
vector Fe
∫∫e
f(∑
Uiϕi)dxdy =∑
Ui
∫∫e
fϕidxdy = UTFe
Each triangle produces a vector Fe with 3 nonzeros. On assembly, those
Fe overlap.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 45
As an approximation, we could look at the centroid of the triangle P . For
linear elements, U(P ) is the average:
U(P ) =Ui + Ui+1 + Ui+2
3.
One-point
integration
∫∫e
f(x, y)U(x, y)dxdy
≈ f(P )
(Ui + Ui+1 + Ui+2
3
)(area of e)
• Global Matrix K and F from Ke and Fe
1. K and F are assembled from element matrices Ke and load vectors
Fe.
2. The intervals and triangles (or quads) can have different lengths and
shapes.
3. First, K and F can be constructed with no boundary conditions. Then
for boundary nodes put I and u0 into F .
To ease understanding, we consider the following 1D problem:− u′′ = 1
u(0) = 0, u′(1) = 0.
Its weak form is∫uxvxdx =
∫1vdx.
Using the discretization in Figure 15,
U = U0ϕ0 + U1ϕ1 + U2ϕ2.
Element matrices Kh and KH .
Assemble Kh and KH into K.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 46
Figure 15: A hat and two half-hats: K will be 3 by 3 and singular.
In the first interval,∫ h
0
(U ′)2dx =
∫ h
0
(−U0
h+
U1
h
)2
dx =1
h(U1 − U0)
2
=[U0 U1]1
h
[1 −1
−1 1
]︸ ︷︷ ︸
Kh
[U0
U1
].
Element
matrix Kh
[ ∫ h
0 (ϕ′0)
2dx∫ h
0 ϕ′0 · ϕ′
1dx∫ h
0 ϕ′1 · ϕ′
0dx∫ h
0 (ϕ′1)
2dx
]=
1
h
[1 −1
−1 1
]
Similarly,
KH =
[ ∫ h+H
h (ϕ′1)
2dx∫ h+H
h ϕ′1 · ϕ′
2dx∫ h+H
h ϕ′2 · ϕ′
1dx∫ h+H
h (ϕ′2)
2dx
]=
1
H
[1 −1
−1 1
].
Now assemble Kh and KH into their right places in K. They overlap:
Global matrix K =
1h
−1h
0
−1h
1h+ 1
H− 1
H
0 − 1H
1H
This matrix has the vector [1 1 1]T in its nullspace. If U0 = U1 = U2
then U = constant and dUdx
= 0.
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 47
Consider the middle row:[−
1
h
1
h+
1
H−
1
H
] U0
U1
U2
=U1 − U0
h+
U2 − U1
H.
This is a difference of first differences. Finite element automatically adjust
for changes in meshsize.
For −(c(x)u′(x))′ = f(x),[−c1
h
c1
h+
c2
H−
c2
H
]lead to
c1(U1 − U0)
h+
c2(U2 − U1)
H.
Now impose an essential boundary condition U0 = 0, corre-
sponding to u(0) = 0. In the boundary row and column, insert the identity
matrix:
Change K to Kb Kb =
1 0 0
0 1h+ 1
H− 1
H
0 − 1H
1H
When we put F0 = 0 on the right side of the equation, the solution will have
U0 = 0. In the lower 2 by 2 submatrix is the usual fixed-free matrix[2 −1
−1 1
]when h = H .
∫ h
0
f(x)︸ ︷︷ ︸=1
U(x)dx =
∫ h
0
[U0 + (U1 − U0)
x
h
]dx
=x
h(U0 − U1) = [U0 U1]
h
2
[1
1
].
Fh =
[ ∫ h
0 f(x)ϕ0(x)dx∫ h
0 f(x)ϕ1(x)dx
]=
h
2
[1
1
]Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 48
and
FH =
[ ∫ h+H
h f(x)ϕ1(x)dx∫ h+H
h f(x)ϕ2(x)dx
]=
H
2
[1
1
].
Assemble load vector F
before boundary conditionF =
[Fh
−
]+
[−FH
]=
1
2
h
h + H
H
Note that h/2, (h+H)/2,H/2 are the areas under the graphϕ0, ϕ0, ϕ0.
To impose U0 = 0 at the left end point, for a fixed-free bar, change the
first component of F to zero in Fb. Finally we have:
KbFb = Fb
1 0 0
0 1h+ 1
H− 1
H
0 − 1H
1H
U0
U1
U2
=1
2
0
h + H
H
It gives U0
U1
U2
=1
2
0
h + hH
1
.
If the essential boundary condition U0 = u(0) = A, that number is
multiplying −1/h in row 2 of K, so −A/h must move into the load
vector Fb as A/h. 1 0 0
0 1h+ 1
H− 1
H
0 − 1H
1H
U0
U1
U2
=
A12(h + H) + A
h12H
.
• Element Matrix in Two Dimension
The trial function have ϕ = a+bx+cy inside each triangle. Those coef-
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 49
Figure 16: Standard triangle T .
ficient a, b, c are determined by the three values 1, 0, 0 at the corners. We
want to construct the three local basis function ϕ1, ϕ2, ϕ3 on the standard
triangle given in Figure 16 satisfying
ϕ1 ϕ2 ϕ3
(0, 0) 1 0 0
(1, 0) 0 1 0
(0, 1) 0 0 1
.
We define the position matrix P :
Position matrix P
Standard triangle
1 0 0
1 1 0
1 0 1
Node 1 at (0, 0)
Node 2 at (1, 0)
Node 3 at (0, 1)
Finding the coefficient ai + bix + ciy for ϕ1, ϕ2, ϕ3 lead PC = I:
C = P−1 give the
coefficients a, b, c
in the three ϕ′s
1 x1 y1
1 x2 y2
1 x3 y3
a1 a2 a3
b1 b2 b3c1 c2 c3
=
1 0 0
0 1 0
0 0 1
For the standard triangle,
Standard
triangle
1 0 0
1 1 0
1 0 1
1 0 0
−1 1 0
−1 0 1
=
1 0 0
0 1 0
0 0 1
ϕ1 =1 − x − y
ϕ2 =x
ϕ3 =y
Computational Science & Engineering (CSE) Yoon Mo Jung
Ch 3. Boundary Value Problems 50
The derivatives of a+ bx+ cy are b and c. Those b’s and c’s are in rows
2 and 3 of C, and they enter the integrals of r the 3 by 3 element matrix
Ke:
Stiffness matrix for element e
(Ke)ij =
∫∫e
(∂ϕi
∂x
∂ϕj
∂x+
∂ϕi
∂y
∂ϕj
∂y
)dxdy = (area)(bibj + cicj).
The area of the triangle is | detP |/2. For the standard triangle,
Standard
element
matrix
KT = (area)(bibj + cicj) =1
2
2 −1 −1
−1 1 0
−1 0 1
• Quadrilateral Elements
In one dimension, we moved from linear element a+ bx to quadratics and
cubics. In two dimension it is often enough to allow an xy term (Q1 element
for rectangles). Even better are the x2, xy, y2 term that produces P2 for
triangles.
Bilinear Q1 elements: U = a + bx + cy + dxy on rectangle. Ele-
ment matrix is 4 by 4.
Quadratic P2 elements: U = a + bx + cy + dxy + ex2 + fy2
on triangle. Element matrix is 6 by 6.
Computational Science & Engineering (CSE) Yoon Mo Jung