Subject: [UFL-dev] derivatives of constants

From: Kristian Oelgaard <[email-masked]>
Date: Thu, 04 Sep 2008 22:07:06 +0200

Hi,

I think we've addressed this before, but I'm not sure when and what the outcome
was. The following 3 forms all result in the same code apart from some variable
names:

element = FiniteElement("Lagrange", "triangle", 1)

v = TestFunction(element)
u = TrialFunction(element)
f = Function(element)

c = Constant("triangle")

a = c*dot(grad(v), grad(u))*dx          # 0
a = dot(grad(v), mult(c, grad(u)))*dx   # 1
a = dot(grad(v), grad(c*u))*dx          # 2

The first two forms are basically identical. However, the latter results in 2
monomial terms that FFC must consider. This is obviously a waste of time since
one evaluates to zero anyway. Should analyze.py or something else pick this up?
How will this be dealt with in UFL? Or should it be handled in the compilers?

Kristian

---

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Fri, 5 Sep 2008 00:46:59 +0200

> How will this be dealt with in UFL? Or should it be handled in the compilers?

I believe I will implement automatic differentiation as algorithms
working directly on UFL.
I'll have to get back to the details later (hopefully I'll have
something working before the
end of the month).

--
Martin

---

From: Kristian Oelgaard <[email-masked]>
Date: Fri, 05 Sep 2008 08:22:50 +0200

> I believe I will implement automatic differentiation as algorithms

So, working directly on UFL inside UFL, or is it in FFC working on output from
UFL. What I mean is, will FFC (or any other form compiler) only 'see' the
non-zero terms?

> something working before the

Great.

Kristian

---

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Fri, 5 Sep 2008 08:39:24 +0200

> UFL. What I mean is, will FFC (or any other form compiler) only 'see' the

The UFL implementation consists of two parts: the language implementation
(a = ...*dx) and utility algorithms that the form compilers can use if
they wish.
Automatic differentiation is in the algorithm part, and yes, it will remove
nonzero terms. There will be differentiation w.r.t. x,y,z,
user-defined variables,
and Functions (Jacobi computation).

-- 
Martin