[petsc-users] On MatDestroy() in Fortran

Edoardo alinovi edoardo.alinovi at gmail.com
Sat Jul 30 13:42:22 CDT 2022


>
> Barry, Jacob,


Thank you very much for your clarification, I think the reference counting
is what is preventing matDestroy() from releasing the matrix memory.

Just to give you a bit of context, in my CFD code I am solving momentum,
pressure, plus two more equations for the turbulence model (k and omega). I
have seen that allocating a matrix  for each equation and keep it in memory
it's a bit optimistic for larger problems, so what I am trying to do is the
following:

do itime=1,ntimes

momentum equation:

allocate the matrix
fill the matrix
ksp-solve()
matDestroy()

pressure equation
allocate the matrix
fill the matrix
ksp-solve()
matDestroy()

k equation
allocate the matrix
fill the matrix
ksp-solve()
matDestroy()

omega equation
allocate the matrix
fill the matrix
ksp-solve()
matDestroy()

enddo

Matrices for momentum, pressure, k and omega have the same size but belong
to different objects so that's why I have 4 of them :)

The idea I have in mind is to destroy A after its use for each equation ,so
that the next equation matrix to be solved can pick up the memory freed
from the previous one. At the end of the story I'll just allocate space for
1 matrix and not 4, or at least this is what I am trying to achieve.

The thing is I do not destroy the ksp, so maybe that detail is preventing
my code from working as intended!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20220730/36dad7b7/attachment-0001.html>


More information about the petsc-users mailing list