old release and new release for ubuntu

Asked by Fotini Karakatsani

Hello,

I implemented SUPG for convection-diffusion-reaction with parameters depending on Peclet number.
I need to compute a local minimum ...

In the previous version of FEnics everything was ok, now I try to compile it in the new one and there is an error message.
Here is my code

from dolfin import *

NUM_CELL = 64
mesh = UnitSquare(NUM_CELL,NUM_CELL)

h = CellSize(mesh)

# Create FunctionSpaces
V = FunctionSpace(mesh, "CG", 1)
W = FunctionSpace(mesh, "DG", 0)

# Boundaries case
def right(x, on_boundary): return x[0] > (1.0 - DOLFIN_EPS)
def left(x, on_boundary): return x[0] < DOLFIN_EPS
def bottom_center(x, on_boundary):
    return x[1] < DOLFIN_EPS and (x[0] > 1./3. - DOLFIN_EPS and x[0] < 2./3.0 + DOLFIN_EPS)
def bottom_lr(x, on_boundary):
    return x[1] < DOLFIN_EPS and (x[0] < 1./3. + DOLFIN_EPS or x[0] > 2./3.0 - DOLFIN_EPS)
def top(x, on_boundary):
    return x[1] > 1.0 - DOLFIN_EPS

g0 = Constant(0.0)
g1 = Constant(1.0)

# No-slip boundary condition for velocity
bc0 = DirichletBC(V, g1, bottom_center)
bc1 = DirichletBC(V, g0, bottom_lr)

bc3 = DirichletBC(V, g0, top)
bc4 = DirichletBC(V, g0, right)

# Collect boundary conditions
bcs = [bc0, bc1, bc4, bc3]

# Parameters
epsilon = Constant(0.00001)
c = Constant(0.0)
f = Constant(0.0)

b = Expression(('-x[1]', 'x[0]'))

uh = TrialFunction(V)

vh = TestFunction(V)
wh = TestFunction(W)

bb = assemble(dot(b,b)*wh*dx)
bF = Function(W,bb)

min_par = min(((sqrt(bF)*h)/(6.*epsilon)),1.0)

########################### SUPG METHOD ####################################

a1 = epsilon*dot(grad(uh), grad(vh))*dx + vh*dot(b,grad(uh))*dx +c*uh*vh*dx
a2 = h/(2.*sqrt(bF))*min_par*inner(dot(b, grad(uh)), dot(b, grad(vh)))*dx

a = a1 + a2
L = f*vh*dx + h/(2.*sqrt(bF))*min_par*h*f*dot(b, grad(vh))*dx

# Compute solution
uh = Function(V)
solve(a == L, uh, bcs)

and here is the error message
UFL conditions cannot be evaluated as bool in a Python context.
Traceback (most recent call last):
  File "supg_ex2.py", line 58, in <module>
    min_par = min(((sqrt(bF)*h)/(2.*epsilon)),1.0)
  File "/usr/lib/python2.7/dist-packages/ufl/conditional.py", line 50, in __nonzero__
    error("UFL conditions cannot be evaluated as bool in a Python context.")
  File "/usr/lib/python2.7/dist-packages/ufl/log.py", line 154, in error
    raise self._exception_type(self._format_raw(*message))
ufl.log.UFLException: UFL conditions cannot be evaluated as bool in a Python context.

What should I change?

Thank you in advance
Fotini

Question information

Language:
English Edit question
Status:
Answered
For:
FEniCS Project Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Johannes Ring (johannr) said :
#1

FEniCS no longer uses Launchpad for Questions & Answers. Please consult the documentation on the FEniCS web page for where and how to (re)post your question: http://fenicsproject.org/support/

Can you help with this problem?

Provide an answer of your own, or ask Fotini Karakatsani for more information if necessary.

To post a message you must log in.