Exception: Form (<empty Form>) seems to be zero: cannot compile it

Asked by Praveen C

Hello

I am getting this error for a simple problem below. I cannot understand the mistake. I am on version 1.0-beta

from dolfin import *

class Inlet(SubDomain):
   def inside(self, x, on_boundary):
      return ((x[0] < DOLFIN_EPS and x[1]-0.1 < DOLFIN_EPS) or \
              (x[1] < DOLFIN_EPS and x[0]-0.1 < DOLFIN_EPS)) and \
             on_boundary

class Outlet(SubDomain):
   def inside(self, x, on_boundary):
      return ((x[0]-1 > -DOLFIN_EPS and x[1]-0.9 > -DOLFIN_EPS) or \
              (x[1]-1 > -DOLFIN_EPS and x[0]-0.9 > -DOLFIN_EPS)) and \
             on_boundary

pinlet = 1.0
poutlet= 0.0

np = 50
mesh = UnitSquare(np, np)

sub_domains = MeshFunction("uint", mesh, mesh.topology().dim() - 1)
inlet = Inlet()
inlet.mark(sub_domains, 0)
outlet = Outlet()
outlet.mark(sub_domains, 1)

Q = FunctionSpace(mesh, "CG", 1)
r = TestFunction(Q)
q = TrialFunction(Q)

a = inner(grad(q), grad(r))*dx
pbc_inlet = DirichletBC(Q, pinlet, sub_domains, 0)
pbc_outlet = DirichletBC(Q, poutlet, sub_domains, 1)
pbc = [pbc_inlet, pbc_outlet]

#pressureProblem = LinearVariationalProblem(a, 0, p, pbc)
#pressureSolver = LinearVariationalSolver(pressureProblem)
#pressureSolver.solve()
p = Function(Q)
solve(a == 0, p, pbc)

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Johan Hake
Solved:
Last query:
Last reply:
Revision history for this message
Best Johan Hake (johan-hake) said :
#1

This is a bug:

  https://bugs.launchpad.net/bugs/846703

which has been fixed in the development version. Your right hand side is zero
and that is what triggers the bug.

Johan

On Friday October 7 2011 07:20:45 Praveen C wrote:
> New question #173554 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/173554
>
> Hello
>
> I am getting this error for a simple problem below. I cannot understand the
> mistake. I am on version 1.0-beta
>
>
> from dolfin import *
>
> class Inlet(SubDomain):
> def inside(self, x, on_boundary):
> return ((x[0] < DOLFIN_EPS and x[1]-0.1 < DOLFIN_EPS) or \
> (x[1] < DOLFIN_EPS and x[0]-0.1 < DOLFIN_EPS)) and \
> on_boundary
>
> class Outlet(SubDomain):
> def inside(self, x, on_boundary):
> return ((x[0]-1 > -DOLFIN_EPS and x[1]-0.9 > -DOLFIN_EPS) or \
> (x[1]-1 > -DOLFIN_EPS and x[0]-0.9 > -DOLFIN_EPS)) and \
> on_boundary
>
> pinlet = 1.0
> poutlet= 0.0
>
> np = 50
> mesh = UnitSquare(np, np)
>
> sub_domains = MeshFunction("uint", mesh, mesh.topology().dim() - 1)
> inlet = Inlet()
> inlet.mark(sub_domains, 0)
> outlet = Outlet()
> outlet.mark(sub_domains, 1)
>
> Q = FunctionSpace(mesh, "CG", 1)
> r = TestFunction(Q)
> q = TrialFunction(Q)
>
> a = inner(grad(q), grad(r))*dx
> pbc_inlet = DirichletBC(Q, pinlet, sub_domains, 0)
> pbc_outlet = DirichletBC(Q, poutlet, sub_domains, 1)
> pbc = [pbc_inlet, pbc_outlet]
>
> #pressureProblem = LinearVariationalProblem(a, 0, p, pbc)
> #pressureSolver = LinearVariationalSolver(pressureProblem)
> #pressureSolver.solve()
> p = Function(Q)
> solve(a == 0, p, pbc)

Revision history for this message
Praveen C (cpraveen) said :
#2

Thanks Johan Hake, that solved my question.