Subject: [UFL-dev] [Bug 461775] [NEW] form errors related to zeros

From: oelgaard <[email-masked]>
Date: Tue, 27 Oct 2009 09:47:41 -0000

Public bug reported:

The following form crashes with

AttributeError: 'Zero' object has no attribute '_expressions'

element = VectorElement("Lagrange", triangle, 1)
v =  TestFunction(element)
du = TrialFunction(element)

U = Function(element)

def planarGrad(u):
  return as_matrix([[u[0].dx(0),      0     ,u[0].dx(1)],
                              [    0     ,          0     ,     0        ],
                              [u[1].dx(0),      0     ,u[1].dx(1)]])

def epsilon(u):
  return 0.5*(planarGrad(u)+planarGrad(u).T)

def NS_a(u,v):
  return inner(epsilon(u),epsilon(v))

L = NS_a(U,v)*dx
a = derivative(L, U, du)

** Affects: ufl
     Importance: Undecided
         Status: New

-- 
form errors related to zeros
https://bugs.launchpad.net/bugs/461775
You received this bug notification because you are subscribed to UFL.

Status in Unified Form Language: New

Bug description:
The following form crashes with

AttributeError: 'Zero' object has no attribute '_expressions'

element = VectorElement("Lagrange", triangle, 1)
v =  TestFunction(element)
du = TrialFunction(element)

U = Function(element)

def planarGrad(u):
  return as_matrix([[u[0].dx(0),      0     ,u[0].dx(1)],
                              [    0     ,          0     ,     0        ],
                              [u[1].dx(0),      0     ,u[1].dx(1)]])

def epsilon(u):
  return 0.5*(planarGrad(u)+planarGrad(u).T)

def NS_a(u,v):
  return inner(epsilon(u),epsilon(v))

L = NS_a(U,v)*dx
a = derivative(L, U, du)

---

From: oelgaard <[email-masked]>
Date: Tue, 27 Oct 2009 09:51:43 -0000

A funny thing is that doing:

L = NS_a(U,v)*dx
#a = derivative(L, U, du)

compilation fails with:
ufl.log.UFLException: Form is not multilinear in basis function arguments.

And similarly if we do:

def NS_a(u,v):
  return inner(planarGrad(u), planarGrad(v))

L = NS_a(U,v)*dx
a = derivative(L, U, du)

compilation also fails with:
ufl.log.UFLException: Form is not multilinear in basis function arguments.

Bug description:

U = Function(element)

def planarGrad(u):

def epsilon(u):

def NS_a(u,v):

L = NS_a(U,v)*dx
a = derivative(L, U, du)

---

From: oelgaard <[email-masked]>
Date: Wed, 28 Oct 2009 08:19:29 -0000

After some more digging around it turns out that if one uses:
 forms = [L, a]

compilation fails with:

for both definitions of NS_a() i.e.,

def NS_a(u,v):

or

def NS_a(u,v):

I guess that stripping the form of any Zeros before checking for
validity and taking derivatives will solve the problem. Is there a
reason not to do this?

Bug description:

U = Function(element)

def planarGrad(u):

def epsilon(u):

def NS_a(u,v):

L = NS_a(U,v)*dx
a = derivative(L, U, du)