UFL index notation

Hi,
I think I’m understanding something wrong here. The following code doesn’t work.

from dolfin import *
from ufl import  indices

mesh = UnitSquareMesh(5,5)
V    = VectorFunctionSpace(mesh, 'CG',1)

A    = Constant(((1,2), (3,4)))
x    = Constant((5,6))

i,j  = indices(2)

u   = A[i,j]*x[i]
v   = project(u, V)

It says that the shape of u is (). I would expect the shape to be (2,).

Try the following:

from dolfin import *
from ufl import  indices

mesh = UnitSquareMesh(5,5)
V    = VectorFunctionSpace(mesh, 'CG',1)

A    = Constant(((1,2), (3,4)))
x    = Constant((5,6))

i,j  = indices(2)

u   = as_vector(A[i,j]*x[i], (j))
v   = project(u, V)
2 Likes