diff --git a/python/dune/perftool/ufl/execution.py b/python/dune/perftool/ufl/execution.py index b7942c9467f5d3e83d665b847da6e660c7f0fcac..30a5b915721d81147ded0fba9946dc0e2f23ae05 100644 --- a/python/dune/perftool/ufl/execution.py +++ b/python/dune/perftool/ufl/execution.py @@ -12,7 +12,7 @@ from ufl import * class TrialFunction(ufl.Coefficient): """ A coefficient that always takes the reserved index 0 """ def __init__(self, element, count=None): - if count and count is not 0: + if count is not None and count != 0: raise PerftoolUFLError("The trial function must be the coefficient of index 0 in uflpdelab") ufl.Coefficient.__init__(self, element, count=0) @@ -20,12 +20,14 @@ class TrialFunction(ufl.Coefficient): class Coefficient(ufl.Coefficient): """ A coefficient that honors the reserved index 0. """ def __init__(self, element, count=None): - if count and count is 0: + if count == 0: raise PerftoolUFLError("The coefficient of index 0 is reserved for the trial function in uflpdelab") - if count and count is 1: + if count == 1: raise PerftoolUFLError("The coefficient of index 1 is reserved for the jacobian apply vector in uflpdelab") - if not count and ufl.Coefficient._globalcount < 2: - count = 2 + if count == 2: + raise PerftoolUFLError("The coefficient of index 2 is reserved for the time variable in uflpdelab") + if count is None and ufl.Coefficient._globalcount < 3: + count = 3 ufl.Coefficient.__init__(self, element, count)