[petsc-users] A very strange bug about using multiple KSPs

Sun, Hui hus003 at ucsd.edu
Tue Mar 3 01:22:08 CST 2015


I set up 2 KSPs through KSPSetComputeOperators, with separate compute matrix functions.



    ierr = KSPSetComputeOperators(ksp1,ComputeMatrix1,NULL);CHKERRQ(ierr);

    ierr = KSPSetComputeOperators(ksp2,ComputeMatrix2,NULL);CHKERRQ(ierr);

Within each computeMatrix function, I define the matrix, and I also print something to the screen. So


PetscErrorCode ComputeMatrix1(KSP ksp, Mat J,Mat jac, void *ctx)

{

    ......

    ierr    = PetscPrintf(PETSC_COMM_WORLD,"1\n");CHKERRQ(ierr);

    ......

}


PetscErrorCode ComputeMatrix2(KSP ksp, Mat J,Mat jac, void *ctx)

{

    ......

    ierr    = PetscPrintf(PETSC_COMM_WORLD,"2\n");CHKERRQ(ierr);

    ......

}


Now if I compile and execute the code, it only print 2, completely ignoring 1, which is not expected, since I have setup ksp1 to use ComputeMatrix1.

Does anyone know what might be wrong? Thank you. I have attached the short code here in this email as well.

Hui
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150303/c72cedd5/attachment.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.c
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150303/c72cedd5/attachment.c>


More information about the petsc-users mailing list