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

How does FEniCS integrate an expression?

+3 votes

I have a user-defined expression "fun" that is everywhere either 0.0 or -1.0. However, if I run

print assemble(conditional(lt(fun, const), 1.0, 0.0)*dx, mesh=mesh)

where const is -0.1, -0.2, -0.3, ..., then, although I would expect to obtain identical results, the results look like
"34.193..., 34.193..., 25.8265..., 25.8265..., 19.424...", i.e. it jumps whenever const reaches some threshold. Why is it? I thought that FEniCS uses some kind of Gaussian quadratures for integrating and fun is <-0.1 iff it is <-0.5.

asked Nov 5, 2013 by franp9am FEniCS Novice (590 points)
edited Nov 5, 2013 by franp9am

1 Answer

+2 votes

The FEniCS libraries interpolate functions in a finite element space. To be sure of which space it being using, you can supply a FiniteElement argument to an Expression.

If you want to have something evaluated at quadrature points, use a 'quadrature element'.

answered Nov 5, 2013 by Garth N. Wells FEniCS Expert (35,930 points)

Ok, thanks. So is it so that FEniCS chooses somehow some FunctionSpace on the mesh and computes something like the projection of the expression to this space first?

It doesn't project. It interpolates.

...