Scientific Computation - Prof. Achi Brandt

Final - Project

Solve the Cauchy Schwartz equations using a V-cycle. This is a recursive algorithm based on cycles in which a fine grid equation is solved on a coarser and coarser grids.
(rounds,n1,n2) - are the number of V-cycles and sweeps to perform in the algorithm before and after the recursion

 


Program:

- final.m

-build_example.m

-V_cycle.m
-relax_F.m  
-relax_G.m
-downscale.m
                 -calc_error.m
-solve_direct.m
-V_cycle.m
-upscale.m
-relax_F.m
-relax_G.m

Command:   final(rounds,n1,n2)

Files: Project.zip


Notes:

1) The Kacmarz relaxation is being used here where we introduce a dummy variable w which represents the change in all directions, i.e., solve

    ((U[i,j+1] + w) - (U[i,j-1] - w))/2h +
    ((V[i+1,j] + w) - (V[i-1,j] - w))/2h = F[i,j]

 

2) The downscale procedure uses the following masks to transfer the residual of F and G to the smaller matrix:

mask_F = [.25 0 .25 ; 0 0 0; .25 0 .25]

mask_G = [ 1/16 0 1/8 0 1/16
                     0    0   0  0   0
                   1/8   0 1/4 0 1/8
                     0    0   0  0  0
                   1/16 0 1/8 0 1/16 ]

3) Upscaling is performed by placing the results in a twice bigger matrix and interpolating the result for intermediate cells.

4) The (standard matlab) norm results are calculated for the difference matrices of the original U and V and the calculated U and V. For this presentation these are taken without a boundary of 2 rows/columns (this is to compensate for the fact that the boundary cells are fixed and cannot converge and since the staggered grid structure forces us to work on smaller F and G matrices than the input matrices).

5) The examples are built as follows: The functions U and V are given as input. Then the F and G functions are calculate discretely for each point from the discrete value of the derivative of U and V. Finally the initial matrix is assembled from the staggered grid of F and G the boundary cells copied from U and V and random values in all other cells.

Results: The following are 5 examples of the execution of the program. Each figure gives the graphs of two function U and V, one plot the original function and the other plots the reconstructed functions from their Cauchy Swartz Equations.

*  The number of V-cycles is 5 and the number of sweeps used is 3 at the beginning and 3 at the end of each cycle.

  Size - 64 Size - 128 Size - 256
Example1 img img img
Example2 img img img
Example3 img img img
Example4 img img img
Example5 img img img