update variable using conditional statement

9 months ago by
Hi, I want to update a variable for the time dependent problem. I have used conditional statement for that, which is as follows
print Aold.vector().array()
[ 0.00057744  0.00021401  0.00011595 ...,  0.          0.00212332
print Anew.vector().array()
[ 0.00057744  0.00021401  0.00011595 ...,  0.          0.00379583

history = conditional(gt(Anew, Aold), Anew, Aold )

Question: will conditional statement check variable element wise.
I am not getting the output always greater than my previous value.

Thanks for the help
Community: FEniCS Project
conditional used in a form will evaluate the arguments at quadrature points. If the functions are P1 or DP0 then it should be equivalent to your expected behaviour.
written 9 months ago by Jan Blechta  
Thank you for the help about conditional statement
written 9 months ago by hirshikesh  

1 Answer

9 months ago by
You can do something like this
import numpy as np

history = np.maximum(Anew.vector().array(), Aold.vector().array())​

history will be a numpy array. This makes sense for nodal basis functions.

Thanks for the help, It works for me
written 9 months ago by hirshikesh  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »