multigrid method multigrid methods (mgm) algebraic multigrid method (amg) geometric multigrid mehod...
Post on 19-Dec-2015
239 Views
Preview:
TRANSCRIPT
MULTIGRID METHOD
MultiGridMethods(MGM)
Algebraic MultiGrid
Method(AMG)
Geometric MultiGrid
Mehod(GMG)
MULTIGRID METHOD
Remark:
Given an approximate:
We want to improve this approximate:
x
bAx
xAbr
xAAxr )( xxAr
(residual)
xxe (error)
Aer
Residual Equation: rAeIt means that if we replace the right hand side vector b in the main linear system, the solution of this new system is the exact error
exx (update)
But the cost of solving this system is the same as solving the original system.
MULTIGRID METHOD (GMG)
H
h hhh bxA
HHH bxA Two-Grid Cycle Algorithm
1) few GS iterations on the system hhh bxA
2) Compute the residual
to obtain an approximate solutionhx
hhh xAbr 3) Restrict the residual h
TH rPr
4) Solve residual equation on coarse mesh HHH reA
5) Interpolate Hh Pee
6) Update hhh exx
7) few GS iterations on the system hhh bxA With initial approximate hx
Pre-smoothing step
Restriction step
Prolongation step
Post-smoothing step
ProloCorrection step
MULTIGRID METHOD (GMG)
V - Cycle
W - Cycle
presmoothing
postsmoothingrestriction
prolongationDirect solver
MULTIGRID METHOD (GMG)
function [sol]=jacobi(A,b,x0,steps)n=length(b);x=x0;xnew = sparse(n,1);for k=1:stepsfor i=1:n sum1=0; for j=1:i-1 sum1=sum1+A(i,j)*x(j); end sum2=0; for j=i+1:n sum2=sum2+A(i,j)*x(j); end xnew(i)=(b(i)-sum1-sum2)/A(i,i);endx=xnew;endsol=xnew;
Jacobi code
MULTIGRID METHOD (GMG)one-dimensional problems
H
h
Coarse mesh
Fine mesh
Hj
hS
HS
We have the inclusionhH SS
hiHj ofn combinatiolinear
0)1()0(
''
uu
fu
Example:
MULTIGRID METHOD (GMG)
hS
hj2h
j 12 hj 12
hj
hj
hj
Hj 122
12122
1
This means that the j-th column of P, corresponding to coarse grid node j, has the form
TjP 0,,0,,1,,0,,02
1
2
1:,
2
1
2
1
2
1
2
1
2
1
2
1
1
1
1
P
TWO GRID METHOD
nf=2*55-1; % number of fine nodesh=1/(nf+1); % fine mesh sizexh=0:h:1; % fine meshoneh=ones(nf,1);Ah=spdiags([-oneh 2*oneh -oneh],-1:1,nf,nf)/h; % fine stiffness matrixbh=ones(nf,1)*h; % fine load vector
nc=(nf-1)/2; % coarse nodesH=1/(nc+1); % coarse mesh sizexH=0:H:1; % coarse meshoneH=ones(nc,1);AH=spdiags([-oneH 2*oneH -oneH],-1:1,nc,nc)/H; % coarse stiffness matrix
uh=zeros(nf,1); % initial guessP=sparse(nf,nc); % prolongation matrixfor i=1:nc P(2*i-1,i)=0.5; P(2*i,i)=1; P(2*i+1,i)=0.5;endR=P'; % Restriction matrixfor k=1:5 [uh]=jacobi(Ah,bh,uh,2); rH=R*(bh-Ah*uh); % Restricted residual eH=AH\rH; % correction step uh =uh+P*eH; % updateendplot(xh,[0 ; uh ; 0]), xlabel('x'), ylabel('u'); grid on
Two Grid
TWO GRID METHODnf=2*55-1; % number of fine nodesh=1/(nf+1); % fine mesh sizexh=0:h:1; % fine meshoneh=ones(nf,1);Ah=spdiags([-oneh 2*oneh -oneh],-1:1,nf,nf)/h; % fine stiffness matrixbh=ones(nf,1)*h; % fine load vector
hhh bxA
nc=(nf-1)/2; % coarse nodesH=1/(nc+1); % coarse mesh sizexH=0:H:1; % coarse meshoneH=ones(nc,1);AH=spdiags([-oneH 2*oneH -oneH],-1:1,nc,nc)/H; % coarse stiffness matrix
HHH bxA
uh=zeros(nf,1); % initial guessP=sparse(nf,nc); % prolongation matrixfor i=1:nc P(2*i-1,i)=0.5; P(2*i,i)=1; P(2*i+1,i)=0.5;endR=P'; % Restriction matrixfor k=1:5 [uh]=jacobi(Ah,bh,uh,2); rH=R*(bh-Ah*uh); % Restricted residual eH=AH\rH; % correction step uh =uh+P*eH; % updateendplot(xh,[0 ; uh ; 0]), xlabel('x'), ylabel('u'); grid on
hT
H rPr HHH reA
MULTIGRID METHOD (GMG)
V - Cycle
u = V_cycle(A,b,u,level)few GS iterations on the system bAu If coarsest level :
else
)( AubRr
)1,,,(V_cycle levelerAe
ePue
Pre-smooth
Restriction
Prolong & update
Post-smooth
Recursive coarse grid correction
bAu solve
0e
endif
few GS iterations on the system bAu
multigrid V-cycle is given by the following recursive algorithm: [Elman, Howard C., David Silvester, and Andy Wathen. Finite elements and fast iterative solvers: with applications in incompressible fluid dynamics. Oxford University Press, 2014.] page102
MULTIGRID METHOD (GMG)
V – Cycle3 level
u = V_cycle(A,b,u,level)few GS iterations on the system bAu If coarsest level :
else
)( AubRr
)1,,,(V_cycle levelerAe
ePue
Pre-smooth
Restriction
Prolong & update
Post-smooth
Recursive coarse grid correction
bAu solve
0e
endif
few GS iterations on the system bAu
111 hhh bxA
222 hhh bxA
333 hhh bxA
MULTIGRID METHOD (GMG)
V – Cycle3 level
111 hhh bxA
222 hhh bxA
333 hhh bxA
clear; clckk=6; n1=4*kk+3; % --- linear system for level 1h1=1/(n1+1); x1=0:h1:1; oneh1=ones(n1,1);A1=spdiags([-oneh1 2*oneh1 -oneh1],-1:1,n1,n1)/h1; b1=ones(n1,1)*h1; % --- linear system for level 2n2=(n1-1)/2; h2=1/(n2+1); x2=0:h2:1; oneh2=ones(n2,1);A2=spdiags([-oneh2 2*oneh2 -oneh2],-1:1,n2,n2)/h2; b2=ones(n2,1)*h2; % --- linear system for level 3n3=(n2-1)/2; h3=1/(n3+1); x3=0:h3:1; oneh3=ones(n3,1);A3=spdiags([-oneh3 2*oneh3 -oneh3],-1:1,n3,n3)/h3; b3=ones(n3,1)*h3;
A(1).size = n1; A(1).h = h1; A(1).mat = A1; A(1).rhs = b1;A(2).size = n2; A(2).h = h2; A(2).mat = A2; A(2).rhs = b2;A(3).size = n3; A(3).h = h3; A(3).mat = A3; A(3).rhs = b3;b = b1; u = sparse(length(b),1); level =3;[u] = V_Cycle(A(1:level),b,u,level);
MULTIGRID METHOD (GMG)function [u] = V_Cycle(A,b,u,level)if level < 1; return ; enddisp(['I am entering level ',num2str(level)]) if size(A,2) == 1 AA = A(1).mat; u = AA\b; disp(' ---coarset level done ---');else [u]=jacobi(A(1).mat,b,u,3); % (3 pre-smoothing) nf = A(1).size; nc = A(2).size; P=sparse(nf,nc); for i=1:nc P(2*i-1,i)=0.5; P(2*i,i)=1; P(2*i+1,i)=0.5; end R=P'; AA = A(1).mat; rbar = R*(b-AA*u); % (restrict residual) ebar = sparse(length(rbar),1); Abar = A(2:level); % --------- recursive coarse grid correction ---- [ebar] = V_Cycle(Abar,rbar,ebar,size(Abar,2)); u = u + P*ebar; % prolong and update end[u]=jacobi(A(1).mat,b,u,3);disp(['I am exiting level ',num2str(level)])end
u = V_cycle(A,b,u,level)
few GS iterations on the system bAu If coarsest level :
else )( AubRr
)1,,,(V_cycle levelerAe
ePue
Pre-smooth
Restriction
Prolong & update
Post-smooth
Recursive coarse grid correction
bAu solve
0e
endif
few GS iterations on the system bAu
MULTIGRID METHOD
MultiGridMethods(MGM)
Algebraic MultiGrid
Method(AMG)
Geometric MultiGrid
Mehod(GMG)
MULTIGRID METHOD (AMG)
Algebraic MultiGrid
Method(AMG)
Can we apply multigrid techniques when there is no grid?
bAu For AMG, these components are required.
1)sequence of grids, 2)P and R3)smoothing4)coarse-grid versions of the fine-grid operator
5) a solver for the coarsest grid.
,,, 321 hhh
,,, 321 hhh AAA
MULTIGRID METHOD (AMG)
Algebraic MultiGrid
Method(AMG)
bAu
Adjacency GraphSelecting the Coarse Grid
we want to partition the grid points into C-pints and F-points.
Denote by Si the set of points that strongly influence i;denote by ST the set of points that strongly depend on the point i.
top related