How do I get Expression from ccode like below ?
def myExpression():
from sympy.physics.vector import ReferenceFrame, curl, divergence, gradient
from sympy import sin, pi, symbols
from sympy.printing import print_ccode, ccode
x, y, z = symbols('x[0] x[1] x[2]')
R = ReferenceFrame('R')
u = sin(pi*x) * sin(pi*y) * sin(pi*z)
laplace_u = divergence(gradient(u, R), R)
print_ccode(u)
print_ccode(laplace_u)
Like above, I want to use Laplace u in my fenics code, how should I do?
I know like this:
import sym as sym
x, y, z = sym.symbols('x[0] x[1] x[2]')
u = 1 + x**2 + 2*y**2
var = [sym.printint.ccode(u)]
variable = Expression(var)
Thanks a lot !!!