← Back to team overview

ufl team mailing list archive

Re: Restriction syntax

 

On Thu, May 14, 2009 at 5:59 PM, Garth N. Wells <gnw20@xxxxxxxxx> wrote:
>
>
> Martin Sandve Alnæs wrote:
>>
>> On Thu, May 14, 2009 at 9:43 AM, Anders Logg <logg@xxxxxxxxx> wrote:
>>>
>>> On Thu, May 14, 2009 at 08:40:41AM +0100, Garth N. Wells wrote:
>>>>
>>>> Martin Sandve Alnæs wrote:
>>>>>
>>>>> Is there a mathematical difference?
>>>>>
>>>> Splitting hairs, I would say yes and that grad(u('+')) is correct and
>>>> grad(u)('+') is not because grad(u) is not defined in a classical sense.
>>>> I prefer grad(u('+')), but FFC used to use grad(u)('+'). My preference
>>>> is however not strong.
>>>>
>>>> My immediate question is will the generated code differ for grad(u('+'))
>>>> and grad(u)('+')?
>>>>
>>>> Garth
>>>
>>> No, since the restriction will be propagated to the leaves... :-)
>>
>> The leaves are terminal expressions, that is literal constants,
>> geometric quantities, functions and basis functions.
>> "Propagating to the leaves" means modifying for example
>>
>>  (grad(f) + grad(g))('+')
>
> So the above works now? It would be super useful for me.

I don't know what FFC does.

But I implemented the propagation right now, only tested
for a simple case but it's a simple algorithm:

# test_restrictions.py:
from ufl import *

e = FiniteElement("DG", triangle, 1)
f = Function(e)
g = Function(e)
a = (grad(f) + grad(g))('-')
print a

from ufl.algorithms import propagate_restrictions

b = propagate_restrictions(a)
print b


martinal@martinal-znote:~/dev/fenics/ufl/sandbox/algorithmtests$
python test_restrictions.py
((grad(w_0)) + (grad(w_1)))('-')
(grad((w_0)('-'))) + (grad((w_1)('-')))


FFC just needs to apply propagate_restrictions to the integrand of
interior facet integrals.

Martin


Follow ups

References