Lecture 9: Contents Finite Difference grids

Lecture 9: Contents
Finite Difference grids
Observation We have treated equations on rectangular or circular
grids.
7
1
Composite and Overlapping Grids
0.8
Interface variables. Block Structure.
Bilinear interpolation. Lagrange Interpolation Formula.
5
0.4
Orthogonal Grid Transformations.
Beziér curves.
0.2
Angle: θ
Coordinate: y
Grid Generation
6
0.6
0
4
3
-0.2
-0.4
2
-0.6
1
-0.8
-1
-1
0
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
Radus: r
Coordinate: x
Question What to do with more complex domains?
May 16, 2017 Sida 1 / 27
May 16, 2017 Sida 2 / 27
Example Consider the equation uxx + uyy = 0 in Ω with Dirichlet
boundary conditions u = f on ∂Ω.
Solution Divide Ω in two parts Ω1 and Ω2 .
(k)
(k)
Supply Ωk with aseparate grid {xi , yj )}, k = 1, 2.
(1)
(2)
Interior points are uh , uh and interior points on the interface w(12) .
Ω
What will the combined finite difference equations look like?
How to construct finite difference equations Ah u = b?
May 16, 2017 Sida 3 / 27
May 16, 2017 Sida 4 / 27
Example Consider the equation uxx + uyy = 0 in Ω = Ω1 ∪ Ω2 , with
Dirichlet boundary conditions u = f on ∂Ω. Due to the specific
function f we want to use a smaller stepsize on Ω1 .
(1)
ui
(12)
wi−1
(12)
wi
(12)
wi+1
(2)
ui
Solution If the grid is a perfect match at the interface then
 (1)

 

(1,w)
(1)
Ah
0
Ah
uh
b(1)


(2)
(2,w)  
 0
  uh(2)  =  b(2) 
