This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

What is the difference between interpolate() and project() ?

+21 votes

What is the difference between projecting a function 'f' onto a function space 'V' via

project(f,V)

and interpolating the function into a function space via

interpolate(f,V)

?

The documentation I've found provides little detail on what exactly either of these functions are supposed to do. I'm assuming that project() forms some minimum norm projection of the function onto the function space, but what norm is used for this projection (L2? H1? A norm associated with the function space V?)

asked Mar 20, 2015 by Nick Alger FEniCS User (1,490 points)

1 Answer

+18 votes
 
Best answer

Hi, let $V$ be the finite element function space with basis functions $\phi_i$ and degrees of freedom $L_j$ that satisfy $L_j(\phi_i)=\delta_{ij}$. Now take some function $u$ and suppose you want to create its interpolant $u_h\in V$. From $u_h=\sum U_i\phi_i$ you get by applying the functionals $L_j$ that the entries in the vector of expansion coefficients are $U_i=L_i(u)$. For elements with this nodal basis the interpolant is thus constructed simply by evaluating the degrees of freedom. Beware of the recently found bug - for enriched elements the basis might not be nodal, but the interpolant is constructed as if it were so, see here and here.

Projection $\pi_h u\in V$ of $u$ is a function that minimises $L:V\mapsto R$, $L(v)=1/2||v-u||_{L^2}$. This leads to a condition that $\pi_h u$ must solve: Find $w\in V$ such that
inner(w, v)*dx=inner(u, v)*dx. In other words projection is obtained by solving a linear system, see here.

answered Mar 24, 2015 by MiroK FEniCS Expert (80,920 points)
selected Mar 25, 2015 by Nick Alger
...