Homework 6. (Due March 17)

advertisement
Homework 6. (Due March 17)
Math. 639
This homework involve implementing an additive domain decomposition preconditioner for the problem
e = Fe.
Ac
e We
We focus on a one dimensional problem resulting in a tridiagonal A.
consider the finite difference approximation to
−(a(x)u′ (x))′ + q(x)u(x) = 1,
x ∈ (0, 1)
u(0) = u(1) = 0.
The matrix entries are given by
 −2
h (a(xi−1/2 ) + a(xi+1/2 )) + q(xi )


eij =
−h−2 a(xi−1/2 )
A


−h−2 a(xi+1/2 )
if i = j,
if j = i − 1,
if j = i + 1.
and the right had side is Fej = 1. Here xα = αh, h = 1/(m + 1), and
i, j = 1, . . . , m. In this assignment, we take a(x) = 1 + x and q(x) = 0.
The finite difference matrix problem has the same properties as the finite
element matrix problem so I will often use notation from the finite element
framework. For example, a nodal basis function in the finite difference case
is just a standard basis vector ei and S = Rm (recall S = Vh in the finite
element case).
Eventually, there will be two types of subspaces (although only the first will
appear in this assignment).
(a) (Type 1). The subspace Sj is defined as a span of a subset of the nodal
basis functions of S and is defined by a vector P J containing the global
indexes so that the i’th unknown (or degree of freedom (DOF)) in the
j’th subspace coincides with the P J(i)’th unknown in global vectors
(such as c). In the Type 1 case, one can also think of the subspace being
defined from an mk × m matrix Pj . The entries are zeros and with the
L, K entry being one if and only if subspace basis function L corresponds
to S basis function K.
(b) (Type 2). This is the general case where the basis functions for Sj (of
dimension mj ) involve linear combinations of basis functions for S. In
this case the subspace is defined again using a mj × m matrix Pj (stored
in CRS format) with the k’th row containing the coefficients for the
1
2
expansion of the k’th basis function of Sj in terms of the basis functions
of S. In the case, the entries of Pj are no longer just zeros and ones.
There are two types of actions (transfer routines) associated with the above
structures corresponding to the two type of vectors in a finite element implementation, i.e., coefficient vectors and inner product vectors.
(i) (Coefficient vectors.) A subspace function with coefficients yi , i =
1, . . . , mj needs to increment a function with coefficients x in S, i.e.,
x = subCoef add1(x, y, P J) or x = subCoef add2(x, y, Pj ).
In both cases, this corresponds to the matrix computation
(0.1)
x = x + Pjt y.
For Type 1, the code looks like a loop over the DOFs of SJ :
x(P J(i)) = x(P J(i)) + y(i);
Note that values in x corresponding to basis functions of S which are
not in Sj are left alone. For Type 2, the code implements (0.1) directly.
Properly written, nodes not in the support of Sj are again left alone.
(ii) (Inner product vectors.) Given an inner product vector Fe on S, we
need to compute IP = Pj Fe which gives corresponding inner product
against the basis functions of Sj . For Type 2, this product is directly
computed (CRS * vector routine). For Type 1, we use P J and extract
the corresponding entries from Fe, i.e.,
IP (i) = Fe (P J(i)),
Call these routines IP = subIp1(tF, P J) and IP = subIp2(tF, Pj ).
You may have to pass additional control variables to these routines, e.g., m
or mk .
Problem 1. Implement the transfer routines mentioned above corresponding
to Type 1 subspaces.
Subproblems: In this assignment, we shall use exact subspace solvers (as
opposed to the more general Rj ). For either type, the subspace “stiffness”
ej = Pj A P t and the additive algorithm with exact solves implematrix is A
j
ments as
l−1
X
e−1 Pj G.
ea G
e=
e
Pjt A
B
j
i=1
3
In terms of the above routines, this becomes
set v=0; // a vector of length m, tG a given inner product vector
for j=1:l-1
// assuming type l-1 subspaces
Fj=subIP1(tF,PJ(j));
si=solve(tA_j,Fj);
v=subCoefadd1(v,y,PJ(j))
end
The solve routine above needs to produce the solution to the subspace probej si = Fj . We will use direct methods for this assignment.
lem A
All of the matrices in this assignment are tridiagonal and symmetric. Thus
the non-zeros can be stored in two vectors D and LD. For example, for the
full m × m problem, these are given by
D(i) = h−2 (a(xi−1/2 ) + a(xi+1/2 )) + q(xi ),
−2
LD(i + 1) = −h
a(xi−1/2 ),
i = 1, . . . , m and
i = 2, . . . , m.
There will be l − 1 subspaces in this problem where l divides m + 1. Set
Inc = (m + 1)/l and H = Inc ∗ h. The j’th subspace has nodes (or indexes)
with xi ∈ ((j − 1)H, (j + 1)H). All subspaces are of Type 1.
Problem 2. Compute the transfer vectors P J(j), j = 1, . . . , l − 1. Develop
ej , the j’th subspace
a routine for computing Dj and LDj corresponding A
e
problem from D and LD corresponding to A.
Problem 3. For matlab users, convert Dj and U Dj to a full mj ×mj matrix
ej (mj = 2 ∗ Inc − 1) so that si = solve(tAj , F j) can be implemented as
A
ej ) ∗ Fj .
si = inv(A
Fortran programmers can use TRISOL.F1 to do the solve (discussed in recitation).
e (for the full m × m problem)
Problem 4. Write a routine that evaluates A
from D and LD. Apply your preconditioned conjugate gradient (PCG) iteration procedure (with the above right hand side and zero initial iterate) and
ea A
e computed
report the estimates for the largest and smallest eigenvalues of B
1When passing the off diagonal coefficients to TRISOL, LD should be passed to “A”,
LD(2) should be passed to “C” and D should be passed to “B” where “A,B,C” are the
first arguments in TRISOL.
4
by PCG as well as their quotient (the estimate for the condition number).
Do this for the following combinations of l and m.
(i)
(ii)
(iii)
(iv)
l = 4, m = 15, 31, 63, 127, 255, 511, 1023.
l = 8, m = 15, 31, 63, 127, 255, 511, 1023.
l = 16, m = 15, 31, 63, 127, 255, 511, 1023.
l = 4, 8, 16, 32, 64, 128, m = 2047
I expect that you will see more or less uniform condition numbers when
l is held fixed. The last example should illustrate the H −2 deterioration
mentioned in class.
Download