11c6d4a29SBarry Smith\documentclass[11pt,english,pdftex]{article} 21c6d4a29SBarry Smith\usepackage{hanging} % added DRE 31c6d4a29SBarry Smith\usepackage{times} 41c6d4a29SBarry Smith\usepackage{url} 51c6d4a29SBarry Smith\usepackage[T1]{fontenc} 61c6d4a29SBarry Smith\usepackage[latin1]{inputenc} 71c6d4a29SBarry Smith\usepackage{geometry} 81c6d4a29SBarry Smith\geometry{verbose,letterpaper,tmargin=1.in,bmargin=1.in,lmargin=1.0in,rmargin=1.0in} 91c6d4a29SBarry Smith 101c6d4a29SBarry Smith\begin{document} 111c6d4a29SBarry SmithConsider the matrix problem $ A x = b$, where $A = L + U + D$. 121c6d4a29SBarry Smith 131c6d4a29SBarry Smith\section*{Notes on SOR Implementation} 141c6d4a29SBarry Smith 151c6d4a29SBarry Smith 161c6d4a29SBarry SmithSymmetric successive over-relaxation as a simple iterative solver can be written as the two-step process 171c6d4a29SBarry Smith\[ 181c6d4a29SBarry Smithx_i^{n+1/2} = x_i^n + \omega A_{ii}^{-1}( b_i - \sum_{j < i} A_{ij} x_j^{n+1/2} - \sum_{j \ge i} A_{ij} x_j^{n}) = (1 - \omega) x_i^n + \omega A_{ii}^{-1}( b_i - \sum_{j < i} A_{ij} x_j^{n+1/2} - \sum_{j > i} A_{ij} x_j^{n}) 191c6d4a29SBarry Smith\] 201c6d4a29SBarry Smithfor $ i=1,2,...n$. Followed by 211c6d4a29SBarry Smith\[ 221c6d4a29SBarry Smithx_i^{n+1} = x_i^{n+1/2} + \omega A_{ii}^{-1}( b_i - \sum_{j \le i} A_{ij} x_j^{n+1/2} - \sum_{j > i} A_{ij} x_j^{n+1}) = (1 - \omega) x_i^{n+1/2} + \omega A_{ii}^{-1}( b_i - \sum_{j < i} A_{ij} x_j^{n+1/2} - \sum_{j > i} A_{ij} x_j^{n+1}) 231c6d4a29SBarry Smith\] 24*e87b5d96SPierre Jolivetfor $ i=n,n-1,....1$. It is called over-relaxation because generally $ \omega $ is greater than one, though on occasion underrelaxation with $ \omega < 1$ has the fastest convergence. 251c6d4a29SBarry Smith 261c6d4a29SBarry SmithTo use this as a preconditioner, just start with $x^0 = $ to obtain 271c6d4a29SBarry Smith\[ 281c6d4a29SBarry Smithx_i^{1/2} = \omega A_{ii}^{-1}( b_i - \sum_{j < i} A_{ij} x_j^{1/2}) 291c6d4a29SBarry Smith\] 301c6d4a29SBarry Smithfor $ i=1,2,...n$. Followed by 311c6d4a29SBarry Smith\[ 321c6d4a29SBarry Smithx_i = (1 - \omega) x_i^{1/2} + \omega A_{ii}^{-1}( b_i - \sum_{j < i} A_{ij} x_j^{1/2} - \sum_{j > i} A_{ij} x_j) 331c6d4a29SBarry Smith\] 341c6d4a29SBarry Smithfor $ i=n,n-1,....1$. 351c6d4a29SBarry Smith 361c6d4a29SBarry SmithRewriting in matrix form 371c6d4a29SBarry Smith\[ 381c6d4a29SBarry Smithx^{1/2} = \omega (L + D)^{-1} b 391c6d4a29SBarry Smith\] 401c6d4a29SBarry Smith\[ 411c6d4a29SBarry Smithx = (1 - \omega) x^{1/2} + \omega (U + D)^{-1}(b - L x^{1/2}) = x^{1/2} + \omega (U+D)^{-1}(b - A x^{1/2}). 421c6d4a29SBarry Smith\] 431c6d4a29SBarry Smith 441c6d4a29SBarry SmithFor the SBAIJ matrix format 451c6d4a29SBarry Smith\begin{verbatim} 461c6d4a29SBarry Smithv = aa + 1; 471c6d4a29SBarry Smith vj = aj + 1; 481c6d4a29SBarry Smith for (i=0; i<m; i++){ 491c6d4a29SBarry Smith nz = ai[i+1] - ai[i] - 1; 501c6d4a29SBarry Smith tmp = - (x[i] = omega*t[i]*aidiag[i]); 511c6d4a29SBarry Smith for (j=0; j<nz; j++) { 521c6d4a29SBarry Smith t[vj[j]] += tmp*v[j]; 531c6d4a29SBarry Smith } 541c6d4a29SBarry Smith v += nz + 1; 551c6d4a29SBarry Smith vj += nz + 1; 561c6d4a29SBarry Smith } 571c6d4a29SBarry Smith\end{verbatim} 5815229ffcSPierre Jolivetthe array $t$ starts with the value of $b $ and is updated a column of the matrix at a time to contain the value of $ (b - L x^{1/2})$ that 591c6d4a29SBarry Smithare then needed in the upper triangular solve 601c6d4a29SBarry Smith\begin{verbatim} 611c6d4a29SBarry Smith v = aa + ai[m-1] + 1; 621c6d4a29SBarry Smith vj = aj + ai[m-1] + 1; 631c6d4a29SBarry Smith nz = 0; 641c6d4a29SBarry Smith for (i=m-1; i>=0; i--){ 651c6d4a29SBarry Smith sum = 0.0; 661c6d4a29SBarry Smith nz2 = ai[i] - ai[i-1] - 1; 6750d8bf02SJed Brown PETSC_Prefetch(v-nz2-1,0,PETSC_PREFETCH_HINT_NTA); 6850d8bf02SJed Brown PETSC_Prefetch(vj-nz2-1,0,PETSC_PREFETCH_HINT_NTA); 691c6d4a29SBarry Smith PetscSparseDensePlusDot(sum,x,v,vj,nz); 701c6d4a29SBarry Smith sum = t[i] - sum; 711c6d4a29SBarry Smith x[i] = (1-omega)*x[i] + omega*sum*aidiag[i]; 721c6d4a29SBarry Smith nz = nz2; 731c6d4a29SBarry Smith v -= nz + 1; 741c6d4a29SBarry Smith vj -= nz + 1; 751c6d4a29SBarry Smith } 761c6d4a29SBarry Smith\end{verbatim} 771c6d4a29SBarry SmithSince the values in $ aa[]$ and $ aj[]$ are visited ``backwards'', the prefetch is used to load the needed previous row of matrix values and column indices into cache before they are needed. 781c6d4a29SBarry Smith 791c6d4a29SBarry SmithFor the AIJ format $t$ is updated a row at a time to contain $ (b - Lx^{1/2}).$ 801c6d4a29SBarry Smith 811c6d4a29SBarry Smith 821c6d4a29SBarry Smith\section*{Notes on Sequential Eisenstat Implementation} 831c6d4a29SBarry Smith 841c6d4a29SBarry Smith 851c6d4a29SBarry Smith\[ 861c6d4a29SBarry Smith x = \omega (L + D)^{-1}b 871c6d4a29SBarry Smith\] 881c6d4a29SBarry Smithis the same as 891c6d4a29SBarry Smith\[ 901c6d4a29SBarry Smith x_i = \omega D_{ii}^{-1}(b_i - \sum_{j<i} A_{ij} x_j) 911c6d4a29SBarry Smith\] 921c6d4a29SBarry Smith\[ 931c6d4a29SBarry Smith x_i = (D_{ii}/\omega)^{-1}(b_i - \sum_{j<i} A_{ij} x_j) 941c6d4a29SBarry Smith\] 951c6d4a29SBarry Smithresulting in 961c6d4a29SBarry Smith\[ 971c6d4a29SBarry Smith x = (L + D/\omega)^{-1}b 981c6d4a29SBarry Smith\] 991c6d4a29SBarry Smith 1001c6d4a29SBarry SmithRather than applying the left preconditioner obtained by apply the two step process $ (L + D/\omega)^{-1} $ and then $ (U + D/\omega)^{-1} $ 1011c6d4a29SBarry Smithone can apply the two ``halves'' of the preconditioner symmetrically to the system resulting in 1021c6d4a29SBarry Smith\[ 1031c6d4a29SBarry Smith (L + D/\omega)^{-1} A (U + D/\omega)^{-1} y = (L + D/\omega)^{-1} b. 1041c6d4a29SBarry Smith\] 1051c6d4a29SBarry SmithThen after this system is solved, $ x = (U + D/\omega)^{-1} y$. If an initial guess that is nonzero is supplied then the 1061c6d4a29SBarry Smithinitial guess for $ y$ must be computed via $ y = (U + D/\omega) x$. 1071c6d4a29SBarry Smith\begin{eqnarray*} 1081c6d4a29SBarry Smith (L + D/\omega)^{-1} A (U + D/\omega)^{-1} & = & (L + D/\omega)^{-1} (L + D + U) (U + D/\omega)^{-1} \\ 1091c6d4a29SBarry Smith & = & (L + D/\omega)^{-1} (L + D/\omega + U + D/\omega + D - 2D/\omega) (U + D/\omega)^{-1} \\ 1101c6d4a29SBarry Smith & = & (U + D/\omega)^{-1} + (L+D/\omega)^{-1}(I + \frac{\omega - 2}{\omega}D(U + D/\omega)^{-1}). 1111c6d4a29SBarry Smith\end{eqnarray*} 1121c6d4a29SBarry Smith 1131c6d4a29SBarry Smith\end{document} 114