[petsc-users] A very strange bug about using multiple KSPs
Dave May
dave.mayhem23 at gmail.com
Tue Mar 3 03:11:33 CST 2015
Try moving your print statement in ComputeMatrix2 to be after
PetscFunctionBeginUser;
You should really use a debugger to see if these functions are being called
or not - don't use print statements.
On Tuesday, 3 March 2015, Sun, Hui <hus003 at ucsd.edu> wrote:
> 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/01883ebc/attachment.html>
More information about the petsc-users
mailing list