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


74
views
0
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 xxx.py 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


1
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.

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

Similar posts:
Search »