Impose Velocity Profile on Inlet Face using Array

These should be

V = W.sub(0).collapse()
x_dofs = V.sub(0).dofmap().dofs()

etc.
Please reduce your example to a minimal problem, there are so many functions in this code that are not necessary to reproduce your error. See the guidelines in: Read before posting: How do I get my question answered? - #3