9
$\begingroup$

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).

$\endgroup$

3 Answers 3

14
$\begingroup$

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.

$\endgroup$
7
  • 1
    $\begingroup$ 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? $\endgroup$
    – arocha
    Aug 31, 2017 at 17:18
  • $\begingroup$ Yes that sounds right to me! I found this book helpful for studying finite element methods beyond simpler problems like the Poisson equation. $\endgroup$ Aug 31, 2017 at 17:57
  • 2
    $\begingroup$ 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". $\endgroup$ Sep 1, 2017 at 3:01
  • $\begingroup$ 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. $\endgroup$
    – arocha
    Sep 1, 2017 at 9:10
  • $\begingroup$ 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 $\endgroup$
    – arocha
    Sep 1, 2017 at 9:15
5
$\begingroup$

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.

$\endgroup$
0
$\begingroup$

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}$$

$\endgroup$
9
  • $\begingroup$ 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. $\endgroup$
    – origimbo
    Aug 31, 2017 at 15:46
  • 1
    $\begingroup$ Also do you have a source for your claim of orthogonality? It's not true for the standard nodal basis for example. $\endgroup$
    – origimbo
    Aug 31, 2017 at 15:51
  • $\begingroup$ 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)? $\endgroup$
    – arocha
    Aug 31, 2017 at 15:52
  • $\begingroup$ 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. $\endgroup$
    – arocha
    Aug 31, 2017 at 15:55
  • $\begingroup$ @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). $\endgroup$
    – origimbo
    Aug 31, 2017 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.