UFL expand_derivatives/indices fail with conditional in FEniCS dev

Issue #82 resolved
Marie Elisabeth Rognes created an issue

The below example fails with "ufl.log.UFLException: Component size mismatch." in FEniCS dev. Does not fail with 1.6

from dolfin import *
from ufl.algorithms import expand_derivatives, expand_indices

mesh = UnitSquareMesh(2, 2)
V = VectorFunctionSpace(mesh, "CG", 1, dim=5)
v = Function(V)
V = v[0]
a = grad(conditional(lt(V, -40), exp(-V), 0))[0]*dx
print a
expand_indices(expand_derivatives(a))

Comments (5)

  1. Marie Elisabeth Rognes reporter

    UFL only example for easier debugging

    from ufl import *
    from ufl.algorithms import expand_derivatives, expand_indices
    
    Q = FiniteElement("CG", triangle, 1)
    V = Coefficient(Q)
    a = grad(conditional(lt(V, -40), V, 0.0))[0]
    print "a = ", a
    b = expand_derivatives(a)
    print "b = ", b
    c = expand_indices(b)
    print "c = ", c
    
  2. Marie Elisabeth Rognes reporter

    The (temporary) solution is of course:

    import ufl
    ufl.algorithms.apply_derivatives.CONDITIONAL_WORKAROUND = True
    

    cf

    commit ae59864654596d2e3aa4c7c5067bdd57e8b62a4e
    Author: Martin Sandve Alnæs <martinal@simula.no>
    Date:   Thu Mar 3 08:15:01 2016 +0100
    
        Make the bugfix in conditional derivatives to avoid inf/nan values in
        generated code default behaviour. This bugfix may break ffc if uflacs
        representation is not used, and if you hit this issue the old
        workaround in ufl can be enabled by setting
    
        ufl.algorithms.apply_derivatives.CONDITIONAL_WORKAROUND = True
    
        at the top of your fenics program.
    
  3. Log in to comment