Project: Finite Difference Methods

The purpose of this project is to write a finite difference code for solving the Poisson equation in a rectangular domain using matrix-free or tensor product matrix.

Reference:

Contents

Step 1: Generate a uniform grid and evaluate the right hand side

Use meshgrid or ndgrid to generate a uniform grid of $(0,1)\times (0,2)$ for a given mesh size $h$.

Evaluate f(x,y) at this uniform grid.

Step 2: Implement A*u

Compare the following three ways of computing A*u

Use them to verify the truncation error. That is, choosing the exact solution u and compute the max norm | A*u - f |. Change h and check the order of truncation error.

Step 3: Impose boundary conditions

Dirichlet boundary condition Evaluate the boundary condition at boundary vertices and move to the right hand side.

Neumann boundary condition Change the stencil near the boundary and modify the right hand side.

Step 4: Solve linear algebraic systems

while err > tol
 u = B(u,f);
 err = norm(f-A*u);
end

Step 5: Convergence