Easiest is to assemble into a distributed matrix from rank 0. So instead of calling MatCreate using PETSC_COMM_SELF, use a parallel communicator (like PETSC_COMM_WORLD). It is fine if only rank 0 calls MatSetValues, but all processes must call MatAssemblyBegin/End.
"Jaganathan, Srikrishna" <[email protected]> writes: > Hello, > > > I have been trying to distribute a already existing stiffness matrix in > my FEM code to petsc parallel matrix object , but I am unable to find > any documentation regarding it. It was quite straightforward to create a > sequential petsc matrix object and everything was working as intended.I > have read some of the user comments in the mailing lists regarding > similar situation and most of the times the solution suggested is to > create stiffness matrix from the the mesh in distributed format. Since > its a little difficult in my case to pass the mesh data in the code , is > there anyway to distribute already existing stiffness matrix ? > > Thanks and Regards > > Srikrishna Jaganathan
