# interpolate function not equal to fe solution

Hi everyone,

I am new to FE and I was wondering what the difference between fenics interpolate and the actual calculation of my following code is:

import dolfin as df

import numpy as np

mesh = df.UnitInterval

f = df.Expression(

V0 = df.FunctionSpac

#V0 = df.FunctionSpac

Pf = df.interpolate(

df.plot(Pf)

u = df.TrialFunctio

v = df.TestFunction(V0)

a = u*v*df.dx

L = f*v*df.dx

s = df.Function(V0)

df.solve(a==L,s)

df.plot(s)

If I use interpolate with the discontinous galerkin degree 0 elements, I see a different solution than what (I assume) would be the actual calculation behind interpolate. With Lagrange 1 and DG higher order both results match nicely. Only for DG 0 I observe a difference. Is this a bug or am I missing something here?

Thanks,

SMF

(dolfin version 1.2.0)

Edit:

Digging further through the fenics book I realized that I do a projection onto the DG 0 Space, which gives the same answer in both cases. My follow up: what is the difference between project and interpolate of an expression? I understand that it matters in case of FE solutions but in case of Expressions I cannot see why project and interpolate should differ? (for DG 0)

## Question information

- Language:
- English Edit question

- Status:
- Answered

- Assignee:
- No assignee Edit question

- Last query:
- 2013-04-19

- Last reply:
- 2013-04-20

Jan Blechta (blechta) said : | #1 |

On Fri, 19 Apr 2013 21:26:11 -0000

SMF <email address hidden> wrote:

> New question #227077 on FEniCS Project:

> https:/

>

> Hi everyone,

>

> am new to FE and I was wondering what the difference between fenics

> interpolate and the actual calculation of my following code is:

>

> mesh = df.UnitInterval

> f = df.Expression(

> V0 = df.FunctionSpac

> #V0 = df.FunctionSpac

> Pf = df.interpolate(

> df.plot(Pf)

>

> u = df.TrialFunctio

> v = df.TestFunction(V0)

>

> a = u*v*df.dx

> L = f*v*df.dx

> s = df.Function(V0)

> df.solve(a==L,s)

> df.plot(s)

That is projection. Interpolation is just interpolating by function in

its dof vertices, not solving variational problem.

>

> If I use interpolate with the discontinous galerkin degree 0

> elements, I see a different solution than (what I assume) would be

> the actual calculation behind interpolate. With Lagrange 1 and DG

> higher order both results match nicely. Only for DG 0 I observe a

> difference. Is this a bug or am I missing something here?

>

> Thanks,

> SMF

>

> (dolfin version 1.2.0)

>

## Can you help with this problem?

Provide an answer of your own, or ask SMF for more information if necessary.