### ufl index representation of an outer product

62

views

0

UFL offers:

$u\otimes v$

is there a way to write this in index notation? E.g:

$u_iv_j=\left(u\otimes v\right)_{ij}=$

I have naturally tried, but get the odd result:

$u\otimes v$

`u`⊗`v`= outer(u, v)is there a way to write this in index notation? E.g:

$u_iv_j=\left(u\otimes v\right)_{ij}=$

`u`_{i}`v`_{j}=(`u`⊗`v`)_{ij}=`u[i]*v[j]`

I have naturally tried, but get the odd result:

```
from dolfin import *
mesh = UnitSquareMesh(1, 1)
V = VectorFunctionSpace(mesh, "CG", 1)
u = Function(V)
print((u[i]*u[j]).ufl_shape)
>>> ()
```

I assume I'm missing something obvious?

Community: FEniCS Project

### 1 Answer

4

I think you need to use the function as_tensor to switch from the component representation to the tensor representation.

```
from dolfin import *
mesh = UnitSquareMesh(1, 1)
V = VectorFunctionSpace(mesh, "CG", 1)
u = Function(V)
print(as_tensor((u[i]*u[j]),(i,j)).ufl_shape)
>>> (2, 2)
```

1

Cheers very much! Found the corresponding part of the documentation to match:

http://fenics.readthedocs.io/projects/ufl/en/latest/manual/form_language.html#making-tensors-from-components

http://fenics.readthedocs.io/projects/ufl/en/latest/manual/form_language.html#making-tensors-from-components

written
8 weeks ago by
Nate

Please login to add an answer/comment or follow this question.