Ah
Ah
(w,2)
c(12)
w(12)
Ahw,1 Ah
Bw
(1)
(2)
Observation On the interface y = y0 = ym we have grid points
from both grids. Need one equation for each grid point.
The matrix has a block structure!
May 16, 2017 Sida 5 / 27
May 16, 2017 Sida 6 / 27
Linear Interpolation
Example Let Ω be a rectangle [xi , xi+1 ] × [yi , yi+1 ]. Approximate
u(x, y) with error O(h2 ) in Ω
Observation Any bilinear polynomial on Ω is a linear combination of
1, x − xi , y − yi and (x − xi )(y − yi ). We need 4 interpolation points to
uniquely define the polynomial.
(12)
Example Discretize the equation ∆u = 0 at one point wi
interface. Use a O(h2 ) accurate approximation.
on the
Remark Bilinear interpolation on a grid will automatically create a
continuous function across interfaces.
May 16, 2017 Sida 7 / 27
May 16, 2017 Sida 8 / 27
Overlapping grids
Example We have a rectangular domain with an elipse shaped hole.
Example Suppose we want O(h3 ) error in the interpolation? How to
organize the interpolation points?
Remark This is biquadratic interpolation. There is also bicubic
interpolation schemes, Trilinear, or Tricubic. All are easy to automate.
May 16, 2017 Sida 9 / 27
May 16, 2017 Sida 10 / 27
Lagrange Interpolation
Example An object moves during a simulation.
Definition Let xj , j = 1, . . . , m be distinct points. The
Lagrange basis polynomial is
ℓi (x) = Πj6=i
x − xj
.
xi − xj
Remark We have ℓi (xi ) = 1 and ℓi (xj ) = 0 for i 6= j.
May 16, 2017 Sida 11 / 27
May 16, 2017 Sida 12 / 27
2
Lemma The unique polynomial of degree m − 1 that
interpolates u(x) in the points xj , i = 1, 2, . . . , m is
1.45
1.5
1.4
1
1.35
0.5
uI (x) =
m
X
0
u(xi )ℓi (x).
1.3
-0.5
1.25
i=1
-1
1.2
-1.5
-2
0.25
0.3
0.35
0.4
0.45
0.5
0.55
0.6
0.65
0.7
1.15
0.2
0.25
0.3
0.35
0.4
0.45
0.5
0.55
0.6
0.65
0.7
Example Find the unique polynomial interpolating the table
xi
ui
0.30
1.23
0.45
1.31
0.53
1.35
Results The Lagrange basis polynomials of degree 3 and the
interpolating polynomial. The error is O(h4 ).
0.67
1.42
Question How to generalize to 2D?
May 16, 2017 Sida 13 / 27
Example We have m = 6 points (xi , yj ) and want to find the
interpolating polynomial uI (x, y).
Introduce basis functions ℓi such that ℓi (xj , yj ) = 1 if i = j and zero
otherwise. Then the interpolant is
uI (x) =
m
X
May 16, 2017 Sida 14 / 27
4
3
2
2
0
1
-2
0
-4
-1
-6
1
-2
1
0.5
0.8
0.4
0.3
0.6
u(xi , xi )ℓi (x).
0.2
0.4
0.1
0
0.5
0.8
0.4
0.3
0.6
0.2
0.4
0.1
0
i=1
Two basis functions ℓ2 (x, y) and ℓ3 (x, y). We use m = 6 interpolation
points and basis functions 1, x, y, xy, x2 , y2 .
May 16, 2017 Sida 15 / 27
May 16, 2017 Sida 16 / 27
Unstructured Grids
4
0.05
3.8
0.04
Example Complicated domains can be divided into triangles.
0.03
3.6
0.02
3.4
0.01
3.2
1
0
1
0.5
0.8
0.4
0.3
0.6
0.2
0.4
0.5
0.8
0.4
0.3
0.6
0.2
0.1
0
0.4
0.1
0
The interpolant uI (x, y) and the error |uI − u|, where
√
u = 3 + x y + cos(2x)y2 was interpolated using m = 6 points.
Remark Really simple and flexible method. The error terms are
obtained by comparing with a Taylor series expansion.
No structure in the linear system Ax = b means more memory needed.
May 16, 2017 Sida 17 / 27
May 16, 2017 Sida 18 / 27
Orthogonal Coordinate Transformations
Definition A coordinate transformation
(x1 , x2 ) 7→ (ξ1 , ξ2 ) is orthogonal it two curves that are
orthogonal at (x∗1 , x∗2 ) are mapped onto curves that are
orthogonal at the intersection (ξ1∗ , ξ2∗ ).
Lemma Let T : (x1 , x2 ) 7→ (ξ1 , ξ2 ) be an orthogonal
transformation. Then
(a(x)ux1 )x1 + (b(x)ux2 )x2 = (ã(ξ)uξ1 )ξ1 + (b̃(ξ)uξ2 )ξ2 .
Two orthogonal grids. How can we construct these?
Remark A conformal mapping creates an orthogonal grid
transformation but can’t control the distribution of points on the
boundary.
Remark We do not introduce mixed derivatives.
May 16, 2017 Sida 19 / 27
May 16, 2017 Sida 20 / 27
Beziér curves
Cubic Beziér curves
A cubic Beziér curve is defiend by four points and given by
Definition A Beziér curve (or surface) is given by a
number of control points.
s(t) = (1 − t)3 P1 + 3(1 − t)2 tP2 + 3(1 − t)t2 P3 + t3 P4 .
Exemple
P2
P2
P3
P2
P4
P1
P1
P1
P3
A linear Beziér curve is given by three points and a quadratic curve is
determined by three points. Beziér curves are approximating splines.
Lemma A cubic Beziér kurva s(x) interpolates the first
and last control point.
May 16, 2017 Sida 21 / 27
Definition The convex hull formed by points {Pi }ni=1
consists of all points that can be written as convex linear
combinatiosn of {Pi }ni=1 .
Exemple what is the convex hull of the points
1
2
0
.
, and P3 =
, P2 =
P1 =
3
1
0
Theorem A Beziér curve lies within the convex hull of its
control points.
May 16, 2017 Sida 23 / 27
May 16, 2017 Sida 22 / 27
Theorem For a Beziér curve with control points {Pi }ni=1
we have the tangent directions
s′ (0) = α(P2 − P1 ) and s′ (1) = α(Pn − Pn−1 ),
α > 0.
Remark It is easy to control the direction of the curve at its end
points.
Question How to make more complex curves?
May 16, 2017 Sida 24 / 27
P2
P3
P7
Example Construct a curvilinear coordinate system for a region
P4
P5
P6
P1
Two cubic Beziér curves defined by the control points {P1 , P2 , P3 , P4 }
and {P4 , P5 , P6 , P7 }. Note that P4 is a common interpolation point.
Remark Algorithms for generating orthogonal grids is an active
research area. There are good methods for many types of geometry.
If P4 −P3 = P5 −P4 the curve has a continuous tangent.
May 16, 2017 Sida 25 / 27
Grids Finite Differences use
• Structured Grids that are relatively simple.
• Combining Grids gives structured matrices.
The goal is to make solving the problem simpler and less resource
demanding.
Alternative The Finite Element method using unstructured grids.
May 16, 2017 Sida 27 / 27
May 16, 2017 Sida 26 / 27