← Back to team overview

dolfin team mailing list archive

Re: [Question #159771]: Derivative of Expression

 

You can take the derivatives of an UFL expression, but not an
dolfin.Expression (which represents compiled code).

Try this for example:

from dolfin import *
mesh = UnitSquare(20, 20)
cell = mesh.ufl_cell()
x = cell.x
f = sin(2*pi*(x[0]**2 + x[1]**2))
plot(project(grad(f), mesh=mesh))
interactive()

Martin

On 31 May 2011 18:41, Praveen C <question159771@xxxxxxxxxxxxxxxxxxxxx> wrote:
> Question #159771 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/159771
>
> Praveen C gave more information on the question:
> I know I can interpolate and Expression and then take grad. But I am
> looking to see if there is some automatic differentiation of an
> Expression available in dolfin.
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dolfin
> Post to     : dolfin@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dolfin
> More help   : https://help.launchpad.net/ListHelp
>


References