FFC fails with conditionals which are functions of a dolfin Function
Issue #107
wontfix
Using conditionals which are functions of a dolfin Function no longer work. In this example specifically:
kappa = conditional(u > 1.0, u, 1.0)
The following code fails unless a uflacs representation is chosen:
from dolfin import *
import matplotlib.pyplot as plt
# Set uflacs representation, and the code runs
# parameters['form_compiler']['representation'] = 'uflacs'
mesh = UnitSquareMesh(32, 32)
V = FunctionSpace(mesh, 'Lagrange', 1)
u, v = Function(V), TestFunction(V)
du = TrialFunction(V)
kappa = conditional(u > 1.0, u, 1.0)
residual = dot(kappa*grad(u), grad(v))*dx
residual -= Constant(1.0)*v*dx
J = derivative(residual, u, du)
def on_bdry(x, on):
return on
bcs = [DirichletBC(V, Constant(1.0), on_bdry)]
problem = NonlinearVariationalProblem(residual, u, bcs=bcs, J=J)
solver = NonlinearVariationalSolver(problem)
solver.solve()
plot(u, backend='matplotlib')
plt.show()
The error reported:
File "lib/python2.7/site-packages/FFC-1.7.0.dev0-py2.7.egg/ffc/quadrature/quadraturetransformer.py", line 338, in conditional
"True value of Condtional should only be one function: " + repr(true))
Exception: True value of Condtional should only be one function: {((1, 'k', 3, 3),): 'FE0[0][k]'}
Comments (5)
-
-
reporter Including the code you suggested allows the script I wrote above to run correctly.
-
- changed status to wontfix
quadrature representation will be removed at some point so won't be fixed unless somebody really wants to submit a fix.
-
- removed milestone
Removing milestone: 1.7 (automated comment)
-
I use conditionals with functions as true or false values extensively. I hope that this feature will continue to be supported.
Also, I never experienced this bug until I upgraded to v. 2016.1.0 recently, and the above-mentioned fix worked for me.
- Log in to comment
Does it work if you do
at the top of the program? This enables the previously default workaround in ufl for this bug in ffc. Unfortunately the workaround produces silent nan values in some programs and thus shouldn't be default. With uflacs conditionals should now be treated correctly in all cases.