I have probably a very stupid problem. I can't solve a simple Poiseuille flow in a straight 2-D channel driven by a pressure drop. Results are complete nonsense. (Setting zero pressure on the outflow gives trivial solution/no flow. Taking pressure on the outflow non-zero (but still having some pressure drop) gives a solution flowing in to the channel from both ends). Also satisfying of the incompressibility is very vague. Could you, please, look at my code? I have no idea what I am doing wrong.
from dolfin import * mesh = Mesh("P.xml") V = VectorFunctionSpace(mesh,"CG",2) Q = FunctionSpace(mesh,"CG",1) W = V*Q w = Function(W) nu = 100 L = 20 noslip = DirichletBC(W.sub(0),(0,0),"on_boundary && (x > 4.0 - DOLFIN_EPS | x < DOLFIN_EPS)") inflow = DirichletBC(W.sub(1),10,"on_boundary && x < DOLFIN_EPS") outflow = DirichletBC(W.sub(1),2,"on_boundary && x > L - DOLFIN_EPS") bcs = [noslip,inflow,outflow] (u,p) = TrialFunctions(W) (v,q) = TestFunctions(W) f = Constant((0,0)) a = nu*inner(grad(u),grad(v))*dx + p*div(v)*dx + div(u)*q*dx L = inner(f,v)*dx problem = LinearVariationalProblem(a,L,w,bcs=bcs) solver = LinearVariationalSolver(problem) solver.solve() (u,p) = split(w) plot(p) plot(div(u)) plot(u) interactive()