I have to program the linear finite element method in 2D, and I d like to ask some question about the method.
The PDE I have to solve is: $-\bigtriangleup u+cu=f$ and $u(x,y)=g(x,y)$ in the boundary. The set is the unit square and the boundary. Triangulization has to be made of $N^2$ squares. c is nonnegative constat. The simplest one.
-First of all I know its equivalent to solve linear system s.t.:
$A \alpha =F$ s.t $F=(f_x)_{x\in N_h}$ with $x \in$ $N_h= (x_k,x_l)$ with $x_k=k/N,x_l=l/N$ and A is the matrix of $a(\phi_x,\phi_y)=\int_{\ [0,1]^2} \bigtriangledown \phi_x \bigtriangledown \phi_y dxdy$ and $\phi_x(y)=$ 1 if x=y, 0 otherwise.
My first question is, this is when $g=0$ but what happens now?
Second one, how can I program this functions in Matlab. Once I have this function defined, how it looks like the matrix, because its sparse matrix, a lot of terms would be 0 due to the definition of $\phi$