DirichletBC on a set of subspaces

Hi,
I’d like to apply a DirichletBC on subspaces but only on a set of subspaces.

My Function space from Fenics-Shell Naghdi non linear:

element = MixedElement([VectorElement("Lagrange", triangle, 1),
                        VectorElement("Lagrange", triangle, 2),
                        FiniteElement("Lagrange", triangle, 1),
                        FiniteElement("N1curl", triangle, 1),
                        RestrictedElement(FiniteElement("N1curl", triangle, 1), "edge")])

U = ProjectedFunctionSpace(mesh, element, num_projected_subspaces=2)

U.sub(0) are variables (x,y) in plane displacement and U.sub(2) is z the out of plane displacement. I’d like to apply a DirichletBC on displacement (x,y,z) as a UserExpresion of (x,y,z).

I want something like that :

DirichletBC([U.sub(0)[0],U.sub(0)[1],U.sub(2)],Constant((0.0,0.0,0.0)),rightFace)

With an Expression instead of the Consant. But it should work with this constant for testing what I want to do.
Thanks

You would have to apply the bc on each individual sub space.

Hi Dokken,
Finaly I merged the field : vectorElement of dim 2 and the finiteElement of dim 1 into one vectorElement of dim 3 for my variables (x,y,z). It changes a little my formulation of the problem but mostly allow me to define the DirichletBC I wanted as a function of (x,y,z) on U.sub(0)

It does work but it could be a problem in case where someone want differents elements types or degree on a set of variables (x,y,z) but still want to define a boundary condition linking these 3 variables in a function. In my case it’s for a rotation in 3D so I need to define this BC on (x,y,z) at once.