[petsc-users] Obtaining an Operator

David Scott d.scott at epcc.ed.ac.uk
Thu Jul 27 09:05:47 CDT 2017


Hello,

In my code I have

   call KSPSetComputeOperators(ksp_u, compute_matrix_u, 
PETSC_NULL_OBJECT, ierr)

later I have something like

   call KSPSolve(ksp_u, RHS_u_vec, u3_vec, ierr)
   call DMCreateMatrix(da_u, B, ierr)
   call compute_matrix_u(ksp_u, B, B, PETSC_NULL_INTEGER, ierr)
   call KSPGetOperators(ksp_u, A, PETSC_NULL_OBJECT, ierr)
   call MatEqual(A, B, flg, ierr)

inside a loop.

On the first iteration 'flg' is set to PETSC_TRUE but after that it is 
set to PETSC_FALSE. Why is that?

My code includes a hand-crafted iterative solver and I want to be able 
to evaluate the residual norm of the aproximate solution it produces 
using the matrix of an analogous PETSc solver. I am trying to determine 
the best way to obtain this matrix. In this case KSPSolve will not have 
been called and I want to know if I can obtain it using compute_matrix_u.

David

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.



More information about the petsc-users mailing list