Cartesian product finite element spaces

I would like to create a vector valued finite element space. I know you can do VectorH1, but what if the number of components is not equal to the spatial dimension?

For example, suppose I want an H1 vector-valued function (defined on a 3-D mesh), with 5 components. How should I do it? I guess I could do this:

V = H1(mesh,order=k, dirichlet=“whatever”)
X = FESpace([V,V,V,V,V])

Would that work?

Also, is there a tensor-valued finite element space option? Say for symmetric matrices? That are trace-free?

That one shall work, but you need to then build your own differential operators.

The “MatrixValued” option can do tensors, which includes full tensor, symmetric, or deviatoric tensor. I guess the symmetric deviatoric tensor might be the one you are looking for.

e.g.,
Sigma = MatrixValued(H1(mesh, order=2), mesh.dim, symmetric=True, deviatoric=True)

Thanks for this. But there isn’t a way to set the number of components in VectorH1? That should be an option.

You can set the dimensions explicitly by

fes = H1(mesh, order=k, dim=5)

or using a product space with the syntax

fes = H1(mesh, order=k)**5

Best,
Michael