← Back to team overview

ufl team mailing list archive

Re: Zero form

 

On 2 November 2010 00:44, Johan Hake <johan.hake@xxxxxxxxx> wrote:
> Hello!
>
> I am automating the building of a ufl form. Something like:
>
>  # create list_of_forms
>  my_form = Zero()*dx
>  for form in list_of_forms:
>      my_form += form
>
> For the for loop to work I need to initate my_form to Zero()*dx, because it
> need to be a form.
>
> Any other ideas of how this can be done? If this is the only way can
> someone(TM) expose 'Zero' to the main ufl namespace?

my_form = reduce(lambda x,y:x+y, list_of_forms)

should do the trick.

On the other hand, I don't see a problem in exposing Zero in the ufl
namespace, it might be convenient in other cases too?

Kristian

> It resides in:
>
>  constantvalue.py
>
> Johan
>
> _______________________________________________
> Mailing list: https://launchpad.net/~ufl
> Post to     : ufl@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~ufl
> More help   : https://help.launchpad.net/ListHelp
>



Follow ups

References