This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Discontinuous Galerkin / max of f('+'), f('-')

+4 votes

Is it possible to define a max as in:

V = FunctionSpace(mesh, 'DG', 1) 
f = Function(V) 
m = max(f('+'),f('-'))
asked Jun 20, 2013 by micdup FEniCS User (1,120 points)
edited Jul 2, 2013 by micdup

1 Answer

+7 votes
 
Best answer

You probably want to use the ufl Max instead of python builtin max.

Mikael

answered Jun 20, 2013 by mikael-mortensen FEniCS Expert (29,340 points)
selected Jun 21, 2013 by Jan Blechta

How can I do that in a python script ?
I cannot find the function Max.
Thanks

Perhaps you have an older ufl version and Max is not avaiable yet? In that case you can define it yourself as

def Max(x, y):
    return conditional(gt(x, y), x, y)

I will use your function.
Thanks a lot.

...