How to impose a Dirichlet bc on a vector sub-space?

As the error message says, the first input has to be a function.
In your code you invoke it with a Constant value:

V1, _ = ME.sub(1).collapse()
u_D = fem.Function(V1)
u_D.x.array[:] =1

boundary_dofs_b = fem.locate_dofs_topological((ME.sub(1), V1), fdim, boundary_facets)
bc_b = fem.dirichletbc(u_D, boundary_dofs_b, ME.sub(1))
3 Likes