### (Deleted) Convert a dolfin function into a ufl tensor

38
views
0
7 months ago by

I am working on an elasticity problem which has more than 1 unknown type, i.e. 2 vectors and 2 single value scalars. Since MixedFunctionSpace got deprecated, I have had to use the below workaround:

# Old version (before fenics 2.0) gives dolfin functions:
Vp = FunctionSpace(mesh, "CG", 1)
Vu = VectorFunctionSpace(mesh, "CG", 1)
V = MixedFunctionSpace([Vu, Vu, Vp, Vp])

# New version (suggested in the forums) gives ufl tensors:
p = 1
V_ele = VectorElement("CG", mesh.ufl_cell(), p)
F_ele = FiniteElement("CG", mesh.ufl_cell(), p)
V = FunctionSpace(mesh, MixedElement([V_ele, V_ele, F_ele, F_ele]))

This has been working fine so far, but now I need to do operations like + between the ufl tensors from above and dolfin functions which gives me this error:

unsupported operand type(s) for +: 'Product' and 'Form'

which makes sense. What I need is another workaround to MixedFunctionSpace that allows me to use functions, and not ufl tensors, or a way to convert my dolfin functions into ufl tensors and vice versa. Any help would be much appreciated.

Community: FEniCS Project
What is the line that is giving you the error?  Usually I get that error when I forget to add an integration measure somewhere, e.g., "a = inner(grad(u), grad(v))*dx + inner(u,v)" (where there should be a "*dx" on the last term).
written 7 months ago by David Kamensky
Thanks David. I thought the problem was way more sophisticated. As the answer to my problem, pointed out by you, has nothing to do with the questions that I asked, I am going to delete this post. Thanks again.
written 7 months ago by Navid Nazari