1. petsc
  2. PETSc
  3. petsc

Commits

BarryFSmith  committed cfd3f46

MatDuplicate_SeqAIJ() could fail on the B matrix in a MPIAIJ matrix because the original blocksize may not apply to the B matrix once it has been "shrunk" for the matrix-vector product. Therefor only preserve blocksize if it is still valid.

  • Participants
  • Parent commits 3162be4
  • Branches master

Comments (0)

Files changed (1)

File src/mat/impls/aij/seq/aij.c

View file
  • Ignore whitespace
   PetscFunctionBegin;
   ierr = MatCreate(PetscObjectComm((PetscObject)A),B);CHKERRQ(ierr);
   ierr = MatSetSizes(*B,A->rmap->n,A->cmap->n,A->rmap->n,A->cmap->n);CHKERRQ(ierr);
-  ierr = MatSetBlockSizes(*B,A->rmap->bs,A->cmap->bs);CHKERRQ(ierr);
+  if (!(A->rmap->n % A->rmap->bs) && !(A->cmap->n % A->cmap->bs)) {
+    ierr = MatSetBlockSizes(*B,A->rmap->bs,A->cmap->bs);CHKERRQ(ierr);
+  }
   ierr = MatSetType(*B,((PetscObject)A)->type_name);CHKERRQ(ierr);
   ierr = MatDuplicateNoCreate_SeqAIJ(*B,A,cpvalues,PETSC_TRUE);CHKERRQ(ierr);
   PetscFunctionReturn(0);