Mixed Vector Spaces

Dear Community,

I would like to use a mixed space involving three components: a vector function space of RT (so actually a tensor but for FEniCS a vector space I guess), a vector function space of CG and a scalar discontinuous space. I contruct the elements as follow:

RTel = VectorElement(s1, mesh.ufl_cell(), 1)
CGel = VectorElement(s2, mesh.ufl_cell(), 1)
DGel = FiniteElement(s3, mesh.ufl_cell(), 0)

I tried W = FunctionSpace(mesh, RTel * CGel * DGel)
but it does not seam to word, for instance if I consider W.sub(1), it is expecting a scalar, and the line
bcs = DirichletBC(W.sub(1),Constant((0.0, 0.0)) , DomainBoundary()) gives

** Error:   Unable to create Dirichlet boundary condition.
*** Reason:  Expecting a scalar boundary value but given function is vector-valued.
*** Where:   This error was encountered inside DirichletBC.cpp.
*** Process: 0
*** 

Thank you!

You can try

W = FunctionSpace(mesh, MixedElement[RTel, CGel, DGel])

which should give the expected result.
I think the * operator creates in this case an element like [ [ RTel, CGel ] , DGel ], which is why W.sub(1) returns something other than expected.

1 Like

Perfect, thank you!!