Subject: [Ufl] Importing Zero

From: Martin Sandve Alnæs <[email-masked]>
Date: Thu, 28 Apr 2011 11:14:17 +0200

In r946 Zero was exposed to the ufl namespace. What is that used for?

from ufl.constantvalue import PermutationSymbol, Identity, Zero, as_ufl

If it's for internal ffc usage, it can be retrieved as from ufl.classes
import Zero.
If it's needed for users, I would rather add something like:

def zero(*shape):
    return Zero(shape)

Usage:
d = cell.d
v = zero(d)
M = zero(d, d)

For consistency and to hide the index dimensions details from the user.

Martin

---

From: Johan Hake <[email-masked]>
Date: Thu, 28 Apr 2011 08:19:26 -0700

I made that request. If you do not like just remove it and I will grab Zero 
from the library.

I use it to build UFL forms. I start out with a Zero form and then I use += to 
add stuff to it. But then I need a "form" to start with, and the Zero form 
fits that purpose. 

Any other suggestion of getting around that?

Kristian has already suggested collecting the forms in a list and then just do 
a reduce(operator.add, list_of_forms), which would work, but would make me re-
write some code ;)

Johan

---

From: Martin Sandve Alnæs <[email-masked]>
Date: Thu, 28 Apr 2011 17:36:49 +0200

I've added zero(*shape), so you can use that instead in the future.
Think I'll remove Zero before the next release.

You can also do as_ufl(0) to get a zero ufl scalar expression,
or possibly 0*dx to define a zero form.

I would make a list and use sum(myforms), or produce the forms
using a generator and use sum(myformgenerator())

Martin