# Nonlinear finite elements/Model finite element approximation

## Finite Element Formulation for Problem 2.

The domain for this problem is ${\displaystyle \Omega =\{x~|~x\in (0,1)\}}$  and the boundary consists of two points ${\displaystyle \Gamma =\{0,1\}}$ . Let us use ${\displaystyle n}$  nodes in the domain so that they divide the domain into ${\displaystyle n-1}$  nonoverlapping, two-noded elements.

Consider the term ${\displaystyle K_{ij}}$  in equation (22). The integral can be written as a sum of integrals over each element as

{\displaystyle {\begin{aligned}K_{ij}&=\int _{0}^{1}\left({\cfrac {dN_{i}}{dx}}{\cfrac {dN_{j}}{dx}}+N_{i}N_{j}\right)~dx\\{\text{(29)}}\quad &=\int _{0}^{x_{1}}\left({\cfrac {dN_{i}}{dx}}{\cfrac {dN_{j}}{dx}}+N_{i}N_{j}\right)~dx+\int _{x_{1}}^{x_{2}}\left({\cfrac {dN_{i}}{dx}}{\cfrac {dN_{j}}{dx}}+N_{i}N_{j}\right)~dx+\dots +\int _{x_{j-1}}^{x_{j}}\left({\cfrac {dN_{i}}{dx}}{\cfrac {dN_{j}}{dx}}+N_{i}N_{j}\right)~dx\\&~~~+\int _{x_{j}}^{x_{j+1}}\left({\cfrac {dN_{i}}{dx}}{\cfrac {dN_{j}}{dx}}+N_{i}N_{j}\right)~dx+\dots +\int _{x_{n-1}}^{x_{n}}\left({\cfrac {dN_{i}}{dx}}{\cfrac {dN_{j}}{dx}}+N_{i}N_{j}\right)~dx~.\end{aligned}}}

In this equation, ${\displaystyle i}$  and ${\displaystyle j}$  are node numbers. Therefore there are ${\displaystyle n\times n}$  possible values of ${\displaystyle K_{ij}}$ .

Assume that node ${\displaystyle i}$  = 2 and node ${\displaystyle j}$  = 4. Then ${\displaystyle N_{i}=1}$  at node 2 and zero at all the other nodes. Similarly, ${\displaystyle N_{j}=1}$  at node 4 and zero at all other nodes. Also, ${\displaystyle N_{i}}$  is non-zero only between nodes 1, 2, and 3 while ${\displaystyle N_{j}}$  is nonzero only between nodes 3, 4, and 5. Since the domains of ${\displaystyle N_{i}}$  and ${\displaystyle N_{j}}$  do not overlap in this case, all the integrals must be zero.

In general, if ${\displaystyle i}$  and ${\displaystyle j}$  are separated by more than one node, at least one of the basis functions has a zero value within each integral. The same holds for the derivatives of the basis functions. Therefore ${\displaystyle K_{ij}=0}$  if ${\displaystyle i}$  and ${\displaystyle j}$  are separated by more than one node.

Therefore, there are three non-trivial cases that need to be looked at

1. ${\displaystyle i=j}$ .
2. ${\displaystyle i=j-1}$ .
3. ${\displaystyle i=j+1}$ .

For the first case, set ${\displaystyle i=j}$  in equation (29). That means

${\displaystyle {\text{(30)}}\qquad \int _{0}^{1}\left({\cfrac {dN_{j}}{dx}}{\cfrac {dN_{j}}{dx}}+N_{j}N_{j}\right)~dx=\int _{x_{j-1}}^{x_{j}}\left({\cfrac {dN_{j}}{dx}}{\cfrac {dN_{j}}{dx}}+N_{j}N_{j}\right)~dx+\int _{x_{j}}^{x_{j+1}}\left({\cfrac {dN_{j}}{dx}}{\cfrac {dN_{j}}{dx}}+N_{j}N_{j}\right)~dx~.}$

After substituting the values of the basis functions (25) and their derivatives (26) into equation (30) and integrating, we get

${\displaystyle {K_{jj}=\int _{0}^{1}\left({\cfrac {dN_{j}}{dx}}{\cfrac {dN_{j}}{dx}}+N_{j}N_{j}\right)~dx={\cfrac {1}{x_{j}-x_{j-1}}}+{\cfrac {1}{x_{j+1}-x_{j}}}+{\cfrac {x_{j+1}-x_{j-1}}{3}}~.}}$

For the second case, set ${\displaystyle i=j-1}$  in equation (29). In this case, the only non-zero integrals in equation (29) are the ones between ${\displaystyle x_{j-1}}$  and ${\displaystyle x_{j}}$ . Hence

${\displaystyle {\text{(31)}}\qquad \int _{0}^{1}\left({\frac {dN_{j-1}}{dx}}{\frac {dN_{j}}{dx}}+N_{j-1}N_{j}\right)~dx=\int _{x_{j-1}}^{x_{j}}\left({\frac {dN_{j-1}}{dx}}{\frac {dN_{j}}{dx}}+N_{j-1}N_{j}\right)~dx~.}$

After substituting the basis functions and their derivatives into equation (31) and integrating, we get

${\displaystyle {K_{(j-1)j}=\int _{0}^{1}\left({\frac {dN_{j-1}}{dx}}{\frac {dN_{j}}{dx}}+N_{j-1}N_{j}\right)~dx=-{\frac {1}{x_{j}-x_{j-1}}}+{\frac {x_{j}-x_{j-1}}{6}}~.}}$

