Hi all, I would like to define a function (call it Func) of my trial function 'u' in a way that depends on the value of a different function (call it epsilon) of the trial function u.
My (naive?) attempt gives an error (ufl.log.UFLException: UFL conditions cannot be evaluated as bool in a Python context.)
Here is a sketch of my attempt:
class F(Expression):
def eval(self, value, x):
if tr(epsilon) >0:
value[0] = tr(epsilon)**2
else:
value[0] = -tr(epsilon)**2 + tr(epsilon)**2
Vv = VectorFunctionSpace(mesh, "Lagrange", 1)
u = TrialFunction(Vv)
epsilon = sym(nabla_grad(u))
Func = F()
Can someone tell me how this should actually be done? Do I need the class structure?
Thank you so much in advance!