← Back to team overview

ufl team mailing list archive

Re: Importing Zero

 

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

On 28 April 2011 17:19, Johan Hake <johan.hake@xxxxxxxxx> wrote:
> 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
>
> On Thursday April 28 2011 02:14:17 Martin Sandve Alnæs wrote:
>> 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
>



References