For the third case, set ${\displaystyle i=j+1}$  in equation (29). In this case, the only non-zero integrals in equation (29) are the ones between ${\displaystyle x_{j}}$  and ${\displaystyle x_{j+1}}$ . Hence

${\displaystyle {\text{(32)}}\qquad \int _{0}^{1}\left({\frac {dN_{j}}{dx}}{\frac {dN_{j+1}}{dx}}+N_{j}N_{j+1}\right)~dx=\int _{x_{j}}^{x_{j+1}}\left({\frac {dN_{j}}{dx}}{\frac {dN_{j+1}}{dx}}+N_{j}N_{j+1}\right)~dx~.}$

After substituting the basis functions and their derivatives into equation (\ref{eq:Integralij+1}) and integrating, we get

${\displaystyle {K_{j(j+1)}=\int _{0}^{1}\left({\frac {dN_{j}}{dx}}{\frac {dN_{j+1}}{dx}}+N_{j}N_{j+1}\right)~dx=-{\frac {1}{x_{j+1}-x_{j}}}+{\frac {x_{j+1}-x_{j}}{6}}~.}}$

The same process can be followed for the integral

${\displaystyle {f_{j}=\int _{0}^{1}x~N_{j}~dx=\int _{x_{j-1}}^{x_{j}}x~N_{j}~dx+\int _{x_{j}}^{x_{j+1}}x~N_{j}~dx={\cfrac {2x_{j}^{3}-3x_{j}^{2}x_{j-1}+x_{j-1}^{3}}{6(x_{j}-x_{j-1})}}+{\cfrac {2x_{j}^{3}-3x_{j}^{2}x_{j+1}+x_{j+1}^{3}}{6(x_{j+1}-x_{j})}}~.}}$

Now that we know the components ${\displaystyle K_{ij}}$  and ${\displaystyle f_{j}}$ , we can solve the system of equations (23) for the unknowns ${\displaystyle a_{i}}$ . This gives us our finite element solution for Problem 2.

### Assembly process.

In the above we did not go through the assembly process that you are familiar with from introductory finite elements. We can simplify things if we use just compute the integrals over each element and assemble them to get the final ${\displaystyle \mathbf {K} }$  and ${\displaystyle \mathbf {f} }$  matrices.

To see how the assembly process works, let us recall equation (21)

${\displaystyle {\text{(33)}}\qquad {\sum _{i=1}^{n}a_{i}\int _{0}^{1}\left({\cfrac {dN_{i}}{dx}}{\cfrac {dN_{j}}{dx}}+N_{i}N_{j}\right)~dx-\int _{0}^{1}x~N_{j}~dx=0\qquad j=1\dots n~.}}$

We can rewrite this equation as

${\displaystyle \sum _{i=1}^{n}K_{ji}a_{i}=f_{j}\qquad \equiv \qquad \sum _{i=1}^{n}K_{ij}a_{i}=f_{j}}$

where

${\displaystyle {\text{(34)}}\qquad K_{ij}=a(N_{i},N_{j})=\int _{0}^{1}\left({\cfrac {dN_{i}}{dx}}{\cfrac {dN_{j}}{dx}}+N_{i}N_{j}\right)~dx\qquad {\text{and}}\qquad f_{j}=\langle x,N_{j}\rangle =\int _{0}^{1}x~N_{j}~dx~.}$

Let us define

${\displaystyle {\text{(35)}}\qquad {\mathcal {F}}(N_{i},N_{j}):={\cfrac {dN_{i}}{dx}}{\cfrac {dN_{j}}{dx}}+N_{i}N_{j}~.}$

Then the first of the equations in (34) can be written as

${\displaystyle {\text{(36)}}\qquad a(N_{i},N_{j})=\int _{0}^{1}{\mathcal {F}}(N_{i},N_{j})~dx~.}$

From equation (29) we can see that the integral over the entire domain ${\displaystyle \Omega }$  can be written as a sum of integrals over the elements ${\displaystyle \Omega _{e}}$ . Therefore, we can write equation (36) as

${\displaystyle {\text{(37)}}\qquad a(N_{i},N_{j})=\int _{\Omega }{\mathcal {F}}(N_{i},N_{j})~dx=\sum _{e=1}^{E}\int _{\Omega _{e}}{\mathcal {F}}(N_{i},N_{j})~dx~.}$

Let ${\displaystyle N_{i}^{e}}$  be the local basis functions in an element. Then equation (37) can be written as

${\displaystyle a(N_{i},N_{j})=\sum _{e=1}^{E}\int _{\Omega _{e}}{\mathcal {F}}(N_{i}^{e},N_{j}^{e})~dx=\sum _{e=1}^{E}a^{e}(N_{i}^{e},N_{j}^{e})=\sum _{e=1}^{E}K_{ij}^{e}~.}$

Similarly, the second equation in (34) can be written as

${\displaystyle \langle x,N_{j}\rangle =\sum _{e=1}^{E}\langle x^{e},N_{j}^{e}\rangle =\sum _{e=1}^{E}f_{j}^{e}}$

where ${\displaystyle x^{e}}$  indicates that the integral is over the element.

Therefore, the matrix ${\displaystyle \mathbf {K} }$  and the vector ${\displaystyle \mathbf {f} }$  can be expressed as a sum over the elements in the form

${\displaystyle \mathbf {K} =\sum _{e=1}^{E}\mathbf {K} ^{e}\qquad {\text{and}}\qquad \mathbf {f} =\sum _{e=1}^{E}\mathbf {f} ^{e}~.}$

This is the familiar assembly process. From this process it is clear that if we can find the weak form for one element, then the finite element system of equations for any combination of such elements can be computed by assembly.