Subject: [FFC-dev] Getting NoneType from dot

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Fri, 12 Oct 2007 21:53:12 +0200

1) What is wrong with this form?
2) If it's a user mistake and not an ffc bug, ffc should raise an
exception and not return None

from ffc import *

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

v  = TestFunction(fe)
u  = TrialFunction(fe)
w  = Function(fe)

Dw = grad(w)
Du = grad(u)

uDw = dot(u, Dw)

print u
print Dw
print uDw # None!

wDu = dot(w, Du)

a = dot(v, uDw+wDu) * dx

-- 
Martin

---

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Fri, 12 Oct 2007 21:56:27 +0200

> fe = FiniteElement("Lagrange", "triangle", 1)

This should be:
fe = VectorElement("Lagrange", "triangle", 1)
but it doesn't change the None returned from dot.

> print uDw # None!

Output:

vi-1
[[w0_a9(dXa11/dx0) | ((d/dXa11)va9[0]), w0_a12(dXa14/dx1) |
((d/dXa14)va12[0])], [w0_a15(dXa17/dx0) | ((d/dXa17)va15[1]),
w0_a18(dXa20/dx1) | ((d/dXa20)va18[1])]]
None

-- 
Martin

---

From: Anders Logg <[email-masked]>
Date: Fri, 12 Oct 2007 22:28:39 +0200

>> 1) What is wrong with this form?

You take a dot product of a scalar with a vector (or a vector with a 
matrix in the vector case).

>> exception and not return None

Yes. Looking at operators.py, the "else" clause seems to be missing for 
the dot function.

/Anders

---

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Sat, 13 Oct 2007 00:01:14 +0200

> matrix in the vector case).

While I agree of course that the scalar case is wrong, I'd expect dot
to handle vector times matrix, the convection term is usually written
"u dot grad u".

-- 
Martin

---

From: Anders Logg <[email-masked]>
Date: Sat, 13 Oct 2007 00:48:21 +0200

> to handle vector times matrix, the convection term is usually written

Yes, we need to fix the dot operator.

In the meantime, do

   u[j]*D(u[i], j)

or

   w[j]*D(u[i], j)

/Anders