Correctly setting initial conditions using Expression() in DG problem

I have discovered an issue when trying to use to avg and jump operators with expressions for the initial conditions in a DG problem. dolfin version ==2019.2.0.dev0

I have been unable to correctly define the expression on both sides of the facet - one side is always ~0. For example:

from fenics import *

mesh = UnitIntervalMesh(10)

V = FunctionSpace(mesh, 'DG', 1)

f = Expression('1', element = V.ufl_element())

# f = interpolate(f, V) #problem persists with or without interpolation step, which I have seen in other codes

print(project(avg(f), mesh=mesh).vector().get_local())

# prints list of 0.5s, but should print list of 1s as f=1 on both sides of each facet

Any insight would be greatly apprecited!

Maybe I’m missing something crucial, but I’m actually surprised this didn’t throw an error.

See the source. Note that it expects a formulation posed only within cell volumes. And consider Where to find 'project'-function in dolfinx? - #2 by nate.

The projection operation you’re proposing doesn’t make sense for an operator (avg(.)) defined on facets only. I’d suggest you construct your own projection operation as you require.

1 Like

Hi Nate, thanks for your answer that makes sense!

I am trying to debug a numerical flux made up of a combination of avg() and jump() operators. Erroneously, I’ve been using project() as a way to evaluate the result and observe the values at the facets. Is there a more correct way of doing this? (avg(f) is a Product object)

Make a manual projection operator, as nate suggests.
See for instance:


Ok thank you both, I will try this