[SOLVED] Conditional value of function
Asked by
Michael Bruckner
Hello everybody,
I am a new user and I can't figure out how to define a function value conditionally.
Here is a minimal snippet illustrating the problem :
from dolfin import *
mesh = UnitSquare(32, 32)
Q = FunctionSpace(mesh, "DG", 1)
phi_exp=
phi = project(phi_exp,Q)
step = 1. if phi > 0.5 else 1e-10
stepp = project(step,Q)
plot(stepp)
interactive()
The goal is to obtain a function where the value is 1 if phi >0.5, 0 elsewhere.
The code above gives 1 everywhere.
Can somebody tell me what is wrong here and how could I achieve a test on the function values ?
Thank you in advance,
Michael
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Martin Sandve Alnæs
- Solved:
- Last query:
- Last reply:
To post a message you must log in.