Understand 1D FEM solution using quadratics elements

Solution 1:

This question doesn't have anything to do with finite difference methods, but you probably got the attention of the right people anyway. I think you're missing the idea that you actually have 2 functions in the linear case, not just 1. The "hat function" is really something that arises when you plot the basis functions globally. These are derived from a similar reference element as well though:

Given a 1d linear reference element on $[-1, 1]$, and nodes $\xi_1 = -1, \xi_2 = +1$, with shape functions:

$$ \psi_1(\xi)=-\frac{1}{2}(\xi-1) \quad \psi_2(\xi)=\frac{1}{2}(\xi+1) $$

This set of functions also satisfies the "partition of unity" requirement, just like the quadratic shape functions. The hat functions $\phi_j$ are really just these shape functions mapped from the reference element to the problem domain.

The only change when you go from linear to quadratic elements is that you now are using 3 nodal values and 3 shape functions to interpolate solutions over the rest of the element rather than 2 of each.

Interpolating solutions is exactly the same once you realize this.

1) Locate the element that contains $x$

2) Find the value of $\xi$ corresponding to the value of $x$ within that element

3) Interpolate using the shape functions:

$$ u(x)=\sum_{i=1}^N u_i \psi_i(\xi) $$

where $N$ is the number of nodes in the element and $i$ is the local, not global, index number.

In practice, it is difficult (and unnecessary) to obtain analytical forms of the shape functions in global coordinates, especially when you move to higher dimensions. For this reason, when people say "shape function", they are almost invariably referring to the shape function in the reference element coordinates, so you don't really need a $\phi(x)$ function like you were thinking.

Solution 2:

Any function $f$ at your quadratic element is interpolated with finite element shape functions, where $(1,2,3)$ are the the nodes (three of them, from the left to the right): $$f(\xi) = \frac{1}{2}\xi(\xi-1) f_1 + (1-\xi^2)f_2 + \frac{1}{2}\xi(\xi+1) f_3$$ This is equivalent with a finite difference representation: $$f(\xi) = f_2 + \frac{1}{2}(f_3 - f_1) \xi + \frac{1}{2}(f_3 - 2 f_2 + f_1) \xi^2$$ Where discretizations of the zero'th, first and second derivative are recognized. Your local nodes obey the same equations, due to isoparametrics: $$z = z_2 + \frac{1}{2}(z_3 - z_1) \xi + \frac{1}{2}(z_3 - 2 z_2 + z_1) \xi^2$$ Therefore if $\,z_2 = (z_1 + z_3)/2$ , as you say, then $z_3 - 2 z_2 + z_1 = 0$. With other words: the quadratic term simply drops out and what we finally have is the same linear element as before.
Due to isoparametrics, the same is valid for any $\,f$, resulting in: $$f_2 = \frac{f_1 + f_3}{2} \quad ; \quad f(\xi) = f_2 + \frac{1}{2}(f_3 - f_1) \xi = \frac{1}{2}(1-\xi) f_1 + \frac{1}{2}(1+\xi) f_3$$ So it's my theory that, e.g. with an equidistant grid, quadratic elements aren't useful. But I have a personal bias towards linear elements, admittedly :-)