I'm trying to discretise the following 2D poisson equation:
$-(u_{xx} + u_{yy}) = f(x,y)$ with boundary condition
$u(x,y) = g(x,y)$.
I'm aiming to solve it using the finite difference method, specifically a 5-point stencil which results in a linear system
$\textbf{AU=F}$.
I have managed to determine the A matrix however, I can't seem to figure out how to implement the boundary conditions. Note that the discretised equation in this case is:
$\frac{1}{h^2}(4U_{i,j} - U_{i-1,j} - U_{i,j-1} - U_{i+1,j} - U_{i,j+1}) = f(x_i,y_j) 1 \leq i,j \leq m$
I understand that the boundary conditions allow us to find out the values of any U on the boundaries, but i can't figure out how to implement it in the discretised problem.
many thanks
If $(x_i,y_j)$ is a boundary node, the equation you presented becomes simply $$ U_{i,j}=g(x_i,y_i). $$