I figured it out, its a linear problem, I can do it as follows:
V = VectorFunctionSpace(mesh, 'P', 2)
Q = FunctionSpace(mesh, 'P', 1)
PPoint = 'near(x[0], 0.0) && near(x[1], 0.0)'
bcp = DirichletBC(Q, Constant(0.0), PPoint, 'pointwise')
p = TrialFunction(Q)
v = TestFunction(V)
F5 = dot(as_vector([px_,py_]) - grad(p), v)*dx
a = lhs(F5)
L = rhs(F5)
p = Function(Q)
solve(a == L, p, bcs=bcp)
But I get a dolfin error:
*** Error: Unable to apply boundary condition.
*** Reason: Dofmap ownership range (0,1089) does not match matrix row range (0,8450).
*** Where: This error was encountered inside BoundaryCondition.cpp.
*** Process: 0
The domain is a 0 to 1 square. What is the reason for this error?