My original code is very long and I can only provide a small fraction of my code,I use gmsh with triangular 2D mesh with order 2, and here is the code I use to construct BC
V_p, V_u, V_T = V.sub(0), V.sub(1), V.sub(2)
V_u_collapsed, _ = V_u.collapse()
inlet_facets = ft.find(2)
p_inf_const = fem.Constant(domain, default_scalar_type(p_inf))
T_inf_const = fem.Constant(domain, default_scalar_type(T_inf))
zero_scalar = fem.Constant(domain, default_scalar_type(0.0))
bc_p_inlet = fem.dirichletbc(p_inf_const, fem.locate_dofs_topological(V_p, tdim - 1, inlet_facets), V_p)
u_inlet_func = fem.Function(V_u_collapsed)
u_inlet_func.interpolate(lambda x: np.vstack((np.full(x.shape[1], u_inf), np.zeros(x.shape[1]))))
bc_u_inlet = fem.dirichletbc(u_inlet_func, fem.locate_dofs_topological(V_u, tdim - 1, inlet_facets))
bc_T_inlet = fem.dirichletbc(T_inf_const, fem.locate_dofs_topological(V_T, tdim - 1, inlet_facets), V_T)
wall_facets = ft.find(1)
u_wall_func = fem.Function(V_u_collapsed)
u_wall_func.interpolate(lambda x: np.zeros((tdim, x.shape[1])))
bc_u_wall = fem.dirichletbc(u_wall_func, fem.locate_dofs_topological(V_u, tdim - 1, wall_facets))
symmetry_facets = ft.find(4)
bc_uy_symm = fem.dirichletbc(zero_scalar,
fem.locate_dofs_topological(V_u.sub(1), tdim - 1, symmetry_facets), V_u.sub(1))
bcs = [bc_p_inlet, bc_u_inlet, bc_T_inlet, bc_u_wall, bc_uy_symm]
then when I apply the BC to petsc vector, I use
fem.petsc.set_bc(Y_stage.x.petsc_vec, bcs)
Here Y_stage is a function on the mixed element space, the mixed element function space has 3 components with dimension 1,2,1, while I use the fem.petsc.set_bc, then some dofs are aplied with the dirichlet BC but some dofs correspond to the boundary are set to 0, is there any docs about it that match the best practices of FEnicsx0.9? thanks you very much