← Back to team overview

ufl team mailing list archive

Re: grad() w.r. to a coefficient

 

On 6 July 2010 14:07, Patrick Riesen <priesen@xxxxxxxxxxxxxxx> wrote:
> Garth N. Wells wrote:
>>
>>
>> On 06/07/10 13:25, Patrick Riesen wrote:
>>>
>>> hello,
>>>
>>> i want to take the gradient of a coefficient with respect to some other
>>> quantity than the spatial coordinates (i.e. some other coefficient).
>>>
>>> i tried to construct a custom operator derived from diff() and the
>>> SpatialCoordinate/Derivative classes in ufl but after some point beyond
>>> my knowledge it always gets evaluated to zero by FFC then stops
>>> compiling with FFC : division by zero!
>>>
>>> does somebody of you experts know an approach to this?
>>>
>>
>> Did you try using 'variable'?
>>
>>    . . .
>>    v  = variable(v)
>>    f  = v*v
>>    df = diff(f, v)
>
> yes, but if f is a coefficient and not an expression of v, this won't work,
> i.e.,
>
> f = Coefficient(element)
> f = variable(f)
> v = SpatialCoordinates(cell)
> v = variable(v)
> df = diff(f, v)
>
> will end up as Type Zero, although this is equivalent to grad(f). that's the
> one case, and it v = Coefficient(element) as well, it will also be zero.
> if would be nice if where not zero :-)

The first example I get although I don't know why it does not work at
the moment, but it could be a bug. The second case where v is a
coefficient I don't get.
If f(x) = x**2, then df/dy = 0, I think that makes sense. Perhaps what
you want (or is trying to do) is described in this blueprint?

https://blueprints.launchpad.net/ufl/+spec/function-derivatoves

Kristian

> patrick
>
>> Garth
>>
>>> many thanks and best regards,
>>> patrick
>>>
>>> _______________________________________________
>>> Mailing list: https://launchpad.net/~ufl
>>> Post to : ufl@xxxxxxxxxxxxxxxxxxx
>>> Unsubscribe : https://launchpad.net/~ufl
>>> More help : https://help.launchpad.net/ListHelp
>>
>
>
> _______________________________________________
> 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