[petsc-users] Obtaining an Operator
Barry Smith
bsmith at mcs.anl.gov
Thu Jul 27 12:14:31 CDT 2017
From the manual page:
Notes: The user provided func() will be called automatically at the very next call to KSPSolve(). It will not be called at future KSPSolve() calls
unless either KSPSetComputeOperators() or KSPSetOperators() is called before that KSPSolve() is called.
So you need to put something like
KSPSetOperators() immediately before the call to KSPSolve within your loop
> On Jul 27, 2017, at 9:05 AM, David Scott <d.scott at epcc.ed.ac.uk> wrote:
>
> 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