Hi All,
thanks in advance for your help.
I have problems understanding how UFL conditions should be handled correctly.
Here is an example
import dolfin as dlfn
ScalarSpace = dlfn.FunctionSpace(mesh, 'DG', 0)
Yinit_value = 1.0
Yinit = dlfn.project(Yinit_value, ScalarSpace)
Y = dlfn.project(1.0/wf*(heavisideFunction(sigmaH)*K/2.0*eps_solve[k,k]**2
+mu*eps_solve_dev[i,j]*eps_solve_dev[j,i]), ScalarSpace)
Y is computed from a solution obtained solving a weak form. Results are as follows
Y.vector().array()
Out[80]:
array([ 3.59723591, 3.59723591, 3.59723591, 3.59723591, 3.59723591,
3.59723591])
Yinit.vector().array()
Out[81]: array([ 1., 1., 1., 1., 1., 1.])
I now want to do something like
if dlfn.conditional(dlfn.gt(Y,Yinit), 1, 0)==1:
print "True"
else:
print "False"
Unfortunately this gives "False" although Y > Yinit...
I also have a workaround
diff=Y.vector().array()-Yinit.vector().array()
diff[diff<0]=0 # set all values in diff which are <0 to zero
if diff.any()==True:
print "True"
My question is now, how does this work with UFL conditionals?
(without using arrays)
Also how would pointwise conditional operations on tensors of rank 2 work?
(is it necessary to formulate such for each component in an loop?)
Thanks, Philipp