Cavity driven flow : Form (<empty Form>) seems to be zero: cannot compile it.
I have implemented a NS solver for a cavity driven flow. The solver triggers the following error message (the code comes right after) :
>> python cavity_driven.py
No Jacobian form specified for nonlinear variational problem.
Differentiating residual form F to obtain Jacobian J = F'.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Form (<empty Form>) seems to be zero: cannot compile it.
Traceback (most recent call last):
File "cavity_driven.py", line 67, in <module>
solve(F == Constant(
File "/usr/lib/
_solve_
File "/usr/lib/
form_
File "/usr/lib/
J = Form(J, form_compiler_
File "/usr/lib/
common_cell)
File "/usr/lib/
return local_jit(*args, **kwargs)
File "/usr/lib/
return jit_compile(form, parameters=p, common_
File "/usr/lib/
return jit_form(
File "/usr/lib/
common_
File "/usr/lib/
analysis = analyze_
File "/usr/lib/
common_cell) for form in forms)
File "/usr/lib/
common_cell) for form in forms)
File "/usr/lib/
"Form (%s) seems to be zero: cannot compile it." % str(form))
File "/usr/lib/
condition or error(*message)
File "<string>", line 1, in <lambda>
File "/usr/lib/
raise self._exception
Exception: Form (<empty Form>) seems to be zero: cannot compile it.
_______
The code :
"""
Cavity driven flow for a square mesh.
u_top = (1.0,0.0)
_>_>_>_>_>_>_>_>_>_
| |
| |
| |
| |
| |
|______
No-slip at walls.
In this code we attempt to accomplish the following :
1) Solve the coupled problem for velocity and pressure for Re = 100.
"""
from dolfin import *
# Physical parameter
mu = Constant(100) # dynamic viscosity
# Dimensionless number
Re = Constant(100) # Reynold's number
# Velocities at the boundaries
u_top_lid = Constant((1, 0)) # Cavity driven
u_bottom_wall = Constant((0, 0)) # No-slip
u_side_walls = Constant((0, 0)) # No-slip
def bnd_Rside(
return on_boundary and near(x[0],1)
def bnd_Lside(
return on_boundary and near(x[0],0)
def bnd_top(
return on_boundary and near(x[1],1)
def bnd_bottom(
return on_boundary and near(x[1],0)
# Define the mesh and the mixed space
mesh = UnitSquare(50,50)
V = VectorFunctionS
Q = FunctionSpace(
VQ = V*Q
# The boundary conditions
bc1 = DirichletBC(
bc2 = DirichletBC(
bc3 = DirichletBC(
bc4 = DirichletBC(
bcs = [bc1,bc2,bc3,bc4]
# Make an initial guess
u = interpolate(
p = interpolate(
# The weak formulation
v,q = TestFunctions(VQ)
F = mu*inner(
Re*
# Solve and store in new functions
up_ = Function(VQ)
solve(F == Constant(
_______
The last triggers the error. What is the error message actually telling me ? Is the form F empty ?
There is also something else which seems strange. If i change F slightly by interchanging the position of the nonlinear term :
inner(grad(u)*u, v)*dx
as
inner(u*grad(u), v)*dx
I get a new error :
Product can only represent products of scalars.
Traceback (most recent call last):
File "cavity_driven.py", line 63, in <module>
Re*
File "/usr/lib/
return _mult(self, o)
File "/usr/lib/
p = Product(a, b[ii])
File "/usr/lib/
error("Product can only represent products of scalars.")
File "/usr/lib/
raise self._exception
ufl.log.
_______
I used inner(grad(u)*u, v)*dx initially as this was used in the NS demo.
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Jan Blechta
- Solved:
- Last query:
- Last reply: