Table of contents

Video lectures

Variational Formulation - The weak form

We cannot directly tackle the strong form of a differential equation to create the FEM. The first step in the FEM is to derive the weak form (or variational form) of the strong form.

Consider the model problem

{ddx(kdudx)=f(x)for x[0,L]kdudx(L)=qu(0)=u0\begin{cases} -\frac{d}{dx}\left(k\dfrac{du}{dx}\right)=f(x) & \text{for }x\in[0,L]\\ k\dfrac{du}{dx}(L)=-q\\ u(0)=u_{0} \end{cases}

From the strong form we can formulate the residual function

r(x)=f(x)+ddx(kdudx)=0r(x)=f(x)+\frac{d}{dx}\left(k\dfrac{du}{dx}\right)=0

This strong form must hold everywhere for x[0,L]x\in[0,L]. Now, the central idea of the weak form is to turn this point-wise residual into an average, following the approach by Liu in [2], we start by creating an integral equation

0Lr(x)dx=0\int_{0}^{L}r(x)dx=0

here, we integrate the residual over the entire domain and set it to zero, we are basically saying that, on average, the residual should be zero. This essentially turns the strong form of the residual into a weak form, and given that we naively integrate it over the entire domain, we seem to have the equation hold "too weak". We could instead integrate (average) over a smaller region around some arbitrary point xx

xΔxx+Δxr(x)dx=0\int_{x-\Delta x}^{x+\Delta x}r(x)dx=0

thus we can control how far away from the point-wise zero point we are by varying Δx\Delta x. This idea can be extended to all locations in the domain x[0,L]x\in[0,L] and we end up with a set of integral equations that approximate the strong form of the differential equation

0x1r(x)dx=0,x1x2r(x)dx=0,,xN1Lr(x)dx=0\int_{0}^{x_{1}}r(x)dx=0,\int_{x_{1}}^{x_{2}}r(x)dx=0,\cdots,\int_{x_{N-1}}^{L}r(x)dx=0

where we have split the original domain into NN subdomains and thus we end up with a set of NN integral equations. The more subdomains we use, the better our approximation and in the limit we have that with NN\rightarrow\infty we get x1x2r(x)dxr(x)\int_{x_{1}}^{x_{2}}r(x)dx\rightarrow r(x).

Now, stating the weak form as a set of arbitrarily many integral functions is cumbersome and limits its potential, we can instead multiply the residual with a function, vv that is non-zero only in a narrow range. This function is known as the test function (a.k.a. weight function) and is arbitrary, meaning that it actually is a set of functions, in fact infinitely many. Another requirement on the test function is that it needs to be zero at the boundary where the solution is known, e.g., for our example above v(0)=0v(0) = 0. The solution u(x)u(x) is really also a member of the same set of functions as the test function. Therefore the solution is also known as the trial function.

We can now integrate the product r(x)v(x)r(x)v(x) over the entire domain [0,L][0,L] for a variety of functions v(x)v(x). The test functions limit the contribution of the residual to their respective subdomain and we achieve a similar effect as the set of integral equations above, see Figure 1 for an illustration of the concept.

1: Illustration of the idea behind the test function. Here vi(x)v_{i}(x) denotes the contribution of a test function in one node.
0Lr(x)v(x)dx=0v:v=0 where u is known\boxed{\int_{0}^{L}r(x)v(x)dx=0\quad\forall v:v=0\text{ where }u\text{ is known}}

In the above, v:v=0\forall v:v=0 reads: for all vv such that vv is zero at x=0x=0. This means that the integral has to hold for all arbitrary functions vv and that the test functions need to be constructed such that they all are 0 on the border where the solution, uu is known to ensure that boundary condition.

2: An illustration of an example set of test functions.

We end up with

0L[f(x)+ddx(kdudx)]v(x)dx=0\int_{0}^{L}\left[f(x)+\frac{d}{dx}\left(k\dfrac{du}{dx}\right)\right]v(x)dx=0

but what about the boundary conditions for the original model problem in (1)? Also, we have not really made things simpler with our integral equation, it still contains a second order derivative. We shall address both issues now with integration by parts.

Integration by parts

Recall the product rule:

ddx(p(x)g(x))=dpdxg+pdgdx\dfrac{d}{dx}\left(p(x)g(x)\right)=\frac{dp}{dx}g+p\dfrac{dg}{dx}

now integrate both sides

abddx(p(x)g(x))dx=abdpdxgdx+abpdgdxdx\int_{a}^{b}\dfrac{d}{dx}\left(p(x)g(x)\right)dx=\int_{a}^{b}\frac{dp}{dx}gdx+\int_{a}^{b}p\dfrac{dg}{dx}dx

Using the fundamental theorem of calculus:

abddx(p(x)g(x))dx=[p(x)g(x)]ab=p(b)g(b)p(a)g(a)\Rightarrow\int_{a}^{b}\dfrac{d}{dx}\left(p(x)g(x)\right)dx=\left[p(x)g(x)\right]_{a}^{b}=p(b)g(b)-p(a)g(a) [p(x)g(x)]ab=abdpdxgdx+abpdgdxdx\Rightarrow\left[p(x)g(x)\right]_{a}^{b}=\int_{a}^{b}\frac{dp}{dx}gdx+\int_{a}^{b}p\dfrac{dg}{dx}dx

Make the substitution p=kdudxp=k\frac{du}{dx} and g=vg=v and using (11) we get

[kdudxv]0L=0Lddx(kdudx)vdx+0Lkdudxdvdxdx\left[k\dfrac{du}{dx}v\right]_{0}^{L}=\int_{0}^{L}\dfrac{d}{dx}\left(k\dfrac{du}{dx}\right)vdx+\int_{0}^{L}k\dfrac{du}{dx}\dfrac{dv}{dx}dx 0Lddx(kdudx)vdx=0Lkdudxdvdxdx[kdudxv]0L\Rightarrow\int_{0}^{L}\dfrac{d}{dx}\left(k\dfrac{du}{dx}\right)vdx=\int_{0}^{L}k\dfrac{du}{dx}\dfrac{dv}{dx}dx-\left[k\dfrac{du}{dx}v\right]_{0}^{L}

Finally we add this to our integral from above

0Lkdudxdvdxdx[kdudxv]0L=0Lfvdx\int_{0}^{L}k\dfrac{du}{dx}\dfrac{dv}{dx}dx-\left[k\dfrac{du}{dx}v\right]_{0}^{L}=\int_{0}^{L}f v dx

and we end up with the weak form of our model problem

0Lkdudxdvdxdx=0Lf(x)v(x)dx+[kdudxv]0Lv:v=0 where u is known\boxed{\int_{0}^{L}k\dfrac{du}{dx}\dfrac{dv}{dx}dx=\int_{0}^{L}f(x)v(x)dx+\left[k\dfrac{du}{dx}v\right]_{0}^{L}\quad\forall v:v=0\text{ where }u\text{ is known}}

If we expand the last term we get

kdudx(L)v(L)kdudx(0)v(0)=0k\dfrac{du}{dx}(L)v(L)-k\dfrac{du}{dx}(0)\overset{=0}{\overbrace{v(0)}}

note that kdudx(L)=qk\dfrac{du}{dx}(L)=-q and that v(0)=0v(0)=0 since uu is known at x=0x=0, this is why we construct the test function in such a way.

We shall soon see that when solving the weak form, we seek a set of admissible solutions u(x)u(x) (a.k.a. trial solutions or trial functions).

We could have skipped the integration by parts and used the original weak form to create the finite element method but our test function would require to be two times differentiable, not a big issues in it self. Also, the resulting matrix system would not be symmetric, which is nice to have for the sake of performance. Furthermore, the boundary conditions would need special treatment.

The recipe for getting to the weak form

To create a weak form from a strong form the following steps are summed up.

Step 1: Multiply the strong form by a test function vv and integrate over the entire domain

Step 2: Integrate by parts

Minimum of potential energy

The model problem can also be formulated as a minimization problem: find uu such that F(u)F(v)F(u)\leq F(v) for all admissable functions vv, where

F(v)=120Lk(dvdx)2dx0Lfvdxkdvdx(L)v(L) F(v)=\dfrac{1}{2}\int_{0}^{L}k\left(\dfrac{dv}{dx}\right)^{2}dx-\int_{0}^{L} f v dx-k\dfrac{dv}{dx}(L)v(L)

The functional FF represents the potential energy of the physical system obeying the model problem, and thus the actual solution to our physical problem is the one that minimizes potential energy.

More on the weak formulation

There exist several alternative numerical methods for solving differential equations, e.g., the Finite Difference Method which is a more direct approach for solving differential equations. The reader might ask, why not just approximate the differential directly using e.g.,

dudxu(x+Δx)u(x)Δx and d2udx2u(x+2Δx)2u(x+Δx)+u(x)Δx2\dfrac{du}{dx}\approx\dfrac{u(x+\Delta x)-u(x)}{\Delta x}\text{ and }\dfrac{d^{2}u}{dx^{2}}\approx\dfrac{u(x+2\Delta x)-2u(x+\Delta x)+u(x)}{\Delta x^{2}}

which is indeed straight forward and will lead to a linear system of equations which is sparse, symmetric and efficient to implement and solve. The problem is that it is troublesome to use it in several dimensions for problems with even just a fairly complicated geometry. Arguably the FEM is more general and robust but not as straight forward and easy to implement.

The strength of the weak form

For some problems there exists a principle of minimum potential energy which leads to the weak form. These approaches usually are physics based and give a physical meaning to the test function, e.g., in mechanics the test functions are "virtual displacements" and the problem of finding the weak form is treated as a minimization of potential energy. It can be argued that the mathematical approach of multiplying the strong form by a test function and integrating by parts is more general since there might not exists a principle of minimum potential energy.

Not all physical problems can be idealized by simple models and sometimes discontinuities emerge in the models, either by the models them selves or by parameters of the models (material parameters in particular). These non-smooth functions cause the derivatives to be ill-defined, thus the strong form of the differential equation fails to describe the physics in each point and the integral formulation of the weak form better describes the physics on average.

Alex from Beyond the Big Bang YouTube channel did an outstanding introduction of the differential equation

ut+uux=0\dfrac{\partial u}{\partial t}+u\dfrac{\partial u}{\partial x}=0

and deriving the weak formulation.

A more detailed example of the strength of the weak form can be found in Section 4.4.1 in [1] where a 1D example is derived handling a discontinuous material parameter.

Examples

Example 1

Consider the residual function

r(x)=x+sin(7x)2+3 for x[0,1]r(x)=x+\dfrac{\sin(7x)}{2}+3\ \text{for }x\in[0,1]

if we split the domain into N=4N=4 equal subdomains and choose the test-function to be a linear function then for the second subdomain (or element), x[0.25 0.5]x \in [0.25\ 0.5], the test functions look like this

3: A test function for element 2

So every element is essentially made up of a set of functions, in this example, two, that multiply the residual function. If we take the sum of this product

i=1nr(x)vi(x)=r(x)\sum_{i=1}^{n}r(x)v_{i}(x)=r(x)

in our example n=2n=2, we see that for any xx if we multiply the test functions from one element with our residual function and take the sum then we get back the residual function! We will study this property in more details in upcoming sections.

Here is a animation to showcase this effect

4: The set of test functions for four elements.

In the above, every subdomain (element) has a set of test functions (in this case two), for which the linear combination yields the residual, or

i=12r(x)φi(x)=r(x) \sum_{i=1}^2 r(x)\varphi_i(x) = r(x)

where φi(x) \varphi_i(x) is known as the basis function when it is applied concretly on an element.

References

[1]
N. S. Ottosen and H. Petersson, Introduction to the finite element method. New York etc.: Prentice Hall, 1992, pp. xv + 410.
[2]
C. Liu, “A brief introduction to the weak form,” Nov. 19, 2014. https://www.comsol.com/blogs/brief-introduction-weak-form/