← Back to team overview

ufl team mailing list archive

Re: Zero form

 

On 2 November 2010 17:11, Johan Hake <johan.hake@xxxxxxxxx> wrote:
> On Tuesday November 2 2010 03:12:09 Kristian Ølgaard wrote:
>> 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.
>
> Thanks for the tip. The loop is a little bit more convoluted than showned here
> so I will probable stick to using Zero().

But still you could loop your forms, append to a list and then use reduce?

Kristian

>> 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?
>
> Thanks!
>
> Johan
>
>> 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