Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Spring 2003 Prof. Tim Warburton MA557/MA578/CS557 Lecture 34.

Similar presentations


Presentation on theme: "1 Spring 2003 Prof. Tim Warburton MA557/MA578/CS557 Lecture 34."— Presentation transcript:

1 1 Spring 2003 Prof. Tim Warburton timwar@math.unm.edu MA557/MA578/CS557 Lecture 34

2 2 Today’s Class A few ways to solve Ax=b for a sparse matrix A in Matlab. Followed by time for work on HW 10. On Friday 04/25/03 we will benefit from a special lecture on preconditioning for iterative methods presented by: – Dr D.M. Day of Sandia National Laboratories http://www.cs.sandia.gov/~dday/

3 3 Recall: Summary of Temporal Implicit Schemes Backwards Euler is unconditionally stable for non- negative diffusion parameter D (i.e. any dt>=0) and first order in dt. Crank-Nicholson is unconditionally stable for non- negative diffusion parameter D (i.e. any dt>=0) and second order in dt. ESDIRK4 – generalizes to fourth order in dt.

4 4 Backwards Euler Linear System Given Cn we wish to find a Cn+1 which satisfies: For simplicity we define: Note that A is a symmetric, positive matrix.

5 5 Lazy Way To Build The Matrix.. Don’t tell anyone I told you this but here’s an easy way to program the construction of the DG operator. The first step is to understand that if I set up a vector which only has one non-zero entry in the n’th entry and then pass it to umDIFFUSIONop then the returned vector will be the n’th column of the A matrix.

6 6 Laziness cont The next step is to use the sparsity of If I set one of the node values in the center white triangle to one and multiply by the Neumann DG derivative operator then the result vector will have non-zero entries in the red triangles and the original white triangle. If I take this result vector and premultiply by the Dirichlet DG derivative operator then there will be non-zero entries in the red, white and blue triangles..

7 7 Finding The Neighbors and Their Neighbors of an Element In umMESH.m there is code which computes the sparse connectivity matrix umSparseEtoE. For: the matrix is: To find neighbors and neighbors of neighbors we consider the square of the connectivity matrix: 12 3 4 5

8 8 Example cont Double connectivity matrix: i.e. Element 1 is within two elements of 2, 3, 4 Element 2 is within two elements of 1, 3, 4 Element 3 is within two elements of 1, 2, 4, 5 Element 4 is within two elements of 1, 2, 3, 5 Element 5 is within two elements of 3, 4 12 3 4 5

9 9 Matlab Implementation (Connectivity): Here we compute the square of the element connectivity matrix:

10 10 Building DG Matrix umDIFFUSIONilu.m 16) Create sparse matrix 20-41) for each node, compute the row of the matrix 44) Compute Cholesky factorization 47) Compute incomplete Cholesky factorization.

11 11 umDIFFUSIONpartop.m In this function we apply the operation of the matrix on a part of the vector.

12 12 First Part of the Part Matrix Multiply umDIFFUSIONpartop.m In this function we apply the Helmholtz operator to all the elements specified in the elmts argument.

13 13 Applying the Helmholtz Operator umDIFFUSIONpartop.m cont

14 14 Driver umDIFFUSIONdemo.m Driver for the implicit DG diffusion solver.

15 15 umDIFFUSIONrun.m Note the changes to pcg and the call to: umDIFFUSIONilu

16 16 In Action It takes a while to build the matrix… We can look at the sparsity pattern of the matrix:

17 17 Some Options For Solving Ax=b We will consider a couple of many options for accelerating the process of solving Ax=b 1)Cholesky factorization of A before time stepping and repeated backsolving. 2)Incomplete Cholesky factorization of A and using this as a preconditioner.

18 18 Option 1: Cholesky factorization Use Cholesky factorization to decompose A into the product of a lower triangular matrix C and its transpose: Then every time we need to peform a backsolve twice: Each backsolve takes N^2 operations (N=total number of unknowns)

19 19 Option 1: Sparsity of Cholesky Factor

20 20 Option 1: Sanity Check on Cholesky Factorization We can check to see how stable the computation of the Cholesky factorization was: Not bad – we lost about 4 decimal places…

21 21 Option 1: Condition number We can use condest to estimate the condition number of the matrix. We see that the condition number is about 800 so we may well expect to lose 3 decimal places in computing the factorization..

22 22 Option 1: Direct Solver Code 31-32) note two back solves..

23 23 Option 2: Incomplete Cholesky Preconditioner We can use an incomplete Cholesky preconditioner in the PCG algorithm. The idea is to use cholinc to compute the Cholesky factorization with a drop tolerance used to determine if entries in the factor are created.

24 24 Sparsity of Incomplete Cholesky Factor cholinc(A, 1e-3) Only 93047 non-zero entriesOnly 68213 non-zero entries cholinc(A, ‘0’)

25 25 Iteration Count Per Time Step Comparing unpreconditioned and preconditioned with incomplete Cholesky:

26 26 Option 2: Incomplete Cholesky Preconditioner We can use an incomplete Cholesky preconditioner in the PCG algorithm. 30) Call to PCG uses incomplete Cholesky factorization.

27 27 Alternative Iterative Schemes in Matlab BICG, BICGSTAB, CGS, GMRES, LSQR, MINRES They all have the same interface. For details type: > help gmres


Download ppt "1 Spring 2003 Prof. Tim Warburton MA557/MA578/CS557 Lecture 34."

Similar presentations


Ads by Google