Analabha Roy <[email protected]> writes:

> Progress Report:
>
>  So I modified my code to remove all the wrong usages of MatCopy where I
> was trying to AllScatter/AllGather a parallel matrix, and replaced with
> usage of MatGetRedundantMatrix(). The highlighted diff is
> here<http://goo.gl/yyJVcV>

Looks fine.

> Now, running it with 1 proc crashes, I guess because the documentation
> says<http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatGetRedundantMatrix.html>that
> only parallel matrices are supported by MatGetRedundantMatrix(), and
> running with 1 proc means the parallel matrices are sequantial (from what I
> read in the PetSc users manual).

You can use this to run on a single process.

  MPI_Comm_size(PetscObjectComm(PetscObject)mat,&size);
  if (size > 1) {
    MatGetRedundantMatrix(mat,&rmat);
  } else {
    rmat = mat;
    PetscObjectReference((PetscObject)rmat);
  }

(In parallel, rmat is a copy, but in serial, rmat is the same matrix.)

Attachment: pgpjUAX1_k44X.pgp
Description: PGP signature

Reply via email to