Isogeometric Analysis and Finite Element Method
It’s been some years since I completed my dissertation on FEM and Isogeometric Analysis, but I realised I never had the time to organise my code properly and archive it. So I archived a part of it in a new repo here: https://github.com/carlonluca/isogeometric-analysis. It may be useful for someone studying the topic.
The main topic of the dissertation is not the Finite Element Method (FEM) actually, but the first and the second chapters present it and I wrote a basic implementation that works for 1D problems here: https://github.com/carlonluca/isogeometric-analysis/blob/master/2.3/drawFEM1DExample.m. The first example uses the implementation to compute an approximation using FEM.
Problem
In the code, the first example solves the differential equation:
Exact solution
It is possible to find an exact solution by integrating both parts twice:
The solution of the system:
is the exact solution to the problem:
Weak Formulation
To calculate the weak formulation we need to first define a Dirichlet lift, as the boundary conditions are non-homogeneous:
Multiply by a test function $\varphi\in C_{0}^{\infty}(\Omega)$:
Now integrate both parts:
Using the technique of integration by parts:
we can get to:
$\varphi$ is a distribution and it therefore vanishes on the boundary:
It is now possible to define the two terms:
Galerkin Method
At this point, the Galerkin method can be applied if we accept to look for an approximate solution in a space $V_{n}$ of dimension $dim(V_{n})=n$. Thus, assuming $\left\{ v_{i}\right\} _{i=0}^{n-1}$ is a basis for $V_{n}$, then we can write our approx solution:
where $\left\{ \bar{v}_{i}\right\} _{i=0}^{n-1}$ are coefficients of the linear combination.
We can create a linear system with $n$ independent equations that can be written in matrix form as:
where:
The basis functions $\left\{ v_{i}\right\} _{i=0}^{n-1}$ can be chosen according to the needs. In the example, simple roof functions are used: https://github.com/carlonluca/isogeometric-analysis/blob/master/2.3/computePhi.m and https://github.com/carlonluca/isogeometric-analysis/blob/master/2.3/computeDphi.m (note that nomenclature in the code is slightly different). Different approximations can be achieved with a different basis for the space $V_{n}$.
A possible choice for the Dirichlet lift is:
which is the one that is used in the example implementation.
Result
The example script solves the problem for $n=2,…,7$. As expected with FEM, the approximation is exact at the nodes. By increasing the dimension of the space where the solution is to be found, the approximation gets closer to the exact curve.
Lagrange Polynomials
In the previous implementation, roof functions were used. It is possible to use piecewise-polynomials of higher order. One possible implementation is Lagrange polynomials.
In the repo there is a sample implementation. The demo draws Lagrange polynomials interpolating an increasing number of points: