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

Why are Expressions obtained via subclassing Expression in Python interpolated but not evaluated on

+8 votes

I have written code in Python using fenics, dolfin etc. to solve the three dimensional Schroedinger Equation. For my choice of potential and weight function I observer slow or non-existing convergence to theoretically known values. After counting the number of calls to the python class implementing the potential I realized, that this does not depend on the interpolation order chosen via parameters["form_compiler"]["quadraturedegree"] but is consistent with being called at all nodes of the interpolation. Is there a way to change a parameter such that the Expression is evaluated at all integration grid points, of course at the cost of much larger CPU time? I will not be able to use fenics for publishable results if this cannot be done/fixed

asked Jun 27, 2013 by moritzbraun FEniCS User (1,390 points)

1 Answer

+6 votes
 
Best answer

Expressions are interpolated in a finite element space. To control the space in which an Expression is interpolated, you can supply the finite element as an argument. Take a look at

http://fenicsproject.org/documentation/dolfin/1.2.0/python/programmers-reference/functions/expression/Expression.html#dolfin.functions.expression.Expression

for examples, especially Points 1 and 3.

If you want to evaluate an Expression at quadrature points, then define your Expression on a QuadratureElement, e.g.

element = FiniteElement("Quadrature", triangle, 3)

where 3 is the degree in the above case.

answered Jun 27, 2013 by Garth N. Wells FEniCS Expert (35,930 points)
selected Jun 28, 2013 by Garth N. Wells

Dear Garth

Thanks a lot for your answer.
I am now quite a lot wiser.
Thus, in order to increase my accuracy I need to use a higher order function space.
However, what I really would like Is a way to force dolfin to evaluate the
factors / functipns appearing in my bilinear form at all integration grid points!
Is there any way to achieve this without rewriting ffc etc from scratch?

regards

Moritz

I've edited my answer to also explain how to evaluate an Expression at quadrature points.

...