using MPI and "total size of new arraymust be unchanged"

12 weeks ago by
Hello there,
I met a problem while using MPI.
part of my code is like:
Q = FunctionSpace(mesh, 'CG', 1)

g  = Function(Q)
tg = TestFunction(Q)

n = len(g.vector())

dgdx = assemble(tg*dx).get_local().copy().reshape([n,]) #<--here I have problem
volume = dgdx.sum()​
So I use mpirun -n number and my error is:
"ValueError: total size of new array must be unchanged"

I think this may be a very simple problem with mpi of python rather than of FEniCS.
but I am a new learner of HPC thus is there any suggestion about how to solve it?
Thanks a lot
Community: FEniCS Project

1 Answer

11 weeks ago by
That's because g.vector() gives you the length of the whole vector, no the local size on each process.

n = len(g.vector().get_local())​

should work.

It works. Thanks a lot!
written 11 weeks ago by SICHENG SUN  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »