9

I'm a novice to finite element and I'm finding quite hard to find the actual difference between Test function(s) and Basis function(s). I would be glad if somone could explain me that and point out how can they differ from one another and in which cases its useful that they differ (or not).

arocha
  • 93
  • 1
  • 5

3 Answers3

14

Suppose that the solution $u$ of the PDE lives in some function space $X$. We'll write the PDE as a bilinear form

$A(u, v) = f(v)$

for all $v$ in $X$, where $f$ is some element of the dual space $X^*$.

To approximate the solution $u$ of this PDE, we can instead look for some field $u_N$ that lives in a finite-dimensional subspace $V_N$ of $X$. Typically, we pick this finite-dimensional subspace by choosing a set of functions $\{\phi_1, \ldots, \phi_N\}$ and setting $V_N$ to be the span of these functions, in which case we can write

$u_N = \sum_{n = 1}^NU_n\phi_n$,

where $\{U_n\}$ are the coefficients of $u_N$ in this basis. The functions $\{\phi_1,\ldots,\phi_N\}$ that we use to describe the solution are the basis functions.

Finally, to reduce our infinite-dimensional problem to a finite-dimensional one, we pick another finite-dimensional subspace $W_N$ of $X$, and choose the coefficients of $u_N$ so that it is the solution of the (finite-dimensional) linear system

$A(u_N, \psi) = f(\psi)$

for all $\psi$ in $W_N$. Much like with how we selected the basis functions, we can instead write $W_N$ as the span of a set of functions $\{\psi_1,\ldots, \psi_N\}$. The functions $\{\psi_1,\ldots,\psi_N\}$ that we integrate against are the test functions. In that case, we can form the matrix $\mathscr{A}$ with entries

$\mathscr{A}_{ij} = A(\phi_j, \psi_i)$,

in which case the linear system can be written in terms of the vector $U$ of coefficients as

$\mathscr{A}U = F$.

Note that the basis functions and the trial functions do not have to be the same thing. What we need in order for the finite-dimensional approximations $u_N$ to converge to $u$ as we take larger and larger approximation spaces is that (1) the finite-dimensional problem is solvable for every $N$ and (2) a stability property, guaranteeing that $\mathscr{A}^{-1}$ is bounded as $N \to \infty$.

You could be forgiven for finding this confusing because, for self-adjoint linear elliptic PDE, the basis and test spaces are almost always the same, so people usually talk about the two spaces as if they're one and the same thing. For nice elliptic PDE, taking $W_N = V_N$ guarantees that the linear system is symmetric, and you can also prove that the approximation is quasi-optimal in a certain sense, so there's little reason to do otherwise.

However, for other kinds of PDE, it can be advantageous to use different basis and test spaces. For example, consider an advective transport problem

$w\cdot \nabla q = f$,

where $w$ is a vector field and we want to solve for $q$. Using the same basis and test functions can lead to lots of oscillatory artifacts. A popular approach to combat this is the streamline upwind Petrov-Galerkin discretization. Suppose that the advection is along a vector field $w$, and let $\phi_n$ be a basis function. The test function $\psi_n$ is then defined in terms of the basis function and the advection field as

$\psi_n = \phi_n + \alpha w\cdot\nabla\phi_n$,

where $\alpha$ is an appropriately-selected parameter. The resulting equation is similar to upwind finite differencing, with similar improvements to numerical stability. In this case, the original problem isn't symmetric or necessarily even positive-definite. There's no symmetry to preserve by taking the basis and test spaces to be identical.

Wolfgang Bangerth
  • 55,373
  • 59
  • 119
Daniel Shapero
  • 10,263
  • 1
  • 28
  • 59
  • 1
    perfect. after some processing time, I think I understood what you meant. Put simple in novice (or user engineer) words: we integrate against the test functions but describe the solution in terms of the basis functions. Am I correct? – arocha Aug 31 '17 at 17:18
  • Yes that sounds right to me! I found this book helpful for studying finite element methods beyond simpler problems like the Poisson equation. – Daniel Shapero Aug 31 '17 at 17:57
  • 2
    As a point of notation, somewhat hidden in @DanielShapero's otherwise excellent answer: If you choose $W_N=V_N$, then we call the method a "Galerkin method". If you choose $W_N\neq V_N$, then we call the method a "Petrov-Galerkin method". – Wolfgang Bangerth Sep 01 '17 at 03:01
  • thanks for that book reference. I'm currently taking a Coursera from University of Michigan on the topic but it seems quite basic so far @WolfgangBangerth I've came across that name (Petrov-Galerkin method) in my research and that exactly where my doubt came up: it was same that in Petrov-Galerkin the basis and test functions were different. – arocha Sep 01 '17 at 09:10
  • btw, ca I get a quick explanation of what do u mean by self-adjoint linear elliptic PDE. I don't get the self-adjoint part – arocha Sep 01 '17 at 09:15
  • @aroche I agree, the coursera class on finite element from U of Michigan is indeed slightly basic, but I think it does manage to find a good balance between rigor and being easy to understand (I am in no way affiliated to it). I have not seen that many professors succeed in such an endeavour. – BlaB Sep 01 '17 at 17:18
  • If you're not familiar with the term "self-adjoint": The Laplace equation is self-adjoint, so you can always take that as an example. – Wolfgang Bangerth Sep 02 '17 at 01:06
5

I'll try to give a short answer.

Basis functions are those that you want in your solution. Test functions are those that you don't want in your residual.

You want them to be same in Bubnov-Galerkin method. The (Bubnov-Galerkin collab) want you, not to be able to build the residual with the same functions you used to build the solution. How can you do that? Well, e.g. by testing the orthogonality of each of the functions you used to build the solution, and the residual.

Johntra Volta
  • 1,403
  • 9
  • 14
0

Formally a test function $\psi$ is a function that belongs to a function space $\mathcal{V}$. If you select among all test functions of such function space one type, e.g. polynomials of second order $\varphi\in\mathcal{P}_2(x)$, you can depompose any function $f(x)$ in terms of this basis. Take into account, for example that the basis vectors (i.e. basis functions) are orthogonal to each other, i.e.: $$ \int_{-L}^{L}{\varphi_i(x)\varphi_k(x)\,dx}=\delta_{ik}\tag{*}$$ Because $f(x)$ is defined as the linear combination of basis functions (do you remember that this is analogous to vector space?): $$f(x) = \sum_n{a_i\varphi_i(x)} \tag{**}$$ To find $a_n$ multiply scalarly the last equation $(**)$ by $\varphi_k$ and apply $(*)$

$$\int_{-L}^{L}{f(x)\varphi_k(x)\,dx}=a_i\int_{-L}^{L}{\varphi_i(x)\varphi_k(x)\,dx}=a_{k}$$

HBR
  • 1,638
  • 8
  • 7
  • While I understand the necessity not to make things complex for a novice, this explanation makes the distinction between the trial and test function spaces a bit fuzzy, which is an area where having distinct spaces is a bit more meaningful. – origimbo Aug 31 '17 at 15:46
  • 1
    Also do you have a source for your claim of orthogonality? It's not true for the standard nodal basis for example. – origimbo Aug 31 '17 at 15:51
  • Thanks for the answer. I understand that the basis functions are in a subspace of the test functions space. The point is that, when I was doing my research on the topic, at some point it was pointed out that to solve non-linear problems (like NS), some times its useful that the test functions and basis functions are different. I don't undestand that statement because they are fundamentally different to begin with! Does this have something to do with using different order Lagrange polynomials for different dependent variables (quadratic for velocities and linear for pressure)? – arocha Aug 31 '17 at 15:52
  • Yes, the orthogonality thing is not true but I understood the point - their inner products between each other give mostly 0, unless they're in neighbouring nodes or are the same. – arocha Aug 31 '17 at 15:55
  • @arocha Are you sure your source wasn't saying the test function and trial function spaces are different? There's no automatic constraint that when testing $\int uv, dx =\int uf, dx$ that $u$ and $v$ have to come from the same function space (and thus have the same basis). – origimbo Aug 31 '17 at 15:57
  • @origimbo Yes, I'm sure - the source is here in the last section (Additional Finite Element Formulations). But I noticed that they refer to the Petrov-Galerkin method... Oops. Yet I don't understand. – arocha Aug 31 '17 at 16:03
  • @arocha Ah, you've run into poorly written English. The statement being made is just that different variables have different trial spaces, as you thought. Since these trial spaces are different, they then require different numbers of basis functions to generate a representation – origimbo Aug 31 '17 at 16:21
  • @arocha This is not poor english. If basis functions are $\varphi_i$. The test functions can be chosen as the basis functions $\varphi_i$ or other types, e.g Petrov-Galerkin test functions are $$\tilde{\varphi}_i=\varphi_i+\tau(\Delta x,\mu,|\vec{v}|)\vec{v}\cdot\vec{\textrm{grad}}\varphi_i$$Where $\tau$ is a function of the mesh size $\Delta x$, the viscosity of the fluid $\mu$ and its velocity $\vec{v}$. These types of functions are really relevant in convection dominated flows because the converctive term breaks the natural symmetry of the finite element basis. – HBR Aug 31 '17 at 16:23
  • @HBR so to clarify if I understood: We have the basis functions $\varphi_i$ that we use as a basis to the solution. But we insert those weird test functions in to the weak form equations to solve it? – arocha Aug 31 '17 at 16:36