[petsc-users] On MatDestroy() in Fortran

Edoardo alinovi edoardo.alinovi at gmail.com
Sat Jul 30 15:31:46 CDT 2022


Hello Barry,

* I assume you are calling KSPSetOperators() before each new KSPSolve() so
that it knows to solve a new system?*

Yes, I do.

This looks like a good trick:
KSPSetOperators(ksp,PETSC_NULL_MAT,PETSC_NULL_MAT)

So you would do:

1) KSPSetOperators(ksp,A,A)

2) KSPSolve(myksp, myrhs, mysol)

3) KSPSetOperators(ksp,PETSC_NULL_MAT,PETSC_NULL_MAT)

4) MatDestroy(A)

Am I right?

I'll have a try and I'll try to destroy the ksp of each equation as well.
The second is more tedious because I'll have to reconstruct it every time.
I'll do some tests to see if that helps.

Thanks a lot!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20220730/a9a61fc2/attachment.html>


More information about the petsc-users mailing list