This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Stationary Navier-Stokes: "All terms in form must have same rank."

+2 votes

To play around, I looked a naive implementation of the stationary Navier-Stokes problem

from dolfin import *

mesh = UnitSquareMesh(20, 20)

V = FunctionSpace(mesh, 'CG', 2)
W = MixedFunctionSpace([V, V])
P = FunctionSpace(mesh, 'CG', 1)
WP = MixedFunctionSpace([W, P])

up = Function(WP)
u, p = up.split()
v, q = TestFunctions(WP)

rho = 1.0
mu = 1.0
f = Expression(('0.0', '-1.0'))
F = dot(grad(u) * u, v) * dx \
    + dot(grad(p), v) * dx \
    + mu * inner(grad(u), grad(v)) * dx \
    + dot(f, v) * dx \
    + div(u) * q * dx

solve(F == 0, up)

The above yields the error

No Jacobian form specified for nonlinear variational problem.
Differentiating residual form F to obtain Jacobian J = F'.
All terms in form must have same rank.
[...]
ufl.log.UFLException: All terms in form must have same rank.

which I fail to interprete. Any hint on what's going wrong?

asked Jan 15, 2014 by nschloe FEniCS User (7,120 points)

1 Answer

+3 votes
 
Best answer

Replace

u, p = up.split()

by

u, p = split(up)

and I think it should be fine.

answered Jan 16, 2014 by mikael-mortensen FEniCS Expert (29,340 points)
selected Jan 16, 2014 by nschloe
...