← Back to team overview

ufl team mailing list archive

Patch to coefficient derivative of conditional

 

Hello,
I suggest change in ForwardAD algorithm for conditional. Let us
calculate derivative of conditional this way
  op = conditional(c[0], 1, 0)*t[1] + conditional(c[0], 0, 1)*f[1]
rather than like that
  op = conditional(c[0], t[1], f[1])

I think this patch enables other ffc/ufl algorithms to see linearity of
this derivative in variation and enables compiling of this example:
  elem = FiniteElement("CG", triangle, 1)
  u  = Coefficient(elem)
  v  = TestFunction(elem)
  du = TrialFunction(elem)
  F = conditional(ge(u, 0), u*u, 0)*v*dx
  J = derivative(F, u, du)

Best regards,
Jan Blechta

Attachment: ufl-blechta-2012-10-03.patch
Description: Binary data


Follow ups