May 3, 24 Page 1 of 18
1 gridpoints for pressure p: j i p, p 1, p 2, p 3, p 4, p,1 p 1,1 p 2,1 p 3,1 p 4,1 p,2 p 1,2 p 2,2 p 3,2 p 4,2 p,3 p 1,3 p 2,3 p 3,3 p 4,3 p,4 p 1,4 p 2,4 p 3,4 p 4,4 Page 2 of 18
2 j Definitions: A = 1 δy, B = 1 δy, C = 1 δx, D = 1 δx, E = 1 δy 2, F = 1 δx 2, G = 2 δx 2 2 δy 2 discrete Poisson equation for p (n+1) (red points): p i+1,j 2p i 1,j + p i 1,j δx 2 equation (i, j): i + p i,j+1 2p i,j + p i,j 1 δy 2 = RHS i,j E p i,j 1 + F p i 1,j + G p i,j + F p i+1,j + E p i,j+1 = RHS i,j Page 3 of 18
j Definitions: A = 1 δy, B = 1 δy, C = 1 δx, D = 1 δx, E = 1 δy 2, F = 1 δx 2, G = 2 δx 2 2 δy 2 boundary conditions (blue points): p 1,j p,j =, δx p i,1 p i, =, δy i p imax+1,j p imax,j = δx for all j = 1,, jmax, p i,jmax+1 p i,jmax = δy for all i = 1,, imax equation (, j): C p,j + D p 1,j =, equation (imax + 1, j): D p imax,j + Cp imax+1,j =, equation (i, ): A p i, + B p i,1 =, equation (i, jmax + 1): B p i,jmax + A p i,jmax+1 = Page 4 of 18
j Definitions: A = 1 δy, B = 1 δy, C = 1 δx, D = 1 δx, E = 1 δy 2, F = 1 δx 2, G = 2 δx 2 2 δy 2 unused corner points (green points): equation (, ): p, =, equation (imax + 1, ): p imax+1, =, equation (, jmax + 1): p,jmax+1 =, equation (imax + 1, jmax + 1): p imax+1,jmax+1 = i (as the values of these points are never used, you can replace by any other value) Page 5 of 18
3 Resulting System of Linear j A = 1 δy, B = 1 δy, C = 1 δx, D = 1 δx, 1 δy 2, F = E = G = 2 δx 2 2 δy 2 i 1 p, A B p 1, A B p 2, A B p 3, 1 p 4, C D p,1 p 1,1 RHS 1,1 p 2,1 RHS 2,1 p 3,1 RHS 3,1 D C p 4,1 C D p,2 p 1,2 RHS 1,2 p 2,2 = RHS 2,2 p 3,2 RHS 3,2 D C p 4,2 C D p,3 p 1,3 RHS 1,3 p 2,3 RHS 2,3 p 3,3 RHS 3,3 D C p 4,3 1 p,4 B A p 1,4 B A p 2,4 B A p 3,4 1 p 4,4 1 δx 2 Page 6 of 18
4 Reduced System of Linear Values to be computed: pressure at red points, thus reduce SLE 1) neglect p,, p imax+1,, p,jmax+1, and p imax+1,jmax+1 (never needed) 2) seperate boundary conditions from the rest of the SLE: p 1, p 1,1 p 2, p 2,1 p 3, p 3,1 p,1 p 1,1 p 4,1 p 3,1 p,2 = p 1,2, p 4,2 p 3,2 p,3 p 1,3 p 1,4 p 3,3 p 2,4 p 1,3 p 3,4 p 3,3 Page 7 of 18
3) remaining SLE for inner grid points: p 1, p 2, p 3, p,1 p 1,1 p 2,1 p 3,1 p 4,1 p,2 p 1,2 p 2,2 p 3,2 p 4,2 p,3 p 1,3 p 2,3 p 3,3 p 4,3 p 1,4 p 2,4 p 3,4 RHS 1,1 RHS 2,1 RHS 3,1 RHS 1,2 = RHS 2,2 RHS 3,2 RHS 1,3 RHS 2,3 RHS 3,3 Page 8 of 18
5 1) set boundary values (blue points) 2) solve the (quadratic) system of linear equations (for the pressure values at red points): G F E p 1,1 RHS 1,1 Ep 1, F p,1 F G F E p 2,1 RHS 2,1 Ep 2, F G E p 3,1 RHS 3,1 Ep 3, F p 4,1 E G F E p 1,2 RHS 1,2 F p,2 p 2,2 = RHS 2,2 E F G E p 3,2 RHS 3,2 F p 4,2 E G F p 1,3 RHS 1,3 F p,3 Ep 1,4 E F G F p 2,3 RHS 2,3 Ep 2,4 E F G p 3,3 RHS 3,3 F p 4,3 Ep 3,4 Remark: values at boundary (blue) points are transported to the right hand side as their are no longer unknown after step 1)!!! Use an iterative solver! Page 9 of 18
6 General Treatment of SLEs starting point: A x = b decomposition of A: A = B + D (B + D) x = b D x = b B x iteration: D x i+1 = b B x i or D x i+1 = D x i + b A x i Page 1 of 18
7 a 1,1 x i+1 = x i + D 1 ( b A x i ) with D := a n,n a 1,1 a 1,1 a n,n a n,n x i+1 1 x i+1 n x i 1 x i n ( x i+1 ir = x i ir + 1 b ir a ir,ir = + b 1 b n ) n a ir,ic x i ir ic=1 a 1,1 a 1,n a n,1 a n,n x i 1 x i n Page 11 of 18
(): for(it=;it<=itmax;it++){ for(ir=1;ir<=n;ir++){ sum=; for(ic=1;ic<=n;ic++) sum = sum + a ir,ic u ic ; v ir = u ir + (b ir sum)/a ir,ir ; } for(ir=1;ir<=n;ir++) u ir = v ir ; } Page 12 of 18
8 a 1,1 x i+1 = x i + D 1 ( b A x i ) with D :=, a n,1 a n,n a 1,1 a n,1 a n,n a 1,1 x i+1 1 x i+1 n x i 1 a n,1 a n,n x i n ( x i+1 ir = x i ir + 1 b ir a ir,ir = + ir is=1 b 1 b n a ir,is x i+1 is a 1,1 a 1,n a n,1 a n,n ) n a ir,is x i is is=ir+1 x i 1 x i n Page 13 of 18
(): for(it=;it<=itmax;it++) for(ir=1;ir<=n;ir++){ sum=; for(ic=1;ic<=n;ic++) sum = sum + a ir,ic u ic ; u ir = u ir + (b ir sum)/a ir,ir ; } no storage of an intermediate result necessary!!!!! Page 14 of 18
9 ion) ( x i+1 ir = x i ir+ω 1 a ir,ir b ir ir is=1 a ir,isx i+1 is ) n is=ir+1 a ir,isx i is (ω [1; 2]) : for(it=;it<=itmax;it++) for(ir=1;ir<=n;ir++){ sum=; for(ic=1;ic<=n;ic++) sum = sum + a ir,ic u ic ; u ir = u ir + ω(b ir sum)/a ir,ir ; } Page 15 of 18
1 Remarks: G F E p 1,1 RHS 1,1 Ep 1, F p,1 F G F E p 2,1 RHS 2,1 Ep 2, F G E p 3,1 RHS 3,1 Ep 3, F p 4,1 E G F E p 1,2 RHS 1,2 F p,2 p 2,2 = RHS 2,2 E F G E p 3,2 RHS 3,2 F p 4,2 E G F p 1,3 RHS 1,3 F p,3 Ep 1,4 E F G F p 2,3 RHS 2,3 Ep 2,4 E F G p 3,3 RHS 3,3 F p 4,3 Ep 3,4 Only five entries per line of the discretization matrix matrix is not to be stored completely!!!! (else: storage cost O(n 2 )!!) Use discretization stencil instead : δy 2 δx 2 2(δx 2 + δy 2 ) δx 2 δy 2 The discretization stencil looks the same for all inner (red) points discretization stencil doesn t have to be stored for each grid point, but only once or can even be directly encoded (see the following algorithm) Page 16 of 18
11 SOR- for Our Code general algorithm our algorithm for(it=;it<=itmax;it++) for(ir=1;ir<=n;ir++){ } sum = ; for(ic=1;ic<=n;ic++) sum = sum+a ir,ic u ic ; u ir = u ir + ω a ir,ir (b ir sum); for(it=;it<=itmax;it++) for(i=1;i<=imax;i++) for(j=1;j<=jmax;j++){ sum = p i+1,j+p i 1,j } ( p i,j p i,j = p i,j ω δx 2 + p i,j+1 +p i,j 1 δy 2 2 δx 2 2 2 + ); 2 δx 2 δy 2 δy 2 (b i,j sum); Page 17 of 18
12 Termination Criterion Final it = ; res = 1; while(res>=eps && it < itmax){ res = ; it = it + 1; for(i=1;i<=imax;i++) for(j=1;j<=jmax;j++){ } r = b i,j p i+1,j + p i 1,j δx 2 p i,j = p i,j ω 2 2 r; δx 2 δy 2 res = res + r r; } res = res; p i,j+1 + p i,j 1 δy 2 + p i,j ( 2 δx + 2 ) ; 2 δy 2 Page 18 of 18