[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: further about PCComputeExplicitOperator()




Application of a preconditioner is almost always a dense operator. The only exception is sparse
approximate inverse and in fact this is why the sparse approximate inverse is a lousy preconditioner.
So I don't think you would ever want to compute the preconditioner into a sparse matrix.


If you want the SPAI preconditioner explicitly as a PETSc sparse matrix you should go into that
code, figure out how the SPAI stores its computed preconditioner and convert it to the PETSc
format.


Note also:
PCComputeExplicitOperator - Computes the explicit preconditioned operator.
this means it computes B*A or A*B (depending on left or right preconditioning). This beasty
(unless you use Jacobi preconditioning) is always dense and it makes no sense to store in
sparse format except for fun.


   Barry


On May 1, 2008, at 8:08 PM, Yujie wrote:

when 1 processor is used, the matrix M in PCComputeExplicitOperator(pc,&M) uses MATSEQDENSE type. Now, I want to use MATSEQAIJ, I change the codes as follows:
1563 if (size == 1) {
1564 //05/01/08
1565 //ierr = MatSetType(*mat,MATSEQDENSE);CHKERRQ(ierr);
1566 //ierr = MatSeqDenseSetPreallocation(*mat,PETSC_NULL);CHKERRQ(ierr);
1567 ierr = MatSetType(*mat,MATSEQAIJ);CHKERRQ(ierr);
1568 ierr = MatSeqAIJSetPreallocation(*mat, 0,PETSC_NULL);CHKERRQ(ierr);
1569
1570 } else {
1571 ierr = MatSetType(*mat,MATMPIAIJ);CHKERRQ(ierr);
1572 ierr = MatMPIAIJSetPreallocation(*mat,0,PETSC_NULL, 0,PETSC_NULL);CHKERRQ(ierr);
1573 }


PCApply is fast when running. However, MatSetValues() is very very slow when some arraies need to set. I find that the problem likely lies in
MatSeqXAIJReallocateAIJ(A,A->rmap.n, 1,nrow,row,col,rmax,aa,ai,aj,rp,ap,imax,nonew,MatScalar) in MatSetValues_SeqAIJ() after debugging the codes.
I can't further figure out where is the problem. Because it is difficult to debug. Could you give me some advice? thanks a lot.


the version of PETSc is 2.3.3-p8.

thanks a lot.

Regards,
Yujie