Outer product evaluation

Hi,

The way in which you are defining the vectors A and B generates “vectors” of second order. Therefore the outer product of A and B gives a fourth order tensor that doesn’t match the order of the TensorFunctionSpace, which is a 3x3 second order tensor. The following example should work

from fenics import *

mesh = BoxMesh(Point(0, 0, 0), Point(1, 1, 1), 1, 1, 1)

A = as_vector([1, 0, 0])
B = as_vector([0, 1, 0])

C = outer(A,B)

# For sake of clarity, always is a good idea to define
# the shape of the tensor function space
T = TensorFunctionSpace(mesh, 'CG', 1, shape=(3,3))
E = project(C, T)

To get the i-th component component of the tensor as a dolfin Function object you can use E.sub(i). If you want the dof value you should consider using dofmaps (see here for instance).

3 Likes