Clarification on conditional expressions
Greetings
I have an inquiry regarding conditional expressions. I apologize in advance if this is more of a UFL issue than a Dolfin issue. I am trying to enforce limits on an expression (physically: species saturation). I am using something simple as follows:
f_limited = conditional(ge(f, limit), limit, f)
What I have noticed is that if I project f_limited for a quick plot, the conditional is not strictly honored. I am assuming this is due to the projection and nothing more, but I just want to check. The following is example code setup to replicate the issue, the limit is set to 5.0 but the maximum value of f_limited_projected turned out to be 5.03624. Is there a recommended method to inspect the limits (min/max) of an expression? Thank you very much in advance.
from dolfin import *
import numpy as np
# Create mesh and define function space
mesh = UnitSquare(32, 32)
V = FunctionSpace(mesh, "CG", 3)
f = Expression(
f_projected = project(f,V)
print "the maximum value of f is: %g"% np.max(
print "establishing a limit of 5 on the value of f"
limit = Constant(5.0)
f_limited = conditional(ge(f, limit), limit, f)
f_limited_projected = project(f_limited, V)
print "the maximum value of f_limited is: %g"% np.max(
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Johan Hake
- Solved:
- Last query:
- Last reply: