Computing coefficients in the linear basis functions for 2D FEM

numerical linear algebranumerical methods

I am currently looking to write a GFEM code but to do this I need to truly understand the construction of a standard FEM code in 2D.

For the example we will be taking triangluar elements (K) with coordinates $(x_1,y_1),\ (x_2,y_2),\ (x_3,y_3)$. Now we know that the linear hat function can be written in the following way:

\begin{equation} \phi_i = a_i + b_ix + c_iy \end{equation}

where for every node, N_i we will have
$$ \phi_i(N_j) = \begin{cases} 1, \ i=j \\ 0,\ i\neq j \end{cases}$$.

Now this makes sense and I have been using it in my research until now. The issues being is how do we compute the next part? (which I have always taken for granted)

We can then find that the coefficients are:
$$ a_i = \frac{x_jy_k – x_ky_j}{2|\mathbf{K}|},\quad b_i = \frac{y_j-y_k}{2|\mathbf{K}|},\quad c_i = \frac{x_k-x_j}{2|\mathbf{K}|} $$,

where $|\mathbf{K}|$ is the area of the triangle,

$$ det(K) = \begin{vmatrix} x_1 & x_2 & x_3\\ y_1 & y_2 & y_3 \end{vmatrix} $$.

Applying the condition above gives:
$$ 1 = a _1 + b_1x_1 + c_1y_1 \\ 1 = a _2 + b_2x_2 + c_2y_2 \\ 1 = a _3 + b_3x_3 + c_3y_3,$$
but I am unsure how to proceed from here as these equations are independent of one another.
If someone could help me get derive the formulas for $a_i$ etc that would be great!

Thanks in advance.

Best Answer

The condition is: $$\phi_i(N_j) = \delta_i^j$$ where $\phi_i$ is the hat function on the triangle defined by the nodes $(x_i,y_i)$, with $i=1,2,3$.

Look WLOG at the $\phi_1$: you have $\phi_1(x_1)=1, \phi_1(x_2)= \phi_1(x_3)=0$, i.e. the following system needs to be solved for $(a_1,b_1,c_1)$.

$\begin{bmatrix} 1 & x_1 & y_1 \\ 1 & x_2 & y_2 \\ 1 & x_3 & y_3 \end{bmatrix} \begin{bmatrix} a_1 \\ b_1 \\ c_1 \end{bmatrix}= \begin{bmatrix} 1\\0\\0 \end{bmatrix}$

The determinant of the matrix is equal to $2|K|$, by elementary geometry. Then, the solution can be obtained pretty easily by Cramer's rule: $$a_1 = \frac{x_2 y_3 - x_3 y_2}{2|K|}$$

$$b_1=\frac{y_2-y_3}{2|K|}$$

$$c_1=\frac{x_3-x_2}{2|K|}$$

The argument above can be easily extended in order to obtain the general formula for $a_i,b_i,c_i$.