Could you share a bit more of your code ? There could be multiple issues here…
I also tried with the full F
and using automated derivative at first, it was clearly not worth trying to debug it. You do need to specify a direction for the derivative, like J=derivative(F, funW, [trial function)]
if you want it to work properly in assemble_system
(see https://fenicsproject.org/olddocs/dolfin/2017.2.0/python/programmers-reference/fem/formmanipulations/derivative.html).
Or, we could leverage the fact that writing J
explicitly is fairly trivial (NS is almost linear after all) :
u, p=split(TrialFunction(W))
u_b,_=ufl.split(funW) # Baseflow
v, w=split(TestFunction(W))
# Incompressibility
J = inner(div(u), w)
# Momentum (different test functions and IBP)
J += inner(grad(u_b)*u, v) # Convection
J += inner(grad(u)*u_b, v)
J += inner(grad(u), grad(v))*Constant(nu) # Diffusion
J -= inner(p,div(v)) # Pressure
I think that this should assemble fine.