I am trying to calculate the reaction force for a set of DOFs in a hyperelasticity problem. This is how I am calculating it:
R = derivative(Pi, u, v) #Pi is the total potential energy
b=assemble(-R)
fint=b.copy()
Reaction=sum(fint[y_dofs_top]) #y_dofs_top is the set of DOFs where Dirichlet BCs are applied
This works perfectly fine in serial. In parallel however, each process calculates its own sum. How can I do the sum in parallel?
I am using a singularity image of FEniCS on a cluster.
Thank you in advance!
I made it work. I was confused about float because MPI.sum was not accepting an array/list of floats. But then I tried the following (which is not very intuitive to me) and it worked: