Wow, this:
print UU
threw a strange exception (at least to me):
UFL conditions cannot be evaluated as bool in a Python context.
Traceback (most recent call last):
File "foo.py", line 49, in <module>
print UU
File "/usr/lib/python2.7/dist-packages/numpy/core/numeric.py", line 1471, in array_str
return array2string(a, max_line_width, precision, suppress_small, ' ', "", str)
File "/usr/lib/python2.7/dist-packages/numpy/core/arrayprint.py", line 445, in array2string
separator, prefix, formatter=formatter)
File "/usr/lib/python2.7/dist-packages/numpy/core/arrayprint.py", line 248, in _array2string
'int' : IntegerFormat(data),
File "/usr/lib/python2.7/dist-packages/numpy/core/arrayprint.py", line 638, in __init__
max_str_len = max(len(str(maximum.reduce(data))),
File "/home/oyvinev/Work/FEniCS_1.3/lib/python2.7/site-packages/ufl/conditional.py", line 50, in __nonzero__
error("UFL conditions cannot be evaluated as bool in a Python context.")
File "/home/oyvinev/Work/FEniCS_1.3/lib/python2.7/site-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.
However, you can make this work by using Constants and Function.assign
UU = Function(V)
UU.assign(Constant(LinearCombCoef[0])*U0+Constant(LinearCombCoef[1])*U1+Constant(LinearCombCoef[2])*U2)