Here is my UFL code
element = FiniteElement("CG", tetrahedron, 2)
v = TestFunction(element)
theta = TrialFunction(element)
rho = Coefficient(element)
theta_n_1 = Coefficient(element)
idt = Constant(tetrahedron)
kappa = Coefficient(element)
uflow = ???
heat_a = idt*v*theta*dx + v*dot(uflow, grad(theta))*dx + kappa*dot(grad(v), grad(theta))*dx
heat_L = idt*v*theta_n_1*dx + v*rho*dx
rho, kappa, and theta_n_1 are user-defined functions that return scalars. There are OK (I define these as Expressions in the C++ code).
The problem is that uflow is a user-defined function that returns a vector. The Python version simply defines this as an Expression, but I need to have a UFL/C++ version of this.
How do I define uflow so it is a user-defined vector that works with the dot operator? (Note: VectorConstant complies under UFL, but I need it to be dependent on the coordinate positions, like I do with the ones I define as Coefficients.
Edit: It appears that creating a VectorElement and defining uflow to be a Coefficient based on that element solves the problem.
vector_element = VectorElement("CG", tetrahedron, 2, 3)
uflow = Coefficient(vector_element)
Can anybody confirm this?