erronnorm, sum of expressions

Issue #220 invalid
Nico Schlömer created an issue

errornorm is a little to strict with its argument checking: Sums (of Expressions) aren't accepted although they are perfectly valid as exact solutions.

MWE:

from dolfin import *

mesh = UnitSquareMesh(20, 20)

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

u = Function(V)

ex0 = Expression('sin(x[0])')
ex1 = 1.0
#ex1 = Constant(1.0)

errornorm(ex0 + ex1, u)

One possible solution would be to treat the sum of Expressions (and products,...) as Expressions.

Comments (5)

  1. Anders Logg (Chalmers)

    The implementation of errornorm() is based on specifying an GenericFunction (user Expression or Function) as the exact solution. This is required since we need to know the exact function space (element) of the exact solution. If you specify a sum of Expressions, those may have different elements, and the function would not know what to do. If you have a sum, then interpolate that sum into a suitable higher order space before sending it into errornorm().

  2. Nico Schlömer reporter

    I've always been thinking of Expressions as expression in the mathematical sense, i.e., the sum of two expressions is an expression and so forth. Apparently, that's not quite the correct notion since "elements" (?) are associated with them. Is there any more detailed info available?

  3. Martin Sandve Alnæs

    Expression = dolfin type

    Expr = ufl type

    If you want to work with symbolic expressions, stick with ufl types and avoid Expression.

  4. Log in to comment