Great, thanks.

I'm using this to properly evaluate the hedgehog map to get second order convergence. Will try this out on Thursday.

all the best
--cjc

On 07/10/14 22:27, Lawrence Mitchell wrote:

On 7 Oct 2014, at 22:21, Colin Cotter <colin.cotter@imperial.ac.uk> wrote:

Just to be clear, does eval being to ufl?


Presuming you mean belong. No, it's Python that evaluates a string in the current environment. 

Eg

x=5
print eval("x")
=> 5

On 7 Oct 2014 21:52, "Lawrence Mitchell" <lawrence.mitchell@imperial.ac.uk> wrote:

On 7 Oct 2014, at 21:34, Colin Cotter <colin.cotter@imperial.ac.uk> wrote:

> Dear all,
>   I'm looking for a way to convert Sympy expressions into UFL expressions, where the symbols are Python functions. Any tips?

The sympy expression printers are tree visitors.  You could write one that visits the tree and produces a UFL tree.

Or, ugly but simpler in the short term:

stringify, replace the functions with the names of the appropriate UFL functions.  eval the resulting string.  urgh.

i.e.

x = Symbol('x')

string = str(exp(-x**2))

from firedrake import *

x = Function(V)

ufl_expr = eval(string)

Lawrence

_______________________________________________
firedrake mailing list
firedrake@imperial.ac.uk
https://mailman.ic.ac.uk/mailman/listinfo/firedrake

_______________________________________________
firedrake mailing list
firedrake@imperial.ac.uk
https://mailman.ic.ac.uk/mailman/listinfo/firedrake


_______________________________________________
firedrake mailing list
firedrake@imperial.ac.uk
https://mailman.ic.ac.uk/mailman/listinfo/firedrake