update variable using conditional statement


76
views
0
5 weeks ago by
hsk  
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
  0.00153726]
print Anew.vector().array()
[ 0.00057744  0.00021401  0.00011595 ...,  0.          0.00379583
  0.00247941]

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
2
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 4 weeks ago by Jan Blechta  
Thank you for the help about conditional statement
written 4 weeks ago by hsk  

1 Answer


1
5 weeks 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 4 weeks ago by hsk  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »